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