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