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