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; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 564 | image_create_info.samples = 1; |
| 565 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 566 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 567 | image_create_info.flags = 0; |
Mark Lobodzinski | 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, |
| 639 | // .samples = 1, |
| 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; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 711 | image_create_info.samples = 1; |
| 712 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 713 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 714 | image_create_info.flags = 0; |
Mark Lobodzinski | 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, |
| 846 | .samples = 1, |
| 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 = {}; |
| 901 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 902 | dsl_binding.arraySize = 1; |
| 903 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 904 | dsl_binding.pImmutableSamplers = NULL; |
| 905 | |
| 906 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 907 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 908 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 909 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 910 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 911 | |
| 912 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 913 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 914 | ASSERT_VK_SUCCESS(err); |
| 915 | |
| 916 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 917 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 918 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 919 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 920 | alloc_info.descriptorPool = ds_pool; |
| 921 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 922 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 923 | ASSERT_VK_SUCCESS(err); |
| 924 | |
| 925 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 926 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 927 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 928 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 929 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 930 | |
| 931 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 932 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 933 | ASSERT_VK_SUCCESS(err); |
| 934 | |
| 935 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 936 | |
| 937 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 938 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 939 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 940 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 941 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" << endl; |
| 942 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 943 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 944 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 945 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 946 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 947 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 948 | } |
| 949 | |
| 950 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 951 | { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 952 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 953 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 954 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 955 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 956 | "Invalid VkDeviceMemory Object "); |
| 957 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 958 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 959 | |
| 960 | // Create an image, allocate memory, free it, and then try to bind it |
| 961 | VkImage image; |
| 962 | VkDeviceMemory mem; |
| 963 | VkMemoryRequirements mem_reqs; |
| 964 | |
| 965 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 966 | const int32_t tex_width = 32; |
| 967 | const int32_t tex_height = 32; |
| 968 | |
| 969 | VkImageCreateInfo image_create_info = {}; |
| 970 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 971 | image_create_info.pNext = NULL; |
| 972 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 973 | image_create_info.format = tex_format; |
| 974 | image_create_info.extent.width = tex_width; |
| 975 | image_create_info.extent.height = tex_height; |
| 976 | image_create_info.extent.depth = 1; |
| 977 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 978 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 979 | image_create_info.samples = 1; |
| 980 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 981 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 982 | image_create_info.flags = 0; |
| 983 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 984 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 985 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 986 | mem_alloc.pNext = NULL; |
| 987 | mem_alloc.allocationSize = 0; |
| 988 | mem_alloc.memoryTypeIndex = 0; |
| 989 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 990 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 991 | ASSERT_VK_SUCCESS(err); |
| 992 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 993 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 994 | image, |
| 995 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 996 | |
| 997 | mem_alloc.allocationSize = mem_reqs.size; |
| 998 | |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 999 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1000 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1001 | |
| 1002 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1003 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1004 | ASSERT_VK_SUCCESS(err); |
| 1005 | |
| 1006 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1007 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1008 | |
| 1009 | // Try to bind free memory that has been freed |
| 1010 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1011 | // This may very well return an error. |
| 1012 | (void)err; |
| 1013 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1014 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1015 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object 0x<handle>'"; |
| 1016 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1017 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1018 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1019 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1020 | } |
| 1021 | |
| 1022 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 1023 | { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1024 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1025 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1026 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1027 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Invalid VkImage Object "); |
| 1028 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1029 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1030 | |
| 1031 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 1032 | VkImage image; |
| 1033 | VkDeviceMemory mem; |
| 1034 | VkMemoryRequirements mem_reqs; |
| 1035 | |
| 1036 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1037 | const int32_t tex_width = 32; |
| 1038 | const int32_t tex_height = 32; |
| 1039 | |
| 1040 | VkImageCreateInfo image_create_info = {}; |
| 1041 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1042 | image_create_info.pNext = NULL; |
| 1043 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1044 | image_create_info.format = tex_format; |
| 1045 | image_create_info.extent.width = tex_width; |
| 1046 | image_create_info.extent.height = tex_height; |
| 1047 | image_create_info.extent.depth = 1; |
| 1048 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1049 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1050 | image_create_info.samples = 1; |
| 1051 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1052 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1053 | image_create_info.flags = 0; |
| 1054 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1055 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1056 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 1057 | mem_alloc.pNext = NULL; |
| 1058 | mem_alloc.allocationSize = 0; |
| 1059 | mem_alloc.memoryTypeIndex = 0; |
| 1060 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1061 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1062 | ASSERT_VK_SUCCESS(err); |
| 1063 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1064 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1065 | image, |
| 1066 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1067 | |
| 1068 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1069 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1070 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1071 | |
| 1072 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1073 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1074 | ASSERT_VK_SUCCESS(err); |
| 1075 | |
| 1076 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1077 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1078 | ASSERT_VK_SUCCESS(err); |
| 1079 | |
| 1080 | // Now Try to bind memory to this destroyed object |
| 1081 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1082 | // This may very well return an error. |
| 1083 | (void) err; |
| 1084 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1085 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1086 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1087 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1088 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1089 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1090 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1091 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1092 | |
| 1093 | TEST_F(VkLayerTest, InvalidBufferViewObject) |
| 1094 | { |
| 1095 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1096 | VkResult err; |
| 1097 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1098 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1099 | "Invalid VkBufferView Object 0xbaadbeef"); |
| 1100 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1101 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1102 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1103 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1104 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1105 | |
| 1106 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1107 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1108 | ds_pool_ci.pNext = NULL; |
| 1109 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1110 | ds_pool_ci.poolSizeCount = 1; |
| 1111 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1112 | |
| 1113 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1114 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1115 | ASSERT_VK_SUCCESS(err); |
| 1116 | |
| 1117 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1118 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1119 | dsl_binding.arraySize = 1; |
| 1120 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1121 | dsl_binding.pImmutableSamplers = NULL; |
| 1122 | |
| 1123 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1124 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1125 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1126 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1127 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1128 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1129 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1130 | ASSERT_VK_SUCCESS(err); |
| 1131 | |
| 1132 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1133 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1134 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1135 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1136 | alloc_info.descriptorPool = ds_pool; |
| 1137 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1138 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1139 | ASSERT_VK_SUCCESS(err); |
| 1140 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1141 | VkBufferView view = (VkBufferView) 0xbaadbeef; // invalid bufferView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1142 | |
| 1143 | VkWriteDescriptorSet descriptor_write; |
| 1144 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1145 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1146 | descriptor_write.dstSet = descriptorSet; |
| 1147 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1148 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1149 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1150 | descriptor_write.pTexelBufferView = &view; |
| 1151 | |
| 1152 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1153 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1154 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1155 | FAIL() << "Did nto receive Error 'Invalid VkBufferView Object 0xbaadbeef'"; |
| 1156 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1157 | } |
| 1158 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1159 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1160 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1161 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1162 | #endif // OBJ_TRACKER_TESTS |
| 1163 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1164 | #if DRAW_STATE_TESTS |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1165 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1166 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1167 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1168 | "Dynamic line width state not set for this command buffer"); |
| 1169 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1170 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1171 | |
| 1172 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1173 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1174 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1175 | FAIL() << "Did not receive Error 'Dynamic line width state not set for this command buffer'"; |
| 1176 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1181 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1182 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1183 | "Dynamic depth bias state not set for this command buffer"); |
| 1184 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1185 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1186 | |
| 1187 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1188 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1189 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1190 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for this command buffer'"; |
| 1191 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1192 | } |
| 1193 | } |
| 1194 | |
Cody Northrop | 4063c9a | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1195 | // Disable these two tests until we can sort out how to track multiple layer errors |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1196 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1197 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1198 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1199 | "Dynamic viewport state not set for this command buffer"); |
| 1200 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1201 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1202 | |
| 1203 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1204 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1205 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1206 | FAIL() << "Did not recieve Error 'Dynamic scissor state not set for this command buffer'"; |
| 1207 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1212 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1213 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1214 | "Dynamic scissor state not set for this command buffer"); |
| 1215 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1216 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1217 | |
| 1218 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1219 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1220 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1221 | FAIL() << "Did not recieve Error ' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1222 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1223 | } |
| 1224 | } |
| 1225 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1226 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1227 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1228 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1229 | "Dynamic blend object state not set for this command buffer"); |
| 1230 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1231 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1232 | |
| 1233 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1234 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1235 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1236 | FAIL() << "Did not recieve Error 'Dynamic blend object state not set for this command buffer'"; |
| 1237 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1242 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1243 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1244 | "Dynamic depth bounds state not set for this command buffer"); |
| 1245 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1246 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1247 | |
| 1248 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1249 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1250 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1251 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set for this command buffer'"; |
| 1252 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1253 | } |
| 1254 | } |
| 1255 | |
| 1256 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1257 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1258 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1259 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1260 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1261 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1262 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1263 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1264 | |
| 1265 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1266 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1267 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1268 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1269 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1270 | } |
| 1271 | } |
| 1272 | |
| 1273 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1274 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1275 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1276 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1277 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1278 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1279 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1280 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1281 | |
| 1282 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1283 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1284 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1285 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1286 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1291 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1292 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1293 | "Dynamic stencil reference state not set for this command buffer"); |
| 1294 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1295 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1296 | |
| 1297 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1298 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1299 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1300 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not set for this command buffer'"; |
| 1301 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1302 | } |
| 1303 | } |
| 1304 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1305 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1306 | { |
| 1307 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1308 | |
| 1309 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1310 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1311 | |
| 1312 | VkFenceCreateInfo fenceInfo = {}; |
| 1313 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1314 | fenceInfo.pNext = NULL; |
| 1315 | fenceInfo.flags = 0; |
| 1316 | |
| 1317 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1318 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1319 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1320 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1321 | // We luck out b/c by default the framework creates CB w/ the VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1322 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1323 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1324 | EndCommandBuffer(); |
| 1325 | |
| 1326 | testFence.init(*m_device, fenceInfo); |
| 1327 | |
| 1328 | // Bypass framework since it does the waits automatically |
| 1329 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1330 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1331 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1332 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1333 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1334 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1335 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1336 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1337 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1338 | submit_info.pSignalSemaphores = NULL; |
| 1339 | |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1340 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1341 | ASSERT_VK_SUCCESS( err ); |
| 1342 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1343 | // Cause validation error by re-submitting cmd buffer that should only be submitted once |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1344 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1345 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1346 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1347 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
| 1348 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1349 | } |
| 1350 | } |
| 1351 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1352 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1353 | { |
| 1354 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1355 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1356 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1357 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1358 | "Incorrectly binding graphics pipeline "); |
| 1359 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1360 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1361 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1362 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1363 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1364 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1365 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1366 | |
| 1367 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1368 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1369 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1370 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1371 | ds_pool_ci.poolSizeCount = 1; |
| 1372 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1373 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1374 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1375 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1376 | ASSERT_VK_SUCCESS(err); |
| 1377 | |
| 1378 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1379 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1380 | dsl_binding.arraySize = 1; |
| 1381 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1382 | dsl_binding.pImmutableSamplers = NULL; |
| 1383 | |
| 1384 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1385 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1386 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1387 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1388 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1389 | |
| 1390 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1391 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1392 | ASSERT_VK_SUCCESS(err); |
| 1393 | |
| 1394 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1395 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1396 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1397 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1398 | alloc_info.descriptorPool = ds_pool; |
| 1399 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1400 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1401 | ASSERT_VK_SUCCESS(err); |
| 1402 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 1403 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1404 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1405 | pipe_ms_state_ci.rasterizationSamples = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1406 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1407 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1408 | pipe_ms_state_ci.pSampleMask = NULL; |
| 1409 | |
| 1410 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1411 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1412 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1413 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1414 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1415 | VkPipelineLayout pipeline_layout; |
| 1416 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1417 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1418 | ASSERT_VK_SUCCESS(err); |
| 1419 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1420 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1421 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1422 | // but add it to be able to run on more devices |
| 1423 | VkPipelineObj pipe(m_device); |
| 1424 | pipe.AddShader(&vs); |
| 1425 | pipe.AddShader(&fs); |
| 1426 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1427 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1428 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1429 | // Calls AllocateCommandBuffers |
| 1430 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 1431 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1432 | memset(&cmd_buf_info, 0, sizeof(VkCommandBufferBeginInfo)); |
| 1433 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1434 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1435 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1436 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1437 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1438 | vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1439 | |
| 1440 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1441 | FAIL() << "Did not receive Error 'Incorrectly binding graphics pipeline (0x<handle>) without an active RenderPass'"; |
| 1442 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1443 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1444 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1445 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1446 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1447 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1448 | } |
| 1449 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1450 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) |
| 1451 | { |
| 1452 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1453 | VkResult err; |
| 1454 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1455 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1456 | "Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
| 1457 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1458 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1459 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1460 | |
| 1461 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1462 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1463 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1464 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1465 | |
| 1466 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1467 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1468 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1469 | ds_pool_ci.flags = 0; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1470 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1471 | ds_pool_ci.poolSizeCount = 1; |
| 1472 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1473 | |
| 1474 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1475 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1476 | ASSERT_VK_SUCCESS(err); |
| 1477 | |
| 1478 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1479 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1480 | dsl_binding.arraySize = 1; |
| 1481 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1482 | dsl_binding.pImmutableSamplers = NULL; |
| 1483 | |
| 1484 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1485 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1486 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1487 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1488 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1489 | |
| 1490 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1491 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1492 | ASSERT_VK_SUCCESS(err); |
| 1493 | |
| 1494 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1495 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1496 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1497 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1498 | alloc_info.descriptorPool = ds_pool; |
| 1499 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1500 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1501 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1502 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1503 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
| 1504 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1505 | } |
| 1506 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1507 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1508 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1509 | } |
| 1510 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1511 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1512 | { |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1513 | VkResult err; |
| 1514 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1515 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1516 | "It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
| 1517 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1518 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1519 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1520 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1521 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1522 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1523 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1524 | |
| 1525 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1526 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1527 | ds_pool_ci.pNext = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1528 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1529 | ds_pool_ci.poolSizeCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1530 | ds_pool_ci.flags = 0; |
| 1531 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1532 | // app can only call vkResetDescriptorPool on this pool.; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1533 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1534 | |
| 1535 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1536 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1537 | ASSERT_VK_SUCCESS(err); |
| 1538 | |
| 1539 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1540 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1541 | dsl_binding.arraySize = 1; |
| 1542 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1543 | dsl_binding.pImmutableSamplers = NULL; |
| 1544 | |
| 1545 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1546 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1547 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1548 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1549 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1550 | |
| 1551 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1552 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1553 | ASSERT_VK_SUCCESS(err); |
| 1554 | |
| 1555 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1556 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1557 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1558 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1559 | alloc_info.descriptorPool = ds_pool; |
| 1560 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1561 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1562 | ASSERT_VK_SUCCESS(err); |
| 1563 | |
| 1564 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1565 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1566 | FAIL() << "Did not receive Error 'It is invalid to call vkFreeDescriptorSets() with a pool created with...'"; |
| 1567 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1568 | } |
| 1569 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1570 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1571 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1572 | } |
| 1573 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1574 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1575 | { |
| 1576 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1577 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1578 | // Attempt to clear DS Pool with bad object |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1579 | /* |
| 1580 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1581 | "Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call"); |
| 1582 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1583 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1584 | vkResetDescriptorPool(device(), badPool); |
| 1585 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1586 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1587 | FAIL() << "Did not receive Error 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1588 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1589 | }*/ |
| 1590 | } |
| 1591 | |
| 1592 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1593 | { |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1594 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1595 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1596 | // Create a valid cmd buffer |
| 1597 | // call vkCmdBindDescriptorSets w/ false DS |
| 1598 | } |
| 1599 | |
| 1600 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1601 | { |
| 1602 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1603 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1604 | } |
| 1605 | |
| 1606 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1607 | { |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1608 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1609 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1610 | // Create a valid cmd buffer |
| 1611 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1612 | // |
| 1613 | // m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1614 | // "Attempt to bind Pipeline "); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1615 | // |
| 1616 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1617 | // VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1618 | // BeginCommandBuffer(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1619 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1620 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1621 | // |
| 1622 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1623 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1624 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1625 | // } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1626 | } |
| 1627 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1628 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1629 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1630 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on CommandBuffer |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1631 | VkResult err; |
| 1632 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1633 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 1634 | " bound but it was never updated. "); |
| 1635 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1636 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1637 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1638 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1639 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1640 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1641 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1642 | |
| 1643 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1644 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1645 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1646 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1647 | ds_pool_ci.poolSizeCount = 1; |
| 1648 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1649 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1650 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1651 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1652 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1653 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1654 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1655 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1656 | dsl_binding.arraySize = 1; |
| 1657 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1658 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1659 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1660 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1661 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1662 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1663 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1664 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1665 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1666 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1667 | ASSERT_VK_SUCCESS(err); |
| 1668 | |
| 1669 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1670 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1671 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1672 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1673 | alloc_info.descriptorPool = ds_pool; |
| 1674 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1675 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1676 | ASSERT_VK_SUCCESS(err); |
| 1677 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1678 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1679 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1680 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1681 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1682 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1683 | |
| 1684 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1685 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1686 | ASSERT_VK_SUCCESS(err); |
| 1687 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1688 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1689 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 1690 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1691 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1692 | VkPipelineObj pipe(m_device); |
| 1693 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1694 | pipe.AddShader(&fs); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1695 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1696 | |
| 1697 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1698 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1699 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1700 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1701 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1702 | FAIL() << "Did not recieve Warning 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1703 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1704 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1705 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1706 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1707 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1708 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1709 | } |
| 1710 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1711 | TEST_F(VkLayerTest, NoBeginCommandBuffer) |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1712 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1713 | |
| 1714 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1715 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1716 | |
| 1717 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1718 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1719 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1720 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1721 | |
| 1722 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1723 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 1724 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1725 | } |
| 1726 | } |
| 1727 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1728 | TEST_F(VkLayerTest, PrimaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1729 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1730 | |
| 1731 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1732 | "may not specify framebuffer or renderpass parameters"); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1733 | |
| 1734 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1735 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1736 | // Calls AllocateCommandBuffers |
| 1737 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1738 | |
| 1739 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1740 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1741 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1742 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1743 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1744 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 1745 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 1746 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1747 | |
| 1748 | // The error should be caught by validation of the BeginCommandBuffer call |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1749 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1750 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1751 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1752 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
| 1753 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1754 | } |
| 1755 | } |
| 1756 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1757 | TEST_F(VkLayerTest, SecondaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1758 | { |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1759 | VkResult err; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1760 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1761 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1762 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1763 | "must specify framebuffer and renderpass parameters"); |
| 1764 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1765 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1766 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1767 | VkCommandBufferAllocateInfo cmd = {}; |
| 1768 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOC_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1769 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1770 | cmd.commandPool = m_commandPool; |
| 1771 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1772 | cmd.bufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1773 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1774 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1775 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1776 | |
| 1777 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1778 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1779 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1780 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1781 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1782 | |
| 1783 | // The error should be caught by validation of the BeginCommandBuffer call |
| 1784 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 1785 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1786 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1787 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
| 1788 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1789 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1790 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1791 | } |
| 1792 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1793 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 1794 | { |
| 1795 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1796 | VkResult err; |
| 1797 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1798 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1799 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 1800 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1801 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1802 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1803 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1804 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1805 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1806 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1807 | |
| 1808 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1809 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1810 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1811 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1812 | ds_pool_ci.poolSizeCount = 1; |
| 1813 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1814 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1815 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1816 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1817 | ASSERT_VK_SUCCESS(err); |
| 1818 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1819 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1820 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1821 | dsl_binding.arraySize = 1; |
| 1822 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1823 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1824 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1825 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1826 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1827 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1828 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1829 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1830 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1831 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1832 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1833 | ASSERT_VK_SUCCESS(err); |
| 1834 | |
| 1835 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1836 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1837 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1838 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1839 | alloc_info.descriptorPool = ds_pool; |
| 1840 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1841 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1842 | ASSERT_VK_SUCCESS(err); |
| 1843 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1844 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1845 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1846 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1847 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1848 | |
| 1849 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1850 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1851 | ASSERT_VK_SUCCESS(err); |
| 1852 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1853 | VkViewport vp = {}; // Just need dummy vp to point to |
| 1854 | VkRect2D sc = {}; // dummy scissor to point to |
| 1855 | |
| 1856 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 1857 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 1858 | vp_state_ci.scissorCount = 1; |
| 1859 | vp_state_ci.pScissors = ≻ |
| 1860 | vp_state_ci.viewportCount = 1; |
| 1861 | vp_state_ci.pViewports = &vp; |
| 1862 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1863 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1864 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1865 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1866 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1867 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1868 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1869 | |
| 1870 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1871 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 1872 | pc_ci.initialDataSize = 0; |
| 1873 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1874 | |
| 1875 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1876 | VkPipelineCache pipelineCache; |
| 1877 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1878 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1879 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1880 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1881 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1882 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1883 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 1884 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1885 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1886 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1887 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 1888 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1889 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1890 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1891 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1892 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 1893 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 1894 | { |
| 1895 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1896 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1897 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1898 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1899 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive "); |
| 1900 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1901 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1902 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1903 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1904 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1905 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1906 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1907 | |
| 1908 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1909 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1910 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1911 | ds_pool_ci.poolSizeCount = 1; |
| 1912 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1913 | |
| 1914 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1915 | err = vkCreateDescriptorPool(m_device->device(), VK_DESCRIPTOR_POOL_USAGE_NON_FREE, 1, &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1916 | ASSERT_VK_SUCCESS(err); |
| 1917 | |
| 1918 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1919 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1920 | dsl_binding.arraySize = 1; |
| 1921 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1922 | dsl_binding.pImmutableSamplers = NULL; |
| 1923 | |
| 1924 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1925 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1926 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1927 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1928 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1929 | |
| 1930 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1931 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1932 | ASSERT_VK_SUCCESS(err); |
| 1933 | |
| 1934 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1935 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1936 | ASSERT_VK_SUCCESS(err); |
| 1937 | |
| 1938 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1939 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1940 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1941 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1942 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1943 | |
| 1944 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1945 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1946 | ASSERT_VK_SUCCESS(err); |
| 1947 | |
| 1948 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 1949 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 1950 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1951 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1952 | // Just using VS txt for Tess shaders as we don't care about functionality |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1953 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 1954 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1955 | |
| 1956 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1957 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1958 | shaderStages[0].shader = vs.handle(); |
| 1959 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1960 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1961 | shaderStages[1].shader = tc.handle(); |
| 1962 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1963 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1964 | shaderStages[2].shader = te.handle(); |
| 1965 | |
| 1966 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 1967 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 1968 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH; |
| 1969 | |
| 1970 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 1971 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 1972 | tsCI.patchControlPoints = 0; // This will cause an error |
| 1973 | |
| 1974 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1975 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 1976 | gp_ci.pNext = NULL; |
| 1977 | gp_ci.stageCount = 3; |
| 1978 | gp_ci.pStages = shaderStages; |
| 1979 | gp_ci.pVertexInputState = NULL; |
| 1980 | gp_ci.pInputAssemblyState = &iaCI; |
| 1981 | gp_ci.pTessellationState = &tsCI; |
| 1982 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1983 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1984 | gp_ci.pMultisampleState = NULL; |
| 1985 | gp_ci.pDepthStencilState = NULL; |
| 1986 | gp_ci.pColorBlendState = NULL; |
| 1987 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1988 | gp_ci.layout = pipeline_layout; |
| 1989 | gp_ci.renderPass = renderPass(); |
| 1990 | |
| 1991 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1992 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 1993 | pc_ci.pNext = NULL; |
| 1994 | pc_ci.initialSize = 0; |
| 1995 | pc_ci.initialData = 0; |
| 1996 | pc_ci.maxSize = 0; |
| 1997 | |
| 1998 | VkPipeline pipeline; |
| 1999 | VkPipelineCache pipelineCache; |
| 2000 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2001 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2002 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2003 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2004 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2005 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2006 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
| 2007 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2008 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2009 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2010 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2011 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2012 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2013 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2014 | } |
| 2015 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2016 | // Set scissor and viewport counts to different numbers |
| 2017 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2018 | { |
| 2019 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2020 | VkResult err; |
| 2021 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2022 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2023 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2024 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2025 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2026 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2027 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2028 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2029 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2030 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2031 | |
| 2032 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2033 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2034 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2035 | ds_pool_ci.poolSizeCount = 1; |
| 2036 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2037 | |
| 2038 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2039 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2040 | ASSERT_VK_SUCCESS(err); |
| 2041 | |
| 2042 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2043 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2044 | dsl_binding.arraySize = 1; |
| 2045 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2046 | |
| 2047 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2048 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2049 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2050 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2051 | |
| 2052 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2053 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2054 | ASSERT_VK_SUCCESS(err); |
| 2055 | |
| 2056 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2057 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2058 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2059 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2060 | alloc_info.descriptorPool = ds_pool; |
| 2061 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2062 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2063 | ASSERT_VK_SUCCESS(err); |
| 2064 | |
| 2065 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2066 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2067 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2068 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2069 | |
| 2070 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2071 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2072 | ASSERT_VK_SUCCESS(err); |
| 2073 | |
| 2074 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2075 | |
| 2076 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2077 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2078 | vp_state_ci.scissorCount = 0; |
| 2079 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2080 | vp_state_ci.pViewports = &vp; |
| 2081 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2082 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2083 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2084 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2085 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2086 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2087 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2088 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2089 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2090 | |
| 2091 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2092 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2093 | gp_ci.stageCount = 2; |
| 2094 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2095 | gp_ci.pViewportState = &vp_state_ci; |
| 2096 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2097 | gp_ci.layout = pipeline_layout; |
| 2098 | gp_ci.renderPass = renderPass(); |
| 2099 | |
| 2100 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2101 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2102 | |
| 2103 | VkPipeline pipeline; |
| 2104 | VkPipelineCache pipelineCache; |
| 2105 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2106 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2107 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2108 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2109 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2110 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2111 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must match scissor count (0).'"; |
| 2112 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2113 | } |
| 2114 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2115 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2116 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2117 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2118 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2119 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2120 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2121 | // for the counts even if the data is going to be set dynamically. |
| 2122 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2123 | { |
| 2124 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2125 | VkResult err; |
| 2126 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2127 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2128 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2129 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2130 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2131 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2132 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2133 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2134 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2135 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2136 | |
| 2137 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2138 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2139 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2140 | ds_pool_ci.poolSizeCount = 1; |
| 2141 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2142 | |
| 2143 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2144 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2145 | ASSERT_VK_SUCCESS(err); |
| 2146 | |
| 2147 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2148 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2149 | dsl_binding.arraySize = 1; |
| 2150 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2151 | |
| 2152 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2153 | 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] | 2154 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2155 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2156 | |
| 2157 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2158 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2159 | ASSERT_VK_SUCCESS(err); |
| 2160 | |
| 2161 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2162 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2163 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2164 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2165 | alloc_info.descriptorPool = ds_pool; |
| 2166 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2167 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2168 | ASSERT_VK_SUCCESS(err); |
| 2169 | |
| 2170 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2171 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2172 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2173 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2174 | |
| 2175 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2176 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2177 | ASSERT_VK_SUCCESS(err); |
| 2178 | |
| 2179 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2180 | // Set scissor as dynamic to avoid second error |
| 2181 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2182 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2183 | dyn_state_ci.dynamicStateCount = 1; |
| 2184 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2185 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2186 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2187 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2188 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2189 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2190 | 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] | 2191 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2192 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2193 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2194 | |
| 2195 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2196 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2197 | gp_ci.stageCount = 2; |
| 2198 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2199 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2200 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2201 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2202 | gp_ci.layout = pipeline_layout; |
| 2203 | gp_ci.renderPass = renderPass(); |
| 2204 | |
| 2205 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2206 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2207 | |
| 2208 | VkPipeline pipeline; |
| 2209 | VkPipelineCache pipelineCache; |
| 2210 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2211 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2212 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2213 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2214 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2215 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2216 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. Even if...'"; |
| 2217 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2218 | } |
| 2219 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2220 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2221 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2222 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2223 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2224 | } |
| 2225 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2226 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2227 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2228 | { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2229 | VkResult err; |
| 2230 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2231 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2232 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2233 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2234 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2235 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2236 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2237 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2238 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2239 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2240 | |
| 2241 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2242 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2243 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2244 | ds_pool_ci.poolSizeCount = 1; |
| 2245 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2246 | |
| 2247 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2248 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2249 | ASSERT_VK_SUCCESS(err); |
| 2250 | |
| 2251 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2252 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2253 | dsl_binding.arraySize = 1; |
| 2254 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2255 | |
| 2256 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2257 | 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] | 2258 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2259 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2260 | |
| 2261 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2262 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2263 | ASSERT_VK_SUCCESS(err); |
| 2264 | |
| 2265 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2266 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2267 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2268 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2269 | alloc_info.descriptorPool = ds_pool; |
| 2270 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2271 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2272 | ASSERT_VK_SUCCESS(err); |
| 2273 | |
| 2274 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2275 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2276 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2277 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2278 | |
| 2279 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2280 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2281 | ASSERT_VK_SUCCESS(err); |
| 2282 | |
| 2283 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2284 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2285 | vp_state_ci.viewportCount = 1; |
| 2286 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2287 | vp_state_ci.scissorCount = 1; |
| 2288 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2289 | |
| 2290 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2291 | // Set scissor as dynamic to avoid that error |
| 2292 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2293 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2294 | dyn_state_ci.dynamicStateCount = 1; |
| 2295 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2296 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2297 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2298 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2299 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2300 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2301 | 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] | 2302 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2303 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2304 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2305 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2306 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2307 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2308 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2309 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2310 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2311 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2312 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2313 | |
| 2314 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2315 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2316 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2317 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2318 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2319 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2320 | rs_ci.pNext = nullptr; |
| 2321 | |
| 2322 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2323 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2324 | cb_ci.pNext = nullptr; |
| 2325 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2326 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2327 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2328 | gp_ci.stageCount = 2; |
| 2329 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2330 | gp_ci.pVertexInputState = &vi_ci; |
| 2331 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2332 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2333 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2334 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2335 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2336 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2337 | gp_ci.layout = pipeline_layout; |
| 2338 | gp_ci.renderPass = renderPass(); |
| 2339 | |
| 2340 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2341 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2342 | |
| 2343 | VkPipeline pipeline; |
| 2344 | VkPipelineCache pipelineCache; |
| 2345 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2346 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2347 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2348 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2349 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2350 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2351 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...'"; |
| 2352 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2353 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2354 | |
| 2355 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2356 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2357 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2358 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2359 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match."); |
| 2360 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2361 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2362 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2363 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2364 | ASSERT_VK_SUCCESS(err); |
| 2365 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2366 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2367 | VkRect2D scissors[2] = {}; // don't care about data |
| 2368 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2369 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 2, scissors); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2370 | Draw(1, 0, 0, 0); |
| 2371 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2372 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2373 | FAIL() << "Did not receive Error 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 2374 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2375 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2376 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2377 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2378 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2379 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2380 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2381 | } |
| 2382 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2383 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2384 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2385 | { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2386 | VkResult err; |
| 2387 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2388 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2389 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 2390 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2391 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2392 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2393 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2394 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2395 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2396 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2397 | |
| 2398 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2399 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2400 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2401 | ds_pool_ci.poolSizeCount = 1; |
| 2402 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2403 | |
| 2404 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2405 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2406 | ASSERT_VK_SUCCESS(err); |
| 2407 | |
| 2408 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2409 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2410 | dsl_binding.arraySize = 1; |
| 2411 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2412 | |
| 2413 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2414 | 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] | 2415 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2416 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2417 | |
| 2418 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2419 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2420 | ASSERT_VK_SUCCESS(err); |
| 2421 | |
| 2422 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2423 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2424 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2425 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2426 | alloc_info.descriptorPool = ds_pool; |
| 2427 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2428 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2429 | ASSERT_VK_SUCCESS(err); |
| 2430 | |
| 2431 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2432 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2433 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2434 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2435 | |
| 2436 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2437 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2438 | ASSERT_VK_SUCCESS(err); |
| 2439 | |
| 2440 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2441 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2442 | vp_state_ci.scissorCount = 1; |
| 2443 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2444 | vp_state_ci.viewportCount = 1; |
| 2445 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2446 | |
| 2447 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2448 | // Set scissor as dynamic to avoid that error |
| 2449 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2450 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2451 | dyn_state_ci.dynamicStateCount = 1; |
| 2452 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2453 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2454 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2455 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2456 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2457 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2458 | 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] | 2459 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2460 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2461 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2462 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2463 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2464 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2465 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2466 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2467 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2468 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2469 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2470 | |
| 2471 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2472 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2473 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2474 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2475 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2476 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2477 | rs_ci.pNext = nullptr; |
| 2478 | |
| 2479 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2480 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2481 | cb_ci.pNext = nullptr; |
| 2482 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2483 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2484 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2485 | gp_ci.stageCount = 2; |
| 2486 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2487 | gp_ci.pVertexInputState = &vi_ci; |
| 2488 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2489 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2490 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2491 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2492 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2493 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2494 | gp_ci.layout = pipeline_layout; |
| 2495 | gp_ci.renderPass = renderPass(); |
| 2496 | |
| 2497 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2498 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2499 | |
| 2500 | VkPipeline pipeline; |
| 2501 | VkPipelineCache pipelineCache; |
| 2502 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2503 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2504 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2505 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2506 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2507 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2508 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...'"; |
| 2509 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2510 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2511 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2512 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2513 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2514 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2515 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match."); |
| 2516 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2517 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 2518 | vp_state_ci.pScissors = ≻ |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2519 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2520 | ASSERT_VK_SUCCESS(err); |
| 2521 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2522 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2523 | VkViewport viewports[2] = {}; // don't care about data |
| 2524 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2525 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2526 | Draw(1, 0, 0, 0); |
| 2527 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2528 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2529 | FAIL() << "Did not receive Error 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
| 2530 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2531 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2532 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2533 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2534 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2535 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2536 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2537 | } |
| 2538 | |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2539 | TEST_F(VkLayerTest, NullRenderPass) |
| 2540 | { |
| 2541 | // Bind a NULL RenderPass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2542 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2543 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2544 | |
| 2545 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2546 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2547 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2548 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2549 | // 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] | 2550 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2551 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2552 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2553 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 2554 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2555 | } |
| 2556 | } |
| 2557 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2558 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 2559 | { |
| 2560 | // Bind a BeginRenderPass within an active RenderPass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2561 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2562 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2563 | |
| 2564 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2565 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2566 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2567 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2568 | // 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] | 2569 | VkRenderPassBeginInfo rp_begin = {}; |
| 2570 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 2571 | rp_begin.pNext = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2572 | rp_begin.renderPass = renderPass(); |
| 2573 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2574 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2575 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2576 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2577 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2578 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2579 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2580 | } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2581 | } |
| 2582 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2583 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 2584 | { |
| 2585 | // Call CmdFillBuffer within an active renderpass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2586 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2587 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2588 | |
| 2589 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2590 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2591 | |
| 2592 | // Renderpass is started here |
| 2593 | BeginCommandBuffer(); |
| 2594 | |
| 2595 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2596 | vk_testing::Buffer dstBuffer; |
| 2597 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2598 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2599 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2600 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2601 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2602 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2603 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2604 | } |
| 2605 | } |
| 2606 | |
| 2607 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 2608 | { |
| 2609 | // Call CmdUpdateBuffer within an active renderpass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2610 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2611 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2612 | |
| 2613 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2614 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2615 | |
| 2616 | // Renderpass is started here |
| 2617 | BeginCommandBuffer(); |
| 2618 | |
| 2619 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2620 | vk_testing::Buffer dstBuffer; |
| 2621 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2622 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2623 | VkDeviceSize dstOffset = 0; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2624 | VkDeviceSize dataSize = 1024; |
| 2625 | const uint32_t *pData = NULL; |
| 2626 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2627 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2628 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2629 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2630 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2631 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2632 | } |
| 2633 | } |
| 2634 | |
| 2635 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 2636 | { |
| 2637 | // Call CmdClearColorImage within an active RenderPass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2638 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2639 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2640 | |
| 2641 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2642 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2643 | |
| 2644 | // Renderpass is started here |
| 2645 | BeginCommandBuffer(); |
| 2646 | |
| 2647 | VkClearColorValue clear_color = {0}; |
| 2648 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2649 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2650 | const int32_t tex_width = 32; |
| 2651 | const int32_t tex_height = 32; |
| 2652 | VkImageCreateInfo image_create_info = {}; |
| 2653 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2654 | image_create_info.pNext = NULL; |
| 2655 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2656 | image_create_info.format = tex_format; |
| 2657 | image_create_info.extent.width = tex_width; |
| 2658 | image_create_info.extent.height = tex_height; |
| 2659 | image_create_info.extent.depth = 1; |
| 2660 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2661 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2662 | image_create_info.samples = 1; |
| 2663 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2664 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2665 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2666 | vk_testing::Image dstImage; |
| 2667 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2668 | |
| 2669 | const VkImageSubresourceRange range = |
| 2670 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 2671 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2672 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), |
| 2673 | dstImage.handle(), |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2674 | VK_IMAGE_LAYOUT_GENERAL, |
| 2675 | &clear_color, |
| 2676 | 1, |
| 2677 | &range); |
| 2678 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2679 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2680 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2681 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2682 | } |
| 2683 | } |
| 2684 | |
| 2685 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 2686 | { |
| 2687 | // Call CmdClearDepthStencilImage within an active RenderPass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2688 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2689 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2690 | |
| 2691 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2692 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2693 | |
| 2694 | // Renderpass is started here |
| 2695 | BeginCommandBuffer(); |
| 2696 | |
| 2697 | VkClearDepthStencilValue clear_value = {0}; |
| 2698 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2699 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 2700 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2701 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 2702 | image_create_info.extent.width = 64; |
| 2703 | image_create_info.extent.height = 64; |
| 2704 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2705 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 2706 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2707 | vk_testing::Image dstImage; |
| 2708 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2709 | |
| 2710 | const VkImageSubresourceRange range = |
| 2711 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2712 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2713 | vkCmdClearDepthStencilImage(m_commandBuffer->GetBufferHandle(), |
| 2714 | dstImage.handle(), |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2715 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 2716 | &clear_value, |
| 2717 | 1, |
| 2718 | &range); |
| 2719 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2720 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2721 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2722 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2723 | } |
| 2724 | } |
| 2725 | |
| 2726 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 2727 | { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2728 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2729 | VkResult err; |
| 2730 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2731 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2732 | "vkCmdClearAttachments: This call must be issued inside an active render pass"); |
| 2733 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2734 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2735 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2736 | |
| 2737 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2738 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2739 | ASSERT_VK_SUCCESS(err); |
| 2740 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2741 | VkClearAttachment color_attachment; |
| 2742 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2743 | color_attachment.clearValue.color.float32[0] = 0; |
| 2744 | color_attachment.clearValue.color.float32[1] = 0; |
| 2745 | color_attachment.clearValue.color.float32[2] = 0; |
| 2746 | color_attachment.clearValue.color.float32[3] = 0; |
| 2747 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2748 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2749 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2750 | 1, &color_attachment, |
| 2751 | 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2752 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2753 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2754 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call must be issued inside an active render pass.'"; |
| 2755 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2756 | } |
| 2757 | } |
| 2758 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2759 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 2760 | { |
| 2761 | // Create a valid cmd buffer |
| 2762 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2763 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 2764 | // 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] | 2765 | } |
Tobin Ehlis | 1056d45 | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 2766 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2767 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 2768 | { |
| 2769 | // Bind a BeginRenderPass within an active RenderPass |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2770 | VkResult err; |
| 2771 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2772 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2773 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 2774 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2775 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2776 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2777 | uint32_t qfi = 0; |
| 2778 | VkBufferCreateInfo buffCI = {}; |
| 2779 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2780 | buffCI.size = 1024; |
| 2781 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2782 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2783 | buffCI.pQueueFamilyIndices = &qfi; |
| 2784 | |
| 2785 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2786 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2787 | ASSERT_VK_SUCCESS(err); |
| 2788 | |
| 2789 | BeginCommandBuffer(); |
| 2790 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2791 | //vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2792 | // 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] | 2793 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2794 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2795 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2796 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...'"; |
| 2797 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2798 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2799 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2800 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2801 | } |
| 2802 | |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2803 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 2804 | { |
| 2805 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2806 | |
| 2807 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2808 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2809 | |
| 2810 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2811 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2812 | |
| 2813 | BeginCommandBuffer(); |
| 2814 | //ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2815 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 2816 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2817 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2818 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2819 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer '"; |
| 2820 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2821 | } |
| 2822 | } |
| 2823 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2824 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 2825 | { |
| 2826 | // 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] | 2827 | VkResult err; |
| 2828 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2829 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2830 | "Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match "); |
| 2831 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2832 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2833 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2834 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2835 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2836 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2837 | |
| 2838 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2839 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2840 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2841 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2842 | ds_pool_ci.poolSizeCount = 1; |
| 2843 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2844 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2845 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2846 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2847 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2848 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2849 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2850 | dsl_binding.arraySize = 1; |
| 2851 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2852 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2853 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2854 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2855 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2856 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2857 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2858 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2859 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2860 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2861 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2862 | ASSERT_VK_SUCCESS(err); |
| 2863 | |
| 2864 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2865 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2866 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2867 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2868 | alloc_info.descriptorPool = ds_pool; |
| 2869 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2870 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2871 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2872 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2873 | VkSamplerCreateInfo sampler_ci = {}; |
| 2874 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2875 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2876 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 2877 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 2878 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 2879 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2880 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2881 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2882 | sampler_ci.mipLodBias = 1.0; |
| 2883 | sampler_ci.maxAnisotropy = 1; |
| 2884 | sampler_ci.compareEnable = VK_FALSE; |
| 2885 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2886 | sampler_ci.minLod = 1.0; |
| 2887 | sampler_ci.maxLod = 1.0; |
| 2888 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2889 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 2890 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2891 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2892 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2893 | ASSERT_VK_SUCCESS(err); |
| 2894 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2895 | VkDescriptorImageInfo info = {}; |
| 2896 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2897 | |
| 2898 | VkWriteDescriptorSet descriptor_write; |
| 2899 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2900 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2901 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2902 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2903 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2904 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2905 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2906 | |
| 2907 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2908 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2909 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2910 | FAIL() << "Did not receive Error 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...'"; |
| 2911 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2912 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2913 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2914 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 2915 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2916 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2917 | } |
| 2918 | |
| 2919 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 2920 | { |
| 2921 | // For overlapping Update, have arrayIndex exceed that of layout |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2922 | VkResult err; |
| 2923 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2924 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2925 | "Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding"); |
| 2926 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2927 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2928 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2929 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2930 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2931 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2932 | |
| 2933 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2934 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2935 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2936 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2937 | ds_pool_ci.poolSizeCount = 1; |
| 2938 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2939 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2940 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2941 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2942 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2943 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2944 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2945 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2946 | dsl_binding.arraySize = 1; |
| 2947 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2948 | dsl_binding.pImmutableSamplers = NULL; |
| 2949 | |
| 2950 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2951 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2952 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2953 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2954 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2955 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2956 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2957 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2958 | ASSERT_VK_SUCCESS(err); |
| 2959 | |
| 2960 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2961 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2962 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2963 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2964 | alloc_info.descriptorPool = ds_pool; |
| 2965 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2966 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2967 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2968 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2969 | VkSamplerCreateInfo sampler_ci = {}; |
| 2970 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2971 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2972 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 2973 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 2974 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 2975 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2976 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2977 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2978 | sampler_ci.mipLodBias = 1.0; |
| 2979 | sampler_ci.maxAnisotropy = 1; |
| 2980 | sampler_ci.compareEnable = VK_FALSE; |
| 2981 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2982 | sampler_ci.minLod = 1.0; |
| 2983 | sampler_ci.maxLod = 1.0; |
| 2984 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2985 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2986 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2987 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2988 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2989 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2990 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2991 | VkDescriptorImageInfo info = {}; |
| 2992 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2993 | |
| 2994 | VkWriteDescriptorSet descriptor_write; |
| 2995 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2996 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2997 | descriptor_write.dstSet = descriptorSet; |
| 2998 | 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] | 2999 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3000 | // 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] | 3001 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3002 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3003 | |
| 3004 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3005 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3006 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3007 | FAIL() << "Did not receive Error 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding...'"; |
| 3008 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3009 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3010 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3011 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3012 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3013 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3014 | } |
| 3015 | |
| 3016 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3017 | { |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3018 | // 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] | 3019 | VkResult err; |
| 3020 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3021 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3022 | " does not have binding to match update binding "); |
| 3023 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3024 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3025 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3026 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3027 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3028 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3029 | |
| 3030 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3031 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3032 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3033 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3034 | ds_pool_ci.poolSizeCount = 1; |
| 3035 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3036 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3037 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3038 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3039 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3040 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3041 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3042 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3043 | dsl_binding.arraySize = 1; |
| 3044 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3045 | dsl_binding.pImmutableSamplers = NULL; |
| 3046 | |
| 3047 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3048 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3049 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3050 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3051 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3052 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3053 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3054 | ASSERT_VK_SUCCESS(err); |
| 3055 | |
| 3056 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3057 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3058 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3059 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3060 | alloc_info.descriptorPool = ds_pool; |
| 3061 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3062 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3063 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3064 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3065 | VkSamplerCreateInfo sampler_ci = {}; |
| 3066 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3067 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3068 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3069 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3070 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3071 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3072 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3073 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3074 | sampler_ci.mipLodBias = 1.0; |
| 3075 | sampler_ci.maxAnisotropy = 1; |
| 3076 | sampler_ci.compareEnable = VK_FALSE; |
| 3077 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3078 | sampler_ci.minLod = 1.0; |
| 3079 | sampler_ci.maxLod = 1.0; |
| 3080 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3081 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3082 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3083 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3084 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3085 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3086 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3087 | VkDescriptorImageInfo info = {}; |
| 3088 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3089 | |
| 3090 | VkWriteDescriptorSet descriptor_write; |
| 3091 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3092 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3093 | descriptor_write.dstSet = descriptorSet; |
| 3094 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3095 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3096 | // 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] | 3097 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3098 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3099 | |
| 3100 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3101 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3102 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3103 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3104 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3105 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3106 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3107 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3108 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3109 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3110 | } |
| 3111 | |
| 3112 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3113 | { |
| 3114 | // 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] | 3115 | VkResult err; |
| 3116 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3117 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3118 | "Unexpected UPDATE struct of type "); |
| 3119 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3120 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3121 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3122 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3123 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3124 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3125 | |
| 3126 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3127 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3128 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3129 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3130 | ds_pool_ci.poolSizeCount = 1; |
| 3131 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3132 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3133 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3134 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3135 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3136 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3137 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3138 | dsl_binding.arraySize = 1; |
| 3139 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3140 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3141 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3142 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3143 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3144 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3145 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3146 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3147 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3148 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3149 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3150 | ASSERT_VK_SUCCESS(err); |
| 3151 | |
| 3152 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3153 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3154 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3155 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3156 | alloc_info.descriptorPool = ds_pool; |
| 3157 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3158 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3159 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3160 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3161 | VkSamplerCreateInfo sampler_ci = {}; |
| 3162 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3163 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3164 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3165 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3166 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3167 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3168 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3169 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3170 | sampler_ci.mipLodBias = 1.0; |
| 3171 | sampler_ci.maxAnisotropy = 1; |
| 3172 | sampler_ci.compareEnable = VK_FALSE; |
| 3173 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3174 | sampler_ci.minLod = 1.0; |
| 3175 | sampler_ci.maxLod = 1.0; |
| 3176 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3177 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3178 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3179 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3180 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3181 | |
| 3182 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3183 | VkDescriptorImageInfo info = {}; |
| 3184 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3185 | |
| 3186 | VkWriteDescriptorSet descriptor_write; |
| 3187 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3188 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3189 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3190 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3191 | // 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] | 3192 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3193 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3194 | |
| 3195 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3196 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3197 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3198 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 3199 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3200 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3201 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3202 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3203 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3204 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3205 | } |
| 3206 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3207 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3208 | { |
| 3209 | // Create a single Sampler descriptor and send it an invalid Sampler |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3210 | VkResult err; |
| 3211 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3212 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3213 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3214 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3215 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3216 | // 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] | 3217 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3218 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3219 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3220 | |
| 3221 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3222 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3223 | ds_pool_ci.pNext = NULL; |
| 3224 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3225 | ds_pool_ci.poolSizeCount = 1; |
| 3226 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3227 | |
| 3228 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3229 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3230 | ASSERT_VK_SUCCESS(err); |
| 3231 | |
| 3232 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3233 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3234 | dsl_binding.arraySize = 1; |
| 3235 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3236 | dsl_binding.pImmutableSamplers = NULL; |
| 3237 | |
| 3238 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3239 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3240 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3241 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3242 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3243 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3244 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3245 | ASSERT_VK_SUCCESS(err); |
| 3246 | |
| 3247 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3248 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3249 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3250 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3251 | alloc_info.descriptorPool = ds_pool; |
| 3252 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3253 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3254 | ASSERT_VK_SUCCESS(err); |
| 3255 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3256 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3257 | |
| 3258 | VkDescriptorImageInfo descriptor_info; |
| 3259 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3260 | descriptor_info.sampler = sampler; |
| 3261 | |
| 3262 | VkWriteDescriptorSet descriptor_write; |
| 3263 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3264 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3265 | descriptor_write.dstSet = descriptorSet; |
| 3266 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3267 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3268 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3269 | descriptor_write.pImageInfo = &descriptor_info; |
| 3270 | |
| 3271 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3272 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3273 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3274 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid sampler...'"; |
| 3275 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3276 | } |
| 3277 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3278 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3279 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3280 | } |
| 3281 | |
| 3282 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3283 | { |
| 3284 | // 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] | 3285 | VkResult err; |
| 3286 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3287 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3288 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3289 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3290 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3291 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3292 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3293 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3294 | |
| 3295 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3296 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3297 | ds_pool_ci.pNext = NULL; |
| 3298 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3299 | ds_pool_ci.poolSizeCount = 1; |
| 3300 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3301 | |
| 3302 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3303 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3304 | ASSERT_VK_SUCCESS(err); |
| 3305 | |
| 3306 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3307 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3308 | dsl_binding.arraySize = 1; |
| 3309 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3310 | dsl_binding.pImmutableSamplers = NULL; |
| 3311 | |
| 3312 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3313 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3314 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3315 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3316 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3317 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3318 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3319 | ASSERT_VK_SUCCESS(err); |
| 3320 | |
| 3321 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3322 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3323 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3324 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3325 | alloc_info.descriptorPool = ds_pool; |
| 3326 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3327 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3328 | ASSERT_VK_SUCCESS(err); |
| 3329 | |
| 3330 | VkSamplerCreateInfo sampler_ci = {}; |
| 3331 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3332 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3333 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3334 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3335 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3336 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3337 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3338 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3339 | sampler_ci.mipLodBias = 1.0; |
| 3340 | sampler_ci.maxAnisotropy = 1; |
| 3341 | sampler_ci.compareEnable = VK_FALSE; |
| 3342 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3343 | sampler_ci.minLod = 1.0; |
| 3344 | sampler_ci.maxLod = 1.0; |
| 3345 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3346 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3347 | |
| 3348 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3349 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3350 | ASSERT_VK_SUCCESS(err); |
| 3351 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3352 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3353 | |
| 3354 | VkDescriptorImageInfo descriptor_info; |
| 3355 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3356 | descriptor_info.sampler = sampler; |
| 3357 | descriptor_info.imageView = view; |
| 3358 | |
| 3359 | VkWriteDescriptorSet descriptor_write; |
| 3360 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3361 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3362 | descriptor_write.dstSet = descriptorSet; |
| 3363 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3364 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3365 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3366 | descriptor_write.pImageInfo = &descriptor_info; |
| 3367 | |
| 3368 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3369 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3370 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3371 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid imageView...'"; |
| 3372 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3373 | } |
| 3374 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3375 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3376 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3377 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3378 | } |
| 3379 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3380 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3381 | { |
| 3382 | // 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] | 3383 | VkResult err; |
| 3384 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3385 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3386 | "Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER "); |
| 3387 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3388 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3389 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3390 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3391 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3392 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3393 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3394 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3395 | |
| 3396 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3397 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3398 | ds_pool_ci.pNext = NULL; |
| 3399 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3400 | ds_pool_ci.poolSizeCount = 2; |
| 3401 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3402 | |
| 3403 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3404 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3405 | ASSERT_VK_SUCCESS(err); |
| 3406 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
| 3407 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3408 | dsl_binding[0].arraySize = 1; |
| 3409 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3410 | dsl_binding[0].pImmutableSamplers = NULL; |
| 3411 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3412 | dsl_binding[1].arraySize = 1; |
| 3413 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3414 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3415 | |
| 3416 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3417 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3418 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3419 | ds_layout_ci.bindingCount = 2; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3420 | ds_layout_ci.pBinding = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3421 | |
| 3422 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3423 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3424 | ASSERT_VK_SUCCESS(err); |
| 3425 | |
| 3426 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3427 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3428 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3429 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3430 | alloc_info.descriptorPool = ds_pool; |
| 3431 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3432 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3433 | ASSERT_VK_SUCCESS(err); |
| 3434 | |
| 3435 | VkSamplerCreateInfo sampler_ci = {}; |
| 3436 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3437 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3438 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3439 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3440 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3441 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3442 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3443 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3444 | sampler_ci.mipLodBias = 1.0; |
| 3445 | sampler_ci.maxAnisotropy = 1; |
| 3446 | sampler_ci.compareEnable = VK_FALSE; |
| 3447 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3448 | sampler_ci.minLod = 1.0; |
| 3449 | sampler_ci.maxLod = 1.0; |
| 3450 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3451 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3452 | |
| 3453 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3454 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3455 | ASSERT_VK_SUCCESS(err); |
| 3456 | |
| 3457 | VkDescriptorImageInfo info = {}; |
| 3458 | info.sampler = sampler; |
| 3459 | |
| 3460 | VkWriteDescriptorSet descriptor_write; |
| 3461 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 3462 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3463 | descriptor_write.dstSet = descriptorSet; |
| 3464 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3465 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3466 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3467 | descriptor_write.pImageInfo = &info; |
| 3468 | // This write update should succeed |
| 3469 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3470 | // Now perform a copy update that fails due to type mismatch |
| 3471 | VkCopyDescriptorSet copy_ds_update; |
| 3472 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3473 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3474 | copy_ds_update.srcSet = descriptorSet; |
| 3475 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3476 | copy_ds_update.dstSet = descriptorSet; |
| 3477 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3478 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3479 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3480 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3481 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3482 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, update count #1, has src update descriptor type_DESCRIPTOR_TYPE_SAMPLER'"; |
| 3483 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3484 | } |
| 3485 | // 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] | 3486 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3487 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3488 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3489 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3490 | copy_ds_update.srcSet = descriptorSet; |
| 3491 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3492 | copy_ds_update.dstSet = descriptorSet; |
| 3493 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3494 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3495 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3496 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3497 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3498 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...'"; |
| 3499 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3500 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3501 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3502 | // 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] | 3503 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3504 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 3505 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3506 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3507 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3508 | copy_ds_update.srcSet = descriptorSet; |
| 3509 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3510 | copy_ds_update.dstSet = descriptorSet; |
| 3511 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3512 | 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] | 3513 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3514 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3515 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3516 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of bounds for matching binding 1...'"; |
| 3517 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3518 | } |
| 3519 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3520 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3521 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3522 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3523 | } |
| 3524 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3525 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 3526 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3527 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3528 | VkResult err; |
| 3529 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3530 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3531 | "Num samples mismatch! "); |
| 3532 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3533 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3534 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3535 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3536 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3537 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3538 | |
| 3539 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3540 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3541 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3542 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3543 | ds_pool_ci.poolSizeCount = 1; |
| 3544 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3545 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3546 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3547 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3548 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3549 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3550 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3551 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3552 | dsl_binding.arraySize = 1; |
| 3553 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3554 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3555 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3556 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3557 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3558 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3559 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3560 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3561 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3562 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3563 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3564 | ASSERT_VK_SUCCESS(err); |
| 3565 | |
| 3566 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3567 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3568 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3569 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3570 | alloc_info.descriptorPool = ds_pool; |
| 3571 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3572 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3573 | ASSERT_VK_SUCCESS(err); |
| 3574 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3575 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3576 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3577 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3578 | pipe_ms_state_ci.rasterizationSamples = 4; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3579 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3580 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3581 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3582 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3583 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3584 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3585 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3586 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3587 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3588 | |
| 3589 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3590 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3591 | ASSERT_VK_SUCCESS(err); |
| 3592 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3593 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3594 | 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] | 3595 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3596 | VkPipelineObj pipe(m_device); |
| 3597 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3598 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3599 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3600 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3601 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3602 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3603 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3604 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3605 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3606 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 3607 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3608 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3609 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3610 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3611 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3612 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3613 | } |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3614 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3615 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 3616 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3617 | // 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] | 3618 | VkResult err; |
| 3619 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3620 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 3621 | "vkCmdClearAttachments() issued on CB object "); |
| 3622 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3623 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3624 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3625 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3626 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3627 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3628 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3629 | |
| 3630 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3631 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3632 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3633 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3634 | ds_pool_ci.poolSizeCount = 1; |
| 3635 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3636 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3637 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3638 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3639 | ASSERT_VK_SUCCESS(err); |
| 3640 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3641 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3642 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3643 | dsl_binding.arraySize = 1; |
| 3644 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3645 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3646 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3647 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3648 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3649 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3650 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3651 | ds_layout_ci.pBinding = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3652 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3653 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3654 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3655 | ASSERT_VK_SUCCESS(err); |
| 3656 | |
| 3657 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3658 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3659 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3660 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3661 | alloc_info.descriptorPool = ds_pool; |
| 3662 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3663 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3664 | ASSERT_VK_SUCCESS(err); |
| 3665 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3666 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3667 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3668 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3669 | pipe_ms_state_ci.rasterizationSamples = 4; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3670 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3671 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3672 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3673 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3674 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3675 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3676 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3677 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3678 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3679 | |
| 3680 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3681 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3682 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3683 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3684 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3685 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 3686 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3687 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3688 | VkPipelineObj pipe(m_device); |
| 3689 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3690 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3691 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3692 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3693 | |
| 3694 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3695 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3696 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 3697 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3698 | VkClearAttachment color_attachment; |
| 3699 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3700 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 3701 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 3702 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 3703 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 3704 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3705 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3706 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3707 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3708 | |
| 3709 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3710 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued on CB object...'"; |
| 3711 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3712 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3713 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3714 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3715 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3716 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3717 | } |
| 3718 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3719 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 3720 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3721 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3722 | VkResult err; |
| 3723 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3724 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3725 | "Vtx Buffer Index 1 was bound, but no vtx buffers are attached to PSO."); |
| 3726 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3727 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3728 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3729 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3730 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3731 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3732 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3733 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3734 | |
| 3735 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3736 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3737 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3738 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3739 | ds_pool_ci.poolSizeCount = 1; |
| 3740 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3741 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3742 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3743 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3744 | ASSERT_VK_SUCCESS(err); |
| 3745 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3746 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3747 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3748 | dsl_binding.arraySize = 1; |
| 3749 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3750 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3751 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3752 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3753 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3754 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3755 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3756 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3757 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3758 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3759 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3760 | ASSERT_VK_SUCCESS(err); |
| 3761 | |
| 3762 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3763 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3764 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3765 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3766 | alloc_info.descriptorPool = ds_pool; |
| 3767 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3768 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3769 | ASSERT_VK_SUCCESS(err); |
| 3770 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3771 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3772 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3773 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3774 | pipe_ms_state_ci.rasterizationSamples = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3775 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3776 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3777 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3778 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3779 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3780 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3781 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3782 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3783 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3784 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3785 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3786 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3787 | ASSERT_VK_SUCCESS(err); |
| 3788 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3789 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3790 | 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] | 3791 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3792 | VkPipelineObj pipe(m_device); |
| 3793 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3794 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3795 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3796 | pipe.SetViewport(m_viewports); |
| 3797 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3798 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3799 | |
| 3800 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3801 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 3802 | // Don't care about actual data, just need to get to draw to flag error |
| 3803 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 3804 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 3805 | 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] | 3806 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3807 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3808 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3809 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.'"; |
| 3810 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3811 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3812 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3813 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3814 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3815 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3816 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3817 | #endif // DRAW_STATE_TESTS |
| 3818 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3819 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3820 | #if GTEST_IS_THREADSAFE |
| 3821 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3822 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3823 | VkEvent event; |
| 3824 | bool bailout; |
| 3825 | }; |
| 3826 | |
| 3827 | extern "C" void *AddToCommandBuffer(void *arg) |
| 3828 | { |
| 3829 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3830 | |
| 3831 | for (int i = 0; i<10000; i++) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3832 | vkCmdSetEvent(data->commandBuffer, data->event, VK_PIPELINE_STAGE_ALL_GPU_COMMANDS); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3833 | if (data->bailout) { |
| 3834 | break; |
| 3835 | } |
| 3836 | } |
| 3837 | return NULL; |
| 3838 | } |
| 3839 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3840 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3841 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3842 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3843 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3844 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "THREADING ERROR"); |
| 3845 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3846 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3847 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3848 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3849 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3850 | // Calls AllocateCommandBuffers |
| 3851 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3852 | |
| 3853 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3854 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3855 | |
| 3856 | VkEventCreateInfo event_info; |
| 3857 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3858 | VkResult err; |
| 3859 | |
| 3860 | memset(&event_info, 0, sizeof(event_info)); |
| 3861 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3862 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3863 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3864 | ASSERT_VK_SUCCESS(err); |
| 3865 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3866 | err = vkResetEvent(device(), event); |
| 3867 | ASSERT_VK_SUCCESS(err); |
| 3868 | |
| 3869 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3870 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3871 | data.event = event; |
| 3872 | data.bailout = false; |
| 3873 | m_errorMonitor->SetBailout(&data.bailout); |
| 3874 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3875 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3876 | // Add many entries to command buffer from this thread at the same time. |
| 3877 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3878 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3879 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3880 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3881 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3882 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3883 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one VkCommandBufferObj in two threads"; |
| 3884 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3885 | } |
| 3886 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3887 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3888 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3889 | #endif // GTEST_IS_THREADSAFE |
| 3890 | #endif // THREADING_TESTS |
| 3891 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3892 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3893 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 3894 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3895 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3896 | "Shader is not SPIR-V"); |
| 3897 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3898 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3899 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3900 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3901 | VkShaderModule module; |
| 3902 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3903 | struct icd_spv_header spv; |
| 3904 | |
| 3905 | spv.magic = ICD_SPV_MAGIC; |
| 3906 | spv.version = ICD_SPV_VERSION; |
| 3907 | spv.gen_magic = 0; |
| 3908 | |
| 3909 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3910 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3911 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3912 | moduleCreateInfo.codeSize = 4; |
| 3913 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3914 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3915 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3916 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3917 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 3918 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3919 | } |
| 3920 | } |
| 3921 | |
| 3922 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 3923 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3924 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3925 | "Shader is not SPIR-V"); |
| 3926 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3927 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3928 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3929 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3930 | VkShaderModule module; |
| 3931 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3932 | struct icd_spv_header spv; |
| 3933 | |
| 3934 | spv.magic = ~ICD_SPV_MAGIC; |
| 3935 | spv.version = ICD_SPV_VERSION; |
| 3936 | spv.gen_magic = 0; |
| 3937 | |
| 3938 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3939 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3940 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3941 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 3942 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3943 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3944 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3945 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3946 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 3947 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3948 | } |
| 3949 | } |
| 3950 | |
| 3951 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 3952 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3953 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3954 | "Shader is not SPIR-V"); |
| 3955 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3956 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3957 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3958 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3959 | VkShaderModule module; |
| 3960 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3961 | struct icd_spv_header spv; |
| 3962 | |
| 3963 | spv.magic = ICD_SPV_MAGIC; |
| 3964 | spv.version = ~ICD_SPV_VERSION; |
| 3965 | spv.gen_magic = 0; |
| 3966 | |
| 3967 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3968 | moduleCreateInfo.pNext = NULL; |
| 3969 | |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3970 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3971 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 3972 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3973 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3974 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3975 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3976 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 3977 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3978 | } |
| 3979 | } |
| 3980 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3981 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 3982 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3983 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 3984 | "not consumed by fragment shader"); |
| 3985 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3986 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3987 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3988 | |
| 3989 | char const *vsSource = |
| 3990 | "#version 140\n" |
| 3991 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3992 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3993 | "\n" |
| 3994 | "layout(location=0) out float x;\n" |
| 3995 | "void main(){\n" |
| 3996 | " gl_Position = vec4(1);\n" |
| 3997 | " x = 0;\n" |
| 3998 | "}\n"; |
| 3999 | char const *fsSource = |
| 4000 | "#version 140\n" |
| 4001 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4002 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4003 | "\n" |
| 4004 | "layout(location=0) out vec4 color;\n" |
| 4005 | "void main(){\n" |
| 4006 | " color = vec4(1);\n" |
| 4007 | "}\n"; |
| 4008 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4009 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4010 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4011 | |
| 4012 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4013 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4014 | pipe.AddShader(&vs); |
| 4015 | pipe.AddShader(&fs); |
| 4016 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4017 | VkDescriptorSetObj descriptorSet(m_device); |
| 4018 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4019 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4020 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4021 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4022 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4023 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4024 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 4025 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4026 | } |
| 4027 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4028 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4029 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4030 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4031 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4032 | "not written by vertex shader"); |
| 4033 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4034 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4035 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4036 | |
| 4037 | char const *vsSource = |
| 4038 | "#version 140\n" |
| 4039 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4040 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4041 | "\n" |
| 4042 | "void main(){\n" |
| 4043 | " gl_Position = vec4(1);\n" |
| 4044 | "}\n"; |
| 4045 | char const *fsSource = |
| 4046 | "#version 140\n" |
| 4047 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4048 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4049 | "\n" |
| 4050 | "layout(location=0) in float x;\n" |
| 4051 | "layout(location=0) out vec4 color;\n" |
| 4052 | "void main(){\n" |
| 4053 | " color = vec4(x);\n" |
| 4054 | "}\n"; |
| 4055 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4056 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4057 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4058 | |
| 4059 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4060 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4061 | pipe.AddShader(&vs); |
| 4062 | pipe.AddShader(&fs); |
| 4063 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4064 | VkDescriptorSetObj descriptorSet(m_device); |
| 4065 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4066 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4067 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4068 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4069 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4070 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4071 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 4072 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4073 | } |
| 4074 | } |
| 4075 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4076 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4077 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4078 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4079 | "Type mismatch on location 0"); |
| 4080 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4081 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4082 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4083 | |
| 4084 | char const *vsSource = |
| 4085 | "#version 140\n" |
| 4086 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4087 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4088 | "\n" |
| 4089 | "layout(location=0) out int x;\n" |
| 4090 | "void main(){\n" |
| 4091 | " x = 0;\n" |
| 4092 | " gl_Position = vec4(1);\n" |
| 4093 | "}\n"; |
| 4094 | char const *fsSource = |
| 4095 | "#version 140\n" |
| 4096 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4097 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4098 | "\n" |
| 4099 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4100 | "layout(location=0) out vec4 color;\n" |
| 4101 | "void main(){\n" |
| 4102 | " color = vec4(x);\n" |
| 4103 | "}\n"; |
| 4104 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4105 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4106 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4107 | |
| 4108 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4109 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4110 | pipe.AddShader(&vs); |
| 4111 | pipe.AddShader(&fs); |
| 4112 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4113 | VkDescriptorSetObj descriptorSet(m_device); |
| 4114 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4115 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4116 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4117 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4118 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4119 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4120 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 4121 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4122 | } |
| 4123 | } |
| 4124 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4125 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4126 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4127 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4128 | "location 0 not consumed by VS"); |
| 4129 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4130 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4131 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4132 | |
| 4133 | VkVertexInputBindingDescription input_binding; |
| 4134 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4135 | |
| 4136 | VkVertexInputAttributeDescription input_attrib; |
| 4137 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4138 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4139 | |
| 4140 | char const *vsSource = |
| 4141 | "#version 140\n" |
| 4142 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4143 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4144 | "\n" |
| 4145 | "void main(){\n" |
| 4146 | " gl_Position = vec4(1);\n" |
| 4147 | "}\n"; |
| 4148 | char const *fsSource = |
| 4149 | "#version 140\n" |
| 4150 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4151 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4152 | "\n" |
| 4153 | "layout(location=0) out vec4 color;\n" |
| 4154 | "void main(){\n" |
| 4155 | " color = vec4(1);\n" |
| 4156 | "}\n"; |
| 4157 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4158 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4159 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4160 | |
| 4161 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4162 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4163 | pipe.AddShader(&vs); |
| 4164 | pipe.AddShader(&fs); |
| 4165 | |
| 4166 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4167 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4168 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4169 | VkDescriptorSetObj descriptorSet(m_device); |
| 4170 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4171 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4172 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4173 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4174 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4175 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4176 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 4177 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4178 | } |
| 4179 | } |
| 4180 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4181 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4182 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4183 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4184 | "VS consumes input at location 0 but not provided"); |
| 4185 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4186 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4187 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4188 | |
| 4189 | char const *vsSource = |
| 4190 | "#version 140\n" |
| 4191 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4192 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4193 | "\n" |
| 4194 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4195 | "void main(){\n" |
| 4196 | " gl_Position = x;\n" |
| 4197 | "}\n"; |
| 4198 | char const *fsSource = |
| 4199 | "#version 140\n" |
| 4200 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4201 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4202 | "\n" |
| 4203 | "layout(location=0) out vec4 color;\n" |
| 4204 | "void main(){\n" |
| 4205 | " color = vec4(1);\n" |
| 4206 | "}\n"; |
| 4207 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4208 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4209 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4210 | |
| 4211 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4212 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4213 | pipe.AddShader(&vs); |
| 4214 | pipe.AddShader(&fs); |
| 4215 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4216 | VkDescriptorSetObj descriptorSet(m_device); |
| 4217 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4218 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4219 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4220 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4221 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4222 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4223 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but not provided'"; |
| 4224 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4225 | } |
| 4226 | } |
| 4227 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4228 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4229 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4230 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4231 | "location 0 does not match VS input type"); |
| 4232 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4233 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4234 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4235 | |
| 4236 | VkVertexInputBindingDescription input_binding; |
| 4237 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4238 | |
| 4239 | VkVertexInputAttributeDescription input_attrib; |
| 4240 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4241 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4242 | |
| 4243 | char const *vsSource = |
| 4244 | "#version 140\n" |
| 4245 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4246 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4247 | "\n" |
| 4248 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4249 | "void main(){\n" |
| 4250 | " gl_Position = vec4(x);\n" |
| 4251 | "}\n"; |
| 4252 | char const *fsSource = |
| 4253 | "#version 140\n" |
| 4254 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4255 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4256 | "\n" |
| 4257 | "layout(location=0) out vec4 color;\n" |
| 4258 | "void main(){\n" |
| 4259 | " color = vec4(1);\n" |
| 4260 | "}\n"; |
| 4261 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4262 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4263 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4264 | |
| 4265 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4266 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4267 | pipe.AddShader(&vs); |
| 4268 | pipe.AddShader(&fs); |
| 4269 | |
| 4270 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4271 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4272 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4273 | VkDescriptorSetObj descriptorSet(m_device); |
| 4274 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4275 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4276 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4277 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4278 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4279 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4280 | FAIL() << "Did not receive Error 'location 0 does not match VS input type'"; |
| 4281 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4282 | } |
| 4283 | } |
| 4284 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4285 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4286 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4287 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4288 | "Duplicate vertex input binding descriptions for binding 0"); |
| 4289 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4290 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4291 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4292 | |
| 4293 | /* Two binding descriptions for binding 0 */ |
| 4294 | VkVertexInputBindingDescription input_bindings[2]; |
| 4295 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4296 | |
| 4297 | VkVertexInputAttributeDescription input_attrib; |
| 4298 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4299 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4300 | |
| 4301 | char const *vsSource = |
| 4302 | "#version 140\n" |
| 4303 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4304 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4305 | "\n" |
| 4306 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 4307 | "void main(){\n" |
| 4308 | " gl_Position = vec4(x);\n" |
| 4309 | "}\n"; |
| 4310 | char const *fsSource = |
| 4311 | "#version 140\n" |
| 4312 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4313 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4314 | "\n" |
| 4315 | "layout(location=0) out vec4 color;\n" |
| 4316 | "void main(){\n" |
| 4317 | " color = vec4(1);\n" |
| 4318 | "}\n"; |
| 4319 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4320 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4321 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4322 | |
| 4323 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4324 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4325 | pipe.AddShader(&vs); |
| 4326 | pipe.AddShader(&fs); |
| 4327 | |
| 4328 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 4329 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4330 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4331 | VkDescriptorSetObj descriptorSet(m_device); |
| 4332 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4333 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4334 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4335 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4336 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4337 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4338 | FAIL() << "Did not receive Error 'Duplicate vertex input binding descriptions for binding 0'"; |
| 4339 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4340 | } |
| 4341 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 4342 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4343 | /* TODO: would be nice to test the mixed broadcast & custom case, but the GLSL->SPV compiler |
| 4344 | * rejects it. */ |
| 4345 | |
| 4346 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 4347 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4348 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4349 | "Attachment 0 not written by FS"); |
| 4350 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4351 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4352 | |
| 4353 | char const *vsSource = |
| 4354 | "#version 140\n" |
| 4355 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4356 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4357 | "\n" |
| 4358 | "void main(){\n" |
| 4359 | " gl_Position = vec4(1);\n" |
| 4360 | "}\n"; |
| 4361 | char const *fsSource = |
| 4362 | "#version 140\n" |
| 4363 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4364 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4365 | "\n" |
| 4366 | "void main(){\n" |
| 4367 | "}\n"; |
| 4368 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4369 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4370 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4371 | |
| 4372 | VkPipelineObj pipe(m_device); |
| 4373 | pipe.AddShader(&vs); |
| 4374 | pipe.AddShader(&fs); |
| 4375 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4376 | /* set up CB 0, not written */ |
| 4377 | pipe.AddColorAttachment(); |
| 4378 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4379 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4380 | VkDescriptorSetObj descriptorSet(m_device); |
| 4381 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4382 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4383 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4384 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4385 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4386 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4387 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 4388 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4389 | } |
| 4390 | } |
| 4391 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4392 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 4393 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4394 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4395 | "FS writes to output location 1 with no matching attachment"); |
| 4396 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4397 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4398 | |
| 4399 | char const *vsSource = |
| 4400 | "#version 140\n" |
| 4401 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4402 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4403 | "\n" |
| 4404 | "void main(){\n" |
| 4405 | " gl_Position = vec4(1);\n" |
| 4406 | "}\n"; |
| 4407 | char const *fsSource = |
| 4408 | "#version 140\n" |
| 4409 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4410 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4411 | "\n" |
| 4412 | "layout(location=0) out vec4 x;\n" |
| 4413 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 4414 | "void main(){\n" |
| 4415 | " x = vec4(1);\n" |
| 4416 | " y = vec4(1);\n" |
| 4417 | "}\n"; |
| 4418 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4419 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4420 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4421 | |
| 4422 | VkPipelineObj pipe(m_device); |
| 4423 | pipe.AddShader(&vs); |
| 4424 | pipe.AddShader(&fs); |
| 4425 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4426 | /* set up CB 0, not written */ |
| 4427 | pipe.AddColorAttachment(); |
| 4428 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4429 | /* FS writes CB 1, but we don't configure it */ |
| 4430 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4431 | VkDescriptorSetObj descriptorSet(m_device); |
| 4432 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4433 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4434 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4435 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4436 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4437 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4438 | FAIL() << "Did not receive Error 'FS writes to output location 1 with no matching attachment'"; |
| 4439 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4440 | } |
| 4441 | } |
| 4442 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4443 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 4444 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4445 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4446 | "does not match FS output type"); |
| 4447 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4448 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4449 | |
| 4450 | char const *vsSource = |
| 4451 | "#version 140\n" |
| 4452 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4453 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4454 | "\n" |
| 4455 | "void main(){\n" |
| 4456 | " gl_Position = vec4(1);\n" |
| 4457 | "}\n"; |
| 4458 | char const *fsSource = |
| 4459 | "#version 140\n" |
| 4460 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4461 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4462 | "\n" |
| 4463 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 4464 | "void main(){\n" |
| 4465 | " x = ivec4(1);\n" |
| 4466 | "}\n"; |
| 4467 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4468 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4469 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4470 | |
| 4471 | VkPipelineObj pipe(m_device); |
| 4472 | pipe.AddShader(&vs); |
| 4473 | pipe.AddShader(&fs); |
| 4474 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4475 | /* set up CB 0; type is UNORM by default */ |
| 4476 | pipe.AddColorAttachment(); |
| 4477 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4478 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4479 | VkDescriptorSetObj descriptorSet(m_device); |
| 4480 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4481 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4482 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4483 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4484 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4485 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4486 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 4487 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4488 | } |
| 4489 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 4490 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4491 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 4492 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4493 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4494 | "not declared in pipeline layout"); |
| 4495 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4496 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4497 | |
| 4498 | char const *vsSource = |
| 4499 | "#version 140\n" |
| 4500 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4501 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4502 | "\n" |
| 4503 | "void main(){\n" |
| 4504 | " gl_Position = vec4(1);\n" |
| 4505 | "}\n"; |
| 4506 | char const *fsSource = |
| 4507 | "#version 140\n" |
| 4508 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4509 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4510 | "\n" |
| 4511 | "layout(location=0) out vec4 x;\n" |
| 4512 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4513 | "void main(){\n" |
| 4514 | " x = vec4(bar.y);\n" |
| 4515 | "}\n"; |
| 4516 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4517 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4518 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4519 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4520 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4521 | VkPipelineObj pipe(m_device); |
| 4522 | pipe.AddShader(&vs); |
| 4523 | pipe.AddShader(&fs); |
| 4524 | |
| 4525 | /* set up CB 0; type is UNORM by default */ |
| 4526 | pipe.AddColorAttachment(); |
| 4527 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4528 | |
| 4529 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4530 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4531 | |
| 4532 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4533 | |
| 4534 | /* should have generated an error -- pipeline layout does not |
| 4535 | * provide a uniform buffer in 0.0 |
| 4536 | */ |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4537 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4538 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 4539 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4540 | } |
| 4541 | } |
| 4542 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4543 | #endif // SHADER_CHECKER_TESTS |
| 4544 | |
| 4545 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4546 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 4547 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4548 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4549 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4550 | |
| 4551 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4552 | |
| 4553 | // Create an image |
| 4554 | VkImage image; |
| 4555 | |
| 4556 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4557 | const int32_t tex_width = 32; |
| 4558 | const int32_t tex_height = 32; |
| 4559 | |
| 4560 | VkImageCreateInfo image_create_info = {}; |
| 4561 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4562 | image_create_info.pNext = NULL; |
| 4563 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4564 | image_create_info.format = tex_format; |
| 4565 | image_create_info.extent.width = tex_width; |
| 4566 | image_create_info.extent.height = tex_height; |
| 4567 | image_create_info.extent.depth = 1; |
| 4568 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4569 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4570 | image_create_info.samples = 1; |
| 4571 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4572 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4573 | image_create_info.flags = 0; |
| 4574 | |
| 4575 | // Introduce error by sending down a bogus width extent |
| 4576 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4577 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4578 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4579 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4580 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable limits for format'"; |
| 4581 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4582 | } |
| 4583 | } |
| 4584 | |
| 4585 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 4586 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4587 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4588 | "CreateImage resource size exceeds allowable maximum"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4589 | |
| 4590 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4591 | |
| 4592 | // Create an image |
| 4593 | VkImage image; |
| 4594 | |
| 4595 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4596 | const int32_t tex_width = 32; |
| 4597 | const int32_t tex_height = 32; |
| 4598 | |
| 4599 | VkImageCreateInfo image_create_info = {}; |
| 4600 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4601 | image_create_info.pNext = NULL; |
| 4602 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4603 | image_create_info.format = tex_format; |
| 4604 | image_create_info.extent.width = tex_width; |
| 4605 | image_create_info.extent.height = tex_height; |
| 4606 | image_create_info.extent.depth = 1; |
| 4607 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4608 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4609 | image_create_info.samples = 1; |
| 4610 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4611 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4612 | image_create_info.flags = 0; |
| 4613 | |
| 4614 | // Introduce error by sending down individually allowable values that result in a surface size |
| 4615 | // exceeding the device maximum |
| 4616 | image_create_info.extent.width = 8192; |
| 4617 | image_create_info.extent.height = 8192; |
| 4618 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4619 | image_create_info.arrayLayers = 4; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4620 | image_create_info.samples = 2; |
| 4621 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4622 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4623 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4624 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4625 | FAIL() << "Did not receive Error 'CreateImage resource size exceeds allowable maximum'"; |
| 4626 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4627 | } |
| 4628 | } |
| 4629 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4630 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 4631 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4632 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 4633 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4634 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4635 | "dstOffset, is not a multiple of 4"); |
| 4636 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4637 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4638 | |
| 4639 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4640 | vk_testing::Buffer buffer; |
| 4641 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4642 | |
| 4643 | BeginCommandBuffer(); |
| 4644 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4645 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4646 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4647 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4648 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4649 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4650 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4651 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4652 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4653 | "dataSize, is not a multiple of 4"); |
| 4654 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4655 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4656 | |
| 4657 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4658 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 4659 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4660 | } |
| 4661 | EndCommandBuffer(); |
| 4662 | } |
| 4663 | |
| 4664 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 4665 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4666 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4667 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4668 | |
| 4669 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4670 | |
| 4671 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4672 | vk_testing::Buffer buffer; |
| 4673 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4674 | |
| 4675 | BeginCommandBuffer(); |
| 4676 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4677 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4678 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4679 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4680 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4681 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4682 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4683 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4684 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4685 | "size, is not a multiple of 4"); |
| 4686 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4687 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4688 | |
| 4689 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4690 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize size, is not a multiple of 4'"; |
| 4691 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4692 | } |
| 4693 | EndCommandBuffer(); |
| 4694 | } |
| 4695 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4696 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4697 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4698 | #if IMAGE_TESTS |
| 4699 | TEST_F(VkLayerTest, InvalidImageView) |
| 4700 | { |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4701 | VkResult err; |
| 4702 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4703 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4704 | "vkCreateImageView called with baseMipLevel 10 "); |
| 4705 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4706 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4707 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4708 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4709 | VkImage image; |
| 4710 | |
| 4711 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4712 | const int32_t tex_width = 32; |
| 4713 | const int32_t tex_height = 32; |
| 4714 | |
| 4715 | VkImageCreateInfo image_create_info = {}; |
| 4716 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4717 | image_create_info.pNext = NULL; |
| 4718 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4719 | image_create_info.format = tex_format; |
| 4720 | image_create_info.extent.width = tex_width; |
| 4721 | image_create_info.extent.height = tex_height; |
| 4722 | image_create_info.extent.depth = 1; |
| 4723 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4724 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4725 | image_create_info.samples = 1; |
| 4726 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4727 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4728 | image_create_info.flags = 0; |
| 4729 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4730 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4731 | ASSERT_VK_SUCCESS(err); |
| 4732 | |
| 4733 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4734 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4735 | image_view_create_info.image = image; |
| 4736 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4737 | image_view_create_info.format = tex_format; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4738 | image_view_create_info.subresourceRange.layerCount = 1; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4739 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4740 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4741 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4742 | |
| 4743 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4744 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4745 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4746 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4747 | FAIL() << "Did not receive Error 'vkCreateImageView called with baseMipLevel 10...'"; |
| 4748 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4749 | } |
| 4750 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4751 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4752 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 4753 | { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4754 | VkResult err; |
| 4755 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4756 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4757 | "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"); |
| 4758 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4759 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4760 | |
| 4761 | // Create an image and try to create a view with an invalid aspectMask |
| 4762 | VkImage image; |
| 4763 | |
| 4764 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4765 | const int32_t tex_width = 32; |
| 4766 | const int32_t tex_height = 32; |
| 4767 | |
| 4768 | VkImageCreateInfo image_create_info = {}; |
| 4769 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4770 | image_create_info.pNext = NULL; |
| 4771 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4772 | image_create_info.format = tex_format; |
| 4773 | image_create_info.extent.width = tex_width; |
| 4774 | image_create_info.extent.height = tex_height; |
| 4775 | image_create_info.extent.depth = 1; |
| 4776 | image_create_info.mipLevels = 1; |
| 4777 | image_create_info.samples = 1; |
| 4778 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4779 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4780 | image_create_info.flags = 0; |
| 4781 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4782 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4783 | ASSERT_VK_SUCCESS(err); |
| 4784 | |
| 4785 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4786 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4787 | image_view_create_info.image = image; |
| 4788 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4789 | image_view_create_info.format = tex_format; |
| 4790 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4791 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4792 | // Cause an error by setting an invalid image aspect |
| 4793 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 4794 | |
| 4795 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4796 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4797 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4798 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4799 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image formats must have ...'"; |
| 4800 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4801 | } |
| 4802 | } |
| 4803 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4804 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 4805 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4806 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4807 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4808 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4809 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4810 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 4811 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4812 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4813 | |
| 4814 | // Create two images of different types and try to copy between them |
| 4815 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4816 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4817 | VkDeviceMemory srcMem; |
| 4818 | VkDeviceMemory destMem; |
| 4819 | VkMemoryRequirements memReqs; |
| 4820 | |
| 4821 | VkImageCreateInfo image_create_info = {}; |
| 4822 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4823 | image_create_info.pNext = NULL; |
| 4824 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4825 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4826 | image_create_info.extent.width = 32; |
| 4827 | image_create_info.extent.height = 32; |
| 4828 | image_create_info.extent.depth = 1; |
| 4829 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4830 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4831 | image_create_info.samples = 1; |
| 4832 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4833 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4834 | image_create_info.flags = 0; |
| 4835 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4836 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4837 | ASSERT_VK_SUCCESS(err); |
| 4838 | |
| 4839 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4840 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4841 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4842 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4843 | ASSERT_VK_SUCCESS(err); |
| 4844 | |
| 4845 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4846 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4847 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4848 | memAlloc.pNext = NULL; |
| 4849 | memAlloc.allocationSize = 0; |
| 4850 | memAlloc.memoryTypeIndex = 0; |
| 4851 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4852 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4853 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4854 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4855 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4856 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4857 | ASSERT_VK_SUCCESS(err); |
| 4858 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4859 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4860 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4861 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4862 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4863 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4864 | ASSERT_VK_SUCCESS(err); |
| 4865 | |
| 4866 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4867 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4868 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4869 | ASSERT_VK_SUCCESS(err); |
| 4870 | |
| 4871 | BeginCommandBuffer(); |
| 4872 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4873 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4874 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4875 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4876 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4877 | copyRegion.srcOffset.x = 0; |
| 4878 | copyRegion.srcOffset.y = 0; |
| 4879 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4880 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4881 | copyRegion.dstSubresource.mipLevel = 0; |
| 4882 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 4883 | copyRegion.dstSubresource.layerCount = 0; |
| 4884 | copyRegion.dstOffset.x = 0; |
| 4885 | copyRegion.dstOffset.y = 0; |
| 4886 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4887 | copyRegion.extent.width = 1; |
| 4888 | copyRegion.extent.height = 1; |
| 4889 | copyRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4890 | 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] | 4891 | EndCommandBuffer(); |
| 4892 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4893 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4894 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 4895 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4896 | } |
| 4897 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4898 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4899 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4900 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 4901 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4902 | } |
| 4903 | |
| 4904 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 4905 | { |
| 4906 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 4907 | } |
| 4908 | |
| 4909 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 4910 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4911 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4912 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4913 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4914 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4915 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 4916 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4917 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4918 | |
| 4919 | // Create two images of different types and try to copy between them |
| 4920 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4921 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4922 | VkDeviceMemory srcMem; |
| 4923 | VkDeviceMemory destMem; |
| 4924 | VkMemoryRequirements memReqs; |
| 4925 | |
| 4926 | VkImageCreateInfo image_create_info = {}; |
| 4927 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4928 | image_create_info.pNext = NULL; |
| 4929 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4930 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4931 | image_create_info.extent.width = 32; |
| 4932 | image_create_info.extent.height = 32; |
| 4933 | image_create_info.extent.depth = 1; |
| 4934 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4935 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4936 | image_create_info.samples = 1; |
| 4937 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4938 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4939 | image_create_info.flags = 0; |
| 4940 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4941 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4942 | ASSERT_VK_SUCCESS(err); |
| 4943 | |
| 4944 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4945 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4946 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4947 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4948 | ASSERT_VK_SUCCESS(err); |
| 4949 | |
| 4950 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4951 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4952 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4953 | memAlloc.pNext = NULL; |
| 4954 | memAlloc.allocationSize = 0; |
| 4955 | memAlloc.memoryTypeIndex = 0; |
| 4956 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4957 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4958 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4959 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4960 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4961 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4962 | ASSERT_VK_SUCCESS(err); |
| 4963 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4964 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4965 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4966 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4967 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4968 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4969 | ASSERT_VK_SUCCESS(err); |
| 4970 | |
| 4971 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4972 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4973 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4974 | ASSERT_VK_SUCCESS(err); |
| 4975 | |
| 4976 | BeginCommandBuffer(); |
| 4977 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4978 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4979 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4980 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4981 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4982 | copyRegion.srcOffset.x = 0; |
| 4983 | copyRegion.srcOffset.y = 0; |
| 4984 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4985 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4986 | copyRegion.dstSubresource.mipLevel = 0; |
| 4987 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 4988 | copyRegion.dstSubresource.layerCount = 0; |
| 4989 | copyRegion.dstOffset.x = 0; |
| 4990 | copyRegion.dstOffset.y = 0; |
| 4991 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4992 | copyRegion.extent.width = 1; |
| 4993 | copyRegion.extent.height = 1; |
| 4994 | copyRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4995 | 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] | 4996 | EndCommandBuffer(); |
| 4997 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4998 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4999 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5000 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5001 | } |
| 5002 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5003 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5004 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5005 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5006 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5007 | } |
| 5008 | |
| 5009 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5010 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5011 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5012 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5013 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5014 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5015 | "vkCmdResolveImage called with source sample count less than 2."); |
| 5016 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5017 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5018 | |
| 5019 | // Create two images of sample count 1 and try to Resolve between them |
| 5020 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5021 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5022 | VkDeviceMemory srcMem; |
| 5023 | VkDeviceMemory destMem; |
| 5024 | VkMemoryRequirements memReqs; |
| 5025 | |
| 5026 | VkImageCreateInfo image_create_info = {}; |
| 5027 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5028 | image_create_info.pNext = NULL; |
| 5029 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5030 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5031 | image_create_info.extent.width = 32; |
| 5032 | image_create_info.extent.height = 1; |
| 5033 | image_create_info.extent.depth = 1; |
| 5034 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5035 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5036 | image_create_info.samples = 1; |
| 5037 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5038 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5039 | image_create_info.flags = 0; |
| 5040 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5041 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5042 | ASSERT_VK_SUCCESS(err); |
| 5043 | |
| 5044 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5045 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5046 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5047 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5048 | ASSERT_VK_SUCCESS(err); |
| 5049 | |
| 5050 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5051 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5052 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5053 | memAlloc.pNext = NULL; |
| 5054 | memAlloc.allocationSize = 0; |
| 5055 | memAlloc.memoryTypeIndex = 0; |
| 5056 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5057 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5058 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5059 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5060 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5061 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5062 | ASSERT_VK_SUCCESS(err); |
| 5063 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5064 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5065 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5066 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5067 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5068 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5069 | ASSERT_VK_SUCCESS(err); |
| 5070 | |
| 5071 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5072 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5073 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5074 | ASSERT_VK_SUCCESS(err); |
| 5075 | |
| 5076 | BeginCommandBuffer(); |
| 5077 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5078 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5079 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5080 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5081 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5082 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5083 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5084 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5085 | resolveRegion.srcOffset.x = 0; |
| 5086 | resolveRegion.srcOffset.y = 0; |
| 5087 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5088 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5089 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5090 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5091 | resolveRegion.dstSubresource.layerCount = 0; |
| 5092 | resolveRegion.dstOffset.x = 0; |
| 5093 | resolveRegion.dstOffset.y = 0; |
| 5094 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5095 | resolveRegion.extent.width = 1; |
| 5096 | resolveRegion.extent.height = 1; |
| 5097 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5098 | 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] | 5099 | EndCommandBuffer(); |
| 5100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5101 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5102 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source sample count less than 2.'"; |
| 5103 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5104 | } |
| 5105 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5106 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5107 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5108 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5109 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5110 | } |
| 5111 | |
| 5112 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5113 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5114 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5115 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5116 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5117 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5118 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 5119 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5120 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5121 | |
| 5122 | // Create two images of sample count 2 and try to Resolve between them |
| 5123 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5124 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5125 | VkDeviceMemory srcMem; |
| 5126 | VkDeviceMemory destMem; |
| 5127 | VkMemoryRequirements memReqs; |
| 5128 | |
| 5129 | VkImageCreateInfo image_create_info = {}; |
| 5130 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5131 | image_create_info.pNext = NULL; |
| 5132 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5133 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5134 | image_create_info.extent.width = 32; |
| 5135 | image_create_info.extent.height = 1; |
| 5136 | image_create_info.extent.depth = 1; |
| 5137 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5138 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5139 | image_create_info.samples = 2; |
| 5140 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5141 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5142 | 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] | 5143 | image_create_info.flags = 0; |
| 5144 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5145 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5146 | ASSERT_VK_SUCCESS(err); |
| 5147 | |
| 5148 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5149 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5150 | 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] | 5151 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5152 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5153 | ASSERT_VK_SUCCESS(err); |
| 5154 | |
| 5155 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5156 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5157 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5158 | memAlloc.pNext = NULL; |
| 5159 | memAlloc.allocationSize = 0; |
| 5160 | memAlloc.memoryTypeIndex = 0; |
| 5161 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5162 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5163 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5164 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5165 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5166 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5167 | ASSERT_VK_SUCCESS(err); |
| 5168 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5169 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5170 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5171 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5172 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5173 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5174 | ASSERT_VK_SUCCESS(err); |
| 5175 | |
| 5176 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5177 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5178 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5179 | ASSERT_VK_SUCCESS(err); |
| 5180 | |
| 5181 | BeginCommandBuffer(); |
| 5182 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5183 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5184 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5185 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5186 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5187 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5188 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5189 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5190 | resolveRegion.srcOffset.x = 0; |
| 5191 | resolveRegion.srcOffset.y = 0; |
| 5192 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5193 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5194 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5195 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5196 | resolveRegion.dstSubresource.layerCount = 0; |
| 5197 | resolveRegion.dstOffset.x = 0; |
| 5198 | resolveRegion.dstOffset.y = 0; |
| 5199 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5200 | resolveRegion.extent.width = 1; |
| 5201 | resolveRegion.extent.height = 1; |
| 5202 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5203 | 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] | 5204 | EndCommandBuffer(); |
| 5205 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5206 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5207 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest sample count greater than 1.'"; |
| 5208 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5209 | } |
| 5210 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5211 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5212 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5213 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5214 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5215 | } |
| 5216 | |
| 5217 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5218 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5219 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5220 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5221 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5222 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5223 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 5224 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5225 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5226 | |
| 5227 | // Create two images of different types and try to copy between them |
| 5228 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5229 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5230 | VkDeviceMemory srcMem; |
| 5231 | VkDeviceMemory destMem; |
| 5232 | VkMemoryRequirements memReqs; |
| 5233 | |
| 5234 | VkImageCreateInfo image_create_info = {}; |
| 5235 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5236 | image_create_info.pNext = NULL; |
| 5237 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5238 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5239 | image_create_info.extent.width = 32; |
| 5240 | image_create_info.extent.height = 1; |
| 5241 | image_create_info.extent.depth = 1; |
| 5242 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5243 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5244 | image_create_info.samples = 2; |
| 5245 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5246 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5247 | 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] | 5248 | image_create_info.flags = 0; |
| 5249 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5250 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5251 | ASSERT_VK_SUCCESS(err); |
| 5252 | |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5253 | // Set format to something other than source image |
| 5254 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5255 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5256 | 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] | 5257 | image_create_info.samples = 1; |
| 5258 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5259 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5260 | ASSERT_VK_SUCCESS(err); |
| 5261 | |
| 5262 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5263 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5264 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5265 | memAlloc.pNext = NULL; |
| 5266 | memAlloc.allocationSize = 0; |
| 5267 | memAlloc.memoryTypeIndex = 0; |
| 5268 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5269 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5270 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5271 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5272 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5273 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5274 | ASSERT_VK_SUCCESS(err); |
| 5275 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5276 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5277 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5278 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5279 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5280 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5281 | ASSERT_VK_SUCCESS(err); |
| 5282 | |
| 5283 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5284 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5285 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5286 | ASSERT_VK_SUCCESS(err); |
| 5287 | |
| 5288 | BeginCommandBuffer(); |
| 5289 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5290 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5291 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5292 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5293 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5294 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5295 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5296 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5297 | resolveRegion.srcOffset.x = 0; |
| 5298 | resolveRegion.srcOffset.y = 0; |
| 5299 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5300 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5301 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5302 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5303 | resolveRegion.dstSubresource.layerCount = 0; |
| 5304 | resolveRegion.dstOffset.x = 0; |
| 5305 | resolveRegion.dstOffset.y = 0; |
| 5306 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5307 | resolveRegion.extent.width = 1; |
| 5308 | resolveRegion.extent.height = 1; |
| 5309 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5310 | 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] | 5311 | EndCommandBuffer(); |
| 5312 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5313 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5314 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest formats.'"; |
| 5315 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5316 | } |
| 5317 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5318 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5319 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5320 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5321 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5322 | } |
| 5323 | |
| 5324 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 5325 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5326 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5327 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5328 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5329 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5330 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 5331 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5332 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5333 | |
| 5334 | // Create two images of different types and try to copy between them |
| 5335 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5336 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5337 | VkDeviceMemory srcMem; |
| 5338 | VkDeviceMemory destMem; |
| 5339 | VkMemoryRequirements memReqs; |
| 5340 | |
| 5341 | VkImageCreateInfo image_create_info = {}; |
| 5342 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5343 | image_create_info.pNext = NULL; |
| 5344 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5345 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5346 | image_create_info.extent.width = 32; |
| 5347 | image_create_info.extent.height = 1; |
| 5348 | image_create_info.extent.depth = 1; |
| 5349 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5350 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5351 | image_create_info.samples = 2; |
| 5352 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5353 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5354 | 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] | 5355 | image_create_info.flags = 0; |
| 5356 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5357 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5358 | ASSERT_VK_SUCCESS(err); |
| 5359 | |
| 5360 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5361 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5362 | 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] | 5363 | image_create_info.samples = 1; |
| 5364 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5365 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5366 | ASSERT_VK_SUCCESS(err); |
| 5367 | |
| 5368 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5369 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5370 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5371 | memAlloc.pNext = NULL; |
| 5372 | memAlloc.allocationSize = 0; |
| 5373 | memAlloc.memoryTypeIndex = 0; |
| 5374 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5375 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5376 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5377 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5378 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5379 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5380 | ASSERT_VK_SUCCESS(err); |
| 5381 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5382 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5383 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5384 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5385 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5386 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5387 | ASSERT_VK_SUCCESS(err); |
| 5388 | |
| 5389 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5390 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5391 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5392 | ASSERT_VK_SUCCESS(err); |
| 5393 | |
| 5394 | BeginCommandBuffer(); |
| 5395 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5396 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5397 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5398 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5399 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5400 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5401 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5402 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5403 | resolveRegion.srcOffset.x = 0; |
| 5404 | resolveRegion.srcOffset.y = 0; |
| 5405 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5406 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5407 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5408 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5409 | resolveRegion.dstSubresource.layerCount = 0; |
| 5410 | resolveRegion.dstOffset.x = 0; |
| 5411 | resolveRegion.dstOffset.y = 0; |
| 5412 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5413 | resolveRegion.extent.width = 1; |
| 5414 | resolveRegion.extent.height = 1; |
| 5415 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5416 | 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] | 5417 | EndCommandBuffer(); |
| 5418 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5419 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5420 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest image types.'"; |
| 5421 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5422 | } |
| 5423 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5424 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5425 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5426 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5427 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5428 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5429 | |
| 5430 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 5431 | { |
| 5432 | // Create a single Image descriptor and cause it to first hit an error due |
| 5433 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 5434 | // The image format check comes 2nd in validation so we trigger it first, |
| 5435 | // 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] | 5436 | VkResult err; |
| 5437 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5438 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5439 | "Combination depth/stencil image formats can have only the "); |
| 5440 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5441 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5442 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5443 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5444 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5445 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5446 | |
| 5447 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5448 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5449 | ds_pool_ci.pNext = NULL; |
| 5450 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5451 | ds_pool_ci.poolSizeCount = 1; |
| 5452 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5453 | |
| 5454 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5455 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5456 | ASSERT_VK_SUCCESS(err); |
| 5457 | |
| 5458 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5459 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5460 | dsl_binding.arraySize = 1; |
| 5461 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5462 | dsl_binding.pImmutableSamplers = NULL; |
| 5463 | |
| 5464 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5465 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5466 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5467 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5468 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5469 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5470 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5471 | ASSERT_VK_SUCCESS(err); |
| 5472 | |
| 5473 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5474 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5475 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5476 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5477 | alloc_info.descriptorPool = ds_pool; |
| 5478 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5479 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5480 | ASSERT_VK_SUCCESS(err); |
| 5481 | |
| 5482 | VkImage image_bad; |
| 5483 | VkImage image_good; |
| 5484 | // One bad format and one good format for Color attachment |
| 5485 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 5486 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 5487 | const int32_t tex_width = 32; |
| 5488 | const int32_t tex_height = 32; |
| 5489 | |
| 5490 | VkImageCreateInfo image_create_info = {}; |
| 5491 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5492 | image_create_info.pNext = NULL; |
| 5493 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5494 | image_create_info.format = tex_format_bad; |
| 5495 | image_create_info.extent.width = tex_width; |
| 5496 | image_create_info.extent.height = tex_height; |
| 5497 | image_create_info.extent.depth = 1; |
| 5498 | image_create_info.mipLevels = 1; |
| 5499 | image_create_info.arrayLayers = 1; |
| 5500 | image_create_info.samples = 1; |
| 5501 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5502 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 5503 | image_create_info.flags = 0; |
| 5504 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5505 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5506 | ASSERT_VK_SUCCESS(err); |
| 5507 | image_create_info.format = tex_format_good; |
| 5508 | 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] | 5509 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5510 | ASSERT_VK_SUCCESS(err); |
| 5511 | |
| 5512 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5513 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5514 | image_view_create_info.image = image_bad; |
| 5515 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5516 | image_view_create_info.format = tex_format_bad; |
| 5517 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 5518 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5519 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5520 | image_view_create_info.subresourceRange.levelCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5521 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5522 | |
| 5523 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5524 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5525 | |
| 5526 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5527 | FAIL() << "Did not receive Error 'Combination depth-stencil image formats can have only the....'"; |
| 5528 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5529 | } |
| 5530 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5531 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 5532 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5533 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5534 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5535 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5536 | #endif // IMAGE_TESTS |
| 5537 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5538 | int main(int argc, char **argv) { |
| 5539 | int result; |
| 5540 | |
| 5541 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5542 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5543 | |
| 5544 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 5545 | |
| 5546 | result = RUN_ALL_TESTS(); |
| 5547 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5548 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5549 | return result; |
| 5550 | } |