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; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2073 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2074 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2075 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2076 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2077 | |
| 2078 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2079 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2080 | gp_ci.stageCount = 2; |
| 2081 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2082 | gp_ci.pViewportState = &vp_state_ci; |
| 2083 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2084 | gp_ci.layout = pipeline_layout; |
| 2085 | gp_ci.renderPass = renderPass(); |
| 2086 | |
| 2087 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2088 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2089 | |
| 2090 | VkPipeline pipeline; |
| 2091 | VkPipelineCache pipelineCache; |
| 2092 | |
| 2093 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, &pipelineCache); |
| 2094 | ASSERT_VK_SUCCESS(err); |
| 2095 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, &pipeline); |
| 2096 | |
| 2097 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2098 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/ viewport and scissor count mismatch."; |
| 2099 | if (!strstr(msgString.c_str(),"Gfx Pipeline viewport count (1) must match scissor count (0).")) { |
| 2100 | FAIL() << "Error received was not 'Gfx Pipeline viewport count (1) must match scissor count (0).' but instead it was '" << msgString.c_str() << "'"; |
| 2101 | } |
| 2102 | |
| 2103 | vkDestroyPipelineCache(m_device->device(), pipelineCache); |
| 2104 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2105 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2106 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
| 2107 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2108 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2109 | // for the counts even if the data is going to be set dynamically. |
| 2110 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2111 | { |
| 2112 | // Attempt to Create Gfx Pipeline w/o a VS |
| 2113 | VkFlags msgFlags; |
| 2114 | std::string msgString; |
| 2115 | VkResult err; |
| 2116 | |
| 2117 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2118 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2119 | m_errorMonitor->ClearState(); |
| 2120 | |
| 2121 | VkDescriptorTypeCount ds_type_count = {}; |
| 2122 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2123 | ds_type_count.count = 1; |
| 2124 | |
| 2125 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2126 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2127 | ds_pool_ci.maxSets = 1; |
| 2128 | ds_pool_ci.count = 1; |
| 2129 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2130 | |
| 2131 | VkDescriptorPool ds_pool; |
| 2132 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
| 2133 | ASSERT_VK_SUCCESS(err); |
| 2134 | |
| 2135 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2136 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2137 | dsl_binding.arraySize = 1; |
| 2138 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2139 | |
| 2140 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2141 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2142 | ds_layout_ci.count = 1; |
| 2143 | ds_layout_ci.pBinding = &dsl_binding; |
| 2144 | |
| 2145 | VkDescriptorSetLayout ds_layout; |
| 2146 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2147 | ASSERT_VK_SUCCESS(err); |
| 2148 | |
| 2149 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2150 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2151 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 2152 | alloc_info.count = 1; |
| 2153 | alloc_info.descriptorPool = ds_pool; |
| 2154 | alloc_info.pSetLayouts = &ds_layout; |
| 2155 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2156 | ASSERT_VK_SUCCESS(err); |
| 2157 | |
| 2158 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2159 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2160 | pipeline_layout_ci.descriptorSetCount = 1; |
| 2161 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2162 | |
| 2163 | VkPipelineLayout pipeline_layout; |
| 2164 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 2165 | ASSERT_VK_SUCCESS(err); |
| 2166 | |
| 2167 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2168 | // Set scissor as dynamic to avoid second error |
| 2169 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2170 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2171 | dyn_state_ci.dynamicStateCount = 1; |
| 2172 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2173 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2174 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2175 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2176 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2177 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2178 | 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] | 2179 | // but add it to be able to run on more devices |
| 2180 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2181 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2182 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2183 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2184 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2185 | |
| 2186 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2187 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2188 | gp_ci.stageCount = 2; |
| 2189 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2190 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2191 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2192 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2193 | gp_ci.layout = pipeline_layout; |
| 2194 | gp_ci.renderPass = renderPass(); |
| 2195 | |
| 2196 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2197 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2198 | |
| 2199 | VkPipeline pipeline; |
| 2200 | VkPipelineCache pipelineCache; |
| 2201 | |
| 2202 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, &pipelineCache); |
| 2203 | ASSERT_VK_SUCCESS(err); |
| 2204 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, &pipeline); |
| 2205 | |
| 2206 | msgFlags = m_errorMonitor->GetState(&msgString); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2207 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o viewport state set."; |
| 2208 | if (!strstr(msgString.c_str(),"Gfx Pipeline pViewportState is null. Even if ")) { |
| 2209 | 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] | 2210 | } |
| 2211 | |
| 2212 | vkDestroyPipelineCache(m_device->device(), pipelineCache); |
| 2213 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2214 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2215 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
| 2216 | } |
| 2217 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2218 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2219 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2220 | { |
| 2221 | VkFlags msgFlags; |
| 2222 | std::string msgString; |
| 2223 | VkResult err; |
| 2224 | |
| 2225 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2226 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2227 | m_errorMonitor->ClearState(); |
| 2228 | |
| 2229 | VkDescriptorTypeCount ds_type_count = {}; |
| 2230 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2231 | ds_type_count.count = 1; |
| 2232 | |
| 2233 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2234 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2235 | ds_pool_ci.maxSets = 1; |
| 2236 | ds_pool_ci.count = 1; |
| 2237 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2238 | |
| 2239 | VkDescriptorPool ds_pool; |
| 2240 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
| 2241 | ASSERT_VK_SUCCESS(err); |
| 2242 | |
| 2243 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2244 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2245 | dsl_binding.arraySize = 1; |
| 2246 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2247 | |
| 2248 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2249 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2250 | ds_layout_ci.count = 1; |
| 2251 | ds_layout_ci.pBinding = &dsl_binding; |
| 2252 | |
| 2253 | VkDescriptorSetLayout ds_layout; |
| 2254 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2255 | ASSERT_VK_SUCCESS(err); |
| 2256 | |
| 2257 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2258 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2259 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 2260 | alloc_info.count = 1; |
| 2261 | alloc_info.descriptorPool = ds_pool; |
| 2262 | alloc_info.pSetLayouts = &ds_layout; |
| 2263 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2264 | ASSERT_VK_SUCCESS(err); |
| 2265 | |
| 2266 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2267 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2268 | pipeline_layout_ci.descriptorSetCount = 1; |
| 2269 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2270 | |
| 2271 | VkPipelineLayout pipeline_layout; |
| 2272 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 2273 | ASSERT_VK_SUCCESS(err); |
| 2274 | |
| 2275 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2276 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2277 | vp_state_ci.viewportCount = 1; |
| 2278 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2279 | vp_state_ci.scissorCount = 1; |
| 2280 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2281 | |
| 2282 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2283 | // Set scissor as dynamic to avoid that error |
| 2284 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2285 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2286 | dyn_state_ci.dynamicStateCount = 1; |
| 2287 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2288 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2289 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2290 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2291 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2292 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2293 | 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] | 2294 | // but add it to be able to run on more devices |
| 2295 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2296 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2297 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2298 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2299 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2300 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2301 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2302 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2303 | vi_ci.pNext = nullptr; |
| 2304 | vi_ci.bindingCount = 0; |
| 2305 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 2306 | vi_ci.attributeCount = 0; |
| 2307 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2308 | |
| 2309 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2310 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2311 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2312 | |
| 2313 | VkPipelineRasterStateCreateInfo rs_ci = {}; |
| 2314 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO; |
| 2315 | rs_ci.pNext = nullptr; |
| 2316 | |
| 2317 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2318 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2319 | cb_ci.pNext = nullptr; |
| 2320 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2321 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2322 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2323 | gp_ci.stageCount = 2; |
| 2324 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2325 | gp_ci.pVertexInputState = &vi_ci; |
| 2326 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2327 | gp_ci.pViewportState = &vp_state_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2328 | gp_ci.pRasterState = &rs_ci; |
| 2329 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2330 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2331 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2332 | gp_ci.layout = pipeline_layout; |
| 2333 | gp_ci.renderPass = renderPass(); |
| 2334 | |
| 2335 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2336 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2337 | |
| 2338 | VkPipeline pipeline; |
| 2339 | VkPipelineCache pipelineCache; |
| 2340 | |
| 2341 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, &pipelineCache); |
| 2342 | ASSERT_VK_SUCCESS(err); |
| 2343 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, &pipeline); |
| 2344 | |
| 2345 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2346 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o scissor set."; |
| 2347 | if (!strstr(msgString.c_str(),"Gfx Pipeline viewportCount is 1, but pViewports is NULL. ")) { |
| 2348 | FAIL() << "Error received was not 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...' but instead it was '" << msgString.c_str() << "'"; |
| 2349 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2350 | m_errorMonitor->ClearState(); |
| 2351 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2352 | // First need to successfully create the PSO from above by setting pViewports |
| 2353 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2354 | vp_state_ci.pViewports = &vp; |
| 2355 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, &pipeline); |
| 2356 | ASSERT_VK_SUCCESS(err); |
| 2357 | BeginCommandBuffer(); |
| 2358 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 2359 | VkRect2D scissors[2] = {}; // don't care about data |
| 2360 | // Count of 2 doesn't match PSO count of 1 |
| 2361 | vkCmdSetScissor(m_cmdBuffer->GetBufferHandle(), 2, scissors); |
| 2362 | Draw(1, 0, 0, 0); |
| 2363 | |
| 2364 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2365 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after setting dynamic scissorCount different from PSO scissorCount."; |
| 2366 | if (!strstr(msgString.c_str(),"Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match.")) { |
| 2367 | FAIL() << "Error received was not 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...' but instead it was '" << msgString.c_str() << "'"; |
| 2368 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2369 | |
| 2370 | vkDestroyPipelineCache(m_device->device(), pipelineCache); |
| 2371 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2372 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2373 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
| 2374 | } |
| 2375 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2376 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2377 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2378 | { |
| 2379 | VkFlags msgFlags; |
| 2380 | std::string msgString; |
| 2381 | VkResult err; |
| 2382 | |
| 2383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2384 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2385 | m_errorMonitor->ClearState(); |
| 2386 | |
| 2387 | VkDescriptorTypeCount ds_type_count = {}; |
| 2388 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2389 | ds_type_count.count = 1; |
| 2390 | |
| 2391 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2392 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2393 | ds_pool_ci.maxSets = 1; |
| 2394 | ds_pool_ci.count = 1; |
| 2395 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2396 | |
| 2397 | VkDescriptorPool ds_pool; |
| 2398 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
| 2399 | ASSERT_VK_SUCCESS(err); |
| 2400 | |
| 2401 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2402 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2403 | dsl_binding.arraySize = 1; |
| 2404 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2405 | |
| 2406 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2407 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2408 | ds_layout_ci.count = 1; |
| 2409 | ds_layout_ci.pBinding = &dsl_binding; |
| 2410 | |
| 2411 | VkDescriptorSetLayout ds_layout; |
| 2412 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2413 | ASSERT_VK_SUCCESS(err); |
| 2414 | |
| 2415 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2416 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2417 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 2418 | alloc_info.count = 1; |
| 2419 | alloc_info.descriptorPool = ds_pool; |
| 2420 | alloc_info.pSetLayouts = &ds_layout; |
| 2421 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2422 | ASSERT_VK_SUCCESS(err); |
| 2423 | |
| 2424 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2425 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2426 | pipeline_layout_ci.descriptorSetCount = 1; |
| 2427 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2428 | |
| 2429 | VkPipelineLayout pipeline_layout; |
| 2430 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 2431 | ASSERT_VK_SUCCESS(err); |
| 2432 | |
| 2433 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2434 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2435 | vp_state_ci.scissorCount = 1; |
| 2436 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2437 | vp_state_ci.viewportCount = 1; |
| 2438 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2439 | |
| 2440 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2441 | // Set scissor as dynamic to avoid that error |
| 2442 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2443 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2444 | dyn_state_ci.dynamicStateCount = 1; |
| 2445 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2446 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2447 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2448 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2449 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2450 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2451 | 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] | 2452 | // but add it to be able to run on more devices |
| 2453 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2454 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2455 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2456 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2457 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2458 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2459 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2460 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2461 | vi_ci.pNext = nullptr; |
| 2462 | vi_ci.bindingCount = 0; |
| 2463 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 2464 | vi_ci.attributeCount = 0; |
| 2465 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2466 | |
| 2467 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2468 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2469 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2470 | |
| 2471 | VkPipelineRasterStateCreateInfo rs_ci = {}; |
| 2472 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO; |
| 2473 | rs_ci.pNext = nullptr; |
| 2474 | |
| 2475 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2476 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2477 | cb_ci.pNext = nullptr; |
| 2478 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2479 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2480 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2481 | gp_ci.stageCount = 2; |
| 2482 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2483 | gp_ci.pVertexInputState = &vi_ci; |
| 2484 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2485 | gp_ci.pViewportState = &vp_state_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2486 | gp_ci.pRasterState = &rs_ci; |
| 2487 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2488 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2489 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2490 | gp_ci.layout = pipeline_layout; |
| 2491 | gp_ci.renderPass = renderPass(); |
| 2492 | |
| 2493 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2494 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2495 | |
| 2496 | VkPipeline pipeline; |
| 2497 | VkPipelineCache pipelineCache; |
| 2498 | |
| 2499 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, &pipelineCache); |
| 2500 | ASSERT_VK_SUCCESS(err); |
| 2501 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, &pipeline); |
| 2502 | |
| 2503 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2504 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o scissor set."; |
| 2505 | if (!strstr(msgString.c_str(),"Gfx Pipeline scissorCount is 1, but pScissors is NULL. ")) { |
| 2506 | FAIL() << "Error received was not 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...' but instead it was '" << msgString.c_str() << "'"; |
| 2507 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2508 | m_errorMonitor->ClearState(); |
| 2509 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2510 | // First need to successfully create the PSO from above by setting pViewports |
| 2511 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 2512 | vp_state_ci.pScissors = ≻ |
| 2513 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, &pipeline); |
| 2514 | ASSERT_VK_SUCCESS(err); |
| 2515 | BeginCommandBuffer(); |
| 2516 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 2517 | VkViewport viewports[2] = {}; // don't care about data |
| 2518 | // Count of 2 doesn't match PSO count of 1 |
| 2519 | vkCmdSetViewport(m_cmdBuffer->GetBufferHandle(), 2, viewports); |
| 2520 | Draw(1, 0, 0, 0); |
| 2521 | |
| 2522 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2523 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after setting dynamic viewportCount different from PSO viewportCount."; |
| 2524 | if (!strstr(msgString.c_str(),"Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match.")) { |
| 2525 | FAIL() << "Error received was not 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...' but instead it was '" << msgString.c_str() << "'"; |
| 2526 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2527 | |
| 2528 | vkDestroyPipelineCache(m_device->device(), pipelineCache); |
| 2529 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2530 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2531 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
| 2532 | } |
| 2533 | |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2534 | TEST_F(VkLayerTest, NullRenderPass) |
| 2535 | { |
| 2536 | // Bind a NULL RenderPass |
| 2537 | VkFlags msgFlags; |
| 2538 | std::string msgString; |
| 2539 | |
| 2540 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2541 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2542 | m_errorMonitor->ClearState(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2543 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2544 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2545 | // 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] | 2546 | vkCmdBeginRenderPass(m_cmdBuffer->GetBufferHandle(), NULL, VK_RENDER_PASS_CONTENTS_INLINE); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2547 | |
| 2548 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2549 | 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] | 2550 | if (!strstr(msgString.c_str(),"You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()")) { |
| 2551 | FAIL() << "Error received was not 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 2552 | } |
| 2553 | } |
| 2554 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2555 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 2556 | { |
| 2557 | // Bind a BeginRenderPass within an active RenderPass |
| 2558 | VkFlags msgFlags; |
| 2559 | std::string msgString; |
| 2560 | |
| 2561 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2562 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2563 | m_errorMonitor->ClearState(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2564 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2565 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2566 | // 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] | 2567 | VkRenderPassBeginInfo rp_begin = {}; |
| 2568 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 2569 | rp_begin.pNext = NULL; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2570 | rp_begin.renderPass = renderPass(); |
| 2571 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2572 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2573 | vkCmdBeginRenderPass(m_cmdBuffer->GetBufferHandle(), &rp_begin, VK_RENDER_PASS_CONTENTS_INLINE); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2574 | |
| 2575 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2576 | 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] | 2577 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2578 | 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] | 2579 | } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2580 | } |
| 2581 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2582 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 2583 | { |
| 2584 | // Call CmdFillBuffer within an active renderpass |
| 2585 | VkFlags msgFlags; |
| 2586 | std::string msgString; |
| 2587 | |
| 2588 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2589 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2590 | m_errorMonitor->ClearState(); |
| 2591 | |
| 2592 | // Renderpass is started here |
| 2593 | BeginCommandBuffer(); |
| 2594 | |
| 2595 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2596 | vk_testing::Buffer destBuffer; |
| 2597 | destBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
| 2598 | |
| 2599 | m_cmdBuffer->FillBuffer(destBuffer.handle(), 0, 4, 0x11111111); |
| 2600 | |
| 2601 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2602 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2603 | "Did not receive error after calling CmdFillBuffer w/i an active RenderPass."; |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2604 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2605 | 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] | 2606 | } |
| 2607 | } |
| 2608 | |
| 2609 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 2610 | { |
| 2611 | // Call CmdUpdateBuffer within an active renderpass |
| 2612 | VkFlags msgFlags; |
| 2613 | std::string msgString; |
| 2614 | |
| 2615 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2616 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2617 | m_errorMonitor->ClearState(); |
| 2618 | |
| 2619 | // Renderpass is started here |
| 2620 | BeginCommandBuffer(); |
| 2621 | |
| 2622 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2623 | vk_testing::Buffer destBuffer; |
| 2624 | destBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
| 2625 | |
| 2626 | VkDeviceSize destOffset = 0; |
| 2627 | VkDeviceSize dataSize = 1024; |
| 2628 | const uint32_t *pData = NULL; |
| 2629 | |
| 2630 | vkCmdUpdateBuffer(m_cmdBuffer->GetBufferHandle(), destBuffer.handle(), destOffset, dataSize, pData); |
| 2631 | |
| 2632 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2633 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2634 | "Did not receive error after calling CmdUpdateBuffer w/i an active RenderPass."; |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2635 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2636 | 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] | 2637 | } |
| 2638 | } |
| 2639 | |
| 2640 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 2641 | { |
| 2642 | // Call CmdClearColorImage within an active RenderPass |
| 2643 | VkFlags msgFlags; |
| 2644 | std::string msgString; |
| 2645 | |
| 2646 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2647 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2648 | m_errorMonitor->ClearState(); |
| 2649 | |
| 2650 | // Renderpass is started here |
| 2651 | BeginCommandBuffer(); |
| 2652 | |
| 2653 | VkClearColorValue clear_color = {0}; |
| 2654 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2655 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2656 | const int32_t tex_width = 32; |
| 2657 | const int32_t tex_height = 32; |
| 2658 | VkImageCreateInfo image_create_info = {}; |
| 2659 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2660 | image_create_info.pNext = NULL; |
| 2661 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2662 | image_create_info.format = tex_format; |
| 2663 | image_create_info.extent.width = tex_width; |
| 2664 | image_create_info.extent.height = tex_height; |
| 2665 | image_create_info.extent.depth = 1; |
| 2666 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2667 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2668 | image_create_info.samples = 1; |
| 2669 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2670 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2671 | |
| 2672 | vk_testing::Image destImage; |
| 2673 | destImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
| 2674 | |
| 2675 | const VkImageSubresourceRange range = |
| 2676 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 2677 | |
| 2678 | vkCmdClearColorImage(m_cmdBuffer->GetBufferHandle(), |
| 2679 | destImage.handle(), |
| 2680 | VK_IMAGE_LAYOUT_GENERAL, |
| 2681 | &clear_color, |
| 2682 | 1, |
| 2683 | &range); |
| 2684 | |
| 2685 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2686 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2687 | "Did not receive error after calling CmdClearColorImage w/i an active RenderPass."; |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2688 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2689 | 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] | 2690 | } |
| 2691 | } |
| 2692 | |
| 2693 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 2694 | { |
| 2695 | // Call CmdClearDepthStencilImage within an active RenderPass |
| 2696 | VkFlags msgFlags; |
| 2697 | std::string msgString; |
| 2698 | |
| 2699 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2700 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2701 | m_errorMonitor->ClearState(); |
| 2702 | |
| 2703 | // Renderpass is started here |
| 2704 | BeginCommandBuffer(); |
| 2705 | |
| 2706 | VkClearDepthStencilValue clear_value = {0}; |
| 2707 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2708 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 2709 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2710 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 2711 | image_create_info.extent.width = 64; |
| 2712 | image_create_info.extent.height = 64; |
| 2713 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2714 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 2715 | |
| 2716 | vk_testing::Image destImage; |
| 2717 | destImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
| 2718 | |
| 2719 | const VkImageSubresourceRange range = |
| 2720 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2721 | |
| 2722 | vkCmdClearDepthStencilImage(m_cmdBuffer->GetBufferHandle(), |
| 2723 | destImage.handle(), |
| 2724 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 2725 | &clear_value, |
| 2726 | 1, |
| 2727 | &range); |
| 2728 | |
| 2729 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2730 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2731 | "Did not receive error after calling CmdClearDepthStencilImage w/i an active RenderPass."; |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2732 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2733 | 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] | 2734 | } |
| 2735 | } |
| 2736 | |
| 2737 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 2738 | { |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2739 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2740 | VkFlags msgFlags; |
| 2741 | std::string msgString; |
| 2742 | VkResult err; |
| 2743 | |
| 2744 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2745 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2746 | m_errorMonitor->ClearState(); |
| 2747 | |
| 2748 | // Start no RenderPass |
| 2749 | err = m_cmdBuffer->BeginCommandBuffer(); |
| 2750 | ASSERT_VK_SUCCESS(err); |
| 2751 | |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2752 | VkClearAttachment color_attachment; |
| 2753 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2754 | color_attachment.clearValue.color.float32[0] = 0; |
| 2755 | color_attachment.clearValue.color.float32[1] = 0; |
| 2756 | color_attachment.clearValue.color.float32[2] = 0; |
| 2757 | color_attachment.clearValue.color.float32[3] = 0; |
| 2758 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2759 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2760 | vkCmdClearAttachments(m_cmdBuffer->GetBufferHandle(), |
| 2761 | 1, &color_attachment, |
| 2762 | 1, &clear_rect); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2763 | |
| 2764 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2765 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2766 | "Did not receive error after calling CmdClearAttachments outside of an active RenderPass."; |
| 2767 | if (!strstr(msgString.c_str(),"vkCmdClearAttachments: This call must be issued inside an active render pass")) { |
| 2768 | 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] | 2769 | } |
| 2770 | } |
| 2771 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2772 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 2773 | { |
| 2774 | // Create a valid cmd buffer |
| 2775 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2776 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 2777 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2778 | } |
Tobin Ehlis | 201b1ba | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 2779 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2780 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 2781 | { |
| 2782 | // Bind a BeginRenderPass within an active RenderPass |
| 2783 | VkFlags msgFlags; |
| 2784 | std::string msgString; |
| 2785 | VkResult err; |
| 2786 | |
| 2787 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2788 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2789 | m_errorMonitor->ClearState(); |
| 2790 | uint32_t qfi = 0; |
| 2791 | VkBufferCreateInfo buffCI = {}; |
| 2792 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2793 | buffCI.size = 1024; |
| 2794 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 2795 | buffCI.queueFamilyCount = 1; |
| 2796 | buffCI.pQueueFamilyIndices = &qfi; |
| 2797 | |
| 2798 | VkBuffer ib; |
| 2799 | err = vkCreateBuffer(m_device->device(), &buffCI, &ib); |
| 2800 | ASSERT_VK_SUCCESS(err); |
| 2801 | |
| 2802 | BeginCommandBuffer(); |
| 2803 | ASSERT_VK_SUCCESS(err); |
| 2804 | //vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2805 | // Should error before calling to driver so don't care about actual data |
| 2806 | vkCmdBindIndexBuffer(m_cmdBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
| 2807 | |
| 2808 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2809 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after vkCmdBindVertexBuffers() w/o active RenderPass."; |
| 2810 | if (!strstr(msgString.c_str(),"vkCmdBindIndexBuffer() offset (0x7) does not fall on ")) { |
| 2811 | FAIL() << "Error received was not 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...' but instead '" << msgString.c_str() << "'"; |
| 2812 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2813 | |
| 2814 | vkDestroyBuffer(m_device->device(), ib); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2815 | } |
| 2816 | |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2817 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 2818 | { |
| 2819 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
| 2820 | VkFlags msgFlags; |
| 2821 | std::string msgString; |
| 2822 | |
| 2823 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2824 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2825 | m_errorMonitor->ClearState(); |
| 2826 | |
| 2827 | BeginCommandBuffer(); |
| 2828 | //ASSERT_VK_SUCCESS(err); |
| 2829 | VkCmdBuffer primCB = m_cmdBuffer->GetBufferHandle(); |
| 2830 | vkCmdExecuteCommands(m_cmdBuffer->GetBufferHandle(), 1, &primCB); |
| 2831 | |
| 2832 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2833 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after vkCmdBindVertexBuffers() w/o active RenderPass."; |
| 2834 | if (!strstr(msgString.c_str(),"vkCmdExecuteCommands() called w/ Primary Cmd Buffer ")) { |
| 2835 | FAIL() << "Error received was not 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer ' but instead '" << msgString.c_str() << "'"; |
| 2836 | } |
| 2837 | } |
| 2838 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2839 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 2840 | { |
| 2841 | // 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] | 2842 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2843 | std::string msgString; |
| 2844 | VkResult err; |
| 2845 | |
| 2846 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2847 | m_errorMonitor->ClearState(); |
| 2848 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2849 | VkDescriptorTypeCount ds_type_count = {}; |
| 2850 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2851 | ds_type_count.count = 1; |
| 2852 | |
| 2853 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2854 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2855 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2856 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2857 | ds_pool_ci.count = 1; |
| 2858 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2859 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2860 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2861 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2862 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2863 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2864 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2865 | dsl_binding.arraySize = 1; |
| 2866 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2867 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2868 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2869 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2870 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2871 | ds_layout_ci.pNext = NULL; |
| 2872 | ds_layout_ci.count = 1; |
| 2873 | ds_layout_ci.pBinding = &dsl_binding; |
| 2874 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2875 | VkDescriptorSetLayout ds_layout; |
| 2876 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2877 | ASSERT_VK_SUCCESS(err); |
| 2878 | |
| 2879 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2880 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2881 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 2882 | alloc_info.count = 1; |
| 2883 | alloc_info.descriptorPool = ds_pool; |
| 2884 | alloc_info.pSetLayouts = &ds_layout; |
| 2885 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2886 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2887 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2888 | VkSamplerCreateInfo sampler_ci = {}; |
| 2889 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2890 | sampler_ci.pNext = NULL; |
| 2891 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 2892 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 2893 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 5162441 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 2894 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2895 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2896 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2897 | sampler_ci.mipLodBias = 1.0; |
| 2898 | sampler_ci.maxAnisotropy = 1; |
| 2899 | sampler_ci.compareEnable = VK_FALSE; |
| 2900 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2901 | sampler_ci.minLod = 1.0; |
| 2902 | sampler_ci.maxLod = 1.0; |
| 2903 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2904 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 2905 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2906 | VkSampler sampler; |
| 2907 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 2908 | ASSERT_VK_SUCCESS(err); |
| 2909 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2910 | VkDescriptorImageInfo info = {}; |
| 2911 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2912 | |
| 2913 | VkWriteDescriptorSet descriptor_write; |
| 2914 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2915 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2916 | descriptor_write.destSet = descriptorSet; |
| 2917 | descriptor_write.count = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2918 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2919 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2920 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2921 | |
| 2922 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2923 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2924 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2925 | 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] | 2926 | if (!strstr(msgString.c_str(),"Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match ")) { |
| 2927 | 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] | 2928 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2929 | |
| 2930 | vkDestroySampler(m_device->device(), sampler); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2931 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2932 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2933 | } |
| 2934 | |
| 2935 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 2936 | { |
| 2937 | // For overlapping Update, have arrayIndex exceed that of layout |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2938 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2939 | std::string msgString; |
| 2940 | VkResult err; |
| 2941 | |
| 2942 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2943 | m_errorMonitor->ClearState(); |
| 2944 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2945 | VkDescriptorTypeCount ds_type_count = {}; |
| 2946 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2947 | ds_type_count.count = 1; |
| 2948 | |
| 2949 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2950 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2951 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2952 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2953 | ds_pool_ci.count = 1; |
| 2954 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2955 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2956 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2957 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2958 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2959 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2960 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2961 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2962 | dsl_binding.arraySize = 1; |
| 2963 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2964 | dsl_binding.pImmutableSamplers = NULL; |
| 2965 | |
| 2966 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2967 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2968 | ds_layout_ci.pNext = NULL; |
| 2969 | ds_layout_ci.count = 1; |
| 2970 | ds_layout_ci.pBinding = &dsl_binding; |
| 2971 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2972 | VkDescriptorSetLayout ds_layout; |
| 2973 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2974 | ASSERT_VK_SUCCESS(err); |
| 2975 | |
| 2976 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2977 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 2978 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 2979 | alloc_info.count = 1; |
| 2980 | alloc_info.descriptorPool = ds_pool; |
| 2981 | alloc_info.pSetLayouts = &ds_layout; |
| 2982 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2983 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2984 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2985 | VkSamplerCreateInfo sampler_ci = {}; |
| 2986 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2987 | sampler_ci.pNext = NULL; |
| 2988 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 2989 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 2990 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 5162441 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 2991 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2992 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2993 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2994 | sampler_ci.mipLodBias = 1.0; |
| 2995 | sampler_ci.maxAnisotropy = 1; |
| 2996 | sampler_ci.compareEnable = VK_FALSE; |
| 2997 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2998 | sampler_ci.minLod = 1.0; |
| 2999 | sampler_ci.maxLod = 1.0; |
| 3000 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3001 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3002 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3003 | VkSampler sampler; |
| 3004 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 3005 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3006 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3007 | VkDescriptorImageInfo info = {}; |
| 3008 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3009 | |
| 3010 | VkWriteDescriptorSet descriptor_write; |
| 3011 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3012 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3013 | descriptor_write.destSet = descriptorSet; |
| 3014 | descriptor_write.destArrayElement = 1; /* This index out of bounds for the update */ |
| 3015 | descriptor_write.count = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3016 | // 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] | 3017 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3018 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3019 | |
| 3020 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3021 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3022 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3023 | 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] | 3024 | if (!strstr(msgString.c_str(),"Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding")) { |
| 3025 | 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] | 3026 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3027 | |
| 3028 | vkDestroySampler(m_device->device(), sampler); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3029 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 3030 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3031 | } |
| 3032 | |
| 3033 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3034 | { |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3035 | // 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] | 3036 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3037 | std::string msgString; |
| 3038 | VkResult err; |
| 3039 | |
| 3040 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3041 | m_errorMonitor->ClearState(); |
| 3042 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3043 | VkDescriptorTypeCount ds_type_count = {}; |
| 3044 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3045 | ds_type_count.count = 1; |
| 3046 | |
| 3047 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3048 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3049 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3050 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3051 | ds_pool_ci.count = 1; |
| 3052 | ds_pool_ci.pTypeCount = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3053 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3054 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3055 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3056 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3057 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3058 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3059 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3060 | dsl_binding.arraySize = 1; |
| 3061 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3062 | dsl_binding.pImmutableSamplers = NULL; |
| 3063 | |
| 3064 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3065 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3066 | ds_layout_ci.pNext = NULL; |
| 3067 | ds_layout_ci.count = 1; |
| 3068 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3069 | VkDescriptorSetLayout ds_layout; |
| 3070 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 3071 | ASSERT_VK_SUCCESS(err); |
| 3072 | |
| 3073 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3074 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3075 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 3076 | alloc_info.count = 1; |
| 3077 | alloc_info.descriptorPool = ds_pool; |
| 3078 | alloc_info.pSetLayouts = &ds_layout; |
| 3079 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3080 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3081 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3082 | VkSamplerCreateInfo sampler_ci = {}; |
| 3083 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3084 | sampler_ci.pNext = NULL; |
| 3085 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 3086 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 3087 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 5162441 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 3088 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3089 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3090 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3091 | sampler_ci.mipLodBias = 1.0; |
| 3092 | sampler_ci.maxAnisotropy = 1; |
| 3093 | sampler_ci.compareEnable = VK_FALSE; |
| 3094 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3095 | sampler_ci.minLod = 1.0; |
| 3096 | sampler_ci.maxLod = 1.0; |
| 3097 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3098 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3099 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3100 | VkSampler sampler; |
| 3101 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 3102 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3103 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3104 | VkDescriptorImageInfo info = {}; |
| 3105 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3106 | |
| 3107 | VkWriteDescriptorSet descriptor_write; |
| 3108 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3109 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3110 | descriptor_write.destSet = descriptorSet; |
| 3111 | descriptor_write.destBinding = 2; |
| 3112 | descriptor_write.count = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3113 | // 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] | 3114 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3115 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3116 | |
| 3117 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3118 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3119 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3120 | 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] | 3121 | if (!strstr(msgString.c_str()," does not have binding to match update binding ")) { |
| 3122 | FAIL() << "Error received was not 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3123 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3124 | |
| 3125 | vkDestroySampler(m_device->device(), sampler); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3126 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 3127 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3128 | } |
| 3129 | |
| 3130 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3131 | { |
| 3132 | // 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] | 3133 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3134 | std::string msgString; |
| 3135 | VkResult err; |
| 3136 | |
| 3137 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3138 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3139 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3140 | VkDescriptorTypeCount ds_type_count = {}; |
| 3141 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3142 | ds_type_count.count = 1; |
| 3143 | |
| 3144 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3145 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3146 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3147 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3148 | ds_pool_ci.count = 1; |
| 3149 | ds_pool_ci.pTypeCount = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3150 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3151 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3152 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3153 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3154 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3155 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3156 | dsl_binding.arraySize = 1; |
| 3157 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3158 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3159 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3160 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3161 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3162 | ds_layout_ci.pNext = NULL; |
| 3163 | ds_layout_ci.count = 1; |
| 3164 | ds_layout_ci.pBinding = &dsl_binding; |
| 3165 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3166 | VkDescriptorSetLayout ds_layout; |
| 3167 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 3168 | ASSERT_VK_SUCCESS(err); |
| 3169 | |
| 3170 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3171 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3172 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 3173 | alloc_info.count = 1; |
| 3174 | alloc_info.descriptorPool = ds_pool; |
| 3175 | alloc_info.pSetLayouts = &ds_layout; |
| 3176 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3177 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3178 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3179 | VkSamplerCreateInfo sampler_ci = {}; |
| 3180 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3181 | sampler_ci.pNext = NULL; |
| 3182 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 3183 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 3184 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 5162441 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 3185 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3186 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3187 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3188 | sampler_ci.mipLodBias = 1.0; |
| 3189 | sampler_ci.maxAnisotropy = 1; |
| 3190 | sampler_ci.compareEnable = VK_FALSE; |
| 3191 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3192 | sampler_ci.minLod = 1.0; |
| 3193 | sampler_ci.maxLod = 1.0; |
| 3194 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3195 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3196 | VkSampler sampler; |
| 3197 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 3198 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3199 | |
| 3200 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3201 | VkDescriptorImageInfo info = {}; |
| 3202 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3203 | |
| 3204 | VkWriteDescriptorSet descriptor_write; |
| 3205 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3206 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
| 3207 | descriptor_write.destSet = descriptorSet; |
| 3208 | descriptor_write.count = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3209 | // 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] | 3210 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3211 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3212 | |
| 3213 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3214 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3215 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3216 | 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] | 3217 | if (!strstr(msgString.c_str(),"Unexpected UPDATE struct of type ")) { |
| 3218 | FAIL() << "Error received was not 'Unexpected UPDATE struct of type '"; |
| 3219 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3220 | |
| 3221 | vkDestroySampler(m_device->device(), sampler); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3222 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 3223 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3224 | } |
| 3225 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3226 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3227 | { |
| 3228 | // Create a single Sampler descriptor and send it an invalid Sampler |
| 3229 | VkFlags msgFlags; |
| 3230 | std::string msgString; |
| 3231 | VkResult err; |
| 3232 | |
| 3233 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3234 | m_errorMonitor->ClearState(); |
| 3235 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied code |
| 3236 | VkDescriptorTypeCount ds_type_count = {}; |
| 3237 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3238 | ds_type_count.count = 1; |
| 3239 | |
| 3240 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3241 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3242 | ds_pool_ci.pNext = NULL; |
| 3243 | ds_pool_ci.maxSets = 1; |
| 3244 | ds_pool_ci.count = 1; |
| 3245 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 3246 | |
| 3247 | VkDescriptorPool ds_pool; |
| 3248 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
| 3249 | ASSERT_VK_SUCCESS(err); |
| 3250 | |
| 3251 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3252 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3253 | dsl_binding.arraySize = 1; |
| 3254 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3255 | dsl_binding.pImmutableSamplers = NULL; |
| 3256 | |
| 3257 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3258 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3259 | ds_layout_ci.pNext = NULL; |
| 3260 | ds_layout_ci.count = 1; |
| 3261 | ds_layout_ci.pBinding = &dsl_binding; |
| 3262 | VkDescriptorSetLayout ds_layout; |
| 3263 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 3264 | ASSERT_VK_SUCCESS(err); |
| 3265 | |
| 3266 | VkDescriptorSet descriptorSet; |
| 3267 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3268 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 3269 | alloc_info.count = 1; |
| 3270 | alloc_info.descriptorPool = ds_pool; |
| 3271 | alloc_info.pSetLayouts = &ds_layout; |
| 3272 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 3273 | ASSERT_VK_SUCCESS(err); |
| 3274 | |
| 3275 | VkSampler sampler; |
| 3276 | sampler.handle = 0xbaadbeef; // Sampler with invalid handle |
| 3277 | |
| 3278 | VkDescriptorImageInfo descriptor_info; |
| 3279 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3280 | descriptor_info.sampler = sampler; |
| 3281 | |
| 3282 | VkWriteDescriptorSet descriptor_write; |
| 3283 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3284 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3285 | descriptor_write.destSet = descriptorSet; |
| 3286 | descriptor_write.destBinding = 0; |
| 3287 | descriptor_write.count = 1; |
| 3288 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3289 | descriptor_write.pImageInfo = &descriptor_info; |
| 3290 | |
| 3291 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3292 | |
| 3293 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3294 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ invalid VkSampler."; |
| 3295 | if (!strstr(msgString.c_str(),"Attempt to update descriptor with invalid sampler 0xbaadbeef")) { |
| 3296 | FAIL() << "Error received was not 'Attempt to update descriptor with invalid sampler...' but instead '" << msgString.c_str() << "'"; |
| 3297 | } |
| 3298 | |
| 3299 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 3300 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
| 3301 | } |
| 3302 | |
| 3303 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3304 | { |
| 3305 | // Create a single combined Image/Sampler descriptor and send it an invalid imageView |
| 3306 | VkFlags msgFlags; |
| 3307 | std::string msgString; |
| 3308 | VkResult err; |
| 3309 | |
| 3310 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3311 | m_errorMonitor->ClearState(); |
| 3312 | VkDescriptorTypeCount ds_type_count = {}; |
| 3313 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3314 | ds_type_count.count = 1; |
| 3315 | |
| 3316 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3317 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3318 | ds_pool_ci.pNext = NULL; |
| 3319 | ds_pool_ci.maxSets = 1; |
| 3320 | ds_pool_ci.count = 1; |
| 3321 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 3322 | |
| 3323 | VkDescriptorPool ds_pool; |
| 3324 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
| 3325 | ASSERT_VK_SUCCESS(err); |
| 3326 | |
| 3327 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3328 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3329 | dsl_binding.arraySize = 1; |
| 3330 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3331 | dsl_binding.pImmutableSamplers = NULL; |
| 3332 | |
| 3333 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3334 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3335 | ds_layout_ci.pNext = NULL; |
| 3336 | ds_layout_ci.count = 1; |
| 3337 | ds_layout_ci.pBinding = &dsl_binding; |
| 3338 | VkDescriptorSetLayout ds_layout; |
| 3339 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 3340 | ASSERT_VK_SUCCESS(err); |
| 3341 | |
| 3342 | VkDescriptorSet descriptorSet; |
| 3343 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3344 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 3345 | alloc_info.count = 1; |
| 3346 | alloc_info.descriptorPool = ds_pool; |
| 3347 | alloc_info.pSetLayouts = &ds_layout; |
| 3348 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 3349 | ASSERT_VK_SUCCESS(err); |
| 3350 | |
| 3351 | VkSamplerCreateInfo sampler_ci = {}; |
| 3352 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3353 | sampler_ci.pNext = NULL; |
| 3354 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 3355 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 3356 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
| 3357 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3358 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3359 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3360 | sampler_ci.mipLodBias = 1.0; |
| 3361 | sampler_ci.maxAnisotropy = 1; |
| 3362 | sampler_ci.compareEnable = VK_FALSE; |
| 3363 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3364 | sampler_ci.minLod = 1.0; |
| 3365 | sampler_ci.maxLod = 1.0; |
| 3366 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3367 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3368 | |
| 3369 | VkSampler sampler; |
| 3370 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 3371 | ASSERT_VK_SUCCESS(err); |
| 3372 | |
| 3373 | VkImageView view; |
| 3374 | view.handle = 0xbaadbeef; // invalid imageView object |
| 3375 | |
| 3376 | VkDescriptorImageInfo descriptor_info; |
| 3377 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3378 | descriptor_info.sampler = sampler; |
| 3379 | descriptor_info.imageView = view; |
| 3380 | |
| 3381 | VkWriteDescriptorSet descriptor_write; |
| 3382 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3383 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3384 | descriptor_write.destSet = descriptorSet; |
| 3385 | descriptor_write.destBinding = 0; |
| 3386 | descriptor_write.count = 1; |
| 3387 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3388 | descriptor_write.pImageInfo = &descriptor_info; |
| 3389 | |
| 3390 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3391 | |
| 3392 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3393 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ invalid VkImageView."; |
| 3394 | if (!strstr(msgString.c_str(),"Attempt to update descriptor with invalid imageView 0xbaadbeef")) { |
| 3395 | FAIL() << "Error received was not 'Attempt to update descriptor with invalid imageView...' but instead '" << msgString.c_str() << "'"; |
| 3396 | } |
| 3397 | |
| 3398 | vkDestroySampler(m_device->device(), sampler); |
| 3399 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 3400 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
| 3401 | } |
| 3402 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3403 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3404 | { |
| 3405 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update into the other |
| 3406 | VkFlags msgFlags; |
| 3407 | std::string msgString; |
| 3408 | VkResult err; |
| 3409 | |
| 3410 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3411 | m_errorMonitor->ClearState(); |
| 3412 | //VkDescriptorSetObj descriptorSet(m_device); |
| 3413 | VkDescriptorTypeCount ds_type_count[2] = {}; |
| 3414 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3415 | ds_type_count[0].count = 1; |
| 3416 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3417 | ds_type_count[1].count = 1; |
| 3418 | |
| 3419 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3420 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3421 | ds_pool_ci.pNext = NULL; |
| 3422 | ds_pool_ci.maxSets = 1; |
| 3423 | ds_pool_ci.count = 2; |
| 3424 | ds_pool_ci.pTypeCount = ds_type_count; |
| 3425 | |
| 3426 | VkDescriptorPool ds_pool; |
| 3427 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
| 3428 | ASSERT_VK_SUCCESS(err); |
| 3429 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
| 3430 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3431 | dsl_binding[0].arraySize = 1; |
| 3432 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3433 | dsl_binding[0].pImmutableSamplers = NULL; |
| 3434 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3435 | dsl_binding[1].arraySize = 1; |
| 3436 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3437 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3438 | |
| 3439 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3440 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3441 | ds_layout_ci.pNext = NULL; |
| 3442 | ds_layout_ci.count = 2; |
| 3443 | ds_layout_ci.pBinding = dsl_binding; |
| 3444 | |
| 3445 | VkDescriptorSetLayout ds_layout; |
| 3446 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 3447 | ASSERT_VK_SUCCESS(err); |
| 3448 | |
| 3449 | VkDescriptorSet descriptorSet; |
| 3450 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3451 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 3452 | alloc_info.count = 1; |
| 3453 | alloc_info.descriptorPool = ds_pool; |
| 3454 | alloc_info.pSetLayouts = &ds_layout; |
| 3455 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 3456 | ASSERT_VK_SUCCESS(err); |
| 3457 | |
| 3458 | VkSamplerCreateInfo sampler_ci = {}; |
| 3459 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3460 | sampler_ci.pNext = NULL; |
| 3461 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 3462 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 3463 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
| 3464 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3465 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3466 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
| 3467 | sampler_ci.mipLodBias = 1.0; |
| 3468 | sampler_ci.maxAnisotropy = 1; |
| 3469 | sampler_ci.compareEnable = VK_FALSE; |
| 3470 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3471 | sampler_ci.minLod = 1.0; |
| 3472 | sampler_ci.maxLod = 1.0; |
| 3473 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3474 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3475 | |
| 3476 | VkSampler sampler; |
| 3477 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 3478 | ASSERT_VK_SUCCESS(err); |
| 3479 | |
| 3480 | VkDescriptorImageInfo info = {}; |
| 3481 | info.sampler = sampler; |
| 3482 | |
| 3483 | VkWriteDescriptorSet descriptor_write; |
| 3484 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 3485 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3486 | descriptor_write.destSet = descriptorSet; |
| 3487 | descriptor_write.destBinding = 1; // SAMPLER binding from layout above |
| 3488 | descriptor_write.count = 1; |
| 3489 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3490 | descriptor_write.pImageInfo = &info; |
| 3491 | // This write update should succeed |
| 3492 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3493 | // Now perform a copy update that fails due to type mismatch |
| 3494 | VkCopyDescriptorSet copy_ds_update; |
| 3495 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3496 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3497 | copy_ds_update.srcSet = descriptorSet; |
| 3498 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
| 3499 | copy_ds_update.destSet = descriptorSet; |
| 3500 | copy_ds_update.destBinding = 0; // ERROR : copy to UNIFORM binding |
| 3501 | copy_ds_update.count = 1; // copy 1 descriptor |
| 3502 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3503 | |
| 3504 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3505 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after copying SAMPLER descriptor type to BUFFER descriptor type."; |
| 3506 | if (!strstr(msgString.c_str(),"Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER ")) { |
| 3507 | 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() << "'"; |
| 3508 | } |
| 3509 | // Now perform a copy update that fails due to binding out of bounds |
| 3510 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3511 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3512 | copy_ds_update.srcSet = descriptorSet; |
| 3513 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
| 3514 | copy_ds_update.destSet = descriptorSet; |
| 3515 | copy_ds_update.destBinding = 0; |
| 3516 | copy_ds_update.count = 1; // copy 1 descriptor |
| 3517 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3518 | |
| 3519 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3520 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after attempting descriptor copy update w/ bad srcBinding."; |
| 3521 | if (!strstr(msgString.c_str(),"Copy descriptor update 0 has srcBinding 3 which is out of bounds ")) { |
| 3522 | FAIL() << "Error received was not 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...' but instead '" << msgString.c_str() << "'"; |
| 3523 | } |
| 3524 | // Now perform a copy update that fails due to binding out of bounds |
| 3525 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3526 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3527 | copy_ds_update.srcSet = descriptorSet; |
| 3528 | copy_ds_update.srcBinding = 1; |
| 3529 | copy_ds_update.destSet = descriptorSet; |
| 3530 | copy_ds_update.destBinding = 0; |
| 3531 | copy_ds_update.count = 5; // ERROR copy 5 descriptors (out of bounds for layout) |
| 3532 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3533 | |
| 3534 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3535 | 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."; |
| 3536 | if (!strstr(msgString.c_str(),"Copy descriptor src update is out of bounds for matching binding 1 ")) { |
| 3537 | FAIL() << "Error received was not 'Copy descriptor src update is out of bounds for matching binding 1...' but instead '" << msgString.c_str() << "'"; |
| 3538 | } |
| 3539 | |
| 3540 | vkDestroySampler(m_device->device(), sampler); |
| 3541 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 3542 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
| 3543 | } |
| 3544 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3545 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 3546 | { |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3547 | // Create CmdBuffer where MSAA samples doesn't match RenderPass sampleCount |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3548 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3549 | std::string msgString; |
| 3550 | VkResult err; |
| 3551 | |
| 3552 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3553 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3554 | m_errorMonitor->ClearState(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3555 | VkDescriptorTypeCount ds_type_count = {}; |
| 3556 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3557 | ds_type_count.count = 1; |
| 3558 | |
| 3559 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3560 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3561 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3562 | ds_pool_ci.maxSets = 1; |
| 3563 | ds_pool_ci.count = 1; |
| 3564 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 3565 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3566 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3567 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3568 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3569 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3570 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3571 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3572 | dsl_binding.arraySize = 1; |
| 3573 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3574 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3575 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3576 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3577 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3578 | ds_layout_ci.pNext = NULL; |
| 3579 | ds_layout_ci.count = 1; |
| 3580 | ds_layout_ci.pBinding = &dsl_binding; |
| 3581 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3582 | VkDescriptorSetLayout ds_layout; |
| 3583 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 3584 | ASSERT_VK_SUCCESS(err); |
| 3585 | |
| 3586 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3587 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3588 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 3589 | alloc_info.count = 1; |
| 3590 | alloc_info.descriptorPool = ds_pool; |
| 3591 | alloc_info.pSetLayouts = &ds_layout; |
| 3592 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3593 | ASSERT_VK_SUCCESS(err); |
| 3594 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3595 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3596 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3597 | pipe_ms_state_ci.pNext = NULL; |
| 3598 | pipe_ms_state_ci.rasterSamples = 4; |
| 3599 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3600 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3601 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3602 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3603 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3604 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3605 | pipeline_layout_ci.pNext = NULL; |
| 3606 | pipeline_layout_ci.descriptorSetCount = 1; |
| 3607 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3608 | |
| 3609 | VkPipelineLayout pipeline_layout; |
| 3610 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 3611 | ASSERT_VK_SUCCESS(err); |
| 3612 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3613 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3614 | 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] | 3615 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3616 | VkPipelineObj pipe(m_device); |
| 3617 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3618 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3619 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3620 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3621 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3622 | BeginCommandBuffer(); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3623 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3624 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3625 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3626 | 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] | 3627 | if (!strstr(msgString.c_str(),"Num samples mismatch! ")) { |
| 3628 | FAIL() << "Error received was not 'Num samples mismatch!...'"; |
| 3629 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3630 | |
| 3631 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3632 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 3633 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3634 | } |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3635 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3636 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 3637 | { |
| 3638 | // Create CmdBuffer where we add ClearCmd for FB Color attachment prior to issuing a Draw |
| 3639 | VkFlags msgFlags; |
| 3640 | std::string msgString; |
| 3641 | VkResult err; |
| 3642 | |
| 3643 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3644 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3645 | m_errorMonitor->ClearState(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3646 | |
| 3647 | VkDescriptorTypeCount ds_type_count = {}; |
| 3648 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3649 | ds_type_count.count = 1; |
| 3650 | |
| 3651 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3652 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3653 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3654 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3655 | ds_pool_ci.count = 1; |
| 3656 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 3657 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3658 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3659 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3660 | ASSERT_VK_SUCCESS(err); |
| 3661 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3662 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3663 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3664 | dsl_binding.arraySize = 1; |
| 3665 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3666 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3667 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3668 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3669 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3670 | ds_layout_ci.pNext = NULL; |
| 3671 | ds_layout_ci.count = 1; |
| 3672 | ds_layout_ci.pBinding = &dsl_binding; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3673 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3674 | VkDescriptorSetLayout ds_layout; |
| 3675 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 3676 | ASSERT_VK_SUCCESS(err); |
| 3677 | |
| 3678 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3679 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3680 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 3681 | alloc_info.count = 1; |
| 3682 | alloc_info.descriptorPool = ds_pool; |
| 3683 | alloc_info.pSetLayouts = &ds_layout; |
| 3684 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3685 | ASSERT_VK_SUCCESS(err); |
| 3686 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3687 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3688 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3689 | pipe_ms_state_ci.pNext = NULL; |
| 3690 | pipe_ms_state_ci.rasterSamples = 4; |
| 3691 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3692 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3693 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3694 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3695 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3696 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3697 | pipeline_layout_ci.pNext = NULL; |
| 3698 | pipeline_layout_ci.descriptorSetCount = 1; |
| 3699 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3700 | |
| 3701 | VkPipelineLayout pipeline_layout; |
| 3702 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 3703 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3704 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3705 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3706 | 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] | 3707 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3708 | VkPipelineObj pipe(m_device); |
| 3709 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3710 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3711 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3712 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3713 | |
| 3714 | BeginCommandBuffer(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3715 | |
| 3716 | m_errorMonitor->ClearState(); |
| 3717 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 3718 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3719 | VkClearAttachment color_attachment; |
| 3720 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3721 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 3722 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 3723 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 3724 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 3725 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3726 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3727 | |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3728 | vkCmdClearAttachments(m_cmdBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3729 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3730 | 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] | 3731 | if (!strstr(msgString.c_str(),"vkCmdClearAttachments() issued on CB object ")) { |
| 3732 | FAIL() << "Error received was not 'vkCmdClearAttachments() issued on CB object...'"; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3733 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3734 | |
| 3735 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3736 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 3737 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3738 | } |
| 3739 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3740 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 3741 | { |
| 3742 | // Create CmdBuffer where MSAA samples doesn't match RenderPass sampleCount |
| 3743 | VkFlags msgFlags; |
| 3744 | std::string msgString; |
| 3745 | VkResult err; |
| 3746 | |
| 3747 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3748 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3749 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3750 | m_errorMonitor->ClearState(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3751 | |
| 3752 | VkDescriptorTypeCount ds_type_count = {}; |
| 3753 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3754 | ds_type_count.count = 1; |
| 3755 | |
| 3756 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3757 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3758 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3759 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3760 | ds_pool_ci.count = 1; |
| 3761 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 3762 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3763 | VkDescriptorPool ds_pool; |
| 3764 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3765 | ASSERT_VK_SUCCESS(err); |
| 3766 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3767 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3768 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3769 | dsl_binding.arraySize = 1; |
| 3770 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3771 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3772 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3773 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3774 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3775 | ds_layout_ci.pNext = NULL; |
| 3776 | ds_layout_ci.count = 1; |
| 3777 | ds_layout_ci.pBinding = &dsl_binding; |
| 3778 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3779 | VkDescriptorSetLayout ds_layout; |
| 3780 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 3781 | ASSERT_VK_SUCCESS(err); |
| 3782 | |
| 3783 | VkDescriptorSet descriptorSet; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3784 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 3785 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 3786 | alloc_info.count = 1; |
| 3787 | alloc_info.descriptorPool = ds_pool; |
| 3788 | alloc_info.pSetLayouts = &ds_layout; |
| 3789 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3790 | ASSERT_VK_SUCCESS(err); |
| 3791 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3792 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3793 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3794 | pipe_ms_state_ci.pNext = NULL; |
| 3795 | pipe_ms_state_ci.rasterSamples = 1; |
| 3796 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3797 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3798 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3799 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3800 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3801 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3802 | pipeline_layout_ci.pNext = NULL; |
| 3803 | pipeline_layout_ci.descriptorSetCount = 1; |
| 3804 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3805 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3806 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3807 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 3808 | ASSERT_VK_SUCCESS(err); |
| 3809 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3810 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3811 | 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] | 3812 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3813 | VkPipelineObj pipe(m_device); |
| 3814 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3815 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3816 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3817 | pipe.SetViewport(m_viewports); |
| 3818 | pipe.SetScissor(m_scissors); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3819 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3820 | |
| 3821 | BeginCommandBuffer(); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3822 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | d28acef | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 3823 | // Don't care about actual data, just need to get to draw to flag error |
| 3824 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 3825 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 3826 | 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] | 3827 | Draw(1, 0, 0, 0); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3828 | |
| 3829 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3830 | 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] | 3831 | 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] | 3832 | 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] | 3833 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3834 | |
| 3835 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3836 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 3837 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3838 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3839 | #endif // DRAW_STATE_TESTS |
| 3840 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3841 | #if THREADING_TESTS |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3842 | #if GTEST_IS_THREADSAFE |
| 3843 | struct thread_data_struct { |
| 3844 | VkCmdBuffer cmdBuffer; |
| 3845 | VkEvent event; |
| 3846 | bool bailout; |
| 3847 | }; |
| 3848 | |
| 3849 | extern "C" void *AddToCommandBuffer(void *arg) |
| 3850 | { |
| 3851 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
| 3852 | std::string msgString; |
| 3853 | |
| 3854 | for (int i = 0; i<10000; i++) { |
Tony Barbour | c2e987e | 2015-06-29 16:20:35 -0600 | [diff] [blame] | 3855 | vkCmdSetEvent(data->cmdBuffer, data->event, VK_PIPELINE_STAGE_ALL_GPU_COMMANDS); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3856 | if (data->bailout) { |
| 3857 | break; |
| 3858 | } |
| 3859 | } |
| 3860 | return NULL; |
| 3861 | } |
| 3862 | |
| 3863 | TEST_F(VkLayerTest, ThreadCmdBufferCollision) |
| 3864 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3865 | VkFlags msgFlags; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3866 | std::string msgString; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3867 | test_platform_thread thread; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3868 | |
| 3869 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3870 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3871 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3872 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3873 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3874 | |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3875 | // Calls AllocCommandBuffers |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3876 | VkCommandBufferObj cmdBuffer(m_device, m_cmdPool); |
| 3877 | |
| 3878 | // Avoid creating RenderPass |
| 3879 | cmdBuffer.BeginCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3880 | |
| 3881 | VkEventCreateInfo event_info; |
| 3882 | VkEvent event; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3883 | VkResult err; |
| 3884 | |
| 3885 | memset(&event_info, 0, sizeof(event_info)); |
| 3886 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3887 | |
| 3888 | err = vkCreateEvent(device(), &event_info, &event); |
| 3889 | ASSERT_VK_SUCCESS(err); |
| 3890 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3891 | err = vkResetEvent(device(), event); |
| 3892 | ASSERT_VK_SUCCESS(err); |
| 3893 | |
| 3894 | struct thread_data_struct data; |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3895 | data.cmdBuffer = cmdBuffer.GetBufferHandle(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3896 | data.event = event; |
| 3897 | data.bailout = false; |
| 3898 | m_errorMonitor->SetBailout(&data.bailout); |
| 3899 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3900 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3901 | // Add many entries to command buffer from this thread at the same time. |
| 3902 | AddToCommandBuffer(&data); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3903 | |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3904 | test_platform_thread_join(thread, NULL); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3905 | cmdBuffer.EndCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3906 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3907 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3908 | 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] | 3909 | if (!strstr(msgString.c_str(),"THREADING ERROR")) { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 3910 | FAIL() << "Error received was not 'THREADING ERROR'"; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3911 | } |
| 3912 | |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3913 | vkDestroyEvent(device(), event); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3914 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3915 | #endif // GTEST_IS_THREADSAFE |
| 3916 | #endif // THREADING_TESTS |
| 3917 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3918 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3919 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 3920 | { |
| 3921 | VkFlags msgFlags; |
| 3922 | std::string msgString; |
| 3923 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3924 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3925 | |
| 3926 | m_errorMonitor->ClearState(); |
| 3927 | |
| 3928 | VkShaderModule module; |
| 3929 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3930 | struct icd_spv_header spv; |
| 3931 | |
| 3932 | spv.magic = ICD_SPV_MAGIC; |
| 3933 | spv.version = ICD_SPV_VERSION; |
| 3934 | spv.gen_magic = 0; |
| 3935 | |
| 3936 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3937 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3938 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3939 | moduleCreateInfo.codeSize = 4; |
| 3940 | moduleCreateInfo.flags = 0; |
| 3941 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, &module); |
| 3942 | |
| 3943 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3944 | |
Chris Forbes | 96b8176 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 3945 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3946 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 3947 | FAIL() << "Incorrect warning: " << msgString; |
| 3948 | } |
| 3949 | } |
| 3950 | |
| 3951 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 3952 | { |
| 3953 | VkFlags msgFlags; |
| 3954 | std::string msgString; |
| 3955 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3956 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3957 | |
| 3958 | m_errorMonitor->ClearState(); |
| 3959 | |
| 3960 | VkShaderModule module; |
| 3961 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3962 | struct icd_spv_header spv; |
| 3963 | |
| 3964 | spv.magic = ~ICD_SPV_MAGIC; |
| 3965 | spv.version = ICD_SPV_VERSION; |
| 3966 | spv.gen_magic = 0; |
| 3967 | |
| 3968 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3969 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3970 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3971 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 3972 | moduleCreateInfo.flags = 0; |
| 3973 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, &module); |
| 3974 | |
| 3975 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3976 | |
Chris Forbes | 96b8176 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 3977 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3978 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 3979 | FAIL() << "Incorrect warning: " << msgString; |
| 3980 | } |
| 3981 | } |
| 3982 | |
| 3983 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 3984 | { |
| 3985 | VkFlags msgFlags; |
| 3986 | std::string msgString; |
| 3987 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3988 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3989 | |
| 3990 | m_errorMonitor->ClearState(); |
| 3991 | |
| 3992 | VkShaderModule module; |
| 3993 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3994 | struct icd_spv_header spv; |
| 3995 | |
| 3996 | spv.magic = ICD_SPV_MAGIC; |
| 3997 | spv.version = ~ICD_SPV_VERSION; |
| 3998 | spv.gen_magic = 0; |
| 3999 | |
| 4000 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4001 | moduleCreateInfo.pNext = NULL; |
| 4002 | |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4003 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4004 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4005 | moduleCreateInfo.flags = 0; |
| 4006 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, &module); |
| 4007 | |
| 4008 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4009 | |
Chris Forbes | 96b8176 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 4010 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4011 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 4012 | FAIL() << "Incorrect warning: " << msgString; |
| 4013 | } |
| 4014 | } |
| 4015 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4016 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 4017 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4018 | VkFlags msgFlags; |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4019 | std::string msgString; |
| 4020 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4021 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4022 | |
| 4023 | char const *vsSource = |
| 4024 | "#version 140\n" |
| 4025 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4026 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4027 | "\n" |
| 4028 | "layout(location=0) out float x;\n" |
| 4029 | "void main(){\n" |
| 4030 | " gl_Position = vec4(1);\n" |
| 4031 | " x = 0;\n" |
| 4032 | "}\n"; |
| 4033 | char const *fsSource = |
| 4034 | "#version 140\n" |
| 4035 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4036 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4037 | "\n" |
| 4038 | "layout(location=0) out vec4 color;\n" |
| 4039 | "void main(){\n" |
| 4040 | " color = vec4(1);\n" |
| 4041 | "}\n"; |
| 4042 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4043 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4044 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4045 | |
| 4046 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4047 | pipe.AddColorAttachment(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4048 | pipe.AddShader(&vs); |
| 4049 | pipe.AddShader(&fs); |
| 4050 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4051 | VkDescriptorSetObj descriptorSet(m_device); |
| 4052 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4053 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4054 | |
| 4055 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4056 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4057 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4058 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4059 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4060 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4061 | if (!strstr(msgString.c_str(),"not consumed by fragment shader")) { |
| 4062 | FAIL() << "Incorrect warning: " << msgString; |
| 4063 | } |
| 4064 | } |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4065 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4066 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4067 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4068 | VkFlags msgFlags; |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4069 | std::string msgString; |
| 4070 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4071 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4072 | |
| 4073 | char const *vsSource = |
| 4074 | "#version 140\n" |
| 4075 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4076 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4077 | "\n" |
| 4078 | "void main(){\n" |
| 4079 | " gl_Position = vec4(1);\n" |
| 4080 | "}\n"; |
| 4081 | char const *fsSource = |
| 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 | "layout(location=0) in float x;\n" |
| 4087 | "layout(location=0) out vec4 color;\n" |
| 4088 | "void main(){\n" |
| 4089 | " color = vec4(x);\n" |
| 4090 | "}\n"; |
| 4091 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4092 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4093 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4094 | |
| 4095 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4096 | pipe.AddColorAttachment(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4097 | pipe.AddShader(&vs); |
| 4098 | pipe.AddShader(&fs); |
| 4099 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4100 | VkDescriptorSetObj descriptorSet(m_device); |
| 4101 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4102 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4103 | |
| 4104 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4105 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4106 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4107 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4108 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4109 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4110 | if (!strstr(msgString.c_str(),"not written by vertex shader")) { |
| 4111 | FAIL() << "Incorrect error: " << msgString; |
| 4112 | } |
| 4113 | } |
| 4114 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4115 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4116 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4117 | VkFlags msgFlags; |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4118 | std::string msgString; |
| 4119 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4120 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4121 | |
| 4122 | char const *vsSource = |
| 4123 | "#version 140\n" |
| 4124 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4125 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4126 | "\n" |
| 4127 | "layout(location=0) out int x;\n" |
| 4128 | "void main(){\n" |
| 4129 | " x = 0;\n" |
| 4130 | " gl_Position = vec4(1);\n" |
| 4131 | "}\n"; |
| 4132 | char const *fsSource = |
| 4133 | "#version 140\n" |
| 4134 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4135 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4136 | "\n" |
| 4137 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4138 | "layout(location=0) out vec4 color;\n" |
| 4139 | "void main(){\n" |
| 4140 | " color = vec4(x);\n" |
| 4141 | "}\n"; |
| 4142 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4143 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4144 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4145 | |
| 4146 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4147 | pipe.AddColorAttachment(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4148 | pipe.AddShader(&vs); |
| 4149 | pipe.AddShader(&fs); |
| 4150 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4151 | VkDescriptorSetObj descriptorSet(m_device); |
| 4152 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4153 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4154 | |
| 4155 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4156 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4157 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4158 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4159 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4160 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4161 | if (!strstr(msgString.c_str(),"Type mismatch on location 0")) { |
| 4162 | FAIL() << "Incorrect error: " << msgString; |
| 4163 | } |
| 4164 | } |
| 4165 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4166 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4167 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4168 | VkFlags msgFlags; |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4169 | std::string msgString; |
| 4170 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4171 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4172 | |
| 4173 | VkVertexInputBindingDescription input_binding; |
| 4174 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4175 | |
| 4176 | VkVertexInputAttributeDescription input_attrib; |
| 4177 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4178 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4179 | |
| 4180 | char const *vsSource = |
| 4181 | "#version 140\n" |
| 4182 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4183 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4184 | "\n" |
| 4185 | "void main(){\n" |
| 4186 | " gl_Position = vec4(1);\n" |
| 4187 | "}\n"; |
| 4188 | char const *fsSource = |
| 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 | "layout(location=0) out vec4 color;\n" |
| 4194 | "void main(){\n" |
| 4195 | " color = vec4(1);\n" |
| 4196 | "}\n"; |
| 4197 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4198 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4199 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4200 | |
| 4201 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4202 | pipe.AddColorAttachment(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4203 | pipe.AddShader(&vs); |
| 4204 | pipe.AddShader(&fs); |
| 4205 | |
| 4206 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4207 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4208 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4209 | VkDescriptorSetObj descriptorSet(m_device); |
| 4210 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4211 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4212 | |
| 4213 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4214 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4215 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4216 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4217 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4218 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4219 | if (!strstr(msgString.c_str(),"location 0 not consumed by VS")) { |
| 4220 | FAIL() << "Incorrect warning: " << msgString; |
| 4221 | } |
| 4222 | } |
| 4223 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4224 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4225 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4226 | VkFlags msgFlags; |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4227 | std::string msgString; |
| 4228 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4229 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4230 | |
| 4231 | char const *vsSource = |
| 4232 | "#version 140\n" |
| 4233 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4234 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4235 | "\n" |
| 4236 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4237 | "void main(){\n" |
| 4238 | " gl_Position = x;\n" |
| 4239 | "}\n"; |
| 4240 | char const *fsSource = |
| 4241 | "#version 140\n" |
| 4242 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4243 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4244 | "\n" |
| 4245 | "layout(location=0) out vec4 color;\n" |
| 4246 | "void main(){\n" |
| 4247 | " color = vec4(1);\n" |
| 4248 | "}\n"; |
| 4249 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4250 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4251 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4252 | |
| 4253 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4254 | pipe.AddColorAttachment(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4255 | pipe.AddShader(&vs); |
| 4256 | pipe.AddShader(&fs); |
| 4257 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4258 | VkDescriptorSetObj descriptorSet(m_device); |
| 4259 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4260 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4261 | |
| 4262 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4263 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4264 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4265 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4266 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4267 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4268 | if (!strstr(msgString.c_str(),"VS consumes input at location 0 but not provided")) { |
| 4269 | FAIL() << "Incorrect warning: " << msgString; |
| 4270 | } |
| 4271 | } |
| 4272 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4273 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4274 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4275 | VkFlags msgFlags; |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4276 | std::string msgString; |
| 4277 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4278 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4279 | |
| 4280 | VkVertexInputBindingDescription input_binding; |
| 4281 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4282 | |
| 4283 | VkVertexInputAttributeDescription input_attrib; |
| 4284 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4285 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4286 | |
| 4287 | char const *vsSource = |
| 4288 | "#version 140\n" |
| 4289 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4290 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4291 | "\n" |
| 4292 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4293 | "void main(){\n" |
| 4294 | " gl_Position = vec4(x);\n" |
| 4295 | "}\n"; |
| 4296 | char const *fsSource = |
| 4297 | "#version 140\n" |
| 4298 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4299 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4300 | "\n" |
| 4301 | "layout(location=0) out vec4 color;\n" |
| 4302 | "void main(){\n" |
| 4303 | " color = vec4(1);\n" |
| 4304 | "}\n"; |
| 4305 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4306 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4307 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4308 | |
| 4309 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4310 | pipe.AddColorAttachment(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4311 | pipe.AddShader(&vs); |
| 4312 | pipe.AddShader(&fs); |
| 4313 | |
| 4314 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4315 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4316 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4317 | VkDescriptorSetObj descriptorSet(m_device); |
| 4318 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4319 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4320 | |
| 4321 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4322 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4323 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4324 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4325 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4326 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4327 | if (!strstr(msgString.c_str(),"location 0 does not match VS input type")) { |
| 4328 | FAIL() << "Incorrect error: " << msgString; |
| 4329 | } |
| 4330 | } |
| 4331 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4332 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4333 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4334 | VkFlags msgFlags; |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4335 | std::string msgString; |
| 4336 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4337 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4338 | |
| 4339 | /* Two binding descriptions for binding 0 */ |
| 4340 | VkVertexInputBindingDescription input_bindings[2]; |
| 4341 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4342 | |
| 4343 | VkVertexInputAttributeDescription input_attrib; |
| 4344 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4345 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4346 | |
| 4347 | char const *vsSource = |
| 4348 | "#version 140\n" |
| 4349 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4350 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4351 | "\n" |
| 4352 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 4353 | "void main(){\n" |
| 4354 | " gl_Position = vec4(x);\n" |
| 4355 | "}\n"; |
| 4356 | char const *fsSource = |
| 4357 | "#version 140\n" |
| 4358 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4359 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4360 | "\n" |
| 4361 | "layout(location=0) out vec4 color;\n" |
| 4362 | "void main(){\n" |
| 4363 | " color = vec4(1);\n" |
| 4364 | "}\n"; |
| 4365 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4366 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4367 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4368 | |
| 4369 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4370 | pipe.AddColorAttachment(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4371 | pipe.AddShader(&vs); |
| 4372 | pipe.AddShader(&fs); |
| 4373 | |
| 4374 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 4375 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4376 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4377 | VkDescriptorSetObj descriptorSet(m_device); |
| 4378 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4379 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4380 | |
| 4381 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4382 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4383 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4384 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4385 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4386 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4387 | if (!strstr(msgString.c_str(),"Duplicate vertex input binding descriptions for binding 0")) { |
| 4388 | FAIL() << "Incorrect error: " << msgString; |
| 4389 | } |
| 4390 | } |
Chris Forbes | 4c94870 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 4391 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4392 | /* TODO: would be nice to test the mixed broadcast & custom case, but the GLSL->SPV compiler |
| 4393 | * rejects it. */ |
| 4394 | |
| 4395 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 4396 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4397 | VkFlags msgFlags; |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4398 | std::string msgString; |
| 4399 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4400 | |
| 4401 | char const *vsSource = |
| 4402 | "#version 140\n" |
| 4403 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4404 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4405 | "\n" |
| 4406 | "void main(){\n" |
| 4407 | " gl_Position = vec4(1);\n" |
| 4408 | "}\n"; |
| 4409 | char const *fsSource = |
| 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 | "}\n"; |
| 4416 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4417 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4418 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4419 | |
| 4420 | VkPipelineObj pipe(m_device); |
| 4421 | pipe.AddShader(&vs); |
| 4422 | pipe.AddShader(&fs); |
| 4423 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4424 | /* set up CB 0, not written */ |
| 4425 | pipe.AddColorAttachment(); |
| 4426 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4427 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4428 | VkDescriptorSetObj descriptorSet(m_device); |
| 4429 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4430 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4431 | |
| 4432 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4433 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4434 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4435 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4436 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4437 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4438 | if (!strstr(msgString.c_str(),"Attachment 0 not written by FS")) { |
| 4439 | FAIL() << "Incorrect error: " << msgString; |
| 4440 | } |
| 4441 | } |
| 4442 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4443 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 4444 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4445 | VkFlags msgFlags; |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4446 | std::string msgString; |
| 4447 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4448 | |
| 4449 | char const *vsSource = |
| 4450 | "#version 140\n" |
| 4451 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4452 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4453 | "\n" |
| 4454 | "void main(){\n" |
| 4455 | " gl_Position = vec4(1);\n" |
| 4456 | "}\n"; |
| 4457 | char const *fsSource = |
| 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 | "layout(location=0) out vec4 x;\n" |
| 4463 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 4464 | "void main(){\n" |
| 4465 | " x = vec4(1);\n" |
| 4466 | " y = vec4(1);\n" |
| 4467 | "}\n"; |
| 4468 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4469 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4470 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4471 | |
| 4472 | VkPipelineObj pipe(m_device); |
| 4473 | pipe.AddShader(&vs); |
| 4474 | pipe.AddShader(&fs); |
| 4475 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4476 | /* set up CB 0, not written */ |
| 4477 | pipe.AddColorAttachment(); |
| 4478 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4479 | /* FS writes CB 1, but we don't configure it */ |
| 4480 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4481 | VkDescriptorSetObj descriptorSet(m_device); |
| 4482 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4483 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4484 | |
| 4485 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4486 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4487 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4488 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4489 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4490 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4491 | if (!strstr(msgString.c_str(),"FS writes to output location 1 with no matching attachment")) { |
| 4492 | FAIL() << "Incorrect warning: " << msgString; |
| 4493 | } |
| 4494 | } |
| 4495 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4496 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 4497 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4498 | VkFlags msgFlags; |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4499 | std::string msgString; |
| 4500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4501 | |
| 4502 | char const *vsSource = |
| 4503 | "#version 140\n" |
| 4504 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4505 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4506 | "\n" |
| 4507 | "void main(){\n" |
| 4508 | " gl_Position = vec4(1);\n" |
| 4509 | "}\n"; |
| 4510 | char const *fsSource = |
| 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 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 4516 | "void main(){\n" |
| 4517 | " x = ivec4(1);\n" |
| 4518 | "}\n"; |
| 4519 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4520 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4521 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4522 | |
| 4523 | VkPipelineObj pipe(m_device); |
| 4524 | pipe.AddShader(&vs); |
| 4525 | pipe.AddShader(&fs); |
| 4526 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4527 | /* set up CB 0; type is UNORM by default */ |
| 4528 | pipe.AddColorAttachment(); |
| 4529 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4530 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4531 | VkDescriptorSetObj descriptorSet(m_device); |
| 4532 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4533 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4534 | |
| 4535 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4536 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4537 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4538 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4539 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4540 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4541 | if (!strstr(msgString.c_str(),"does not match FS output type")) { |
| 4542 | FAIL() << "Incorrect error: " << msgString; |
| 4543 | } |
| 4544 | } |
Chris Forbes | c205073 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 4545 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4546 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 4547 | { |
| 4548 | VkFlags msgFlags; |
| 4549 | std::string msgString; |
| 4550 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4551 | |
| 4552 | char const *vsSource = |
| 4553 | "#version 140\n" |
| 4554 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4555 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4556 | "\n" |
| 4557 | "void main(){\n" |
| 4558 | " gl_Position = vec4(1);\n" |
| 4559 | "}\n"; |
| 4560 | char const *fsSource = |
| 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 | "layout(location=0) out vec4 x;\n" |
| 4566 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4567 | "void main(){\n" |
| 4568 | " x = vec4(bar.y);\n" |
| 4569 | "}\n"; |
| 4570 | |
| 4571 | m_errorMonitor->ClearState(); |
| 4572 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4573 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4574 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4575 | |
| 4576 | |
| 4577 | VkPipelineObj pipe(m_device); |
| 4578 | pipe.AddShader(&vs); |
| 4579 | pipe.AddShader(&fs); |
| 4580 | |
| 4581 | /* set up CB 0; type is UNORM by default */ |
| 4582 | pipe.AddColorAttachment(); |
| 4583 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4584 | |
| 4585 | VkDescriptorSetObj descriptorSet(m_device); |
| 4586 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
| 4587 | |
| 4588 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4589 | |
| 4590 | /* should have generated an error -- pipeline layout does not |
| 4591 | * provide a uniform buffer in 0.0 |
| 4592 | */ |
| 4593 | msgFlags = m_errorMonitor->GetState(&msgString); |
Courtney Goeltzenleuchter | 0abdb66 | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 4594 | 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] | 4595 | if (!strstr(msgString.c_str(),"not declared in pipeline layout")) { |
| 4596 | FAIL() << "Incorrect error: " << msgString; |
| 4597 | } |
| 4598 | } |
| 4599 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4600 | #endif // SHADER_CHECKER_TESTS |
| 4601 | |
| 4602 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4603 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 4604 | { |
| 4605 | VkFlags msgFlags; |
| 4606 | std::string msgString; |
| 4607 | |
| 4608 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4609 | m_errorMonitor->ClearState(); |
| 4610 | |
| 4611 | // Create an image |
| 4612 | VkImage image; |
| 4613 | |
| 4614 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4615 | const int32_t tex_width = 32; |
| 4616 | const int32_t tex_height = 32; |
| 4617 | |
| 4618 | VkImageCreateInfo image_create_info = {}; |
| 4619 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4620 | image_create_info.pNext = NULL; |
| 4621 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4622 | image_create_info.format = tex_format; |
| 4623 | image_create_info.extent.width = tex_width; |
| 4624 | image_create_info.extent.height = tex_height; |
| 4625 | image_create_info.extent.depth = 1; |
| 4626 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4627 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4628 | image_create_info.samples = 1; |
| 4629 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4630 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4631 | image_create_info.flags = 0; |
| 4632 | |
| 4633 | // Introduce error by sending down a bogus width extent |
| 4634 | image_create_info.extent.width = 65536; |
| 4635 | vkCreateImage(m_device->device(), &image_create_info, &image); |
| 4636 | |
| 4637 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4638 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an image" << |
| 4639 | "with extents outside the queried limits"; |
| 4640 | if (!strstr(msgString.c_str(),"CreateImage extents exceed allowable limits for format")) { |
| 4641 | FAIL() << "Error received did not match expected error message from vkCreateImage in DeviceLimits layer"; |
| 4642 | } |
| 4643 | } |
| 4644 | |
| 4645 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 4646 | { |
| 4647 | VkFlags msgFlags; |
| 4648 | std::string msgString; |
| 4649 | |
| 4650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4651 | m_errorMonitor->ClearState(); |
| 4652 | |
| 4653 | // Create an image |
| 4654 | VkImage image; |
| 4655 | |
| 4656 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4657 | const int32_t tex_width = 32; |
| 4658 | const int32_t tex_height = 32; |
| 4659 | |
| 4660 | VkImageCreateInfo image_create_info = {}; |
| 4661 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4662 | image_create_info.pNext = NULL; |
| 4663 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4664 | image_create_info.format = tex_format; |
| 4665 | image_create_info.extent.width = tex_width; |
| 4666 | image_create_info.extent.height = tex_height; |
| 4667 | image_create_info.extent.depth = 1; |
| 4668 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4669 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4670 | image_create_info.samples = 1; |
| 4671 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4672 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4673 | image_create_info.flags = 0; |
| 4674 | |
| 4675 | // Introduce error by sending down individually allowable values that result in a surface size |
| 4676 | // exceeding the device maximum |
| 4677 | image_create_info.extent.width = 8192; |
| 4678 | image_create_info.extent.height = 8192; |
| 4679 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4680 | image_create_info.arrayLayers = 4; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4681 | image_create_info.samples = 2; |
| 4682 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4683 | vkCreateImage(m_device->device(), &image_create_info, &image); |
| 4684 | |
| 4685 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4686 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an image" << |
| 4687 | "with resource size exceeding queried limit"; |
| 4688 | if (!strstr(msgString.c_str(),"CreateImage resource size exceeds allowable maximum")) { |
| 4689 | FAIL() << "Error received did not match expected error message from vkCreateImage in DeviceLimits layer"; |
| 4690 | } |
| 4691 | } |
| 4692 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4693 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 4694 | { |
| 4695 | VkFlags msgFlags; |
| 4696 | std::string msgString; |
| 4697 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 4698 | |
| 4699 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4700 | |
| 4701 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4702 | vk_testing::Buffer buffer; |
| 4703 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4704 | |
| 4705 | BeginCommandBuffer(); |
| 4706 | // Introduce failure by using offset that is not multiple of 4 |
| 4707 | m_cmdBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
| 4708 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4709 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling UpdateBuffer with bad offset"; |
| 4710 | if (!strstr(msgString.c_str(),"destOffset, is not a multiple of 4")) { |
| 4711 | FAIL() << "Error received was not 'vkCmdUpdateBuffer parameter, VkDeviceSize destOffset, is not a multiple of 4'"; |
| 4712 | } |
| 4713 | // Introduce failure by using size that is not multiple of 4 |
| 4714 | m_cmdBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
| 4715 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4716 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling UpdateBuffer with bad size"; |
| 4717 | if (!strstr(msgString.c_str(),"dataSize, is not a multiple of 4")) { |
| 4718 | FAIL() << "Error received was not 'vkCmdUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 4719 | } |
| 4720 | EndCommandBuffer(); |
| 4721 | } |
| 4722 | |
| 4723 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 4724 | { |
| 4725 | VkFlags msgFlags; |
| 4726 | std::string msgString; |
| 4727 | |
| 4728 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4729 | |
| 4730 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4731 | vk_testing::Buffer buffer; |
| 4732 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4733 | |
| 4734 | BeginCommandBuffer(); |
| 4735 | // Introduce failure by using offset that is not multiple of 4 |
| 4736 | m_cmdBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
| 4737 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4738 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling FillBuffer with bad offset"; |
| 4739 | if (!strstr(msgString.c_str(),"destOffset, is not a multiple of 4")) { |
| 4740 | FAIL() << "Error received was not 'vkCmdFillBuffer parameter, VkDeviceSize destOffset, is not a multiple of 4'"; |
| 4741 | } |
| 4742 | // Introduce failure by using size that is not multiple of 4 |
| 4743 | m_cmdBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
| 4744 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4745 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling FillBuffer with bad size"; |
| 4746 | if (!strstr(msgString.c_str(),"fillSize, is not a multiple of 4")) { |
| 4747 | FAIL() << "Error received was not 'vkCmdFillBuffer parameter, VkDeviceSize fillSize, is not a multiple of 4'"; |
| 4748 | } |
| 4749 | EndCommandBuffer(); |
| 4750 | } |
| 4751 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4752 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4753 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4754 | #if IMAGE_TESTS |
| 4755 | TEST_F(VkLayerTest, InvalidImageView) |
| 4756 | { |
| 4757 | VkFlags msgFlags; |
| 4758 | std::string msgString; |
| 4759 | VkResult err; |
| 4760 | |
| 4761 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4762 | m_errorMonitor->ClearState(); |
| 4763 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4764 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4765 | VkImage image; |
| 4766 | |
| 4767 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4768 | const int32_t tex_width = 32; |
| 4769 | const int32_t tex_height = 32; |
| 4770 | |
| 4771 | VkImageCreateInfo image_create_info = {}; |
| 4772 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4773 | image_create_info.pNext = NULL; |
| 4774 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4775 | image_create_info.format = tex_format; |
| 4776 | image_create_info.extent.width = tex_width; |
| 4777 | image_create_info.extent.height = tex_height; |
| 4778 | image_create_info.extent.depth = 1; |
| 4779 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4780 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4781 | image_create_info.samples = 1; |
| 4782 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4783 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4784 | image_create_info.flags = 0; |
| 4785 | |
| 4786 | err = vkCreateImage(m_device->device(), &image_create_info, &image); |
| 4787 | ASSERT_VK_SUCCESS(err); |
| 4788 | |
| 4789 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4790 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4791 | image_view_create_info.image = image; |
| 4792 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4793 | image_view_create_info.format = tex_format; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4794 | image_view_create_info.subresourceRange.numLayers = 1; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4795 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4796 | image_view_create_info.subresourceRange.numLevels = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4797 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4798 | |
| 4799 | VkImageView view; |
| 4800 | err = vkCreateImageView(m_device->device(), &image_view_create_info, &view); |
| 4801 | |
| 4802 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4803 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an invalid ImageView"; |
| 4804 | if (!strstr(msgString.c_str(),"vkCreateImageView called with baseMipLevel 10 ")) { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4805 | 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] | 4806 | } |
| 4807 | } |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4808 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4809 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 4810 | { |
| 4811 | VkFlags msgFlags; |
| 4812 | std::string msgString; |
| 4813 | VkResult err; |
| 4814 | |
| 4815 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4816 | m_errorMonitor->ClearState(); |
| 4817 | |
| 4818 | // Create an image and try to create a view with an invalid aspectMask |
| 4819 | VkImage image; |
| 4820 | |
| 4821 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4822 | const int32_t tex_width = 32; |
| 4823 | const int32_t tex_height = 32; |
| 4824 | |
| 4825 | VkImageCreateInfo image_create_info = {}; |
| 4826 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4827 | image_create_info.pNext = NULL; |
| 4828 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4829 | image_create_info.format = tex_format; |
| 4830 | image_create_info.extent.width = tex_width; |
| 4831 | image_create_info.extent.height = tex_height; |
| 4832 | image_create_info.extent.depth = 1; |
| 4833 | image_create_info.mipLevels = 1; |
| 4834 | image_create_info.samples = 1; |
| 4835 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4836 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4837 | image_create_info.flags = 0; |
| 4838 | |
| 4839 | err = vkCreateImage(m_device->device(), &image_create_info, &image); |
| 4840 | ASSERT_VK_SUCCESS(err); |
| 4841 | |
| 4842 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4843 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4844 | image_view_create_info.image = image; |
| 4845 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4846 | image_view_create_info.format = tex_format; |
| 4847 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 4848 | image_view_create_info.subresourceRange.numLevels = 1; |
| 4849 | // Cause an error by setting an invalid image aspect |
| 4850 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 4851 | |
| 4852 | VkImageView view; |
| 4853 | err = vkCreateImageView(m_device->device(), &image_view_create_info, &view); |
| 4854 | |
| 4855 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4856 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error when specifying an invalid ImageView aspect"; |
| 4857 | if (!strstr(msgString.c_str(),"vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set")) { |
| 4858 | FAIL() << "Error received was not 'VkCreateImageView: Color image formats must have ...' but instead '" << msgString.c_str() << "'"; |
| 4859 | } |
| 4860 | } |
| 4861 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4862 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 4863 | { |
| 4864 | VkFlags msgFlags; |
| 4865 | std::string msgString; |
| 4866 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4867 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4868 | |
| 4869 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4870 | m_errorMonitor->ClearState(); |
| 4871 | |
| 4872 | // Create two images of different types and try to copy between them |
| 4873 | VkImage srcImage; |
| 4874 | VkImage destImage; |
| 4875 | VkDeviceMemory srcMem; |
| 4876 | VkDeviceMemory destMem; |
| 4877 | VkMemoryRequirements memReqs; |
| 4878 | |
| 4879 | VkImageCreateInfo image_create_info = {}; |
| 4880 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4881 | image_create_info.pNext = NULL; |
| 4882 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4883 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4884 | image_create_info.extent.width = 32; |
| 4885 | image_create_info.extent.height = 32; |
| 4886 | image_create_info.extent.depth = 1; |
| 4887 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4888 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4889 | image_create_info.samples = 1; |
| 4890 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4891 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT; |
| 4892 | image_create_info.flags = 0; |
| 4893 | |
| 4894 | err = vkCreateImage(m_device->device(), &image_create_info, &srcImage); |
| 4895 | ASSERT_VK_SUCCESS(err); |
| 4896 | |
| 4897 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 4898 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT; |
| 4899 | |
| 4900 | err = vkCreateImage(m_device->device(), &image_create_info, &destImage); |
| 4901 | ASSERT_VK_SUCCESS(err); |
| 4902 | |
| 4903 | // Allocate memory |
| 4904 | VkMemoryAllocInfo memAlloc = {}; |
| 4905 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4906 | memAlloc.pNext = NULL; |
| 4907 | memAlloc.allocationSize = 0; |
| 4908 | memAlloc.memoryTypeIndex = 0; |
| 4909 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4910 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4911 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4912 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4913 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4914 | err = vkAllocMemory(m_device->device(), &memAlloc, &srcMem); |
| 4915 | ASSERT_VK_SUCCESS(err); |
| 4916 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4917 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4918 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4919 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4920 | ASSERT_VK_SUCCESS(err); |
| 4921 | err = vkAllocMemory(m_device->device(), &memAlloc, &destMem); |
| 4922 | ASSERT_VK_SUCCESS(err); |
| 4923 | |
| 4924 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4925 | ASSERT_VK_SUCCESS(err); |
| 4926 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 4927 | ASSERT_VK_SUCCESS(err); |
| 4928 | |
| 4929 | BeginCommandBuffer(); |
| 4930 | VkImageCopy copyRegion; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 4931 | copyRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4932 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4933 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 4934 | copyRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4935 | copyRegion.srcOffset.x = 0; |
| 4936 | copyRegion.srcOffset.y = 0; |
| 4937 | copyRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 4938 | copyRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4939 | copyRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4940 | copyRegion.destSubresource.baseArrayLayer = 0; |
| 4941 | copyRegion.destSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4942 | copyRegion.destOffset.x = 0; |
| 4943 | copyRegion.destOffset.y = 0; |
| 4944 | copyRegion.destOffset.z = 0; |
| 4945 | copyRegion.extent.width = 1; |
| 4946 | copyRegion.extent.height = 1; |
| 4947 | copyRegion.extent.depth = 1; |
| 4948 | m_cmdBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 4949 | EndCommandBuffer(); |
| 4950 | |
| 4951 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4952 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdCopyImage type mismatch"; |
| 4953 | if (!strstr(msgString.c_str(),"vkCmdCopyImage called with unmatched source and dest image types")) { |
| 4954 | FAIL() << "Error received was not 'vkCmdCopyImage called with unmatched source and dest image types' but instead '" << msgString.c_str() << "'"; |
| 4955 | } |
| 4956 | |
| 4957 | vkDestroyImage(m_device->device(), srcImage); |
| 4958 | vkDestroyImage(m_device->device(), destImage); |
| 4959 | vkFreeMemory(m_device->device(), srcMem); |
| 4960 | vkFreeMemory(m_device->device(), destMem); |
| 4961 | } |
| 4962 | |
| 4963 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 4964 | { |
| 4965 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 4966 | } |
| 4967 | |
| 4968 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 4969 | { |
| 4970 | VkFlags msgFlags; |
| 4971 | std::string msgString; |
| 4972 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4973 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4974 | |
| 4975 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4976 | m_errorMonitor->ClearState(); |
| 4977 | |
| 4978 | // Create two images of different types and try to copy between them |
| 4979 | VkImage srcImage; |
| 4980 | VkImage destImage; |
| 4981 | VkDeviceMemory srcMem; |
| 4982 | VkDeviceMemory destMem; |
| 4983 | VkMemoryRequirements memReqs; |
| 4984 | |
| 4985 | VkImageCreateInfo image_create_info = {}; |
| 4986 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4987 | image_create_info.pNext = NULL; |
| 4988 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4989 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4990 | image_create_info.extent.width = 32; |
| 4991 | image_create_info.extent.height = 32; |
| 4992 | image_create_info.extent.depth = 1; |
| 4993 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4994 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4995 | image_create_info.samples = 1; |
| 4996 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4997 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT; |
| 4998 | image_create_info.flags = 0; |
| 4999 | |
| 5000 | err = vkCreateImage(m_device->device(), &image_create_info, &srcImage); |
| 5001 | ASSERT_VK_SUCCESS(err); |
| 5002 | |
| 5003 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 5004 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT; |
| 5005 | |
| 5006 | err = vkCreateImage(m_device->device(), &image_create_info, &destImage); |
| 5007 | ASSERT_VK_SUCCESS(err); |
| 5008 | |
| 5009 | // Allocate memory |
| 5010 | VkMemoryAllocInfo memAlloc = {}; |
| 5011 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5012 | memAlloc.pNext = NULL; |
| 5013 | memAlloc.allocationSize = 0; |
| 5014 | memAlloc.memoryTypeIndex = 0; |
| 5015 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5016 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5017 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5018 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5019 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5020 | err = vkAllocMemory(m_device->device(), &memAlloc, &srcMem); |
| 5021 | ASSERT_VK_SUCCESS(err); |
| 5022 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5023 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5024 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5025 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5026 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5027 | err = vkAllocMemory(m_device->device(), &memAlloc, &destMem); |
| 5028 | ASSERT_VK_SUCCESS(err); |
| 5029 | |
| 5030 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5031 | ASSERT_VK_SUCCESS(err); |
| 5032 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5033 | ASSERT_VK_SUCCESS(err); |
| 5034 | |
| 5035 | BeginCommandBuffer(); |
| 5036 | VkImageCopy copyRegion; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5037 | copyRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5038 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5039 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 5040 | copyRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5041 | copyRegion.srcOffset.x = 0; |
| 5042 | copyRegion.srcOffset.y = 0; |
| 5043 | copyRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5044 | copyRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5045 | copyRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5046 | copyRegion.destSubresource.baseArrayLayer = 0; |
| 5047 | copyRegion.destSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5048 | copyRegion.destOffset.x = 0; |
| 5049 | copyRegion.destOffset.y = 0; |
| 5050 | copyRegion.destOffset.z = 0; |
| 5051 | copyRegion.extent.width = 1; |
| 5052 | copyRegion.extent.height = 1; |
| 5053 | copyRegion.extent.depth = 1; |
| 5054 | m_cmdBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 5055 | EndCommandBuffer(); |
| 5056 | |
| 5057 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5058 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdCopyImage type mismatch"; |
| 5059 | if (!strstr(msgString.c_str(),"vkCmdCopyImage called with unmatched source and dest image types")) { |
| 5060 | FAIL() << "Error received was not 'vkCmdCopyImage called with unmatched source and dest image types' but instead '" << msgString.c_str() << "'"; |
| 5061 | } |
| 5062 | |
| 5063 | vkDestroyImage(m_device->device(), srcImage); |
| 5064 | vkDestroyImage(m_device->device(), destImage); |
| 5065 | vkFreeMemory(m_device->device(), srcMem); |
| 5066 | vkFreeMemory(m_device->device(), destMem); |
| 5067 | } |
| 5068 | |
| 5069 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5070 | { |
| 5071 | VkFlags msgFlags; |
| 5072 | std::string msgString; |
| 5073 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5074 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5075 | |
| 5076 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5077 | m_errorMonitor->ClearState(); |
| 5078 | |
| 5079 | // Create two images of sample count 1 and try to Resolve between them |
| 5080 | VkImage srcImage; |
| 5081 | VkImage destImage; |
| 5082 | VkDeviceMemory srcMem; |
| 5083 | VkDeviceMemory destMem; |
| 5084 | VkMemoryRequirements memReqs; |
| 5085 | |
| 5086 | VkImageCreateInfo image_create_info = {}; |
| 5087 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5088 | image_create_info.pNext = NULL; |
| 5089 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5090 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5091 | image_create_info.extent.width = 32; |
| 5092 | image_create_info.extent.height = 1; |
| 5093 | image_create_info.extent.depth = 1; |
| 5094 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5095 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5096 | image_create_info.samples = 1; |
| 5097 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5098 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT; |
| 5099 | image_create_info.flags = 0; |
| 5100 | |
| 5101 | err = vkCreateImage(m_device->device(), &image_create_info, &srcImage); |
| 5102 | ASSERT_VK_SUCCESS(err); |
| 5103 | |
| 5104 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 5105 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT; |
| 5106 | |
| 5107 | err = vkCreateImage(m_device->device(), &image_create_info, &destImage); |
| 5108 | ASSERT_VK_SUCCESS(err); |
| 5109 | |
| 5110 | // Allocate memory |
| 5111 | VkMemoryAllocInfo memAlloc = {}; |
| 5112 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5113 | memAlloc.pNext = NULL; |
| 5114 | memAlloc.allocationSize = 0; |
| 5115 | memAlloc.memoryTypeIndex = 0; |
| 5116 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5117 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5118 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5119 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5120 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5121 | err = vkAllocMemory(m_device->device(), &memAlloc, &srcMem); |
| 5122 | ASSERT_VK_SUCCESS(err); |
| 5123 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5124 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5125 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5126 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5127 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5128 | err = vkAllocMemory(m_device->device(), &memAlloc, &destMem); |
| 5129 | ASSERT_VK_SUCCESS(err); |
| 5130 | |
| 5131 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5132 | ASSERT_VK_SUCCESS(err); |
| 5133 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5134 | ASSERT_VK_SUCCESS(err); |
| 5135 | |
| 5136 | BeginCommandBuffer(); |
| 5137 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5138 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5139 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5140 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5141 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5142 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5143 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 5144 | resolveRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5145 | resolveRegion.srcOffset.x = 0; |
| 5146 | resolveRegion.srcOffset.y = 0; |
| 5147 | resolveRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5148 | resolveRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5149 | resolveRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5150 | resolveRegion.destSubresource.baseArrayLayer = 0; |
| 5151 | resolveRegion.destSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5152 | resolveRegion.destOffset.x = 0; |
| 5153 | resolveRegion.destOffset.y = 0; |
| 5154 | resolveRegion.destOffset.z = 0; |
| 5155 | resolveRegion.extent.width = 1; |
| 5156 | resolveRegion.extent.height = 1; |
| 5157 | resolveRegion.extent.depth = 1; |
| 5158 | m_cmdBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
| 5159 | EndCommandBuffer(); |
| 5160 | |
| 5161 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5162 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage type mismatch"; |
| 5163 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with source sample count less than 2.")) { |
| 5164 | FAIL() << "Error received was not 'vkCmdResolveImage called with source sample count less than 2.' but instead '" << msgString.c_str() << "'"; |
| 5165 | } |
| 5166 | |
| 5167 | vkDestroyImage(m_device->device(), srcImage); |
| 5168 | vkDestroyImage(m_device->device(), destImage); |
| 5169 | vkFreeMemory(m_device->device(), srcMem); |
| 5170 | vkFreeMemory(m_device->device(), destMem); |
| 5171 | } |
| 5172 | |
| 5173 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5174 | { |
| 5175 | VkFlags msgFlags; |
| 5176 | std::string msgString; |
| 5177 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5178 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5179 | |
| 5180 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5181 | m_errorMonitor->ClearState(); |
| 5182 | |
| 5183 | // Create two images of sample count 2 and try to Resolve between them |
| 5184 | VkImage srcImage; |
| 5185 | VkImage destImage; |
| 5186 | VkDeviceMemory srcMem; |
| 5187 | VkDeviceMemory destMem; |
| 5188 | VkMemoryRequirements memReqs; |
| 5189 | |
| 5190 | VkImageCreateInfo image_create_info = {}; |
| 5191 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5192 | image_create_info.pNext = NULL; |
| 5193 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5194 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5195 | image_create_info.extent.width = 32; |
| 5196 | image_create_info.extent.height = 1; |
| 5197 | image_create_info.extent.depth = 1; |
| 5198 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5199 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5200 | image_create_info.samples = 2; |
| 5201 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5202 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5203 | 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] | 5204 | image_create_info.flags = 0; |
| 5205 | |
| 5206 | err = vkCreateImage(m_device->device(), &image_create_info, &srcImage); |
| 5207 | ASSERT_VK_SUCCESS(err); |
| 5208 | |
| 5209 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
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_DESTINATION_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5212 | |
| 5213 | err = vkCreateImage(m_device->device(), &image_create_info, &destImage); |
| 5214 | ASSERT_VK_SUCCESS(err); |
| 5215 | |
| 5216 | // Allocate memory |
| 5217 | VkMemoryAllocInfo memAlloc = {}; |
| 5218 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5219 | memAlloc.pNext = NULL; |
| 5220 | memAlloc.allocationSize = 0; |
| 5221 | memAlloc.memoryTypeIndex = 0; |
| 5222 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5223 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5224 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5225 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5226 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5227 | err = vkAllocMemory(m_device->device(), &memAlloc, &srcMem); |
| 5228 | ASSERT_VK_SUCCESS(err); |
| 5229 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5230 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5231 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5232 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5233 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5234 | err = vkAllocMemory(m_device->device(), &memAlloc, &destMem); |
| 5235 | ASSERT_VK_SUCCESS(err); |
| 5236 | |
| 5237 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5238 | ASSERT_VK_SUCCESS(err); |
| 5239 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5240 | ASSERT_VK_SUCCESS(err); |
| 5241 | |
| 5242 | BeginCommandBuffer(); |
| 5243 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5244 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5245 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5246 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5247 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5248 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5249 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 5250 | resolveRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5251 | resolveRegion.srcOffset.x = 0; |
| 5252 | resolveRegion.srcOffset.y = 0; |
| 5253 | resolveRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5254 | resolveRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5255 | resolveRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5256 | resolveRegion.destSubresource.baseArrayLayer = 0; |
| 5257 | resolveRegion.destSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5258 | resolveRegion.destOffset.x = 0; |
| 5259 | resolveRegion.destOffset.y = 0; |
| 5260 | resolveRegion.destOffset.z = 0; |
| 5261 | resolveRegion.extent.width = 1; |
| 5262 | resolveRegion.extent.height = 1; |
| 5263 | resolveRegion.extent.depth = 1; |
| 5264 | m_cmdBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
| 5265 | EndCommandBuffer(); |
| 5266 | |
| 5267 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5268 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage type mismatch"; |
| 5269 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with dest sample count greater than 1.")) { |
| 5270 | FAIL() << "Error received was not 'vkCmdResolveImage called with dest sample count greater than 1.' but instead '" << msgString.c_str() << "'"; |
| 5271 | } |
| 5272 | |
| 5273 | vkDestroyImage(m_device->device(), srcImage); |
| 5274 | vkDestroyImage(m_device->device(), destImage); |
| 5275 | vkFreeMemory(m_device->device(), srcMem); |
| 5276 | vkFreeMemory(m_device->device(), destMem); |
| 5277 | } |
| 5278 | |
| 5279 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5280 | { |
| 5281 | VkFlags msgFlags; |
| 5282 | std::string msgString; |
| 5283 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5284 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5285 | |
| 5286 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5287 | m_errorMonitor->ClearState(); |
| 5288 | |
| 5289 | // Create two images of different types and try to copy between them |
| 5290 | VkImage srcImage; |
| 5291 | VkImage destImage; |
| 5292 | VkDeviceMemory srcMem; |
| 5293 | VkDeviceMemory destMem; |
| 5294 | VkMemoryRequirements memReqs; |
| 5295 | |
| 5296 | VkImageCreateInfo image_create_info = {}; |
| 5297 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5298 | image_create_info.pNext = NULL; |
| 5299 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5300 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5301 | image_create_info.extent.width = 32; |
| 5302 | image_create_info.extent.height = 1; |
| 5303 | image_create_info.extent.depth = 1; |
| 5304 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5305 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5306 | image_create_info.samples = 2; |
| 5307 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5308 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5309 | 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] | 5310 | image_create_info.flags = 0; |
| 5311 | |
| 5312 | err = vkCreateImage(m_device->device(), &image_create_info, &srcImage); |
| 5313 | ASSERT_VK_SUCCESS(err); |
| 5314 | |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5315 | // Set format to something other than source image |
| 5316 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5317 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5318 | 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] | 5319 | image_create_info.samples = 1; |
| 5320 | |
| 5321 | err = vkCreateImage(m_device->device(), &image_create_info, &destImage); |
| 5322 | ASSERT_VK_SUCCESS(err); |
| 5323 | |
| 5324 | // Allocate memory |
| 5325 | VkMemoryAllocInfo memAlloc = {}; |
| 5326 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5327 | memAlloc.pNext = NULL; |
| 5328 | memAlloc.allocationSize = 0; |
| 5329 | memAlloc.memoryTypeIndex = 0; |
| 5330 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5331 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5332 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5333 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5334 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5335 | err = vkAllocMemory(m_device->device(), &memAlloc, &srcMem); |
| 5336 | ASSERT_VK_SUCCESS(err); |
| 5337 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5338 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5339 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5340 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5341 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5342 | err = vkAllocMemory(m_device->device(), &memAlloc, &destMem); |
| 5343 | ASSERT_VK_SUCCESS(err); |
| 5344 | |
| 5345 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5346 | ASSERT_VK_SUCCESS(err); |
| 5347 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5348 | ASSERT_VK_SUCCESS(err); |
| 5349 | |
| 5350 | BeginCommandBuffer(); |
| 5351 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5352 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5353 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5354 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5355 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5356 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5357 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 5358 | resolveRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5359 | resolveRegion.srcOffset.x = 0; |
| 5360 | resolveRegion.srcOffset.y = 0; |
| 5361 | resolveRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5362 | resolveRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5363 | resolveRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5364 | resolveRegion.destSubresource.baseArrayLayer = 0; |
| 5365 | resolveRegion.destSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5366 | resolveRegion.destOffset.x = 0; |
| 5367 | resolveRegion.destOffset.y = 0; |
| 5368 | resolveRegion.destOffset.z = 0; |
| 5369 | resolveRegion.extent.width = 1; |
| 5370 | resolveRegion.extent.height = 1; |
| 5371 | resolveRegion.extent.depth = 1; |
| 5372 | m_cmdBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
| 5373 | EndCommandBuffer(); |
| 5374 | |
| 5375 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5376 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage format mismatch"; |
| 5377 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with unmatched source and dest formats.")) { |
| 5378 | FAIL() << "Error received was not 'vkCmdResolveImage called with unmatched source and dest formats.' but instead '" << msgString.c_str() << "'"; |
| 5379 | } |
| 5380 | |
| 5381 | vkDestroyImage(m_device->device(), srcImage); |
| 5382 | vkDestroyImage(m_device->device(), destImage); |
| 5383 | vkFreeMemory(m_device->device(), srcMem); |
| 5384 | vkFreeMemory(m_device->device(), destMem); |
| 5385 | } |
| 5386 | |
| 5387 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 5388 | { |
| 5389 | VkFlags msgFlags; |
| 5390 | std::string msgString; |
| 5391 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5392 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5393 | |
| 5394 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5395 | m_errorMonitor->ClearState(); |
| 5396 | |
| 5397 | // Create two images of different types and try to copy between them |
| 5398 | VkImage srcImage; |
| 5399 | VkImage destImage; |
| 5400 | VkDeviceMemory srcMem; |
| 5401 | VkDeviceMemory destMem; |
| 5402 | VkMemoryRequirements memReqs; |
| 5403 | |
| 5404 | VkImageCreateInfo image_create_info = {}; |
| 5405 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5406 | image_create_info.pNext = NULL; |
| 5407 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5408 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5409 | image_create_info.extent.width = 32; |
| 5410 | image_create_info.extent.height = 1; |
| 5411 | image_create_info.extent.depth = 1; |
| 5412 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5413 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5414 | image_create_info.samples = 2; |
| 5415 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5416 | // Note: Some implementations expect color attachment usage for any multisample surface |
| 5417 | 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] | 5418 | image_create_info.flags = 0; |
| 5419 | |
| 5420 | err = vkCreateImage(m_device->device(), &image_create_info, &srcImage); |
| 5421 | ASSERT_VK_SUCCESS(err); |
| 5422 | |
| 5423 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
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_DESTINATION_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5426 | image_create_info.samples = 1; |
| 5427 | |
| 5428 | err = vkCreateImage(m_device->device(), &image_create_info, &destImage); |
| 5429 | ASSERT_VK_SUCCESS(err); |
| 5430 | |
| 5431 | // Allocate memory |
| 5432 | VkMemoryAllocInfo memAlloc = {}; |
| 5433 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5434 | memAlloc.pNext = NULL; |
| 5435 | memAlloc.allocationSize = 0; |
| 5436 | memAlloc.memoryTypeIndex = 0; |
| 5437 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5438 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5439 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5440 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5441 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5442 | err = vkAllocMemory(m_device->device(), &memAlloc, &srcMem); |
| 5443 | ASSERT_VK_SUCCESS(err); |
| 5444 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5445 | vkGetImageMemoryRequirements(m_device->device(), destImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5446 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5447 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5448 | ASSERT_TRUE(pass); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5449 | err = vkAllocMemory(m_device->device(), &memAlloc, &destMem); |
| 5450 | ASSERT_VK_SUCCESS(err); |
| 5451 | |
| 5452 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5453 | ASSERT_VK_SUCCESS(err); |
| 5454 | err = vkBindImageMemory(m_device->device(), destImage, destMem, 0); |
| 5455 | ASSERT_VK_SUCCESS(err); |
| 5456 | |
| 5457 | BeginCommandBuffer(); |
| 5458 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5459 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5460 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5461 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5462 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5463 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5464 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 5465 | resolveRegion.srcSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5466 | resolveRegion.srcOffset.x = 0; |
| 5467 | resolveRegion.srcOffset.y = 0; |
| 5468 | resolveRegion.srcOffset.z = 0; |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5469 | resolveRegion.destSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5470 | resolveRegion.destSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5471 | resolveRegion.destSubresource.baseArrayLayer = 0; |
| 5472 | resolveRegion.destSubresource.numLayers = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5473 | resolveRegion.destOffset.x = 0; |
| 5474 | resolveRegion.destOffset.y = 0; |
| 5475 | resolveRegion.destOffset.z = 0; |
| 5476 | resolveRegion.extent.width = 1; |
| 5477 | resolveRegion.extent.height = 1; |
| 5478 | resolveRegion.extent.depth = 1; |
| 5479 | m_cmdBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, destImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
| 5480 | EndCommandBuffer(); |
| 5481 | |
| 5482 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5483 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage type mismatch"; |
| 5484 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with unmatched source and dest image types.")) { |
| 5485 | FAIL() << "Error received was not 'vkCmdResolveImage called with unmatched source and dest image types.' but instead '" << msgString.c_str() << "'"; |
| 5486 | } |
| 5487 | |
| 5488 | vkDestroyImage(m_device->device(), srcImage); |
| 5489 | vkDestroyImage(m_device->device(), destImage); |
| 5490 | vkFreeMemory(m_device->device(), srcMem); |
| 5491 | vkFreeMemory(m_device->device(), destMem); |
| 5492 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5493 | |
| 5494 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 5495 | { |
| 5496 | // Create a single Image descriptor and cause it to first hit an error due |
| 5497 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 5498 | // The image format check comes 2nd in validation so we trigger it first, |
| 5499 | // then when we cause aspect fail next, bad format check will be preempted |
| 5500 | VkFlags msgFlags; |
| 5501 | std::string msgString; |
| 5502 | VkResult err; |
| 5503 | |
| 5504 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5505 | m_errorMonitor->ClearState(); |
| 5506 | VkDescriptorTypeCount ds_type_count = {}; |
| 5507 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5508 | ds_type_count.count = 1; |
| 5509 | |
| 5510 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5511 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5512 | ds_pool_ci.pNext = NULL; |
| 5513 | ds_pool_ci.maxSets = 1; |
| 5514 | ds_pool_ci.count = 1; |
| 5515 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 5516 | |
| 5517 | VkDescriptorPool ds_pool; |
| 5518 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
| 5519 | ASSERT_VK_SUCCESS(err); |
| 5520 | |
| 5521 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5522 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5523 | dsl_binding.arraySize = 1; |
| 5524 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5525 | dsl_binding.pImmutableSamplers = NULL; |
| 5526 | |
| 5527 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5528 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5529 | ds_layout_ci.pNext = NULL; |
| 5530 | ds_layout_ci.count = 1; |
| 5531 | ds_layout_ci.pBinding = &dsl_binding; |
| 5532 | VkDescriptorSetLayout ds_layout; |
| 5533 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 5534 | ASSERT_VK_SUCCESS(err); |
| 5535 | |
| 5536 | VkDescriptorSet descriptorSet; |
| 5537 | VkDescriptorSetAllocInfo alloc_info = {}; |
| 5538 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 5539 | alloc_info.count = 1; |
| 5540 | alloc_info.descriptorPool = ds_pool; |
| 5541 | alloc_info.pSetLayouts = &ds_layout; |
| 5542 | err = vkAllocDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 5543 | ASSERT_VK_SUCCESS(err); |
| 5544 | |
| 5545 | VkImage image_bad; |
| 5546 | VkImage image_good; |
| 5547 | // One bad format and one good format for Color attachment |
| 5548 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 5549 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 5550 | const int32_t tex_width = 32; |
| 5551 | const int32_t tex_height = 32; |
| 5552 | |
| 5553 | VkImageCreateInfo image_create_info = {}; |
| 5554 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5555 | image_create_info.pNext = NULL; |
| 5556 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5557 | image_create_info.format = tex_format_bad; |
| 5558 | image_create_info.extent.width = tex_width; |
| 5559 | image_create_info.extent.height = tex_height; |
| 5560 | image_create_info.extent.depth = 1; |
| 5561 | image_create_info.mipLevels = 1; |
| 5562 | image_create_info.arrayLayers = 1; |
| 5563 | image_create_info.samples = 1; |
| 5564 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5565 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 5566 | image_create_info.flags = 0; |
| 5567 | |
| 5568 | err = vkCreateImage(m_device->device(), &image_create_info, &image_bad); |
| 5569 | ASSERT_VK_SUCCESS(err); |
| 5570 | image_create_info.format = tex_format_good; |
| 5571 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 5572 | err = vkCreateImage(m_device->device(), &image_create_info, &image_good); |
| 5573 | ASSERT_VK_SUCCESS(err); |
| 5574 | |
| 5575 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5576 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5577 | image_view_create_info.image = image_bad; |
| 5578 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5579 | image_view_create_info.format = tex_format_bad; |
| 5580 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 5581 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5582 | image_view_create_info.subresourceRange.numLayers = 1; |
| 5583 | image_view_create_info.subresourceRange.numLevels = 1; |
| 5584 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5585 | |
| 5586 | VkImageView view; |
| 5587 | err = vkCreateImageView(m_device->device(), &image_view_create_info, &view); |
| 5588 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5589 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating ImageView for DS image w/ COLOR aspect bit set."; |
| 5590 | if (!strstr(msgString.c_str(),"Combination depth/stencil image formats can have only the ")) { |
| 5591 | FAIL() << "Error received was not 'Combination depth/stencil image formats can have only the....' but instead '" << msgString.c_str() << "'"; |
| 5592 | } |
| 5593 | |
| 5594 | vkDestroyImage(m_device->device(), image_bad); |
| 5595 | vkDestroyImage(m_device->device(), image_good); |
| 5596 | vkDestroyImageView(m_device->device(), view); |
| 5597 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 5598 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
| 5599 | } |
| 5600 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5601 | #endif // IMAGE_TESTS |
| 5602 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5603 | int main(int argc, char **argv) { |
| 5604 | int result; |
| 5605 | |
| 5606 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5607 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5608 | |
| 5609 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 5610 | |
| 5611 | result = RUN_ALL_TESTS(); |
| 5612 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5613 | VkTestFramework::Finish(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5614 | return result; |
| 5615 | } |