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 |
| 13 | #define OBJ_TRACKER_TESTS 1 |
| 14 | #define DRAW_STATE_TESTS 1 |
| 15 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 16 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 17 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 18 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 19 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 20 | //-------------------------------------------------------------------------------------- |
| 21 | // Mesh and VertexFormat Data |
| 22 | //-------------------------------------------------------------------------------------- |
| 23 | struct Vertex |
| 24 | { |
| 25 | float posX, posY, posZ, posW; // Position data |
| 26 | float r, g, b, a; // Color |
| 27 | }; |
| 28 | |
| 29 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
| 30 | |
| 31 | typedef enum _BsoFailSelect { |
| 32 | BsoFailNone = 0x00000000, |
Cody Northrop | 271ba75 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 33 | BsoFailLineWidth = 0x00000001, |
| 34 | BsoFailDepthBias = 0x00000002, |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 35 | BsoFailViewport = 0x00000004, |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 36 | BsoFailScissor = 0x00000008, |
| 37 | BsoFailBlend = 0x00000010, |
| 38 | BsoFailDepthBounds = 0x00000020, |
| 39 | BsoFailStencilReadMask = 0x00000040, |
| 40 | BsoFailStencilWriteMask = 0x00000080, |
| 41 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 42 | } BsoFailSelect; |
| 43 | |
| 44 | struct vktriangle_vs_uniform { |
| 45 | // Must start with MVP |
| 46 | float mvp[4][4]; |
| 47 | float position[3][4]; |
| 48 | float color[3][4]; |
| 49 | }; |
| 50 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 51 | static const char bindStateVertShaderText[] = |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 52 | "#version 130\n" |
| 53 | "vec2 vertices[3];\n" |
| 54 | "void main() {\n" |
| 55 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 56 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 57 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 58 | " gl_Position = vec4(vertices[gl_VertexID % 3], 0.0, 1.0);\n" |
| 59 | "}\n"; |
| 60 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 61 | static const char bindStateFragShaderText[] = |
Cody Northrop | 8a3bb13 | 2015-06-16 17:32:04 -0600 | [diff] [blame] | 62 | "#version 140\n" |
| 63 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 64 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 65 | "\n" |
| 66 | "layout(location = 0) out vec4 uFragColor;\n" |
| 67 | "void main(){\n" |
| 68 | " uFragColor = vec4(0,1,0,1);\n" |
| 69 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 70 | |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 71 | static VkBool32 myDbgFunc( |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 72 | VkFlags msgFlags, |
| 73 | VkDbgObjectType objType, |
| 74 | uint64_t srcObject, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 75 | size_t location, |
| 76 | int32_t msgCode, |
| 77 | const char* pLayerPrefix, |
| 78 | const char* pMsg, |
| 79 | void* pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 80 | |
| 81 | class ErrorMonitor { |
| 82 | public: |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 83 | ErrorMonitor() |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 84 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 85 | test_platform_thread_create_mutex(&m_mutex); |
| 86 | test_platform_thread_lock_mutex(&m_mutex); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 87 | m_msgFlags = VK_DBG_REPORT_INFO_BIT; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 88 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 89 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 90 | } |
| 91 | void ClearState() |
| 92 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 93 | test_platform_thread_lock_mutex(&m_mutex); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 94 | m_msgFlags = VK_DBG_REPORT_INFO_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 95 | m_msgString.clear(); |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 96 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 97 | } |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 98 | VkFlags GetState(std::string *msgString) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 99 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 100 | test_platform_thread_lock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 101 | *msgString = m_msgString; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 102 | test_platform_thread_unlock_mutex(&m_mutex); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 103 | return m_msgFlags; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 104 | } |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 105 | void SetState(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 106 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 107 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 108 | if (m_bailout != NULL) { |
| 109 | *m_bailout = true; |
| 110 | } |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 111 | m_msgFlags = msgFlags; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 112 | m_msgString.reserve(strlen(msgString)); |
| 113 | m_msgString = msgString; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 114 | test_platform_thread_unlock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 115 | } |
| 116 | void SetBailout(bool *bailout) |
| 117 | { |
| 118 | m_bailout = bailout; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | private: |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 122 | VkFlags m_msgFlags; |
| 123 | std::string m_msgString; |
| 124 | test_platform_thread_mutex m_mutex; |
| 125 | bool* m_bailout; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 126 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 127 | |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 128 | static VkBool32 myDbgFunc( |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 129 | VkFlags msgFlags, |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 130 | VkDbgObjectType objType, |
| 131 | uint64_t srcObject, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 132 | size_t location, |
| 133 | int32_t msgCode, |
| 134 | const char* pLayerPrefix, |
| 135 | const char* pMsg, |
| 136 | void* pUserData) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 137 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 138 | if (msgFlags & (VK_DBG_REPORT_WARN_BIT | VK_DBG_REPORT_ERROR_BIT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 139 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 140 | errMonitor->SetState(msgFlags, pMsg); |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 141 | return true; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 142 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 143 | |
| 144 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 145 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 146 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 147 | class VkLayerTest : public VkRenderFramework |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 148 | { |
| 149 | public: |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 150 | VkResult BeginCommandBuffer(VkCommandBufferObj &cmdBuffer); |
| 151 | VkResult EndCommandBuffer(VkCommandBufferObj &cmdBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 152 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask); |
| 153 | void GenericDrawPreparation(VkCommandBufferObj *cmdBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 154 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
| 155 | { GenericDrawPreparation(m_cmdBuffer, pipelineobj, descriptorSet, failMask); } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 156 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 157 | /* Convenience functions that use built-in command buffer */ |
| 158 | VkResult BeginCommandBuffer() { return BeginCommandBuffer(*m_cmdBuffer); } |
| 159 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_cmdBuffer); } |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 160 | void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) |
| 161 | { m_cmdBuffer->Draw(vertexCount, instanceCount, firstVertex, firstInstance); } |
| 162 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) |
| 163 | { m_cmdBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); } |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 164 | void QueueCommandBuffer() { m_cmdBuffer->QueueCommandBuffer(); } |
| 165 | void QueueCommandBuffer(const VkFence& fence) { m_cmdBuffer->QueueCommandBuffer(fence); } |
| 166 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding) |
| 167 | { m_cmdBuffer->BindVertexBuffer(vertexBuffer, offset, binding); } |
| 168 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) |
| 169 | { m_cmdBuffer->BindIndexBuffer(indexBuffer, offset); } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 170 | protected: |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 171 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 172 | |
| 173 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 174 | std::vector<const char *> instance_layer_names; |
| 175 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 176 | std::vector<const char *> instance_extension_names; |
| 177 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 178 | |
Courtney Goeltzenleuchter | 05159a9 | 2015-07-30 11:32:46 -0600 | [diff] [blame] | 179 | instance_extension_names.push_back(VK_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 180 | /* |
| 181 | * Since CreateDbgMsgCallback is an instance level extension call |
| 182 | * any extension / layer that utilizes that feature also needs |
| 183 | * to be enabled at create instance time. |
| 184 | */ |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 185 | // Use Threading layer first to protect others from ThreadCmdBufferCollision test |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 186 | instance_layer_names.push_back("Threading"); |
| 187 | instance_layer_names.push_back("ObjectTracker"); |
| 188 | instance_layer_names.push_back("MemTracker"); |
| 189 | instance_layer_names.push_back("DrawState"); |
| 190 | instance_layer_names.push_back("ShaderChecker"); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 191 | instance_layer_names.push_back("DeviceLimits"); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 192 | instance_layer_names.push_back("Image"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 193 | |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 194 | device_layer_names.push_back("Threading"); |
| 195 | device_layer_names.push_back("ObjectTracker"); |
| 196 | device_layer_names.push_back("MemTracker"); |
| 197 | device_layer_names.push_back("DrawState"); |
| 198 | device_layer_names.push_back("ShaderChecker"); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 199 | device_layer_names.push_back("DeviceLimits"); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 200 | device_layer_names.push_back("Image"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 201 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 202 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 203 | this->app_info.pNext = NULL; |
| 204 | this->app_info.pAppName = "layer_tests"; |
| 205 | this->app_info.appVersion = 1; |
| 206 | this->app_info.pEngineName = "unittest"; |
| 207 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 208 | this->app_info.apiVersion = VK_API_VERSION; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 209 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 210 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 211 | InitFramework(instance_layer_names, device_layer_names, |
| 212 | instance_extension_names, device_extension_names, |
| 213 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | virtual void TearDown() { |
| 217 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 218 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 219 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 220 | } |
| 221 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 222 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 223 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &cmdBuffer) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 224 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 225 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 226 | |
| 227 | result = cmdBuffer.BeginCommandBuffer(); |
| 228 | |
| 229 | /* |
| 230 | * For render test all drawing happens in a single render pass |
| 231 | * on a single command buffer. |
| 232 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 233 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 234 | cmdBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | return result; |
| 238 | } |
| 239 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 240 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &cmdBuffer) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 241 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 242 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 243 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 244 | if (renderPass()) { |
Chia-I Wu | 0b50a1c | 2015-06-26 15:34:39 +0800 | [diff] [blame] | 245 | cmdBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 246 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 247 | |
| 248 | result = cmdBuffer.EndCommandBuffer(); |
| 249 | |
| 250 | return result; |
| 251 | } |
| 252 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 253 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask) |
| 254 | { |
| 255 | // Create identity matrix |
| 256 | int i; |
| 257 | struct vktriangle_vs_uniform data; |
| 258 | |
| 259 | glm::mat4 Projection = glm::mat4(1.0f); |
| 260 | glm::mat4 View = glm::mat4(1.0f); |
| 261 | glm::mat4 Model = glm::mat4(1.0f); |
| 262 | glm::mat4 MVP = Projection * View * Model; |
| 263 | const int matrixSize = sizeof(MVP); |
| 264 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
| 265 | |
| 266 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 267 | |
| 268 | static const Vertex tri_data[] = |
| 269 | { |
| 270 | { XYZ1( -1, -1, 0 ), XYZ1( 1.f, 0.f, 0.f ) }, |
| 271 | { XYZ1( 1, -1, 0 ), XYZ1( 0.f, 1.f, 0.f ) }, |
| 272 | { XYZ1( 0, 1, 0 ), XYZ1( 0.f, 0.f, 1.f ) }, |
| 273 | }; |
| 274 | |
| 275 | for (i=0; i<3; i++) { |
| 276 | data.position[i][0] = tri_data[i].posX; |
| 277 | data.position[i][1] = tri_data[i].posY; |
| 278 | data.position[i][2] = tri_data[i].posZ; |
| 279 | data.position[i][3] = tri_data[i].posW; |
| 280 | data.color[i][0] = tri_data[i].r; |
| 281 | data.color[i][1] = tri_data[i].g; |
| 282 | data.color[i][2] = tri_data[i].b; |
| 283 | data.color[i][3] = tri_data[i].a; |
| 284 | } |
| 285 | |
| 286 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 287 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 288 | |
| 289 | VkConstantBufferObj constantBuffer(m_device, bufSize*2, sizeof(float), (const void*) &data); |
| 290 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 291 | VkShaderObj vs(m_device,vertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 292 | VkShaderObj ps(m_device,fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 293 | |
| 294 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 295 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 296 | pipelineobj.AddShader(&vs); |
| 297 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 298 | if (failMask & BsoFailLineWidth) { |
| 299 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
| 300 | } |
| 301 | if (failMask & BsoFailDepthBias) { |
| 302 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
| 303 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 304 | // 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] | 305 | if (failMask & BsoFailViewport) { |
| 306 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 307 | m_viewports.clear(); |
| 308 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 309 | } |
| 310 | if (failMask & BsoFailScissor) { |
| 311 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 312 | m_scissors.clear(); |
| 313 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 314 | } |
| 315 | if (failMask & BsoFailBlend) { |
| 316 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
| 317 | } |
| 318 | if (failMask & BsoFailDepthBounds) { |
| 319 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 320 | } |
| 321 | if (failMask & BsoFailStencilReadMask) { |
| 322 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 323 | } |
| 324 | if (failMask & BsoFailStencilWriteMask) { |
| 325 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 326 | } |
| 327 | if (failMask & BsoFailStencilReference) { |
| 328 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 329 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 330 | |
| 331 | VkDescriptorSetObj descriptorSet(m_device); |
| 332 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, constantBuffer); |
| 333 | |
| 334 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 335 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 336 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 337 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 338 | |
| 339 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 340 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 341 | |
| 342 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 343 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 344 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 345 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *cmdBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
| 349 | { |
| 350 | if (m_depthStencil->Initialized()) { |
| 351 | cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, m_depthStencil); |
| 352 | } else { |
| 353 | cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
| 354 | } |
| 355 | |
| 356 | cmdBuffer->PrepareAttachments(); |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 357 | // Make sure depthWriteEnable is set so that Depth fail test will work correctly |
| 358 | // 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] | 359 | VkStencilOpState stencil = {}; |
| 360 | stencil.stencilFailOp = VK_STENCIL_OP_KEEP; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 361 | stencil.stencilPassOp = VK_STENCIL_OP_KEEP; |
| 362 | stencil.stencilDepthFailOp = VK_STENCIL_OP_KEEP; |
| 363 | stencil.stencilCompareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 364 | |
| 365 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 366 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 367 | ds_ci.pNext = NULL; |
| 368 | ds_ci.depthTestEnable = VK_FALSE; |
| 369 | ds_ci.depthWriteEnable = VK_TRUE; |
| 370 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 371 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
| 372 | ds_ci.stencilTestEnable = VK_TRUE; |
| 373 | ds_ci.front = stencil; |
| 374 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 375 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 376 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 377 | pipelineobj.SetViewport(m_viewports); |
| 378 | pipelineobj.SetScissor(m_scissors); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 379 | descriptorSet.CreateVKDescriptorSet(cmdBuffer); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 380 | VkResult err = pipelineobj.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 381 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 382 | cmdBuffer->BindPipeline(pipelineobj); |
| 383 | cmdBuffer->BindDescriptorSet(descriptorSet); |
| 384 | } |
| 385 | |
| 386 | // ******************************************************************************************************************** |
| 387 | // ******************************************************************************************************************** |
| 388 | // ******************************************************************************************************************** |
| 389 | // ******************************************************************************************************************** |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 390 | #if MEM_TRACKER_TESTS |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 391 | TEST_F(VkLayerTest, CallResetCmdBufferBeforeCompletion) |
| 392 | { |
| 393 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 394 | VkFlags msgFlags; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 395 | std::string msgString; |
| 396 | |
| 397 | VkFenceCreateInfo fenceInfo = {}; |
| 398 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 399 | fenceInfo.pNext = NULL; |
| 400 | fenceInfo.flags = 0; |
| 401 | |
| 402 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 403 | |
| 404 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 405 | vk_testing::Buffer buffer; |
| 406 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 407 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 408 | BeginCommandBuffer(); |
| 409 | m_cmdBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
| 410 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 411 | |
| 412 | testFence.init(*m_device, fenceInfo); |
| 413 | |
| 414 | // Bypass framework since it does the waits automatically |
| 415 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 416 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 417 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 418 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 419 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 420 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 421 | submit_info.commandBufferCount = 1; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 422 | submit_info.pCommandBuffers = &m_cmdBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 423 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 424 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 425 | |
| 426 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 427 | ASSERT_VK_SUCCESS( err ); |
| 428 | |
| 429 | m_errorMonitor->ClearState(); |
| 430 | // Introduce failure by calling begin again before checking fence |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 431 | vkResetCommandBuffer(m_cmdBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 432 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 433 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 434 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling ResetCommandBuffer on an active Command Buffer"; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 435 | if (!strstr(msgString.c_str(),"Resetting CB")) { |
| 436 | FAIL() << "Error received was not 'Resetting CB (0xaddress) before it has completed. You must check CB flag before'"; |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | TEST_F(VkLayerTest, CallBeginCmdBufferBeforeCompletion) |
| 441 | { |
| 442 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 443 | VkFlags msgFlags; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 444 | std::string msgString; |
| 445 | |
| 446 | VkFenceCreateInfo fenceInfo = {}; |
| 447 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 448 | fenceInfo.pNext = NULL; |
| 449 | fenceInfo.flags = 0; |
| 450 | |
| 451 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 452 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 453 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 454 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 455 | BeginCommandBuffer(); |
| 456 | m_cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
| 457 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 458 | |
| 459 | testFence.init(*m_device, fenceInfo); |
| 460 | |
| 461 | // Bypass framework since it does the waits automatically |
| 462 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 463 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 464 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 465 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 466 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 467 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 468 | submit_info.commandBufferCount = 1; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 469 | submit_info.pCommandBuffers = &m_cmdBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 470 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 471 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 472 | |
| 473 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 474 | ASSERT_VK_SUCCESS( err ); |
| 475 | |
| 476 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 477 | |
| 478 | VkCmdBufferBeginInfo info = {}; |
Courtney Goeltzenleuchter | 04bb5f8 | 2015-10-21 18:11:04 -0600 | [diff] [blame] | 479 | info.flags = VK_CMD_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 480 | info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO; |
| 481 | info.renderPass = VK_NULL_HANDLE; |
| 482 | info.subpass = 0; |
| 483 | info.framebuffer = VK_NULL_HANDLE; |
| 484 | |
| 485 | // Introduce failure by calling BCB again before checking fence |
| 486 | vkBeginCommandBuffer(m_cmdBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 487 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 488 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 489 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling BeginCommandBuffer on an active Command Buffer"; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 490 | if (!strstr(msgString.c_str(),"Calling vkBeginCommandBuffer() on active CB")) { |
| 491 | FAIL() << "Error received was not 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 492 | } |
| 493 | } |
| 494 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 495 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) |
| 496 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 497 | VkFlags msgFlags; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 498 | std::string msgString; |
| 499 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 500 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 501 | |
| 502 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 503 | m_errorMonitor->ClearState(); |
| 504 | |
| 505 | // Create an image, allocate memory, free it, and then try to bind it |
| 506 | VkImage image; |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 507 | VkDeviceMemory mem; |
| 508 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 509 | |
| 510 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 511 | const int32_t tex_width = 32; |
| 512 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 513 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 514 | VkImageCreateInfo image_create_info = {}; |
| 515 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 516 | image_create_info.pNext = NULL; |
| 517 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 518 | image_create_info.format = tex_format; |
| 519 | image_create_info.extent.width = tex_width; |
| 520 | image_create_info.extent.height = tex_height; |
| 521 | image_create_info.extent.depth = 1; |
| 522 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 523 | image_create_info.arrayLayers = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 524 | image_create_info.samples = 1; |
| 525 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 526 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 527 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 528 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 529 | VkMemoryAllocInfo mem_alloc = {}; |
| 530 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 531 | mem_alloc.pNext = NULL; |
| 532 | mem_alloc.allocationSize = 0; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 533 | // 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] | 534 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 535 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 536 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 537 | ASSERT_VK_SUCCESS(err); |
| 538 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 539 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 540 | image, |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 541 | &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 542 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 543 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 544 | |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 545 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 546 | 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] | 547 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 548 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 549 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 550 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 551 | // allocate memory |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 552 | err = vkAllocMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 553 | ASSERT_VK_SUCCESS(err); |
| 554 | |
| 555 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 556 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 557 | ASSERT_VK_SUCCESS(err); |
| 558 | |
| 559 | // Map memory as if to initialize the image |
| 560 | void *mappedAddress = NULL; |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 561 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 562 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 563 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 564 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while tring to map memory not visible to CPU"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 565 | if (!strstr(msgString.c_str(),"Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT")) { |
| 566 | FAIL() << "Error received did not match expected error message from vkMapMemory in MemTracker"; |
| 567 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 568 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 569 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 570 | } |
| 571 | |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 572 | // TODO : Is this test still valid. Not sure it is with updates to memory binding model |
| 573 | // Verify and delete the test of fix the check |
| 574 | //TEST_F(VkLayerTest, FreeBoundMemory) |
| 575 | //{ |
| 576 | // VkFlags msgFlags; |
| 577 | // std::string msgString; |
| 578 | // VkResult err; |
| 579 | // |
| 580 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 581 | // m_errorMonitor->ClearState(); |
| 582 | // |
| 583 | // // Create an image, allocate memory, free it, and then try to bind it |
| 584 | // VkImage image; |
| 585 | // VkDeviceMemory mem; |
| 586 | // VkMemoryRequirements mem_reqs; |
| 587 | // |
| 588 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 589 | // const int32_t tex_width = 32; |
| 590 | // const int32_t tex_height = 32; |
| 591 | // |
| 592 | // const VkImageCreateInfo image_create_info = { |
| 593 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 594 | // .pNext = NULL, |
| 595 | // .imageType = VK_IMAGE_TYPE_2D, |
| 596 | // .format = tex_format, |
| 597 | // .extent = { tex_width, tex_height, 1 }, |
| 598 | // .mipLevels = 1, |
| 599 | // .arraySize = 1, |
| 600 | // .samples = 1, |
| 601 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 602 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 603 | // .flags = 0, |
| 604 | // }; |
| 605 | // VkMemoryAllocInfo mem_alloc = { |
| 606 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO, |
| 607 | // .pNext = NULL, |
| 608 | // .allocationSize = 0, |
| 609 | // .memoryTypeIndex = 0, |
| 610 | // }; |
| 611 | // |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 612 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 613 | // ASSERT_VK_SUCCESS(err); |
| 614 | // |
| 615 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 616 | // image, |
| 617 | // &mem_reqs); |
| 618 | // ASSERT_VK_SUCCESS(err); |
| 619 | // |
| 620 | // mem_alloc.allocationSize = mem_reqs.size; |
| 621 | // |
| 622 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 623 | // ASSERT_VK_SUCCESS(err); |
| 624 | // |
| 625 | // // allocate memory |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 626 | // err = vkAllocMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 627 | // ASSERT_VK_SUCCESS(err); |
| 628 | // |
| 629 | // // Bind memory to Image object |
| 630 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 631 | // ASSERT_VK_SUCCESS(err); |
| 632 | // |
| 633 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 634 | // vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 635 | // msgFlags = m_errorMonitor->GetState(&msgString); |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 636 | // |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 637 | // ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an warning while tring to free bound memory"; |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 638 | // if (!strstr(msgString.c_str(),"Freeing memory object while it still has references")) { |
| 639 | // FAIL() << "Warning received did not match expected message from freeMemObjInfo in MemTracker"; |
| 640 | // } |
| 641 | //} |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 642 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 643 | TEST_F(VkLayerTest, RebindMemory) |
| 644 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 645 | VkFlags msgFlags; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 646 | std::string msgString; |
| 647 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 648 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 649 | |
| 650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 651 | m_errorMonitor->ClearState(); |
| 652 | |
| 653 | // Create an image, allocate memory, free it, and then try to bind it |
| 654 | VkImage image; |
| 655 | VkDeviceMemory mem1; |
| 656 | VkDeviceMemory mem2; |
| 657 | VkMemoryRequirements mem_reqs; |
| 658 | |
| 659 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 660 | const int32_t tex_width = 32; |
| 661 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 662 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 663 | VkImageCreateInfo image_create_info = {}; |
| 664 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 665 | image_create_info.pNext = NULL; |
| 666 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 667 | image_create_info.format = tex_format; |
| 668 | image_create_info.extent.width = tex_width; |
| 669 | image_create_info.extent.height = tex_height; |
| 670 | image_create_info.extent.depth = 1; |
| 671 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 672 | image_create_info.arrayLayers = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 673 | image_create_info.samples = 1; |
| 674 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 675 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 676 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 677 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 678 | VkMemoryAllocInfo mem_alloc = {}; |
| 679 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 680 | mem_alloc.pNext = NULL; |
| 681 | mem_alloc.allocationSize = 0; |
| 682 | mem_alloc.memoryTypeIndex = 0; |
| 683 | |
| 684 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 685 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 686 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 687 | ASSERT_VK_SUCCESS(err); |
| 688 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 689 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 690 | image, |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 691 | &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 692 | |
| 693 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 694 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 695 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 696 | |
| 697 | // allocate 2 memory objects |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 698 | err = vkAllocMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 699 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 700 | err = vkAllocMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 701 | ASSERT_VK_SUCCESS(err); |
| 702 | |
| 703 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 704 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 705 | ASSERT_VK_SUCCESS(err); |
| 706 | |
| 707 | // 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] | 708 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 709 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 710 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 711 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while tring to rebind an object"; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 712 | if (!strstr(msgString.c_str(),"which has already been bound to mem object")) { |
| 713 | FAIL() << "Error received did not match expected message when rebinding memory to an object"; |
| 714 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 715 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 716 | vkDestroyImage(m_device->device(), image, NULL); |
| 717 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 718 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 719 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 720 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 721 | TEST_F(VkLayerTest, SubmitSignaledFence) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 722 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 723 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 724 | VkFlags msgFlags; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 725 | std::string msgString; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 726 | |
| 727 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 728 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 729 | fenceInfo.pNext = NULL; |
| 730 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 731 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 732 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 733 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 734 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 735 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 736 | BeginCommandBuffer(); |
| 737 | m_cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
| 738 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 739 | |
| 740 | testFence.init(*m_device, fenceInfo); |
| 741 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 742 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 743 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 744 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 745 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 746 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 747 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 748 | submit_info.commandBufferCount = 1; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 749 | submit_info.pCommandBuffers = &m_cmdBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 750 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 751 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 752 | |
| 753 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 754 | vkQueueWaitIdle(m_device->m_queue ); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 755 | msgFlags = m_errorMonitor->GetState(&msgString); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 756 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 757 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err from using a fence in SIGNALED state in call to vkQueueSubmit"; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 758 | if (!strstr(msgString.c_str(),"submitted in SIGNALED state. Fences must be reset before being submitted")) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 759 | FAIL() << "Error received was not 'VkQueueSubmit with fence in SIGNALED_STATE'"; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 760 | } |
| 761 | |
| 762 | } |
| 763 | |
| 764 | TEST_F(VkLayerTest, ResetUnsignaledFence) |
| 765 | { |
| 766 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 767 | VkFlags msgFlags; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 768 | std::string msgString; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 769 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 770 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 771 | fenceInfo.pNext = NULL; |
| 772 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 773 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 774 | testFence.init(*m_device, fenceInfo); |
| 775 | m_errorMonitor->ClearState(); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 776 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 777 | vkResetFences(m_device->device(), 1, fences); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 778 | msgFlags = m_errorMonitor->GetState(&msgString); |
Tobin Ehlis | bcca3ce | 2015-10-01 10:14:48 -0600 | [diff] [blame] | 779 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_WARN_BIT)) << "Did not receive an error from submitting fence with UNSIGNALED state to vkResetFences"; |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 780 | if (!strstr(msgString.c_str(),"submitted to VkResetFences in UNSIGNALED STATE")) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 781 | FAIL() << "Error received was not 'VkResetFences with fence in UNSIGNALED_STATE'"; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 782 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 783 | |
| 784 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 785 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 786 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 787 | #if 0 |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 788 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 789 | { |
| 790 | // Initiate Draw w/o a PSO bound |
| 791 | VkFlags msgFlags; |
| 792 | std::string msgString; |
| 793 | |
| 794 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 795 | m_errorMonitor->ClearState(); |
| 796 | VkCommandBufferObj cmdBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 797 | BeginCommandBuffer(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 798 | |
| 799 | const VkExtent3D e3d = { |
| 800 | .width = 128, |
| 801 | .height = 128, |
| 802 | .depth = 1, |
| 803 | }; |
| 804 | const VkImageCreateInfo ici = { |
| 805 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 806 | .pNext = NULL, |
| 807 | .imageType = VK_IMAGE_TYPE_2D, |
| 808 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 809 | .extent = e3d, |
| 810 | .mipLevels = 1, |
| 811 | .arraySize = 1, |
| 812 | .samples = 1, |
| 813 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | 660f0ca | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 814 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 815 | .flags = 0, |
| 816 | }; |
| 817 | |
| 818 | VkImage dsi; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 819 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 820 | VkDepthStencilView dsv; |
| 821 | const VkDepthStencilViewCreateInfo dsvci = { |
| 822 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 823 | .pNext = NULL, |
| 824 | .image = dsi, |
| 825 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 826 | .baseArrayLayer = 0, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 827 | .arraySize = 1, |
| 828 | .flags = 0, |
| 829 | }; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 830 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 831 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 832 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after attempting to create DSView w/ image lacking USAGE_DS_BIT flag"; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 833 | if (!strstr(msgString.c_str(),"Invalid usage flag for image ")) { |
| 834 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
| 835 | } |
| 836 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 837 | #endif // 0 |
| 838 | #endif // MEM_TRACKER_TESTS |
| 839 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 840 | #if OBJ_TRACKER_TESTS |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 841 | TEST_F(VkLayerTest, PipelineNotBound) |
| 842 | { |
| 843 | VkFlags msgFlags; |
| 844 | std::string msgString; |
| 845 | VkResult err; |
| 846 | |
| 847 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 848 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 849 | m_errorMonitor->ClearState(); |
| 850 | |
| 851 | VkDescriptorTypeCount ds_type_count = {}; |
| 852 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 853 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 854 | |
| 855 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 856 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 857 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 858 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 859 | ds_pool_ci.typeCount = 1; |
| 860 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 861 | |
| 862 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 863 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 864 | ASSERT_VK_SUCCESS(err); |
| 865 | |
| 866 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 867 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 868 | dsl_binding.arraySize = 1; |
| 869 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 870 | dsl_binding.pImmutableSamplers = NULL; |
| 871 | |
| 872 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 873 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 874 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 875 | ds_layout_ci.bindingCount = 1; |
| 876 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 877 | |
| 878 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 879 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 880 | ASSERT_VK_SUCCESS(err); |
| 881 | |
| 882 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 883 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 884 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 885 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 886 | alloc_info.descriptorPool = ds_pool; |
| 887 | alloc_info.pSetLayouts = &ds_layout; |
| 888 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 889 | ASSERT_VK_SUCCESS(err); |
| 890 | |
| 891 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 892 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 893 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 894 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 895 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 896 | |
| 897 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 898 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 899 | ASSERT_VK_SUCCESS(err); |
| 900 | |
| 901 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 902 | |
| 903 | BeginCommandBuffer(); |
| 904 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
| 905 | |
| 906 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 907 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding invalid pipeline to CmdBuffer"; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 908 | if (!strstr(msgString.c_str(),"Invalid VkPipeline Object ")) { |
| 909 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be' but instead it was '" << msgString.c_str() << "'"; |
| 910 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 911 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 912 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 913 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 914 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 915 | } |
| 916 | |
| 917 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 918 | { |
| 919 | VkFlags msgFlags; |
| 920 | std::string msgString; |
| 921 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 922 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 923 | |
| 924 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 925 | m_errorMonitor->ClearState(); |
| 926 | |
| 927 | // Create an image, allocate memory, free it, and then try to bind it |
| 928 | VkImage image; |
| 929 | VkDeviceMemory mem; |
| 930 | VkMemoryRequirements mem_reqs; |
| 931 | |
| 932 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 933 | const int32_t tex_width = 32; |
| 934 | const int32_t tex_height = 32; |
| 935 | |
| 936 | VkImageCreateInfo image_create_info = {}; |
| 937 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 938 | image_create_info.pNext = NULL; |
| 939 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 940 | image_create_info.format = tex_format; |
| 941 | image_create_info.extent.width = tex_width; |
| 942 | image_create_info.extent.height = tex_height; |
| 943 | image_create_info.extent.depth = 1; |
| 944 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 945 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 946 | image_create_info.samples = 1; |
| 947 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 948 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 949 | image_create_info.flags = 0; |
| 950 | |
| 951 | VkMemoryAllocInfo mem_alloc = {}; |
| 952 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 953 | mem_alloc.pNext = NULL; |
| 954 | mem_alloc.allocationSize = 0; |
| 955 | mem_alloc.memoryTypeIndex = 0; |
| 956 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 957 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 958 | ASSERT_VK_SUCCESS(err); |
| 959 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 960 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 961 | image, |
| 962 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 963 | |
| 964 | mem_alloc.allocationSize = mem_reqs.size; |
| 965 | |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 966 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 967 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 968 | |
| 969 | // allocate memory |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 970 | err = vkAllocMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 971 | ASSERT_VK_SUCCESS(err); |
| 972 | |
| 973 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 974 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 975 | |
| 976 | // Try to bind free memory that has been freed |
| 977 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 978 | // This may very well return an error. |
| 979 | (void)err; |
| 980 | |
| 981 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 982 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while tring to bind a freed memory object"; |
| 983 | if (!strstr(msgString.c_str(),"Invalid VkDeviceMemory Object ")) { |
| 984 | FAIL() << "Error received from BindInvalidMemory was not 'Invalid VkDeviceMemory Object 0x<handle>' but instead '" << msgString.c_str() << "'"; |
| 985 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 986 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 987 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 991 | { |
| 992 | VkFlags msgFlags; |
| 993 | std::string msgString; |
| 994 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 995 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 996 | |
| 997 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 998 | m_errorMonitor->ClearState(); |
| 999 | |
| 1000 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 1001 | VkImage image; |
| 1002 | VkDeviceMemory mem; |
| 1003 | VkMemoryRequirements mem_reqs; |
| 1004 | |
| 1005 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1006 | const int32_t tex_width = 32; |
| 1007 | const int32_t tex_height = 32; |
| 1008 | |
| 1009 | VkImageCreateInfo image_create_info = {}; |
| 1010 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1011 | image_create_info.pNext = NULL; |
| 1012 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1013 | image_create_info.format = tex_format; |
| 1014 | image_create_info.extent.width = tex_width; |
| 1015 | image_create_info.extent.height = tex_height; |
| 1016 | image_create_info.extent.depth = 1; |
| 1017 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1018 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1019 | image_create_info.samples = 1; |
| 1020 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1021 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1022 | image_create_info.flags = 0; |
| 1023 | |
| 1024 | VkMemoryAllocInfo mem_alloc = {}; |
| 1025 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 1026 | mem_alloc.pNext = NULL; |
| 1027 | mem_alloc.allocationSize = 0; |
| 1028 | mem_alloc.memoryTypeIndex = 0; |
| 1029 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1030 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1031 | ASSERT_VK_SUCCESS(err); |
| 1032 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1033 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1034 | image, |
| 1035 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1036 | |
| 1037 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1038 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1039 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1040 | |
| 1041 | // Allocate memory |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1042 | err = vkAllocMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1043 | ASSERT_VK_SUCCESS(err); |
| 1044 | |
| 1045 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1046 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1047 | ASSERT_VK_SUCCESS(err); |
| 1048 | |
| 1049 | // Now Try to bind memory to this destroyed object |
| 1050 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1051 | // This may very well return an error. |
| 1052 | (void) err; |
| 1053 | |
| 1054 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1055 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while binding memory to a destroyed object"; |
| 1056 | if (!strstr(msgString.c_str(),"Invalid VkImage Object ")) { |
| 1057 | FAIL() << "Error received from BindMemoryToDestroyedObject was not 'Invalid VkImage Object 0x<handle>' but rather '" << msgString.c_str() << "'"; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1058 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1059 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1060 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1061 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1062 | |
| 1063 | TEST_F(VkLayerTest, InvalidBufferViewObject) |
| 1064 | { |
| 1065 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
| 1066 | VkFlags msgFlags; |
| 1067 | std::string msgString; |
| 1068 | VkResult err; |
| 1069 | |
| 1070 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1071 | m_errorMonitor->ClearState(); |
| 1072 | VkDescriptorTypeCount ds_type_count = {}; |
| 1073 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1074 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1075 | |
| 1076 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1077 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1078 | ds_pool_ci.pNext = NULL; |
| 1079 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1080 | ds_pool_ci.typeCount = 1; |
| 1081 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1082 | |
| 1083 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1084 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1085 | ASSERT_VK_SUCCESS(err); |
| 1086 | |
| 1087 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1088 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1089 | dsl_binding.arraySize = 1; |
| 1090 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1091 | dsl_binding.pImmutableSamplers = NULL; |
| 1092 | |
| 1093 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1094 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1095 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1096 | ds_layout_ci.bindingCount = 1; |
| 1097 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1098 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1099 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1100 | ASSERT_VK_SUCCESS(err); |
| 1101 | |
| 1102 | VkDescriptorSet descriptorSet; |
| 1103 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 1104 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1105 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1106 | alloc_info.descriptorPool = ds_pool; |
| 1107 | alloc_info.pSetLayouts = &ds_layout; |
| 1108 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1109 | ASSERT_VK_SUCCESS(err); |
| 1110 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1111 | VkBufferView view = (VkBufferView) 0xbaadbeef; // invalid bufferView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1112 | |
| 1113 | VkWriteDescriptorSet descriptor_write; |
| 1114 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1115 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1116 | descriptor_write.destSet = descriptorSet; |
| 1117 | descriptor_write.destBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1118 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1119 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1120 | descriptor_write.pTexelBufferView = &view; |
| 1121 | |
| 1122 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1123 | |
| 1124 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1125 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ invalid VkDescriptorBufferInfo."; |
| 1126 | if (!strstr(msgString.c_str(),"Invalid VkBufferView Object 0xbaadbeef")) { |
| 1127 | FAIL() << "Error received was not 'Invalid VkBufferView Object 0xbaadbeef' but instead '" << msgString.c_str() << "'"; |
| 1128 | } |
| 1129 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1130 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1131 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1132 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1133 | #endif // OBJ_TRACKER_TESTS |
| 1134 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1135 | #if DRAW_STATE_TESTS |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1136 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1137 | { |
| 1138 | VkFlags msgFlags; |
| 1139 | std::string msgString; |
| 1140 | m_errorMonitor->ClearState(); |
| 1141 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1142 | |
| 1143 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1144 | |
| 1145 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1146 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Line Width State Object"; |
| 1147 | if (!strstr(msgString.c_str(),"Dynamic line width state not set for this command buffer")) { |
| 1148 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic line width state not set for this command buffer'"; |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1153 | { |
| 1154 | VkFlags msgFlags; |
| 1155 | std::string msgString; |
| 1156 | m_errorMonitor->ClearState(); |
| 1157 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1158 | |
| 1159 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1160 | |
| 1161 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1162 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Depth Bias State Object"; |
| 1163 | if (!strstr(msgString.c_str(),"Dynamic depth bias state not set for this command buffer")) { |
| 1164 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic depth bias state not set for this command buffer'"; |
| 1165 | } |
| 1166 | } |
| 1167 | |
Cody Northrop | 4063c9a | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1168 | // Disable these two tests until we can sort out how to track multiple layer errors |
| 1169 | #if 0 |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1170 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1171 | { |
| 1172 | VkFlags msgFlags; |
| 1173 | std::string msgString; |
| 1174 | m_errorMonitor->ClearState(); |
| 1175 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1176 | |
| 1177 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1178 | |
| 1179 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1180 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Viewport State Object"; |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1181 | // TODO : Viewport and scissor currently set as a pair in framework so scissor error masks viewport error |
| 1182 | if (!strstr(msgString.c_str(),"Dynamic scissor state not set for this command buffer")) { |
| 1183 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic scissor state not set for this command buffer'"; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1184 | } |
| 1185 | } |
| 1186 | |
| 1187 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1188 | { |
| 1189 | VkFlags msgFlags; |
| 1190 | std::string msgString; |
| 1191 | m_errorMonitor->ClearState(); |
| 1192 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1193 | |
| 1194 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1195 | |
| 1196 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1197 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Viewport State Object"; |
| 1198 | if (!strstr(msgString.c_str(),"Dynamic scissor state not set for this command buffer")) { |
| 1199 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1200 | } |
| 1201 | } |
Cody Northrop | 4063c9a | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1202 | #endif |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1203 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1204 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1205 | { |
| 1206 | VkFlags msgFlags; |
| 1207 | std::string msgString; |
| 1208 | m_errorMonitor->ClearState(); |
| 1209 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1210 | |
| 1211 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1212 | |
| 1213 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1214 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Blend State Object"; |
| 1215 | if (!strstr(msgString.c_str(),"Dynamic blend object state not set for this command buffer")) { |
| 1216 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic blend object state not set for this command buffer'"; |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1221 | { |
| 1222 | VkFlags msgFlags; |
| 1223 | std::string msgString; |
| 1224 | m_errorMonitor->ClearState(); |
| 1225 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1226 | |
| 1227 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1228 | |
| 1229 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1230 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Depth Bounds State Object"; |
| 1231 | if (!strstr(msgString.c_str(),"Dynamic depth bounds state not set for this command buffer")) { |
| 1232 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic depth bounds state not set for this command buffer'"; |
| 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1237 | { |
| 1238 | VkFlags msgFlags; |
| 1239 | std::string msgString; |
| 1240 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1241 | m_errorMonitor->ClearState(); |
| 1242 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1243 | |
| 1244 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1245 | |
| 1246 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1247 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Setting a Stencil Read Mask"; |
| 1248 | if (!strstr(msgString.c_str(),"Dynamic stencil read mask state not set for this command buffer")) { |
| 1249 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1250 | } |
| 1251 | } |
| 1252 | |
| 1253 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1254 | { |
| 1255 | VkFlags msgFlags; |
| 1256 | std::string msgString; |
| 1257 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1258 | m_errorMonitor->ClearState(); |
| 1259 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1260 | |
| 1261 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1262 | |
| 1263 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1264 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Setting a Stencil Write Mask"; |
| 1265 | if (!strstr(msgString.c_str(),"Dynamic stencil write mask state not set for this command buffer")) { |
| 1266 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1267 | } |
| 1268 | } |
| 1269 | |
| 1270 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1271 | { |
| 1272 | VkFlags msgFlags; |
| 1273 | std::string msgString; |
| 1274 | m_errorMonitor->ClearState(); |
| 1275 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1276 | |
| 1277 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1278 | |
| 1279 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1280 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Setting a Stencil Reference"; |
| 1281 | if (!strstr(msgString.c_str(),"Dynamic stencil reference state not set for this command buffer")) { |
| 1282 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic stencil reference state not set for this command buffer'"; |
| 1283 | } |
| 1284 | } |
| 1285 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1286 | TEST_F(VkLayerTest, CmdBufferTwoSubmits) |
| 1287 | { |
| 1288 | vk_testing::Fence testFence; |
| 1289 | VkFlags msgFlags; |
| 1290 | std::string msgString; |
| 1291 | |
| 1292 | VkFenceCreateInfo fenceInfo = {}; |
| 1293 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1294 | fenceInfo.pNext = NULL; |
| 1295 | fenceInfo.flags = 0; |
| 1296 | |
| 1297 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1298 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1299 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1300 | |
Courtney Goeltzenleuchter | 04bb5f8 | 2015-10-21 18:11:04 -0600 | [diff] [blame] | 1301 | // We luck out b/c by default the framework creates CB w/ the VK_CMD_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1302 | BeginCommandBuffer(); |
| 1303 | m_cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
| 1304 | EndCommandBuffer(); |
| 1305 | |
| 1306 | testFence.init(*m_device, fenceInfo); |
| 1307 | |
| 1308 | // Bypass framework since it does the waits automatically |
| 1309 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1310 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1311 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1312 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1313 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1314 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1315 | submit_info.commandBufferCount = 1; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1316 | submit_info.pCommandBuffers = &m_cmdBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1317 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1318 | submit_info.pSignalSemaphores = NULL; |
| 1319 | |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1320 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1321 | ASSERT_VK_SUCCESS( err ); |
| 1322 | |
| 1323 | m_errorMonitor->ClearState(); |
| 1324 | // 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] | 1325 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1326 | |
| 1327 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1328 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after re-submitting Command Buffer that was created with one-time submit flag"; |
Courtney Goeltzenleuchter | 04bb5f8 | 2015-10-21 18:11:04 -0600 | [diff] [blame] | 1329 | if (!strstr(msgString.c_str(),"was begun w/ VK_CMD_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted")) { |
| 1330 | FAIL() << "Error received was not 'CB (0xaddress) was created w/ VK_CMD_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1331 | } |
| 1332 | } |
| 1333 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1334 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1335 | { |
| 1336 | // Initiate Draw w/o a PSO bound |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1337 | VkFlags msgFlags; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1338 | std::string msgString; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1339 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1340 | |
| 1341 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1342 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1343 | m_errorMonitor->ClearState(); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1344 | |
| 1345 | VkDescriptorTypeCount ds_type_count = {}; |
| 1346 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1347 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1348 | |
| 1349 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1350 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1351 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1352 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1353 | ds_pool_ci.typeCount = 1; |
| 1354 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1355 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1356 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1357 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1358 | ASSERT_VK_SUCCESS(err); |
| 1359 | |
| 1360 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1361 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1362 | dsl_binding.arraySize = 1; |
| 1363 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1364 | dsl_binding.pImmutableSamplers = NULL; |
| 1365 | |
| 1366 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1367 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1368 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1369 | ds_layout_ci.bindingCount = 1; |
| 1370 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1371 | |
| 1372 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1373 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1374 | ASSERT_VK_SUCCESS(err); |
| 1375 | |
| 1376 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1377 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 1378 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1379 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1380 | alloc_info.descriptorPool = ds_pool; |
| 1381 | alloc_info.pSetLayouts = &ds_layout; |
| 1382 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1383 | ASSERT_VK_SUCCESS(err); |
| 1384 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 1385 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1386 | pipe_ms_state_ci.pNext = NULL; |
| 1387 | pipe_ms_state_ci.rasterSamples = 1; |
| 1388 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1389 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1390 | pipe_ms_state_ci.pSampleMask = NULL; |
| 1391 | |
| 1392 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1393 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1394 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1395 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1396 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1397 | VkPipelineLayout pipeline_layout; |
| 1398 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1399 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1400 | ASSERT_VK_SUCCESS(err); |
| 1401 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1402 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1403 | 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] | 1404 | // but add it to be able to run on more devices |
| 1405 | VkPipelineObj pipe(m_device); |
| 1406 | pipe.AddShader(&vs); |
| 1407 | pipe.AddShader(&fs); |
| 1408 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1409 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1410 | m_errorMonitor->ClearState(); |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1411 | // Calls AllocCommandBuffers |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1412 | VkCommandBufferObj cmdBuffer(m_device, m_cmdPool); |
| 1413 | VkCmdBufferBeginInfo cmd_buf_info = {}; |
| 1414 | memset(&cmd_buf_info, 0, sizeof(VkCmdBufferBeginInfo)); |
| 1415 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO; |
| 1416 | cmd_buf_info.pNext = NULL; |
Courtney Goeltzenleuchter | 04bb5f8 | 2015-10-21 18:11:04 -0600 | [diff] [blame] | 1417 | cmd_buf_info.flags = VK_CMD_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1418 | |
| 1419 | vkBeginCommandBuffer(cmdBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1420 | vkCmdBindPipeline(cmdBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1421 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1422 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding pipeline to CmdBuffer w/o active RenderPass"; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1423 | if (!strstr(msgString.c_str(),"Incorrectly binding graphics pipeline ")) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1424 | FAIL() << "Error received was not 'Incorrectly binding graphics pipeline (0x<handle>) without an active RenderPass' but rather '" << msgString.c_str() << "'"; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1425 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1426 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1427 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1428 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1429 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1430 | } |
| 1431 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1432 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) |
| 1433 | { |
| 1434 | // Initiate Draw w/o a PSO bound |
| 1435 | VkFlags msgFlags; |
| 1436 | std::string msgString; |
| 1437 | VkResult err; |
| 1438 | |
| 1439 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1440 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1441 | m_errorMonitor->ClearState(); |
| 1442 | |
| 1443 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer descriptor from it |
| 1444 | VkDescriptorTypeCount ds_type_count = {}; |
| 1445 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1446 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1447 | |
| 1448 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1449 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1450 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1451 | ds_pool_ci.flags = 0; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1452 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1453 | ds_pool_ci.typeCount = 1; |
| 1454 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1455 | |
| 1456 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1457 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1458 | ASSERT_VK_SUCCESS(err); |
| 1459 | |
| 1460 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1461 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1462 | dsl_binding.arraySize = 1; |
| 1463 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1464 | dsl_binding.pImmutableSamplers = NULL; |
| 1465 | |
| 1466 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1467 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1468 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1469 | ds_layout_ci.bindingCount = 1; |
| 1470 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1471 | |
| 1472 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1473 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1474 | ASSERT_VK_SUCCESS(err); |
| 1475 | |
| 1476 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1477 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 1478 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1479 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1480 | alloc_info.descriptorPool = ds_pool; |
| 1481 | alloc_info.pSetLayouts = &ds_layout; |
| 1482 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1483 | |
| 1484 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1485 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after alloc descriptor from pool w/o requested type"; |
| 1486 | if (!strstr(msgString.c_str(),"Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ")) { |
| 1487 | FAIL() << "Error received was not 'Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...' but rather '" << msgString.c_str() << "'"; |
| 1488 | } |
| 1489 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1490 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1491 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1492 | } |
| 1493 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1494 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1495 | { |
| 1496 | VkFlags msgFlags; |
| 1497 | std::string msgString; |
| 1498 | VkResult err; |
| 1499 | |
| 1500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1501 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1502 | m_errorMonitor->ClearState(); |
| 1503 | |
| 1504 | VkDescriptorTypeCount ds_type_count = {}; |
| 1505 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1506 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1507 | |
| 1508 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1509 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1510 | ds_pool_ci.pNext = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1511 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1512 | ds_pool_ci.typeCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1513 | ds_pool_ci.flags = 0; |
| 1514 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1515 | // app can only call vkResetDescriptorPool on this pool.; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1516 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1517 | |
| 1518 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1519 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1520 | ASSERT_VK_SUCCESS(err); |
| 1521 | |
| 1522 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1523 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1524 | dsl_binding.arraySize = 1; |
| 1525 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1526 | dsl_binding.pImmutableSamplers = NULL; |
| 1527 | |
| 1528 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1529 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1530 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1531 | ds_layout_ci.bindingCount = 1; |
| 1532 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1533 | |
| 1534 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1535 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1536 | ASSERT_VK_SUCCESS(err); |
| 1537 | |
| 1538 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1539 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 1540 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1541 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1542 | alloc_info.descriptorPool = ds_pool; |
| 1543 | alloc_info.pSetLayouts = &ds_layout; |
| 1544 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1545 | ASSERT_VK_SUCCESS(err); |
| 1546 | |
| 1547 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 1548 | msgFlags = m_errorMonitor->GetState(&msgString); |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1549 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after freeing descriptor from non-free Pool"; |
| 1550 | |
| 1551 | if (!strstr(msgString.c_str(),"It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT.")) { |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1552 | FAIL() << "Error received was not 'It is invalid to call vkFreeDescriptorSets() with a pool created with...' but instead it was '" << msgString.c_str() << "'"; |
| 1553 | } |
| 1554 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1555 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1556 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1557 | } |
| 1558 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1559 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1560 | { |
| 1561 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1562 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1563 | // Attempt to clear DS Pool with bad object |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1564 | /* VkFlags msgFlags; |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1565 | std::string msgString; |
| 1566 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1567 | vkResetDescriptorPool(device(), badPool); |
| 1568 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1569 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1570 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Resetting an invalid DescriptorPool Object"; |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1571 | if (!strstr(msgString.c_str(),"Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call")) { |
| 1572 | FAIL() << "Error received was note 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1573 | }*/ |
| 1574 | } |
| 1575 | |
| 1576 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1577 | { |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1578 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1579 | // 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] | 1580 | // Create a valid cmd buffer |
| 1581 | // call vkCmdBindDescriptorSets w/ false DS |
| 1582 | } |
| 1583 | |
| 1584 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1585 | { |
| 1586 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1587 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1588 | } |
| 1589 | |
| 1590 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1591 | { |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1592 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1593 | // 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] | 1594 | // Create a valid cmd buffer |
| 1595 | // call vkCmdBindPipeline w/ false Pipeline |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1596 | // VkFlags msgFlags; |
| 1597 | // std::string msgString; |
| 1598 | // |
| 1599 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1600 | // m_errorMonitor->ClearState(); |
| 1601 | // VkCommandBufferObj cmdBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1602 | // BeginCommandBuffer(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1603 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 1604 | // vkCmdBindPipeline(cmdBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
| 1605 | // msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1606 | // ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding invalid pipeline to CmdBuffer"; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1607 | // if (!strstr(msgString.c_str(),"Attempt to bind Pipeline ")) { |
| 1608 | // FAIL() << "Error received was not 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1609 | // } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1610 | } |
| 1611 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1612 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1613 | { |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1614 | // Create and update CmdBuffer then call QueueSubmit w/o calling End on CmdBuffer |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1615 | VkFlags msgFlags; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1616 | std::string msgString; |
| 1617 | VkResult err; |
| 1618 | |
| 1619 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1620 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1621 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1622 | m_errorMonitor->ClearState(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1623 | VkDescriptorTypeCount ds_type_count = {}; |
| 1624 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1625 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1626 | |
| 1627 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1628 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1629 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1630 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1631 | ds_pool_ci.typeCount = 1; |
| 1632 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1633 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1634 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1635 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1636 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1637 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1638 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1639 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1640 | dsl_binding.arraySize = 1; |
| 1641 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1642 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1643 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1644 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1645 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1646 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1647 | ds_layout_ci.bindingCount = 1; |
| 1648 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1649 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1650 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1651 | ASSERT_VK_SUCCESS(err); |
| 1652 | |
| 1653 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1654 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 1655 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1656 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1657 | alloc_info.descriptorPool = ds_pool; |
| 1658 | alloc_info.pSetLayouts = &ds_layout; |
| 1659 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1660 | ASSERT_VK_SUCCESS(err); |
| 1661 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1662 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1663 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1664 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1665 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1666 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1667 | |
| 1668 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1669 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1670 | ASSERT_VK_SUCCESS(err); |
| 1671 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1672 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1673 | 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] | 1674 | // but add it to be able to run on more devices |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1675 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1676 | VkPipelineObj pipe(m_device); |
| 1677 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1678 | pipe.AddShader(&fs); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1679 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1680 | |
| 1681 | BeginCommandBuffer(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1682 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1683 | vkCmdBindDescriptorSets(m_cmdBuffer->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] | 1684 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1685 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1686 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT) << "Did not warn after binding a DescriptorSet that was never updated."; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1687 | if (!strstr(msgString.c_str()," bound but it was never updated. ")) { |
| 1688 | FAIL() << "Error received was not 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1689 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1690 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1691 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1692 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1693 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1694 | } |
| 1695 | |
| 1696 | TEST_F(VkLayerTest, NoBeginCmdBuffer) |
| 1697 | { |
| 1698 | VkFlags msgFlags; |
| 1699 | std::string msgString; |
| 1700 | |
| 1701 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1702 | m_errorMonitor->ClearState(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1703 | VkCommandBufferObj cmdBuffer(m_device, m_cmdPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1704 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
| 1705 | vkEndCommandBuffer(cmdBuffer.GetBufferHandle()); |
| 1706 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1707 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after ending a CmdBuffer w/o calling BeginCommandBuffer()"; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1708 | if (!strstr(msgString.c_str(),"You must call vkBeginCommandBuffer() before this call to ")) { |
| 1709 | FAIL() << "Error received was not 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 1710 | } |
| 1711 | } |
| 1712 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1713 | TEST_F(VkLayerTest, PrimaryCmdBufferFramebufferAndRenderpass) |
| 1714 | { |
| 1715 | VkFlags msgFlags; |
| 1716 | std::string msgString; |
| 1717 | |
| 1718 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1719 | m_errorMonitor->ClearState(); |
| 1720 | |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1721 | // Calls AllocCommandBuffers |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1722 | VkCommandBufferObj cmdBuffer(m_device, m_cmdPool); |
| 1723 | |
| 1724 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1725 | VkCmdBufferBeginInfo cmd_buf_info = {}; |
| 1726 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO; |
| 1727 | cmd_buf_info.pNext = NULL; |
Courtney Goeltzenleuchter | 04bb5f8 | 2015-10-21 18:11:04 -0600 | [diff] [blame] | 1728 | cmd_buf_info.flags = VK_CMD_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1729 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 1730 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 1731 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1732 | |
| 1733 | // The error should be caught by validation of the BeginCommandBuffer call |
| 1734 | vkBeginCommandBuffer(cmdBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1735 | |
| 1736 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1737 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error passing a non-NULL Framebuffer and Renderpass to BeginCommandBuffer()"; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1738 | if (!strstr(msgString.c_str(),"may not specify framebuffer or renderpass parameters")) { |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1739 | FAIL() << "Error received was not 'vkAllocCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1740 | } |
| 1741 | } |
| 1742 | |
| 1743 | TEST_F(VkLayerTest, SecondaryCmdBufferFramebufferAndRenderpass) |
| 1744 | { |
| 1745 | VkFlags msgFlags; |
| 1746 | std::string msgString; |
| 1747 | VkResult err; |
| 1748 | VkCmdBuffer draw_cmd; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1749 | |
| 1750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1751 | m_errorMonitor->ClearState(); |
| 1752 | |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1753 | VkCmdBufferAllocInfo cmd = {}; |
| 1754 | cmd.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_ALLOC_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1755 | cmd.pNext = NULL; |
| 1756 | cmd.cmdPool = m_cmdPool; |
| 1757 | cmd.level = VK_CMD_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1758 | cmd.bufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1759 | |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1760 | err = vkAllocCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1761 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1762 | |
| 1763 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1764 | VkCmdBufferBeginInfo cmd_buf_info = {}; |
| 1765 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO; |
| 1766 | cmd_buf_info.pNext = NULL; |
Courtney Goeltzenleuchter | 04bb5f8 | 2015-10-21 18:11:04 -0600 | [diff] [blame] | 1767 | cmd_buf_info.flags = VK_CMD_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1768 | |
| 1769 | // The error should be caught by validation of the BeginCommandBuffer call |
| 1770 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 1771 | |
| 1772 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1773 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error passing NULL Framebuffer/Renderpass to BeginCommandBuffer()"; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1774 | if (!strstr(msgString.c_str(),"must specify framebuffer and renderpass parameters")) { |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1775 | FAIL() << "Error received was not 'vkAllocCommandBuffers(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1776 | } |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1777 | vkFreeCommandBuffers(m_device->device(), m_cmdPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1778 | } |
| 1779 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1780 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 1781 | { |
| 1782 | // Attempt to Create Gfx Pipeline w/o a VS |
| 1783 | VkFlags msgFlags; |
| 1784 | std::string msgString; |
| 1785 | VkResult err; |
| 1786 | |
| 1787 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1788 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1789 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1790 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1791 | VkDescriptorTypeCount ds_type_count = {}; |
| 1792 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1793 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1794 | |
| 1795 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1796 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1797 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1798 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1799 | ds_pool_ci.typeCount = 1; |
| 1800 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1801 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1802 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1803 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1804 | ASSERT_VK_SUCCESS(err); |
| 1805 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1806 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1807 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1808 | dsl_binding.arraySize = 1; |
| 1809 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1810 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1811 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1812 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1813 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1814 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1815 | ds_layout_ci.bindingCount = 1; |
| 1816 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1817 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1818 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1819 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1820 | ASSERT_VK_SUCCESS(err); |
| 1821 | |
| 1822 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1823 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 1824 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1825 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1826 | alloc_info.descriptorPool = ds_pool; |
| 1827 | alloc_info.pSetLayouts = &ds_layout; |
| 1828 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1829 | ASSERT_VK_SUCCESS(err); |
| 1830 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1831 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1832 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1833 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1834 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1835 | |
| 1836 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1837 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1838 | ASSERT_VK_SUCCESS(err); |
| 1839 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1840 | VkViewport vp = {}; // Just need dummy vp to point to |
| 1841 | VkRect2D sc = {}; // dummy scissor to point to |
| 1842 | |
| 1843 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 1844 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 1845 | vp_state_ci.scissorCount = 1; |
| 1846 | vp_state_ci.pScissors = ≻ |
| 1847 | vp_state_ci.viewportCount = 1; |
| 1848 | vp_state_ci.pViewports = &vp; |
| 1849 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1850 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1851 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1852 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1853 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1854 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1855 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1856 | |
| 1857 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1858 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1859 | pc_ci.initialSize = 0; |
| 1860 | pc_ci.initialData = 0; |
| 1861 | pc_ci.maxSize = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1862 | |
| 1863 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1864 | VkPipelineCache pipelineCache; |
| 1865 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1866 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1867 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1868 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1869 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1870 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1871 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o VS."; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1872 | if (!strstr(msgString.c_str(),"Invalid Pipeline CreateInfo State: Vtx Shader required")) { |
| 1873 | FAIL() << "Error received was not 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 1874 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1875 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1876 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 1877 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1878 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1879 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1880 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1881 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 1882 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 1883 | { |
| 1884 | // Attempt to Create Gfx Pipeline w/o a VS |
| 1885 | VkFlags msgFlags; |
| 1886 | std::string msgString; |
| 1887 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1888 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1889 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1890 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1891 | m_errorMonitor->ClearState(); |
| 1892 | |
| 1893 | VkDescriptorTypeCount ds_type_count = {}; |
| 1894 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1895 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1896 | |
| 1897 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1898 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1899 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1900 | ds_pool_ci.typeCount = 1; |
| 1901 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1902 | |
| 1903 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1904 | 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] | 1905 | ASSERT_VK_SUCCESS(err); |
| 1906 | |
| 1907 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1908 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1909 | dsl_binding.arraySize = 1; |
| 1910 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1911 | dsl_binding.pImmutableSamplers = NULL; |
| 1912 | |
| 1913 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1914 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1915 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1916 | ds_layout_ci.bindingCount = 1; |
| 1917 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1918 | |
| 1919 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1920 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1921 | ASSERT_VK_SUCCESS(err); |
| 1922 | |
| 1923 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1924 | err = vkAllocDescriptorSets(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] | 1925 | ASSERT_VK_SUCCESS(err); |
| 1926 | |
| 1927 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1928 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1929 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1930 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1931 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1932 | |
| 1933 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1934 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1935 | ASSERT_VK_SUCCESS(err); |
| 1936 | |
| 1937 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 1938 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 1939 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1940 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1941 | // 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] | 1942 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 1943 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1944 | |
| 1945 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1946 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1947 | shaderStages[0].shader = vs.handle(); |
| 1948 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1949 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1950 | shaderStages[1].shader = tc.handle(); |
| 1951 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1952 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1953 | shaderStages[2].shader = te.handle(); |
| 1954 | |
| 1955 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 1956 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 1957 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH; |
| 1958 | |
| 1959 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 1960 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 1961 | tsCI.patchControlPoints = 0; // This will cause an error |
| 1962 | |
| 1963 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1964 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 1965 | gp_ci.pNext = NULL; |
| 1966 | gp_ci.stageCount = 3; |
| 1967 | gp_ci.pStages = shaderStages; |
| 1968 | gp_ci.pVertexInputState = NULL; |
| 1969 | gp_ci.pInputAssemblyState = &iaCI; |
| 1970 | gp_ci.pTessellationState = &tsCI; |
| 1971 | gp_ci.pViewportState = NULL; |
| 1972 | gp_ci.pRasterState = NULL; |
| 1973 | gp_ci.pMultisampleState = NULL; |
| 1974 | gp_ci.pDepthStencilState = NULL; |
| 1975 | gp_ci.pColorBlendState = NULL; |
| 1976 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1977 | gp_ci.layout = pipeline_layout; |
| 1978 | gp_ci.renderPass = renderPass(); |
| 1979 | |
| 1980 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1981 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 1982 | pc_ci.pNext = NULL; |
| 1983 | pc_ci.initialSize = 0; |
| 1984 | pc_ci.initialData = 0; |
| 1985 | pc_ci.maxSize = 0; |
| 1986 | |
| 1987 | VkPipeline pipeline; |
| 1988 | VkPipelineCache pipelineCache; |
| 1989 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1990 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1991 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1992 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1993 | |
| 1994 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1995 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Tess Gfx Pipeline w/ 0 patchControlPoints."; |
| 1996 | if (!strstr(msgString.c_str(),"Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive ")) { |
| 1997 | FAIL() << "Error received was not 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...' but instead '" << msgString.c_str() << "'"; |
| 1998 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1999 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2000 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2001 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2002 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2003 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2004 | } |
| 2005 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2006 | // Set scissor and viewport counts to different numbers |
| 2007 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2008 | { |
| 2009 | // Attempt to Create Gfx Pipeline w/o a VS |
| 2010 | VkFlags msgFlags; |
| 2011 | std::string msgString; |
| 2012 | VkResult err; |
| 2013 | |
| 2014 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2015 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2016 | m_errorMonitor->ClearState(); |
| 2017 | |
| 2018 | VkDescriptorTypeCount ds_type_count = {}; |
| 2019 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2020 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2021 | |
| 2022 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2023 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2024 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2025 | ds_pool_ci.typeCount = 1; |
| 2026 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2027 | |
| 2028 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2029 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2030 | ASSERT_VK_SUCCESS(err); |
| 2031 | |
| 2032 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2033 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2034 | dsl_binding.arraySize = 1; |
| 2035 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2036 | |
| 2037 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2038 | 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] | 2039 | ds_layout_ci.bindingCount = 1; |
| 2040 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2041 | |
| 2042 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2043 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2044 | ASSERT_VK_SUCCESS(err); |
| 2045 | |
| 2046 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2047 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2048 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2049 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2050 | alloc_info.descriptorPool = ds_pool; |
| 2051 | alloc_info.pSetLayouts = &ds_layout; |
| 2052 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2053 | ASSERT_VK_SUCCESS(err); |
| 2054 | |
| 2055 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2056 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2057 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2058 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2059 | |
| 2060 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2061 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2062 | ASSERT_VK_SUCCESS(err); |
| 2063 | |
| 2064 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2065 | |
| 2066 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2067 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2068 | vp_state_ci.scissorCount = 0; |
| 2069 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2070 | vp_state_ci.pViewports = &vp; |
| 2071 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2072 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2073 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2074 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2075 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2076 | 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] | 2077 | // but add it to be able to run on more devices |
| 2078 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2079 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2080 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2081 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2082 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2083 | |
| 2084 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2085 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2086 | gp_ci.stageCount = 2; |
| 2087 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2088 | gp_ci.pViewportState = &vp_state_ci; |
| 2089 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2090 | gp_ci.layout = pipeline_layout; |
| 2091 | gp_ci.renderPass = renderPass(); |
| 2092 | |
| 2093 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2094 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2095 | |
| 2096 | VkPipeline pipeline; |
| 2097 | VkPipelineCache pipelineCache; |
| 2098 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2099 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2100 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2101 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2102 | |
| 2103 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2104 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/ viewport and scissor count mismatch."; |
| 2105 | if (!strstr(msgString.c_str(),"Gfx Pipeline viewport count (1) must match scissor count (0).")) { |
| 2106 | FAIL() << "Error received was not 'Gfx Pipeline viewport count (1) must match scissor count (0).' but instead it was '" << msgString.c_str() << "'"; |
| 2107 | } |
| 2108 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2109 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2110 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2111 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2112 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2113 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2114 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2115 | // for the counts even if the data is going to be set dynamically. |
| 2116 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2117 | { |
| 2118 | // Attempt to Create Gfx Pipeline w/o a VS |
| 2119 | VkFlags msgFlags; |
| 2120 | std::string msgString; |
| 2121 | VkResult err; |
| 2122 | |
| 2123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2124 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2125 | m_errorMonitor->ClearState(); |
| 2126 | |
| 2127 | VkDescriptorTypeCount ds_type_count = {}; |
| 2128 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2129 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2130 | |
| 2131 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2132 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2133 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2134 | ds_pool_ci.typeCount = 1; |
| 2135 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2136 | |
| 2137 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2138 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2139 | ASSERT_VK_SUCCESS(err); |
| 2140 | |
| 2141 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2142 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2143 | dsl_binding.arraySize = 1; |
| 2144 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2145 | |
| 2146 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2147 | 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] | 2148 | ds_layout_ci.bindingCount = 1; |
| 2149 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2150 | |
| 2151 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2152 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2153 | ASSERT_VK_SUCCESS(err); |
| 2154 | |
| 2155 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2156 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2157 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2158 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2159 | alloc_info.descriptorPool = ds_pool; |
| 2160 | alloc_info.pSetLayouts = &ds_layout; |
| 2161 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2162 | ASSERT_VK_SUCCESS(err); |
| 2163 | |
| 2164 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2165 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2166 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2167 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2168 | |
| 2169 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2170 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2171 | ASSERT_VK_SUCCESS(err); |
| 2172 | |
| 2173 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2174 | // Set scissor as dynamic to avoid second error |
| 2175 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2176 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2177 | dyn_state_ci.dynamicStateCount = 1; |
| 2178 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2179 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2180 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2181 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2182 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2183 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2184 | 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] | 2185 | // but add it to be able to run on more devices |
| 2186 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2187 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2188 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2189 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2190 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2191 | |
| 2192 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2193 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2194 | gp_ci.stageCount = 2; |
| 2195 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2196 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2197 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2198 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2199 | gp_ci.layout = pipeline_layout; |
| 2200 | gp_ci.renderPass = renderPass(); |
| 2201 | |
| 2202 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2203 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2204 | |
| 2205 | VkPipeline pipeline; |
| 2206 | VkPipelineCache pipelineCache; |
| 2207 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2208 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2209 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2210 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2211 | |
| 2212 | msgFlags = m_errorMonitor->GetState(&msgString); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2213 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o viewport state set."; |
| 2214 | if (!strstr(msgString.c_str(),"Gfx Pipeline pViewportState is null. Even if ")) { |
| 2215 | FAIL() << "Error received was not 'Gfx Pipeline pViewportState is null. Even if...' but instead it was '" << msgString.c_str() << "'"; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2216 | } |
| 2217 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2218 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2219 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2220 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2221 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2222 | } |
| 2223 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2224 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2225 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2226 | { |
| 2227 | VkFlags msgFlags; |
| 2228 | std::string msgString; |
| 2229 | VkResult err; |
| 2230 | |
| 2231 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2232 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2233 | m_errorMonitor->ClearState(); |
| 2234 | |
| 2235 | VkDescriptorTypeCount ds_type_count = {}; |
| 2236 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2237 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2238 | |
| 2239 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2240 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2241 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2242 | ds_pool_ci.typeCount = 1; |
| 2243 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2244 | |
| 2245 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2246 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2247 | ASSERT_VK_SUCCESS(err); |
| 2248 | |
| 2249 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2250 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2251 | dsl_binding.arraySize = 1; |
| 2252 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2253 | |
| 2254 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2255 | 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] | 2256 | ds_layout_ci.bindingCount = 1; |
| 2257 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2258 | |
| 2259 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2260 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2261 | ASSERT_VK_SUCCESS(err); |
| 2262 | |
| 2263 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2264 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2265 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2266 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2267 | alloc_info.descriptorPool = ds_pool; |
| 2268 | alloc_info.pSetLayouts = &ds_layout; |
| 2269 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2270 | ASSERT_VK_SUCCESS(err); |
| 2271 | |
| 2272 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2273 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2274 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2275 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2276 | |
| 2277 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2278 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2279 | ASSERT_VK_SUCCESS(err); |
| 2280 | |
| 2281 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2282 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2283 | vp_state_ci.viewportCount = 1; |
| 2284 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2285 | vp_state_ci.scissorCount = 1; |
| 2286 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2287 | |
| 2288 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2289 | // Set scissor as dynamic to avoid that error |
| 2290 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2291 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2292 | dyn_state_ci.dynamicStateCount = 1; |
| 2293 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2294 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2295 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2296 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2297 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2298 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2299 | 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] | 2300 | // but add it to be able to run on more devices |
| 2301 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2302 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2303 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2304 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2305 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2306 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2307 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2308 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2309 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2310 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2311 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2312 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2313 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2314 | |
| 2315 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2316 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2317 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2318 | |
| 2319 | VkPipelineRasterStateCreateInfo rs_ci = {}; |
| 2320 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO; |
| 2321 | rs_ci.pNext = nullptr; |
| 2322 | |
| 2323 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2324 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2325 | cb_ci.pNext = nullptr; |
| 2326 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2327 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2328 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2329 | gp_ci.stageCount = 2; |
| 2330 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2331 | gp_ci.pVertexInputState = &vi_ci; |
| 2332 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2333 | gp_ci.pViewportState = &vp_state_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2334 | gp_ci.pRasterState = &rs_ci; |
| 2335 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2336 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2337 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2338 | gp_ci.layout = pipeline_layout; |
| 2339 | gp_ci.renderPass = renderPass(); |
| 2340 | |
| 2341 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2342 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2343 | |
| 2344 | VkPipeline pipeline; |
| 2345 | VkPipelineCache pipelineCache; |
| 2346 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2347 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2348 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2349 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2350 | |
| 2351 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2352 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o scissor set."; |
| 2353 | if (!strstr(msgString.c_str(),"Gfx Pipeline viewportCount is 1, but pViewports is NULL. ")) { |
| 2354 | FAIL() << "Error received was not 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...' but instead it was '" << msgString.c_str() << "'"; |
| 2355 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2356 | m_errorMonitor->ClearState(); |
| 2357 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2358 | // First need to successfully create the PSO from above by setting pViewports |
| 2359 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2360 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2361 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2362 | ASSERT_VK_SUCCESS(err); |
| 2363 | BeginCommandBuffer(); |
| 2364 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 2365 | VkRect2D scissors[2] = {}; // don't care about data |
| 2366 | // Count of 2 doesn't match PSO count of 1 |
| 2367 | vkCmdSetScissor(m_cmdBuffer->GetBufferHandle(), 2, scissors); |
| 2368 | Draw(1, 0, 0, 0); |
| 2369 | |
| 2370 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2371 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after setting dynamic scissorCount different from PSO scissorCount."; |
| 2372 | if (!strstr(msgString.c_str(),"Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match.")) { |
| 2373 | FAIL() << "Error received was not 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...' but instead it was '" << msgString.c_str() << "'"; |
| 2374 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2375 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2376 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2377 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2378 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2379 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2380 | } |
| 2381 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2382 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2383 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2384 | { |
| 2385 | VkFlags msgFlags; |
| 2386 | std::string msgString; |
| 2387 | VkResult err; |
| 2388 | |
| 2389 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2390 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2391 | m_errorMonitor->ClearState(); |
| 2392 | |
| 2393 | VkDescriptorTypeCount ds_type_count = {}; |
| 2394 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2395 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2396 | |
| 2397 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2398 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2399 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2400 | ds_pool_ci.typeCount = 1; |
| 2401 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2402 | |
| 2403 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2404 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2405 | ASSERT_VK_SUCCESS(err); |
| 2406 | |
| 2407 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2408 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2409 | dsl_binding.arraySize = 1; |
| 2410 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2411 | |
| 2412 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2413 | 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] | 2414 | ds_layout_ci.bindingCount = 1; |
| 2415 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2416 | |
| 2417 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2418 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2419 | ASSERT_VK_SUCCESS(err); |
| 2420 | |
| 2421 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2422 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2423 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2424 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2425 | alloc_info.descriptorPool = ds_pool; |
| 2426 | alloc_info.pSetLayouts = &ds_layout; |
| 2427 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2428 | ASSERT_VK_SUCCESS(err); |
| 2429 | |
| 2430 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2431 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2432 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2433 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2434 | |
| 2435 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2436 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2437 | ASSERT_VK_SUCCESS(err); |
| 2438 | |
| 2439 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2440 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2441 | vp_state_ci.scissorCount = 1; |
| 2442 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2443 | vp_state_ci.viewportCount = 1; |
| 2444 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2445 | |
| 2446 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2447 | // Set scissor as dynamic to avoid that error |
| 2448 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2449 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2450 | dyn_state_ci.dynamicStateCount = 1; |
| 2451 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2452 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2453 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2454 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2455 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2456 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2457 | 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] | 2458 | // but add it to be able to run on more devices |
| 2459 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2460 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2461 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2462 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2463 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2464 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2465 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2466 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2467 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2468 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2469 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2470 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2471 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2472 | |
| 2473 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2474 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2475 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2476 | |
| 2477 | VkPipelineRasterStateCreateInfo rs_ci = {}; |
| 2478 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO; |
| 2479 | rs_ci.pNext = nullptr; |
| 2480 | |
| 2481 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2482 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2483 | cb_ci.pNext = nullptr; |
| 2484 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2485 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2486 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2487 | gp_ci.stageCount = 2; |
| 2488 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2489 | gp_ci.pVertexInputState = &vi_ci; |
| 2490 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2491 | gp_ci.pViewportState = &vp_state_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2492 | gp_ci.pRasterState = &rs_ci; |
| 2493 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2494 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2495 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2496 | gp_ci.layout = pipeline_layout; |
| 2497 | gp_ci.renderPass = renderPass(); |
| 2498 | |
| 2499 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2500 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2501 | |
| 2502 | VkPipeline pipeline; |
| 2503 | VkPipelineCache pipelineCache; |
| 2504 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2505 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2506 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2507 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2508 | |
| 2509 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2510 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o scissor set."; |
| 2511 | if (!strstr(msgString.c_str(),"Gfx Pipeline scissorCount is 1, but pScissors is NULL. ")) { |
| 2512 | FAIL() << "Error received was not 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...' but instead it was '" << msgString.c_str() << "'"; |
| 2513 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2514 | m_errorMonitor->ClearState(); |
| 2515 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2516 | // First need to successfully create the PSO from above by setting pViewports |
| 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(); |
| 2522 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 2523 | VkViewport viewports[2] = {}; // don't care about data |
| 2524 | // Count of 2 doesn't match PSO count of 1 |
| 2525 | vkCmdSetViewport(m_cmdBuffer->GetBufferHandle(), 2, viewports); |
| 2526 | Draw(1, 0, 0, 0); |
| 2527 | |
| 2528 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2529 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after setting dynamic viewportCount different from PSO viewportCount."; |
| 2530 | if (!strstr(msgString.c_str(),"Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match.")) { |
| 2531 | FAIL() << "Error received was not 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...' but instead it was '" << msgString.c_str() << "'"; |
| 2532 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2533 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2534 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2535 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2536 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2537 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2538 | } |
| 2539 | |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2540 | TEST_F(VkLayerTest, NullRenderPass) |
| 2541 | { |
| 2542 | // Bind a NULL RenderPass |
| 2543 | VkFlags msgFlags; |
| 2544 | std::string msgString; |
| 2545 | |
| 2546 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2547 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2548 | m_errorMonitor->ClearState(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2549 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2550 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2551 | // Don't care about RenderPass handle b/c error should be flagged before that |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2552 | vkCmdBeginRenderPass(m_cmdBuffer->GetBufferHandle(), NULL, VK_RENDER_PASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2553 | |
| 2554 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2555 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding NULL RenderPass."; |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2556 | if (!strstr(msgString.c_str(),"You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()")) { |
| 2557 | FAIL() << "Error received was not 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 2558 | } |
| 2559 | } |
| 2560 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2561 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 2562 | { |
| 2563 | // Bind a BeginRenderPass within an active RenderPass |
| 2564 | VkFlags msgFlags; |
| 2565 | std::string msgString; |
| 2566 | |
| 2567 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2568 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2569 | m_errorMonitor->ClearState(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2570 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2571 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2572 | // 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] | 2573 | VkRenderPassBeginInfo rp_begin = {}; |
| 2574 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 2575 | rp_begin.pNext = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2576 | rp_begin.renderPass = renderPass(); |
| 2577 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2578 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2579 | vkCmdBeginRenderPass(m_cmdBuffer->GetBufferHandle(), &rp_begin, VK_RENDER_PASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2580 | |
| 2581 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2582 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding RenderPass w/i an active RenderPass."; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2583 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2584 | FAIL() << "Error received was not 'It is invalid to issue this call inside an active render pass...'"; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2585 | } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2586 | } |
| 2587 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2588 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 2589 | { |
| 2590 | // Call CmdFillBuffer within an active renderpass |
| 2591 | VkFlags msgFlags; |
| 2592 | std::string msgString; |
| 2593 | |
| 2594 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2595 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2596 | m_errorMonitor->ClearState(); |
| 2597 | |
| 2598 | // Renderpass is started here |
| 2599 | BeginCommandBuffer(); |
| 2600 | |
| 2601 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2602 | vk_testing::Buffer destBuffer; |
| 2603 | destBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
| 2604 | |
| 2605 | m_cmdBuffer->FillBuffer(destBuffer.handle(), 0, 4, 0x11111111); |
| 2606 | |
| 2607 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2608 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2609 | "Did not receive error after calling CmdFillBuffer w/i an active RenderPass."; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2610 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2611 | FAIL() << "Error received was not '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 | } |
| 2614 | |
| 2615 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 2616 | { |
| 2617 | // Call CmdUpdateBuffer within an active renderpass |
| 2618 | VkFlags msgFlags; |
| 2619 | std::string msgString; |
| 2620 | |
| 2621 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2622 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2623 | m_errorMonitor->ClearState(); |
| 2624 | |
| 2625 | // Renderpass is started here |
| 2626 | BeginCommandBuffer(); |
| 2627 | |
| 2628 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2629 | vk_testing::Buffer destBuffer; |
| 2630 | destBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
| 2631 | |
| 2632 | VkDeviceSize destOffset = 0; |
| 2633 | VkDeviceSize dataSize = 1024; |
| 2634 | const uint32_t *pData = NULL; |
| 2635 | |
| 2636 | vkCmdUpdateBuffer(m_cmdBuffer->GetBufferHandle(), destBuffer.handle(), destOffset, dataSize, pData); |
| 2637 | |
| 2638 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2639 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2640 | "Did not receive error after calling CmdUpdateBuffer w/i an active RenderPass."; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2641 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2642 | FAIL() << "Error received was not 'It is invalid to issue this call inside an active render pass...'"; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2643 | } |
| 2644 | } |
| 2645 | |
| 2646 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 2647 | { |
| 2648 | // Call CmdClearColorImage within an active RenderPass |
| 2649 | VkFlags msgFlags; |
| 2650 | std::string msgString; |
| 2651 | |
| 2652 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2653 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2654 | m_errorMonitor->ClearState(); |
| 2655 | |
| 2656 | // Renderpass is started here |
| 2657 | BeginCommandBuffer(); |
| 2658 | |
| 2659 | VkClearColorValue clear_color = {0}; |
| 2660 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2661 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2662 | const int32_t tex_width = 32; |
| 2663 | const int32_t tex_height = 32; |
| 2664 | VkImageCreateInfo image_create_info = {}; |
| 2665 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2666 | image_create_info.pNext = NULL; |
| 2667 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2668 | image_create_info.format = tex_format; |
| 2669 | image_create_info.extent.width = tex_width; |
| 2670 | image_create_info.extent.height = tex_height; |
| 2671 | image_create_info.extent.depth = 1; |
| 2672 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2673 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2674 | image_create_info.samples = 1; |
| 2675 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2676 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2677 | |
| 2678 | vk_testing::Image destImage; |
| 2679 | destImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
| 2680 | |
| 2681 | const VkImageSubresourceRange range = |
| 2682 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 2683 | |
| 2684 | vkCmdClearColorImage(m_cmdBuffer->GetBufferHandle(), |
| 2685 | destImage.handle(), |
| 2686 | VK_IMAGE_LAYOUT_GENERAL, |
| 2687 | &clear_color, |
| 2688 | 1, |
| 2689 | &range); |
| 2690 | |
| 2691 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2692 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2693 | "Did not receive error after calling CmdClearColorImage w/i an active RenderPass."; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2694 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2695 | FAIL() << "Error received was not 'It is invalid to issue this call inside an active render pass...'"; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2696 | } |
| 2697 | } |
| 2698 | |
| 2699 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 2700 | { |
| 2701 | // Call CmdClearDepthStencilImage within an active RenderPass |
| 2702 | VkFlags msgFlags; |
| 2703 | std::string msgString; |
| 2704 | |
| 2705 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2706 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2707 | m_errorMonitor->ClearState(); |
| 2708 | |
| 2709 | // Renderpass is started here |
| 2710 | BeginCommandBuffer(); |
| 2711 | |
| 2712 | VkClearDepthStencilValue clear_value = {0}; |
| 2713 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2714 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 2715 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2716 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 2717 | image_create_info.extent.width = 64; |
| 2718 | image_create_info.extent.height = 64; |
| 2719 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2720 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 2721 | |
| 2722 | vk_testing::Image destImage; |
| 2723 | destImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
| 2724 | |
| 2725 | const VkImageSubresourceRange range = |
| 2726 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2727 | |
| 2728 | vkCmdClearDepthStencilImage(m_cmdBuffer->GetBufferHandle(), |
| 2729 | destImage.handle(), |
| 2730 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 2731 | &clear_value, |
| 2732 | 1, |
| 2733 | &range); |
| 2734 | |
| 2735 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2736 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2737 | "Did not receive error after calling CmdClearDepthStencilImage w/i an active RenderPass."; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2738 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2739 | FAIL() << "Error received was not 'It is invalid to issue this call inside an active render pass...'"; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2740 | } |
| 2741 | } |
| 2742 | |
| 2743 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 2744 | { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2745 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2746 | VkFlags msgFlags; |
| 2747 | std::string msgString; |
| 2748 | VkResult err; |
| 2749 | |
| 2750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2751 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2752 | m_errorMonitor->ClearState(); |
| 2753 | |
| 2754 | // Start no RenderPass |
| 2755 | err = m_cmdBuffer->BeginCommandBuffer(); |
| 2756 | ASSERT_VK_SUCCESS(err); |
| 2757 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2758 | VkClearAttachment color_attachment; |
| 2759 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2760 | color_attachment.clearValue.color.float32[0] = 0; |
| 2761 | color_attachment.clearValue.color.float32[1] = 0; |
| 2762 | color_attachment.clearValue.color.float32[2] = 0; |
| 2763 | color_attachment.clearValue.color.float32[3] = 0; |
| 2764 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2765 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2766 | vkCmdClearAttachments(m_cmdBuffer->GetBufferHandle(), |
| 2767 | 1, &color_attachment, |
| 2768 | 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2769 | |
| 2770 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2771 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2772 | "Did not receive error after calling CmdClearAttachments outside of an active RenderPass."; |
| 2773 | if (!strstr(msgString.c_str(),"vkCmdClearAttachments: This call must be issued inside an active render pass")) { |
| 2774 | FAIL() << "Error received was not 'vkCmdClearAttachments: This call must be issued inside an active render pass.'"; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2775 | } |
| 2776 | } |
| 2777 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2778 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 2779 | { |
| 2780 | // Create a valid cmd buffer |
| 2781 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2782 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 2783 | // 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] | 2784 | } |
Tobin Ehlis | 1056d45 | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 2785 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2786 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 2787 | { |
| 2788 | // Bind a BeginRenderPass within an active RenderPass |
| 2789 | VkFlags msgFlags; |
| 2790 | std::string msgString; |
| 2791 | VkResult err; |
| 2792 | |
| 2793 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2794 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2795 | m_errorMonitor->ClearState(); |
| 2796 | uint32_t qfi = 0; |
| 2797 | VkBufferCreateInfo buffCI = {}; |
| 2798 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2799 | buffCI.size = 1024; |
| 2800 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2801 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2802 | buffCI.pQueueFamilyIndices = &qfi; |
| 2803 | |
| 2804 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2805 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2806 | ASSERT_VK_SUCCESS(err); |
| 2807 | |
| 2808 | BeginCommandBuffer(); |
| 2809 | ASSERT_VK_SUCCESS(err); |
| 2810 | //vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2811 | // Should error before calling to driver so don't care about actual data |
| 2812 | vkCmdBindIndexBuffer(m_cmdBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
| 2813 | |
| 2814 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2815 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after vkCmdBindVertexBuffers() w/o active RenderPass."; |
| 2816 | if (!strstr(msgString.c_str(),"vkCmdBindIndexBuffer() offset (0x7) does not fall on ")) { |
| 2817 | FAIL() << "Error received was not 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...' but instead '" << msgString.c_str() << "'"; |
| 2818 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2819 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2820 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2821 | } |
| 2822 | |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2823 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 2824 | { |
| 2825 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
| 2826 | VkFlags msgFlags; |
| 2827 | std::string msgString; |
| 2828 | |
| 2829 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2830 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2831 | m_errorMonitor->ClearState(); |
| 2832 | |
| 2833 | BeginCommandBuffer(); |
| 2834 | //ASSERT_VK_SUCCESS(err); |
| 2835 | VkCmdBuffer primCB = m_cmdBuffer->GetBufferHandle(); |
| 2836 | vkCmdExecuteCommands(m_cmdBuffer->GetBufferHandle(), 1, &primCB); |
| 2837 | |
| 2838 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2839 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after vkCmdBindVertexBuffers() w/o active RenderPass."; |
| 2840 | if (!strstr(msgString.c_str(),"vkCmdExecuteCommands() called w/ Primary Cmd Buffer ")) { |
| 2841 | FAIL() << "Error received was not 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer ' but instead '" << msgString.c_str() << "'"; |
| 2842 | } |
| 2843 | } |
| 2844 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2845 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 2846 | { |
| 2847 | // Create DS w/ layout of one type and attempt Update w/ mis-matched type |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2848 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2849 | std::string msgString; |
| 2850 | VkResult err; |
| 2851 | |
| 2852 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2853 | m_errorMonitor->ClearState(); |
| 2854 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2855 | VkDescriptorTypeCount ds_type_count = {}; |
| 2856 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2857 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2858 | |
| 2859 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2860 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2861 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2862 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2863 | ds_pool_ci.typeCount = 1; |
| 2864 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2865 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2866 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2867 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2868 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2869 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2870 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2871 | dsl_binding.arraySize = 1; |
| 2872 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2873 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2874 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2875 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2876 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2877 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2878 | ds_layout_ci.bindingCount = 1; |
| 2879 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2880 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2881 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2882 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2883 | ASSERT_VK_SUCCESS(err); |
| 2884 | |
| 2885 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2886 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2887 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2888 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2889 | alloc_info.descriptorPool = ds_pool; |
| 2890 | alloc_info.pSetLayouts = &ds_layout; |
| 2891 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2892 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2893 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2894 | VkSamplerCreateInfo sampler_ci = {}; |
| 2895 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2896 | sampler_ci.pNext = NULL; |
| 2897 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 2898 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 2899 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 9795335 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 2900 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2901 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2902 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2903 | sampler_ci.mipLodBias = 1.0; |
| 2904 | sampler_ci.maxAnisotropy = 1; |
| 2905 | sampler_ci.compareEnable = VK_FALSE; |
| 2906 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2907 | sampler_ci.minLod = 1.0; |
| 2908 | sampler_ci.maxLod = 1.0; |
| 2909 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2910 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 2911 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2912 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2913 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2914 | ASSERT_VK_SUCCESS(err); |
| 2915 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2916 | VkDescriptorImageInfo info = {}; |
| 2917 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2918 | |
| 2919 | VkWriteDescriptorSet descriptor_write; |
| 2920 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2921 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2922 | descriptor_write.destSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2923 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2924 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2925 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2926 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2927 | |
| 2928 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2929 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2930 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2931 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating BUFFER Descriptor w/ incorrect type of SAMPLER."; |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 2932 | if (!strstr(msgString.c_str(),"Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match ")) { |
| 2933 | FAIL() << "Error received was not 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...' but instead '" << msgString.c_str() << "'"; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2934 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2935 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2936 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 2937 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2938 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2939 | } |
| 2940 | |
| 2941 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 2942 | { |
| 2943 | // For overlapping Update, have arrayIndex exceed that of layout |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2944 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2945 | std::string msgString; |
| 2946 | VkResult err; |
| 2947 | |
| 2948 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2949 | m_errorMonitor->ClearState(); |
| 2950 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2951 | VkDescriptorTypeCount ds_type_count = {}; |
| 2952 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2953 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2954 | |
| 2955 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2956 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2957 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2958 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2959 | ds_pool_ci.typeCount = 1; |
| 2960 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2961 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2962 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2963 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2964 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2965 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2966 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2967 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2968 | dsl_binding.arraySize = 1; |
| 2969 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2970 | dsl_binding.pImmutableSamplers = NULL; |
| 2971 | |
| 2972 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2973 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2974 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2975 | ds_layout_ci.bindingCount = 1; |
| 2976 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2977 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2978 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2979 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2980 | ASSERT_VK_SUCCESS(err); |
| 2981 | |
| 2982 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2983 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2984 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2985 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2986 | alloc_info.descriptorPool = ds_pool; |
| 2987 | alloc_info.pSetLayouts = &ds_layout; |
| 2988 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2989 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2990 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2991 | VkSamplerCreateInfo sampler_ci = {}; |
| 2992 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2993 | sampler_ci.pNext = NULL; |
| 2994 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 2995 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 2996 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 9795335 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 2997 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2998 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2999 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3000 | sampler_ci.mipLodBias = 1.0; |
| 3001 | sampler_ci.maxAnisotropy = 1; |
| 3002 | sampler_ci.compareEnable = VK_FALSE; |
| 3003 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3004 | sampler_ci.minLod = 1.0; |
| 3005 | sampler_ci.maxLod = 1.0; |
| 3006 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3007 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3008 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3009 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3010 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3011 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3012 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3013 | VkDescriptorImageInfo info = {}; |
| 3014 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3015 | |
| 3016 | VkWriteDescriptorSet descriptor_write; |
| 3017 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3018 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3019 | descriptor_write.destSet = descriptorSet; |
| 3020 | descriptor_write.destArrayElement = 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3021 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3022 | // 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] | 3023 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3024 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3025 | |
| 3026 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3027 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3028 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3029 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ index out of bounds."; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3030 | if (!strstr(msgString.c_str(),"Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding")) { |
| 3031 | FAIL() << "Error received was not 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding...'"; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3032 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3033 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3034 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3035 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3036 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3037 | } |
| 3038 | |
| 3039 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3040 | { |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3041 | // Create layout w/ count of 1 and attempt update to that layout w/ binding index 2 |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3042 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3043 | std::string msgString; |
| 3044 | VkResult err; |
| 3045 | |
| 3046 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3047 | m_errorMonitor->ClearState(); |
| 3048 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3049 | VkDescriptorTypeCount ds_type_count = {}; |
| 3050 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3051 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3052 | |
| 3053 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3054 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3055 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3056 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3057 | ds_pool_ci.typeCount = 1; |
| 3058 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3059 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3060 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3061 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3062 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3063 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3064 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3065 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3066 | dsl_binding.arraySize = 1; |
| 3067 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3068 | dsl_binding.pImmutableSamplers = NULL; |
| 3069 | |
| 3070 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3071 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3072 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3073 | ds_layout_ci.bindingCount = 1; |
| 3074 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3075 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3076 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3077 | ASSERT_VK_SUCCESS(err); |
| 3078 | |
| 3079 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3080 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3081 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3082 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3083 | alloc_info.descriptorPool = ds_pool; |
| 3084 | alloc_info.pSetLayouts = &ds_layout; |
| 3085 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3086 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3087 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3088 | VkSamplerCreateInfo sampler_ci = {}; |
| 3089 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3090 | sampler_ci.pNext = NULL; |
| 3091 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 3092 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 3093 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 9795335 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 3094 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3095 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3096 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3097 | sampler_ci.mipLodBias = 1.0; |
| 3098 | sampler_ci.maxAnisotropy = 1; |
| 3099 | sampler_ci.compareEnable = VK_FALSE; |
| 3100 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3101 | sampler_ci.minLod = 1.0; |
| 3102 | sampler_ci.maxLod = 1.0; |
| 3103 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3104 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3105 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3106 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3107 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3108 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3109 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3110 | VkDescriptorImageInfo info = {}; |
| 3111 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3112 | |
| 3113 | VkWriteDescriptorSet descriptor_write; |
| 3114 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3115 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3116 | descriptor_write.destSet = descriptorSet; |
| 3117 | descriptor_write.destBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3118 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3119 | // 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] | 3120 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3121 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3122 | |
| 3123 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3124 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3125 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3126 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ count too large for layout."; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3127 | if (!strstr(msgString.c_str()," does not have binding to match update binding ")) { |
| 3128 | FAIL() << "Error received was not 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3129 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3130 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3131 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3132 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3133 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3134 | } |
| 3135 | |
| 3136 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3137 | { |
| 3138 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* types |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3139 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3140 | std::string msgString; |
| 3141 | VkResult err; |
| 3142 | |
| 3143 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3144 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3145 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3146 | VkDescriptorTypeCount ds_type_count = {}; |
| 3147 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3148 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3149 | |
| 3150 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3151 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3152 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3153 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3154 | ds_pool_ci.typeCount = 1; |
| 3155 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3156 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3157 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3158 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3159 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3160 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3161 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3162 | dsl_binding.arraySize = 1; |
| 3163 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3164 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3165 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3166 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3167 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3168 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3169 | ds_layout_ci.bindingCount = 1; |
| 3170 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3171 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3172 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3173 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3174 | ASSERT_VK_SUCCESS(err); |
| 3175 | |
| 3176 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3177 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3178 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3179 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3180 | alloc_info.descriptorPool = ds_pool; |
| 3181 | alloc_info.pSetLayouts = &ds_layout; |
| 3182 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3183 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3184 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3185 | VkSamplerCreateInfo sampler_ci = {}; |
| 3186 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3187 | sampler_ci.pNext = NULL; |
| 3188 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 3189 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 3190 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 9795335 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 3191 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3192 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3193 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3194 | sampler_ci.mipLodBias = 1.0; |
| 3195 | sampler_ci.maxAnisotropy = 1; |
| 3196 | sampler_ci.compareEnable = VK_FALSE; |
| 3197 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3198 | sampler_ci.minLod = 1.0; |
| 3199 | sampler_ci.maxLod = 1.0; |
| 3200 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3201 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3202 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3203 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3204 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3205 | |
| 3206 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3207 | VkDescriptorImageInfo info = {}; |
| 3208 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3209 | |
| 3210 | VkWriteDescriptorSet descriptor_write; |
| 3211 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3212 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
| 3213 | descriptor_write.destSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3214 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3215 | // 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] | 3216 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3217 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3218 | |
| 3219 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3220 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3221 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3222 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ invalid struct type."; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3223 | if (!strstr(msgString.c_str(),"Unexpected UPDATE struct of type ")) { |
| 3224 | FAIL() << "Error received was not 'Unexpected UPDATE struct of type '"; |
| 3225 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3226 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3227 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3228 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3229 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3230 | } |
| 3231 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3232 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3233 | { |
| 3234 | // Create a single Sampler descriptor and send it an invalid Sampler |
| 3235 | VkFlags msgFlags; |
| 3236 | std::string msgString; |
| 3237 | VkResult err; |
| 3238 | |
| 3239 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3240 | m_errorMonitor->ClearState(); |
| 3241 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied code |
| 3242 | VkDescriptorTypeCount ds_type_count = {}; |
| 3243 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3244 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3245 | |
| 3246 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3247 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3248 | ds_pool_ci.pNext = NULL; |
| 3249 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3250 | ds_pool_ci.typeCount = 1; |
| 3251 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3252 | |
| 3253 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3254 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3255 | ASSERT_VK_SUCCESS(err); |
| 3256 | |
| 3257 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3258 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3259 | dsl_binding.arraySize = 1; |
| 3260 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3261 | dsl_binding.pImmutableSamplers = NULL; |
| 3262 | |
| 3263 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3264 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3265 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3266 | ds_layout_ci.bindingCount = 1; |
| 3267 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3268 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3269 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3270 | ASSERT_VK_SUCCESS(err); |
| 3271 | |
| 3272 | VkDescriptorSet descriptorSet; |
| 3273 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3274 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3275 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3276 | alloc_info.descriptorPool = ds_pool; |
| 3277 | alloc_info.pSetLayouts = &ds_layout; |
| 3278 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 3279 | ASSERT_VK_SUCCESS(err); |
| 3280 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3281 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3282 | |
| 3283 | VkDescriptorImageInfo descriptor_info; |
| 3284 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3285 | descriptor_info.sampler = sampler; |
| 3286 | |
| 3287 | VkWriteDescriptorSet descriptor_write; |
| 3288 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3289 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3290 | descriptor_write.destSet = descriptorSet; |
| 3291 | descriptor_write.destBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3292 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3293 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3294 | descriptor_write.pImageInfo = &descriptor_info; |
| 3295 | |
| 3296 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3297 | |
| 3298 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3299 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ invalid VkSampler."; |
| 3300 | if (!strstr(msgString.c_str(),"Attempt to update descriptor with invalid sampler 0xbaadbeef")) { |
| 3301 | FAIL() << "Error received was not 'Attempt to update descriptor with invalid sampler...' but instead '" << msgString.c_str() << "'"; |
| 3302 | } |
| 3303 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3304 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3305 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3306 | } |
| 3307 | |
| 3308 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3309 | { |
| 3310 | // Create a single combined Image/Sampler descriptor and send it an invalid imageView |
| 3311 | VkFlags msgFlags; |
| 3312 | std::string msgString; |
| 3313 | VkResult err; |
| 3314 | |
| 3315 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3316 | m_errorMonitor->ClearState(); |
| 3317 | VkDescriptorTypeCount ds_type_count = {}; |
| 3318 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3319 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3320 | |
| 3321 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3322 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3323 | ds_pool_ci.pNext = NULL; |
| 3324 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3325 | ds_pool_ci.typeCount = 1; |
| 3326 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3327 | |
| 3328 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3329 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3330 | ASSERT_VK_SUCCESS(err); |
| 3331 | |
| 3332 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3333 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3334 | dsl_binding.arraySize = 1; |
| 3335 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3336 | dsl_binding.pImmutableSamplers = NULL; |
| 3337 | |
| 3338 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3339 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3340 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3341 | ds_layout_ci.bindingCount = 1; |
| 3342 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3343 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3344 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3345 | ASSERT_VK_SUCCESS(err); |
| 3346 | |
| 3347 | VkDescriptorSet descriptorSet; |
| 3348 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3349 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3350 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3351 | alloc_info.descriptorPool = ds_pool; |
| 3352 | alloc_info.pSetLayouts = &ds_layout; |
| 3353 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 3354 | ASSERT_VK_SUCCESS(err); |
| 3355 | |
| 3356 | VkSamplerCreateInfo sampler_ci = {}; |
| 3357 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3358 | sampler_ci.pNext = NULL; |
| 3359 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 3360 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 3361 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
| 3362 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3363 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3364 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3365 | sampler_ci.mipLodBias = 1.0; |
| 3366 | sampler_ci.maxAnisotropy = 1; |
| 3367 | sampler_ci.compareEnable = VK_FALSE; |
| 3368 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3369 | sampler_ci.minLod = 1.0; |
| 3370 | sampler_ci.maxLod = 1.0; |
| 3371 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3372 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3373 | |
| 3374 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3375 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3376 | ASSERT_VK_SUCCESS(err); |
| 3377 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3378 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3379 | |
| 3380 | VkDescriptorImageInfo descriptor_info; |
| 3381 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3382 | descriptor_info.sampler = sampler; |
| 3383 | descriptor_info.imageView = view; |
| 3384 | |
| 3385 | VkWriteDescriptorSet descriptor_write; |
| 3386 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3387 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3388 | descriptor_write.destSet = descriptorSet; |
| 3389 | descriptor_write.destBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3390 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3391 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3392 | descriptor_write.pImageInfo = &descriptor_info; |
| 3393 | |
| 3394 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3395 | |
| 3396 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3397 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ invalid VkImageView."; |
| 3398 | if (!strstr(msgString.c_str(),"Attempt to update descriptor with invalid imageView 0xbaadbeef")) { |
| 3399 | FAIL() << "Error received was not 'Attempt to update descriptor with invalid imageView...' but instead '" << msgString.c_str() << "'"; |
| 3400 | } |
| 3401 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3402 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3403 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3404 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3405 | } |
| 3406 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3407 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3408 | { |
| 3409 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update into the other |
| 3410 | VkFlags msgFlags; |
| 3411 | std::string msgString; |
| 3412 | VkResult err; |
| 3413 | |
| 3414 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3415 | m_errorMonitor->ClearState(); |
| 3416 | //VkDescriptorSetObj descriptorSet(m_device); |
| 3417 | VkDescriptorTypeCount ds_type_count[2] = {}; |
| 3418 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3419 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3420 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3421 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3422 | |
| 3423 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3424 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3425 | ds_pool_ci.pNext = NULL; |
| 3426 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3427 | ds_pool_ci.typeCount = 2; |
| 3428 | ds_pool_ci.pTypeCounts = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3429 | |
| 3430 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3431 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3432 | ASSERT_VK_SUCCESS(err); |
| 3433 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
| 3434 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3435 | dsl_binding[0].arraySize = 1; |
| 3436 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3437 | dsl_binding[0].pImmutableSamplers = NULL; |
| 3438 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3439 | dsl_binding[1].arraySize = 1; |
| 3440 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3441 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3442 | |
| 3443 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3444 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3445 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3446 | ds_layout_ci.bindingCount = 2; |
| 3447 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3448 | |
| 3449 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3450 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3451 | ASSERT_VK_SUCCESS(err); |
| 3452 | |
| 3453 | VkDescriptorSet descriptorSet; |
| 3454 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3455 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3456 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3457 | alloc_info.descriptorPool = ds_pool; |
| 3458 | alloc_info.pSetLayouts = &ds_layout; |
| 3459 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 3460 | ASSERT_VK_SUCCESS(err); |
| 3461 | |
| 3462 | VkSamplerCreateInfo sampler_ci = {}; |
| 3463 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3464 | sampler_ci.pNext = NULL; |
| 3465 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 3466 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 3467 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
| 3468 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3469 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3470 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3471 | sampler_ci.mipLodBias = 1.0; |
| 3472 | sampler_ci.maxAnisotropy = 1; |
| 3473 | sampler_ci.compareEnable = VK_FALSE; |
| 3474 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3475 | sampler_ci.minLod = 1.0; |
| 3476 | sampler_ci.maxLod = 1.0; |
| 3477 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3478 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3479 | |
| 3480 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3481 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3482 | ASSERT_VK_SUCCESS(err); |
| 3483 | |
| 3484 | VkDescriptorImageInfo info = {}; |
| 3485 | info.sampler = sampler; |
| 3486 | |
| 3487 | VkWriteDescriptorSet descriptor_write; |
| 3488 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 3489 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3490 | descriptor_write.destSet = descriptorSet; |
| 3491 | descriptor_write.destBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3492 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3493 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3494 | descriptor_write.pImageInfo = &info; |
| 3495 | // This write update should succeed |
| 3496 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3497 | // Now perform a copy update that fails due to type mismatch |
| 3498 | VkCopyDescriptorSet copy_ds_update; |
| 3499 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3500 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3501 | copy_ds_update.srcSet = descriptorSet; |
| 3502 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
| 3503 | copy_ds_update.destSet = descriptorSet; |
| 3504 | copy_ds_update.destBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3505 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3506 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3507 | |
| 3508 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3509 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after copying SAMPLER descriptor type to BUFFER descriptor type."; |
| 3510 | if (!strstr(msgString.c_str(),"Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER ")) { |
| 3511 | FAIL() << "Error received was not 'Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER...' but instead '" << msgString.c_str() << "'"; |
| 3512 | } |
| 3513 | // Now perform a copy update that fails due to binding out of bounds |
| 3514 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3515 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3516 | copy_ds_update.srcSet = descriptorSet; |
| 3517 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
| 3518 | copy_ds_update.destSet = descriptorSet; |
| 3519 | copy_ds_update.destBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3520 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3521 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3522 | |
| 3523 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3524 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after attempting descriptor copy update w/ bad srcBinding."; |
| 3525 | if (!strstr(msgString.c_str(),"Copy descriptor update 0 has srcBinding 3 which is out of bounds ")) { |
| 3526 | FAIL() << "Error received was not 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...' but instead '" << msgString.c_str() << "'"; |
| 3527 | } |
| 3528 | // Now perform a copy update that fails due to binding out of bounds |
| 3529 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3530 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3531 | copy_ds_update.srcSet = descriptorSet; |
| 3532 | copy_ds_update.srcBinding = 1; |
| 3533 | copy_ds_update.destSet = descriptorSet; |
| 3534 | copy_ds_update.destBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3535 | 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] | 3536 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3537 | |
| 3538 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3539 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after attempting descriptor copy update w/ count out of bounds for layout."; |
| 3540 | if (!strstr(msgString.c_str(),"Copy descriptor src update is out of bounds for matching binding 1 ")) { |
| 3541 | FAIL() << "Error received was not 'Copy descriptor src update is out of bounds for matching binding 1...' but instead '" << msgString.c_str() << "'"; |
| 3542 | } |
| 3543 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3544 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3545 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3546 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3547 | } |
| 3548 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3549 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 3550 | { |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3551 | // Create CmdBuffer where MSAA samples doesn't match RenderPass sampleCount |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3552 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3553 | std::string msgString; |
| 3554 | VkResult err; |
| 3555 | |
| 3556 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3557 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3558 | m_errorMonitor->ClearState(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3559 | VkDescriptorTypeCount ds_type_count = {}; |
| 3560 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3561 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3562 | |
| 3563 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3564 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3565 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3566 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3567 | ds_pool_ci.typeCount = 1; |
| 3568 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3569 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3570 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3571 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3572 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3573 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3574 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3575 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3576 | dsl_binding.arraySize = 1; |
| 3577 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3578 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3579 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3580 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3581 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3582 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3583 | ds_layout_ci.bindingCount = 1; |
| 3584 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3585 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3586 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3587 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3588 | ASSERT_VK_SUCCESS(err); |
| 3589 | |
| 3590 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3591 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3592 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3593 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3594 | alloc_info.descriptorPool = ds_pool; |
| 3595 | alloc_info.pSetLayouts = &ds_layout; |
| 3596 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3597 | ASSERT_VK_SUCCESS(err); |
| 3598 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3599 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3600 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3601 | pipe_ms_state_ci.pNext = NULL; |
| 3602 | pipe_ms_state_ci.rasterSamples = 4; |
| 3603 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3604 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3605 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3606 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3607 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3608 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3609 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3610 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3611 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3612 | |
| 3613 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3614 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3615 | ASSERT_VK_SUCCESS(err); |
| 3616 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3617 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3618 | 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] | 3619 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3620 | VkPipelineObj pipe(m_device); |
| 3621 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3622 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3623 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3624 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3625 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3626 | BeginCommandBuffer(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3627 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3628 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3629 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3630 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding RenderPass w/ mismatched MSAA from PSO."; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3631 | if (!strstr(msgString.c_str(),"Num samples mismatch! ")) { |
| 3632 | FAIL() << "Error received was not 'Num samples mismatch!...'"; |
| 3633 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3634 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3635 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3636 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3637 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3638 | } |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3639 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3640 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 3641 | { |
| 3642 | // Create CmdBuffer where we add ClearCmd for FB Color attachment prior to issuing a Draw |
| 3643 | VkFlags msgFlags; |
| 3644 | std::string msgString; |
| 3645 | VkResult err; |
| 3646 | |
| 3647 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3648 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3649 | m_errorMonitor->ClearState(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3650 | |
| 3651 | VkDescriptorTypeCount ds_type_count = {}; |
| 3652 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3653 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3654 | |
| 3655 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3656 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3657 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3658 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3659 | ds_pool_ci.typeCount = 1; |
| 3660 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3661 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3662 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3663 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
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 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3667 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3668 | dsl_binding.arraySize = 1; |
| 3669 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3670 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3671 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3672 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3673 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3674 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3675 | ds_layout_ci.bindingCount = 1; |
| 3676 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3677 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3678 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3679 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3680 | ASSERT_VK_SUCCESS(err); |
| 3681 | |
| 3682 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3683 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3684 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3685 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3686 | alloc_info.descriptorPool = ds_pool; |
| 3687 | alloc_info.pSetLayouts = &ds_layout; |
| 3688 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3689 | ASSERT_VK_SUCCESS(err); |
| 3690 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3691 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3692 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3693 | pipe_ms_state_ci.pNext = NULL; |
| 3694 | pipe_ms_state_ci.rasterSamples = 4; |
| 3695 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3696 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3697 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3698 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3699 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3700 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3701 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3702 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3703 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3704 | |
| 3705 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3706 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3707 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3708 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3709 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3710 | 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] | 3711 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3712 | VkPipelineObj pipe(m_device); |
| 3713 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3714 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3715 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3716 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3717 | |
| 3718 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3719 | |
| 3720 | m_errorMonitor->ClearState(); |
| 3721 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 3722 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3723 | VkClearAttachment color_attachment; |
| 3724 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3725 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 3726 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 3727 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 3728 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 3729 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3730 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3731 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3732 | vkCmdClearAttachments(m_cmdBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3733 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3734 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT) << "Did not receive error after issuing Clear Cmd on FB color attachment prior to Draw Cmd."; |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3735 | if (!strstr(msgString.c_str(),"vkCmdClearAttachments() issued on CB object ")) { |
| 3736 | FAIL() << "Error received was not 'vkCmdClearAttachments() issued on CB object...'"; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3737 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3738 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3739 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3740 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3741 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3742 | } |
| 3743 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3744 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 3745 | { |
| 3746 | // Create CmdBuffer where MSAA samples doesn't match RenderPass sampleCount |
| 3747 | VkFlags msgFlags; |
| 3748 | std::string msgString; |
| 3749 | VkResult err; |
| 3750 | |
| 3751 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3752 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3753 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3754 | m_errorMonitor->ClearState(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3755 | |
| 3756 | VkDescriptorTypeCount ds_type_count = {}; |
| 3757 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3758 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3759 | |
| 3760 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3761 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3762 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3763 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3764 | ds_pool_ci.typeCount = 1; |
| 3765 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3766 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3767 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3768 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
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 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3772 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3773 | dsl_binding.arraySize = 1; |
| 3774 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3775 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3776 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3777 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3778 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3779 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3780 | ds_layout_ci.bindingCount = 1; |
| 3781 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3782 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3783 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3784 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3785 | ASSERT_VK_SUCCESS(err); |
| 3786 | |
| 3787 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3788 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3789 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3790 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3791 | alloc_info.descriptorPool = ds_pool; |
| 3792 | alloc_info.pSetLayouts = &ds_layout; |
| 3793 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3794 | ASSERT_VK_SUCCESS(err); |
| 3795 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3796 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3797 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3798 | pipe_ms_state_ci.pNext = NULL; |
| 3799 | pipe_ms_state_ci.rasterSamples = 1; |
| 3800 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3801 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3802 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3803 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3804 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3805 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3806 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3807 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3808 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3809 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3810 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3811 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3812 | ASSERT_VK_SUCCESS(err); |
| 3813 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3814 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3815 | 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] | 3816 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3817 | VkPipelineObj pipe(m_device); |
| 3818 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3819 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3820 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3821 | pipe.SetViewport(m_viewports); |
| 3822 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3823 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3824 | |
| 3825 | BeginCommandBuffer(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3826 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 3827 | // Don't care about actual data, just need to get to draw to flag error |
| 3828 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 3829 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 3830 | 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] | 3831 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3832 | |
| 3833 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3834 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding Vtx Buffer w/o VBO attached to PSO."; |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 3835 | if (!strstr(msgString.c_str(),"Vtx Buffer Index 1 was bound, but no vtx buffers are attached to PSO.")) { |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3836 | FAIL() << "Error received was not 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.' but instead was '" << msgString.c_str() << "'"; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3837 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3838 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3839 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3840 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3841 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3842 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3843 | #endif // DRAW_STATE_TESTS |
| 3844 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3845 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3846 | #if GTEST_IS_THREADSAFE |
| 3847 | struct thread_data_struct { |
| 3848 | VkCmdBuffer cmdBuffer; |
| 3849 | VkEvent event; |
| 3850 | bool bailout; |
| 3851 | }; |
| 3852 | |
| 3853 | extern "C" void *AddToCommandBuffer(void *arg) |
| 3854 | { |
| 3855 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
| 3856 | std::string msgString; |
| 3857 | |
| 3858 | for (int i = 0; i<10000; i++) { |
Tony Barbour | 0b2cfb2 | 2015-06-29 16:20:35 -0600 | [diff] [blame] | 3859 | vkCmdSetEvent(data->cmdBuffer, data->event, VK_PIPELINE_STAGE_ALL_GPU_COMMANDS); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3860 | if (data->bailout) { |
| 3861 | break; |
| 3862 | } |
| 3863 | } |
| 3864 | return NULL; |
| 3865 | } |
| 3866 | |
| 3867 | TEST_F(VkLayerTest, ThreadCmdBufferCollision) |
| 3868 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3869 | VkFlags msgFlags; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3870 | std::string msgString; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3871 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3872 | |
| 3873 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3874 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3875 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3876 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3877 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3878 | |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3879 | // Calls AllocCommandBuffers |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3880 | VkCommandBufferObj cmdBuffer(m_device, m_cmdPool); |
| 3881 | |
| 3882 | // Avoid creating RenderPass |
| 3883 | cmdBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3884 | |
| 3885 | VkEventCreateInfo event_info; |
| 3886 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3887 | VkResult err; |
| 3888 | |
| 3889 | memset(&event_info, 0, sizeof(event_info)); |
| 3890 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3891 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3892 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3893 | ASSERT_VK_SUCCESS(err); |
| 3894 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3895 | err = vkResetEvent(device(), event); |
| 3896 | ASSERT_VK_SUCCESS(err); |
| 3897 | |
| 3898 | struct thread_data_struct data; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3899 | data.cmdBuffer = cmdBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3900 | data.event = event; |
| 3901 | data.bailout = false; |
| 3902 | m_errorMonitor->SetBailout(&data.bailout); |
| 3903 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3904 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3905 | // Add many entries to command buffer from this thread at the same time. |
| 3906 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3907 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3908 | test_platform_thread_join(thread, NULL); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3909 | cmdBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3910 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3911 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3912 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err from using one VkCommandBufferObj in two threads"; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3913 | if (!strstr(msgString.c_str(),"THREADING ERROR")) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 3914 | FAIL() << "Error received was not 'THREADING ERROR'"; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3915 | } |
| 3916 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3917 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3918 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3919 | #endif // GTEST_IS_THREADSAFE |
| 3920 | #endif // THREADING_TESTS |
| 3921 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3922 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3923 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 3924 | { |
| 3925 | VkFlags msgFlags; |
| 3926 | std::string msgString; |
| 3927 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3928 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3929 | |
| 3930 | m_errorMonitor->ClearState(); |
| 3931 | |
| 3932 | VkShaderModule module; |
| 3933 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3934 | struct icd_spv_header spv; |
| 3935 | |
| 3936 | spv.magic = ICD_SPV_MAGIC; |
| 3937 | spv.version = ICD_SPV_VERSION; |
| 3938 | spv.gen_magic = 0; |
| 3939 | |
| 3940 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3941 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3942 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3943 | moduleCreateInfo.codeSize = 4; |
| 3944 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3945 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3946 | |
| 3947 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3948 | |
Chris Forbes | 46794b8 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 3949 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3950 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 3951 | FAIL() << "Incorrect warning: " << msgString; |
| 3952 | } |
| 3953 | } |
| 3954 | |
| 3955 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 3956 | { |
| 3957 | VkFlags msgFlags; |
| 3958 | std::string msgString; |
| 3959 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3960 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3961 | |
| 3962 | m_errorMonitor->ClearState(); |
| 3963 | |
| 3964 | VkShaderModule module; |
| 3965 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3966 | struct icd_spv_header spv; |
| 3967 | |
| 3968 | spv.magic = ~ICD_SPV_MAGIC; |
| 3969 | spv.version = ICD_SPV_VERSION; |
| 3970 | spv.gen_magic = 0; |
| 3971 | |
| 3972 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3973 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3974 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3975 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 3976 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3977 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3978 | |
| 3979 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3980 | |
Chris Forbes | 46794b8 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 3981 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3982 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 3983 | FAIL() << "Incorrect warning: " << msgString; |
| 3984 | } |
| 3985 | } |
| 3986 | |
| 3987 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 3988 | { |
| 3989 | VkFlags msgFlags; |
| 3990 | std::string msgString; |
| 3991 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3992 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3993 | |
| 3994 | m_errorMonitor->ClearState(); |
| 3995 | |
| 3996 | VkShaderModule module; |
| 3997 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3998 | struct icd_spv_header spv; |
| 3999 | |
| 4000 | spv.magic = ICD_SPV_MAGIC; |
| 4001 | spv.version = ~ICD_SPV_VERSION; |
| 4002 | spv.gen_magic = 0; |
| 4003 | |
| 4004 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4005 | moduleCreateInfo.pNext = NULL; |
| 4006 | |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4007 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4008 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4009 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4010 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4011 | |
| 4012 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4013 | |
Chris Forbes | 46794b8 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 4014 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4015 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 4016 | FAIL() << "Incorrect warning: " << msgString; |
| 4017 | } |
| 4018 | } |
| 4019 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4020 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 4021 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4022 | VkFlags msgFlags; |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4023 | std::string msgString; |
| 4024 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4025 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4026 | |
| 4027 | char const *vsSource = |
| 4028 | "#version 140\n" |
| 4029 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4030 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4031 | "\n" |
| 4032 | "layout(location=0) out float x;\n" |
| 4033 | "void main(){\n" |
| 4034 | " gl_Position = vec4(1);\n" |
| 4035 | " x = 0;\n" |
| 4036 | "}\n"; |
| 4037 | char const *fsSource = |
| 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 | "layout(location=0) out vec4 color;\n" |
| 4043 | "void main(){\n" |
| 4044 | " color = vec4(1);\n" |
| 4045 | "}\n"; |
| 4046 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4047 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4048 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4049 | |
| 4050 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4051 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4052 | pipe.AddShader(&vs); |
| 4053 | pipe.AddShader(&fs); |
| 4054 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4055 | VkDescriptorSetObj descriptorSet(m_device); |
| 4056 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4057 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4058 | |
| 4059 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4060 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4061 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4062 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4063 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4064 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4065 | if (!strstr(msgString.c_str(),"not consumed by fragment shader")) { |
| 4066 | FAIL() << "Incorrect warning: " << msgString; |
| 4067 | } |
| 4068 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4069 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4070 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4071 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4072 | VkFlags msgFlags; |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4073 | std::string msgString; |
| 4074 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4075 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4076 | |
| 4077 | char const *vsSource = |
| 4078 | "#version 140\n" |
| 4079 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4080 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4081 | "\n" |
| 4082 | "void main(){\n" |
| 4083 | " gl_Position = vec4(1);\n" |
| 4084 | "}\n"; |
| 4085 | char const *fsSource = |
| 4086 | "#version 140\n" |
| 4087 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4088 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4089 | "\n" |
| 4090 | "layout(location=0) in float x;\n" |
| 4091 | "layout(location=0) out vec4 color;\n" |
| 4092 | "void main(){\n" |
| 4093 | " color = vec4(x);\n" |
| 4094 | "}\n"; |
| 4095 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4096 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4097 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4098 | |
| 4099 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4100 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4101 | pipe.AddShader(&vs); |
| 4102 | pipe.AddShader(&fs); |
| 4103 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4104 | VkDescriptorSetObj descriptorSet(m_device); |
| 4105 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4106 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4107 | |
| 4108 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4109 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4110 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4111 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4112 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4113 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4114 | if (!strstr(msgString.c_str(),"not written by vertex shader")) { |
| 4115 | FAIL() << "Incorrect error: " << msgString; |
| 4116 | } |
| 4117 | } |
| 4118 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4119 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4120 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4121 | VkFlags msgFlags; |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4122 | std::string msgString; |
| 4123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4124 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4125 | |
| 4126 | char const *vsSource = |
| 4127 | "#version 140\n" |
| 4128 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4129 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4130 | "\n" |
| 4131 | "layout(location=0) out int x;\n" |
| 4132 | "void main(){\n" |
| 4133 | " x = 0;\n" |
| 4134 | " gl_Position = vec4(1);\n" |
| 4135 | "}\n"; |
| 4136 | char const *fsSource = |
| 4137 | "#version 140\n" |
| 4138 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4139 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4140 | "\n" |
| 4141 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4142 | "layout(location=0) out vec4 color;\n" |
| 4143 | "void main(){\n" |
| 4144 | " color = vec4(x);\n" |
| 4145 | "}\n"; |
| 4146 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4147 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4148 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4149 | |
| 4150 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4151 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4152 | pipe.AddShader(&vs); |
| 4153 | pipe.AddShader(&fs); |
| 4154 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4155 | VkDescriptorSetObj descriptorSet(m_device); |
| 4156 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4157 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4158 | |
| 4159 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4160 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4161 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4162 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4163 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4164 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4165 | if (!strstr(msgString.c_str(),"Type mismatch on location 0")) { |
| 4166 | FAIL() << "Incorrect error: " << msgString; |
| 4167 | } |
| 4168 | } |
| 4169 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4170 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4171 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4172 | VkFlags msgFlags; |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4173 | std::string msgString; |
| 4174 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4175 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4176 | |
| 4177 | VkVertexInputBindingDescription input_binding; |
| 4178 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4179 | |
| 4180 | VkVertexInputAttributeDescription input_attrib; |
| 4181 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4182 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4183 | |
| 4184 | char const *vsSource = |
| 4185 | "#version 140\n" |
| 4186 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4187 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4188 | "\n" |
| 4189 | "void main(){\n" |
| 4190 | " gl_Position = vec4(1);\n" |
| 4191 | "}\n"; |
| 4192 | char const *fsSource = |
| 4193 | "#version 140\n" |
| 4194 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4195 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4196 | "\n" |
| 4197 | "layout(location=0) out vec4 color;\n" |
| 4198 | "void main(){\n" |
| 4199 | " color = vec4(1);\n" |
| 4200 | "}\n"; |
| 4201 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4202 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4203 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4204 | |
| 4205 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4206 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4207 | pipe.AddShader(&vs); |
| 4208 | pipe.AddShader(&fs); |
| 4209 | |
| 4210 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4211 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4212 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4213 | VkDescriptorSetObj descriptorSet(m_device); |
| 4214 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4215 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4216 | |
| 4217 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4218 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4219 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4220 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4221 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4222 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4223 | if (!strstr(msgString.c_str(),"location 0 not consumed by VS")) { |
| 4224 | FAIL() << "Incorrect warning: " << msgString; |
| 4225 | } |
| 4226 | } |
| 4227 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4228 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4229 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4230 | VkFlags msgFlags; |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4231 | std::string msgString; |
| 4232 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4233 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4234 | |
| 4235 | char const *vsSource = |
| 4236 | "#version 140\n" |
| 4237 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4238 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4239 | "\n" |
| 4240 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4241 | "void main(){\n" |
| 4242 | " gl_Position = x;\n" |
| 4243 | "}\n"; |
| 4244 | char const *fsSource = |
| 4245 | "#version 140\n" |
| 4246 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4247 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4248 | "\n" |
| 4249 | "layout(location=0) out vec4 color;\n" |
| 4250 | "void main(){\n" |
| 4251 | " color = vec4(1);\n" |
| 4252 | "}\n"; |
| 4253 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4254 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4255 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4256 | |
| 4257 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4258 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4259 | pipe.AddShader(&vs); |
| 4260 | pipe.AddShader(&fs); |
| 4261 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4262 | VkDescriptorSetObj descriptorSet(m_device); |
| 4263 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4264 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4265 | |
| 4266 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4267 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4268 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4269 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4270 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4271 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4272 | if (!strstr(msgString.c_str(),"VS consumes input at location 0 but not provided")) { |
| 4273 | FAIL() << "Incorrect warning: " << msgString; |
| 4274 | } |
| 4275 | } |
| 4276 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4277 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4278 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4279 | VkFlags msgFlags; |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4280 | std::string msgString; |
| 4281 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4282 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4283 | |
| 4284 | VkVertexInputBindingDescription input_binding; |
| 4285 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4286 | |
| 4287 | VkVertexInputAttributeDescription input_attrib; |
| 4288 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4289 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4290 | |
| 4291 | char const *vsSource = |
| 4292 | "#version 140\n" |
| 4293 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4294 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4295 | "\n" |
| 4296 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4297 | "void main(){\n" |
| 4298 | " gl_Position = vec4(x);\n" |
| 4299 | "}\n"; |
| 4300 | char const *fsSource = |
| 4301 | "#version 140\n" |
| 4302 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4303 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4304 | "\n" |
| 4305 | "layout(location=0) out vec4 color;\n" |
| 4306 | "void main(){\n" |
| 4307 | " color = vec4(1);\n" |
| 4308 | "}\n"; |
| 4309 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4310 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4311 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4312 | |
| 4313 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4314 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4315 | pipe.AddShader(&vs); |
| 4316 | pipe.AddShader(&fs); |
| 4317 | |
| 4318 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4319 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4320 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4321 | VkDescriptorSetObj descriptorSet(m_device); |
| 4322 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4323 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4324 | |
| 4325 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4326 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4327 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4328 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4329 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4330 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4331 | if (!strstr(msgString.c_str(),"location 0 does not match VS input type")) { |
| 4332 | FAIL() << "Incorrect error: " << msgString; |
| 4333 | } |
| 4334 | } |
| 4335 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4336 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4337 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4338 | VkFlags msgFlags; |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4339 | std::string msgString; |
| 4340 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4341 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4342 | |
| 4343 | /* Two binding descriptions for binding 0 */ |
| 4344 | VkVertexInputBindingDescription input_bindings[2]; |
| 4345 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4346 | |
| 4347 | VkVertexInputAttributeDescription input_attrib; |
| 4348 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4349 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4350 | |
| 4351 | char const *vsSource = |
| 4352 | "#version 140\n" |
| 4353 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4354 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4355 | "\n" |
| 4356 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 4357 | "void main(){\n" |
| 4358 | " gl_Position = vec4(x);\n" |
| 4359 | "}\n"; |
| 4360 | char const *fsSource = |
| 4361 | "#version 140\n" |
| 4362 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4363 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4364 | "\n" |
| 4365 | "layout(location=0) out vec4 color;\n" |
| 4366 | "void main(){\n" |
| 4367 | " color = vec4(1);\n" |
| 4368 | "}\n"; |
| 4369 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4370 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4371 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4372 | |
| 4373 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4374 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4375 | pipe.AddShader(&vs); |
| 4376 | pipe.AddShader(&fs); |
| 4377 | |
| 4378 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 4379 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4380 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4381 | VkDescriptorSetObj descriptorSet(m_device); |
| 4382 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4383 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4384 | |
| 4385 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4386 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4387 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4388 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4389 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4390 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4391 | if (!strstr(msgString.c_str(),"Duplicate vertex input binding descriptions for binding 0")) { |
| 4392 | FAIL() << "Incorrect error: " << msgString; |
| 4393 | } |
| 4394 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 4395 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4396 | /* TODO: would be nice to test the mixed broadcast & custom case, but the GLSL->SPV compiler |
| 4397 | * rejects it. */ |
| 4398 | |
| 4399 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 4400 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4401 | VkFlags msgFlags; |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4402 | std::string msgString; |
| 4403 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4404 | |
| 4405 | char const *vsSource = |
| 4406 | "#version 140\n" |
| 4407 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4408 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4409 | "\n" |
| 4410 | "void main(){\n" |
| 4411 | " gl_Position = vec4(1);\n" |
| 4412 | "}\n"; |
| 4413 | char const *fsSource = |
| 4414 | "#version 140\n" |
| 4415 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4416 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4417 | "\n" |
| 4418 | "void main(){\n" |
| 4419 | "}\n"; |
| 4420 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4421 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4422 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4423 | |
| 4424 | VkPipelineObj pipe(m_device); |
| 4425 | pipe.AddShader(&vs); |
| 4426 | pipe.AddShader(&fs); |
| 4427 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4428 | /* set up CB 0, not written */ |
| 4429 | pipe.AddColorAttachment(); |
| 4430 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4431 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4432 | VkDescriptorSetObj descriptorSet(m_device); |
| 4433 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4434 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4435 | |
| 4436 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4437 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4438 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4439 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4440 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4441 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4442 | if (!strstr(msgString.c_str(),"Attachment 0 not written by FS")) { |
| 4443 | FAIL() << "Incorrect error: " << msgString; |
| 4444 | } |
| 4445 | } |
| 4446 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4447 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 4448 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4449 | VkFlags msgFlags; |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4450 | std::string msgString; |
| 4451 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4452 | |
| 4453 | char const *vsSource = |
| 4454 | "#version 140\n" |
| 4455 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4456 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4457 | "\n" |
| 4458 | "void main(){\n" |
| 4459 | " gl_Position = vec4(1);\n" |
| 4460 | "}\n"; |
| 4461 | char const *fsSource = |
| 4462 | "#version 140\n" |
| 4463 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4464 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4465 | "\n" |
| 4466 | "layout(location=0) out vec4 x;\n" |
| 4467 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 4468 | "void main(){\n" |
| 4469 | " x = vec4(1);\n" |
| 4470 | " y = vec4(1);\n" |
| 4471 | "}\n"; |
| 4472 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4473 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4474 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4475 | |
| 4476 | VkPipelineObj pipe(m_device); |
| 4477 | pipe.AddShader(&vs); |
| 4478 | pipe.AddShader(&fs); |
| 4479 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4480 | /* set up CB 0, not written */ |
| 4481 | pipe.AddColorAttachment(); |
| 4482 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4483 | /* FS writes CB 1, but we don't configure it */ |
| 4484 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4485 | VkDescriptorSetObj descriptorSet(m_device); |
| 4486 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4487 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4488 | |
| 4489 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4490 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4491 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4492 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4493 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4494 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4495 | if (!strstr(msgString.c_str(),"FS writes to output location 1 with no matching attachment")) { |
| 4496 | FAIL() << "Incorrect warning: " << msgString; |
| 4497 | } |
| 4498 | } |
| 4499 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4500 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 4501 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4502 | VkFlags msgFlags; |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4503 | std::string msgString; |
| 4504 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4505 | |
| 4506 | char const *vsSource = |
| 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 | "void main(){\n" |
| 4512 | " gl_Position = vec4(1);\n" |
| 4513 | "}\n"; |
| 4514 | char const *fsSource = |
| 4515 | "#version 140\n" |
| 4516 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4517 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4518 | "\n" |
| 4519 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 4520 | "void main(){\n" |
| 4521 | " x = ivec4(1);\n" |
| 4522 | "}\n"; |
| 4523 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4524 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4525 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4526 | |
| 4527 | VkPipelineObj pipe(m_device); |
| 4528 | pipe.AddShader(&vs); |
| 4529 | pipe.AddShader(&fs); |
| 4530 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4531 | /* set up CB 0; type is UNORM by default */ |
| 4532 | pipe.AddColorAttachment(); |
| 4533 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4534 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4535 | VkDescriptorSetObj descriptorSet(m_device); |
| 4536 | descriptorSet.AppendDummy(); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4537 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4538 | |
| 4539 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4540 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4541 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4542 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4543 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4544 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4545 | if (!strstr(msgString.c_str(),"does not match FS output type")) { |
| 4546 | FAIL() << "Incorrect error: " << msgString; |
| 4547 | } |
| 4548 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 4549 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4550 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 4551 | { |
| 4552 | VkFlags msgFlags; |
| 4553 | std::string msgString; |
| 4554 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4555 | |
| 4556 | char const *vsSource = |
| 4557 | "#version 140\n" |
| 4558 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4559 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4560 | "\n" |
| 4561 | "void main(){\n" |
| 4562 | " gl_Position = vec4(1);\n" |
| 4563 | "}\n"; |
| 4564 | char const *fsSource = |
| 4565 | "#version 140\n" |
| 4566 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4567 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4568 | "\n" |
| 4569 | "layout(location=0) out vec4 x;\n" |
| 4570 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4571 | "void main(){\n" |
| 4572 | " x = vec4(bar.y);\n" |
| 4573 | "}\n"; |
| 4574 | |
| 4575 | m_errorMonitor->ClearState(); |
| 4576 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4577 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4578 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4579 | |
| 4580 | |
| 4581 | VkPipelineObj pipe(m_device); |
| 4582 | pipe.AddShader(&vs); |
| 4583 | pipe.AddShader(&fs); |
| 4584 | |
| 4585 | /* set up CB 0; type is UNORM by default */ |
| 4586 | pipe.AddColorAttachment(); |
| 4587 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4588 | |
| 4589 | VkDescriptorSetObj descriptorSet(m_device); |
| 4590 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
| 4591 | |
| 4592 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4593 | |
| 4594 | /* should have generated an error -- pipeline layout does not |
| 4595 | * provide a uniform buffer in 0.0 |
| 4596 | */ |
| 4597 | msgFlags = m_errorMonitor->GetState(&msgString); |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 4598 | ASSERT_TRUE((msgFlags & VK_DBG_REPORT_ERROR_BIT) == VK_DBG_REPORT_ERROR_BIT); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4599 | if (!strstr(msgString.c_str(),"not declared in pipeline layout")) { |
| 4600 | FAIL() << "Incorrect error: " << msgString; |
| 4601 | } |
| 4602 | } |
| 4603 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4604 | #endif // SHADER_CHECKER_TESTS |
| 4605 | |
| 4606 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4607 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 4608 | { |
| 4609 | VkFlags msgFlags; |
| 4610 | std::string msgString; |
| 4611 | |
| 4612 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4613 | m_errorMonitor->ClearState(); |
| 4614 | |
| 4615 | // Create an image |
| 4616 | VkImage image; |
| 4617 | |
| 4618 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4619 | const int32_t tex_width = 32; |
| 4620 | const int32_t tex_height = 32; |
| 4621 | |
| 4622 | VkImageCreateInfo image_create_info = {}; |
| 4623 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4624 | image_create_info.pNext = NULL; |
| 4625 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4626 | image_create_info.format = tex_format; |
| 4627 | image_create_info.extent.width = tex_width; |
| 4628 | image_create_info.extent.height = tex_height; |
| 4629 | image_create_info.extent.depth = 1; |
| 4630 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4631 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4632 | image_create_info.samples = 1; |
| 4633 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4634 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4635 | image_create_info.flags = 0; |
| 4636 | |
| 4637 | // Introduce error by sending down a bogus width extent |
| 4638 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4639 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4640 | |
| 4641 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4642 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an image" << |
| 4643 | "with extents outside the queried limits"; |
| 4644 | if (!strstr(msgString.c_str(),"CreateImage extents exceed allowable limits for format")) { |
| 4645 | FAIL() << "Error received did not match expected error message from vkCreateImage in DeviceLimits layer"; |
| 4646 | } |
| 4647 | } |
| 4648 | |
| 4649 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 4650 | { |
| 4651 | VkFlags msgFlags; |
| 4652 | std::string msgString; |
| 4653 | |
| 4654 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4655 | m_errorMonitor->ClearState(); |
| 4656 | |
| 4657 | // Create an image |
| 4658 | VkImage image; |
| 4659 | |
| 4660 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4661 | const int32_t tex_width = 32; |
| 4662 | const int32_t tex_height = 32; |
| 4663 | |
| 4664 | VkImageCreateInfo image_create_info = {}; |
| 4665 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4666 | image_create_info.pNext = NULL; |
| 4667 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4668 | image_create_info.format = tex_format; |
| 4669 | image_create_info.extent.width = tex_width; |
| 4670 | image_create_info.extent.height = tex_height; |
| 4671 | image_create_info.extent.depth = 1; |
| 4672 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4673 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4674 | image_create_info.samples = 1; |
| 4675 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4676 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4677 | image_create_info.flags = 0; |
| 4678 | |
| 4679 | // Introduce error by sending down individually allowable values that result in a surface size |
| 4680 | // exceeding the device maximum |
| 4681 | image_create_info.extent.width = 8192; |
| 4682 | image_create_info.extent.height = 8192; |
| 4683 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4684 | image_create_info.arrayLayers = 4; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4685 | image_create_info.samples = 2; |
| 4686 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4687 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4688 | |
| 4689 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4690 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an image" << |
| 4691 | "with resource size exceeding queried limit"; |
| 4692 | if (!strstr(msgString.c_str(),"CreateImage resource size exceeds allowable maximum")) { |
| 4693 | FAIL() << "Error received did not match expected error message from vkCreateImage in DeviceLimits layer"; |
| 4694 | } |
| 4695 | } |
| 4696 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4697 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 4698 | { |
| 4699 | VkFlags msgFlags; |
| 4700 | std::string msgString; |
| 4701 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 4702 | |
| 4703 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4704 | |
| 4705 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4706 | vk_testing::Buffer buffer; |
| 4707 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4708 | |
| 4709 | BeginCommandBuffer(); |
| 4710 | // Introduce failure by using offset that is not multiple of 4 |
| 4711 | m_cmdBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
| 4712 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4713 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling UpdateBuffer with bad offset"; |
| 4714 | if (!strstr(msgString.c_str(),"destOffset, is not a multiple of 4")) { |
| 4715 | FAIL() << "Error received was not 'vkCmdUpdateBuffer parameter, VkDeviceSize destOffset, is not a multiple of 4'"; |
| 4716 | } |
| 4717 | // Introduce failure by using size that is not multiple of 4 |
| 4718 | m_cmdBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
| 4719 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4720 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling UpdateBuffer with bad size"; |
| 4721 | if (!strstr(msgString.c_str(),"dataSize, is not a multiple of 4")) { |
| 4722 | FAIL() << "Error received was not 'vkCmdUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 4723 | } |
| 4724 | EndCommandBuffer(); |
| 4725 | } |
| 4726 | |
| 4727 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 4728 | { |
| 4729 | VkFlags msgFlags; |
| 4730 | std::string msgString; |
| 4731 | |
| 4732 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4733 | |
| 4734 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4735 | vk_testing::Buffer buffer; |
| 4736 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4737 | |
| 4738 | BeginCommandBuffer(); |
| 4739 | // Introduce failure by using offset that is not multiple of 4 |
| 4740 | m_cmdBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
| 4741 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4742 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling FillBuffer with bad offset"; |
| 4743 | if (!strstr(msgString.c_str(),"destOffset, is not a multiple of 4")) { |
| 4744 | FAIL() << "Error received was not 'vkCmdFillBuffer parameter, VkDeviceSize destOffset, is not a multiple of 4'"; |
| 4745 | } |
| 4746 | // Introduce failure by using size that is not multiple of 4 |
| 4747 | m_cmdBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
| 4748 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4749 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling FillBuffer with bad size"; |
| 4750 | if (!strstr(msgString.c_str(),"fillSize, is not a multiple of 4")) { |
| 4751 | FAIL() << "Error received was not 'vkCmdFillBuffer parameter, VkDeviceSize fillSize, is not a multiple of 4'"; |
| 4752 | } |
| 4753 | EndCommandBuffer(); |
| 4754 | } |
| 4755 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4756 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4757 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4758 | #if IMAGE_TESTS |
| 4759 | TEST_F(VkLayerTest, InvalidImageView) |
| 4760 | { |
| 4761 | VkFlags msgFlags; |
| 4762 | std::string msgString; |
| 4763 | VkResult err; |
| 4764 | |
| 4765 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4766 | m_errorMonitor->ClearState(); |
| 4767 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4768 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4769 | VkImage image; |
| 4770 | |
| 4771 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4772 | const int32_t tex_width = 32; |
| 4773 | const int32_t tex_height = 32; |
| 4774 | |
| 4775 | VkImageCreateInfo image_create_info = {}; |
| 4776 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4777 | image_create_info.pNext = NULL; |
| 4778 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4779 | image_create_info.format = tex_format; |
| 4780 | image_create_info.extent.width = tex_width; |
| 4781 | image_create_info.extent.height = tex_height; |
| 4782 | image_create_info.extent.depth = 1; |
| 4783 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4784 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4785 | image_create_info.samples = 1; |
| 4786 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4787 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4788 | image_create_info.flags = 0; |
| 4789 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4790 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4791 | ASSERT_VK_SUCCESS(err); |
| 4792 | |
| 4793 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4794 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4795 | image_view_create_info.image = image; |
| 4796 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4797 | image_view_create_info.format = tex_format; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4798 | image_view_create_info.subresourceRange.numLayers = 1; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4799 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4800 | image_view_create_info.subresourceRange.numLevels = 1; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4801 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4802 | |
| 4803 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4804 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4805 | |
| 4806 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4807 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an invalid ImageView"; |
| 4808 | if (!strstr(msgString.c_str(),"vkCreateImageView called with baseMipLevel 10 ")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4809 | FAIL() << "Error received was not 'vkCreateImageView called with baseMipLevel 10...' but instead '" << msgString.c_str() << "'"; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4810 | } |
| 4811 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4812 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4813 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 4814 | { |
| 4815 | VkFlags msgFlags; |
| 4816 | std::string msgString; |
| 4817 | VkResult err; |
| 4818 | |
| 4819 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4820 | m_errorMonitor->ClearState(); |
| 4821 | |
| 4822 | // Create an image and try to create a view with an invalid aspectMask |
| 4823 | VkImage image; |
| 4824 | |
| 4825 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4826 | const int32_t tex_width = 32; |
| 4827 | const int32_t tex_height = 32; |
| 4828 | |
| 4829 | VkImageCreateInfo image_create_info = {}; |
| 4830 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4831 | image_create_info.pNext = NULL; |
| 4832 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4833 | image_create_info.format = tex_format; |
| 4834 | image_create_info.extent.width = tex_width; |
| 4835 | image_create_info.extent.height = tex_height; |
| 4836 | image_create_info.extent.depth = 1; |
| 4837 | image_create_info.mipLevels = 1; |
| 4838 | image_create_info.samples = 1; |
| 4839 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4840 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4841 | image_create_info.flags = 0; |
| 4842 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4843 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4844 | ASSERT_VK_SUCCESS(err); |
| 4845 | |
| 4846 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4847 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4848 | image_view_create_info.image = image; |
| 4849 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4850 | image_view_create_info.format = tex_format; |
| 4851 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 4852 | image_view_create_info.subresourceRange.numLevels = 1; |
| 4853 | // Cause an error by setting an invalid image aspect |
| 4854 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 4855 | |
| 4856 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4857 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4858 | |
| 4859 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4860 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error when specifying an invalid ImageView aspect"; |
| 4861 | if (!strstr(msgString.c_str(),"vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set")) { |
| 4862 | FAIL() << "Error received was not 'VkCreateImageView: Color image formats must have ...' but instead '" << msgString.c_str() << "'"; |
| 4863 | } |
| 4864 | } |
| 4865 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4866 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 4867 | { |
| 4868 | VkFlags msgFlags; |
| 4869 | std::string msgString; |
| 4870 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4871 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4872 | |
| 4873 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4874 | m_errorMonitor->ClearState(); |
| 4875 | |
| 4876 | // Create two images of different types and try to copy between them |
| 4877 | VkImage srcImage; |
| 4878 | VkImage destImage; |
| 4879 | VkDeviceMemory srcMem; |
| 4880 | VkDeviceMemory destMem; |
| 4881 | VkMemoryRequirements memReqs; |
| 4882 | |
| 4883 | VkImageCreateInfo image_create_info = {}; |
| 4884 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4885 | image_create_info.pNext = NULL; |
| 4886 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4887 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4888 | image_create_info.extent.width = 32; |
| 4889 | image_create_info.extent.height = 32; |
| 4890 | image_create_info.extent.depth = 1; |
| 4891 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4892 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4893 | image_create_info.samples = 1; |
| 4894 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4895 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT; |
| 4896 | image_create_info.flags = 0; |
| 4897 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4898 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4899 | ASSERT_VK_SUCCESS(err); |
| 4900 | |
| 4901 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 4902 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT; |
| 4903 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4904 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &destImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4905 | ASSERT_VK_SUCCESS(err); |
| 4906 | |
| 4907 | // Allocate memory |
| 4908 | VkMemoryAllocInfo memAlloc = {}; |
| 4909 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4910 | memAlloc.pNext = NULL; |
| 4911 | memAlloc.allocationSize = 0; |
| 4912 | memAlloc.memoryTypeIndex = 0; |
| 4913 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4914 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4915 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4916 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4917 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4918 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4919 | ASSERT_VK_SUCCESS(err); |
| 4920 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4921 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4922 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4923 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4924 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4925 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4926 | ASSERT_VK_SUCCESS(err); |
| 4927 | |
| 4928 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4929 | ASSERT_VK_SUCCESS(err); |
| 4930 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 4931 | ASSERT_VK_SUCCESS(err); |
| 4932 | |
| 4933 | BeginCommandBuffer(); |
| 4934 | VkImageCopy copyRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 4935 | copyRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4936 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4937 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 4938 | copyRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4939 | copyRegion.srcOffset.x = 0; |
| 4940 | copyRegion.srcOffset.y = 0; |
| 4941 | copyRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 4942 | copyRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4943 | copyRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4944 | copyRegion.destSubresource.baseArrayLayer = 0; |
| 4945 | copyRegion.destSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4946 | copyRegion.destOffset.x = 0; |
| 4947 | copyRegion.destOffset.y = 0; |
| 4948 | copyRegion.destOffset.z = 0; |
| 4949 | copyRegion.extent.width = 1; |
| 4950 | copyRegion.extent.height = 1; |
| 4951 | copyRegion.extent.depth = 1; |
| 4952 | m_cmdBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 4953 | EndCommandBuffer(); |
| 4954 | |
| 4955 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4956 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdCopyImage type mismatch"; |
| 4957 | if (!strstr(msgString.c_str(),"vkCmdCopyImage called with unmatched source and dest image types")) { |
| 4958 | FAIL() << "Error received was not 'vkCmdCopyImage called with unmatched source and dest image types' but instead '" << msgString.c_str() << "'"; |
| 4959 | } |
| 4960 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4961 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 4962 | vkDestroyImage(m_device->device(), destImage, NULL); |
| 4963 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 4964 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4965 | } |
| 4966 | |
| 4967 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 4968 | { |
| 4969 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 4970 | } |
| 4971 | |
| 4972 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 4973 | { |
| 4974 | VkFlags msgFlags; |
| 4975 | std::string msgString; |
| 4976 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4977 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4978 | |
| 4979 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4980 | m_errorMonitor->ClearState(); |
| 4981 | |
| 4982 | // Create two images of different types and try to copy between them |
| 4983 | VkImage srcImage; |
| 4984 | VkImage destImage; |
| 4985 | VkDeviceMemory srcMem; |
| 4986 | VkDeviceMemory destMem; |
| 4987 | VkMemoryRequirements memReqs; |
| 4988 | |
| 4989 | VkImageCreateInfo image_create_info = {}; |
| 4990 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4991 | image_create_info.pNext = NULL; |
| 4992 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4993 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4994 | image_create_info.extent.width = 32; |
| 4995 | image_create_info.extent.height = 32; |
| 4996 | image_create_info.extent.depth = 1; |
| 4997 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4998 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4999 | image_create_info.samples = 1; |
| 5000 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5001 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT; |
| 5002 | image_create_info.flags = 0; |
| 5003 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5004 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5005 | ASSERT_VK_SUCCESS(err); |
| 5006 | |
| 5007 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 5008 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT; |
| 5009 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5010 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &destImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5011 | ASSERT_VK_SUCCESS(err); |
| 5012 | |
| 5013 | // Allocate memory |
| 5014 | VkMemoryAllocInfo memAlloc = {}; |
| 5015 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5016 | memAlloc.pNext = NULL; |
| 5017 | memAlloc.allocationSize = 0; |
| 5018 | memAlloc.memoryTypeIndex = 0; |
| 5019 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5020 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5021 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5022 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5023 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5024 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5025 | ASSERT_VK_SUCCESS(err); |
| 5026 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5027 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5028 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5029 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5030 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5031 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5032 | ASSERT_VK_SUCCESS(err); |
| 5033 | |
| 5034 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5035 | ASSERT_VK_SUCCESS(err); |
| 5036 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5037 | ASSERT_VK_SUCCESS(err); |
| 5038 | |
| 5039 | BeginCommandBuffer(); |
| 5040 | VkImageCopy copyRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5041 | copyRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5042 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5043 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 5044 | copyRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5045 | copyRegion.srcOffset.x = 0; |
| 5046 | copyRegion.srcOffset.y = 0; |
| 5047 | copyRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5048 | copyRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5049 | copyRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5050 | copyRegion.destSubresource.baseArrayLayer = 0; |
| 5051 | copyRegion.destSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5052 | copyRegion.destOffset.x = 0; |
| 5053 | copyRegion.destOffset.y = 0; |
| 5054 | copyRegion.destOffset.z = 0; |
| 5055 | copyRegion.extent.width = 1; |
| 5056 | copyRegion.extent.height = 1; |
| 5057 | copyRegion.extent.depth = 1; |
| 5058 | m_cmdBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 5059 | EndCommandBuffer(); |
| 5060 | |
| 5061 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5062 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdCopyImage type mismatch"; |
| 5063 | if (!strstr(msgString.c_str(),"vkCmdCopyImage called with unmatched source and dest image types")) { |
| 5064 | FAIL() << "Error received was not 'vkCmdCopyImage called with unmatched source and dest image types' but instead '" << msgString.c_str() << "'"; |
| 5065 | } |
| 5066 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5067 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 5068 | vkDestroyImage(m_device->device(), destImage, NULL); |
| 5069 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5070 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5071 | } |
| 5072 | |
| 5073 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5074 | { |
| 5075 | VkFlags msgFlags; |
| 5076 | std::string msgString; |
| 5077 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5078 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5079 | |
| 5080 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5081 | m_errorMonitor->ClearState(); |
| 5082 | |
| 5083 | // Create two images of sample count 1 and try to Resolve between them |
| 5084 | VkImage srcImage; |
| 5085 | VkImage destImage; |
| 5086 | VkDeviceMemory srcMem; |
| 5087 | VkDeviceMemory destMem; |
| 5088 | VkMemoryRequirements memReqs; |
| 5089 | |
| 5090 | VkImageCreateInfo image_create_info = {}; |
| 5091 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5092 | image_create_info.pNext = NULL; |
| 5093 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5094 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5095 | image_create_info.extent.width = 32; |
| 5096 | image_create_info.extent.height = 1; |
| 5097 | image_create_info.extent.depth = 1; |
| 5098 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5099 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5100 | image_create_info.samples = 1; |
| 5101 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5102 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT; |
| 5103 | image_create_info.flags = 0; |
| 5104 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5105 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5106 | ASSERT_VK_SUCCESS(err); |
| 5107 | |
| 5108 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 5109 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT; |
| 5110 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5111 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &destImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5112 | ASSERT_VK_SUCCESS(err); |
| 5113 | |
| 5114 | // Allocate memory |
| 5115 | VkMemoryAllocInfo memAlloc = {}; |
| 5116 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5117 | memAlloc.pNext = NULL; |
| 5118 | memAlloc.allocationSize = 0; |
| 5119 | memAlloc.memoryTypeIndex = 0; |
| 5120 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5121 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5122 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5123 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5124 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5125 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5126 | ASSERT_VK_SUCCESS(err); |
| 5127 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5128 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5129 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5130 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5131 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5132 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5133 | ASSERT_VK_SUCCESS(err); |
| 5134 | |
| 5135 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5136 | ASSERT_VK_SUCCESS(err); |
| 5137 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5138 | ASSERT_VK_SUCCESS(err); |
| 5139 | |
| 5140 | BeginCommandBuffer(); |
| 5141 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5142 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5143 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5144 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5145 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5146 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5147 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 5148 | resolveRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5149 | resolveRegion.srcOffset.x = 0; |
| 5150 | resolveRegion.srcOffset.y = 0; |
| 5151 | resolveRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5152 | resolveRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5153 | resolveRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5154 | resolveRegion.destSubresource.baseArrayLayer = 0; |
| 5155 | resolveRegion.destSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5156 | resolveRegion.destOffset.x = 0; |
| 5157 | resolveRegion.destOffset.y = 0; |
| 5158 | resolveRegion.destOffset.z = 0; |
| 5159 | resolveRegion.extent.width = 1; |
| 5160 | resolveRegion.extent.height = 1; |
| 5161 | resolveRegion.extent.depth = 1; |
| 5162 | m_cmdBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
| 5163 | EndCommandBuffer(); |
| 5164 | |
| 5165 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5166 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage type mismatch"; |
| 5167 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with source sample count less than 2.")) { |
| 5168 | FAIL() << "Error received was not 'vkCmdResolveImage called with source sample count less than 2.' but instead '" << msgString.c_str() << "'"; |
| 5169 | } |
| 5170 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5171 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 5172 | vkDestroyImage(m_device->device(), destImage, NULL); |
| 5173 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5174 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5175 | } |
| 5176 | |
| 5177 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5178 | { |
| 5179 | VkFlags msgFlags; |
| 5180 | std::string msgString; |
| 5181 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5182 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5183 | |
| 5184 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5185 | m_errorMonitor->ClearState(); |
| 5186 | |
| 5187 | // Create two images of sample count 2 and try to Resolve between them |
| 5188 | VkImage srcImage; |
| 5189 | VkImage destImage; |
| 5190 | VkDeviceMemory srcMem; |
| 5191 | VkDeviceMemory destMem; |
| 5192 | VkMemoryRequirements memReqs; |
| 5193 | |
| 5194 | VkImageCreateInfo image_create_info = {}; |
| 5195 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5196 | image_create_info.pNext = NULL; |
| 5197 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5198 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5199 | image_create_info.extent.width = 32; |
| 5200 | image_create_info.extent.height = 1; |
| 5201 | image_create_info.extent.depth = 1; |
| 5202 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5203 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5204 | image_create_info.samples = 2; |
| 5205 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5206 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5207 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5208 | image_create_info.flags = 0; |
| 5209 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5210 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5211 | ASSERT_VK_SUCCESS(err); |
| 5212 | |
| 5213 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5214 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5215 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5216 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5217 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &destImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5218 | ASSERT_VK_SUCCESS(err); |
| 5219 | |
| 5220 | // Allocate memory |
| 5221 | VkMemoryAllocInfo memAlloc = {}; |
| 5222 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5223 | memAlloc.pNext = NULL; |
| 5224 | memAlloc.allocationSize = 0; |
| 5225 | memAlloc.memoryTypeIndex = 0; |
| 5226 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5227 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5228 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5229 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5230 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5231 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5232 | ASSERT_VK_SUCCESS(err); |
| 5233 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5234 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5235 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5236 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5237 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5238 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5239 | ASSERT_VK_SUCCESS(err); |
| 5240 | |
| 5241 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5242 | ASSERT_VK_SUCCESS(err); |
| 5243 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5244 | ASSERT_VK_SUCCESS(err); |
| 5245 | |
| 5246 | BeginCommandBuffer(); |
| 5247 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5248 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5249 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5250 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5251 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5252 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5253 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 5254 | resolveRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5255 | resolveRegion.srcOffset.x = 0; |
| 5256 | resolveRegion.srcOffset.y = 0; |
| 5257 | resolveRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5258 | resolveRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5259 | resolveRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5260 | resolveRegion.destSubresource.baseArrayLayer = 0; |
| 5261 | resolveRegion.destSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5262 | resolveRegion.destOffset.x = 0; |
| 5263 | resolveRegion.destOffset.y = 0; |
| 5264 | resolveRegion.destOffset.z = 0; |
| 5265 | resolveRegion.extent.width = 1; |
| 5266 | resolveRegion.extent.height = 1; |
| 5267 | resolveRegion.extent.depth = 1; |
| 5268 | m_cmdBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
| 5269 | EndCommandBuffer(); |
| 5270 | |
| 5271 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5272 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage type mismatch"; |
| 5273 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with dest sample count greater than 1.")) { |
| 5274 | FAIL() << "Error received was not 'vkCmdResolveImage called with dest sample count greater than 1.' but instead '" << msgString.c_str() << "'"; |
| 5275 | } |
| 5276 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5277 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 5278 | vkDestroyImage(m_device->device(), destImage, NULL); |
| 5279 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5280 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5281 | } |
| 5282 | |
| 5283 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5284 | { |
| 5285 | VkFlags msgFlags; |
| 5286 | std::string msgString; |
| 5287 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5288 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5289 | |
| 5290 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5291 | m_errorMonitor->ClearState(); |
| 5292 | |
| 5293 | // Create two images of different types and try to copy between them |
| 5294 | VkImage srcImage; |
| 5295 | VkImage destImage; |
| 5296 | VkDeviceMemory srcMem; |
| 5297 | VkDeviceMemory destMem; |
| 5298 | VkMemoryRequirements memReqs; |
| 5299 | |
| 5300 | VkImageCreateInfo image_create_info = {}; |
| 5301 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5302 | image_create_info.pNext = NULL; |
| 5303 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5304 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5305 | image_create_info.extent.width = 32; |
| 5306 | image_create_info.extent.height = 1; |
| 5307 | image_create_info.extent.depth = 1; |
| 5308 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5309 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5310 | image_create_info.samples = 2; |
| 5311 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5312 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5313 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5314 | image_create_info.flags = 0; |
| 5315 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5316 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5317 | ASSERT_VK_SUCCESS(err); |
| 5318 | |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5319 | // Set format to something other than source image |
| 5320 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5321 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5322 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5323 | image_create_info.samples = 1; |
| 5324 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5325 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &destImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5326 | ASSERT_VK_SUCCESS(err); |
| 5327 | |
| 5328 | // Allocate memory |
| 5329 | VkMemoryAllocInfo memAlloc = {}; |
| 5330 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5331 | memAlloc.pNext = NULL; |
| 5332 | memAlloc.allocationSize = 0; |
| 5333 | memAlloc.memoryTypeIndex = 0; |
| 5334 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5335 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5336 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5337 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5338 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5339 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5340 | ASSERT_VK_SUCCESS(err); |
| 5341 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5342 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5343 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5344 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5345 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5346 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5347 | ASSERT_VK_SUCCESS(err); |
| 5348 | |
| 5349 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5350 | ASSERT_VK_SUCCESS(err); |
| 5351 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5352 | ASSERT_VK_SUCCESS(err); |
| 5353 | |
| 5354 | BeginCommandBuffer(); |
| 5355 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5356 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5357 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5358 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5359 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5360 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5361 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 5362 | resolveRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5363 | resolveRegion.srcOffset.x = 0; |
| 5364 | resolveRegion.srcOffset.y = 0; |
| 5365 | resolveRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5366 | resolveRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5367 | resolveRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5368 | resolveRegion.destSubresource.baseArrayLayer = 0; |
| 5369 | resolveRegion.destSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5370 | resolveRegion.destOffset.x = 0; |
| 5371 | resolveRegion.destOffset.y = 0; |
| 5372 | resolveRegion.destOffset.z = 0; |
| 5373 | resolveRegion.extent.width = 1; |
| 5374 | resolveRegion.extent.height = 1; |
| 5375 | resolveRegion.extent.depth = 1; |
| 5376 | m_cmdBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
| 5377 | EndCommandBuffer(); |
| 5378 | |
| 5379 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5380 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage format mismatch"; |
| 5381 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with unmatched source and dest formats.")) { |
| 5382 | FAIL() << "Error received was not 'vkCmdResolveImage called with unmatched source and dest formats.' but instead '" << msgString.c_str() << "'"; |
| 5383 | } |
| 5384 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5385 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 5386 | vkDestroyImage(m_device->device(), destImage, NULL); |
| 5387 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5388 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5389 | } |
| 5390 | |
| 5391 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 5392 | { |
| 5393 | VkFlags msgFlags; |
| 5394 | std::string msgString; |
| 5395 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5396 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5397 | |
| 5398 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5399 | m_errorMonitor->ClearState(); |
| 5400 | |
| 5401 | // Create two images of different types and try to copy between them |
| 5402 | VkImage srcImage; |
| 5403 | VkImage destImage; |
| 5404 | VkDeviceMemory srcMem; |
| 5405 | VkDeviceMemory destMem; |
| 5406 | VkMemoryRequirements memReqs; |
| 5407 | |
| 5408 | VkImageCreateInfo image_create_info = {}; |
| 5409 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5410 | image_create_info.pNext = NULL; |
| 5411 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5412 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5413 | image_create_info.extent.width = 32; |
| 5414 | image_create_info.extent.height = 1; |
| 5415 | image_create_info.extent.depth = 1; |
| 5416 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5417 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5418 | image_create_info.samples = 2; |
| 5419 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5420 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5421 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5422 | image_create_info.flags = 0; |
| 5423 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5424 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5425 | ASSERT_VK_SUCCESS(err); |
| 5426 | |
| 5427 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5428 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5429 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5430 | image_create_info.samples = 1; |
| 5431 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5432 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &destImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5433 | ASSERT_VK_SUCCESS(err); |
| 5434 | |
| 5435 | // Allocate memory |
| 5436 | VkMemoryAllocInfo memAlloc = {}; |
| 5437 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5438 | memAlloc.pNext = NULL; |
| 5439 | memAlloc.allocationSize = 0; |
| 5440 | memAlloc.memoryTypeIndex = 0; |
| 5441 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5442 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5443 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5444 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5445 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5446 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5447 | ASSERT_VK_SUCCESS(err); |
| 5448 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5449 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5450 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5451 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5452 | ASSERT_TRUE(pass); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5453 | err = vkAllocMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5454 | ASSERT_VK_SUCCESS(err); |
| 5455 | |
| 5456 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5457 | ASSERT_VK_SUCCESS(err); |
| 5458 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5459 | ASSERT_VK_SUCCESS(err); |
| 5460 | |
| 5461 | BeginCommandBuffer(); |
| 5462 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5463 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5464 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5465 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5466 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5467 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5468 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 5469 | resolveRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5470 | resolveRegion.srcOffset.x = 0; |
| 5471 | resolveRegion.srcOffset.y = 0; |
| 5472 | resolveRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5473 | resolveRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5474 | resolveRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5475 | resolveRegion.destSubresource.baseArrayLayer = 0; |
| 5476 | resolveRegion.destSubresource.numLayers = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5477 | resolveRegion.destOffset.x = 0; |
| 5478 | resolveRegion.destOffset.y = 0; |
| 5479 | resolveRegion.destOffset.z = 0; |
| 5480 | resolveRegion.extent.width = 1; |
| 5481 | resolveRegion.extent.height = 1; |
| 5482 | resolveRegion.extent.depth = 1; |
| 5483 | m_cmdBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
| 5484 | EndCommandBuffer(); |
| 5485 | |
| 5486 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5487 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage type mismatch"; |
| 5488 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with unmatched source and dest image types.")) { |
| 5489 | FAIL() << "Error received was not 'vkCmdResolveImage called with unmatched source and dest image types.' but instead '" << msgString.c_str() << "'"; |
| 5490 | } |
| 5491 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5492 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 5493 | vkDestroyImage(m_device->device(), destImage, NULL); |
| 5494 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5495 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5496 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5497 | |
| 5498 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 5499 | { |
| 5500 | // Create a single Image descriptor and cause it to first hit an error due |
| 5501 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 5502 | // The image format check comes 2nd in validation so we trigger it first, |
| 5503 | // then when we cause aspect fail next, bad format check will be preempted |
| 5504 | VkFlags msgFlags; |
| 5505 | std::string msgString; |
| 5506 | VkResult err; |
| 5507 | |
| 5508 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5509 | m_errorMonitor->ClearState(); |
| 5510 | VkDescriptorTypeCount ds_type_count = {}; |
| 5511 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5512 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5513 | |
| 5514 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5515 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5516 | ds_pool_ci.pNext = NULL; |
| 5517 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5518 | ds_pool_ci.typeCount = 1; |
| 5519 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5520 | |
| 5521 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5522 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5523 | ASSERT_VK_SUCCESS(err); |
| 5524 | |
| 5525 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5526 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5527 | dsl_binding.arraySize = 1; |
| 5528 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5529 | dsl_binding.pImmutableSamplers = NULL; |
| 5530 | |
| 5531 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5532 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5533 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5534 | ds_layout_ci.bindingCount = 1; |
| 5535 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5536 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5537 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5538 | ASSERT_VK_SUCCESS(err); |
| 5539 | |
| 5540 | VkDescriptorSet descriptorSet; |
| 5541 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 5542 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5543 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5544 | alloc_info.descriptorPool = ds_pool; |
| 5545 | alloc_info.pSetLayouts = &ds_layout; |
| 5546 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 5547 | ASSERT_VK_SUCCESS(err); |
| 5548 | |
| 5549 | VkImage image_bad; |
| 5550 | VkImage image_good; |
| 5551 | // One bad format and one good format for Color attachment |
| 5552 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 5553 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 5554 | const int32_t tex_width = 32; |
| 5555 | const int32_t tex_height = 32; |
| 5556 | |
| 5557 | VkImageCreateInfo image_create_info = {}; |
| 5558 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5559 | image_create_info.pNext = NULL; |
| 5560 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5561 | image_create_info.format = tex_format_bad; |
| 5562 | image_create_info.extent.width = tex_width; |
| 5563 | image_create_info.extent.height = tex_height; |
| 5564 | image_create_info.extent.depth = 1; |
| 5565 | image_create_info.mipLevels = 1; |
| 5566 | image_create_info.arrayLayers = 1; |
| 5567 | image_create_info.samples = 1; |
| 5568 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5569 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 5570 | image_create_info.flags = 0; |
| 5571 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5572 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5573 | ASSERT_VK_SUCCESS(err); |
| 5574 | image_create_info.format = tex_format_good; |
| 5575 | 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] | 5576 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5577 | ASSERT_VK_SUCCESS(err); |
| 5578 | |
| 5579 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5580 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5581 | image_view_create_info.image = image_bad; |
| 5582 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5583 | image_view_create_info.format = tex_format_bad; |
| 5584 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 5585 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5586 | image_view_create_info.subresourceRange.numLayers = 1; |
| 5587 | image_view_create_info.subresourceRange.numLevels = 1; |
| 5588 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5589 | |
| 5590 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5591 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5592 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5593 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating ImageView for DS image w/ COLOR aspect bit set."; |
| 5594 | if (!strstr(msgString.c_str(),"Combination depth/stencil image formats can have only the ")) { |
| 5595 | FAIL() << "Error received was not 'Combination depth/stencil image formats can have only the....' but instead '" << msgString.c_str() << "'"; |
| 5596 | } |
| 5597 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5598 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 5599 | vkDestroyImage(m_device->device(), image_good, NULL); |
| 5600 | vkDestroyImageView(m_device->device(), view, NULL); |
| 5601 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5602 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5603 | } |
| 5604 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5605 | #endif // IMAGE_TESTS |
| 5606 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5607 | int main(int argc, char **argv) { |
| 5608 | int result; |
| 5609 | |
| 5610 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5611 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5612 | |
| 5613 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 5614 | |
| 5615 | result = RUN_ALL_TESTS(); |
| 5616 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5617 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5618 | return result; |
| 5619 | } |