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" |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 3 | #include "gtest-1.7.0/include/gtest/gtest.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 | } |
| 304 | if (failMask & BsoFailViewport) { |
| 305 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
| 306 | } |
| 307 | if (failMask & BsoFailScissor) { |
| 308 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
| 309 | } |
| 310 | if (failMask & BsoFailBlend) { |
| 311 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
| 312 | } |
| 313 | if (failMask & BsoFailDepthBounds) { |
| 314 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 315 | } |
| 316 | if (failMask & BsoFailStencilReadMask) { |
| 317 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 318 | } |
| 319 | if (failMask & BsoFailStencilWriteMask) { |
| 320 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 321 | } |
| 322 | if (failMask & BsoFailStencilReference) { |
| 323 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 324 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 325 | |
| 326 | VkDescriptorSetObj descriptorSet(m_device); |
| 327 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, constantBuffer); |
| 328 | |
| 329 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 330 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 331 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 332 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 333 | |
| 334 | // render triangle |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 335 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 336 | |
| 337 | // finalize recording of the command buffer |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 338 | EndCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 339 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 340 | QueueCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *cmdBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
| 344 | { |
| 345 | if (m_depthStencil->Initialized()) { |
| 346 | cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, m_depthStencil); |
| 347 | } else { |
| 348 | cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
| 349 | } |
| 350 | |
| 351 | cmdBuffer->PrepareAttachments(); |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 352 | // Make sure depthWriteEnable is set so that Depth fail test will work correctly |
| 353 | // 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] | 354 | VkStencilOpState stencil = {}; |
| 355 | stencil.stencilFailOp = VK_STENCIL_OP_KEEP; |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 356 | stencil.stencilPassOp = VK_STENCIL_OP_KEEP; |
| 357 | stencil.stencilDepthFailOp = VK_STENCIL_OP_KEEP; |
| 358 | stencil.stencilCompareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 359 | |
| 360 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 361 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 362 | ds_ci.pNext = NULL; |
| 363 | ds_ci.depthTestEnable = VK_FALSE; |
| 364 | ds_ci.depthWriteEnable = VK_TRUE; |
| 365 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 366 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
| 367 | ds_ci.stencilTestEnable = VK_TRUE; |
| 368 | ds_ci.front = stencil; |
| 369 | ds_ci.back = stencil; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 370 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 371 | pipelineobj.SetDepthStencil(&ds_ci); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 372 | descriptorSet.CreateVKDescriptorSet(cmdBuffer); |
Cody Northrop | ccfa96d | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 373 | VkResult err = pipelineobj.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 374 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 375 | cmdBuffer->BindPipeline(pipelineobj); |
| 376 | cmdBuffer->BindDescriptorSet(descriptorSet); |
| 377 | } |
| 378 | |
| 379 | // ******************************************************************************************************************** |
| 380 | // ******************************************************************************************************************** |
| 381 | // ******************************************************************************************************************** |
| 382 | // ******************************************************************************************************************** |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 383 | #if MEM_TRACKER_TESTS |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 384 | TEST_F(VkLayerTest, CallResetCmdBufferBeforeCompletion) |
| 385 | { |
| 386 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 387 | VkFlags msgFlags; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 388 | std::string msgString; |
| 389 | |
| 390 | VkFenceCreateInfo fenceInfo = {}; |
| 391 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 392 | fenceInfo.pNext = NULL; |
| 393 | fenceInfo.flags = 0; |
| 394 | |
| 395 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | e389b88 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 396 | |
| 397 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 398 | vk_testing::Buffer buffer; |
| 399 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 400 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 401 | BeginCommandBuffer(); |
| 402 | m_cmdBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
| 403 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 404 | |
| 405 | testFence.init(*m_device, fenceInfo); |
| 406 | |
| 407 | // Bypass framework since it does the waits automatically |
| 408 | VkResult err = VK_SUCCESS; |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 409 | err = vkQueueSubmit( m_device->m_queue, 1, &m_cmdBuffer->handle(), testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 410 | ASSERT_VK_SUCCESS( err ); |
| 411 | |
| 412 | m_errorMonitor->ClearState(); |
| 413 | // Introduce failure by calling begin again before checking fence |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 414 | vkResetCommandBuffer(m_cmdBuffer->handle(), 0); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 415 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 416 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 417 | 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] | 418 | if (!strstr(msgString.c_str(),"Resetting CB")) { |
| 419 | FAIL() << "Error received was not 'Resetting CB (0xaddress) before it has completed. You must check CB flag before'"; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | TEST_F(VkLayerTest, CallBeginCmdBufferBeforeCompletion) |
| 424 | { |
| 425 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 426 | VkFlags msgFlags; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 427 | std::string msgString; |
| 428 | |
| 429 | VkFenceCreateInfo fenceInfo = {}; |
| 430 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 431 | fenceInfo.pNext = NULL; |
| 432 | fenceInfo.flags = 0; |
| 433 | |
| 434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 435 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 436 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 437 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 438 | BeginCommandBuffer(); |
| 439 | m_cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
| 440 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 441 | |
| 442 | testFence.init(*m_device, fenceInfo); |
| 443 | |
| 444 | // Bypass framework since it does the waits automatically |
| 445 | VkResult err = VK_SUCCESS; |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 446 | err = vkQueueSubmit( m_device->m_queue, 1, &m_cmdBuffer->handle(), testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 447 | ASSERT_VK_SUCCESS( err ); |
| 448 | |
| 449 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 450 | |
| 451 | VkCmdBufferBeginInfo info = {}; |
| 452 | info.flags = VK_CMD_BUFFER_OPTIMIZE_SMALL_BATCH_BIT | VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT; |
| 453 | info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO; |
| 454 | info.renderPass = VK_NULL_HANDLE; |
| 455 | info.subpass = 0; |
| 456 | info.framebuffer = VK_NULL_HANDLE; |
| 457 | |
| 458 | // Introduce failure by calling BCB again before checking fence |
| 459 | vkBeginCommandBuffer(m_cmdBuffer->handle(), &info); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 460 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 461 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 462 | 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] | 463 | if (!strstr(msgString.c_str(),"Calling vkBeginCommandBuffer() on active CB")) { |
| 464 | FAIL() << "Error received was not 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 465 | } |
| 466 | } |
| 467 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 468 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) |
| 469 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 470 | VkFlags msgFlags; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 471 | std::string msgString; |
| 472 | VkResult err; |
| 473 | |
| 474 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 475 | m_errorMonitor->ClearState(); |
| 476 | |
| 477 | // Create an image, allocate memory, free it, and then try to bind it |
| 478 | VkImage image; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 479 | VkDeviceMemory mem; |
| 480 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 481 | |
| 482 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 483 | const int32_t tex_width = 32; |
| 484 | const int32_t tex_height = 32; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 485 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 486 | VkImageCreateInfo image_create_info = {}; |
| 487 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 488 | image_create_info.pNext = NULL; |
| 489 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 490 | image_create_info.format = tex_format; |
| 491 | image_create_info.extent.width = tex_width; |
| 492 | image_create_info.extent.height = tex_height; |
| 493 | image_create_info.extent.depth = 1; |
| 494 | image_create_info.mipLevels = 1; |
| 495 | image_create_info.arraySize = 1; |
| 496 | image_create_info.samples = 1; |
| 497 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 498 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 499 | image_create_info.flags = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 500 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 501 | VkMemoryAllocInfo mem_alloc = {}; |
| 502 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 503 | mem_alloc.pNext = NULL; |
| 504 | mem_alloc.allocationSize = 0; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 505 | // 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] | 506 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 507 | |
| 508 | err = vkCreateImage(m_device->device(), &image_create_info, &image); |
| 509 | ASSERT_VK_SUCCESS(err); |
| 510 | |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 511 | err = vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 512 | image, |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 513 | &mem_reqs); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 514 | ASSERT_VK_SUCCESS(err); |
| 515 | |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 516 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 517 | |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 518 | err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 519 | if(err != VK_SUCCESS) { // If we can't find any unmappable memory this test doesn't make sense |
| 520 | vkDestroyImage(m_device->device(), image); |
Tony Barbour | 49a3b65 | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 521 | return; |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 522 | } |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 523 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 524 | // allocate memory |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 525 | err = vkAllocMemory(m_device->device(), &mem_alloc, &mem); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 526 | ASSERT_VK_SUCCESS(err); |
| 527 | |
| 528 | // Try to bind free memory that has been freed |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 529 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 530 | ASSERT_VK_SUCCESS(err); |
| 531 | |
| 532 | // Map memory as if to initialize the image |
| 533 | void *mappedAddress = NULL; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 534 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, &mappedAddress); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 535 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 536 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 537 | 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] | 538 | if (!strstr(msgString.c_str(),"Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT")) { |
| 539 | FAIL() << "Error received did not match expected error message from vkMapMemory in MemTracker"; |
| 540 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 541 | |
| 542 | vkDestroyImage(m_device->device(), image); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 543 | } |
| 544 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 545 | // TODO : Is this test still valid. Not sure it is with updates to memory binding model |
| 546 | // Verify and delete the test of fix the check |
| 547 | //TEST_F(VkLayerTest, FreeBoundMemory) |
| 548 | //{ |
| 549 | // VkFlags msgFlags; |
| 550 | // std::string msgString; |
| 551 | // VkResult err; |
| 552 | // |
| 553 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 554 | // m_errorMonitor->ClearState(); |
| 555 | // |
| 556 | // // Create an image, allocate memory, free it, and then try to bind it |
| 557 | // VkImage image; |
| 558 | // VkDeviceMemory mem; |
| 559 | // VkMemoryRequirements mem_reqs; |
| 560 | // |
| 561 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 562 | // const int32_t tex_width = 32; |
| 563 | // const int32_t tex_height = 32; |
| 564 | // |
| 565 | // const VkImageCreateInfo image_create_info = { |
| 566 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 567 | // .pNext = NULL, |
| 568 | // .imageType = VK_IMAGE_TYPE_2D, |
| 569 | // .format = tex_format, |
| 570 | // .extent = { tex_width, tex_height, 1 }, |
| 571 | // .mipLevels = 1, |
| 572 | // .arraySize = 1, |
| 573 | // .samples = 1, |
| 574 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 575 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 576 | // .flags = 0, |
| 577 | // }; |
| 578 | // VkMemoryAllocInfo mem_alloc = { |
| 579 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO, |
| 580 | // .pNext = NULL, |
| 581 | // .allocationSize = 0, |
| 582 | // .memoryTypeIndex = 0, |
| 583 | // }; |
| 584 | // |
| 585 | // err = vkCreateImage(m_device->device(), &image_create_info, &image); |
| 586 | // ASSERT_VK_SUCCESS(err); |
| 587 | // |
| 588 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 589 | // image, |
| 590 | // &mem_reqs); |
| 591 | // ASSERT_VK_SUCCESS(err); |
| 592 | // |
| 593 | // mem_alloc.allocationSize = mem_reqs.size; |
| 594 | // |
| 595 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 596 | // ASSERT_VK_SUCCESS(err); |
| 597 | // |
| 598 | // // allocate memory |
| 599 | // err = vkAllocMemory(m_device->device(), &mem_alloc, &mem); |
| 600 | // ASSERT_VK_SUCCESS(err); |
| 601 | // |
| 602 | // // Bind memory to Image object |
| 603 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 604 | // ASSERT_VK_SUCCESS(err); |
| 605 | // |
| 606 | // // Introduce validation failure, free memory while still bound to object |
| 607 | // vkFreeMemory(m_device->device(), mem); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 608 | // msgFlags = m_errorMonitor->GetState(&msgString); |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 609 | // |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 610 | // 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] | 611 | // if (!strstr(msgString.c_str(),"Freeing memory object while it still has references")) { |
| 612 | // FAIL() << "Warning received did not match expected message from freeMemObjInfo in MemTracker"; |
| 613 | // } |
| 614 | //} |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 615 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 616 | TEST_F(VkLayerTest, RebindMemory) |
| 617 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 618 | VkFlags msgFlags; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 619 | std::string msgString; |
| 620 | VkResult err; |
| 621 | |
| 622 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 623 | m_errorMonitor->ClearState(); |
| 624 | |
| 625 | // Create an image, allocate memory, free it, and then try to bind it |
| 626 | VkImage image; |
| 627 | VkDeviceMemory mem1; |
| 628 | VkDeviceMemory mem2; |
| 629 | VkMemoryRequirements mem_reqs; |
| 630 | |
| 631 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 632 | const int32_t tex_width = 32; |
| 633 | const int32_t tex_height = 32; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 634 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 635 | VkImageCreateInfo image_create_info = {}; |
| 636 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 637 | image_create_info.pNext = NULL; |
| 638 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 639 | image_create_info.format = tex_format; |
| 640 | image_create_info.extent.width = tex_width; |
| 641 | image_create_info.extent.height = tex_height; |
| 642 | image_create_info.extent.depth = 1; |
| 643 | image_create_info.mipLevels = 1; |
| 644 | image_create_info.arraySize = 1; |
| 645 | image_create_info.samples = 1; |
| 646 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 647 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 648 | image_create_info.flags = 0; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 649 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 650 | VkMemoryAllocInfo mem_alloc = {}; |
| 651 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 652 | mem_alloc.pNext = NULL; |
| 653 | mem_alloc.allocationSize = 0; |
| 654 | mem_alloc.memoryTypeIndex = 0; |
| 655 | |
| 656 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 657 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 658 | err = vkCreateImage(m_device->device(), &image_create_info, &image); |
| 659 | ASSERT_VK_SUCCESS(err); |
| 660 | |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 661 | err = vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 662 | image, |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 663 | &mem_reqs); |
| 664 | ASSERT_VK_SUCCESS(err); |
| 665 | |
| 666 | mem_alloc.allocationSize = mem_reqs.size; |
Chia-I Wu | f5fb109 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 667 | 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] | 668 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 669 | |
| 670 | // allocate 2 memory objects |
| 671 | err = vkAllocMemory(m_device->device(), &mem_alloc, &mem1); |
| 672 | ASSERT_VK_SUCCESS(err); |
| 673 | err = vkAllocMemory(m_device->device(), &mem_alloc, &mem2); |
| 674 | ASSERT_VK_SUCCESS(err); |
| 675 | |
| 676 | // Bind first memory object to Image object |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 677 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 678 | ASSERT_VK_SUCCESS(err); |
| 679 | |
| 680 | // 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] | 681 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 682 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 683 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 684 | 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] | 685 | if (!strstr(msgString.c_str(),"which has already been bound to mem object")) { |
| 686 | FAIL() << "Error received did not match expected message when rebinding memory to an object"; |
| 687 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 688 | |
| 689 | vkDestroyImage(m_device->device(), image); |
| 690 | vkFreeMemory(m_device->device(), mem1); |
| 691 | vkFreeMemory(m_device->device(), mem2); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 692 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 693 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 694 | TEST_F(VkLayerTest, SubmitSignaledFence) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 695 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 696 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 697 | VkFlags msgFlags; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 698 | std::string msgString; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 699 | |
| 700 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 701 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 702 | fenceInfo.pNext = NULL; |
| 703 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 704 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 705 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 706 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 707 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 708 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 709 | BeginCommandBuffer(); |
| 710 | m_cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
| 711 | EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 712 | |
| 713 | testFence.init(*m_device, fenceInfo); |
| 714 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 715 | |
| 716 | vkQueueSubmit(m_device->m_queue, 1, &m_cmdBuffer->handle(), testFence.handle()); |
| 717 | vkQueueWaitIdle(m_device->m_queue ); |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 718 | msgFlags = m_errorMonitor->GetState(&msgString); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 719 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 720 | 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] | 721 | 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] | 722 | FAIL() << "Error received was not 'VkQueueSubmit with fence in SIGNALED_STATE'"; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | } |
| 726 | |
| 727 | TEST_F(VkLayerTest, ResetUnsignaledFence) |
| 728 | { |
| 729 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 730 | VkFlags msgFlags; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 731 | std::string msgString; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 732 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 733 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 734 | fenceInfo.pNext = NULL; |
| 735 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 736 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 737 | testFence.init(*m_device, fenceInfo); |
| 738 | m_errorMonitor->ClearState(); |
Chia-I Wu | a499234 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 739 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 740 | vkResetFences(m_device->device(), 1, fences); |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 741 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 742 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_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] | 743 | if (!strstr(msgString.c_str(),"submitted to VkResetFences in UNSIGNALED STATE")) { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 744 | FAIL() << "Error received was not 'VkResetFences with fence in UNSIGNALED_STATE'"; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 745 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 746 | |
| 747 | } |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 748 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 749 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 750 | #if 0 |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 751 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 752 | { |
| 753 | // Initiate Draw w/o a PSO bound |
| 754 | VkFlags msgFlags; |
| 755 | std::string msgString; |
| 756 | |
| 757 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 758 | m_errorMonitor->ClearState(); |
| 759 | VkCommandBufferObj cmdBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 760 | BeginCommandBuffer(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 761 | |
| 762 | const VkExtent3D e3d = { |
| 763 | .width = 128, |
| 764 | .height = 128, |
| 765 | .depth = 1, |
| 766 | }; |
| 767 | const VkImageCreateInfo ici = { |
| 768 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 769 | .pNext = NULL, |
| 770 | .imageType = VK_IMAGE_TYPE_2D, |
| 771 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 772 | .extent = e3d, |
| 773 | .mipLevels = 1, |
| 774 | .arraySize = 1, |
| 775 | .samples = 1, |
| 776 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | c3b8eea | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 777 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 778 | .flags = 0, |
| 779 | }; |
| 780 | |
| 781 | VkImage dsi; |
| 782 | vkCreateImage(m_device->device(), &ici, &dsi); |
| 783 | VkDepthStencilView dsv; |
| 784 | const VkDepthStencilViewCreateInfo dsvci = { |
| 785 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 786 | .pNext = NULL, |
| 787 | .image = dsi, |
| 788 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 789 | .baseArrayLayer = 0, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 790 | .arraySize = 1, |
| 791 | .flags = 0, |
| 792 | }; |
| 793 | vkCreateDepthStencilView(m_device->device(), &dsvci, &dsv); |
| 794 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 795 | 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] | 796 | if (!strstr(msgString.c_str(),"Invalid usage flag for image ")) { |
| 797 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
| 798 | } |
| 799 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 800 | #endif // 0 |
| 801 | #endif // MEM_TRACKER_TESTS |
| 802 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 803 | #if OBJ_TRACKER_TESTS |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 804 | TEST_F(VkLayerTest, PipelineNotBound) |
| 805 | { |
| 806 | VkFlags msgFlags; |
| 807 | std::string msgString; |
| 808 | VkResult err; |
| 809 | |
| 810 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 811 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 812 | m_errorMonitor->ClearState(); |
| 813 | |
| 814 | VkDescriptorTypeCount ds_type_count = {}; |
| 815 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 816 | ds_type_count.count = 1; |
| 817 | |
| 818 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 819 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 820 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 821 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 822 | ds_pool_ci.maxSets = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 823 | ds_pool_ci.count = 1; |
| 824 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 825 | |
| 826 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 827 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 828 | ASSERT_VK_SUCCESS(err); |
| 829 | |
| 830 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 831 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 832 | dsl_binding.arraySize = 1; |
| 833 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 834 | dsl_binding.pImmutableSamplers = NULL; |
| 835 | |
| 836 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 837 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 838 | ds_layout_ci.pNext = NULL; |
| 839 | ds_layout_ci.count = 1; |
| 840 | ds_layout_ci.pBinding = &dsl_binding; |
| 841 | |
| 842 | VkDescriptorSetLayout ds_layout; |
| 843 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 844 | ASSERT_VK_SUCCESS(err); |
| 845 | |
| 846 | VkDescriptorSet descriptorSet; |
| 847 | err = vkAllocDescriptorSets(m_device->device(), ds_pool, VK_DESCRIPTOR_SET_USAGE_ONE_SHOT, 1, &ds_layout, &descriptorSet); |
| 848 | ASSERT_VK_SUCCESS(err); |
| 849 | |
| 850 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 851 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 852 | pipeline_layout_ci.pNext = NULL; |
| 853 | pipeline_layout_ci.descriptorSetCount = 1; |
| 854 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 855 | |
| 856 | VkPipelineLayout pipeline_layout; |
| 857 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 858 | ASSERT_VK_SUCCESS(err); |
| 859 | |
| 860 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 861 | |
| 862 | BeginCommandBuffer(); |
| 863 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
| 864 | |
| 865 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 866 | 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] | 867 | if (!strstr(msgString.c_str(),"Invalid VkPipeline Object ")) { |
| 868 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be' but instead it was '" << msgString.c_str() << "'"; |
| 869 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 870 | |
| 871 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
| 872 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 873 | ASSERT_VK_SUCCESS(err); |
| 874 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 875 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 879 | { |
| 880 | VkFlags msgFlags; |
| 881 | std::string msgString; |
| 882 | VkResult err; |
| 883 | |
| 884 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 885 | m_errorMonitor->ClearState(); |
| 886 | |
| 887 | // Create an image, allocate memory, free it, and then try to bind it |
| 888 | VkImage image; |
| 889 | VkDeviceMemory mem; |
| 890 | VkMemoryRequirements mem_reqs; |
| 891 | |
| 892 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 893 | const int32_t tex_width = 32; |
| 894 | const int32_t tex_height = 32; |
| 895 | |
| 896 | VkImageCreateInfo image_create_info = {}; |
| 897 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 898 | image_create_info.pNext = NULL; |
| 899 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 900 | image_create_info.format = tex_format; |
| 901 | image_create_info.extent.width = tex_width; |
| 902 | image_create_info.extent.height = tex_height; |
| 903 | image_create_info.extent.depth = 1; |
| 904 | image_create_info.mipLevels = 1; |
| 905 | image_create_info.arraySize = 1; |
| 906 | image_create_info.samples = 1; |
| 907 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 908 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 909 | image_create_info.flags = 0; |
| 910 | |
| 911 | VkMemoryAllocInfo mem_alloc = {}; |
| 912 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 913 | mem_alloc.pNext = NULL; |
| 914 | mem_alloc.allocationSize = 0; |
| 915 | mem_alloc.memoryTypeIndex = 0; |
| 916 | |
| 917 | err = vkCreateImage(m_device->device(), &image_create_info, &image); |
| 918 | ASSERT_VK_SUCCESS(err); |
| 919 | |
| 920 | err = vkGetImageMemoryRequirements(m_device->device(), |
| 921 | image, |
| 922 | &mem_reqs); |
| 923 | ASSERT_VK_SUCCESS(err); |
| 924 | |
| 925 | mem_alloc.allocationSize = mem_reqs.size; |
| 926 | |
| 927 | err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 928 | ASSERT_VK_SUCCESS(err); |
| 929 | |
| 930 | // allocate memory |
| 931 | err = vkAllocMemory(m_device->device(), &mem_alloc, &mem); |
| 932 | ASSERT_VK_SUCCESS(err); |
| 933 | |
| 934 | // Introduce validation failure, free memory before binding |
| 935 | vkFreeMemory(m_device->device(), mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 936 | |
| 937 | // Try to bind free memory that has been freed |
| 938 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 939 | // This may very well return an error. |
| 940 | (void)err; |
| 941 | |
| 942 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 943 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while tring to bind a freed memory object"; |
| 944 | if (!strstr(msgString.c_str(),"Invalid VkDeviceMemory Object ")) { |
| 945 | FAIL() << "Error received from BindInvalidMemory was not 'Invalid VkDeviceMemory Object 0x<handle>' but instead '" << msgString.c_str() << "'"; |
| 946 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 947 | |
| 948 | vkDestroyImage(m_device->device(), image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 952 | { |
| 953 | VkFlags msgFlags; |
| 954 | std::string msgString; |
| 955 | VkResult err; |
| 956 | |
| 957 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 958 | m_errorMonitor->ClearState(); |
| 959 | |
| 960 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 961 | VkImage image; |
| 962 | VkDeviceMemory mem; |
| 963 | VkMemoryRequirements mem_reqs; |
| 964 | |
| 965 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 966 | const int32_t tex_width = 32; |
| 967 | const int32_t tex_height = 32; |
| 968 | |
| 969 | VkImageCreateInfo image_create_info = {}; |
| 970 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 971 | image_create_info.pNext = NULL; |
| 972 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 973 | image_create_info.format = tex_format; |
| 974 | image_create_info.extent.width = tex_width; |
| 975 | image_create_info.extent.height = tex_height; |
| 976 | image_create_info.extent.depth = 1; |
| 977 | image_create_info.mipLevels = 1; |
| 978 | image_create_info.arraySize = 1; |
| 979 | image_create_info.samples = 1; |
| 980 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 981 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 982 | image_create_info.flags = 0; |
| 983 | |
| 984 | VkMemoryAllocInfo mem_alloc = {}; |
| 985 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 986 | mem_alloc.pNext = NULL; |
| 987 | mem_alloc.allocationSize = 0; |
| 988 | mem_alloc.memoryTypeIndex = 0; |
| 989 | |
| 990 | err = vkCreateImage(m_device->device(), &image_create_info, &image); |
| 991 | ASSERT_VK_SUCCESS(err); |
| 992 | |
| 993 | err = vkGetImageMemoryRequirements(m_device->device(), |
| 994 | image, |
| 995 | &mem_reqs); |
| 996 | ASSERT_VK_SUCCESS(err); |
| 997 | |
| 998 | mem_alloc.allocationSize = mem_reqs.size; |
| 999 | err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1000 | ASSERT_VK_SUCCESS(err); |
| 1001 | |
| 1002 | // Allocate memory |
| 1003 | err = vkAllocMemory(m_device->device(), &mem_alloc, &mem); |
| 1004 | ASSERT_VK_SUCCESS(err); |
| 1005 | |
| 1006 | // Introduce validation failure, destroy Image object before binding |
| 1007 | vkDestroyImage(m_device->device(), image); |
| 1008 | ASSERT_VK_SUCCESS(err); |
| 1009 | |
| 1010 | // Now Try to bind memory to this destroyed object |
| 1011 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1012 | // This may very well return an error. |
| 1013 | (void) err; |
| 1014 | |
| 1015 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1016 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while binding memory to a destroyed object"; |
| 1017 | if (!strstr(msgString.c_str(),"Invalid VkImage Object ")) { |
| 1018 | 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] | 1019 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1020 | |
| 1021 | vkFreeMemory(m_device->device(), mem); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1022 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1023 | #endif // OBJ_TRACKER_TESTS |
| 1024 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1025 | #if DRAW_STATE_TESTS |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1026 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1027 | { |
| 1028 | VkFlags msgFlags; |
| 1029 | std::string msgString; |
| 1030 | m_errorMonitor->ClearState(); |
| 1031 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1032 | |
| 1033 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1034 | |
| 1035 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1036 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Line Width State Object"; |
| 1037 | if (!strstr(msgString.c_str(),"Dynamic line width state not set for this command buffer")) { |
| 1038 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic line width state not set for this command buffer'"; |
| 1039 | } |
| 1040 | } |
| 1041 | |
| 1042 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1043 | { |
| 1044 | VkFlags msgFlags; |
| 1045 | std::string msgString; |
| 1046 | m_errorMonitor->ClearState(); |
| 1047 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1048 | |
| 1049 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1050 | |
| 1051 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1052 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Depth Bias State Object"; |
| 1053 | if (!strstr(msgString.c_str(),"Dynamic depth bias state not set for this command buffer")) { |
| 1054 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic depth bias state not set for this command buffer'"; |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1059 | { |
| 1060 | VkFlags msgFlags; |
| 1061 | std::string msgString; |
| 1062 | m_errorMonitor->ClearState(); |
| 1063 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1064 | |
| 1065 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1066 | |
| 1067 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1068 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Viewport State Object"; |
| 1069 | if (!strstr(msgString.c_str(),"Dynamic viewport state not set for this command buffer")) { |
| 1070 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic viewport state not set for this command buffer'"; |
| 1071 | } |
| 1072 | } |
| 1073 | |
| 1074 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1075 | { |
| 1076 | VkFlags msgFlags; |
| 1077 | std::string msgString; |
| 1078 | m_errorMonitor->ClearState(); |
| 1079 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1080 | |
| 1081 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1082 | |
| 1083 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1084 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Viewport State Object"; |
| 1085 | if (!strstr(msgString.c_str(),"Dynamic scissor state not set for this command buffer")) { |
| 1086 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1087 | } |
| 1088 | } |
| 1089 | |
| 1090 | |
| 1091 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1092 | { |
| 1093 | VkFlags msgFlags; |
| 1094 | std::string msgString; |
| 1095 | m_errorMonitor->ClearState(); |
| 1096 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1097 | |
| 1098 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1099 | |
| 1100 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1101 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Blend State Object"; |
| 1102 | if (!strstr(msgString.c_str(),"Dynamic blend object state not set for this command buffer")) { |
| 1103 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic blend object state not set for this command buffer'"; |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1108 | { |
| 1109 | VkFlags msgFlags; |
| 1110 | std::string msgString; |
| 1111 | m_errorMonitor->ClearState(); |
| 1112 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1113 | |
| 1114 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1115 | |
| 1116 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1117 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Depth Bounds State Object"; |
| 1118 | if (!strstr(msgString.c_str(),"Dynamic depth bounds state not set for this command buffer")) { |
| 1119 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic depth bounds state not set for this command buffer'"; |
| 1120 | } |
| 1121 | } |
| 1122 | |
| 1123 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1124 | { |
| 1125 | VkFlags msgFlags; |
| 1126 | std::string msgString; |
| 1127 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1128 | m_errorMonitor->ClearState(); |
| 1129 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1130 | |
| 1131 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1132 | |
| 1133 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1134 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Setting a Stencil Read Mask"; |
| 1135 | if (!strstr(msgString.c_str(),"Dynamic stencil read mask state not set for this command buffer")) { |
| 1136 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1141 | { |
| 1142 | VkFlags msgFlags; |
| 1143 | std::string msgString; |
| 1144 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1145 | m_errorMonitor->ClearState(); |
| 1146 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1147 | |
| 1148 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1149 | |
| 1150 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1151 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Setting a Stencil Write Mask"; |
| 1152 | if (!strstr(msgString.c_str(),"Dynamic stencil write mask state not set for this command buffer")) { |
| 1153 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1154 | } |
| 1155 | } |
| 1156 | |
| 1157 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1158 | { |
| 1159 | VkFlags msgFlags; |
| 1160 | std::string msgString; |
| 1161 | m_errorMonitor->ClearState(); |
| 1162 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1163 | |
| 1164 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1165 | |
| 1166 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1167 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Setting a Stencil Reference"; |
| 1168 | if (!strstr(msgString.c_str(),"Dynamic stencil reference state not set for this command buffer")) { |
| 1169 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic stencil reference state not set for this command buffer'"; |
| 1170 | } |
| 1171 | } |
| 1172 | |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1173 | TEST_F(VkLayerTest, CmdBufferTwoSubmits) |
| 1174 | { |
| 1175 | vk_testing::Fence testFence; |
| 1176 | VkFlags msgFlags; |
| 1177 | std::string msgString; |
| 1178 | |
| 1179 | VkFenceCreateInfo fenceInfo = {}; |
| 1180 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1181 | fenceInfo.pNext = NULL; |
| 1182 | fenceInfo.flags = 0; |
| 1183 | |
| 1184 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1185 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1186 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1187 | |
| 1188 | // We luck out b/c by default the framework creates CB w/ the VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT set |
| 1189 | BeginCommandBuffer(); |
| 1190 | m_cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
| 1191 | EndCommandBuffer(); |
| 1192 | |
| 1193 | testFence.init(*m_device, fenceInfo); |
| 1194 | |
| 1195 | // Bypass framework since it does the waits automatically |
| 1196 | VkResult err = VK_SUCCESS; |
| 1197 | err = vkQueueSubmit( m_device->m_queue, 1, &m_cmdBuffer->handle(), testFence.handle()); |
| 1198 | ASSERT_VK_SUCCESS( err ); |
| 1199 | |
| 1200 | m_errorMonitor->ClearState(); |
| 1201 | // Cause validation error by re-submitting cmd buffer that should only be submitted once |
| 1202 | err = vkQueueSubmit( m_device->m_queue, 1, &m_cmdBuffer->handle(), testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1203 | |
| 1204 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1205 | 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] | 1206 | 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] | 1207 | FAIL() << "Error received was not 'CB (0xaddress) was created w/ VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT set...'"; |
| 1208 | } |
| 1209 | } |
| 1210 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1211 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1212 | { |
| 1213 | // Initiate Draw w/o a PSO bound |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1214 | VkFlags msgFlags; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1215 | std::string msgString; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1216 | VkResult err; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1217 | |
| 1218 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1219 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1220 | m_errorMonitor->ClearState(); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1221 | |
| 1222 | VkDescriptorTypeCount ds_type_count = {}; |
| 1223 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1224 | ds_type_count.count = 1; |
| 1225 | |
| 1226 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1227 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1228 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1229 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 1230 | ds_pool_ci.maxSets = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1231 | ds_pool_ci.count = 1; |
| 1232 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 1233 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1234 | VkDescriptorPool ds_pool; |
| 1235 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1236 | ASSERT_VK_SUCCESS(err); |
| 1237 | |
| 1238 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1239 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1240 | dsl_binding.arraySize = 1; |
| 1241 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1242 | dsl_binding.pImmutableSamplers = NULL; |
| 1243 | |
| 1244 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1245 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1246 | ds_layout_ci.pNext = NULL; |
| 1247 | ds_layout_ci.count = 1; |
| 1248 | ds_layout_ci.pBinding = &dsl_binding; |
| 1249 | |
| 1250 | VkDescriptorSetLayout ds_layout; |
| 1251 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 1252 | ASSERT_VK_SUCCESS(err); |
| 1253 | |
| 1254 | VkDescriptorSet descriptorSet; |
| 1255 | err = vkAllocDescriptorSets(m_device->device(), ds_pool, VK_DESCRIPTOR_SET_USAGE_ONE_SHOT, 1, &ds_layout, &descriptorSet); |
| 1256 | ASSERT_VK_SUCCESS(err); |
| 1257 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 1258 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1259 | pipe_ms_state_ci.pNext = NULL; |
| 1260 | pipe_ms_state_ci.rasterSamples = 1; |
| 1261 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1262 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1263 | pipe_ms_state_ci.pSampleMask = NULL; |
| 1264 | |
| 1265 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1266 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1267 | pipeline_layout_ci.pNext = NULL; |
| 1268 | pipeline_layout_ci.descriptorSetCount = 1; |
| 1269 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1270 | VkPipelineLayout pipeline_layout; |
| 1271 | |
| 1272 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 1273 | ASSERT_VK_SUCCESS(err); |
| 1274 | |
| 1275 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX, this); |
| 1276 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT, this); // TODO - We shouldn't need a fragment shader |
| 1277 | // but add it to be able to run on more devices |
| 1278 | VkPipelineObj pipe(m_device); |
| 1279 | pipe.AddShader(&vs); |
| 1280 | pipe.AddShader(&fs); |
| 1281 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1282 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1283 | m_errorMonitor->ClearState(); |
| 1284 | // Calls CreateCommandBuffer |
| 1285 | VkCommandBufferObj cmdBuffer(m_device, m_cmdPool); |
| 1286 | VkCmdBufferBeginInfo cmd_buf_info = {}; |
| 1287 | memset(&cmd_buf_info, 0, sizeof(VkCmdBufferBeginInfo)); |
| 1288 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO; |
| 1289 | cmd_buf_info.pNext = NULL; |
| 1290 | cmd_buf_info.flags = VK_CMD_BUFFER_OPTIMIZE_SMALL_BATCH_BIT | |
| 1291 | VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT; |
| 1292 | |
| 1293 | vkBeginCommandBuffer(cmdBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1294 | vkCmdBindPipeline(cmdBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1295 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1296 | 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] | 1297 | if (!strstr(msgString.c_str(),"Incorrectly binding graphics pipeline ")) { |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1298 | FAIL() << "Error received was not 'Incorrectly binding graphics pipeline (0x<handle>) without an active RenderPass'"; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1299 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1300 | |
| 1301 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
| 1302 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 1303 | ASSERT_VK_SUCCESS(err); |
| 1304 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 1305 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1306 | } |
| 1307 | |
| 1308 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1309 | { |
| 1310 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1311 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1312 | // Attempt to clear DS Pool with bad object |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1313 | /* VkFlags msgFlags; |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1314 | std::string msgString; |
| 1315 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1316 | vkResetDescriptorPool(device(), badPool); |
| 1317 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1318 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1319 | 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] | 1320 | if (!strstr(msgString.c_str(),"Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call")) { |
| 1321 | FAIL() << "Error received was note 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1322 | }*/ |
| 1323 | } |
| 1324 | |
| 1325 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1326 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1327 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1328 | // 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] | 1329 | // Create a valid cmd buffer |
| 1330 | // call vkCmdBindDescriptorSets w/ false DS |
| 1331 | } |
| 1332 | |
| 1333 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1334 | { |
| 1335 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1336 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1337 | } |
| 1338 | |
| 1339 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1340 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1341 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1342 | // 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] | 1343 | // Create a valid cmd buffer |
| 1344 | // call vkCmdBindPipeline w/ false Pipeline |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1345 | // VkFlags msgFlags; |
| 1346 | // std::string msgString; |
| 1347 | // |
| 1348 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1349 | // m_errorMonitor->ClearState(); |
| 1350 | // VkCommandBufferObj cmdBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1351 | // BeginCommandBuffer(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1352 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 1353 | // vkCmdBindPipeline(cmdBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
| 1354 | // msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1355 | // 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] | 1356 | // if (!strstr(msgString.c_str(),"Attempt to bind Pipeline ")) { |
| 1357 | // FAIL() << "Error received was not 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1358 | // } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1359 | } |
| 1360 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1361 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1362 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1363 | // 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] | 1364 | VkFlags msgFlags; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1365 | std::string msgString; |
| 1366 | VkResult err; |
| 1367 | |
| 1368 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1369 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1370 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1371 | m_errorMonitor->ClearState(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1372 | VkDescriptorTypeCount ds_type_count = {}; |
| 1373 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1374 | ds_type_count.count = 1; |
| 1375 | |
| 1376 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1377 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1378 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1379 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 1380 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1381 | ds_pool_ci.count = 1; |
| 1382 | ds_pool_ci.pTypeCount = &ds_type_count; |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1383 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1384 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1385 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1386 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1387 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1388 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1389 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1390 | dsl_binding.arraySize = 1; |
| 1391 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1392 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1393 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1394 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1395 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1396 | ds_layout_ci.pNext = NULL; |
| 1397 | ds_layout_ci.count = 1; |
| 1398 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1399 | VkDescriptorSetLayout ds_layout; |
| 1400 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 1401 | ASSERT_VK_SUCCESS(err); |
| 1402 | |
| 1403 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 1404 | 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] | 1405 | ASSERT_VK_SUCCESS(err); |
| 1406 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1407 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1408 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1409 | pipeline_layout_ci.pNext = NULL; |
| 1410 | pipeline_layout_ci.descriptorSetCount = 1; |
| 1411 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1412 | |
| 1413 | VkPipelineLayout pipeline_layout; |
| 1414 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 1415 | ASSERT_VK_SUCCESS(err); |
| 1416 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 1417 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX, this); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1418 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT, this); // TODO - We shouldn't need a fragment shader |
| 1419 | // but add it to be able to run on more devices |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1420 | |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1421 | VkPipelineObj pipe(m_device); |
| 1422 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1423 | pipe.AddShader(&fs); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1424 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1425 | |
| 1426 | BeginCommandBuffer(); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1427 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1428 | 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] | 1429 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1430 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1431 | 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] | 1432 | if (!strstr(msgString.c_str()," bound but it was never updated. ")) { |
| 1433 | FAIL() << "Error received was not 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1434 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1435 | |
| 1436 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
| 1437 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 1438 | ASSERT_VK_SUCCESS(err); |
| 1439 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 1440 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1441 | } |
| 1442 | |
| 1443 | TEST_F(VkLayerTest, NoBeginCmdBuffer) |
| 1444 | { |
| 1445 | VkFlags msgFlags; |
| 1446 | std::string msgString; |
| 1447 | |
| 1448 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1449 | m_errorMonitor->ClearState(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1450 | VkCommandBufferObj cmdBuffer(m_device, m_cmdPool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1451 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
| 1452 | vkEndCommandBuffer(cmdBuffer.GetBufferHandle()); |
| 1453 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1454 | 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] | 1455 | if (!strstr(msgString.c_str(),"You must call vkBeginCommandBuffer() before this call to ")) { |
| 1456 | FAIL() << "Error received was not 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 1457 | } |
| 1458 | } |
| 1459 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1460 | TEST_F(VkLayerTest, PrimaryCmdBufferFramebufferAndRenderpass) |
| 1461 | { |
| 1462 | VkFlags msgFlags; |
| 1463 | std::string msgString; |
| 1464 | |
| 1465 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1466 | m_errorMonitor->ClearState(); |
| 1467 | |
| 1468 | // Calls CreateCommandBuffer |
| 1469 | VkCommandBufferObj cmdBuffer(m_device, m_cmdPool); |
| 1470 | |
| 1471 | // 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] | 1472 | VkCmdBufferBeginInfo cmd_buf_info = {}; |
| 1473 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO; |
| 1474 | cmd_buf_info.pNext = NULL; |
| 1475 | cmd_buf_info.flags = VK_CMD_BUFFER_OPTIMIZE_SMALL_BATCH_BIT | |
| 1476 | VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT; |
| 1477 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 1478 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 1479 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1480 | |
| 1481 | // The error should be caught by validation of the BeginCommandBuffer call |
| 1482 | vkBeginCommandBuffer(cmdBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1483 | |
| 1484 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1485 | 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] | 1486 | if (!strstr(msgString.c_str(),"may not specify framebuffer or renderpass parameters")) { |
| 1487 | FAIL() << "Error received was not 'vkCreateCommandBuffer(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
| 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | TEST_F(VkLayerTest, SecondaryCmdBufferFramebufferAndRenderpass) |
| 1492 | { |
| 1493 | VkFlags msgFlags; |
| 1494 | std::string msgString; |
| 1495 | VkResult err; |
| 1496 | VkCmdBuffer draw_cmd; |
| 1497 | VkCmdPool cmd_pool; |
| 1498 | |
| 1499 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1500 | m_errorMonitor->ClearState(); |
| 1501 | |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1502 | VkCmdBufferCreateInfo cmd = {}; |
| 1503 | cmd.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO; |
| 1504 | cmd.pNext = NULL; |
| 1505 | cmd.cmdPool = m_cmdPool; |
| 1506 | cmd.level = VK_CMD_BUFFER_LEVEL_SECONDARY; |
| 1507 | cmd.flags = 0; |
| 1508 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1509 | err = vkCreateCommandBuffer(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1510 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1511 | |
| 1512 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1513 | VkCmdBufferBeginInfo cmd_buf_info = {}; |
| 1514 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO; |
| 1515 | cmd_buf_info.pNext = NULL; |
| 1516 | cmd_buf_info.flags = VK_CMD_BUFFER_OPTIMIZE_SMALL_BATCH_BIT | |
| 1517 | VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1518 | |
| 1519 | // The error should be caught by validation of the BeginCommandBuffer call |
| 1520 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 1521 | |
| 1522 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1523 | 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] | 1524 | if (!strstr(msgString.c_str(),"must specify framebuffer and renderpass parameters")) { |
| 1525 | FAIL() << "Error received was not 'vkCreateCommandBuffer(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
| 1526 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1527 | vkDestroyCommandBuffer(m_device->device(), draw_cmd); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1528 | } |
| 1529 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1530 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 1531 | { |
| 1532 | // Attempt to Create Gfx Pipeline w/o a VS |
| 1533 | VkFlags msgFlags; |
| 1534 | std::string msgString; |
| 1535 | VkResult err; |
| 1536 | |
| 1537 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1538 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1539 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1540 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1541 | VkDescriptorTypeCount ds_type_count = {}; |
| 1542 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1543 | ds_type_count.count = 1; |
| 1544 | |
| 1545 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1546 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1547 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1548 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 1549 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1550 | ds_pool_ci.count = 1; |
| 1551 | ds_pool_ci.pTypeCount = &ds_type_count; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1552 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1553 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1554 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1555 | ASSERT_VK_SUCCESS(err); |
| 1556 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1557 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1558 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1559 | dsl_binding.arraySize = 1; |
| 1560 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1561 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1562 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1563 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1564 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1565 | ds_layout_ci.pNext = NULL; |
| 1566 | ds_layout_ci.count = 1; |
| 1567 | ds_layout_ci.pBinding = &dsl_binding; |
| 1568 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1569 | VkDescriptorSetLayout ds_layout; |
| 1570 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 1571 | ASSERT_VK_SUCCESS(err); |
| 1572 | |
| 1573 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 1574 | 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] | 1575 | ASSERT_VK_SUCCESS(err); |
| 1576 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1577 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1578 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1579 | pipeline_layout_ci.pNext = NULL; |
| 1580 | pipeline_layout_ci.descriptorSetCount = 1; |
| 1581 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1582 | |
| 1583 | VkPipelineLayout pipeline_layout; |
| 1584 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 1585 | ASSERT_VK_SUCCESS(err); |
| 1586 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1587 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1588 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 1589 | gp_ci.pNext = NULL; |
| 1590 | gp_ci.stageCount = 0; |
| 1591 | gp_ci.pStages = NULL; |
| 1592 | gp_ci.pVertexInputState = NULL; |
| 1593 | gp_ci.pInputAssemblyState = NULL; |
| 1594 | gp_ci.pTessellationState = NULL; |
| 1595 | gp_ci.pViewportState = NULL; |
| 1596 | gp_ci.pRasterState = NULL; |
| 1597 | gp_ci.pMultisampleState = NULL; |
| 1598 | gp_ci.pDepthStencilState = NULL; |
| 1599 | gp_ci.pColorBlendState = NULL; |
| 1600 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1601 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1602 | gp_ci.renderPass = renderPass(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1603 | |
| 1604 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1605 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 1606 | pc_ci.pNext = NULL; |
| 1607 | pc_ci.initialSize = 0; |
| 1608 | pc_ci.initialData = 0; |
| 1609 | pc_ci.maxSize = 0; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1610 | |
| 1611 | VkPipeline pipeline; |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1612 | VkPipelineCache pipelineCache; |
| 1613 | |
| 1614 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, &pipelineCache); |
| 1615 | ASSERT_VK_SUCCESS(err); |
| 1616 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, &pipeline); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1617 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1618 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1619 | 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] | 1620 | if (!strstr(msgString.c_str(),"Invalid Pipeline CreateInfo State: Vtx Shader required")) { |
| 1621 | FAIL() << "Error received was not 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 1622 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1623 | |
| 1624 | vkDestroyPipelineCache(m_device->device(), pipelineCache); |
| 1625 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
| 1626 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 1627 | ASSERT_VK_SUCCESS(err); |
| 1628 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 1629 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1630 | } |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1631 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 1632 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 1633 | { |
| 1634 | // Attempt to Create Gfx Pipeline w/o a VS |
| 1635 | VkFlags msgFlags; |
| 1636 | std::string msgString; |
| 1637 | VkResult err; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1638 | |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1639 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1640 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1641 | m_errorMonitor->ClearState(); |
| 1642 | |
| 1643 | VkDescriptorTypeCount ds_type_count = {}; |
| 1644 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1645 | ds_type_count.count = 1; |
| 1646 | |
| 1647 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1648 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1649 | ds_pool_ci.pNext = NULL; |
| 1650 | ds_pool_ci.count = 1; |
| 1651 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 1652 | |
| 1653 | VkDescriptorPool ds_pool; |
| 1654 | err = vkCreateDescriptorPool(m_device->device(), VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT, 1, &ds_pool_ci, &ds_pool); |
| 1655 | ASSERT_VK_SUCCESS(err); |
| 1656 | |
| 1657 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1658 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1659 | dsl_binding.arraySize = 1; |
| 1660 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1661 | dsl_binding.pImmutableSamplers = NULL; |
| 1662 | |
| 1663 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1664 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1665 | ds_layout_ci.pNext = NULL; |
| 1666 | ds_layout_ci.count = 1; |
| 1667 | ds_layout_ci.pBinding = &dsl_binding; |
| 1668 | |
| 1669 | VkDescriptorSetLayout ds_layout; |
| 1670 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 1671 | ASSERT_VK_SUCCESS(err); |
| 1672 | |
| 1673 | VkDescriptorSet descriptorSet; |
| 1674 | err = vkAllocDescriptorSets(m_device->device(), ds_pool, VK_DESCRIPTOR_SET_USAGE_ONE_SHOT, 1, &ds_layout, &descriptorSet); |
| 1675 | ASSERT_VK_SUCCESS(err); |
| 1676 | |
| 1677 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1678 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1679 | pipeline_layout_ci.pNext = NULL; |
| 1680 | pipeline_layout_ci.descriptorSetCount = 1; |
| 1681 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1682 | |
| 1683 | VkPipelineLayout pipeline_layout; |
| 1684 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 1685 | ASSERT_VK_SUCCESS(err); |
| 1686 | |
| 1687 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 1688 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 1689 | |
| 1690 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX, this); |
| 1691 | // Just using VS txt for Tess shaders as we don't care about functionality |
| 1692 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESS_CONTROL, this); |
| 1693 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESS_EVALUATION, this); |
| 1694 | |
| 1695 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
| 1696 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX; |
| 1697 | shaderStages[0].shader = vs.handle(); |
| 1698 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
| 1699 | shaderStages[1].stage = VK_SHADER_STAGE_TESS_CONTROL; |
| 1700 | shaderStages[1].shader = tc.handle(); |
| 1701 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
| 1702 | shaderStages[2].stage = VK_SHADER_STAGE_TESS_EVALUATION; |
| 1703 | shaderStages[2].shader = te.handle(); |
| 1704 | |
| 1705 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 1706 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 1707 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH; |
| 1708 | |
| 1709 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 1710 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 1711 | tsCI.patchControlPoints = 0; // This will cause an error |
| 1712 | |
| 1713 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1714 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 1715 | gp_ci.pNext = NULL; |
| 1716 | gp_ci.stageCount = 3; |
| 1717 | gp_ci.pStages = shaderStages; |
| 1718 | gp_ci.pVertexInputState = NULL; |
| 1719 | gp_ci.pInputAssemblyState = &iaCI; |
| 1720 | gp_ci.pTessellationState = &tsCI; |
| 1721 | gp_ci.pViewportState = NULL; |
| 1722 | gp_ci.pRasterState = NULL; |
| 1723 | gp_ci.pMultisampleState = NULL; |
| 1724 | gp_ci.pDepthStencilState = NULL; |
| 1725 | gp_ci.pColorBlendState = NULL; |
| 1726 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1727 | gp_ci.layout = pipeline_layout; |
| 1728 | gp_ci.renderPass = renderPass(); |
| 1729 | |
| 1730 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1731 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 1732 | pc_ci.pNext = NULL; |
| 1733 | pc_ci.initialSize = 0; |
| 1734 | pc_ci.initialData = 0; |
| 1735 | pc_ci.maxSize = 0; |
| 1736 | |
| 1737 | VkPipeline pipeline; |
| 1738 | VkPipelineCache pipelineCache; |
| 1739 | |
| 1740 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, &pipelineCache); |
| 1741 | ASSERT_VK_SUCCESS(err); |
| 1742 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, &pipeline); |
| 1743 | |
| 1744 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1745 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Tess Gfx Pipeline w/ 0 patchControlPoints."; |
| 1746 | if (!strstr(msgString.c_str(),"Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive ")) { |
| 1747 | FAIL() << "Error received was not 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...' but instead '" << msgString.c_str() << "'"; |
| 1748 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1749 | |
| 1750 | vkDestroyPipelineCache(m_device->device(), pipelineCache); |
| 1751 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
| 1752 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 1753 | ASSERT_VK_SUCCESS(err); |
| 1754 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 1755 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1756 | } |
| 1757 | */ |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 1758 | TEST_F(VkLayerTest, NullRenderPass) |
| 1759 | { |
| 1760 | // Bind a NULL RenderPass |
| 1761 | VkFlags msgFlags; |
| 1762 | std::string msgString; |
| 1763 | |
| 1764 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1765 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1766 | m_errorMonitor->ClearState(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 1767 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1768 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 1769 | // 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] | 1770 | vkCmdBeginRenderPass(m_cmdBuffer->GetBufferHandle(), NULL, VK_RENDER_PASS_CONTENTS_INLINE); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 1771 | |
| 1772 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1773 | 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] | 1774 | if (!strstr(msgString.c_str(),"You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()")) { |
| 1775 | FAIL() << "Error received was not 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 1776 | } |
| 1777 | } |
| 1778 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1779 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 1780 | { |
| 1781 | // Bind a BeginRenderPass within an active RenderPass |
| 1782 | VkFlags msgFlags; |
| 1783 | std::string msgString; |
| 1784 | |
| 1785 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1786 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1787 | m_errorMonitor->ClearState(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1788 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1789 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 1790 | // 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] | 1791 | VkRenderPassBeginInfo rp_begin = {}; |
| 1792 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 1793 | rp_begin.pNext = NULL; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1794 | rp_begin.renderPass = renderPass(); |
| 1795 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1796 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1797 | vkCmdBeginRenderPass(m_cmdBuffer->GetBufferHandle(), &rp_begin, VK_RENDER_PASS_CONTENTS_INLINE); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1798 | |
| 1799 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1800 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding RenderPass w/i an active RenderPass."; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1801 | if (!strstr(msgString.c_str(),"Cannot call vkCmdBeginRenderPass() during an active RenderPass ")) { |
| 1802 | FAIL() << "Error received was not 'Cannot call vkCmdBeginRenderPass() during an active RenderPass...'"; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1803 | } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1804 | } |
| 1805 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 1806 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 1807 | { |
| 1808 | // Call CmdFillBuffer within an active renderpass |
| 1809 | VkFlags msgFlags; |
| 1810 | std::string msgString; |
| 1811 | |
| 1812 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1813 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1814 | m_errorMonitor->ClearState(); |
| 1815 | |
| 1816 | // Renderpass is started here |
| 1817 | BeginCommandBuffer(); |
| 1818 | |
| 1819 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 1820 | vk_testing::Buffer destBuffer; |
| 1821 | destBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
| 1822 | |
| 1823 | m_cmdBuffer->FillBuffer(destBuffer.handle(), 0, 4, 0x11111111); |
| 1824 | |
| 1825 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1826 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 1827 | "Did not receive error after calling CmdFillBuffer w/i an active RenderPass."; |
| 1828 | if (!strstr(msgString.c_str(),"CmdFillBuffer cmd issued within an active RenderPass")) { |
| 1829 | FAIL() << "Error received was not 'CmdFillBuffer cmd issued within an active RenderPass'"; |
| 1830 | } |
| 1831 | } |
| 1832 | |
| 1833 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 1834 | { |
| 1835 | // Call CmdUpdateBuffer within an active renderpass |
| 1836 | VkFlags msgFlags; |
| 1837 | std::string msgString; |
| 1838 | |
| 1839 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1840 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1841 | m_errorMonitor->ClearState(); |
| 1842 | |
| 1843 | // Renderpass is started here |
| 1844 | BeginCommandBuffer(); |
| 1845 | |
| 1846 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 1847 | vk_testing::Buffer destBuffer; |
| 1848 | destBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
| 1849 | |
| 1850 | VkDeviceSize destOffset = 0; |
| 1851 | VkDeviceSize dataSize = 1024; |
| 1852 | const uint32_t *pData = NULL; |
| 1853 | |
| 1854 | vkCmdUpdateBuffer(m_cmdBuffer->GetBufferHandle(), destBuffer.handle(), destOffset, dataSize, pData); |
| 1855 | |
| 1856 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1857 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 1858 | "Did not receive error after calling CmdUpdateBuffer w/i an active RenderPass."; |
| 1859 | if (!strstr(msgString.c_str(),"CmdUpdateBuffer cmd issued within an active RenderPass")) { |
| 1860 | FAIL() << "Error received was not 'CmdUpdateBuffer cmd issued within an active RenderPass'"; |
| 1861 | } |
| 1862 | } |
| 1863 | |
| 1864 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 1865 | { |
| 1866 | // Call CmdClearColorImage within an active RenderPass |
| 1867 | VkFlags msgFlags; |
| 1868 | std::string msgString; |
| 1869 | |
| 1870 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1871 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1872 | m_errorMonitor->ClearState(); |
| 1873 | |
| 1874 | // Renderpass is started here |
| 1875 | BeginCommandBuffer(); |
| 1876 | |
| 1877 | VkClearColorValue clear_color = {0}; |
| 1878 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 1879 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1880 | const int32_t tex_width = 32; |
| 1881 | const int32_t tex_height = 32; |
| 1882 | VkImageCreateInfo image_create_info = {}; |
| 1883 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1884 | image_create_info.pNext = NULL; |
| 1885 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1886 | image_create_info.format = tex_format; |
| 1887 | image_create_info.extent.width = tex_width; |
| 1888 | image_create_info.extent.height = tex_height; |
| 1889 | image_create_info.extent.depth = 1; |
| 1890 | image_create_info.mipLevels = 1; |
| 1891 | image_create_info.arraySize = 1; |
| 1892 | image_create_info.samples = 1; |
| 1893 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1894 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1895 | |
| 1896 | vk_testing::Image destImage; |
| 1897 | destImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
| 1898 | |
| 1899 | const VkImageSubresourceRange range = |
| 1900 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 1901 | |
| 1902 | vkCmdClearColorImage(m_cmdBuffer->GetBufferHandle(), |
| 1903 | destImage.handle(), |
| 1904 | VK_IMAGE_LAYOUT_GENERAL, |
| 1905 | &clear_color, |
| 1906 | 1, |
| 1907 | &range); |
| 1908 | |
| 1909 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1910 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 1911 | "Did not receive error after calling CmdClearColorImage w/i an active RenderPass."; |
| 1912 | if (!strstr(msgString.c_str(),"CmdClearColorImage cmd issued within an active RenderPass")) { |
| 1913 | FAIL() << "Error received was not 'CmdClearColorImage cmd issued within an active RenderPass'"; |
| 1914 | } |
| 1915 | } |
| 1916 | |
| 1917 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 1918 | { |
| 1919 | // Call CmdClearDepthStencilImage within an active RenderPass |
| 1920 | VkFlags msgFlags; |
| 1921 | std::string msgString; |
| 1922 | |
| 1923 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1924 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1925 | m_errorMonitor->ClearState(); |
| 1926 | |
| 1927 | // Renderpass is started here |
| 1928 | BeginCommandBuffer(); |
| 1929 | |
| 1930 | VkClearDepthStencilValue clear_value = {0}; |
| 1931 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 1932 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 1933 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1934 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 1935 | image_create_info.extent.width = 64; |
| 1936 | image_create_info.extent.height = 64; |
| 1937 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 1938 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 1939 | |
| 1940 | vk_testing::Image destImage; |
| 1941 | destImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
| 1942 | |
| 1943 | const VkImageSubresourceRange range = |
| 1944 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 1945 | |
| 1946 | vkCmdClearDepthStencilImage(m_cmdBuffer->GetBufferHandle(), |
| 1947 | destImage.handle(), |
| 1948 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 1949 | &clear_value, |
| 1950 | 1, |
| 1951 | &range); |
| 1952 | |
| 1953 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1954 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 1955 | "Did not receive error after calling CmdClearDepthStencilImage w/i an active RenderPass."; |
| 1956 | if (!strstr(msgString.c_str(),"CmdClearDepthStencilImage cmd issued within an active RenderPass")) { |
| 1957 | FAIL() << "Error received was not 'CmdClearDepthStencilImage cmd issued within an active RenderPass'"; |
| 1958 | } |
| 1959 | } |
| 1960 | |
| 1961 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 1962 | { |
| 1963 | // Call CmdClearColorAttachments outside of an active RenderPass |
| 1964 | VkFlags msgFlags; |
| 1965 | std::string msgString; |
| 1966 | VkResult err; |
| 1967 | |
| 1968 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1969 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1970 | m_errorMonitor->ClearState(); |
| 1971 | |
| 1972 | // Start no RenderPass |
| 1973 | err = m_cmdBuffer->BeginCommandBuffer(); |
| 1974 | ASSERT_VK_SUCCESS(err); |
| 1975 | |
| 1976 | VkClearColorValue clear_color = {0}; |
| 1977 | VkRect3D clear_rect = { { 0, 0, 0 }, { 32, 32, 1 } }; |
| 1978 | |
| 1979 | vkCmdClearColorAttachment(m_cmdBuffer->GetBufferHandle(), 0, |
| 1980 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 1981 | &clear_color, 1, &clear_rect); |
| 1982 | |
| 1983 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1984 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 1985 | "Did not receive error after calling CmdClearColorAttachment outside of an active RenderPass."; |
| 1986 | if (!strstr(msgString.c_str(),"CmdClearColorAttachment cmd issued outside of an active RenderPass")) { |
| 1987 | FAIL() << "Error received was not 'CmdClearColorAttachment cmd issued outside of an active RenderPass'"; |
| 1988 | } |
| 1989 | } |
| 1990 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1991 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 1992 | { |
| 1993 | // Create a valid cmd buffer |
| 1994 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1995 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1996 | // 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] | 1997 | } |
Tobin Ehlis | 201b1ba | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 1998 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1999 | TEST_F(VkLayerTest, VtxBufferNoRenderPass) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2000 | { |
| 2001 | // Bind VBO out-of-bounds for given PSO |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2002 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2003 | std::string msgString; |
| 2004 | VkResult err; |
| 2005 | |
| 2006 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2007 | m_errorMonitor->ClearState(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2008 | |
| 2009 | VkDescriptorTypeCount ds_type_count = {}; |
| 2010 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2011 | ds_type_count.count = 1; |
| 2012 | |
| 2013 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2014 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2015 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2016 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 2017 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2018 | ds_pool_ci.count = 1; |
| 2019 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2020 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2021 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2022 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2023 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2024 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2025 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2026 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2027 | dsl_binding.arraySize = 1; |
| 2028 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2029 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2030 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2031 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2032 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2033 | ds_layout_ci.pNext = NULL; |
| 2034 | ds_layout_ci.count = 1; |
| 2035 | ds_layout_ci.pBinding = &dsl_binding; |
| 2036 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2037 | VkDescriptorSetLayout ds_layout; |
| 2038 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2039 | ASSERT_VK_SUCCESS(err); |
| 2040 | |
| 2041 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2042 | 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] | 2043 | ASSERT_VK_SUCCESS(err); |
| 2044 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2045 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2046 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2047 | pipeline_layout_ci.pNext = NULL; |
| 2048 | pipeline_layout_ci.descriptorSetCount = 1; |
| 2049 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2050 | |
| 2051 | VkPipelineLayout pipeline_layout; |
| 2052 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 2053 | ASSERT_VK_SUCCESS(err); |
| 2054 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 2055 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX, this); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2056 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT, this); // TODO - We shouldn't need a fragment shader |
| 2057 | // but add it to be able to run on more devices |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 2058 | VkPipelineObj pipe(m_device); |
| 2059 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2060 | pipe.AddShader(&fs); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 2061 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2062 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2063 | BeginCommandBuffer(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2064 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 2065 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2066 | // Should error before calling to driver so don't care about actual data |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2067 | vkCmdBindVertexBuffers(m_cmdBuffer->GetBufferHandle(), 0, 1, NULL, NULL); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2068 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2069 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2070 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after vkCmdBindVertexBuffers() w/o active RenderPass."; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2071 | if (!strstr(msgString.c_str(),"Incorrect call to vkCmdBindVertexBuffers() without an active RenderPass.")) { |
| 2072 | FAIL() << "Error received was not 'Incorrect call to vkCmdBindVertexBuffers() without an active RenderPass.'"; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2073 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2074 | |
| 2075 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
| 2076 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 2077 | ASSERT_VK_SUCCESS(err); |
| 2078 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2079 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2080 | } |
| 2081 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2082 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 2083 | { |
| 2084 | // Bind a BeginRenderPass within an active RenderPass |
| 2085 | VkFlags msgFlags; |
| 2086 | std::string msgString; |
| 2087 | VkResult err; |
| 2088 | |
| 2089 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2090 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2091 | m_errorMonitor->ClearState(); |
| 2092 | uint32_t qfi = 0; |
| 2093 | VkBufferCreateInfo buffCI = {}; |
| 2094 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2095 | buffCI.size = 1024; |
| 2096 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 2097 | buffCI.queueFamilyCount = 1; |
| 2098 | buffCI.pQueueFamilyIndices = &qfi; |
| 2099 | |
| 2100 | VkBuffer ib; |
| 2101 | err = vkCreateBuffer(m_device->device(), &buffCI, &ib); |
| 2102 | ASSERT_VK_SUCCESS(err); |
| 2103 | |
| 2104 | BeginCommandBuffer(); |
| 2105 | ASSERT_VK_SUCCESS(err); |
| 2106 | //vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2107 | // Should error before calling to driver so don't care about actual data |
| 2108 | vkCmdBindIndexBuffer(m_cmdBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
| 2109 | |
| 2110 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2111 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after vkCmdBindVertexBuffers() w/o active RenderPass."; |
| 2112 | if (!strstr(msgString.c_str(),"vkCmdBindIndexBuffer() offset (0x7) does not fall on ")) { |
| 2113 | FAIL() << "Error received was not 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...' but instead '" << msgString.c_str() << "'"; |
| 2114 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2115 | |
| 2116 | vkDestroyBuffer(m_device->device(), ib); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2117 | } |
| 2118 | |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2119 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 2120 | { |
| 2121 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
| 2122 | VkFlags msgFlags; |
| 2123 | std::string msgString; |
| 2124 | |
| 2125 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2126 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2127 | m_errorMonitor->ClearState(); |
| 2128 | |
| 2129 | BeginCommandBuffer(); |
| 2130 | //ASSERT_VK_SUCCESS(err); |
| 2131 | VkCmdBuffer primCB = m_cmdBuffer->GetBufferHandle(); |
| 2132 | vkCmdExecuteCommands(m_cmdBuffer->GetBufferHandle(), 1, &primCB); |
| 2133 | |
| 2134 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2135 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after vkCmdBindVertexBuffers() w/o active RenderPass."; |
| 2136 | if (!strstr(msgString.c_str(),"vkCmdExecuteCommands() called w/ Primary Cmd Buffer ")) { |
| 2137 | FAIL() << "Error received was not 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer ' but instead '" << msgString.c_str() << "'"; |
| 2138 | } |
| 2139 | } |
| 2140 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2141 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 2142 | { |
| 2143 | // 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] | 2144 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2145 | std::string msgString; |
| 2146 | VkResult err; |
| 2147 | |
| 2148 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2149 | m_errorMonitor->ClearState(); |
| 2150 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2151 | VkDescriptorTypeCount ds_type_count = {}; |
| 2152 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2153 | ds_type_count.count = 1; |
| 2154 | |
| 2155 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2156 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2157 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2158 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 2159 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2160 | ds_pool_ci.count = 1; |
| 2161 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2162 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2163 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2164 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2165 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2166 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2167 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2168 | dsl_binding.arraySize = 1; |
| 2169 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2170 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2171 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2172 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2173 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2174 | ds_layout_ci.pNext = NULL; |
| 2175 | ds_layout_ci.count = 1; |
| 2176 | ds_layout_ci.pBinding = &dsl_binding; |
| 2177 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2178 | VkDescriptorSetLayout ds_layout; |
| 2179 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2180 | ASSERT_VK_SUCCESS(err); |
| 2181 | |
| 2182 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2183 | 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] | 2184 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2185 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2186 | VkSamplerCreateInfo sampler_ci = {}; |
| 2187 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2188 | sampler_ci.pNext = NULL; |
| 2189 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 2190 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 2191 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 5162441 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 2192 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2193 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2194 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2195 | sampler_ci.mipLodBias = 1.0; |
| 2196 | sampler_ci.maxAnisotropy = 1; |
| 2197 | sampler_ci.compareEnable = VK_FALSE; |
| 2198 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2199 | sampler_ci.minLod = 1.0; |
| 2200 | sampler_ci.maxLod = 1.0; |
| 2201 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2202 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 2203 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2204 | VkSampler sampler; |
| 2205 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 2206 | ASSERT_VK_SUCCESS(err); |
| 2207 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2208 | VkDescriptorInfo descriptor_info; |
| 2209 | memset(&descriptor_info, 0, sizeof(descriptor_info)); |
| 2210 | descriptor_info.sampler = sampler; |
| 2211 | |
| 2212 | VkWriteDescriptorSet descriptor_write; |
| 2213 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2214 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2215 | descriptor_write.destSet = descriptorSet; |
| 2216 | descriptor_write.count = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2217 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2218 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2219 | descriptor_write.pDescriptors = &descriptor_info; |
| 2220 | |
| 2221 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2222 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2223 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2224 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating BUFFER Descriptor w/ incorrect type of SAMPLER."; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2225 | if (!strstr(msgString.c_str(),"Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET does not match ")) { |
| 2226 | FAIL() << "Error received was not 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET does not match overlapping binding type!'"; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2227 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2228 | |
| 2229 | vkDestroySampler(m_device->device(), sampler); |
| 2230 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 2231 | ASSERT_VK_SUCCESS(err); |
| 2232 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2233 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2234 | } |
| 2235 | |
| 2236 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 2237 | { |
| 2238 | // For overlapping Update, have arrayIndex exceed that of layout |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2239 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2240 | std::string msgString; |
| 2241 | VkResult err; |
| 2242 | |
| 2243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2244 | m_errorMonitor->ClearState(); |
| 2245 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2246 | VkDescriptorTypeCount ds_type_count = {}; |
| 2247 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2248 | ds_type_count.count = 1; |
| 2249 | |
| 2250 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2251 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2252 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2253 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 2254 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2255 | ds_pool_ci.count = 1; |
| 2256 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2257 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2258 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2259 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2260 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2261 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2262 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2263 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2264 | dsl_binding.arraySize = 1; |
| 2265 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2266 | dsl_binding.pImmutableSamplers = NULL; |
| 2267 | |
| 2268 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2269 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2270 | ds_layout_ci.pNext = NULL; |
| 2271 | ds_layout_ci.count = 1; |
| 2272 | ds_layout_ci.pBinding = &dsl_binding; |
| 2273 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2274 | VkDescriptorSetLayout ds_layout; |
| 2275 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2276 | ASSERT_VK_SUCCESS(err); |
| 2277 | |
| 2278 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2279 | 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] | 2280 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2281 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2282 | VkSamplerCreateInfo sampler_ci = {}; |
| 2283 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2284 | sampler_ci.pNext = NULL; |
| 2285 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 2286 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 2287 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 5162441 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 2288 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2289 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2290 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2291 | sampler_ci.mipLodBias = 1.0; |
| 2292 | sampler_ci.maxAnisotropy = 1; |
| 2293 | sampler_ci.compareEnable = VK_FALSE; |
| 2294 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2295 | sampler_ci.minLod = 1.0; |
| 2296 | sampler_ci.maxLod = 1.0; |
| 2297 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2298 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2299 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2300 | VkSampler sampler; |
| 2301 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 2302 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2303 | |
| 2304 | VkDescriptorInfo descriptor_info; |
| 2305 | memset(&descriptor_info, 0, sizeof(descriptor_info)); |
| 2306 | descriptor_info.sampler = sampler; |
| 2307 | |
| 2308 | VkWriteDescriptorSet descriptor_write; |
| 2309 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2310 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2311 | descriptor_write.destSet = descriptorSet; |
| 2312 | descriptor_write.destArrayElement = 1; /* This index out of bounds for the update */ |
| 2313 | descriptor_write.count = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2314 | // 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] | 2315 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2316 | descriptor_write.pDescriptors = &descriptor_info; |
| 2317 | |
| 2318 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2319 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2320 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2321 | 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] | 2322 | if (!strstr(msgString.c_str(),"Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding")) { |
| 2323 | 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] | 2324 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2325 | |
| 2326 | vkDestroySampler(m_device->device(), sampler); |
| 2327 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 2328 | ASSERT_VK_SUCCESS(err); |
| 2329 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2330 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2331 | } |
| 2332 | |
| 2333 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 2334 | { |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2335 | // 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] | 2336 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2337 | std::string msgString; |
| 2338 | VkResult err; |
| 2339 | |
| 2340 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2341 | m_errorMonitor->ClearState(); |
| 2342 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2343 | VkDescriptorTypeCount ds_type_count = {}; |
| 2344 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2345 | ds_type_count.count = 1; |
| 2346 | |
| 2347 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2348 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2349 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2350 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 2351 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2352 | ds_pool_ci.count = 1; |
| 2353 | ds_pool_ci.pTypeCount = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2354 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2355 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2356 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2357 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2358 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2359 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2360 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2361 | dsl_binding.arraySize = 1; |
| 2362 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2363 | dsl_binding.pImmutableSamplers = NULL; |
| 2364 | |
| 2365 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2366 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2367 | ds_layout_ci.pNext = NULL; |
| 2368 | ds_layout_ci.count = 1; |
| 2369 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2370 | VkDescriptorSetLayout ds_layout; |
| 2371 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2372 | ASSERT_VK_SUCCESS(err); |
| 2373 | |
| 2374 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2375 | 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] | 2376 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2377 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2378 | VkSamplerCreateInfo sampler_ci = {}; |
| 2379 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2380 | sampler_ci.pNext = NULL; |
| 2381 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 2382 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 2383 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 5162441 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 2384 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2385 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2386 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2387 | sampler_ci.mipLodBias = 1.0; |
| 2388 | sampler_ci.maxAnisotropy = 1; |
| 2389 | sampler_ci.compareEnable = VK_FALSE; |
| 2390 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2391 | sampler_ci.minLod = 1.0; |
| 2392 | sampler_ci.maxLod = 1.0; |
| 2393 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2394 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2395 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2396 | VkSampler sampler; |
| 2397 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 2398 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2399 | |
| 2400 | VkDescriptorInfo descriptor_info; |
| 2401 | memset(&descriptor_info, 0, sizeof(descriptor_info)); |
| 2402 | descriptor_info.sampler = sampler; |
| 2403 | |
| 2404 | VkWriteDescriptorSet descriptor_write; |
| 2405 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2406 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2407 | descriptor_write.destSet = descriptorSet; |
| 2408 | descriptor_write.destBinding = 2; |
| 2409 | descriptor_write.count = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2410 | // 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] | 2411 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2412 | descriptor_write.pDescriptors = &descriptor_info; |
| 2413 | |
| 2414 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2415 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2416 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2417 | 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] | 2418 | if (!strstr(msgString.c_str()," does not have binding to match update binding ")) { |
| 2419 | FAIL() << "Error received was not 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 2420 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2421 | |
| 2422 | vkDestroySampler(m_device->device(), sampler); |
| 2423 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 2424 | ASSERT_VK_SUCCESS(err); |
| 2425 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2426 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2427 | } |
| 2428 | |
| 2429 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 2430 | { |
| 2431 | // 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] | 2432 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2433 | std::string msgString; |
| 2434 | VkResult err; |
| 2435 | |
| 2436 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2437 | m_errorMonitor->ClearState(); |
| 2438 | //VkDescriptorSetObj descriptorSet(m_device); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2439 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2440 | VkDescriptorTypeCount ds_type_count = {}; |
| 2441 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2442 | ds_type_count.count = 1; |
| 2443 | |
| 2444 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2445 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2446 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2447 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 2448 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2449 | ds_pool_ci.count = 1; |
| 2450 | ds_pool_ci.pTypeCount = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2451 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2452 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2453 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2454 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2455 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2456 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2457 | dsl_binding.arraySize = 1; |
| 2458 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2459 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2460 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2461 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2462 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2463 | ds_layout_ci.pNext = NULL; |
| 2464 | ds_layout_ci.count = 1; |
| 2465 | ds_layout_ci.pBinding = &dsl_binding; |
| 2466 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2467 | VkDescriptorSetLayout ds_layout; |
| 2468 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2469 | ASSERT_VK_SUCCESS(err); |
| 2470 | |
| 2471 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2472 | 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] | 2473 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2474 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2475 | VkSamplerCreateInfo sampler_ci = {}; |
| 2476 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2477 | sampler_ci.pNext = NULL; |
| 2478 | sampler_ci.magFilter = VK_TEX_FILTER_NEAREST; |
| 2479 | sampler_ci.minFilter = VK_TEX_FILTER_NEAREST; |
| 2480 | sampler_ci.mipMode = VK_TEX_MIPMAP_MODE_BASE; |
Courtney Goeltzenleuchter | 5162441 | 2015-09-10 14:08:50 -0600 | [diff] [blame] | 2481 | sampler_ci.addressModeU = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2482 | sampler_ci.addressModeV = VK_TEX_ADDRESS_MODE_CLAMP; |
| 2483 | sampler_ci.addressModeW = VK_TEX_ADDRESS_MODE_CLAMP; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2484 | sampler_ci.mipLodBias = 1.0; |
| 2485 | sampler_ci.maxAnisotropy = 1; |
| 2486 | sampler_ci.compareEnable = VK_FALSE; |
| 2487 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2488 | sampler_ci.minLod = 1.0; |
| 2489 | sampler_ci.maxLod = 1.0; |
| 2490 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2491 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2492 | VkSampler sampler; |
| 2493 | err = vkCreateSampler(m_device->device(), &sampler_ci, &sampler); |
| 2494 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2495 | |
| 2496 | |
| 2497 | VkDescriptorInfo descriptor_info; |
| 2498 | memset(&descriptor_info, 0, sizeof(descriptor_info)); |
| 2499 | descriptor_info.sampler = sampler; |
| 2500 | |
| 2501 | VkWriteDescriptorSet descriptor_write; |
| 2502 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2503 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
| 2504 | descriptor_write.destSet = descriptorSet; |
| 2505 | descriptor_write.count = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2506 | // 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] | 2507 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2508 | descriptor_write.pDescriptors = &descriptor_info; |
| 2509 | |
| 2510 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2511 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2512 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2513 | 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] | 2514 | if (!strstr(msgString.c_str(),"Unexpected UPDATE struct of type ")) { |
| 2515 | FAIL() << "Error received was not 'Unexpected UPDATE struct of type '"; |
| 2516 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2517 | |
| 2518 | vkDestroySampler(m_device->device(), sampler); |
| 2519 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 2520 | ASSERT_VK_SUCCESS(err); |
| 2521 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2522 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2523 | } |
| 2524 | |
| 2525 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 2526 | { |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2527 | // Create CmdBuffer where MSAA samples doesn't match RenderPass sampleCount |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2528 | VkFlags msgFlags; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2529 | std::string msgString; |
| 2530 | VkResult err; |
| 2531 | |
| 2532 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2533 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2534 | m_errorMonitor->ClearState(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2535 | VkDescriptorTypeCount ds_type_count = {}; |
| 2536 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2537 | ds_type_count.count = 1; |
| 2538 | |
| 2539 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2540 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2541 | ds_pool_ci.pNext = NULL; |
| 2542 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 2543 | ds_pool_ci.maxSets = 1; |
| 2544 | ds_pool_ci.count = 1; |
| 2545 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2546 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2547 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2548 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2549 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2550 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2551 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2552 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2553 | dsl_binding.arraySize = 1; |
| 2554 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2555 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2556 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2557 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2558 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2559 | ds_layout_ci.pNext = NULL; |
| 2560 | ds_layout_ci.count = 1; |
| 2561 | ds_layout_ci.pBinding = &dsl_binding; |
| 2562 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2563 | VkDescriptorSetLayout ds_layout; |
| 2564 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2565 | ASSERT_VK_SUCCESS(err); |
| 2566 | |
| 2567 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2568 | 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] | 2569 | ASSERT_VK_SUCCESS(err); |
| 2570 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2571 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 2572 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 2573 | pipe_ms_state_ci.pNext = NULL; |
| 2574 | pipe_ms_state_ci.rasterSamples = 4; |
| 2575 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 2576 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 2577 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2578 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2579 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2580 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2581 | pipeline_layout_ci.pNext = NULL; |
| 2582 | pipeline_layout_ci.descriptorSetCount = 1; |
| 2583 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2584 | |
| 2585 | VkPipelineLayout pipeline_layout; |
| 2586 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 2587 | ASSERT_VK_SUCCESS(err); |
| 2588 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 2589 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX, this); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2590 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT, this); // TODO - We shouldn't need a fragment shader |
| 2591 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 2592 | VkPipelineObj pipe(m_device); |
| 2593 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2594 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 2595 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 2596 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2597 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2598 | BeginCommandBuffer(); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 2599 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2600 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2601 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2602 | 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] | 2603 | if (!strstr(msgString.c_str(),"Num samples mismatch! ")) { |
| 2604 | FAIL() << "Error received was not 'Num samples mismatch!...'"; |
| 2605 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2606 | |
| 2607 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
| 2608 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 2609 | ASSERT_VK_SUCCESS(err); |
| 2610 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2611 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2612 | } |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2613 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2614 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 2615 | { |
| 2616 | // Create CmdBuffer where we add ClearCmd for FB Color attachment prior to issuing a Draw |
| 2617 | VkFlags msgFlags; |
| 2618 | std::string msgString; |
| 2619 | VkResult err; |
| 2620 | |
| 2621 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2622 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2623 | m_errorMonitor->ClearState(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2624 | |
| 2625 | VkDescriptorTypeCount ds_type_count = {}; |
| 2626 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2627 | ds_type_count.count = 1; |
| 2628 | |
| 2629 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2630 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2631 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2632 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 2633 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2634 | ds_pool_ci.count = 1; |
| 2635 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2636 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2637 | VkDescriptorPool ds_pool; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2638 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2639 | ASSERT_VK_SUCCESS(err); |
| 2640 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2641 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2642 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2643 | dsl_binding.arraySize = 1; |
| 2644 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2645 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2646 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2647 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2648 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2649 | ds_layout_ci.pNext = NULL; |
| 2650 | ds_layout_ci.count = 1; |
| 2651 | ds_layout_ci.pBinding = &dsl_binding; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2652 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2653 | VkDescriptorSetLayout ds_layout; |
| 2654 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2655 | ASSERT_VK_SUCCESS(err); |
| 2656 | |
| 2657 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2658 | 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] | 2659 | ASSERT_VK_SUCCESS(err); |
| 2660 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2661 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 2662 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 2663 | pipe_ms_state_ci.pNext = NULL; |
| 2664 | pipe_ms_state_ci.rasterSamples = 4; |
| 2665 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 2666 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 2667 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2668 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2669 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2670 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2671 | pipeline_layout_ci.pNext = NULL; |
| 2672 | pipeline_layout_ci.descriptorSetCount = 1; |
| 2673 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2674 | |
| 2675 | VkPipelineLayout pipeline_layout; |
| 2676 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 2677 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2678 | |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 2679 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX, this); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2680 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT, this); // TODO - We shouldn't need a fragment shader |
| 2681 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 2682 | VkPipelineObj pipe(m_device); |
| 2683 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2684 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 2685 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 2686 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2687 | |
| 2688 | BeginCommandBuffer(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2689 | |
| 2690 | m_errorMonitor->ClearState(); |
| 2691 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 2692 | // Also pass down other dummy params to keep driver and paramchecker happy |
| 2693 | VkClearColorValue cCV; |
Cody Northrop | 2563a03 | 2015-08-25 15:26:38 -0600 | [diff] [blame] | 2694 | cCV.float32[0] = 1.0; |
| 2695 | cCV.float32[1] = 1.0; |
| 2696 | cCV.float32[2] = 1.0; |
| 2697 | cCV.float32[3] = 1.0; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2698 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2699 | vkCmdClearColorAttachment(m_cmdBuffer->GetBufferHandle(), 0, (VkImageLayout)NULL, &cCV, 0, NULL); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2700 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2701 | 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."; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2702 | if (!strstr(msgString.c_str(),"vkCmdClearColorAttachment() issued on CB object ")) { |
| 2703 | FAIL() << "Error received was not 'vkCmdClearColorAttachment() issued on CB object...'"; |
| 2704 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2705 | |
| 2706 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
| 2707 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 2708 | ASSERT_VK_SUCCESS(err); |
| 2709 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2710 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2711 | } |
| 2712 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2713 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 2714 | { |
| 2715 | // Create CmdBuffer where MSAA samples doesn't match RenderPass sampleCount |
| 2716 | VkFlags msgFlags; |
| 2717 | std::string msgString; |
| 2718 | VkResult err; |
| 2719 | |
| 2720 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2721 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2722 | m_errorMonitor->ClearState(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2723 | |
| 2724 | VkDescriptorTypeCount ds_type_count = {}; |
| 2725 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2726 | ds_type_count.count = 1; |
| 2727 | |
| 2728 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2729 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2730 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2731 | ds_pool_ci.poolUsage = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT; |
| 2732 | ds_pool_ci.maxSets = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2733 | ds_pool_ci.count = 1; |
| 2734 | ds_pool_ci.pTypeCount = &ds_type_count; |
| 2735 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2736 | VkDescriptorPool ds_pool; |
| 2737 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, &ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2738 | ASSERT_VK_SUCCESS(err); |
| 2739 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2740 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2741 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2742 | dsl_binding.arraySize = 1; |
| 2743 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2744 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2745 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2746 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2747 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2748 | ds_layout_ci.pNext = NULL; |
| 2749 | ds_layout_ci.count = 1; |
| 2750 | ds_layout_ci.pBinding = &dsl_binding; |
| 2751 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2752 | VkDescriptorSetLayout ds_layout; |
| 2753 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, &ds_layout); |
| 2754 | ASSERT_VK_SUCCESS(err); |
| 2755 | |
| 2756 | VkDescriptorSet descriptorSet; |
Cody Northrop | c8aa4a5 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2757 | 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] | 2758 | ASSERT_VK_SUCCESS(err); |
| 2759 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2760 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 2761 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 2762 | pipe_ms_state_ci.pNext = NULL; |
| 2763 | pipe_ms_state_ci.rasterSamples = 1; |
| 2764 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 2765 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 2766 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2767 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2768 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2769 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2770 | pipeline_layout_ci.pNext = NULL; |
| 2771 | pipeline_layout_ci.descriptorSetCount = 1; |
| 2772 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2773 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2774 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2775 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, &pipeline_layout); |
| 2776 | ASSERT_VK_SUCCESS(err); |
| 2777 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 2778 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX, this); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2779 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT, this); // TODO - We shouldn't need a fragment shader |
| 2780 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 2781 | VkPipelineObj pipe(m_device); |
| 2782 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2783 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 2784 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 2785 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2786 | |
| 2787 | BeginCommandBuffer(); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 2788 | vkCmdBindPipeline(m_cmdBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | d28acef | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 2789 | // Don't care about actual data, just need to get to draw to flag error |
| 2790 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 2791 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 2792 | 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] | 2793 | Draw(1, 0, 0, 0); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2794 | |
| 2795 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2796 | 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] | 2797 | if (!strstr(msgString.c_str(),"Vtx Buffer Index 1 was bound, but no vtx buffers are attached to PSO.")) { |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2798 | FAIL() << "Error received was not 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.'"; |
| 2799 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2800 | |
| 2801 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout); |
| 2802 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 2803 | ASSERT_VK_SUCCESS(err); |
| 2804 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout); |
| 2805 | vkDestroyDescriptorPool(m_device->device(), ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2806 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2807 | #endif // DRAW_STATE_TESTS |
| 2808 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2809 | #if THREADING_TESTS |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2810 | #if GTEST_IS_THREADSAFE |
| 2811 | struct thread_data_struct { |
| 2812 | VkCmdBuffer cmdBuffer; |
| 2813 | VkEvent event; |
| 2814 | bool bailout; |
| 2815 | }; |
| 2816 | |
| 2817 | extern "C" void *AddToCommandBuffer(void *arg) |
| 2818 | { |
| 2819 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
| 2820 | std::string msgString; |
| 2821 | |
| 2822 | for (int i = 0; i<10000; i++) { |
Tony Barbour | c2e987e | 2015-06-29 16:20:35 -0600 | [diff] [blame] | 2823 | vkCmdSetEvent(data->cmdBuffer, data->event, VK_PIPELINE_STAGE_ALL_GPU_COMMANDS); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2824 | if (data->bailout) { |
| 2825 | break; |
| 2826 | } |
| 2827 | } |
| 2828 | return NULL; |
| 2829 | } |
| 2830 | |
| 2831 | TEST_F(VkLayerTest, ThreadCmdBufferCollision) |
| 2832 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2833 | VkFlags msgFlags; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2834 | std::string msgString; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 2835 | test_platform_thread thread; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2836 | |
| 2837 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2838 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2839 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2840 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2841 | m_errorMonitor->ClearState(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2842 | BeginCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2843 | |
| 2844 | VkEventCreateInfo event_info; |
| 2845 | VkEvent event; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2846 | VkResult err; |
| 2847 | |
| 2848 | memset(&event_info, 0, sizeof(event_info)); |
| 2849 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2850 | |
| 2851 | err = vkCreateEvent(device(), &event_info, &event); |
| 2852 | ASSERT_VK_SUCCESS(err); |
| 2853 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2854 | err = vkResetEvent(device(), event); |
| 2855 | ASSERT_VK_SUCCESS(err); |
| 2856 | |
| 2857 | struct thread_data_struct data; |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2858 | data.cmdBuffer = m_cmdBuffer->handle(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2859 | data.event = event; |
| 2860 | data.bailout = false; |
| 2861 | m_errorMonitor->SetBailout(&data.bailout); |
| 2862 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 2863 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2864 | // Add many entries to command buffer from this thread at the same time. |
| 2865 | AddToCommandBuffer(&data); |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 2866 | test_platform_thread_join(thread, NULL); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2867 | EndCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2868 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2869 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2870 | 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] | 2871 | if (!strstr(msgString.c_str(),"THREADING ERROR")) { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2872 | FAIL() << "Error received was not 'THREADING ERROR'"; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2873 | } |
| 2874 | |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2875 | vkDestroyEvent(device(), event); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 2876 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2877 | #endif // GTEST_IS_THREADSAFE |
| 2878 | #endif // THREADING_TESTS |
| 2879 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 2880 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 2881 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 2882 | { |
| 2883 | VkFlags msgFlags; |
| 2884 | std::string msgString; |
| 2885 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2886 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2887 | |
| 2888 | m_errorMonitor->ClearState(); |
| 2889 | |
| 2890 | VkShaderModule module; |
| 2891 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 2892 | struct icd_spv_header spv; |
| 2893 | |
| 2894 | spv.magic = ICD_SPV_MAGIC; |
| 2895 | spv.version = ICD_SPV_VERSION; |
| 2896 | spv.gen_magic = 0; |
| 2897 | |
| 2898 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 2899 | moduleCreateInfo.pNext = NULL; |
| 2900 | moduleCreateInfo.pCode = &spv; |
| 2901 | moduleCreateInfo.codeSize = 4; |
| 2902 | moduleCreateInfo.flags = 0; |
| 2903 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, &module); |
| 2904 | |
| 2905 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2906 | |
Chris Forbes | 96b8176 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 2907 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 2908 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 2909 | FAIL() << "Incorrect warning: " << msgString; |
| 2910 | } |
| 2911 | } |
| 2912 | |
| 2913 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 2914 | { |
| 2915 | VkFlags msgFlags; |
| 2916 | std::string msgString; |
| 2917 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2918 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2919 | |
| 2920 | m_errorMonitor->ClearState(); |
| 2921 | |
| 2922 | VkShaderModule module; |
| 2923 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 2924 | struct icd_spv_header spv; |
| 2925 | |
| 2926 | spv.magic = ~ICD_SPV_MAGIC; |
| 2927 | spv.version = ICD_SPV_VERSION; |
| 2928 | spv.gen_magic = 0; |
| 2929 | |
| 2930 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 2931 | moduleCreateInfo.pNext = NULL; |
| 2932 | moduleCreateInfo.pCode = &spv; |
| 2933 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 2934 | moduleCreateInfo.flags = 0; |
| 2935 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, &module); |
| 2936 | |
| 2937 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2938 | |
Chris Forbes | 96b8176 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 2939 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 2940 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 2941 | FAIL() << "Incorrect warning: " << msgString; |
| 2942 | } |
| 2943 | } |
| 2944 | |
| 2945 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 2946 | { |
| 2947 | VkFlags msgFlags; |
| 2948 | std::string msgString; |
| 2949 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2950 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2951 | |
| 2952 | m_errorMonitor->ClearState(); |
| 2953 | |
| 2954 | VkShaderModule module; |
| 2955 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 2956 | struct icd_spv_header spv; |
| 2957 | |
| 2958 | spv.magic = ICD_SPV_MAGIC; |
| 2959 | spv.version = ~ICD_SPV_VERSION; |
| 2960 | spv.gen_magic = 0; |
| 2961 | |
| 2962 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 2963 | moduleCreateInfo.pNext = NULL; |
| 2964 | |
| 2965 | moduleCreateInfo.pCode = &spv; |
| 2966 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 2967 | moduleCreateInfo.flags = 0; |
| 2968 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, &module); |
| 2969 | |
| 2970 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2971 | |
Chris Forbes | 96b8176 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 2972 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 2973 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 2974 | FAIL() << "Incorrect warning: " << msgString; |
| 2975 | } |
| 2976 | } |
| 2977 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 2978 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 2979 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2980 | VkFlags msgFlags; |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 2981 | std::string msgString; |
| 2982 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2983 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 2984 | |
| 2985 | char const *vsSource = |
| 2986 | "#version 140\n" |
| 2987 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2988 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2989 | "\n" |
| 2990 | "layout(location=0) out float x;\n" |
| 2991 | "void main(){\n" |
| 2992 | " gl_Position = vec4(1);\n" |
| 2993 | " x = 0;\n" |
| 2994 | "}\n"; |
| 2995 | char const *fsSource = |
| 2996 | "#version 140\n" |
| 2997 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2998 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2999 | "\n" |
| 3000 | "layout(location=0) out vec4 color;\n" |
| 3001 | "void main(){\n" |
| 3002 | " color = vec4(1);\n" |
| 3003 | "}\n"; |
| 3004 | |
| 3005 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3006 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3007 | |
| 3008 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3009 | pipe.AddColorAttachment(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3010 | pipe.AddShader(&vs); |
| 3011 | pipe.AddShader(&fs); |
| 3012 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3013 | VkDescriptorSetObj descriptorSet(m_device); |
| 3014 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3015 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3016 | |
| 3017 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3018 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3019 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3020 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3021 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3022 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3023 | if (!strstr(msgString.c_str(),"not consumed by fragment shader")) { |
| 3024 | FAIL() << "Incorrect warning: " << msgString; |
| 3025 | } |
| 3026 | } |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3027 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 3028 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 3029 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3030 | VkFlags msgFlags; |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 3031 | std::string msgString; |
| 3032 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3033 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 3034 | |
| 3035 | char const *vsSource = |
| 3036 | "#version 140\n" |
| 3037 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3038 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3039 | "\n" |
| 3040 | "void main(){\n" |
| 3041 | " gl_Position = vec4(1);\n" |
| 3042 | "}\n"; |
| 3043 | char const *fsSource = |
| 3044 | "#version 140\n" |
| 3045 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3046 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3047 | "\n" |
| 3048 | "layout(location=0) in float x;\n" |
| 3049 | "layout(location=0) out vec4 color;\n" |
| 3050 | "void main(){\n" |
| 3051 | " color = vec4(x);\n" |
| 3052 | "}\n"; |
| 3053 | |
| 3054 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3055 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3056 | |
| 3057 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3058 | pipe.AddColorAttachment(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 3059 | pipe.AddShader(&vs); |
| 3060 | pipe.AddShader(&fs); |
| 3061 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 3062 | VkDescriptorSetObj descriptorSet(m_device); |
| 3063 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3064 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 3065 | |
| 3066 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3067 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 3068 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3069 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 3070 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3071 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 3072 | if (!strstr(msgString.c_str(),"not written by vertex shader")) { |
| 3073 | FAIL() << "Incorrect error: " << msgString; |
| 3074 | } |
| 3075 | } |
| 3076 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 3077 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 3078 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3079 | VkFlags msgFlags; |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 3080 | std::string msgString; |
| 3081 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3082 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 3083 | |
| 3084 | char const *vsSource = |
| 3085 | "#version 140\n" |
| 3086 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3087 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3088 | "\n" |
| 3089 | "layout(location=0) out int x;\n" |
| 3090 | "void main(){\n" |
| 3091 | " x = 0;\n" |
| 3092 | " gl_Position = vec4(1);\n" |
| 3093 | "}\n"; |
| 3094 | char const *fsSource = |
| 3095 | "#version 140\n" |
| 3096 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3097 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3098 | "\n" |
| 3099 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 3100 | "layout(location=0) out vec4 color;\n" |
| 3101 | "void main(){\n" |
| 3102 | " color = vec4(x);\n" |
| 3103 | "}\n"; |
| 3104 | |
| 3105 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3106 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3107 | |
| 3108 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3109 | pipe.AddColorAttachment(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 3110 | pipe.AddShader(&vs); |
| 3111 | pipe.AddShader(&fs); |
| 3112 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 3113 | VkDescriptorSetObj descriptorSet(m_device); |
| 3114 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3115 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 3116 | |
| 3117 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3118 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 3119 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3120 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 3121 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3122 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 3123 | if (!strstr(msgString.c_str(),"Type mismatch on location 0")) { |
| 3124 | FAIL() << "Incorrect error: " << msgString; |
| 3125 | } |
| 3126 | } |
| 3127 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 3128 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 3129 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3130 | VkFlags msgFlags; |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 3131 | std::string msgString; |
| 3132 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3133 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 3134 | |
| 3135 | VkVertexInputBindingDescription input_binding; |
| 3136 | memset(&input_binding, 0, sizeof(input_binding)); |
| 3137 | |
| 3138 | VkVertexInputAttributeDescription input_attrib; |
| 3139 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 3140 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 3141 | |
| 3142 | char const *vsSource = |
| 3143 | "#version 140\n" |
| 3144 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3145 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3146 | "\n" |
| 3147 | "void main(){\n" |
| 3148 | " gl_Position = vec4(1);\n" |
| 3149 | "}\n"; |
| 3150 | char const *fsSource = |
| 3151 | "#version 140\n" |
| 3152 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3153 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3154 | "\n" |
| 3155 | "layout(location=0) out vec4 color;\n" |
| 3156 | "void main(){\n" |
| 3157 | " color = vec4(1);\n" |
| 3158 | "}\n"; |
| 3159 | |
| 3160 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3161 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3162 | |
| 3163 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3164 | pipe.AddColorAttachment(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 3165 | pipe.AddShader(&vs); |
| 3166 | pipe.AddShader(&fs); |
| 3167 | |
| 3168 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 3169 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 3170 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 3171 | VkDescriptorSetObj descriptorSet(m_device); |
| 3172 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3173 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 3174 | |
| 3175 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3176 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 3177 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3178 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 3179 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3180 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 3181 | if (!strstr(msgString.c_str(),"location 0 not consumed by VS")) { |
| 3182 | FAIL() << "Incorrect warning: " << msgString; |
| 3183 | } |
| 3184 | } |
| 3185 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 3186 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 3187 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3188 | VkFlags msgFlags; |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 3189 | std::string msgString; |
| 3190 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3191 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 3192 | |
| 3193 | char const *vsSource = |
| 3194 | "#version 140\n" |
| 3195 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3196 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3197 | "\n" |
| 3198 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 3199 | "void main(){\n" |
| 3200 | " gl_Position = x;\n" |
| 3201 | "}\n"; |
| 3202 | char const *fsSource = |
| 3203 | "#version 140\n" |
| 3204 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3205 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3206 | "\n" |
| 3207 | "layout(location=0) out vec4 color;\n" |
| 3208 | "void main(){\n" |
| 3209 | " color = vec4(1);\n" |
| 3210 | "}\n"; |
| 3211 | |
| 3212 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3213 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3214 | |
| 3215 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3216 | pipe.AddColorAttachment(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 3217 | pipe.AddShader(&vs); |
| 3218 | pipe.AddShader(&fs); |
| 3219 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 3220 | VkDescriptorSetObj descriptorSet(m_device); |
| 3221 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3222 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 3223 | |
| 3224 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3225 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 3226 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3227 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 3228 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3229 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 3230 | if (!strstr(msgString.c_str(),"VS consumes input at location 0 but not provided")) { |
| 3231 | FAIL() << "Incorrect warning: " << msgString; |
| 3232 | } |
| 3233 | } |
| 3234 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 3235 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 3236 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3237 | VkFlags msgFlags; |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 3238 | std::string msgString; |
| 3239 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3240 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 3241 | |
| 3242 | VkVertexInputBindingDescription input_binding; |
| 3243 | memset(&input_binding, 0, sizeof(input_binding)); |
| 3244 | |
| 3245 | VkVertexInputAttributeDescription input_attrib; |
| 3246 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 3247 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 3248 | |
| 3249 | char const *vsSource = |
| 3250 | "#version 140\n" |
| 3251 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3252 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3253 | "\n" |
| 3254 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 3255 | "void main(){\n" |
| 3256 | " gl_Position = vec4(x);\n" |
| 3257 | "}\n"; |
| 3258 | char const *fsSource = |
| 3259 | "#version 140\n" |
| 3260 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3261 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3262 | "\n" |
| 3263 | "layout(location=0) out vec4 color;\n" |
| 3264 | "void main(){\n" |
| 3265 | " color = vec4(1);\n" |
| 3266 | "}\n"; |
| 3267 | |
| 3268 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3269 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3270 | |
| 3271 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3272 | pipe.AddColorAttachment(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 3273 | pipe.AddShader(&vs); |
| 3274 | pipe.AddShader(&fs); |
| 3275 | |
| 3276 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 3277 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 3278 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 3279 | VkDescriptorSetObj descriptorSet(m_device); |
| 3280 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3281 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 3282 | |
| 3283 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3284 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 3285 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3286 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 3287 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3288 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 3289 | if (!strstr(msgString.c_str(),"location 0 does not match VS input type")) { |
| 3290 | FAIL() << "Incorrect error: " << msgString; |
| 3291 | } |
| 3292 | } |
| 3293 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 3294 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 3295 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3296 | VkFlags msgFlags; |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 3297 | std::string msgString; |
| 3298 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3299 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 3300 | |
| 3301 | /* Two binding descriptions for binding 0 */ |
| 3302 | VkVertexInputBindingDescription input_bindings[2]; |
| 3303 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 3304 | |
| 3305 | VkVertexInputAttributeDescription input_attrib; |
| 3306 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 3307 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 3308 | |
| 3309 | char const *vsSource = |
| 3310 | "#version 140\n" |
| 3311 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3312 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3313 | "\n" |
| 3314 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 3315 | "void main(){\n" |
| 3316 | " gl_Position = vec4(x);\n" |
| 3317 | "}\n"; |
| 3318 | char const *fsSource = |
| 3319 | "#version 140\n" |
| 3320 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3321 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3322 | "\n" |
| 3323 | "layout(location=0) out vec4 color;\n" |
| 3324 | "void main(){\n" |
| 3325 | " color = vec4(1);\n" |
| 3326 | "}\n"; |
| 3327 | |
| 3328 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3329 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3330 | |
| 3331 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3332 | pipe.AddColorAttachment(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 3333 | pipe.AddShader(&vs); |
| 3334 | pipe.AddShader(&fs); |
| 3335 | |
| 3336 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 3337 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 3338 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 3339 | VkDescriptorSetObj descriptorSet(m_device); |
| 3340 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3341 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 3342 | |
| 3343 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3344 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 3345 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3346 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 3347 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3348 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 3349 | if (!strstr(msgString.c_str(),"Duplicate vertex input binding descriptions for binding 0")) { |
| 3350 | FAIL() << "Incorrect error: " << msgString; |
| 3351 | } |
| 3352 | } |
Chris Forbes | 4c94870 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 3353 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 3354 | /* TODO: would be nice to test the mixed broadcast & custom case, but the GLSL->SPV compiler |
| 3355 | * rejects it. */ |
| 3356 | |
| 3357 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 3358 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3359 | VkFlags msgFlags; |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 3360 | std::string msgString; |
| 3361 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 3362 | |
| 3363 | char const *vsSource = |
| 3364 | "#version 140\n" |
| 3365 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3366 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3367 | "\n" |
| 3368 | "void main(){\n" |
| 3369 | " gl_Position = vec4(1);\n" |
| 3370 | "}\n"; |
| 3371 | char const *fsSource = |
| 3372 | "#version 140\n" |
| 3373 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3374 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3375 | "\n" |
| 3376 | "void main(){\n" |
| 3377 | "}\n"; |
| 3378 | |
| 3379 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3380 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3381 | |
| 3382 | VkPipelineObj pipe(m_device); |
| 3383 | pipe.AddShader(&vs); |
| 3384 | pipe.AddShader(&fs); |
| 3385 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3386 | /* set up CB 0, not written */ |
| 3387 | pipe.AddColorAttachment(); |
| 3388 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 3389 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 3390 | VkDescriptorSetObj descriptorSet(m_device); |
| 3391 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3392 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 3393 | |
| 3394 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3395 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 3396 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3397 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 3398 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3399 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 3400 | if (!strstr(msgString.c_str(),"Attachment 0 not written by FS")) { |
| 3401 | FAIL() << "Incorrect error: " << msgString; |
| 3402 | } |
| 3403 | } |
| 3404 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 3405 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 3406 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3407 | VkFlags msgFlags; |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 3408 | std::string msgString; |
| 3409 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 3410 | |
| 3411 | char const *vsSource = |
| 3412 | "#version 140\n" |
| 3413 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3414 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3415 | "\n" |
| 3416 | "void main(){\n" |
| 3417 | " gl_Position = vec4(1);\n" |
| 3418 | "}\n"; |
| 3419 | char const *fsSource = |
| 3420 | "#version 140\n" |
| 3421 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3422 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3423 | "\n" |
| 3424 | "layout(location=0) out vec4 x;\n" |
| 3425 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 3426 | "void main(){\n" |
| 3427 | " x = vec4(1);\n" |
| 3428 | " y = vec4(1);\n" |
| 3429 | "}\n"; |
| 3430 | |
| 3431 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3432 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3433 | |
| 3434 | VkPipelineObj pipe(m_device); |
| 3435 | pipe.AddShader(&vs); |
| 3436 | pipe.AddShader(&fs); |
| 3437 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3438 | /* set up CB 0, not written */ |
| 3439 | pipe.AddColorAttachment(); |
| 3440 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 3441 | /* FS writes CB 1, but we don't configure it */ |
| 3442 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 3443 | VkDescriptorSetObj descriptorSet(m_device); |
| 3444 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3445 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 3446 | |
| 3447 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3448 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 3449 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3450 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 3451 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3452 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 3453 | if (!strstr(msgString.c_str(),"FS writes to output location 1 with no matching attachment")) { |
| 3454 | FAIL() << "Incorrect warning: " << msgString; |
| 3455 | } |
| 3456 | } |
| 3457 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3458 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 3459 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3460 | VkFlags msgFlags; |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3461 | std::string msgString; |
| 3462 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3463 | |
| 3464 | char const *vsSource = |
| 3465 | "#version 140\n" |
| 3466 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3467 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3468 | "\n" |
| 3469 | "void main(){\n" |
| 3470 | " gl_Position = vec4(1);\n" |
| 3471 | "}\n"; |
| 3472 | char const *fsSource = |
| 3473 | "#version 140\n" |
| 3474 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3475 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3476 | "\n" |
| 3477 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 3478 | "void main(){\n" |
| 3479 | " x = ivec4(1);\n" |
| 3480 | "}\n"; |
| 3481 | |
| 3482 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3483 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3484 | |
| 3485 | VkPipelineObj pipe(m_device); |
| 3486 | pipe.AddShader(&vs); |
| 3487 | pipe.AddShader(&fs); |
| 3488 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3489 | /* set up CB 0; type is UNORM by default */ |
| 3490 | pipe.AddColorAttachment(); |
| 3491 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3492 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3493 | VkDescriptorSetObj descriptorSet(m_device); |
| 3494 | descriptorSet.AppendDummy(); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3495 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3496 | |
| 3497 | m_errorMonitor->ClearState(); |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 3498 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3499 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3500 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3501 | |
Cody Northrop | 1684adb | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3502 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3503 | if (!strstr(msgString.c_str(),"does not match FS output type")) { |
| 3504 | FAIL() << "Incorrect error: " << msgString; |
| 3505 | } |
| 3506 | } |
Chris Forbes | c205073 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 3507 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 3508 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 3509 | { |
| 3510 | VkFlags msgFlags; |
| 3511 | std::string msgString; |
| 3512 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 3513 | |
| 3514 | char const *vsSource = |
| 3515 | "#version 140\n" |
| 3516 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3517 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3518 | "\n" |
| 3519 | "void main(){\n" |
| 3520 | " gl_Position = vec4(1);\n" |
| 3521 | "}\n"; |
| 3522 | char const *fsSource = |
| 3523 | "#version 140\n" |
| 3524 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 3525 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 3526 | "\n" |
| 3527 | "layout(location=0) out vec4 x;\n" |
| 3528 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3529 | "void main(){\n" |
| 3530 | " x = vec4(bar.y);\n" |
| 3531 | "}\n"; |
| 3532 | |
| 3533 | m_errorMonitor->ClearState(); |
| 3534 | |
| 3535 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX, this); |
| 3536 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT, this); |
| 3537 | |
| 3538 | |
| 3539 | VkPipelineObj pipe(m_device); |
| 3540 | pipe.AddShader(&vs); |
| 3541 | pipe.AddShader(&fs); |
| 3542 | |
| 3543 | /* set up CB 0; type is UNORM by default */ |
| 3544 | pipe.AddColorAttachment(); |
| 3545 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3546 | |
| 3547 | VkDescriptorSetObj descriptorSet(m_device); |
| 3548 | descriptorSet.CreateVKDescriptorSet(m_cmdBuffer); |
| 3549 | |
| 3550 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 3551 | |
| 3552 | /* should have generated an error -- pipeline layout does not |
| 3553 | * provide a uniform buffer in 0.0 |
| 3554 | */ |
| 3555 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3556 | ASSERT_TRUE(msgFlags & VK_DBG_REPORT_ERROR_BIT); |
| 3557 | if (!strstr(msgString.c_str(),"not declared in pipeline layout")) { |
| 3558 | FAIL() << "Incorrect error: " << msgString; |
| 3559 | } |
| 3560 | } |
| 3561 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3562 | #endif // SHADER_CHECKER_TESTS |
| 3563 | |
| 3564 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 3565 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 3566 | { |
| 3567 | VkFlags msgFlags; |
| 3568 | std::string msgString; |
| 3569 | |
| 3570 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3571 | m_errorMonitor->ClearState(); |
| 3572 | |
| 3573 | // Create an image |
| 3574 | VkImage image; |
| 3575 | |
| 3576 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3577 | const int32_t tex_width = 32; |
| 3578 | const int32_t tex_height = 32; |
| 3579 | |
| 3580 | VkImageCreateInfo image_create_info = {}; |
| 3581 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3582 | image_create_info.pNext = NULL; |
| 3583 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3584 | image_create_info.format = tex_format; |
| 3585 | image_create_info.extent.width = tex_width; |
| 3586 | image_create_info.extent.height = tex_height; |
| 3587 | image_create_info.extent.depth = 1; |
| 3588 | image_create_info.mipLevels = 1; |
| 3589 | image_create_info.arraySize = 1; |
| 3590 | image_create_info.samples = 1; |
| 3591 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3592 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3593 | image_create_info.flags = 0; |
| 3594 | |
| 3595 | // Introduce error by sending down a bogus width extent |
| 3596 | image_create_info.extent.width = 65536; |
| 3597 | vkCreateImage(m_device->device(), &image_create_info, &image); |
| 3598 | |
| 3599 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3600 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an image" << |
| 3601 | "with extents outside the queried limits"; |
| 3602 | if (!strstr(msgString.c_str(),"CreateImage extents exceed allowable limits for format")) { |
| 3603 | FAIL() << "Error received did not match expected error message from vkCreateImage in DeviceLimits layer"; |
| 3604 | } |
| 3605 | } |
| 3606 | |
| 3607 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 3608 | { |
| 3609 | VkFlags msgFlags; |
| 3610 | std::string msgString; |
| 3611 | |
| 3612 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3613 | m_errorMonitor->ClearState(); |
| 3614 | |
| 3615 | // Create an image |
| 3616 | VkImage image; |
| 3617 | |
| 3618 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3619 | const int32_t tex_width = 32; |
| 3620 | const int32_t tex_height = 32; |
| 3621 | |
| 3622 | VkImageCreateInfo image_create_info = {}; |
| 3623 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3624 | image_create_info.pNext = NULL; |
| 3625 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3626 | image_create_info.format = tex_format; |
| 3627 | image_create_info.extent.width = tex_width; |
| 3628 | image_create_info.extent.height = tex_height; |
| 3629 | image_create_info.extent.depth = 1; |
| 3630 | image_create_info.mipLevels = 1; |
| 3631 | image_create_info.arraySize = 1; |
| 3632 | image_create_info.samples = 1; |
| 3633 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3634 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3635 | image_create_info.flags = 0; |
| 3636 | |
| 3637 | // Introduce error by sending down individually allowable values that result in a surface size |
| 3638 | // exceeding the device maximum |
| 3639 | image_create_info.extent.width = 8192; |
| 3640 | image_create_info.extent.height = 8192; |
| 3641 | image_create_info.extent.depth = 16; |
| 3642 | image_create_info.arraySize = 4; |
| 3643 | image_create_info.samples = 2; |
| 3644 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3645 | vkCreateImage(m_device->device(), &image_create_info, &image); |
| 3646 | |
| 3647 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3648 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an image" << |
| 3649 | "with resource size exceeding queried limit"; |
| 3650 | if (!strstr(msgString.c_str(),"CreateImage resource size exceeds allowable maximum")) { |
| 3651 | FAIL() << "Error received did not match expected error message from vkCreateImage in DeviceLimits layer"; |
| 3652 | } |
| 3653 | } |
| 3654 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3655 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 3656 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 3657 | #if IMAGE_TESTS |
| 3658 | TEST_F(VkLayerTest, InvalidImageView) |
| 3659 | { |
| 3660 | VkFlags msgFlags; |
| 3661 | std::string msgString; |
| 3662 | VkResult err; |
| 3663 | |
| 3664 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3665 | m_errorMonitor->ClearState(); |
| 3666 | |
| 3667 | // Create an image, allocate memory, free it, and then try to bind it |
| 3668 | VkImage image; |
| 3669 | |
| 3670 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3671 | const int32_t tex_width = 32; |
| 3672 | const int32_t tex_height = 32; |
| 3673 | |
| 3674 | VkImageCreateInfo image_create_info = {}; |
| 3675 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3676 | image_create_info.pNext = NULL; |
| 3677 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3678 | image_create_info.format = tex_format; |
| 3679 | image_create_info.extent.width = tex_width; |
| 3680 | image_create_info.extent.height = tex_height; |
| 3681 | image_create_info.extent.depth = 1; |
| 3682 | image_create_info.mipLevels = 1; |
| 3683 | image_create_info.arraySize = 1; |
| 3684 | image_create_info.samples = 1; |
| 3685 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3686 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3687 | image_create_info.flags = 0; |
| 3688 | |
| 3689 | err = vkCreateImage(m_device->device(), &image_create_info, &image); |
| 3690 | ASSERT_VK_SUCCESS(err); |
| 3691 | |
| 3692 | VkImageViewCreateInfo image_view_create_info = {}; |
| 3693 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3694 | image_view_create_info.image = image; |
| 3695 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3696 | image_view_create_info.format = tex_format; |
| 3697 | image_view_create_info.subresourceRange.arraySize = 1; |
| 3698 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 3699 | image_view_create_info.subresourceRange.mipLevels = 1; |
| 3700 | |
| 3701 | VkImageView view; |
| 3702 | err = vkCreateImageView(m_device->device(), &image_view_create_info, &view); |
| 3703 | |
| 3704 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3705 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an invalid ImageView"; |
| 3706 | if (!strstr(msgString.c_str(),"vkCreateImageView called with baseMipLevel 10 ")) { |
| 3707 | FAIL() << "Error received was not 'vkCreateImageView called with baseMipLevel 10...' but instaed '" << msgString.c_str() << "'"; |
| 3708 | } |
| 3709 | } |
| 3710 | #endif // IMAGE_TESTS |
| 3711 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 3712 | int main(int argc, char **argv) { |
| 3713 | int result; |
| 3714 | |
| 3715 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 3716 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 3717 | |
| 3718 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 3719 | |
| 3720 | result = RUN_ALL_TESTS(); |
| 3721 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 3722 | VkTestFramework::Finish(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 3723 | return result; |
| 3724 | } |