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