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