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: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 150 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 151 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 152 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 153 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, 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) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 155 | { GenericDrawPreparation(m_commandBuffer, 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 */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 158 | VkResult BeginCommandBuffer() { return BeginCommandBuffer(*m_commandBuffer); } |
| 159 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
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) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 161 | { m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, firstInstance); } |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 162 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 163 | { m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); } |
| 164 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
| 165 | void QueueCommandBuffer(const VkFence& fence) { m_commandBuffer->QueueCommandBuffer(fence); } |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 166 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 167 | { m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); } |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 168 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 169 | { m_commandBuffer->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 | */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 185 | // Use Threading layer first to protect others from ThreadCommandBufferCollision 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; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 204 | this->app_info.pApplicationName = "layer_tests"; |
| 205 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 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 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 223 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) |
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 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 227 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 234 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | return result; |
| 238 | } |
| 239 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 240 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) |
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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 245 | commandBuffer.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 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 248 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 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 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 348 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 349 | { |
| 350 | if (m_depthStencil->Initialized()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 351 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 352 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 353 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 354 | } |
| 355 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 356 | commandBuffer->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); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 379 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
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); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 382 | commandBuffer->BindPipeline(pipelineobj); |
| 383 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | // ******************************************************************************************************************** |
| 387 | // ******************************************************************************************************************** |
| 388 | // ******************************************************************************************************************** |
| 389 | // ******************************************************************************************************************** |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 390 | #if MEM_TRACKER_TESTS |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 391 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 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(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 409 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 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 | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 416 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 417 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 418 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 419 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 420 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 421 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 422 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 423 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 424 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 425 | |
| 426 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 427 | ASSERT_VK_SUCCESS( err ); |
| 428 | |
| 429 | m_errorMonitor->ClearState(); |
| 430 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 431 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 432 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 433 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 434 | 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] | 435 | if (!strstr(msgString.c_str(),"Resetting CB")) { |
| 436 | FAIL() << "Error received was not 'Resetting CB (0xaddress) before it has completed. You must check CB flag before'"; |
| 437 | } |
| 438 | } |
| 439 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 440 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 441 | { |
| 442 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 443 | VkFlags msgFlags; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 444 | std::string msgString; |
| 445 | |
| 446 | VkFenceCreateInfo fenceInfo = {}; |
| 447 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 448 | fenceInfo.pNext = NULL; |
| 449 | fenceInfo.flags = 0; |
| 450 | |
| 451 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 452 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 453 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 454 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 455 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 456 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 457 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 458 | |
| 459 | testFence.init(*m_device, fenceInfo); |
| 460 | |
| 461 | // Bypass framework since it does the waits automatically |
| 462 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 463 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 464 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 465 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 466 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 467 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 468 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 469 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 470 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 471 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 472 | |
| 473 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 474 | ASSERT_VK_SUCCESS( err ); |
| 475 | |
| 476 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 477 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 478 | VkCommandBufferBeginInfo info = {}; |
| 479 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 480 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 481 | info.renderPass = VK_NULL_HANDLE; |
| 482 | info.subpass = 0; |
| 483 | info.framebuffer = VK_NULL_HANDLE; |
| 484 | |
| 485 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 486 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 487 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 488 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 489 | 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] | 490 | if (!strstr(msgString.c_str(),"Calling vkBeginCommandBuffer() on active CB")) { |
| 491 | FAIL() << "Error received was not 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 492 | } |
| 493 | } |
| 494 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 495 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) |
| 496 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 497 | VkFlags msgFlags; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 498 | std::string msgString; |
| 499 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 500 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 501 | |
| 502 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 503 | m_errorMonitor->ClearState(); |
| 504 | |
| 505 | // Create an image, allocate memory, free it, and then try to bind it |
| 506 | VkImage image; |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 507 | VkDeviceMemory mem; |
| 508 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 509 | |
| 510 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 511 | const int32_t tex_width = 32; |
| 512 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 513 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 514 | VkImageCreateInfo image_create_info = {}; |
| 515 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 516 | image_create_info.pNext = NULL; |
| 517 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 518 | image_create_info.format = tex_format; |
| 519 | image_create_info.extent.width = tex_width; |
| 520 | image_create_info.extent.height = tex_height; |
| 521 | image_create_info.extent.depth = 1; |
| 522 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 523 | image_create_info.arrayLayers = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 524 | image_create_info.samples = 1; |
| 525 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 526 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 527 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 528 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 529 | VkMemoryAllocateInfo mem_alloc = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 530 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 531 | mem_alloc.pNext = NULL; |
| 532 | mem_alloc.allocationSize = 0; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 533 | // 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] | 534 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 535 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 536 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 537 | ASSERT_VK_SUCCESS(err); |
| 538 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 539 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 540 | image, |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 541 | &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 542 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 543 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 544 | |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 545 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 546 | if(!pass) { // If we can't find any unmappable memory this test doesn't make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 547 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 548 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 549 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 550 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 551 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 552 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 553 | ASSERT_VK_SUCCESS(err); |
| 554 | |
| 555 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 556 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 557 | ASSERT_VK_SUCCESS(err); |
| 558 | |
| 559 | // Map memory as if to initialize the image |
| 560 | void *mappedAddress = NULL; |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 561 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 562 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 563 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 564 | 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] | 565 | if (!strstr(msgString.c_str(),"Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT")) { |
| 566 | FAIL() << "Error received did not match expected error message from vkMapMemory in MemTracker"; |
| 567 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 568 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 569 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 570 | } |
| 571 | |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 572 | // TODO : Is this test still valid. Not sure it is with updates to memory binding model |
| 573 | // Verify and delete the test of fix the check |
| 574 | //TEST_F(VkLayerTest, FreeBoundMemory) |
| 575 | //{ |
| 576 | // VkFlags msgFlags; |
| 577 | // std::string msgString; |
| 578 | // VkResult err; |
| 579 | // |
| 580 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 581 | // m_errorMonitor->ClearState(); |
| 582 | // |
| 583 | // // Create an image, allocate memory, free it, and then try to bind it |
| 584 | // VkImage image; |
| 585 | // VkDeviceMemory mem; |
| 586 | // VkMemoryRequirements mem_reqs; |
| 587 | // |
| 588 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 589 | // const int32_t tex_width = 32; |
| 590 | // const int32_t tex_height = 32; |
| 591 | // |
| 592 | // const VkImageCreateInfo image_create_info = { |
| 593 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 594 | // .pNext = NULL, |
| 595 | // .imageType = VK_IMAGE_TYPE_2D, |
| 596 | // .format = tex_format, |
| 597 | // .extent = { tex_width, tex_height, 1 }, |
| 598 | // .mipLevels = 1, |
| 599 | // .arraySize = 1, |
| 600 | // .samples = 1, |
| 601 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 602 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 603 | // .flags = 0, |
| 604 | // }; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 605 | // VkMemoryAllocateInfo mem_alloc = { |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 606 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO, |
| 607 | // .pNext = NULL, |
| 608 | // .allocationSize = 0, |
| 609 | // .memoryTypeIndex = 0, |
| 610 | // }; |
| 611 | // |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 612 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 613 | // ASSERT_VK_SUCCESS(err); |
| 614 | // |
| 615 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 616 | // image, |
| 617 | // &mem_reqs); |
| 618 | // ASSERT_VK_SUCCESS(err); |
| 619 | // |
| 620 | // mem_alloc.allocationSize = mem_reqs.size; |
| 621 | // |
| 622 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 623 | // ASSERT_VK_SUCCESS(err); |
| 624 | // |
| 625 | // // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 626 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 627 | // ASSERT_VK_SUCCESS(err); |
| 628 | // |
| 629 | // // Bind memory to Image object |
| 630 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 631 | // ASSERT_VK_SUCCESS(err); |
| 632 | // |
| 633 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 634 | // vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 635 | // msgFlags = m_errorMonitor->GetState(&msgString); |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 636 | // |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 637 | // 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] | 638 | // if (!strstr(msgString.c_str(),"Freeing memory object while it still has references")) { |
| 639 | // FAIL() << "Warning received did not match expected message from freeMemObjInfo in MemTracker"; |
| 640 | // } |
| 641 | //} |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 642 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 643 | TEST_F(VkLayerTest, RebindMemory) |
| 644 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 645 | VkFlags msgFlags; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 646 | std::string msgString; |
| 647 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 648 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 649 | |
| 650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 651 | m_errorMonitor->ClearState(); |
| 652 | |
| 653 | // Create an image, allocate memory, free it, and then try to bind it |
| 654 | VkImage image; |
| 655 | VkDeviceMemory mem1; |
| 656 | VkDeviceMemory mem2; |
| 657 | VkMemoryRequirements mem_reqs; |
| 658 | |
| 659 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 660 | const int32_t tex_width = 32; |
| 661 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 662 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 663 | VkImageCreateInfo image_create_info = {}; |
| 664 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 665 | image_create_info.pNext = NULL; |
| 666 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 667 | image_create_info.format = tex_format; |
| 668 | image_create_info.extent.width = tex_width; |
| 669 | image_create_info.extent.height = tex_height; |
| 670 | image_create_info.extent.depth = 1; |
| 671 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 672 | image_create_info.arrayLayers = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 673 | image_create_info.samples = 1; |
| 674 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 675 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 676 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 677 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 678 | VkMemoryAllocateInfo mem_alloc = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 679 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 680 | mem_alloc.pNext = NULL; |
| 681 | mem_alloc.allocationSize = 0; |
| 682 | mem_alloc.memoryTypeIndex = 0; |
| 683 | |
| 684 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 685 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 686 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 687 | ASSERT_VK_SUCCESS(err); |
| 688 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 689 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 690 | image, |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 691 | &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 692 | |
| 693 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 694 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 695 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 696 | |
| 697 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 698 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 699 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 700 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 701 | ASSERT_VK_SUCCESS(err); |
| 702 | |
| 703 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 704 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 705 | ASSERT_VK_SUCCESS(err); |
| 706 | |
| 707 | // 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] | 708 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 709 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 710 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 711 | 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] | 712 | if (!strstr(msgString.c_str(),"which has already been bound to mem object")) { |
| 713 | FAIL() << "Error received did not match expected message when rebinding memory to an object"; |
| 714 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 715 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 716 | vkDestroyImage(m_device->device(), image, NULL); |
| 717 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 718 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 719 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 720 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 721 | TEST_F(VkLayerTest, SubmitSignaledFence) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 722 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 723 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 724 | VkFlags msgFlags; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 725 | std::string msgString; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 726 | |
| 727 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 728 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 729 | fenceInfo.pNext = NULL; |
| 730 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 731 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 732 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 733 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 734 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 735 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 736 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 737 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 738 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 739 | |
| 740 | testFence.init(*m_device, fenceInfo); |
| 741 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 742 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 743 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 744 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 745 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 746 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 747 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 748 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 749 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 750 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 751 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 752 | |
| 753 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 754 | vkQueueWaitIdle(m_device->m_queue ); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 755 | msgFlags = m_errorMonitor->GetState(&msgString); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 756 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 757 | 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] | 758 | 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] | 759 | FAIL() << "Error received was not 'VkQueueSubmit with fence in SIGNALED_STATE'"; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 760 | } |
| 761 | |
| 762 | } |
| 763 | |
| 764 | TEST_F(VkLayerTest, ResetUnsignaledFence) |
| 765 | { |
| 766 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 767 | VkFlags msgFlags; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 768 | std::string msgString; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 769 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 770 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 771 | fenceInfo.pNext = NULL; |
| 772 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 773 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 774 | testFence.init(*m_device, fenceInfo); |
| 775 | m_errorMonitor->ClearState(); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 776 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 777 | vkResetFences(m_device->device(), 1, fences); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 778 | msgFlags = m_errorMonitor->GetState(&msgString); |
Tobin Ehlis | bcca3ce | 2015-10-01 10:14:48 -0600 | [diff] [blame] | 779 | 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] | 780 | if (!strstr(msgString.c_str(),"submitted to VkResetFences in UNSIGNALED STATE")) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 781 | FAIL() << "Error received was not 'VkResetFences with fence in UNSIGNALED_STATE'"; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 782 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 783 | |
| 784 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 785 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 786 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 787 | #if 0 |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 788 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 789 | { |
| 790 | // Initiate Draw w/o a PSO bound |
| 791 | VkFlags msgFlags; |
| 792 | std::string msgString; |
| 793 | |
| 794 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 795 | m_errorMonitor->ClearState(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 796 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 797 | BeginCommandBuffer(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 798 | |
| 799 | const VkExtent3D e3d = { |
| 800 | .width = 128, |
| 801 | .height = 128, |
| 802 | .depth = 1, |
| 803 | }; |
| 804 | const VkImageCreateInfo ici = { |
| 805 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 806 | .pNext = NULL, |
| 807 | .imageType = VK_IMAGE_TYPE_2D, |
| 808 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 809 | .extent = e3d, |
| 810 | .mipLevels = 1, |
| 811 | .arraySize = 1, |
| 812 | .samples = 1, |
| 813 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | 660f0ca | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 814 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 815 | .flags = 0, |
| 816 | }; |
| 817 | |
| 818 | VkImage dsi; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 819 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 820 | VkDepthStencilView dsv; |
| 821 | const VkDepthStencilViewCreateInfo dsvci = { |
| 822 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 823 | .pNext = NULL, |
| 824 | .image = dsi, |
| 825 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 826 | .baseArrayLayer = 0, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 827 | .arraySize = 1, |
| 828 | .flags = 0, |
| 829 | }; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 830 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 831 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 832 | 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] | 833 | if (!strstr(msgString.c_str(),"Invalid usage flag for image ")) { |
| 834 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
| 835 | } |
| 836 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 837 | #endif // 0 |
| 838 | #endif // MEM_TRACKER_TESTS |
| 839 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 840 | #if OBJ_TRACKER_TESTS |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 841 | TEST_F(VkLayerTest, PipelineNotBound) |
| 842 | { |
| 843 | VkFlags msgFlags; |
| 844 | std::string msgString; |
| 845 | VkResult err; |
| 846 | |
| 847 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 848 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 849 | m_errorMonitor->ClearState(); |
| 850 | |
| 851 | VkDescriptorTypeCount ds_type_count = {}; |
| 852 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 853 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 854 | |
| 855 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 856 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 857 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 858 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 859 | ds_pool_ci.typeCount = 1; |
| 860 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 861 | |
| 862 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 863 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 864 | ASSERT_VK_SUCCESS(err); |
| 865 | |
| 866 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 867 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 868 | dsl_binding.arraySize = 1; |
| 869 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 870 | dsl_binding.pImmutableSamplers = NULL; |
| 871 | |
| 872 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 873 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 874 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 875 | ds_layout_ci.bindingCount = 1; |
| 876 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 877 | |
| 878 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 879 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 880 | ASSERT_VK_SUCCESS(err); |
| 881 | |
| 882 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 883 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 884 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 885 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 886 | alloc_info.descriptorPool = ds_pool; |
| 887 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 888 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 889 | ASSERT_VK_SUCCESS(err); |
| 890 | |
| 891 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 892 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 893 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 894 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 895 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 896 | |
| 897 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 898 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 899 | ASSERT_VK_SUCCESS(err); |
| 900 | |
| 901 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 902 | |
| 903 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 904 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 905 | |
| 906 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 907 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding invalid pipeline to CommandBuffer"; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 908 | if (!strstr(msgString.c_str(),"Invalid VkPipeline Object ")) { |
| 909 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be' but instead it was '" << msgString.c_str() << "'"; |
| 910 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 911 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 912 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 913 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 914 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 915 | } |
| 916 | |
| 917 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 918 | { |
| 919 | VkFlags msgFlags; |
| 920 | std::string msgString; |
| 921 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 922 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 923 | |
| 924 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 925 | m_errorMonitor->ClearState(); |
| 926 | |
| 927 | // Create an image, allocate memory, free it, and then try to bind it |
| 928 | VkImage image; |
| 929 | VkDeviceMemory mem; |
| 930 | VkMemoryRequirements mem_reqs; |
| 931 | |
| 932 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 933 | const int32_t tex_width = 32; |
| 934 | const int32_t tex_height = 32; |
| 935 | |
| 936 | VkImageCreateInfo image_create_info = {}; |
| 937 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 938 | image_create_info.pNext = NULL; |
| 939 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 940 | image_create_info.format = tex_format; |
| 941 | image_create_info.extent.width = tex_width; |
| 942 | image_create_info.extent.height = tex_height; |
| 943 | image_create_info.extent.depth = 1; |
| 944 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 945 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 946 | image_create_info.samples = 1; |
| 947 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 948 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 949 | image_create_info.flags = 0; |
| 950 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 951 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 952 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 953 | mem_alloc.pNext = NULL; |
| 954 | mem_alloc.allocationSize = 0; |
| 955 | mem_alloc.memoryTypeIndex = 0; |
| 956 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 957 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 958 | ASSERT_VK_SUCCESS(err); |
| 959 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 960 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 961 | image, |
| 962 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 963 | |
| 964 | mem_alloc.allocationSize = mem_reqs.size; |
| 965 | |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 966 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 967 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 968 | |
| 969 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 970 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 971 | ASSERT_VK_SUCCESS(err); |
| 972 | |
| 973 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 974 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 975 | |
| 976 | // Try to bind free memory that has been freed |
| 977 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 978 | // This may very well return an error. |
| 979 | (void)err; |
| 980 | |
| 981 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 982 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while tring to bind a freed memory object"; |
| 983 | if (!strstr(msgString.c_str(),"Invalid VkDeviceMemory Object ")) { |
| 984 | FAIL() << "Error received from BindInvalidMemory was not 'Invalid VkDeviceMemory Object 0x<handle>' but instead '" << msgString.c_str() << "'"; |
| 985 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 986 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 987 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 991 | { |
| 992 | VkFlags msgFlags; |
| 993 | std::string msgString; |
| 994 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 995 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 996 | |
| 997 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 998 | m_errorMonitor->ClearState(); |
| 999 | |
| 1000 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 1001 | VkImage image; |
| 1002 | VkDeviceMemory mem; |
| 1003 | VkMemoryRequirements mem_reqs; |
| 1004 | |
| 1005 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1006 | const int32_t tex_width = 32; |
| 1007 | const int32_t tex_height = 32; |
| 1008 | |
| 1009 | VkImageCreateInfo image_create_info = {}; |
| 1010 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1011 | image_create_info.pNext = NULL; |
| 1012 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1013 | image_create_info.format = tex_format; |
| 1014 | image_create_info.extent.width = tex_width; |
| 1015 | image_create_info.extent.height = tex_height; |
| 1016 | image_create_info.extent.depth = 1; |
| 1017 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1018 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1019 | image_create_info.samples = 1; |
| 1020 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1021 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1022 | image_create_info.flags = 0; |
| 1023 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1024 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1025 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 1026 | mem_alloc.pNext = NULL; |
| 1027 | mem_alloc.allocationSize = 0; |
| 1028 | mem_alloc.memoryTypeIndex = 0; |
| 1029 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1030 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1031 | ASSERT_VK_SUCCESS(err); |
| 1032 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1033 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1034 | image, |
| 1035 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1036 | |
| 1037 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1038 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1039 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1040 | |
| 1041 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1042 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1043 | ASSERT_VK_SUCCESS(err); |
| 1044 | |
| 1045 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1046 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1047 | ASSERT_VK_SUCCESS(err); |
| 1048 | |
| 1049 | // Now Try to bind memory to this destroyed object |
| 1050 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1051 | // This may very well return an error. |
| 1052 | (void) err; |
| 1053 | |
| 1054 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1055 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while binding memory to a destroyed object"; |
| 1056 | if (!strstr(msgString.c_str(),"Invalid VkImage Object ")) { |
| 1057 | 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] | 1058 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1059 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1060 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1061 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1062 | |
| 1063 | TEST_F(VkLayerTest, InvalidBufferViewObject) |
| 1064 | { |
| 1065 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
| 1066 | VkFlags msgFlags; |
| 1067 | std::string msgString; |
| 1068 | VkResult err; |
| 1069 | |
| 1070 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1071 | m_errorMonitor->ClearState(); |
| 1072 | VkDescriptorTypeCount ds_type_count = {}; |
| 1073 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1074 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1075 | |
| 1076 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1077 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1078 | ds_pool_ci.pNext = NULL; |
| 1079 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1080 | ds_pool_ci.typeCount = 1; |
| 1081 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1082 | |
| 1083 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1084 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1085 | ASSERT_VK_SUCCESS(err); |
| 1086 | |
| 1087 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1088 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1089 | dsl_binding.arraySize = 1; |
| 1090 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1091 | dsl_binding.pImmutableSamplers = NULL; |
| 1092 | |
| 1093 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1094 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1095 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1096 | ds_layout_ci.bindingCount = 1; |
| 1097 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1098 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1099 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1100 | ASSERT_VK_SUCCESS(err); |
| 1101 | |
| 1102 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1103 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1104 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1105 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1106 | alloc_info.descriptorPool = ds_pool; |
| 1107 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1108 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1109 | ASSERT_VK_SUCCESS(err); |
| 1110 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1111 | VkBufferView view = (VkBufferView) 0xbaadbeef; // invalid bufferView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1112 | |
| 1113 | VkWriteDescriptorSet descriptor_write; |
| 1114 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1115 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1116 | descriptor_write.dstSet = descriptorSet; |
| 1117 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1118 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1119 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1120 | descriptor_write.pTexelBufferView = &view; |
| 1121 | |
| 1122 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1123 | |
| 1124 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1125 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ invalid VkDescriptorBufferInfo."; |
| 1126 | if (!strstr(msgString.c_str(),"Invalid VkBufferView Object 0xbaadbeef")) { |
| 1127 | FAIL() << "Error received was not 'Invalid VkBufferView Object 0xbaadbeef' but instead '" << msgString.c_str() << "'"; |
| 1128 | } |
| 1129 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1130 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1131 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1132 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1133 | #endif // OBJ_TRACKER_TESTS |
| 1134 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1135 | #if DRAW_STATE_TESTS |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1136 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1137 | { |
| 1138 | VkFlags msgFlags; |
| 1139 | std::string msgString; |
| 1140 | m_errorMonitor->ClearState(); |
| 1141 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1142 | |
| 1143 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1144 | |
| 1145 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1146 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Line Width State Object"; |
| 1147 | if (!strstr(msgString.c_str(),"Dynamic line width state not set for this command buffer")) { |
| 1148 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic line width state not set for this command buffer'"; |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1153 | { |
| 1154 | VkFlags msgFlags; |
| 1155 | std::string msgString; |
| 1156 | m_errorMonitor->ClearState(); |
| 1157 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1158 | |
| 1159 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1160 | |
| 1161 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1162 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Depth Bias State Object"; |
| 1163 | if (!strstr(msgString.c_str(),"Dynamic depth bias state not set for this command buffer")) { |
| 1164 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic depth bias state not set for this command buffer'"; |
| 1165 | } |
| 1166 | } |
| 1167 | |
Cody Northrop | 4063c9a | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1168 | // Disable these two tests until we can sort out how to track multiple layer errors |
| 1169 | #if 0 |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1170 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1171 | { |
| 1172 | VkFlags msgFlags; |
| 1173 | std::string msgString; |
| 1174 | m_errorMonitor->ClearState(); |
| 1175 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1176 | |
| 1177 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1178 | |
| 1179 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1180 | 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] | 1181 | // TODO : Viewport and scissor currently set as a pair in framework so scissor error masks viewport error |
| 1182 | if (!strstr(msgString.c_str(),"Dynamic scissor state not set for this command buffer")) { |
| 1183 | 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] | 1184 | } |
| 1185 | } |
| 1186 | |
| 1187 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1188 | { |
| 1189 | VkFlags msgFlags; |
| 1190 | std::string msgString; |
| 1191 | m_errorMonitor->ClearState(); |
| 1192 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1193 | |
| 1194 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1195 | |
| 1196 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1197 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Viewport State Object"; |
| 1198 | if (!strstr(msgString.c_str(),"Dynamic scissor state not set for this command buffer")) { |
| 1199 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1200 | } |
| 1201 | } |
Cody Northrop | 4063c9a | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1202 | #endif |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1203 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1204 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1205 | { |
| 1206 | VkFlags msgFlags; |
| 1207 | std::string msgString; |
| 1208 | m_errorMonitor->ClearState(); |
| 1209 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1210 | |
| 1211 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1212 | |
| 1213 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1214 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Blend State Object"; |
| 1215 | if (!strstr(msgString.c_str(),"Dynamic blend object state not set for this command buffer")) { |
| 1216 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic blend object state not set for this command buffer'"; |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1221 | { |
| 1222 | VkFlags msgFlags; |
| 1223 | std::string msgString; |
| 1224 | m_errorMonitor->ClearState(); |
| 1225 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1226 | |
| 1227 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1228 | |
| 1229 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1230 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Binding a Depth Bounds State Object"; |
| 1231 | if (!strstr(msgString.c_str(),"Dynamic depth bounds state not set for this command buffer")) { |
| 1232 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic depth bounds state not set for this command buffer'"; |
| 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1237 | { |
| 1238 | VkFlags msgFlags; |
| 1239 | std::string msgString; |
| 1240 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1241 | m_errorMonitor->ClearState(); |
| 1242 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1243 | |
| 1244 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1245 | |
| 1246 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1247 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Setting a Stencil Read Mask"; |
| 1248 | if (!strstr(msgString.c_str(),"Dynamic stencil read mask state not set for this command buffer")) { |
| 1249 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1250 | } |
| 1251 | } |
| 1252 | |
| 1253 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1254 | { |
| 1255 | VkFlags msgFlags; |
| 1256 | std::string msgString; |
| 1257 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1258 | m_errorMonitor->ClearState(); |
| 1259 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1260 | |
| 1261 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1262 | |
| 1263 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1264 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Setting a Stencil Write Mask"; |
| 1265 | if (!strstr(msgString.c_str(),"Dynamic stencil write mask state not set for this command buffer")) { |
| 1266 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1267 | } |
| 1268 | } |
| 1269 | |
| 1270 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1271 | { |
| 1272 | VkFlags msgFlags; |
| 1273 | std::string msgString; |
| 1274 | m_errorMonitor->ClearState(); |
| 1275 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1276 | |
| 1277 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1278 | |
| 1279 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1280 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from Not Setting a Stencil Reference"; |
| 1281 | if (!strstr(msgString.c_str(),"Dynamic stencil reference state not set for this command buffer")) { |
| 1282 | FAIL() << "Received: '" << msgString.c_str() << "' Expected: 'Dynamic stencil reference state not set for this command buffer'"; |
| 1283 | } |
| 1284 | } |
| 1285 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1286 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1287 | { |
| 1288 | vk_testing::Fence testFence; |
| 1289 | VkFlags msgFlags; |
| 1290 | std::string msgString; |
| 1291 | |
| 1292 | VkFenceCreateInfo fenceInfo = {}; |
| 1293 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1294 | fenceInfo.pNext = NULL; |
| 1295 | fenceInfo.flags = 0; |
| 1296 | |
| 1297 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1298 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1299 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1300 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1301 | // We luck out b/c by default the framework creates CB w/ the VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1302 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1303 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1304 | EndCommandBuffer(); |
| 1305 | |
| 1306 | testFence.init(*m_device, fenceInfo); |
| 1307 | |
| 1308 | // Bypass framework since it does the waits automatically |
| 1309 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1310 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1311 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1312 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1313 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1314 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1315 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1316 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1317 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1318 | submit_info.pSignalSemaphores = NULL; |
| 1319 | |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1320 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1321 | ASSERT_VK_SUCCESS( err ); |
| 1322 | |
| 1323 | m_errorMonitor->ClearState(); |
| 1324 | // 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] | 1325 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1326 | |
| 1327 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1328 | 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"; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1329 | if (!strstr(msgString.c_str(),"was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted")) { |
| 1330 | FAIL() << "Error received was not 'CB (0xaddress) was created w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1331 | } |
| 1332 | } |
| 1333 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1334 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1335 | { |
| 1336 | // Initiate Draw w/o a PSO bound |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1337 | VkFlags msgFlags; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1338 | std::string msgString; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1339 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1340 | |
| 1341 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1342 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1343 | m_errorMonitor->ClearState(); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1344 | |
| 1345 | VkDescriptorTypeCount ds_type_count = {}; |
| 1346 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1347 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1348 | |
| 1349 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1350 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1351 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1352 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1353 | ds_pool_ci.typeCount = 1; |
| 1354 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1355 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1356 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1357 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1358 | ASSERT_VK_SUCCESS(err); |
| 1359 | |
| 1360 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1361 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1362 | dsl_binding.arraySize = 1; |
| 1363 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1364 | dsl_binding.pImmutableSamplers = NULL; |
| 1365 | |
| 1366 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1367 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1368 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1369 | ds_layout_ci.bindingCount = 1; |
| 1370 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1371 | |
| 1372 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1373 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1374 | ASSERT_VK_SUCCESS(err); |
| 1375 | |
| 1376 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1377 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1378 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1379 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1380 | alloc_info.descriptorPool = ds_pool; |
| 1381 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1382 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1383 | ASSERT_VK_SUCCESS(err); |
| 1384 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 1385 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1386 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1387 | pipe_ms_state_ci.rasterizationSamples = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1388 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1389 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1390 | pipe_ms_state_ci.pSampleMask = NULL; |
| 1391 | |
| 1392 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1393 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1394 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1395 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1396 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1397 | VkPipelineLayout pipeline_layout; |
| 1398 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1399 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1400 | ASSERT_VK_SUCCESS(err); |
| 1401 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1402 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1403 | 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] | 1404 | // but add it to be able to run on more devices |
| 1405 | VkPipelineObj pipe(m_device); |
| 1406 | pipe.AddShader(&vs); |
| 1407 | pipe.AddShader(&fs); |
| 1408 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1409 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1410 | m_errorMonitor->ClearState(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1411 | // Calls AllocateCommandBuffers |
| 1412 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 1413 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1414 | memset(&cmd_buf_info, 0, sizeof(VkCommandBufferBeginInfo)); |
| 1415 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1416 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1417 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1418 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1419 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1420 | vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1421 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1422 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding pipeline to CommandBuffer w/o active RenderPass"; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1423 | if (!strstr(msgString.c_str(),"Incorrectly binding graphics pipeline ")) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1424 | 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] | 1425 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1426 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1427 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1428 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1429 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1430 | } |
| 1431 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1432 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) |
| 1433 | { |
| 1434 | // Initiate Draw w/o a PSO bound |
| 1435 | VkFlags msgFlags; |
| 1436 | std::string msgString; |
| 1437 | VkResult err; |
| 1438 | |
| 1439 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1440 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1441 | m_errorMonitor->ClearState(); |
| 1442 | |
| 1443 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer descriptor from it |
| 1444 | VkDescriptorTypeCount ds_type_count = {}; |
| 1445 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1446 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1447 | |
| 1448 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1449 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1450 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1451 | ds_pool_ci.flags = 0; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1452 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1453 | ds_pool_ci.typeCount = 1; |
| 1454 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1455 | |
| 1456 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1457 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1458 | ASSERT_VK_SUCCESS(err); |
| 1459 | |
| 1460 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1461 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1462 | dsl_binding.arraySize = 1; |
| 1463 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1464 | dsl_binding.pImmutableSamplers = NULL; |
| 1465 | |
| 1466 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1467 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1468 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1469 | ds_layout_ci.bindingCount = 1; |
| 1470 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1471 | |
| 1472 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1473 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1474 | ASSERT_VK_SUCCESS(err); |
| 1475 | |
| 1476 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1477 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1478 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1479 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1480 | alloc_info.descriptorPool = ds_pool; |
| 1481 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1482 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1483 | |
| 1484 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1485 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after alloc descriptor from pool w/o requested type"; |
| 1486 | if (!strstr(msgString.c_str(),"Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ")) { |
| 1487 | FAIL() << "Error received was not 'Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...' but rather '" << msgString.c_str() << "'"; |
| 1488 | } |
| 1489 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1490 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1491 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1492 | } |
| 1493 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1494 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1495 | { |
| 1496 | VkFlags msgFlags; |
| 1497 | std::string msgString; |
| 1498 | VkResult err; |
| 1499 | |
| 1500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1501 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1502 | m_errorMonitor->ClearState(); |
| 1503 | |
| 1504 | VkDescriptorTypeCount ds_type_count = {}; |
| 1505 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1506 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1507 | |
| 1508 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1509 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1510 | ds_pool_ci.pNext = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1511 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1512 | ds_pool_ci.typeCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1513 | ds_pool_ci.flags = 0; |
| 1514 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1515 | // app can only call vkResetDescriptorPool on this pool.; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1516 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1517 | |
| 1518 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1519 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1520 | ASSERT_VK_SUCCESS(err); |
| 1521 | |
| 1522 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1523 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1524 | dsl_binding.arraySize = 1; |
| 1525 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1526 | dsl_binding.pImmutableSamplers = NULL; |
| 1527 | |
| 1528 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1529 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1530 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1531 | ds_layout_ci.bindingCount = 1; |
| 1532 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1533 | |
| 1534 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1535 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1536 | ASSERT_VK_SUCCESS(err); |
| 1537 | |
| 1538 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1539 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1540 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1541 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1542 | alloc_info.descriptorPool = ds_pool; |
| 1543 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1544 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1545 | ASSERT_VK_SUCCESS(err); |
| 1546 | |
| 1547 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
| 1548 | msgFlags = m_errorMonitor->GetState(&msgString); |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1549 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after freeing descriptor from non-free Pool"; |
| 1550 | |
| 1551 | if (!strstr(msgString.c_str(),"It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT.")) { |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1552 | FAIL() << "Error received was not 'It is invalid to call vkFreeDescriptorSets() with a pool created with...' but instead it was '" << msgString.c_str() << "'"; |
| 1553 | } |
| 1554 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1555 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1556 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1557 | } |
| 1558 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1559 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1560 | { |
| 1561 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1562 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1563 | // Attempt to clear DS Pool with bad object |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1564 | /* VkFlags msgFlags; |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1565 | std::string msgString; |
| 1566 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1567 | vkResetDescriptorPool(device(), badPool); |
| 1568 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1569 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1570 | 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] | 1571 | if (!strstr(msgString.c_str(),"Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call")) { |
| 1572 | FAIL() << "Error received was note 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1573 | }*/ |
| 1574 | } |
| 1575 | |
| 1576 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1577 | { |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1578 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1579 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1580 | // Create a valid cmd buffer |
| 1581 | // call vkCmdBindDescriptorSets w/ false DS |
| 1582 | } |
| 1583 | |
| 1584 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1585 | { |
| 1586 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1587 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1588 | } |
| 1589 | |
| 1590 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1591 | { |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1592 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1593 | // 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] | 1594 | // Create a valid cmd buffer |
| 1595 | // call vkCmdBindPipeline w/ false Pipeline |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1596 | // VkFlags msgFlags; |
| 1597 | // std::string msgString; |
| 1598 | // |
| 1599 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1600 | // m_errorMonitor->ClearState(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1601 | // VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1602 | // BeginCommandBuffer(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1603 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1604 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1605 | // msgFlags = m_errorMonitor->GetState(&msgString); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1606 | // ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding invalid pipeline to CommandBuffer"; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1607 | // if (!strstr(msgString.c_str(),"Attempt to bind Pipeline ")) { |
| 1608 | // FAIL() << "Error received was not 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1609 | // } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1610 | } |
| 1611 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1612 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1613 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1614 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on CommandBuffer |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1615 | VkFlags msgFlags; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1616 | std::string msgString; |
| 1617 | VkResult err; |
| 1618 | |
| 1619 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1620 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1621 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1622 | m_errorMonitor->ClearState(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1623 | VkDescriptorTypeCount ds_type_count = {}; |
| 1624 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1625 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1626 | |
| 1627 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1628 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1629 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1630 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1631 | ds_pool_ci.typeCount = 1; |
| 1632 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1633 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1634 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1635 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1636 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1637 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1638 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1639 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1640 | dsl_binding.arraySize = 1; |
| 1641 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1642 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1643 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1644 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1645 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1646 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1647 | ds_layout_ci.bindingCount = 1; |
| 1648 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1649 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1650 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1651 | ASSERT_VK_SUCCESS(err); |
| 1652 | |
| 1653 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1654 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1655 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1656 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1657 | alloc_info.descriptorPool = ds_pool; |
| 1658 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1659 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1660 | ASSERT_VK_SUCCESS(err); |
| 1661 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1662 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1663 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1664 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1665 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1666 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1667 | |
| 1668 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1669 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1670 | ASSERT_VK_SUCCESS(err); |
| 1671 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1672 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1673 | 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] | 1674 | // but add it to be able to run on more devices |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1675 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1676 | VkPipelineObj pipe(m_device); |
| 1677 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1678 | pipe.AddShader(&fs); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1679 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1680 | |
| 1681 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1682 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1683 | vkCmdBindDescriptorSets(m_commandBuffer->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] | 1684 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1685 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1686 | 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] | 1687 | if (!strstr(msgString.c_str()," bound but it was never updated. ")) { |
| 1688 | FAIL() << "Error received was not 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1689 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1690 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1691 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1692 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1693 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1694 | } |
| 1695 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1696 | TEST_F(VkLayerTest, NoBeginCommandBuffer) |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1697 | { |
| 1698 | VkFlags msgFlags; |
| 1699 | std::string msgString; |
| 1700 | |
| 1701 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1702 | m_errorMonitor->ClearState(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1703 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1704 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1705 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1706 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1707 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after ending a CommandBuffer w/o calling BeginCommandBuffer()"; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1708 | if (!strstr(msgString.c_str(),"You must call vkBeginCommandBuffer() before this call to ")) { |
| 1709 | FAIL() << "Error received was not 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 1710 | } |
| 1711 | } |
| 1712 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1713 | TEST_F(VkLayerTest, PrimaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1714 | { |
| 1715 | VkFlags msgFlags; |
| 1716 | std::string msgString; |
| 1717 | |
| 1718 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1719 | m_errorMonitor->ClearState(); |
| 1720 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1721 | // Calls AllocateCommandBuffers |
| 1722 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1723 | |
| 1724 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1725 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1726 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1727 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1728 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1729 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 1730 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 1731 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1732 | |
| 1733 | // The error should be caught by validation of the BeginCommandBuffer call |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1734 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1735 | |
| 1736 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1737 | 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] | 1738 | if (!strstr(msgString.c_str(),"may not specify framebuffer or renderpass parameters")) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1739 | FAIL() << "Error received was not 'vkAllocateCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1740 | } |
| 1741 | } |
| 1742 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1743 | TEST_F(VkLayerTest, SecondaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1744 | { |
| 1745 | VkFlags msgFlags; |
| 1746 | std::string msgString; |
| 1747 | VkResult err; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1748 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1749 | |
| 1750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1751 | m_errorMonitor->ClearState(); |
| 1752 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1753 | VkCommandBufferAllocateInfo cmd = {}; |
| 1754 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOC_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1755 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1756 | cmd.commandPool = m_commandPool; |
| 1757 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1758 | cmd.bufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1759 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1760 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1761 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1762 | |
| 1763 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1764 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1765 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1766 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1767 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1768 | |
| 1769 | // The error should be caught by validation of the BeginCommandBuffer call |
| 1770 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 1771 | |
| 1772 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1773 | 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] | 1774 | if (!strstr(msgString.c_str(),"must specify framebuffer and renderpass parameters")) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1775 | FAIL() << "Error received was not 'vkAllocateCommandBuffers(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1776 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1777 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1778 | } |
| 1779 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1780 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 1781 | { |
| 1782 | // Attempt to Create Gfx Pipeline w/o a VS |
| 1783 | VkFlags msgFlags; |
| 1784 | std::string msgString; |
| 1785 | VkResult err; |
| 1786 | |
| 1787 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1788 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1789 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1790 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1791 | VkDescriptorTypeCount ds_type_count = {}; |
| 1792 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1793 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1794 | |
| 1795 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1796 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1797 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1798 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1799 | ds_pool_ci.typeCount = 1; |
| 1800 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1801 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1802 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1803 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1804 | ASSERT_VK_SUCCESS(err); |
| 1805 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1806 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1807 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1808 | dsl_binding.arraySize = 1; |
| 1809 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1810 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1811 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1812 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1813 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1814 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1815 | ds_layout_ci.bindingCount = 1; |
| 1816 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1817 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1818 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1819 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1820 | ASSERT_VK_SUCCESS(err); |
| 1821 | |
| 1822 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1823 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1824 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1825 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1826 | alloc_info.descriptorPool = ds_pool; |
| 1827 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1828 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1829 | ASSERT_VK_SUCCESS(err); |
| 1830 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1831 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1832 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1833 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1834 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1835 | |
| 1836 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1837 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1838 | ASSERT_VK_SUCCESS(err); |
| 1839 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1840 | VkViewport vp = {}; // Just need dummy vp to point to |
| 1841 | VkRect2D sc = {}; // dummy scissor to point to |
| 1842 | |
| 1843 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 1844 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 1845 | vp_state_ci.scissorCount = 1; |
| 1846 | vp_state_ci.pScissors = ≻ |
| 1847 | vp_state_ci.viewportCount = 1; |
| 1848 | vp_state_ci.pViewports = &vp; |
| 1849 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1850 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1851 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1852 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1853 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1854 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1855 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1856 | |
| 1857 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1858 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 1859 | pc_ci.initialDataSize = 0; |
| 1860 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1861 | |
| 1862 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1863 | VkPipelineCache pipelineCache; |
| 1864 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1865 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1866 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1867 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1868 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1869 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 1870 | 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] | 1871 | if (!strstr(msgString.c_str(),"Invalid Pipeline CreateInfo State: Vtx Shader required")) { |
| 1872 | FAIL() << "Error received was not 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 1873 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1874 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1875 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 1876 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1877 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1878 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1879 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1880 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 1881 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 1882 | { |
| 1883 | // Attempt to Create Gfx Pipeline w/o a VS |
| 1884 | VkFlags msgFlags; |
| 1885 | std::string msgString; |
| 1886 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1887 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1888 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1889 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1890 | m_errorMonitor->ClearState(); |
| 1891 | |
| 1892 | VkDescriptorTypeCount ds_type_count = {}; |
| 1893 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1894 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1895 | |
| 1896 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1897 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1898 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1899 | ds_pool_ci.typeCount = 1; |
| 1900 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1901 | |
| 1902 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1903 | err = vkCreateDescriptorPool(m_device->device(), VK_DESCRIPTOR_POOL_USAGE_NON_FREE, 1, &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1904 | ASSERT_VK_SUCCESS(err); |
| 1905 | |
| 1906 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1907 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1908 | dsl_binding.arraySize = 1; |
| 1909 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1910 | dsl_binding.pImmutableSamplers = NULL; |
| 1911 | |
| 1912 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1913 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1914 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1915 | ds_layout_ci.bindingCount = 1; |
| 1916 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1917 | |
| 1918 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1919 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1920 | ASSERT_VK_SUCCESS(err); |
| 1921 | |
| 1922 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1923 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1924 | ASSERT_VK_SUCCESS(err); |
| 1925 | |
| 1926 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1927 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1928 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1929 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1930 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1931 | |
| 1932 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1933 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1934 | ASSERT_VK_SUCCESS(err); |
| 1935 | |
| 1936 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 1937 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 1938 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1939 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1940 | // 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] | 1941 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 1942 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1943 | |
| 1944 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1945 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1946 | shaderStages[0].shader = vs.handle(); |
| 1947 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1948 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1949 | shaderStages[1].shader = tc.handle(); |
| 1950 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1951 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1952 | shaderStages[2].shader = te.handle(); |
| 1953 | |
| 1954 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 1955 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 1956 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH; |
| 1957 | |
| 1958 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 1959 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 1960 | tsCI.patchControlPoints = 0; // This will cause an error |
| 1961 | |
| 1962 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1963 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 1964 | gp_ci.pNext = NULL; |
| 1965 | gp_ci.stageCount = 3; |
| 1966 | gp_ci.pStages = shaderStages; |
| 1967 | gp_ci.pVertexInputState = NULL; |
| 1968 | gp_ci.pInputAssemblyState = &iaCI; |
| 1969 | gp_ci.pTessellationState = &tsCI; |
| 1970 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1971 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1972 | gp_ci.pMultisampleState = NULL; |
| 1973 | gp_ci.pDepthStencilState = NULL; |
| 1974 | gp_ci.pColorBlendState = NULL; |
| 1975 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1976 | gp_ci.layout = pipeline_layout; |
| 1977 | gp_ci.renderPass = renderPass(); |
| 1978 | |
| 1979 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1980 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 1981 | pc_ci.pNext = NULL; |
| 1982 | pc_ci.initialSize = 0; |
| 1983 | pc_ci.initialData = 0; |
| 1984 | pc_ci.maxSize = 0; |
| 1985 | |
| 1986 | VkPipeline pipeline; |
| 1987 | VkPipelineCache pipelineCache; |
| 1988 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1989 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1990 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1991 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1992 | |
| 1993 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 1994 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Tess Gfx Pipeline w/ 0 patchControlPoints."; |
| 1995 | if (!strstr(msgString.c_str(),"Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive ")) { |
| 1996 | FAIL() << "Error received was not 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...' but instead '" << msgString.c_str() << "'"; |
| 1997 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1998 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1999 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2000 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2001 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2002 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2003 | } |
| 2004 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2005 | // Set scissor and viewport counts to different numbers |
| 2006 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2007 | { |
| 2008 | // Attempt to Create Gfx Pipeline w/o a VS |
| 2009 | VkFlags msgFlags; |
| 2010 | std::string msgString; |
| 2011 | VkResult err; |
| 2012 | |
| 2013 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2014 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2015 | m_errorMonitor->ClearState(); |
| 2016 | |
| 2017 | VkDescriptorTypeCount ds_type_count = {}; |
| 2018 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2019 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2020 | |
| 2021 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2022 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2023 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2024 | ds_pool_ci.typeCount = 1; |
| 2025 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2026 | |
| 2027 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2028 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2029 | ASSERT_VK_SUCCESS(err); |
| 2030 | |
| 2031 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2032 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2033 | dsl_binding.arraySize = 1; |
| 2034 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2035 | |
| 2036 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2037 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2038 | ds_layout_ci.bindingCount = 1; |
| 2039 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2040 | |
| 2041 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2042 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2043 | ASSERT_VK_SUCCESS(err); |
| 2044 | |
| 2045 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2046 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2047 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2048 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2049 | alloc_info.descriptorPool = ds_pool; |
| 2050 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2051 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2052 | ASSERT_VK_SUCCESS(err); |
| 2053 | |
| 2054 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2055 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2056 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2057 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2058 | |
| 2059 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2060 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2061 | ASSERT_VK_SUCCESS(err); |
| 2062 | |
| 2063 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2064 | |
| 2065 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2066 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2067 | vp_state_ci.scissorCount = 0; |
| 2068 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2069 | vp_state_ci.pViewports = &vp; |
| 2070 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2071 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2072 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2073 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2074 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2075 | 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] | 2076 | // but add it to be able to run on more devices |
| 2077 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
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; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2081 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2082 | |
| 2083 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2084 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2085 | gp_ci.stageCount = 2; |
| 2086 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2087 | gp_ci.pViewportState = &vp_state_ci; |
| 2088 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2089 | gp_ci.layout = pipeline_layout; |
| 2090 | gp_ci.renderPass = renderPass(); |
| 2091 | |
| 2092 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2093 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2094 | |
| 2095 | VkPipeline pipeline; |
| 2096 | VkPipelineCache pipelineCache; |
| 2097 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2098 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2099 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2100 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2101 | |
| 2102 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2103 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/ viewport and scissor count mismatch."; |
| 2104 | if (!strstr(msgString.c_str(),"Gfx Pipeline viewport count (1) must match scissor count (0).")) { |
| 2105 | FAIL() << "Error received was not 'Gfx Pipeline viewport count (1) must match scissor count (0).' but instead it was '" << msgString.c_str() << "'"; |
| 2106 | } |
| 2107 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2108 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2109 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2110 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2111 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2112 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2113 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2114 | // for the counts even if the data is going to be set dynamically. |
| 2115 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2116 | { |
| 2117 | // Attempt to Create Gfx Pipeline w/o a VS |
| 2118 | VkFlags msgFlags; |
| 2119 | std::string msgString; |
| 2120 | VkResult err; |
| 2121 | |
| 2122 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2123 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2124 | m_errorMonitor->ClearState(); |
| 2125 | |
| 2126 | VkDescriptorTypeCount ds_type_count = {}; |
| 2127 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2128 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2129 | |
| 2130 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2131 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2132 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2133 | ds_pool_ci.typeCount = 1; |
| 2134 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2135 | |
| 2136 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2137 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2138 | ASSERT_VK_SUCCESS(err); |
| 2139 | |
| 2140 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2141 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2142 | dsl_binding.arraySize = 1; |
| 2143 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2144 | |
| 2145 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2146 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2147 | ds_layout_ci.bindingCount = 1; |
| 2148 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2149 | |
| 2150 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2151 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2152 | ASSERT_VK_SUCCESS(err); |
| 2153 | |
| 2154 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2155 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2156 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2157 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2158 | alloc_info.descriptorPool = ds_pool; |
| 2159 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2160 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2161 | ASSERT_VK_SUCCESS(err); |
| 2162 | |
| 2163 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2164 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2165 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2166 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2167 | |
| 2168 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2169 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2170 | ASSERT_VK_SUCCESS(err); |
| 2171 | |
| 2172 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2173 | // Set scissor as dynamic to avoid second error |
| 2174 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2175 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2176 | dyn_state_ci.dynamicStateCount = 1; |
| 2177 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2178 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2179 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2180 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2181 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2182 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2183 | 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] | 2184 | // but add it to be able to run on more devices |
| 2185 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2186 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2187 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2188 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2189 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2190 | |
| 2191 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2192 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2193 | gp_ci.stageCount = 2; |
| 2194 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2195 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2196 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2197 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2198 | gp_ci.layout = pipeline_layout; |
| 2199 | gp_ci.renderPass = renderPass(); |
| 2200 | |
| 2201 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2202 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2203 | |
| 2204 | VkPipeline pipeline; |
| 2205 | VkPipelineCache pipelineCache; |
| 2206 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2207 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2208 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2209 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2210 | |
| 2211 | msgFlags = m_errorMonitor->GetState(&msgString); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2212 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o viewport state set."; |
| 2213 | if (!strstr(msgString.c_str(),"Gfx Pipeline pViewportState is null. Even if ")) { |
| 2214 | 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] | 2215 | } |
| 2216 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2217 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2218 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2219 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2220 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2221 | } |
| 2222 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2223 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2224 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2225 | { |
| 2226 | VkFlags msgFlags; |
| 2227 | std::string msgString; |
| 2228 | VkResult err; |
| 2229 | |
| 2230 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2231 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2232 | m_errorMonitor->ClearState(); |
| 2233 | |
| 2234 | VkDescriptorTypeCount ds_type_count = {}; |
| 2235 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2236 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2237 | |
| 2238 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2239 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2240 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2241 | ds_pool_ci.typeCount = 1; |
| 2242 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2243 | |
| 2244 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2245 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2246 | ASSERT_VK_SUCCESS(err); |
| 2247 | |
| 2248 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2249 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2250 | dsl_binding.arraySize = 1; |
| 2251 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2252 | |
| 2253 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2254 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2255 | ds_layout_ci.bindingCount = 1; |
| 2256 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2257 | |
| 2258 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2259 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2260 | ASSERT_VK_SUCCESS(err); |
| 2261 | |
| 2262 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2263 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2264 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2265 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2266 | alloc_info.descriptorPool = ds_pool; |
| 2267 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2268 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2269 | ASSERT_VK_SUCCESS(err); |
| 2270 | |
| 2271 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2272 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2273 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2274 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2275 | |
| 2276 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2277 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2278 | ASSERT_VK_SUCCESS(err); |
| 2279 | |
| 2280 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2281 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2282 | vp_state_ci.viewportCount = 1; |
| 2283 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2284 | vp_state_ci.scissorCount = 1; |
| 2285 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2286 | |
| 2287 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2288 | // Set scissor as dynamic to avoid that error |
| 2289 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2290 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2291 | dyn_state_ci.dynamicStateCount = 1; |
| 2292 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2293 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2294 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2295 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2296 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2297 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2298 | 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] | 2299 | // but add it to be able to run on more devices |
| 2300 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2301 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2302 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2303 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2304 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2305 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2306 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2307 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2308 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2309 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2310 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2311 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2312 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2313 | |
| 2314 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2315 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2316 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2317 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2318 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2319 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO; |
| 2320 | rs_ci.pNext = nullptr; |
| 2321 | |
| 2322 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2323 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2324 | cb_ci.pNext = nullptr; |
| 2325 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2326 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2327 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2328 | gp_ci.stageCount = 2; |
| 2329 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2330 | gp_ci.pVertexInputState = &vi_ci; |
| 2331 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2332 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2333 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2334 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2335 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2336 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2337 | gp_ci.layout = pipeline_layout; |
| 2338 | gp_ci.renderPass = renderPass(); |
| 2339 | |
| 2340 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2341 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2342 | |
| 2343 | VkPipeline pipeline; |
| 2344 | VkPipelineCache pipelineCache; |
| 2345 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2346 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2347 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2348 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2349 | |
| 2350 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2351 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o scissor set."; |
| 2352 | if (!strstr(msgString.c_str(),"Gfx Pipeline viewportCount is 1, but pViewports is NULL. ")) { |
| 2353 | FAIL() << "Error received was not 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...' but instead it was '" << msgString.c_str() << "'"; |
| 2354 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2355 | m_errorMonitor->ClearState(); |
| 2356 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2357 | // First need to successfully create the PSO from above by setting pViewports |
| 2358 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2359 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2360 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2361 | ASSERT_VK_SUCCESS(err); |
| 2362 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2363 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2364 | VkRect2D scissors[2] = {}; // don't care about data |
| 2365 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2366 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 2, scissors); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2367 | Draw(1, 0, 0, 0); |
| 2368 | |
| 2369 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2370 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after setting dynamic scissorCount different from PSO scissorCount."; |
| 2371 | if (!strstr(msgString.c_str(),"Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match.")) { |
| 2372 | FAIL() << "Error received was not 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...' but instead it was '" << msgString.c_str() << "'"; |
| 2373 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2374 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2375 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2376 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2377 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2378 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2379 | } |
| 2380 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2381 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2382 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2383 | { |
| 2384 | VkFlags msgFlags; |
| 2385 | std::string msgString; |
| 2386 | VkResult err; |
| 2387 | |
| 2388 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2389 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2390 | m_errorMonitor->ClearState(); |
| 2391 | |
| 2392 | VkDescriptorTypeCount ds_type_count = {}; |
| 2393 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2394 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2395 | |
| 2396 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2397 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2398 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2399 | ds_pool_ci.typeCount = 1; |
| 2400 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2401 | |
| 2402 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2403 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2404 | ASSERT_VK_SUCCESS(err); |
| 2405 | |
| 2406 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2407 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2408 | dsl_binding.arraySize = 1; |
| 2409 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2410 | |
| 2411 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2412 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2413 | ds_layout_ci.bindingCount = 1; |
| 2414 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2415 | |
| 2416 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2417 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2418 | ASSERT_VK_SUCCESS(err); |
| 2419 | |
| 2420 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2421 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2422 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2423 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2424 | alloc_info.descriptorPool = ds_pool; |
| 2425 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2426 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2427 | ASSERT_VK_SUCCESS(err); |
| 2428 | |
| 2429 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2430 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2431 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2432 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2433 | |
| 2434 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2435 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2436 | ASSERT_VK_SUCCESS(err); |
| 2437 | |
| 2438 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2439 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2440 | vp_state_ci.scissorCount = 1; |
| 2441 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2442 | vp_state_ci.viewportCount = 1; |
| 2443 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2444 | |
| 2445 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2446 | // Set scissor as dynamic to avoid that error |
| 2447 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2448 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2449 | dyn_state_ci.dynamicStateCount = 1; |
| 2450 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2451 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2452 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2453 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2454 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2455 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2456 | 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] | 2457 | // but add it to be able to run on more devices |
| 2458 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2459 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2460 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2461 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2462 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2463 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2464 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2465 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2466 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2467 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2468 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2469 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2470 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2471 | |
| 2472 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2473 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2474 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2475 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2476 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2477 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO; |
| 2478 | rs_ci.pNext = nullptr; |
| 2479 | |
| 2480 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2481 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2482 | cb_ci.pNext = nullptr; |
| 2483 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2484 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2485 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2486 | gp_ci.stageCount = 2; |
| 2487 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2488 | gp_ci.pVertexInputState = &vi_ci; |
| 2489 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2490 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2491 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2492 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2493 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2494 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2495 | gp_ci.layout = pipeline_layout; |
| 2496 | gp_ci.renderPass = renderPass(); |
| 2497 | |
| 2498 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2499 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2500 | |
| 2501 | VkPipeline pipeline; |
| 2502 | VkPipelineCache pipelineCache; |
| 2503 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2504 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2505 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2506 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2507 | |
| 2508 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2509 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating Gfx Pipeline w/o scissor set."; |
| 2510 | if (!strstr(msgString.c_str(),"Gfx Pipeline scissorCount is 1, but pScissors is NULL. ")) { |
| 2511 | FAIL() << "Error received was not 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...' but instead it was '" << msgString.c_str() << "'"; |
| 2512 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2513 | m_errorMonitor->ClearState(); |
| 2514 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2515 | // First need to successfully create the PSO from above by setting pViewports |
| 2516 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 2517 | vp_state_ci.pScissors = ≻ |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2518 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2519 | ASSERT_VK_SUCCESS(err); |
| 2520 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2521 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2522 | VkViewport viewports[2] = {}; // don't care about data |
| 2523 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2524 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2525 | Draw(1, 0, 0, 0); |
| 2526 | |
| 2527 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2528 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after setting dynamic viewportCount different from PSO viewportCount."; |
| 2529 | if (!strstr(msgString.c_str(),"Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match.")) { |
| 2530 | FAIL() << "Error received was not 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...' but instead it was '" << msgString.c_str() << "'"; |
| 2531 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2532 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2533 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2534 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2535 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2536 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2537 | } |
| 2538 | |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2539 | TEST_F(VkLayerTest, NullRenderPass) |
| 2540 | { |
| 2541 | // Bind a NULL RenderPass |
| 2542 | VkFlags msgFlags; |
| 2543 | std::string msgString; |
| 2544 | |
| 2545 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2546 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2547 | m_errorMonitor->ClearState(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2548 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2549 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2550 | // Don't care about RenderPass handle b/c error should be flagged before that |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2551 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, VK_RENDER_PASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2552 | |
| 2553 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2554 | 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] | 2555 | if (!strstr(msgString.c_str(),"You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()")) { |
| 2556 | FAIL() << "Error received was not 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 2557 | } |
| 2558 | } |
| 2559 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2560 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 2561 | { |
| 2562 | // Bind a BeginRenderPass within an active RenderPass |
| 2563 | VkFlags msgFlags; |
| 2564 | std::string msgString; |
| 2565 | |
| 2566 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2567 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2568 | m_errorMonitor->ClearState(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2569 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2570 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2571 | // 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] | 2572 | VkRenderPassBeginInfo rp_begin = {}; |
| 2573 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 2574 | rp_begin.pNext = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2575 | rp_begin.renderPass = renderPass(); |
| 2576 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2577 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2578 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, VK_RENDER_PASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2579 | |
| 2580 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2581 | 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] | 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...'"; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2584 | } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2585 | } |
| 2586 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2587 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 2588 | { |
| 2589 | // Call CmdFillBuffer 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 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2601 | vk_testing::Buffer dstBuffer; |
| 2602 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2603 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2604 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2605 | |
| 2606 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2607 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2608 | "Did not receive error after calling CmdFillBuffer w/i an active RenderPass."; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2609 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2610 | 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] | 2611 | } |
| 2612 | } |
| 2613 | |
| 2614 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 2615 | { |
| 2616 | // Call CmdUpdateBuffer within an active renderpass |
| 2617 | VkFlags msgFlags; |
| 2618 | std::string msgString; |
| 2619 | |
| 2620 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2621 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2622 | m_errorMonitor->ClearState(); |
| 2623 | |
| 2624 | // Renderpass is started here |
| 2625 | BeginCommandBuffer(); |
| 2626 | |
| 2627 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2628 | vk_testing::Buffer dstBuffer; |
| 2629 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2630 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2631 | VkDeviceSize dstOffset = 0; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2632 | VkDeviceSize dataSize = 1024; |
| 2633 | const uint32_t *pData = NULL; |
| 2634 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2635 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2636 | |
| 2637 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2638 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2639 | "Did not receive error after calling CmdUpdateBuffer w/i an active RenderPass."; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2640 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2641 | 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] | 2642 | } |
| 2643 | } |
| 2644 | |
| 2645 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 2646 | { |
| 2647 | // Call CmdClearColorImage within an active RenderPass |
| 2648 | VkFlags msgFlags; |
| 2649 | std::string msgString; |
| 2650 | |
| 2651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2652 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2653 | m_errorMonitor->ClearState(); |
| 2654 | |
| 2655 | // Renderpass is started here |
| 2656 | BeginCommandBuffer(); |
| 2657 | |
| 2658 | VkClearColorValue clear_color = {0}; |
| 2659 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2660 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2661 | const int32_t tex_width = 32; |
| 2662 | const int32_t tex_height = 32; |
| 2663 | VkImageCreateInfo image_create_info = {}; |
| 2664 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2665 | image_create_info.pNext = NULL; |
| 2666 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2667 | image_create_info.format = tex_format; |
| 2668 | image_create_info.extent.width = tex_width; |
| 2669 | image_create_info.extent.height = tex_height; |
| 2670 | image_create_info.extent.depth = 1; |
| 2671 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2672 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2673 | image_create_info.samples = 1; |
| 2674 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2675 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2676 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2677 | vk_testing::Image dstImage; |
| 2678 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2679 | |
| 2680 | const VkImageSubresourceRange range = |
| 2681 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 2682 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2683 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), |
| 2684 | dstImage.handle(), |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2685 | VK_IMAGE_LAYOUT_GENERAL, |
| 2686 | &clear_color, |
| 2687 | 1, |
| 2688 | &range); |
| 2689 | |
| 2690 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2691 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2692 | "Did not receive error after calling CmdClearColorImage w/i an active RenderPass."; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2693 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2694 | 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] | 2695 | } |
| 2696 | } |
| 2697 | |
| 2698 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 2699 | { |
| 2700 | // Call CmdClearDepthStencilImage within an active RenderPass |
| 2701 | VkFlags msgFlags; |
| 2702 | std::string msgString; |
| 2703 | |
| 2704 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2705 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2706 | m_errorMonitor->ClearState(); |
| 2707 | |
| 2708 | // Renderpass is started here |
| 2709 | BeginCommandBuffer(); |
| 2710 | |
| 2711 | VkClearDepthStencilValue clear_value = {0}; |
| 2712 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2713 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 2714 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2715 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 2716 | image_create_info.extent.width = 64; |
| 2717 | image_create_info.extent.height = 64; |
| 2718 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2719 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 2720 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2721 | vk_testing::Image dstImage; |
| 2722 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2723 | |
| 2724 | const VkImageSubresourceRange range = |
| 2725 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2726 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2727 | vkCmdClearDepthStencilImage(m_commandBuffer->GetBufferHandle(), |
| 2728 | dstImage.handle(), |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2729 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 2730 | &clear_value, |
| 2731 | 1, |
| 2732 | &range); |
| 2733 | |
| 2734 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2735 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
| 2736 | "Did not receive error after calling CmdClearDepthStencilImage w/i an active RenderPass."; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2737 | if (!strstr(msgString.c_str(),"It is invalid to issue this call inside an active render pass")) { |
| 2738 | 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] | 2739 | } |
| 2740 | } |
| 2741 | |
| 2742 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 2743 | { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2744 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2745 | VkFlags msgFlags; |
| 2746 | std::string msgString; |
| 2747 | VkResult err; |
| 2748 | |
| 2749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2750 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2751 | m_errorMonitor->ClearState(); |
| 2752 | |
| 2753 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2754 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2755 | ASSERT_VK_SUCCESS(err); |
| 2756 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2757 | VkClearAttachment color_attachment; |
| 2758 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2759 | color_attachment.clearValue.color.float32[0] = 0; |
| 2760 | color_attachment.clearValue.color.float32[1] = 0; |
| 2761 | color_attachment.clearValue.color.float32[2] = 0; |
| 2762 | color_attachment.clearValue.color.float32[3] = 0; |
| 2763 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2764 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2765 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2766 | 1, &color_attachment, |
| 2767 | 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2768 | |
| 2769 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2770 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2771 | "Did not receive error after calling CmdClearAttachments outside of an active RenderPass."; |
| 2772 | if (!strstr(msgString.c_str(),"vkCmdClearAttachments: This call must be issued inside an active render pass")) { |
| 2773 | 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] | 2774 | } |
| 2775 | } |
| 2776 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2777 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 2778 | { |
| 2779 | // Create a valid cmd buffer |
| 2780 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2781 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 2782 | // 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] | 2783 | } |
Tobin Ehlis | 1056d45 | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 2784 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2785 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 2786 | { |
| 2787 | // Bind a BeginRenderPass within an active RenderPass |
| 2788 | VkFlags msgFlags; |
| 2789 | std::string msgString; |
| 2790 | VkResult err; |
| 2791 | |
| 2792 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2793 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2794 | m_errorMonitor->ClearState(); |
| 2795 | uint32_t qfi = 0; |
| 2796 | VkBufferCreateInfo buffCI = {}; |
| 2797 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2798 | buffCI.size = 1024; |
| 2799 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2800 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2801 | buffCI.pQueueFamilyIndices = &qfi; |
| 2802 | |
| 2803 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2804 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2805 | ASSERT_VK_SUCCESS(err); |
| 2806 | |
| 2807 | BeginCommandBuffer(); |
| 2808 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2809 | //vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2810 | // Should error before calling to driver so don't care about actual data |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2811 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2812 | |
| 2813 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2814 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after vkCmdBindVertexBuffers() w/o active RenderPass."; |
| 2815 | if (!strstr(msgString.c_str(),"vkCmdBindIndexBuffer() offset (0x7) does not fall on ")) { |
| 2816 | FAIL() << "Error received was not 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...' but instead '" << msgString.c_str() << "'"; |
| 2817 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2818 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2819 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2820 | } |
| 2821 | |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2822 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 2823 | { |
| 2824 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
| 2825 | VkFlags msgFlags; |
| 2826 | std::string msgString; |
| 2827 | |
| 2828 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2829 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2830 | m_errorMonitor->ClearState(); |
| 2831 | |
| 2832 | BeginCommandBuffer(); |
| 2833 | //ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2834 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 2835 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2836 | |
| 2837 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 2838 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after vkCmdBindVertexBuffers() w/o active RenderPass."; |
| 2839 | if (!strstr(msgString.c_str(),"vkCmdExecuteCommands() called w/ Primary Cmd Buffer ")) { |
| 2840 | FAIL() << "Error received was not 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer ' but instead '" << msgString.c_str() << "'"; |
| 2841 | } |
| 2842 | } |
| 2843 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2844 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 2845 | { |
| 2846 | // 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] | 2847 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2848 | std::string msgString; |
| 2849 | VkResult err; |
| 2850 | |
| 2851 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2852 | m_errorMonitor->ClearState(); |
| 2853 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2854 | VkDescriptorTypeCount ds_type_count = {}; |
| 2855 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2856 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2857 | |
| 2858 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2859 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2860 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2861 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2862 | ds_pool_ci.typeCount = 1; |
| 2863 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2864 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2865 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2866 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2867 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2868 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2869 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2870 | dsl_binding.arraySize = 1; |
| 2871 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2872 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2873 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2874 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2875 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2876 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2877 | ds_layout_ci.bindingCount = 1; |
| 2878 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2879 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2880 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2881 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2882 | ASSERT_VK_SUCCESS(err); |
| 2883 | |
| 2884 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2885 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2886 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2887 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2888 | alloc_info.descriptorPool = ds_pool; |
| 2889 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2890 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2891 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2892 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2893 | VkSamplerCreateInfo sampler_ci = {}; |
| 2894 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2895 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2896 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 2897 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 2898 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 2899 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2900 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2901 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2902 | sampler_ci.mipLodBias = 1.0; |
| 2903 | sampler_ci.maxAnisotropy = 1; |
| 2904 | sampler_ci.compareEnable = VK_FALSE; |
| 2905 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2906 | sampler_ci.minLod = 1.0; |
| 2907 | sampler_ci.maxLod = 1.0; |
| 2908 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2909 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 2910 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2911 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2912 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2913 | ASSERT_VK_SUCCESS(err); |
| 2914 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2915 | VkDescriptorImageInfo info = {}; |
| 2916 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2917 | |
| 2918 | VkWriteDescriptorSet descriptor_write; |
| 2919 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2920 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2921 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2922 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2923 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2924 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2925 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2926 | |
| 2927 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2928 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2929 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 2930 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating BUFFER Descriptor w/ incorrect type of SAMPLER."; |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 2931 | if (!strstr(msgString.c_str(),"Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match ")) { |
| 2932 | FAIL() << "Error received was not 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...' but instead '" << msgString.c_str() << "'"; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2933 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2934 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2935 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 2936 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2937 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2938 | } |
| 2939 | |
| 2940 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 2941 | { |
| 2942 | // For overlapping Update, have arrayIndex exceed that of layout |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2943 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2944 | std::string msgString; |
| 2945 | VkResult err; |
| 2946 | |
| 2947 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2948 | m_errorMonitor->ClearState(); |
| 2949 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2950 | VkDescriptorTypeCount ds_type_count = {}; |
| 2951 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2952 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2953 | |
| 2954 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2955 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2956 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2957 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2958 | ds_pool_ci.typeCount = 1; |
| 2959 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2960 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2961 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2962 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2963 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2964 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2965 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2966 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2967 | dsl_binding.arraySize = 1; |
| 2968 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2969 | dsl_binding.pImmutableSamplers = NULL; |
| 2970 | |
| 2971 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2972 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2973 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2974 | ds_layout_ci.bindingCount = 1; |
| 2975 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2976 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2977 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2978 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2979 | ASSERT_VK_SUCCESS(err); |
| 2980 | |
| 2981 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2982 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2983 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2984 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2985 | alloc_info.descriptorPool = ds_pool; |
| 2986 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2987 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2988 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2989 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2990 | VkSamplerCreateInfo sampler_ci = {}; |
| 2991 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2992 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2993 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 2994 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 2995 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 2996 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2997 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2998 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2999 | sampler_ci.mipLodBias = 1.0; |
| 3000 | sampler_ci.maxAnisotropy = 1; |
| 3001 | sampler_ci.compareEnable = VK_FALSE; |
| 3002 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3003 | sampler_ci.minLod = 1.0; |
| 3004 | sampler_ci.maxLod = 1.0; |
| 3005 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3006 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3007 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3008 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3009 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3010 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3011 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3012 | VkDescriptorImageInfo info = {}; |
| 3013 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3014 | |
| 3015 | VkWriteDescriptorSet descriptor_write; |
| 3016 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3017 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3018 | descriptor_write.dstSet = descriptorSet; |
| 3019 | descriptor_write.dstArrayElement = 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3020 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3021 | // 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] | 3022 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3023 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3024 | |
| 3025 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3026 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3027 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3028 | 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] | 3029 | if (!strstr(msgString.c_str(),"Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding")) { |
| 3030 | 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] | 3031 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3032 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3033 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3034 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3035 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3036 | } |
| 3037 | |
| 3038 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3039 | { |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3040 | // 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] | 3041 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3042 | std::string msgString; |
| 3043 | VkResult err; |
| 3044 | |
| 3045 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3046 | m_errorMonitor->ClearState(); |
| 3047 | //VkDescriptorSetObj descriptorSet(m_device); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3048 | VkDescriptorTypeCount ds_type_count = {}; |
| 3049 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3050 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3051 | |
| 3052 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3053 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3054 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3055 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3056 | ds_pool_ci.typeCount = 1; |
| 3057 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3058 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3059 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3060 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3061 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3062 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3063 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3064 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3065 | dsl_binding.arraySize = 1; |
| 3066 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3067 | dsl_binding.pImmutableSamplers = NULL; |
| 3068 | |
| 3069 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3070 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3071 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3072 | ds_layout_ci.bindingCount = 1; |
| 3073 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3074 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3075 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3076 | ASSERT_VK_SUCCESS(err); |
| 3077 | |
| 3078 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3079 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3080 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3081 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3082 | alloc_info.descriptorPool = ds_pool; |
| 3083 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3084 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3085 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3086 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3087 | VkSamplerCreateInfo sampler_ci = {}; |
| 3088 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3089 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3090 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3091 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3092 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3093 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3094 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3095 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3096 | sampler_ci.mipLodBias = 1.0; |
| 3097 | sampler_ci.maxAnisotropy = 1; |
| 3098 | sampler_ci.compareEnable = VK_FALSE; |
| 3099 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3100 | sampler_ci.minLod = 1.0; |
| 3101 | sampler_ci.maxLod = 1.0; |
| 3102 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3103 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3104 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3105 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3106 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3107 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3108 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3109 | VkDescriptorImageInfo info = {}; |
| 3110 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3111 | |
| 3112 | VkWriteDescriptorSet descriptor_write; |
| 3113 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3114 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3115 | descriptor_write.dstSet = descriptorSet; |
| 3116 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3117 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3118 | // 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] | 3119 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3120 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3121 | |
| 3122 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3123 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3124 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3125 | 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] | 3126 | if (!strstr(msgString.c_str()," does not have binding to match update binding ")) { |
| 3127 | FAIL() << "Error received was not 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3128 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3129 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3130 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3131 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3132 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3133 | } |
| 3134 | |
| 3135 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3136 | { |
| 3137 | // 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] | 3138 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3139 | std::string msgString; |
| 3140 | VkResult err; |
| 3141 | |
| 3142 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3143 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3144 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3145 | VkDescriptorTypeCount ds_type_count = {}; |
| 3146 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3147 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3148 | |
| 3149 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3150 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3151 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3152 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3153 | ds_pool_ci.typeCount = 1; |
| 3154 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3155 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3156 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3157 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3158 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3159 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3160 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3161 | dsl_binding.arraySize = 1; |
| 3162 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3163 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3164 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3165 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3166 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3167 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3168 | ds_layout_ci.bindingCount = 1; |
| 3169 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3170 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3171 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3172 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3173 | ASSERT_VK_SUCCESS(err); |
| 3174 | |
| 3175 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3176 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3177 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3178 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3179 | alloc_info.descriptorPool = ds_pool; |
| 3180 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3181 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3182 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3183 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3184 | VkSamplerCreateInfo sampler_ci = {}; |
| 3185 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3186 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3187 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3188 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3189 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3190 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3191 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3192 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3193 | sampler_ci.mipLodBias = 1.0; |
| 3194 | sampler_ci.maxAnisotropy = 1; |
| 3195 | sampler_ci.compareEnable = VK_FALSE; |
| 3196 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3197 | sampler_ci.minLod = 1.0; |
| 3198 | sampler_ci.maxLod = 1.0; |
| 3199 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3200 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3201 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3202 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3203 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3204 | |
| 3205 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3206 | VkDescriptorImageInfo info = {}; |
| 3207 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3208 | |
| 3209 | VkWriteDescriptorSet descriptor_write; |
| 3210 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3211 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3212 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3213 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3214 | // 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] | 3215 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3216 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3217 | |
| 3218 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3219 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3220 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3221 | 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] | 3222 | if (!strstr(msgString.c_str(),"Unexpected UPDATE struct of type ")) { |
| 3223 | FAIL() << "Error received was not 'Unexpected UPDATE struct of type '"; |
| 3224 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3225 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3226 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3227 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3228 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3229 | } |
| 3230 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3231 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3232 | { |
| 3233 | // Create a single Sampler descriptor and send it an invalid Sampler |
| 3234 | VkFlags msgFlags; |
| 3235 | std::string msgString; |
| 3236 | VkResult err; |
| 3237 | |
| 3238 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3239 | m_errorMonitor->ClearState(); |
| 3240 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied code |
| 3241 | VkDescriptorTypeCount ds_type_count = {}; |
| 3242 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3243 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3244 | |
| 3245 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3246 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3247 | ds_pool_ci.pNext = NULL; |
| 3248 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3249 | ds_pool_ci.typeCount = 1; |
| 3250 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3251 | |
| 3252 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3253 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3254 | ASSERT_VK_SUCCESS(err); |
| 3255 | |
| 3256 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3257 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3258 | dsl_binding.arraySize = 1; |
| 3259 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3260 | dsl_binding.pImmutableSamplers = NULL; |
| 3261 | |
| 3262 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3263 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3264 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3265 | ds_layout_ci.bindingCount = 1; |
| 3266 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3267 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3268 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3269 | ASSERT_VK_SUCCESS(err); |
| 3270 | |
| 3271 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3272 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3273 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3274 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3275 | alloc_info.descriptorPool = ds_pool; |
| 3276 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3277 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3278 | ASSERT_VK_SUCCESS(err); |
| 3279 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3280 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3281 | |
| 3282 | VkDescriptorImageInfo descriptor_info; |
| 3283 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3284 | descriptor_info.sampler = sampler; |
| 3285 | |
| 3286 | VkWriteDescriptorSet descriptor_write; |
| 3287 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3288 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3289 | descriptor_write.dstSet = descriptorSet; |
| 3290 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3291 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3292 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3293 | descriptor_write.pImageInfo = &descriptor_info; |
| 3294 | |
| 3295 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3296 | |
| 3297 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3298 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ invalid VkSampler."; |
| 3299 | if (!strstr(msgString.c_str(),"Attempt to update descriptor with invalid sampler 0xbaadbeef")) { |
| 3300 | FAIL() << "Error received was not 'Attempt to update descriptor with invalid sampler...' but instead '" << msgString.c_str() << "'"; |
| 3301 | } |
| 3302 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3303 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3304 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3305 | } |
| 3306 | |
| 3307 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3308 | { |
| 3309 | // Create a single combined Image/Sampler descriptor and send it an invalid imageView |
| 3310 | VkFlags msgFlags; |
| 3311 | std::string msgString; |
| 3312 | VkResult err; |
| 3313 | |
| 3314 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3315 | m_errorMonitor->ClearState(); |
| 3316 | VkDescriptorTypeCount ds_type_count = {}; |
| 3317 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3318 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3319 | |
| 3320 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3321 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3322 | ds_pool_ci.pNext = NULL; |
| 3323 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3324 | ds_pool_ci.typeCount = 1; |
| 3325 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3326 | |
| 3327 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3328 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3329 | ASSERT_VK_SUCCESS(err); |
| 3330 | |
| 3331 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3332 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3333 | dsl_binding.arraySize = 1; |
| 3334 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3335 | dsl_binding.pImmutableSamplers = NULL; |
| 3336 | |
| 3337 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3338 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3339 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3340 | ds_layout_ci.bindingCount = 1; |
| 3341 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3342 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3343 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3344 | ASSERT_VK_SUCCESS(err); |
| 3345 | |
| 3346 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3347 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3348 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3349 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3350 | alloc_info.descriptorPool = ds_pool; |
| 3351 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3352 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3353 | ASSERT_VK_SUCCESS(err); |
| 3354 | |
| 3355 | VkSamplerCreateInfo sampler_ci = {}; |
| 3356 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3357 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3358 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3359 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3360 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3361 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3362 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3363 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3364 | sampler_ci.mipLodBias = 1.0; |
| 3365 | sampler_ci.maxAnisotropy = 1; |
| 3366 | sampler_ci.compareEnable = VK_FALSE; |
| 3367 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3368 | sampler_ci.minLod = 1.0; |
| 3369 | sampler_ci.maxLod = 1.0; |
| 3370 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3371 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3372 | |
| 3373 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3374 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3375 | ASSERT_VK_SUCCESS(err); |
| 3376 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3377 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3378 | |
| 3379 | VkDescriptorImageInfo descriptor_info; |
| 3380 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3381 | descriptor_info.sampler = sampler; |
| 3382 | descriptor_info.imageView = view; |
| 3383 | |
| 3384 | VkWriteDescriptorSet descriptor_write; |
| 3385 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3386 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3387 | descriptor_write.dstSet = descriptorSet; |
| 3388 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3389 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3390 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3391 | descriptor_write.pImageInfo = &descriptor_info; |
| 3392 | |
| 3393 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3394 | |
| 3395 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3396 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after updating Descriptor w/ invalid VkImageView."; |
| 3397 | if (!strstr(msgString.c_str(),"Attempt to update descriptor with invalid imageView 0xbaadbeef")) { |
| 3398 | FAIL() << "Error received was not 'Attempt to update descriptor with invalid imageView...' but instead '" << msgString.c_str() << "'"; |
| 3399 | } |
| 3400 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3401 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3402 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3403 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3404 | } |
| 3405 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3406 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3407 | { |
| 3408 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update into the other |
| 3409 | VkFlags msgFlags; |
| 3410 | std::string msgString; |
| 3411 | VkResult err; |
| 3412 | |
| 3413 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3414 | m_errorMonitor->ClearState(); |
| 3415 | //VkDescriptorSetObj descriptorSet(m_device); |
| 3416 | VkDescriptorTypeCount ds_type_count[2] = {}; |
| 3417 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3418 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3419 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3420 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3421 | |
| 3422 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3423 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3424 | ds_pool_ci.pNext = NULL; |
| 3425 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3426 | ds_pool_ci.typeCount = 2; |
| 3427 | ds_pool_ci.pTypeCounts = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3428 | |
| 3429 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3430 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3431 | ASSERT_VK_SUCCESS(err); |
| 3432 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
| 3433 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3434 | dsl_binding[0].arraySize = 1; |
| 3435 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3436 | dsl_binding[0].pImmutableSamplers = NULL; |
| 3437 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3438 | dsl_binding[1].arraySize = 1; |
| 3439 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3440 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3441 | |
| 3442 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3443 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3444 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3445 | ds_layout_ci.bindingCount = 2; |
| 3446 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3447 | |
| 3448 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3449 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3450 | ASSERT_VK_SUCCESS(err); |
| 3451 | |
| 3452 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3453 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3454 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3455 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3456 | alloc_info.descriptorPool = ds_pool; |
| 3457 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3458 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3459 | ASSERT_VK_SUCCESS(err); |
| 3460 | |
| 3461 | VkSamplerCreateInfo sampler_ci = {}; |
| 3462 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3463 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3464 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3465 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3466 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3467 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3468 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3469 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3470 | sampler_ci.mipLodBias = 1.0; |
| 3471 | sampler_ci.maxAnisotropy = 1; |
| 3472 | sampler_ci.compareEnable = VK_FALSE; |
| 3473 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3474 | sampler_ci.minLod = 1.0; |
| 3475 | sampler_ci.maxLod = 1.0; |
| 3476 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3477 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3478 | |
| 3479 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3480 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3481 | ASSERT_VK_SUCCESS(err); |
| 3482 | |
| 3483 | VkDescriptorImageInfo info = {}; |
| 3484 | info.sampler = sampler; |
| 3485 | |
| 3486 | VkWriteDescriptorSet descriptor_write; |
| 3487 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 3488 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3489 | descriptor_write.dstSet = descriptorSet; |
| 3490 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3491 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3492 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3493 | descriptor_write.pImageInfo = &info; |
| 3494 | // This write update should succeed |
| 3495 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3496 | // Now perform a copy update that fails due to type mismatch |
| 3497 | VkCopyDescriptorSet copy_ds_update; |
| 3498 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3499 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3500 | copy_ds_update.srcSet = descriptorSet; |
| 3501 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3502 | copy_ds_update.dstSet = descriptorSet; |
| 3503 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3504 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3505 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3506 | |
| 3507 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3508 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after copying SAMPLER descriptor type to BUFFER descriptor type."; |
| 3509 | if (!strstr(msgString.c_str(),"Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER ")) { |
| 3510 | FAIL() << "Error received was not 'Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER...' but instead '" << msgString.c_str() << "'"; |
| 3511 | } |
| 3512 | // Now perform a copy update that fails due to binding out of bounds |
| 3513 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3514 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3515 | copy_ds_update.srcSet = descriptorSet; |
| 3516 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3517 | copy_ds_update.dstSet = descriptorSet; |
| 3518 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3519 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3520 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3521 | |
| 3522 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3523 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after attempting descriptor copy update w/ bad srcBinding."; |
| 3524 | if (!strstr(msgString.c_str(),"Copy descriptor update 0 has srcBinding 3 which is out of bounds ")) { |
| 3525 | FAIL() << "Error received was not 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...' but instead '" << msgString.c_str() << "'"; |
| 3526 | } |
| 3527 | // Now perform a copy update that fails due to binding out of bounds |
| 3528 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3529 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3530 | copy_ds_update.srcSet = descriptorSet; |
| 3531 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3532 | copy_ds_update.dstSet = descriptorSet; |
| 3533 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3534 | copy_ds_update.descriptorCount = 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3535 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3536 | |
| 3537 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3538 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after attempting descriptor copy update w/ count out of bounds for layout."; |
| 3539 | if (!strstr(msgString.c_str(),"Copy descriptor src update is out of bounds for matching binding 1 ")) { |
| 3540 | FAIL() << "Error received was not 'Copy descriptor src update is out of bounds for matching binding 1...' but instead '" << msgString.c_str() << "'"; |
| 3541 | } |
| 3542 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3543 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3544 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3545 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3546 | } |
| 3547 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3548 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 3549 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3550 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3551 | VkFlags msgFlags; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3552 | std::string msgString; |
| 3553 | VkResult err; |
| 3554 | |
| 3555 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3556 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3557 | m_errorMonitor->ClearState(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3558 | VkDescriptorTypeCount ds_type_count = {}; |
| 3559 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3560 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3561 | |
| 3562 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3563 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3564 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3565 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3566 | ds_pool_ci.typeCount = 1; |
| 3567 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3568 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3569 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3570 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3571 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3572 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3573 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3574 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3575 | dsl_binding.arraySize = 1; |
| 3576 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3577 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3578 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3579 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3580 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3581 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3582 | ds_layout_ci.bindingCount = 1; |
| 3583 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3584 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3585 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3586 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3587 | ASSERT_VK_SUCCESS(err); |
| 3588 | |
| 3589 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3590 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3591 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3592 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3593 | alloc_info.descriptorPool = ds_pool; |
| 3594 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3595 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3596 | ASSERT_VK_SUCCESS(err); |
| 3597 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3598 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3599 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3600 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3601 | pipe_ms_state_ci.rasterizationSamples = 4; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3602 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3603 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3604 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3605 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3606 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3607 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3608 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3609 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3610 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3611 | |
| 3612 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3613 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3614 | ASSERT_VK_SUCCESS(err); |
| 3615 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3616 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3617 | 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] | 3618 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3619 | VkPipelineObj pipe(m_device); |
| 3620 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3621 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3622 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3623 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3624 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3625 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3626 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3627 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3628 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3629 | 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] | 3630 | if (!strstr(msgString.c_str(),"Num samples mismatch! ")) { |
| 3631 | FAIL() << "Error received was not 'Num samples mismatch!...'"; |
| 3632 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3633 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3634 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3635 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3636 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3637 | } |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3638 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3639 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 3640 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3641 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior to issuing a Draw |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3642 | VkFlags msgFlags; |
| 3643 | std::string msgString; |
| 3644 | VkResult err; |
| 3645 | |
| 3646 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3647 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3648 | m_errorMonitor->ClearState(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3649 | |
| 3650 | VkDescriptorTypeCount ds_type_count = {}; |
| 3651 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3652 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3653 | |
| 3654 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3655 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3656 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3657 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3658 | ds_pool_ci.typeCount = 1; |
| 3659 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3660 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3661 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3662 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3663 | ASSERT_VK_SUCCESS(err); |
| 3664 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3665 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3666 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3667 | dsl_binding.arraySize = 1; |
| 3668 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3669 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3670 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3671 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3672 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3673 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3674 | ds_layout_ci.bindingCount = 1; |
| 3675 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3676 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3677 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3678 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3679 | ASSERT_VK_SUCCESS(err); |
| 3680 | |
| 3681 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3682 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3683 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3684 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3685 | alloc_info.descriptorPool = ds_pool; |
| 3686 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3687 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3688 | ASSERT_VK_SUCCESS(err); |
| 3689 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3690 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3691 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3692 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3693 | pipe_ms_state_ci.rasterizationSamples = 4; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3694 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3695 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3696 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3697 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3698 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3699 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3700 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3701 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3702 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3703 | |
| 3704 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3705 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3706 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3707 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3708 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3709 | 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] | 3710 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3711 | VkPipelineObj pipe(m_device); |
| 3712 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3713 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3714 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3715 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3716 | |
| 3717 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3718 | |
| 3719 | m_errorMonitor->ClearState(); |
| 3720 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 3721 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3722 | VkClearAttachment color_attachment; |
| 3723 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3724 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 3725 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 3726 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 3727 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 3728 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3729 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3730 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3731 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3732 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3733 | 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] | 3734 | if (!strstr(msgString.c_str(),"vkCmdClearAttachments() issued on CB object ")) { |
| 3735 | FAIL() << "Error received was not 'vkCmdClearAttachments() issued on CB object...'"; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3736 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3737 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3738 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3739 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3740 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3741 | } |
| 3742 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3743 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 3744 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3745 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3746 | VkFlags msgFlags; |
| 3747 | std::string msgString; |
| 3748 | VkResult err; |
| 3749 | |
| 3750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3751 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3752 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3753 | m_errorMonitor->ClearState(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3754 | |
| 3755 | VkDescriptorTypeCount ds_type_count = {}; |
| 3756 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3757 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3758 | |
| 3759 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3760 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3761 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3762 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3763 | ds_pool_ci.typeCount = 1; |
| 3764 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3765 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3766 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3767 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3768 | ASSERT_VK_SUCCESS(err); |
| 3769 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3770 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3771 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3772 | dsl_binding.arraySize = 1; |
| 3773 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3774 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3775 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3776 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3777 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3778 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3779 | ds_layout_ci.bindingCount = 1; |
| 3780 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3781 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3782 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3783 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3784 | ASSERT_VK_SUCCESS(err); |
| 3785 | |
| 3786 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3787 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3788 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3789 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3790 | alloc_info.descriptorPool = ds_pool; |
| 3791 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3792 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3793 | ASSERT_VK_SUCCESS(err); |
| 3794 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3795 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3796 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3797 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3798 | pipe_ms_state_ci.rasterizationSamples = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3799 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3800 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3801 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3802 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3803 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3804 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3805 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3806 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3807 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3808 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3809 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3810 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3811 | ASSERT_VK_SUCCESS(err); |
| 3812 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3813 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3814 | 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] | 3815 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3816 | VkPipelineObj pipe(m_device); |
| 3817 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3818 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3819 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3820 | pipe.SetViewport(m_viewports); |
| 3821 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3822 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3823 | |
| 3824 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3825 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 3826 | // Don't care about actual data, just need to get to draw to flag error |
| 3827 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 3828 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 3829 | 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] | 3830 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3831 | |
| 3832 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3833 | 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] | 3834 | 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] | 3835 | 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] | 3836 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3837 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3838 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3839 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3840 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3841 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3842 | #endif // DRAW_STATE_TESTS |
| 3843 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3844 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3845 | #if GTEST_IS_THREADSAFE |
| 3846 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3847 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3848 | VkEvent event; |
| 3849 | bool bailout; |
| 3850 | }; |
| 3851 | |
| 3852 | extern "C" void *AddToCommandBuffer(void *arg) |
| 3853 | { |
| 3854 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
| 3855 | std::string msgString; |
| 3856 | |
| 3857 | for (int i = 0; i<10000; i++) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3858 | vkCmdSetEvent(data->commandBuffer, data->event, VK_PIPELINE_STAGE_ALL_GPU_COMMANDS); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3859 | if (data->bailout) { |
| 3860 | break; |
| 3861 | } |
| 3862 | } |
| 3863 | return NULL; |
| 3864 | } |
| 3865 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3866 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3867 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3868 | VkFlags msgFlags; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3869 | std::string msgString; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3870 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3871 | |
| 3872 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3873 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3874 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3875 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3876 | m_errorMonitor->ClearState(); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3877 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3878 | // Calls AllocateCommandBuffers |
| 3879 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3880 | |
| 3881 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3882 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3883 | |
| 3884 | VkEventCreateInfo event_info; |
| 3885 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3886 | VkResult err; |
| 3887 | |
| 3888 | memset(&event_info, 0, sizeof(event_info)); |
| 3889 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3890 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3891 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3892 | ASSERT_VK_SUCCESS(err); |
| 3893 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3894 | err = vkResetEvent(device(), event); |
| 3895 | ASSERT_VK_SUCCESS(err); |
| 3896 | |
| 3897 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3898 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3899 | data.event = event; |
| 3900 | data.bailout = false; |
| 3901 | m_errorMonitor->SetBailout(&data.bailout); |
| 3902 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3903 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3904 | // Add many entries to command buffer from this thread at the same time. |
| 3905 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3906 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3907 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3908 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3909 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3910 | msgFlags = m_errorMonitor->GetState(&msgString); |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 3911 | 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] | 3912 | if (!strstr(msgString.c_str(),"THREADING ERROR")) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 3913 | FAIL() << "Error received was not 'THREADING ERROR'"; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3914 | } |
| 3915 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3916 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3917 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3918 | #endif // GTEST_IS_THREADSAFE |
| 3919 | #endif // THREADING_TESTS |
| 3920 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3921 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3922 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 3923 | { |
| 3924 | VkFlags msgFlags; |
| 3925 | std::string msgString; |
| 3926 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3927 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3928 | |
| 3929 | m_errorMonitor->ClearState(); |
| 3930 | |
| 3931 | VkShaderModule module; |
| 3932 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3933 | struct icd_spv_header spv; |
| 3934 | |
| 3935 | spv.magic = ICD_SPV_MAGIC; |
| 3936 | spv.version = ICD_SPV_VERSION; |
| 3937 | spv.gen_magic = 0; |
| 3938 | |
| 3939 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3940 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3941 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3942 | moduleCreateInfo.codeSize = 4; |
| 3943 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3944 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3945 | |
| 3946 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3947 | |
Chris Forbes | 46794b8 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 3948 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3949 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 3950 | FAIL() << "Incorrect warning: " << msgString; |
| 3951 | } |
| 3952 | } |
| 3953 | |
| 3954 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 3955 | { |
| 3956 | VkFlags msgFlags; |
| 3957 | std::string msgString; |
| 3958 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3959 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3960 | |
| 3961 | m_errorMonitor->ClearState(); |
| 3962 | |
| 3963 | VkShaderModule module; |
| 3964 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3965 | struct icd_spv_header spv; |
| 3966 | |
| 3967 | spv.magic = ~ICD_SPV_MAGIC; |
| 3968 | spv.version = ICD_SPV_VERSION; |
| 3969 | spv.gen_magic = 0; |
| 3970 | |
| 3971 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3972 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3973 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3974 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 3975 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3976 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3977 | |
| 3978 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 3979 | |
Chris Forbes | 46794b8 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 3980 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3981 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 3982 | FAIL() << "Incorrect warning: " << msgString; |
| 3983 | } |
| 3984 | } |
| 3985 | |
| 3986 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 3987 | { |
| 3988 | VkFlags msgFlags; |
| 3989 | std::string msgString; |
| 3990 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3991 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3992 | |
| 3993 | m_errorMonitor->ClearState(); |
| 3994 | |
| 3995 | VkShaderModule module; |
| 3996 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3997 | struct icd_spv_header spv; |
| 3998 | |
| 3999 | spv.magic = ICD_SPV_MAGIC; |
| 4000 | spv.version = ~ICD_SPV_VERSION; |
| 4001 | spv.gen_magic = 0; |
| 4002 | |
| 4003 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4004 | moduleCreateInfo.pNext = NULL; |
| 4005 | |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4006 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4007 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4008 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4009 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4010 | |
| 4011 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4012 | |
Chris Forbes | 46794b8 | 2015-09-18 11:40:23 +1200 | [diff] [blame] | 4013 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_ERROR_BIT); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4014 | if (!strstr(msgString.c_str(),"Shader is not SPIR-V")) { |
| 4015 | FAIL() << "Incorrect warning: " << msgString; |
| 4016 | } |
| 4017 | } |
| 4018 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4019 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 4020 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4021 | VkFlags msgFlags; |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4022 | std::string msgString; |
| 4023 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4024 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4025 | |
| 4026 | char const *vsSource = |
| 4027 | "#version 140\n" |
| 4028 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4029 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4030 | "\n" |
| 4031 | "layout(location=0) out float x;\n" |
| 4032 | "void main(){\n" |
| 4033 | " gl_Position = vec4(1);\n" |
| 4034 | " x = 0;\n" |
| 4035 | "}\n"; |
| 4036 | char const *fsSource = |
| 4037 | "#version 140\n" |
| 4038 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4039 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4040 | "\n" |
| 4041 | "layout(location=0) out vec4 color;\n" |
| 4042 | "void main(){\n" |
| 4043 | " color = vec4(1);\n" |
| 4044 | "}\n"; |
| 4045 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4046 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4047 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4048 | |
| 4049 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4050 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4051 | pipe.AddShader(&vs); |
| 4052 | pipe.AddShader(&fs); |
| 4053 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4054 | VkDescriptorSetObj descriptorSet(m_device); |
| 4055 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4056 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4057 | |
| 4058 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4059 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4060 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4061 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4062 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4063 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4064 | if (!strstr(msgString.c_str(),"not consumed by fragment shader")) { |
| 4065 | FAIL() << "Incorrect warning: " << msgString; |
| 4066 | } |
| 4067 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4068 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4069 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4070 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4071 | VkFlags msgFlags; |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4072 | std::string msgString; |
| 4073 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4074 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4075 | |
| 4076 | char const *vsSource = |
| 4077 | "#version 140\n" |
| 4078 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4079 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4080 | "\n" |
| 4081 | "void main(){\n" |
| 4082 | " gl_Position = vec4(1);\n" |
| 4083 | "}\n"; |
| 4084 | char const *fsSource = |
| 4085 | "#version 140\n" |
| 4086 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4087 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4088 | "\n" |
| 4089 | "layout(location=0) in float x;\n" |
| 4090 | "layout(location=0) out vec4 color;\n" |
| 4091 | "void main(){\n" |
| 4092 | " color = vec4(x);\n" |
| 4093 | "}\n"; |
| 4094 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4095 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4096 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4097 | |
| 4098 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4099 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4100 | pipe.AddShader(&vs); |
| 4101 | pipe.AddShader(&fs); |
| 4102 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4103 | VkDescriptorSetObj descriptorSet(m_device); |
| 4104 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4105 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4106 | |
| 4107 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4108 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4109 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4110 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4111 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4112 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4113 | if (!strstr(msgString.c_str(),"not written by vertex shader")) { |
| 4114 | FAIL() << "Incorrect error: " << msgString; |
| 4115 | } |
| 4116 | } |
| 4117 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4118 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4119 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4120 | VkFlags msgFlags; |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4121 | std::string msgString; |
| 4122 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4123 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4124 | |
| 4125 | char const *vsSource = |
| 4126 | "#version 140\n" |
| 4127 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4128 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4129 | "\n" |
| 4130 | "layout(location=0) out int x;\n" |
| 4131 | "void main(){\n" |
| 4132 | " x = 0;\n" |
| 4133 | " gl_Position = vec4(1);\n" |
| 4134 | "}\n"; |
| 4135 | char const *fsSource = |
| 4136 | "#version 140\n" |
| 4137 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4138 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4139 | "\n" |
| 4140 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4141 | "layout(location=0) out vec4 color;\n" |
| 4142 | "void main(){\n" |
| 4143 | " color = vec4(x);\n" |
| 4144 | "}\n"; |
| 4145 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4146 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4147 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4148 | |
| 4149 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4150 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4151 | pipe.AddShader(&vs); |
| 4152 | pipe.AddShader(&fs); |
| 4153 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4154 | VkDescriptorSetObj descriptorSet(m_device); |
| 4155 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4156 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4157 | |
| 4158 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4159 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4160 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4161 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4162 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4163 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4164 | if (!strstr(msgString.c_str(),"Type mismatch on location 0")) { |
| 4165 | FAIL() << "Incorrect error: " << msgString; |
| 4166 | } |
| 4167 | } |
| 4168 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4169 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4170 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4171 | VkFlags msgFlags; |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4172 | std::string msgString; |
| 4173 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4174 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4175 | |
| 4176 | VkVertexInputBindingDescription input_binding; |
| 4177 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4178 | |
| 4179 | VkVertexInputAttributeDescription input_attrib; |
| 4180 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4181 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4182 | |
| 4183 | char const *vsSource = |
| 4184 | "#version 140\n" |
| 4185 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4186 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4187 | "\n" |
| 4188 | "void main(){\n" |
| 4189 | " gl_Position = vec4(1);\n" |
| 4190 | "}\n"; |
| 4191 | char const *fsSource = |
| 4192 | "#version 140\n" |
| 4193 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4194 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4195 | "\n" |
| 4196 | "layout(location=0) out vec4 color;\n" |
| 4197 | "void main(){\n" |
| 4198 | " color = vec4(1);\n" |
| 4199 | "}\n"; |
| 4200 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4201 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4202 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4203 | |
| 4204 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4205 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4206 | pipe.AddShader(&vs); |
| 4207 | pipe.AddShader(&fs); |
| 4208 | |
| 4209 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4210 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4211 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4212 | VkDescriptorSetObj descriptorSet(m_device); |
| 4213 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4214 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4215 | |
| 4216 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4217 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4218 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4219 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4220 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4221 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4222 | if (!strstr(msgString.c_str(),"location 0 not consumed by VS")) { |
| 4223 | FAIL() << "Incorrect warning: " << msgString; |
| 4224 | } |
| 4225 | } |
| 4226 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4227 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4228 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4229 | VkFlags msgFlags; |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4230 | std::string msgString; |
| 4231 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4232 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4233 | |
| 4234 | char const *vsSource = |
| 4235 | "#version 140\n" |
| 4236 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4237 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4238 | "\n" |
| 4239 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4240 | "void main(){\n" |
| 4241 | " gl_Position = x;\n" |
| 4242 | "}\n"; |
| 4243 | char const *fsSource = |
| 4244 | "#version 140\n" |
| 4245 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4246 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4247 | "\n" |
| 4248 | "layout(location=0) out vec4 color;\n" |
| 4249 | "void main(){\n" |
| 4250 | " color = vec4(1);\n" |
| 4251 | "}\n"; |
| 4252 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4253 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4254 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4255 | |
| 4256 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4257 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4258 | pipe.AddShader(&vs); |
| 4259 | pipe.AddShader(&fs); |
| 4260 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4261 | VkDescriptorSetObj descriptorSet(m_device); |
| 4262 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4263 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4264 | |
| 4265 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4266 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4267 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4268 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4269 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4270 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4271 | if (!strstr(msgString.c_str(),"VS consumes input at location 0 but not provided")) { |
| 4272 | FAIL() << "Incorrect warning: " << msgString; |
| 4273 | } |
| 4274 | } |
| 4275 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4276 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4277 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4278 | VkFlags msgFlags; |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4279 | std::string msgString; |
| 4280 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4281 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4282 | |
| 4283 | VkVertexInputBindingDescription input_binding; |
| 4284 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4285 | |
| 4286 | VkVertexInputAttributeDescription input_attrib; |
| 4287 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4288 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4289 | |
| 4290 | char const *vsSource = |
| 4291 | "#version 140\n" |
| 4292 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4293 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4294 | "\n" |
| 4295 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4296 | "void main(){\n" |
| 4297 | " gl_Position = vec4(x);\n" |
| 4298 | "}\n"; |
| 4299 | char const *fsSource = |
| 4300 | "#version 140\n" |
| 4301 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4302 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4303 | "\n" |
| 4304 | "layout(location=0) out vec4 color;\n" |
| 4305 | "void main(){\n" |
| 4306 | " color = vec4(1);\n" |
| 4307 | "}\n"; |
| 4308 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4309 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4310 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4311 | |
| 4312 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4313 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4314 | pipe.AddShader(&vs); |
| 4315 | pipe.AddShader(&fs); |
| 4316 | |
| 4317 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4318 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4319 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4320 | VkDescriptorSetObj descriptorSet(m_device); |
| 4321 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4322 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4323 | |
| 4324 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4325 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4326 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4327 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4328 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4329 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4330 | if (!strstr(msgString.c_str(),"location 0 does not match VS input type")) { |
| 4331 | FAIL() << "Incorrect error: " << msgString; |
| 4332 | } |
| 4333 | } |
| 4334 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4335 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4336 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4337 | VkFlags msgFlags; |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4338 | std::string msgString; |
| 4339 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4340 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4341 | |
| 4342 | /* Two binding descriptions for binding 0 */ |
| 4343 | VkVertexInputBindingDescription input_bindings[2]; |
| 4344 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4345 | |
| 4346 | VkVertexInputAttributeDescription input_attrib; |
| 4347 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4348 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4349 | |
| 4350 | char const *vsSource = |
| 4351 | "#version 140\n" |
| 4352 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4353 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4354 | "\n" |
| 4355 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 4356 | "void main(){\n" |
| 4357 | " gl_Position = vec4(x);\n" |
| 4358 | "}\n"; |
| 4359 | char const *fsSource = |
| 4360 | "#version 140\n" |
| 4361 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4362 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4363 | "\n" |
| 4364 | "layout(location=0) out vec4 color;\n" |
| 4365 | "void main(){\n" |
| 4366 | " color = vec4(1);\n" |
| 4367 | "}\n"; |
| 4368 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4369 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4370 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4371 | |
| 4372 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4373 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4374 | pipe.AddShader(&vs); |
| 4375 | pipe.AddShader(&fs); |
| 4376 | |
| 4377 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 4378 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4379 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4380 | VkDescriptorSetObj descriptorSet(m_device); |
| 4381 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4382 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4383 | |
| 4384 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4385 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4386 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4387 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4388 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4389 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4390 | if (!strstr(msgString.c_str(),"Duplicate vertex input binding descriptions for binding 0")) { |
| 4391 | FAIL() << "Incorrect error: " << msgString; |
| 4392 | } |
| 4393 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 4394 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4395 | /* TODO: would be nice to test the mixed broadcast & custom case, but the GLSL->SPV compiler |
| 4396 | * rejects it. */ |
| 4397 | |
| 4398 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 4399 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4400 | VkFlags msgFlags; |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4401 | std::string msgString; |
| 4402 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4403 | |
| 4404 | char const *vsSource = |
| 4405 | "#version 140\n" |
| 4406 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4407 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4408 | "\n" |
| 4409 | "void main(){\n" |
| 4410 | " gl_Position = vec4(1);\n" |
| 4411 | "}\n"; |
| 4412 | char const *fsSource = |
| 4413 | "#version 140\n" |
| 4414 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4415 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4416 | "\n" |
| 4417 | "void main(){\n" |
| 4418 | "}\n"; |
| 4419 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4420 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4421 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4422 | |
| 4423 | VkPipelineObj pipe(m_device); |
| 4424 | pipe.AddShader(&vs); |
| 4425 | pipe.AddShader(&fs); |
| 4426 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4427 | /* set up CB 0, not written */ |
| 4428 | pipe.AddColorAttachment(); |
| 4429 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4430 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4431 | VkDescriptorSetObj descriptorSet(m_device); |
| 4432 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4433 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4434 | |
| 4435 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4436 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4437 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4438 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4439 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4440 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4441 | if (!strstr(msgString.c_str(),"Attachment 0 not written by FS")) { |
| 4442 | FAIL() << "Incorrect error: " << msgString; |
| 4443 | } |
| 4444 | } |
| 4445 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4446 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 4447 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4448 | VkFlags msgFlags; |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4449 | std::string msgString; |
| 4450 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4451 | |
| 4452 | char const *vsSource = |
| 4453 | "#version 140\n" |
| 4454 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4455 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4456 | "\n" |
| 4457 | "void main(){\n" |
| 4458 | " gl_Position = vec4(1);\n" |
| 4459 | "}\n"; |
| 4460 | char const *fsSource = |
| 4461 | "#version 140\n" |
| 4462 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4463 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4464 | "\n" |
| 4465 | "layout(location=0) out vec4 x;\n" |
| 4466 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 4467 | "void main(){\n" |
| 4468 | " x = vec4(1);\n" |
| 4469 | " y = vec4(1);\n" |
| 4470 | "}\n"; |
| 4471 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4472 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4473 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4474 | |
| 4475 | VkPipelineObj pipe(m_device); |
| 4476 | pipe.AddShader(&vs); |
| 4477 | pipe.AddShader(&fs); |
| 4478 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4479 | /* set up CB 0, not written */ |
| 4480 | pipe.AddColorAttachment(); |
| 4481 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4482 | /* FS writes CB 1, but we don't configure it */ |
| 4483 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4484 | VkDescriptorSetObj descriptorSet(m_device); |
| 4485 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4486 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4487 | |
| 4488 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4489 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4490 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4491 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4492 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4493 | ASSERT_NE(0, msgFlags & VK_DBG_REPORT_WARN_BIT); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4494 | if (!strstr(msgString.c_str(),"FS writes to output location 1 with no matching attachment")) { |
| 4495 | FAIL() << "Incorrect warning: " << msgString; |
| 4496 | } |
| 4497 | } |
| 4498 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4499 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 4500 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4501 | VkFlags msgFlags; |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4502 | std::string msgString; |
| 4503 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4504 | |
| 4505 | char const *vsSource = |
| 4506 | "#version 140\n" |
| 4507 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4508 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4509 | "\n" |
| 4510 | "void main(){\n" |
| 4511 | " gl_Position = vec4(1);\n" |
| 4512 | "}\n"; |
| 4513 | char const *fsSource = |
| 4514 | "#version 140\n" |
| 4515 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4516 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4517 | "\n" |
| 4518 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 4519 | "void main(){\n" |
| 4520 | " x = ivec4(1);\n" |
| 4521 | "}\n"; |
| 4522 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4523 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4524 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4525 | |
| 4526 | VkPipelineObj pipe(m_device); |
| 4527 | pipe.AddShader(&vs); |
| 4528 | pipe.AddShader(&fs); |
| 4529 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4530 | /* set up CB 0; type is UNORM by default */ |
| 4531 | pipe.AddColorAttachment(); |
| 4532 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4533 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4534 | VkDescriptorSetObj descriptorSet(m_device); |
| 4535 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4536 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4537 | |
| 4538 | m_errorMonitor->ClearState(); |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4539 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4540 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4541 | msgFlags = m_errorMonitor->GetState(&msgString); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4542 | |
Cody Northrop | d2ad034 | 2015-08-05 11:15:02 -0600 | [diff] [blame] | 4543 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4544 | if (!strstr(msgString.c_str(),"does not match FS output type")) { |
| 4545 | FAIL() << "Incorrect error: " << msgString; |
| 4546 | } |
| 4547 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 4548 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4549 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 4550 | { |
| 4551 | VkFlags msgFlags; |
| 4552 | std::string msgString; |
| 4553 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4554 | |
| 4555 | char const *vsSource = |
| 4556 | "#version 140\n" |
| 4557 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4558 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4559 | "\n" |
| 4560 | "void main(){\n" |
| 4561 | " gl_Position = vec4(1);\n" |
| 4562 | "}\n"; |
| 4563 | char const *fsSource = |
| 4564 | "#version 140\n" |
| 4565 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4566 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4567 | "\n" |
| 4568 | "layout(location=0) out vec4 x;\n" |
| 4569 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4570 | "void main(){\n" |
| 4571 | " x = vec4(bar.y);\n" |
| 4572 | "}\n"; |
| 4573 | |
| 4574 | m_errorMonitor->ClearState(); |
| 4575 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4576 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4577 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4578 | |
| 4579 | |
| 4580 | VkPipelineObj pipe(m_device); |
| 4581 | pipe.AddShader(&vs); |
| 4582 | pipe.AddShader(&fs); |
| 4583 | |
| 4584 | /* set up CB 0; type is UNORM by default */ |
| 4585 | pipe.AddColorAttachment(); |
| 4586 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4587 | |
| 4588 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4589 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4590 | |
| 4591 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4592 | |
| 4593 | /* should have generated an error -- pipeline layout does not |
| 4594 | * provide a uniform buffer in 0.0 |
| 4595 | */ |
| 4596 | msgFlags = m_errorMonitor->GetState(&msgString); |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 4597 | 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] | 4598 | if (!strstr(msgString.c_str(),"not declared in pipeline layout")) { |
| 4599 | FAIL() << "Incorrect error: " << msgString; |
| 4600 | } |
| 4601 | } |
| 4602 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4603 | #endif // SHADER_CHECKER_TESTS |
| 4604 | |
| 4605 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4606 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 4607 | { |
| 4608 | VkFlags msgFlags; |
| 4609 | std::string msgString; |
| 4610 | |
| 4611 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4612 | m_errorMonitor->ClearState(); |
| 4613 | |
| 4614 | // Create an image |
| 4615 | VkImage image; |
| 4616 | |
| 4617 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4618 | const int32_t tex_width = 32; |
| 4619 | const int32_t tex_height = 32; |
| 4620 | |
| 4621 | VkImageCreateInfo image_create_info = {}; |
| 4622 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4623 | image_create_info.pNext = NULL; |
| 4624 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4625 | image_create_info.format = tex_format; |
| 4626 | image_create_info.extent.width = tex_width; |
| 4627 | image_create_info.extent.height = tex_height; |
| 4628 | image_create_info.extent.depth = 1; |
| 4629 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4630 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4631 | image_create_info.samples = 1; |
| 4632 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4633 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4634 | image_create_info.flags = 0; |
| 4635 | |
| 4636 | // Introduce error by sending down a bogus width extent |
| 4637 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4638 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4639 | |
| 4640 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4641 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an image" << |
| 4642 | "with extents outside the queried limits"; |
| 4643 | if (!strstr(msgString.c_str(),"CreateImage extents exceed allowable limits for format")) { |
| 4644 | FAIL() << "Error received did not match expected error message from vkCreateImage in DeviceLimits layer"; |
| 4645 | } |
| 4646 | } |
| 4647 | |
| 4648 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 4649 | { |
| 4650 | VkFlags msgFlags; |
| 4651 | std::string msgString; |
| 4652 | |
| 4653 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4654 | m_errorMonitor->ClearState(); |
| 4655 | |
| 4656 | // Create an image |
| 4657 | VkImage image; |
| 4658 | |
| 4659 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4660 | const int32_t tex_width = 32; |
| 4661 | const int32_t tex_height = 32; |
| 4662 | |
| 4663 | VkImageCreateInfo image_create_info = {}; |
| 4664 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4665 | image_create_info.pNext = NULL; |
| 4666 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4667 | image_create_info.format = tex_format; |
| 4668 | image_create_info.extent.width = tex_width; |
| 4669 | image_create_info.extent.height = tex_height; |
| 4670 | image_create_info.extent.depth = 1; |
| 4671 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4672 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4673 | image_create_info.samples = 1; |
| 4674 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4675 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4676 | image_create_info.flags = 0; |
| 4677 | |
| 4678 | // Introduce error by sending down individually allowable values that result in a surface size |
| 4679 | // exceeding the device maximum |
| 4680 | image_create_info.extent.width = 8192; |
| 4681 | image_create_info.extent.height = 8192; |
| 4682 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4683 | image_create_info.arrayLayers = 4; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4684 | image_create_info.samples = 2; |
| 4685 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4686 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4687 | |
| 4688 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4689 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an image" << |
| 4690 | "with resource size exceeding queried limit"; |
| 4691 | if (!strstr(msgString.c_str(),"CreateImage resource size exceeds allowable maximum")) { |
| 4692 | FAIL() << "Error received did not match expected error message from vkCreateImage in DeviceLimits layer"; |
| 4693 | } |
| 4694 | } |
| 4695 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4696 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 4697 | { |
| 4698 | VkFlags msgFlags; |
| 4699 | std::string msgString; |
| 4700 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 4701 | |
| 4702 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4703 | |
| 4704 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4705 | vk_testing::Buffer buffer; |
| 4706 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4707 | |
| 4708 | BeginCommandBuffer(); |
| 4709 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4710 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4711 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4712 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling UpdateBuffer with bad offset"; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4713 | if (!strstr(msgString.c_str(),"dstOffset, is not a multiple of 4")) { |
| 4714 | FAIL() << "Error received was not 'vkCmdUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4715 | } |
| 4716 | // Introduce failure by using size that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4717 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4718 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4719 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling UpdateBuffer with bad size"; |
| 4720 | if (!strstr(msgString.c_str(),"dataSize, is not a multiple of 4")) { |
| 4721 | FAIL() << "Error received was not 'vkCmdUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 4722 | } |
| 4723 | EndCommandBuffer(); |
| 4724 | } |
| 4725 | |
| 4726 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 4727 | { |
| 4728 | VkFlags msgFlags; |
| 4729 | std::string msgString; |
| 4730 | |
| 4731 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4732 | |
| 4733 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4734 | vk_testing::Buffer buffer; |
| 4735 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4736 | |
| 4737 | BeginCommandBuffer(); |
| 4738 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4739 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4740 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4741 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling FillBuffer with bad offset"; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4742 | if (!strstr(msgString.c_str(),"dstOffset, is not a multiple of 4")) { |
| 4743 | FAIL() << "Error received was not 'vkCmdFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4744 | } |
| 4745 | // Introduce failure by using size that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4746 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4747 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4748 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an err after calling FillBuffer with bad size"; |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 4749 | if (!strstr(msgString.c_str(),"size, is not a multiple of 4")) { |
| 4750 | FAIL() << "Error received was not 'vkCmdFillBuffer parameter, VkDeviceSize size, is not a multiple of 4'"; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4751 | } |
| 4752 | EndCommandBuffer(); |
| 4753 | } |
| 4754 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4755 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4756 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4757 | #if IMAGE_TESTS |
| 4758 | TEST_F(VkLayerTest, InvalidImageView) |
| 4759 | { |
| 4760 | VkFlags msgFlags; |
| 4761 | std::string msgString; |
| 4762 | VkResult err; |
| 4763 | |
| 4764 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4765 | m_errorMonitor->ClearState(); |
| 4766 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4767 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4768 | VkImage image; |
| 4769 | |
| 4770 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4771 | const int32_t tex_width = 32; |
| 4772 | const int32_t tex_height = 32; |
| 4773 | |
| 4774 | VkImageCreateInfo image_create_info = {}; |
| 4775 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4776 | image_create_info.pNext = NULL; |
| 4777 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4778 | image_create_info.format = tex_format; |
| 4779 | image_create_info.extent.width = tex_width; |
| 4780 | image_create_info.extent.height = tex_height; |
| 4781 | image_create_info.extent.depth = 1; |
| 4782 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4783 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4784 | image_create_info.samples = 1; |
| 4785 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4786 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4787 | image_create_info.flags = 0; |
| 4788 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4789 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4790 | ASSERT_VK_SUCCESS(err); |
| 4791 | |
| 4792 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4793 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4794 | image_view_create_info.image = image; |
| 4795 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4796 | image_view_create_info.format = tex_format; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4797 | image_view_create_info.subresourceRange.layerCount = 1; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4798 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4799 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4800 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4801 | |
| 4802 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4803 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4804 | |
| 4805 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4806 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error while creating an invalid ImageView"; |
| 4807 | if (!strstr(msgString.c_str(),"vkCreateImageView called with baseMipLevel 10 ")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4808 | 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] | 4809 | } |
| 4810 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4811 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4812 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 4813 | { |
| 4814 | VkFlags msgFlags; |
| 4815 | std::string msgString; |
| 4816 | VkResult err; |
| 4817 | |
| 4818 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4819 | m_errorMonitor->ClearState(); |
| 4820 | |
| 4821 | // Create an image and try to create a view with an invalid aspectMask |
| 4822 | VkImage image; |
| 4823 | |
| 4824 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4825 | const int32_t tex_width = 32; |
| 4826 | const int32_t tex_height = 32; |
| 4827 | |
| 4828 | VkImageCreateInfo image_create_info = {}; |
| 4829 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4830 | image_create_info.pNext = NULL; |
| 4831 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4832 | image_create_info.format = tex_format; |
| 4833 | image_create_info.extent.width = tex_width; |
| 4834 | image_create_info.extent.height = tex_height; |
| 4835 | image_create_info.extent.depth = 1; |
| 4836 | image_create_info.mipLevels = 1; |
| 4837 | image_create_info.samples = 1; |
| 4838 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4839 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4840 | image_create_info.flags = 0; |
| 4841 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4842 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4843 | ASSERT_VK_SUCCESS(err); |
| 4844 | |
| 4845 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4846 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4847 | image_view_create_info.image = image; |
| 4848 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4849 | image_view_create_info.format = tex_format; |
| 4850 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4851 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4852 | // Cause an error by setting an invalid image aspect |
| 4853 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 4854 | |
| 4855 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4856 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4857 | |
| 4858 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4859 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error when specifying an invalid ImageView aspect"; |
| 4860 | if (!strstr(msgString.c_str(),"vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set")) { |
| 4861 | FAIL() << "Error received was not 'VkCreateImageView: Color image formats must have ...' but instead '" << msgString.c_str() << "'"; |
| 4862 | } |
| 4863 | } |
| 4864 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4865 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 4866 | { |
| 4867 | VkFlags msgFlags; |
| 4868 | std::string msgString; |
| 4869 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4870 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4871 | |
| 4872 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4873 | m_errorMonitor->ClearState(); |
| 4874 | |
| 4875 | // Create two images of different types and try to copy between them |
| 4876 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4877 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4878 | VkDeviceMemory srcMem; |
| 4879 | VkDeviceMemory destMem; |
| 4880 | VkMemoryRequirements memReqs; |
| 4881 | |
| 4882 | VkImageCreateInfo image_create_info = {}; |
| 4883 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4884 | image_create_info.pNext = NULL; |
| 4885 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4886 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4887 | image_create_info.extent.width = 32; |
| 4888 | image_create_info.extent.height = 32; |
| 4889 | image_create_info.extent.depth = 1; |
| 4890 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4891 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4892 | image_create_info.samples = 1; |
| 4893 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4894 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4895 | image_create_info.flags = 0; |
| 4896 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4897 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4898 | ASSERT_VK_SUCCESS(err); |
| 4899 | |
| 4900 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4901 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4902 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4903 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4904 | ASSERT_VK_SUCCESS(err); |
| 4905 | |
| 4906 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4907 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4908 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4909 | memAlloc.pNext = NULL; |
| 4910 | memAlloc.allocationSize = 0; |
| 4911 | memAlloc.memoryTypeIndex = 0; |
| 4912 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4913 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4914 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4915 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4916 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4917 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4918 | ASSERT_VK_SUCCESS(err); |
| 4919 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4920 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4921 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4922 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4923 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4924 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4925 | ASSERT_VK_SUCCESS(err); |
| 4926 | |
| 4927 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4928 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4929 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4930 | ASSERT_VK_SUCCESS(err); |
| 4931 | |
| 4932 | BeginCommandBuffer(); |
| 4933 | VkImageCopy copyRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 4934 | copyRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4935 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4936 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4937 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4938 | copyRegion.srcOffset.x = 0; |
| 4939 | copyRegion.srcOffset.y = 0; |
| 4940 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4941 | copyRegion.dstSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4942 | copyRegion.dstSubresource.mipLevel = 0; |
| 4943 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 4944 | copyRegion.dstSubresource.layerCount = 0; |
| 4945 | copyRegion.dstOffset.x = 0; |
| 4946 | copyRegion.dstOffset.y = 0; |
| 4947 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4948 | copyRegion.extent.width = 1; |
| 4949 | copyRegion.extent.height = 1; |
| 4950 | copyRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4951 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4952 | EndCommandBuffer(); |
| 4953 | |
| 4954 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 4955 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdCopyImage type mismatch"; |
| 4956 | if (!strstr(msgString.c_str(),"vkCmdCopyImage called with unmatched source and dest image types")) { |
| 4957 | FAIL() << "Error received was not 'vkCmdCopyImage called with unmatched source and dest image types' but instead '" << msgString.c_str() << "'"; |
| 4958 | } |
| 4959 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4960 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4961 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4962 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 4963 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4964 | } |
| 4965 | |
| 4966 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 4967 | { |
| 4968 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 4969 | } |
| 4970 | |
| 4971 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 4972 | { |
| 4973 | VkFlags msgFlags; |
| 4974 | std::string msgString; |
| 4975 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4976 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4977 | |
| 4978 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4979 | m_errorMonitor->ClearState(); |
| 4980 | |
| 4981 | // Create two images of different types and try to copy between them |
| 4982 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4983 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4984 | VkDeviceMemory srcMem; |
| 4985 | VkDeviceMemory destMem; |
| 4986 | VkMemoryRequirements memReqs; |
| 4987 | |
| 4988 | VkImageCreateInfo image_create_info = {}; |
| 4989 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4990 | image_create_info.pNext = NULL; |
| 4991 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4992 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4993 | image_create_info.extent.width = 32; |
| 4994 | image_create_info.extent.height = 32; |
| 4995 | image_create_info.extent.depth = 1; |
| 4996 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4997 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4998 | image_create_info.samples = 1; |
| 4999 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5000 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5001 | image_create_info.flags = 0; |
| 5002 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5003 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5004 | ASSERT_VK_SUCCESS(err); |
| 5005 | |
| 5006 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5007 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5008 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5009 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5010 | ASSERT_VK_SUCCESS(err); |
| 5011 | |
| 5012 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5013 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5014 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5015 | memAlloc.pNext = NULL; |
| 5016 | memAlloc.allocationSize = 0; |
| 5017 | memAlloc.memoryTypeIndex = 0; |
| 5018 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5019 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5020 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5021 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5022 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5023 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5024 | ASSERT_VK_SUCCESS(err); |
| 5025 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5026 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5027 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5028 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5029 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5030 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5031 | ASSERT_VK_SUCCESS(err); |
| 5032 | |
| 5033 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5034 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5035 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5036 | ASSERT_VK_SUCCESS(err); |
| 5037 | |
| 5038 | BeginCommandBuffer(); |
| 5039 | VkImageCopy copyRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5040 | copyRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5041 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5042 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5043 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5044 | copyRegion.srcOffset.x = 0; |
| 5045 | copyRegion.srcOffset.y = 0; |
| 5046 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5047 | copyRegion.dstSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5048 | copyRegion.dstSubresource.mipLevel = 0; |
| 5049 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5050 | copyRegion.dstSubresource.layerCount = 0; |
| 5051 | copyRegion.dstOffset.x = 0; |
| 5052 | copyRegion.dstOffset.y = 0; |
| 5053 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5054 | copyRegion.extent.width = 1; |
| 5055 | copyRegion.extent.height = 1; |
| 5056 | copyRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5057 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5058 | EndCommandBuffer(); |
| 5059 | |
| 5060 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5061 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdCopyImage type mismatch"; |
| 5062 | if (!strstr(msgString.c_str(),"vkCmdCopyImage called with unmatched source and dest image types")) { |
| 5063 | FAIL() << "Error received was not 'vkCmdCopyImage called with unmatched source and dest image types' but instead '" << msgString.c_str() << "'"; |
| 5064 | } |
| 5065 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5066 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5067 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5068 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5069 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5070 | } |
| 5071 | |
| 5072 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5073 | { |
| 5074 | VkFlags msgFlags; |
| 5075 | std::string msgString; |
| 5076 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5077 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5078 | |
| 5079 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5080 | m_errorMonitor->ClearState(); |
| 5081 | |
| 5082 | // Create two images of sample count 1 and try to Resolve between them |
| 5083 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5084 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5085 | VkDeviceMemory srcMem; |
| 5086 | VkDeviceMemory destMem; |
| 5087 | VkMemoryRequirements memReqs; |
| 5088 | |
| 5089 | VkImageCreateInfo image_create_info = {}; |
| 5090 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5091 | image_create_info.pNext = NULL; |
| 5092 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5093 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5094 | image_create_info.extent.width = 32; |
| 5095 | image_create_info.extent.height = 1; |
| 5096 | image_create_info.extent.depth = 1; |
| 5097 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5098 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5099 | image_create_info.samples = 1; |
| 5100 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5101 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5102 | image_create_info.flags = 0; |
| 5103 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5104 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5105 | ASSERT_VK_SUCCESS(err); |
| 5106 | |
| 5107 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5108 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5109 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5110 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5111 | ASSERT_VK_SUCCESS(err); |
| 5112 | |
| 5113 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5114 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5115 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5116 | memAlloc.pNext = NULL; |
| 5117 | memAlloc.allocationSize = 0; |
| 5118 | memAlloc.memoryTypeIndex = 0; |
| 5119 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5120 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5121 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5122 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5123 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5124 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5125 | ASSERT_VK_SUCCESS(err); |
| 5126 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5127 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5128 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5129 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5130 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5131 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5132 | ASSERT_VK_SUCCESS(err); |
| 5133 | |
| 5134 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5135 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5136 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5137 | ASSERT_VK_SUCCESS(err); |
| 5138 | |
| 5139 | BeginCommandBuffer(); |
| 5140 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5141 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5142 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5143 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5144 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5145 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5146 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5147 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5148 | resolveRegion.srcOffset.x = 0; |
| 5149 | resolveRegion.srcOffset.y = 0; |
| 5150 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5151 | resolveRegion.dstSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5152 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5153 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5154 | resolveRegion.dstSubresource.layerCount = 0; |
| 5155 | resolveRegion.dstOffset.x = 0; |
| 5156 | resolveRegion.dstOffset.y = 0; |
| 5157 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5158 | resolveRegion.extent.width = 1; |
| 5159 | resolveRegion.extent.height = 1; |
| 5160 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5161 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5162 | EndCommandBuffer(); |
| 5163 | |
| 5164 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5165 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage type mismatch"; |
| 5166 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with source sample count less than 2.")) { |
| 5167 | FAIL() << "Error received was not 'vkCmdResolveImage called with source sample count less than 2.' but instead '" << msgString.c_str() << "'"; |
| 5168 | } |
| 5169 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5170 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5171 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5172 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5173 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5174 | } |
| 5175 | |
| 5176 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5177 | { |
| 5178 | VkFlags msgFlags; |
| 5179 | std::string msgString; |
| 5180 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5181 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5182 | |
| 5183 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5184 | m_errorMonitor->ClearState(); |
| 5185 | |
| 5186 | // Create two images of sample count 2 and try to Resolve between them |
| 5187 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5188 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5189 | VkDeviceMemory srcMem; |
| 5190 | VkDeviceMemory destMem; |
| 5191 | VkMemoryRequirements memReqs; |
| 5192 | |
| 5193 | VkImageCreateInfo image_create_info = {}; |
| 5194 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5195 | image_create_info.pNext = NULL; |
| 5196 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5197 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5198 | image_create_info.extent.width = 32; |
| 5199 | image_create_info.extent.height = 1; |
| 5200 | image_create_info.extent.depth = 1; |
| 5201 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5202 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5203 | image_create_info.samples = 2; |
| 5204 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5205 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5206 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5207 | image_create_info.flags = 0; |
| 5208 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5209 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5210 | ASSERT_VK_SUCCESS(err); |
| 5211 | |
| 5212 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5213 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5214 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5215 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5216 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5217 | ASSERT_VK_SUCCESS(err); |
| 5218 | |
| 5219 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5220 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5221 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5222 | memAlloc.pNext = NULL; |
| 5223 | memAlloc.allocationSize = 0; |
| 5224 | memAlloc.memoryTypeIndex = 0; |
| 5225 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5226 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5227 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5228 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5229 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5230 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5231 | ASSERT_VK_SUCCESS(err); |
| 5232 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5233 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5234 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5235 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5236 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5237 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5238 | ASSERT_VK_SUCCESS(err); |
| 5239 | |
| 5240 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5241 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5242 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5243 | ASSERT_VK_SUCCESS(err); |
| 5244 | |
| 5245 | BeginCommandBuffer(); |
| 5246 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5247 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5248 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5249 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5250 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5251 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5252 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5253 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5254 | resolveRegion.srcOffset.x = 0; |
| 5255 | resolveRegion.srcOffset.y = 0; |
| 5256 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5257 | resolveRegion.dstSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5258 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5259 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5260 | resolveRegion.dstSubresource.layerCount = 0; |
| 5261 | resolveRegion.dstOffset.x = 0; |
| 5262 | resolveRegion.dstOffset.y = 0; |
| 5263 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5264 | resolveRegion.extent.width = 1; |
| 5265 | resolveRegion.extent.height = 1; |
| 5266 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5267 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5268 | EndCommandBuffer(); |
| 5269 | |
| 5270 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5271 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage type mismatch"; |
| 5272 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with dest sample count greater than 1.")) { |
| 5273 | FAIL() << "Error received was not 'vkCmdResolveImage called with dest sample count greater than 1.' but instead '" << msgString.c_str() << "'"; |
| 5274 | } |
| 5275 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5276 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5277 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5278 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5279 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5280 | } |
| 5281 | |
| 5282 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5283 | { |
| 5284 | VkFlags msgFlags; |
| 5285 | std::string msgString; |
| 5286 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5287 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5288 | |
| 5289 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5290 | m_errorMonitor->ClearState(); |
| 5291 | |
| 5292 | // Create two images of different types and try to copy between them |
| 5293 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5294 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5295 | VkDeviceMemory srcMem; |
| 5296 | VkDeviceMemory destMem; |
| 5297 | VkMemoryRequirements memReqs; |
| 5298 | |
| 5299 | VkImageCreateInfo image_create_info = {}; |
| 5300 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5301 | image_create_info.pNext = NULL; |
| 5302 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5303 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5304 | image_create_info.extent.width = 32; |
| 5305 | image_create_info.extent.height = 1; |
| 5306 | image_create_info.extent.depth = 1; |
| 5307 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5308 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5309 | image_create_info.samples = 2; |
| 5310 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5311 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5312 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5313 | image_create_info.flags = 0; |
| 5314 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5315 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5316 | ASSERT_VK_SUCCESS(err); |
| 5317 | |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5318 | // Set format to something other than source image |
| 5319 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5320 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5321 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5322 | image_create_info.samples = 1; |
| 5323 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5324 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5325 | ASSERT_VK_SUCCESS(err); |
| 5326 | |
| 5327 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5328 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5329 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5330 | memAlloc.pNext = NULL; |
| 5331 | memAlloc.allocationSize = 0; |
| 5332 | memAlloc.memoryTypeIndex = 0; |
| 5333 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5334 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5335 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5336 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5337 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5338 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5339 | ASSERT_VK_SUCCESS(err); |
| 5340 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5341 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5342 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5343 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5344 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5345 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5346 | ASSERT_VK_SUCCESS(err); |
| 5347 | |
| 5348 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5349 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5350 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5351 | ASSERT_VK_SUCCESS(err); |
| 5352 | |
| 5353 | BeginCommandBuffer(); |
| 5354 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5355 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5356 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5357 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5358 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5359 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5360 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5361 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5362 | resolveRegion.srcOffset.x = 0; |
| 5363 | resolveRegion.srcOffset.y = 0; |
| 5364 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5365 | resolveRegion.dstSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5366 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5367 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5368 | resolveRegion.dstSubresource.layerCount = 0; |
| 5369 | resolveRegion.dstOffset.x = 0; |
| 5370 | resolveRegion.dstOffset.y = 0; |
| 5371 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5372 | resolveRegion.extent.width = 1; |
| 5373 | resolveRegion.extent.height = 1; |
| 5374 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5375 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5376 | EndCommandBuffer(); |
| 5377 | |
| 5378 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5379 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage format mismatch"; |
| 5380 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with unmatched source and dest formats.")) { |
| 5381 | FAIL() << "Error received was not 'vkCmdResolveImage called with unmatched source and dest formats.' but instead '" << msgString.c_str() << "'"; |
| 5382 | } |
| 5383 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5384 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5385 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5386 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5387 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5388 | } |
| 5389 | |
| 5390 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 5391 | { |
| 5392 | VkFlags msgFlags; |
| 5393 | std::string msgString; |
| 5394 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5395 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5396 | |
| 5397 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5398 | m_errorMonitor->ClearState(); |
| 5399 | |
| 5400 | // Create two images of different types and try to copy between them |
| 5401 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5402 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5403 | VkDeviceMemory srcMem; |
| 5404 | VkDeviceMemory destMem; |
| 5405 | VkMemoryRequirements memReqs; |
| 5406 | |
| 5407 | VkImageCreateInfo image_create_info = {}; |
| 5408 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5409 | image_create_info.pNext = NULL; |
| 5410 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5411 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5412 | image_create_info.extent.width = 32; |
| 5413 | image_create_info.extent.height = 1; |
| 5414 | image_create_info.extent.depth = 1; |
| 5415 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5416 | image_create_info.arrayLayers = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5417 | image_create_info.samples = 2; |
| 5418 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5419 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5420 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5421 | image_create_info.flags = 0; |
| 5422 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5423 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5424 | ASSERT_VK_SUCCESS(err); |
| 5425 | |
| 5426 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5427 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5428 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5429 | image_create_info.samples = 1; |
| 5430 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5431 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5432 | ASSERT_VK_SUCCESS(err); |
| 5433 | |
| 5434 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5435 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5436 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5437 | memAlloc.pNext = NULL; |
| 5438 | memAlloc.allocationSize = 0; |
| 5439 | memAlloc.memoryTypeIndex = 0; |
| 5440 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5441 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5442 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5443 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5444 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5445 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5446 | ASSERT_VK_SUCCESS(err); |
| 5447 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5448 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5449 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5450 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5451 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5452 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5453 | ASSERT_VK_SUCCESS(err); |
| 5454 | |
| 5455 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5456 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5457 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5458 | ASSERT_VK_SUCCESS(err); |
| 5459 | |
| 5460 | BeginCommandBuffer(); |
| 5461 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5462 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5463 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5464 | VkImageResolve resolveRegion; |
Courtney Goeltzenleuchter | 908e767 | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 5465 | resolveRegion.srcSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5466 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5467 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5468 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5469 | resolveRegion.srcOffset.x = 0; |
| 5470 | resolveRegion.srcOffset.y = 0; |
| 5471 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5472 | resolveRegion.dstSubresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5473 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5474 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5475 | resolveRegion.dstSubresource.layerCount = 0; |
| 5476 | resolveRegion.dstOffset.x = 0; |
| 5477 | resolveRegion.dstOffset.y = 0; |
| 5478 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5479 | resolveRegion.extent.width = 1; |
| 5480 | resolveRegion.extent.height = 1; |
| 5481 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5482 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5483 | EndCommandBuffer(); |
| 5484 | |
| 5485 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5486 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive an error from vkCmdResolveImage type mismatch"; |
| 5487 | if (!strstr(msgString.c_str(),"vkCmdResolveImage called with unmatched source and dest image types.")) { |
| 5488 | FAIL() << "Error received was not 'vkCmdResolveImage called with unmatched source and dest image types.' but instead '" << msgString.c_str() << "'"; |
| 5489 | } |
| 5490 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5491 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5492 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5493 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5494 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5495 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5496 | |
| 5497 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 5498 | { |
| 5499 | // Create a single Image descriptor and cause it to first hit an error due |
| 5500 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 5501 | // The image format check comes 2nd in validation so we trigger it first, |
| 5502 | // then when we cause aspect fail next, bad format check will be preempted |
| 5503 | VkFlags msgFlags; |
| 5504 | std::string msgString; |
| 5505 | VkResult err; |
| 5506 | |
| 5507 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5508 | m_errorMonitor->ClearState(); |
| 5509 | VkDescriptorTypeCount ds_type_count = {}; |
| 5510 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5511 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5512 | |
| 5513 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5514 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5515 | ds_pool_ci.pNext = NULL; |
| 5516 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5517 | ds_pool_ci.typeCount = 1; |
| 5518 | ds_pool_ci.pTypeCounts = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5519 | |
| 5520 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5521 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5522 | ASSERT_VK_SUCCESS(err); |
| 5523 | |
| 5524 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5525 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5526 | dsl_binding.arraySize = 1; |
| 5527 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5528 | dsl_binding.pImmutableSamplers = NULL; |
| 5529 | |
| 5530 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5531 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5532 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5533 | ds_layout_ci.bindingCount = 1; |
| 5534 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5535 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5536 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5537 | ASSERT_VK_SUCCESS(err); |
| 5538 | |
| 5539 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5540 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5541 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5542 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5543 | alloc_info.descriptorPool = ds_pool; |
| 5544 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5545 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5546 | ASSERT_VK_SUCCESS(err); |
| 5547 | |
| 5548 | VkImage image_bad; |
| 5549 | VkImage image_good; |
| 5550 | // One bad format and one good format for Color attachment |
| 5551 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 5552 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 5553 | const int32_t tex_width = 32; |
| 5554 | const int32_t tex_height = 32; |
| 5555 | |
| 5556 | VkImageCreateInfo image_create_info = {}; |
| 5557 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5558 | image_create_info.pNext = NULL; |
| 5559 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5560 | image_create_info.format = tex_format_bad; |
| 5561 | image_create_info.extent.width = tex_width; |
| 5562 | image_create_info.extent.height = tex_height; |
| 5563 | image_create_info.extent.depth = 1; |
| 5564 | image_create_info.mipLevels = 1; |
| 5565 | image_create_info.arrayLayers = 1; |
| 5566 | image_create_info.samples = 1; |
| 5567 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5568 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 5569 | image_create_info.flags = 0; |
| 5570 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5571 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5572 | ASSERT_VK_SUCCESS(err); |
| 5573 | image_create_info.format = tex_format_good; |
| 5574 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5575 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5576 | ASSERT_VK_SUCCESS(err); |
| 5577 | |
| 5578 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5579 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5580 | image_view_create_info.image = image_bad; |
| 5581 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5582 | image_view_create_info.format = tex_format_bad; |
| 5583 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 5584 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5585 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5586 | image_view_create_info.subresourceRange.levelCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5587 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5588 | |
| 5589 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5590 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5591 | msgFlags = m_errorMonitor->GetState(&msgString); |
| 5592 | ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after creating ImageView for DS image w/ COLOR aspect bit set."; |
| 5593 | if (!strstr(msgString.c_str(),"Combination depth/stencil image formats can have only the ")) { |
| 5594 | FAIL() << "Error received was not 'Combination depth/stencil image formats can have only the....' but instead '" << msgString.c_str() << "'"; |
| 5595 | } |
| 5596 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5597 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 5598 | vkDestroyImage(m_device->device(), image_good, NULL); |
| 5599 | vkDestroyImageView(m_device->device(), view, NULL); |
| 5600 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5601 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5602 | } |
| 5603 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5604 | #endif // IMAGE_TESTS |
| 5605 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5606 | int main(int argc, char **argv) { |
| 5607 | int result; |
| 5608 | |
| 5609 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5610 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5611 | |
| 5612 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 5613 | |
| 5614 | result = RUN_ALL_TESTS(); |
| 5615 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5616 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5617 | return result; |
| 5618 | } |