Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 1 | /* |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2022 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2022 Valve Corporation |
| 4 | * Copyright (c) 2015-2022 LunarG, Inc. |
| 5 | * Copyright (c) 2015-2022 Google, Inc. |
| 6 | * Modifications Copyright (C) 2020-2022 Advanced Micro Devices, Inc. All rights reserved. |
Tony-LunarG | 4c25337 | 2022-01-18 13:51:07 -0700 | [diff] [blame] | 7 | * Modifications Copyright (C) 2021-2022 ARM, Inc. All rights reserved. |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 8 | * |
| 9 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | * you may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include "cast_utils.h" |
| 18 | #include "layer_validation_tests.h" |
| 19 | |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 20 | TEST_F(VkLayerTest, DynamicRenderingCommandBufferInheritanceRenderingInfo) { |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 21 | TEST_DESCRIPTION("VkCommandBufferInheritanceRenderingInfoKHR Dynamic Rendering Tests."); |
| 22 | |
| 23 | uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2); |
| 24 | if (version < VK_API_VERSION_1_2) { |
| 25 | printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix); |
| 26 | return; |
| 27 | } |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 28 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 29 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
Nathaniel Cesario | a06135e | 2022-03-02 21:22:30 -0700 | [diff] [blame] | 30 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 31 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 32 | if (!AreRequiredExtensionsEnabled()) { |
| 33 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 34 | } |
| 35 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 36 | if (DeviceValidationVersion() < VK_API_VERSION_1_2) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 37 | GTEST_SKIP() << "At least Vulkan version 1.2 is required"; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 38 | } |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 39 | |
Nathaniel Cesario | a06135e | 2022-03-02 21:22:30 -0700 | [diff] [blame] | 40 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 41 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 42 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 43 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 44 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 45 | } |
| 46 | |
ziga-lunarg | f54cb2a | 2022-03-11 02:54:27 +0100 | [diff] [blame] | 47 | features2.features.variableMultisampleRate = VK_FALSE; |
| 48 | |
Nathaniel Cesario | a06135e | 2022-03-02 21:22:30 -0700 | [diff] [blame] | 49 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 50 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 51 | VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>(); |
| 52 | VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props); |
| 53 | vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2); |
| 54 | |
| 55 | if (multiview_props.maxMultiviewViewCount == 32) { |
| 56 | printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix); |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | VkFormat color_format = VK_FORMAT_D32_SFLOAT; |
| 61 | |
| 62 | auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
| 63 | cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1; |
| 64 | cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format; |
| 65 | cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_R8G8B8_UNORM; |
| 66 | cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = VK_FORMAT_R8G8B8_SNORM; |
| 67 | cmd_buffer_inheritance_rendering_info.viewMask = 1 << multiview_props.maxMultiviewViewCount; |
| 68 | |
| 69 | auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoAMD>(); |
| 70 | sample_count_info_amd.pNext = &cmd_buffer_inheritance_rendering_info; |
| 71 | sample_count_info_amd.colorAttachmentCount = 2; |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 72 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 73 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 74 | cmd_buffer_inheritance_info.pNext = &sample_count_info_amd; |
| 75 | |
| 76 | auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>(); |
| 77 | cmd_buffer_allocate_info.commandPool = m_commandPool->handle(); |
| 78 | cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
| 79 | cmd_buffer_allocate_info.commandBufferCount = 0x1; |
| 80 | |
| 81 | VkCommandBuffer secondary_cmd_buffer; |
| 82 | VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer); |
| 83 | ASSERT_VK_SUCCESS(err); |
| 84 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06003"); |
Tony-LunarG | bbd2ab9 | 2021-12-02 08:31:24 -0700 | [diff] [blame] | 85 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-colorAttachmentCount-06004"); |
| 86 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-variableMultisampleRate-06005"); |
| 87 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06007"); |
| 88 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-multiview-06008"); |
| 89 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-viewMask-06009"); |
ziga-lunarg | 813fa01 | 2022-04-09 14:09:57 +0200 | [diff] [blame] | 90 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06199"); |
| 91 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06200"); |
| 92 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-pColorAttachmentFormats-06006"); |
| 93 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06540"); |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 94 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541"); |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 95 | |
| 96 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 97 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 98 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 99 | vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info); |
| 100 | m_errorMonitor->VerifyFound(); |
| 101 | } |
| 102 | |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 103 | TEST_F(VkLayerTest, DynamicRenderingCommandDraw) { |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 104 | TEST_DESCRIPTION("vkCmdDraw* Dynamic Rendering Tests."); |
| 105 | |
| 106 | uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2); |
| 107 | if (version < VK_API_VERSION_1_2) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 108 | GTEST_SKIP() << "At least Vulkan version 1.2 is required, skipping test."; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 112 | |
| 113 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 114 | |
| 115 | if (DeviceValidationVersion() < VK_API_VERSION_1_2) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 116 | GTEST_SKIP() << "At least Vulkan version 1.2 is required"; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 117 | } |
| 118 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 119 | if (!AreRequiredExtensionsEnabled()) { |
| 120 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 124 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 125 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 126 | if (!dynamic_rendering_features.dynamicRendering) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 127 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping."; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 131 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 132 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 133 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 134 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 135 | auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 136 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 137 | VkPipelineObj pipe(m_device); |
| 138 | pipe.AddShader(&vs); |
| 139 | pipe.AddShader(&fs); |
| 140 | pipe.AddDefaultColorAttachment(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 141 | pipe.SetDepthStencil(&ds_state); |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 142 | |
| 143 | VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}; |
| 144 | const VkDescriptorSetLayoutObj dsl(m_device, {dslb}); |
| 145 | const VkPipelineLayoutObj pl(m_device, {&dsl}); |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 146 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 147 | VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 148 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 149 | pipeline_rendering_info.depthAttachmentFormat = depth_format; |
| 150 | pipeline_rendering_info.stencilAttachmentFormat = depth_format; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 151 | |
| 152 | auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>(); |
| 153 | multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT; |
| 154 | |
| 155 | auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 156 | pipe.InitGraphicsPipelineCreateInfo(&create_info); |
| 157 | create_info.pMultisampleState = &multisample_state_create_info; |
| 158 | create_info.renderPass = VkRenderPass(0x1); |
| 159 | create_info.pNext = &pipeline_rendering_info; |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 160 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 161 | VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info); |
| 162 | ASSERT_VK_SUCCESS(err); |
| 163 | |
| 164 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 165 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 166 | |
| 167 | VkImageObj image(m_device); |
| 168 | image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 169 | ASSERT_TRUE(image.initialized()); |
| 170 | |
| 171 | VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, |
| 172 | nullptr, |
| 173 | 0, |
| 174 | image.handle(), |
| 175 | VK_IMAGE_VIEW_TYPE_2D, |
| 176 | depth_format, |
| 177 | {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, |
| 178 | VK_COMPONENT_SWIZZLE_IDENTITY}, |
| 179 | {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}}; |
| 180 | |
paul-lunarg | 18e1634 | 2022-07-12 14:02:23 -0600 | [diff] [blame] | 181 | vk_testing::ImageView depth_image_view(*m_device, ivci); |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 182 | |
| 183 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 184 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
paul-lunarg | 18e1634 | 2022-07-12 14:02:23 -0600 | [diff] [blame] | 185 | depth_attachment.imageView = depth_image_view.handle(); |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 186 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 187 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 188 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 189 | begin_rendering_info.pStencilAttachment = &depth_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 190 | begin_rendering_info.layerCount = 1; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 191 | |
| 192 | m_commandBuffer->begin(); |
| 193 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 194 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 195 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); |
| 196 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); |
| 197 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189"); |
| 198 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190"); |
| 199 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 200 | m_errorMonitor->VerifyFound(); |
| 201 | m_commandBuffer->EndRendering(); |
| 202 | m_commandBuffer->end(); |
| 203 | } |
| 204 | |
| 205 | TEST_F(VkLayerTest, DynamicRenderingGraphicsPipelineCreateInfo) { |
| 206 | TEST_DESCRIPTION("Test graphics pipeline creation with dynamic rendering."); |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 207 | m_errorMonitor->ExpectSuccess(); |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 208 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 209 | uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2); |
| 210 | if (version < VK_API_VERSION_1_2) { |
| 211 | printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix); |
| 212 | return; |
| 213 | } |
| 214 | |
| 215 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 216 | |
| 217 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 218 | |
| 219 | if (DeviceValidationVersion() < VK_API_VERSION_1_2) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 220 | GTEST_SKIP() << "At least Vulkan version 1.2 is required"; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 221 | } |
| 222 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 223 | if (!AreRequiredExtensionsEnabled()) { |
| 224 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 228 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 229 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 230 | if (!dynamic_rendering_features.dynamicRendering) { |
| 231 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 232 | return; |
| 233 | } |
| 234 | |
| 235 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 236 | |
| 237 | const VkPipelineLayoutObj pl(m_device); |
| 238 | VkPipelineObj pipe(m_device); |
| 239 | |
| 240 | VkPipelineColorBlendAttachmentState color_blend_attachment_state = {}; |
| 241 | |
| 242 | auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>(); |
| 243 | color_blend_state_create_info.attachmentCount = 1; |
| 244 | color_blend_state_create_info.pAttachments = &color_blend_attachment_state; |
| 245 | |
| 246 | VkFormat color_format[2] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_D32_SFLOAT_S8_UINT}; |
| 247 | |
| 248 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 249 | pipeline_rendering_info.colorAttachmentCount = 2; |
| 250 | pipeline_rendering_info.pColorAttachmentFormats = &color_format[0]; |
| 251 | pipeline_rendering_info.viewMask = 0x2; |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 252 | pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 253 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 254 | auto pipeline_tessellation_state_info = LvlInitStruct<VkPipelineTessellationStateCreateInfo>(); |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 255 | pipeline_tessellation_state_info.patchControlPoints = 1; |
| 256 | |
| 257 | auto pipeline_input_assembly_state_info = LvlInitStruct<VkPipelineInputAssemblyStateCreateInfo>(); |
| 258 | pipeline_input_assembly_state_info.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
| 259 | |
| 260 | auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 261 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 262 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 263 | VkShaderObj gs(this, bindStateGeomShaderText, VK_SHADER_STAGE_GEOMETRY_BIT); |
| 264 | VkShaderObj te(this, bindStateTeshaderText, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT); |
| 265 | VkShaderObj tc(this, bindStateTscShaderText, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT); |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 266 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
| 267 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 268 | pipe.AddShader(&vs); |
| 269 | pipe.AddShader(&gs); |
| 270 | pipe.AddShader(&te); |
| 271 | pipe.AddShader(&tc); |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 272 | pipe.AddShader(&fs); |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 273 | pipe.InitGraphicsPipelineCreateInfo(&create_info); |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 274 | m_errorMonitor->VerifyNotFound(); |
| 275 | |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 276 | create_info.pColorBlendState = &color_blend_state_create_info; |
| 277 | create_info.pNext = &pipeline_rendering_info; |
| 278 | create_info.pTessellationState = &pipeline_tessellation_state_info; |
| 279 | create_info.pInputAssemblyState = &pipeline_input_assembly_state_info; |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 280 | |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 281 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06053"); |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 282 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581"); |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 283 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06055"); |
| 284 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06057"); |
| 285 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06058"); |
Nathaniel Cesario | a611857 | 2022-03-24 04:48:33 -0600 | [diff] [blame] | 286 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-multiview-06577"); |
Aaron Hagan | aca5044 | 2021-12-07 22:26:29 -0500 | [diff] [blame] | 287 | pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info); |
| 288 | m_errorMonitor->VerifyFound(); |
| 289 | |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 290 | create_info.pColorBlendState = nullptr; |
| 291 | pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED; |
| 292 | pipeline_rendering_info.viewMask = 0x0; |
| 293 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 294 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06054"); |
| 295 | pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info); |
| 296 | m_errorMonitor->VerifyFound(); |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 297 | |
ziga-lunarg | 5e67160 | 2022-03-17 19:06:55 +0100 | [diff] [blame] | 298 | color_format[0] = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 299 | color_blend_attachment_state.blendEnable = VK_TRUE; |
| 300 | create_info.pColorBlendState = &color_blend_state_create_info; |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 301 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581"); |
ziga-lunarg | 5e67160 | 2022-03-17 19:06:55 +0100 | [diff] [blame] | 302 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06062"); |
ziga-lunarg | 5e67160 | 2022-03-17 19:06:55 +0100 | [diff] [blame] | 303 | pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info); |
| 304 | m_errorMonitor->VerifyFound(); |
| 305 | color_format[0] = VK_FORMAT_R8G8B8A8_UNORM; |
| 306 | |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 307 | auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 308 | ds_ci.flags = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM; |
| 309 | color_blend_state_create_info.flags = VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM; |
| 310 | create_info.pColorBlendState = &color_blend_state_create_info; |
| 311 | create_info.pDepthStencilState = &ds_ci; |
| 312 | create_info.renderPass = VK_NULL_HANDLE; |
| 313 | pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 314 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06482"); |
| 315 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06483"); |
| 316 | pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info); |
| 317 | m_errorMonitor->VerifyFound(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | TEST_F(VkLayerTest, DynamicRenderingWithMismatchingViewMask) { |
| 321 | TEST_DESCRIPTION("Draw with Dynamic Rendering and a mismatching viewMask"); |
| 322 | |
| 323 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 324 | |
| 325 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 326 | |
| 327 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 328 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 329 | if (!AreRequiredExtensionsEnabled()) { |
| 330 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 334 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 338 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features); |
| 339 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 340 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 341 | if (!dynamic_rendering_features.dynamicRendering) { |
| 342 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 343 | return; |
| 344 | } |
| 345 | if (!multiview_features.multiview) { |
| 346 | printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix); |
| 347 | return; |
| 348 | } |
| 349 | |
| 350 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 351 | |
| 352 | char const *fsSource = R"glsl( |
| 353 | #version 450 |
| 354 | layout(location=0) out vec4 color; |
| 355 | void main() { |
| 356 | color = vec4(1.0f); |
| 357 | } |
| 358 | )glsl"; |
| 359 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 360 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 361 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 362 | |
| 363 | VkPipelineObj pipe(m_device); |
| 364 | pipe.AddShader(&vs); |
| 365 | pipe.AddShader(&fs); |
| 366 | pipe.AddDefaultColorAttachment(); |
| 367 | |
| 368 | VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}; |
| 369 | const VkDescriptorSetLayoutObj dsl(m_device, {dslb}); |
| 370 | const VkPipelineLayoutObj pl(m_device, {&dsl}); |
| 371 | |
| 372 | VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 373 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 374 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 375 | pipeline_rendering_info.pColorAttachmentFormats = &color_formats; |
| 376 | pipeline_rendering_info.viewMask = 1; |
| 377 | |
| 378 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
| 379 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
| 380 | m_viewports.push_back(viewport); |
| 381 | m_scissors.push_back(scissor); |
| 382 | pipe.SetViewport(m_viewports); |
| 383 | pipe.SetScissor(m_scissors); |
| 384 | |
| 385 | auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 386 | pipe.InitGraphicsPipelineCreateInfo(&create_info); |
| 387 | create_info.pNext = &pipeline_rendering_info; |
| 388 | |
| 389 | pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info); |
| 390 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 391 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 392 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 393 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 394 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 395 | begin_rendering_info.colorAttachmentCount = 1; |
| 396 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 397 | begin_rendering_info.viewMask = 2; |
| 398 | begin_rendering_info.layerCount = 1; |
| 399 | |
| 400 | m_commandBuffer->begin(); |
| 401 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 402 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 403 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-viewMask-06178"); |
| 404 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 405 | m_errorMonitor->VerifyFound(); |
| 406 | m_commandBuffer->EndRendering(); |
| 407 | m_commandBuffer->end(); |
| 408 | } |
| 409 | |
| 410 | TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachments) { |
| 411 | TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color attachment counts and depth/stencil formats"); |
| 412 | |
| 413 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 414 | |
| 415 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 416 | |
| 417 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 418 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 419 | if (!AreRequiredExtensionsEnabled()) { |
| 420 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 424 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 428 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 429 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 430 | if (!dynamic_rendering_features.dynamicRendering) { |
| 431 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 432 | return; |
| 433 | } |
| 434 | |
| 435 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 436 | |
| 437 | char const *fsSource = R"glsl( |
| 438 | #version 450 |
| 439 | layout(location=0) out vec4 color; |
| 440 | void main() { |
| 441 | color = vec4(1.0f); |
| 442 | } |
| 443 | )glsl"; |
| 444 | |
| 445 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
| 446 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
| 447 | m_viewports.push_back(viewport); |
| 448 | m_scissors.push_back(scissor); |
| 449 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 450 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 451 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 452 | |
| 453 | VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}; |
| 454 | const VkDescriptorSetLayoutObj dsl(m_device, {dslb}); |
| 455 | const VkPipelineLayoutObj pl(m_device, {&dsl}); |
| 456 | |
| 457 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 458 | |
| 459 | VkPipelineObj pipe1(m_device); |
| 460 | pipe1.AddShader(&vs); |
| 461 | pipe1.AddShader(&fs); |
| 462 | pipe1.AddDefaultColorAttachment(); |
| 463 | pipe1.SetViewport(m_viewports); |
| 464 | pipe1.SetScissor(m_scissors); |
| 465 | |
| 466 | VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 467 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 468 | pipeline_rendering_info.pColorAttachmentFormats = color_formats; |
| 469 | |
| 470 | auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 471 | pipe1.InitGraphicsPipelineCreateInfo(&create_info1); |
| 472 | create_info1.pNext = &pipeline_rendering_info; |
| 473 | |
| 474 | pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1); |
| 475 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 476 | auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 477 | |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 478 | VkPipelineObj pipe2(m_device); |
| 479 | pipe2.AddShader(&vs); |
| 480 | pipe2.AddShader(&fs); |
| 481 | pipe2.AddDefaultColorAttachment(); |
| 482 | pipe2.SetViewport(m_viewports); |
| 483 | pipe2.SetScissor(m_scissors); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 484 | pipe2.SetDepthStencil(&ds_state); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 485 | |
| 486 | pipeline_rendering_info.colorAttachmentCount = 0; |
| 487 | pipeline_rendering_info.pColorAttachmentFormats = nullptr; |
| 488 | pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D16_UNORM; |
| 489 | |
| 490 | auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 491 | pipe2.InitGraphicsPipelineCreateInfo(&create_info2); |
| 492 | create_info2.pNext = &pipeline_rendering_info; |
| 493 | |
| 494 | pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2); |
| 495 | |
| 496 | VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu()); |
| 497 | ASSERT_TRUE(depthStencilFormat != 0); |
| 498 | |
| 499 | bool testStencil = false; |
| 500 | VkFormat stencilFormat = VK_FORMAT_UNDEFINED; |
| 501 | |
| 502 | if (ImageFormatIsSupported(gpu(), VK_FORMAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) { |
| 503 | stencilFormat = VK_FORMAT_S8_UINT; |
| 504 | testStencil = true; |
| 505 | } else if ((depthStencilFormat != VK_FORMAT_D16_UNORM_S8_UINT) && |
| 506 | ImageFormatIsSupported(gpu(), VK_FORMAT_D16_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) { |
| 507 | stencilFormat = VK_FORMAT_D16_UNORM_S8_UINT; |
| 508 | testStencil = true; |
| 509 | } else if ((depthStencilFormat != VK_FORMAT_D24_UNORM_S8_UINT) && |
| 510 | ImageFormatIsSupported(gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) { |
| 511 | stencilFormat = VK_FORMAT_D24_UNORM_S8_UINT; |
| 512 | testStencil = true; |
| 513 | } else if ((depthStencilFormat != VK_FORMAT_D32_SFLOAT_S8_UINT) && |
| 514 | ImageFormatIsSupported(gpu(), VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) { |
| 515 | stencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 516 | testStencil = true; |
| 517 | } |
| 518 | |
| 519 | VkPipelineObj pipe3(m_device); |
| 520 | |
| 521 | if (testStencil) { |
| 522 | pipe3.AddShader(&vs); |
| 523 | pipe3.AddShader(&fs); |
| 524 | pipe3.AddDefaultColorAttachment(); |
| 525 | pipe3.SetViewport(m_viewports); |
| 526 | pipe3.SetScissor(m_scissors); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 527 | pipe3.SetDepthStencil(&ds_state); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 528 | |
| 529 | pipeline_rendering_info.colorAttachmentCount = 0; |
| 530 | pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED; |
| 531 | pipeline_rendering_info.stencilAttachmentFormat = stencilFormat; |
| 532 | |
| 533 | auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 534 | pipe3.InitGraphicsPipelineCreateInfo(&create_info3); |
| 535 | create_info3.pNext = &pipeline_rendering_info; |
| 536 | |
| 537 | pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3); |
| 538 | } |
| 539 | |
| 540 | VkImageObj colorImage(m_device); |
| 541 | colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 542 | VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 543 | |
| 544 | VkImageObj depthStencilImage(m_device); |
| 545 | depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 546 | VkImageView depthStencilImageView = |
| 547 | depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 548 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 549 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 550 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 551 | color_attachment.imageView = colorImageView; |
| 552 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 553 | VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 554 | depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 555 | depth_stencil_attachment.imageView = depthStencilImageView; |
| 556 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 557 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 558 | begin_rendering_info.layerCount = 1; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 559 | m_commandBuffer->begin(); |
| 560 | |
| 561 | // Mismatching color attachment count |
| 562 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 563 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle()); |
| 564 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06179"); |
| 565 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 566 | m_errorMonitor->VerifyFound(); |
| 567 | m_commandBuffer->EndRendering(); |
| 568 | |
| 569 | // Mismatching color formats |
| 570 | begin_rendering_info.colorAttachmentCount = 1; |
| 571 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 572 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 573 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle()); |
| 574 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06180"); |
| 575 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 576 | m_errorMonitor->VerifyFound(); |
| 577 | m_commandBuffer->EndRendering(); |
| 578 | |
| 579 | // Mismatching depth format |
| 580 | begin_rendering_info.colorAttachmentCount = 0; |
| 581 | begin_rendering_info.pColorAttachments = nullptr; |
| 582 | begin_rendering_info.pDepthAttachment = &depth_stencil_attachment; |
| 583 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 584 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle()); |
| 585 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06181"); |
| 586 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 587 | m_errorMonitor->VerifyFound(); |
| 588 | m_commandBuffer->EndRendering(); |
| 589 | |
| 590 | // Mismatching stencil format |
| 591 | if (testStencil) { |
| 592 | begin_rendering_info.pDepthAttachment = nullptr; |
| 593 | begin_rendering_info.pStencilAttachment = &depth_stencil_attachment; |
| 594 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 595 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle()); |
| 596 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06182"); |
| 597 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 598 | m_errorMonitor->VerifyFound(); |
| 599 | m_commandBuffer->EndRendering(); |
| 600 | } |
| 601 | |
| 602 | m_commandBuffer->end(); |
| 603 | } |
| 604 | |
| 605 | TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachmentSamples) { |
| 606 | TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color/depth/stencil sample counts"); |
| 607 | |
| 608 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 609 | |
| 610 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 611 | |
| 612 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 613 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 614 | if (!AreRequiredExtensionsEnabled()) { |
| 615 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 619 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 623 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 624 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 625 | if (!dynamic_rendering_features.dynamicRendering) { |
| 626 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 627 | return; |
| 628 | } |
| 629 | |
| 630 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 631 | |
| 632 | char const *fsSource = R"glsl( |
| 633 | #version 450 |
| 634 | layout(location=0) out vec4 color; |
| 635 | void main() { |
| 636 | color = vec4(1.0f); |
| 637 | } |
| 638 | )glsl"; |
| 639 | |
| 640 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
| 641 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
| 642 | m_viewports.push_back(viewport); |
| 643 | m_scissors.push_back(scissor); |
| 644 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 645 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 646 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 647 | |
| 648 | VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}; |
| 649 | const VkDescriptorSetLayoutObj dsl(m_device, {dslb}); |
| 650 | const VkPipelineLayoutObj pl(m_device, {&dsl}); |
| 651 | |
| 652 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 653 | |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 654 | VkPipelineObj pipe1(m_device); |
| 655 | pipe1.AddShader(&vs); |
| 656 | pipe1.AddShader(&fs); |
| 657 | pipe1.AddDefaultColorAttachment(); |
| 658 | pipe1.SetViewport(m_viewports); |
| 659 | pipe1.SetScissor(m_scissors); |
| 660 | |
| 661 | VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 662 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 663 | pipeline_rendering_info.pColorAttachmentFormats = color_formats; |
| 664 | |
| 665 | auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 666 | pipe1.InitGraphicsPipelineCreateInfo(&create_info1); |
| 667 | create_info1.pNext = &pipeline_rendering_info; |
| 668 | |
| 669 | auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>(); |
| 670 | multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT; |
| 671 | create_info1.pMultisampleState = &multisample_state_create_info; |
| 672 | |
| 673 | pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1); |
| 674 | |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 675 | VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu()); |
| 676 | ASSERT_TRUE(depthStencilFormat != 0); |
| 677 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 678 | auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 679 | |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 680 | VkPipelineObj pipe2(m_device); |
| 681 | pipe2.AddShader(&vs); |
| 682 | pipe2.AddShader(&fs); |
| 683 | pipe2.AddDefaultColorAttachment(); |
| 684 | pipe2.SetViewport(m_viewports); |
| 685 | pipe2.SetScissor(m_scissors); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 686 | pipe2.SetDepthStencil(&ds_state); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 687 | |
| 688 | pipeline_rendering_info.colorAttachmentCount = 0; |
| 689 | pipeline_rendering_info.pColorAttachmentFormats = nullptr; |
| 690 | pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat; |
| 691 | |
| 692 | auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 693 | pipe2.InitGraphicsPipelineCreateInfo(&create_info2); |
| 694 | create_info2.pNext = &pipeline_rendering_info; |
| 695 | |
| 696 | create_info2.pMultisampleState = &multisample_state_create_info; |
| 697 | |
| 698 | pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2); |
| 699 | |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 700 | VkPipelineObj pipe3(m_device); |
| 701 | |
| 702 | pipe3.AddShader(&vs); |
| 703 | pipe3.AddShader(&fs); |
| 704 | pipe3.AddDefaultColorAttachment(); |
| 705 | pipe3.SetViewport(m_viewports); |
| 706 | pipe3.SetScissor(m_scissors); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 707 | pipe3.SetDepthStencil(&ds_state); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 708 | |
| 709 | pipeline_rendering_info.colorAttachmentCount = 0; |
| 710 | pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED; |
| 711 | pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat; |
| 712 | |
| 713 | auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 714 | pipe3.InitGraphicsPipelineCreateInfo(&create_info3); |
| 715 | create_info3.pNext = &pipeline_rendering_info; |
| 716 | |
| 717 | create_info3.pMultisampleState = &multisample_state_create_info; |
| 718 | |
| 719 | pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3); |
| 720 | |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 721 | VkImageObj colorImage(m_device); |
| 722 | colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 723 | VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 724 | |
| 725 | VkImageObj depthStencilImage(m_device); |
| 726 | depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 727 | VkImageView depthStencilImageView = |
| 728 | depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 729 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 730 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 731 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 732 | color_attachment.imageView = colorImageView; |
| 733 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 734 | VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 735 | depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 736 | depth_stencil_attachment.imageView = depthStencilImageView; |
| 737 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 738 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 739 | begin_rendering_info.layerCount = 1; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 740 | m_commandBuffer->begin(); |
| 741 | |
| 742 | // Mismatching color samples |
| 743 | begin_rendering_info.colorAttachmentCount = 1; |
| 744 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 745 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 746 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle()); |
| 747 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06188"); |
| 748 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 749 | m_errorMonitor->VerifyFound(); |
| 750 | m_commandBuffer->EndRendering(); |
| 751 | |
| 752 | // Mismatching depth samples |
| 753 | begin_rendering_info.colorAttachmentCount = 0; |
| 754 | begin_rendering_info.pColorAttachments = nullptr; |
| 755 | begin_rendering_info.pDepthAttachment = &depth_stencil_attachment; |
| 756 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 757 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle()); |
| 758 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189"); |
| 759 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 760 | m_errorMonitor->VerifyFound(); |
| 761 | m_commandBuffer->EndRendering(); |
| 762 | |
| 763 | // Mismatching stencil samples |
| 764 | begin_rendering_info.pDepthAttachment = nullptr; |
| 765 | begin_rendering_info.pStencilAttachment = &depth_stencil_attachment; |
| 766 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 767 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle()); |
| 768 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190"); |
| 769 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 770 | m_errorMonitor->VerifyFound(); |
| 771 | m_commandBuffer->EndRendering(); |
| 772 | |
| 773 | m_commandBuffer->end(); |
| 774 | } |
| 775 | |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 776 | TEST_F(VkLayerTest, DynamicRenderingWithMismatchingMixedAttachmentSamples) { |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 777 | TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching mixed color/depth/stencil sample counts"); |
| 778 | |
| 779 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 780 | |
| 781 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 782 | |
| 783 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 784 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 785 | if (!AreRequiredExtensionsEnabled()) { |
| 786 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 790 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 794 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 795 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 796 | if (!dynamic_rendering_features.dynamicRendering) { |
| 797 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 798 | return; |
| 799 | } |
| 800 | |
| 801 | bool amd_samples = false; |
| 802 | if (DeviceExtensionSupported(gpu(), nullptr, VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME)) { |
| 803 | m_device_extension_names.push_back(VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME); |
| 804 | amd_samples = true; |
| 805 | } |
| 806 | |
| 807 | bool nv_samples = false; |
| 808 | if (DeviceExtensionSupported(gpu(), nullptr, VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME)) { |
| 809 | m_device_extension_names.push_back(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME); |
| 810 | nv_samples = true; |
| 811 | } |
| 812 | |
| 813 | if (!amd_samples && !nv_samples) { |
| 814 | printf("%s Test requires either VK_AMD_mixed_attachment_samples or VK_NV_framebuffer_mixed_samples, skipping\n", |
| 815 | kSkipPrefix); |
| 816 | return; |
| 817 | } |
| 818 | |
| 819 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 820 | |
| 821 | char const *fsSource = R"glsl( |
| 822 | #version 450 |
| 823 | layout(location=0) out vec4 color; |
| 824 | void main() { |
| 825 | color = vec4(1.0f); |
| 826 | } |
| 827 | )glsl"; |
| 828 | |
| 829 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
| 830 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
| 831 | m_viewports.push_back(viewport); |
| 832 | m_scissors.push_back(scissor); |
| 833 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 834 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 835 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 836 | |
| 837 | VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}; |
| 838 | const VkDescriptorSetLayoutObj dsl(m_device, {dslb}); |
| 839 | const VkPipelineLayoutObj pl(m_device, {&dsl}); |
| 840 | |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 841 | VkSampleCountFlagBits counts[2] = {VK_SAMPLE_COUNT_2_BIT, VK_SAMPLE_COUNT_2_BIT}; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 842 | auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>(); |
| 843 | |
| 844 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info); |
| 845 | |
| 846 | VkPipelineObj pipe1(m_device); |
| 847 | pipe1.AddShader(&vs); |
| 848 | pipe1.AddShader(&fs); |
| 849 | pipe1.AddDefaultColorAttachment(); |
| 850 | pipe1.SetViewport(m_viewports); |
| 851 | pipe1.SetScissor(m_scissors); |
| 852 | |
| 853 | VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 854 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 855 | pipeline_rendering_info.pColorAttachmentFormats = color_formats; |
| 856 | |
| 857 | samples_info.colorAttachmentCount = 1; |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 858 | samples_info.pColorAttachmentSamples = counts; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 859 | |
| 860 | auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 861 | pipe1.InitGraphicsPipelineCreateInfo(&create_info1); |
| 862 | create_info1.pNext = &pipeline_rendering_info; |
| 863 | |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 864 | samples_info.colorAttachmentCount = 2; |
| 865 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06063"); |
| 866 | pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1); |
| 867 | m_errorMonitor->VerifyFound(); |
| 868 | |
| 869 | samples_info.colorAttachmentCount = 1; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 870 | pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1); |
| 871 | |
| 872 | VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu()); |
| 873 | ASSERT_TRUE(depthStencilFormat != 0); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 874 | auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 875 | |
| 876 | VkPipelineObj pipe2(m_device); |
| 877 | pipe2.AddShader(&vs); |
| 878 | pipe2.AddShader(&fs); |
| 879 | pipe2.AddDefaultColorAttachment(); |
| 880 | pipe2.SetViewport(m_viewports); |
| 881 | pipe2.SetScissor(m_scissors); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 882 | pipe2.SetDepthStencil(&ds_state); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 883 | |
| 884 | pipeline_rendering_info.colorAttachmentCount = 0; |
| 885 | pipeline_rendering_info.pColorAttachmentFormats = nullptr; |
| 886 | pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat; |
| 887 | |
| 888 | samples_info.colorAttachmentCount = 0; |
| 889 | samples_info.pColorAttachmentSamples = nullptr; |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 890 | samples_info.depthStencilAttachmentSamples = counts[0]; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 891 | |
| 892 | auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 893 | pipe2.InitGraphicsPipelineCreateInfo(&create_info2); |
| 894 | create_info2.pNext = &pipeline_rendering_info; |
| 895 | |
| 896 | pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2); |
| 897 | |
| 898 | VkPipelineObj pipe3(m_device); |
| 899 | |
| 900 | pipe3.AddShader(&vs); |
| 901 | pipe3.AddShader(&fs); |
| 902 | pipe3.AddDefaultColorAttachment(); |
| 903 | pipe3.SetViewport(m_viewports); |
| 904 | pipe3.SetScissor(m_scissors); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 905 | pipe3.SetDepthStencil(&ds_state); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 906 | |
| 907 | pipeline_rendering_info.colorAttachmentCount = 0; |
| 908 | pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED; |
| 909 | pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat; |
| 910 | |
| 911 | auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 912 | pipe3.InitGraphicsPipelineCreateInfo(&create_info3); |
| 913 | create_info3.pNext = &pipeline_rendering_info; |
| 914 | |
| 915 | pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3); |
| 916 | |
| 917 | VkImageObj colorImage(m_device); |
| 918 | colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 919 | VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 920 | |
| 921 | VkImageObj depthStencilImage(m_device); |
| 922 | depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 923 | VkImageView depthStencilImageView = |
| 924 | depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 925 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 926 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 927 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 928 | color_attachment.imageView = colorImageView; |
| 929 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 930 | VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 931 | depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 932 | depth_stencil_attachment.imageView = depthStencilImageView; |
| 933 | |
sfricke-samsung | 6fc3e32 | 2022-02-15 22:41:29 -0800 | [diff] [blame] | 934 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 935 | m_commandBuffer->begin(); |
| 936 | |
| 937 | // Mismatching color samples |
| 938 | begin_rendering_info.colorAttachmentCount = 1; |
| 939 | begin_rendering_info.pColorAttachments = &color_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 940 | begin_rendering_info.layerCount = 1; |
stusmith | 15f24a8 | 2021-12-24 15:21:19 +0000 | [diff] [blame] | 941 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 942 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle()); |
| 943 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06185"); |
| 944 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 945 | m_errorMonitor->VerifyFound(); |
| 946 | m_commandBuffer->EndRendering(); |
| 947 | |
| 948 | // Mismatching depth samples |
| 949 | begin_rendering_info.colorAttachmentCount = 0; |
| 950 | begin_rendering_info.pColorAttachments = nullptr; |
| 951 | begin_rendering_info.pDepthAttachment = &depth_stencil_attachment; |
| 952 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 953 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle()); |
| 954 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06186"); |
| 955 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 956 | m_errorMonitor->VerifyFound(); |
| 957 | m_commandBuffer->EndRendering(); |
| 958 | |
| 959 | // Mismatching stencil samples |
| 960 | begin_rendering_info.pDepthAttachment = nullptr; |
| 961 | begin_rendering_info.pStencilAttachment = &depth_stencil_attachment; |
| 962 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 963 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle()); |
| 964 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06187"); |
| 965 | m_commandBuffer->Draw(1, 1, 0, 0); |
| 966 | m_errorMonitor->VerifyFound(); |
| 967 | m_commandBuffer->EndRendering(); |
| 968 | |
| 969 | m_commandBuffer->end(); |
| 970 | } |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 971 | |
| 972 | TEST_F(VkLayerTest, DynamicRenderingAttachmentInfo) { |
| 973 | TEST_DESCRIPTION("AttachmentInfo Dynamic Rendering Tests."); |
| 974 | |
| 975 | uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2); |
| 976 | if (version < VK_API_VERSION_1_2) { |
| 977 | printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix); |
| 978 | return; |
| 979 | } |
| 980 | |
| 981 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 982 | |
| 983 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 984 | |
| 985 | if (DeviceValidationVersion() < VK_API_VERSION_1_2) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 986 | GTEST_SKIP() << "At least Vulkan version 1.2 is required"; |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 987 | } |
| 988 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 989 | if (!AreRequiredExtensionsEnabled()) { |
| 990 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 991 | } |
| 992 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 993 | auto fdm_features = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapFeaturesEXT>(); |
| 994 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&fdm_features); |
| 995 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 996 | if (!dynamic_rendering_features.dynamicRendering) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 997 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping"; |
| 998 | } |
| 999 | if (!fdm_features.fragmentDensityMapNonSubsampledImages) { |
| 1000 | GTEST_SKIP() << "fragmentDensityMapNonSubsampledImages not supported."; |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1004 | |
| 1005 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 1006 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
| 1007 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1008 | auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 1009 | |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 1010 | VkPipelineObj pipe(m_device); |
| 1011 | pipe.AddShader(&vs); |
| 1012 | pipe.AddShader(&fs); |
| 1013 | pipe.AddDefaultColorAttachment(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1014 | pipe.SetDepthStencil(&ds_state); |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 1015 | |
| 1016 | VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}; |
| 1017 | const VkDescriptorSetLayoutObj dsl(m_device, {dslb}); |
| 1018 | const VkPipelineLayoutObj pl(m_device, {&dsl}); |
| 1019 | |
| 1020 | VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 1021 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 1022 | pipeline_rendering_info.depthAttachmentFormat = depth_format; |
| 1023 | |
| 1024 | auto pipeline_create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>(); |
| 1025 | pipe.InitGraphicsPipelineCreateInfo(&pipeline_create_info); |
| 1026 | pipeline_create_info.pNext = &pipeline_rendering_info; |
| 1027 | |
| 1028 | VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &pipeline_create_info); |
| 1029 | ASSERT_VK_SUCCESS(err); |
| 1030 | |
| 1031 | VkImageObj image(m_device); |
| 1032 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 1033 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1034 | image_create_info.format = depth_format; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1035 | image_create_info.extent = {64, 64, 1}; |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 1036 | image_create_info.mipLevels = 1; |
| 1037 | image_create_info.arrayLayers = 1; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1038 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 1039 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 1040 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT; |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 1041 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1042 | |
| 1043 | image.Init(image_create_info); |
| 1044 | ASSERT_TRUE(image.initialized()); |
| 1045 | |
| 1046 | VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, |
| 1047 | nullptr, |
| 1048 | 0, |
| 1049 | image.handle(), |
| 1050 | VK_IMAGE_VIEW_TYPE_2D, |
| 1051 | depth_format, |
| 1052 | {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, |
| 1053 | VK_COMPONENT_SWIZZLE_IDENTITY}, |
| 1054 | {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}}; |
| 1055 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1056 | VkImageView depth_image_view = image.targetView(ivci); |
| 1057 | ASSERT_NE(depth_image_view, VK_NULL_HANDLE); |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 1058 | |
| 1059 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 1060 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; |
| 1061 | depth_attachment.imageView = depth_image_view; |
| 1062 | depth_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; |
| 1063 | depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; |
| 1064 | |
| 1065 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 1066 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 1067 | begin_rendering_info.viewMask = 0x4; |
| 1068 | |
| 1069 | VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map = |
| 1070 | LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 1071 | fragment_density_map.imageView = depth_image_view; |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 1072 | fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 1073 | begin_rendering_info.pNext = &fragment_density_map; |
| 1074 | |
| 1075 | m_commandBuffer->begin(); |
| 1076 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multiview-06127"); |
Jeremy Gebben | 09c1a07 | 2022-02-08 09:42:47 -0700 | [diff] [blame] | 1077 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06107"); |
| 1078 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06108"); |
| 1079 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06116"); |
Jeremy Gebben | 09c1a07 | 2022-02-08 09:42:47 -0700 | [diff] [blame] | 1080 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06145"); |
| 1081 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06146"); |
Aaron Hagan | 80034ea | 2021-12-23 11:24:09 -0500 | [diff] [blame] | 1082 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1083 | m_errorMonitor->VerifyFound(); |
| 1084 | } |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 1085 | |
| 1086 | TEST_F(VkLayerTest, DynamicRenderingBufferBeginInfoLegacy) { |
| 1087 | TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests."); |
| 1088 | |
| 1089 | uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2); |
| 1090 | if (version < VK_API_VERSION_1_2) { |
| 1091 | printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix); |
| 1092 | return; |
| 1093 | } |
| 1094 | |
| 1095 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1096 | |
| 1097 | ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 1098 | |
| 1099 | if (DeviceValidationVersion() < VK_API_VERSION_1_2) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1100 | GTEST_SKIP() << "At least Vulkan version 1.2 is required"; |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 1101 | } |
| 1102 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1103 | if (!AreRequiredExtensionsEnabled()) { |
| 1104 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 1105 | } |
| 1106 | |
| 1107 | auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
| 1108 | cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 1109 | |
| 1110 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 1111 | cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info; |
| 1112 | cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE; |
| 1113 | |
| 1114 | auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>(); |
| 1115 | cmd_buffer_allocate_info.commandPool = m_commandPool->handle(); |
| 1116 | cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
| 1117 | cmd_buffer_allocate_info.commandBufferCount = 0x1; |
| 1118 | |
| 1119 | VkCommandBuffer secondary_cmd_buffer; |
| 1120 | VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer); |
| 1121 | ASSERT_VK_SUCCESS(err); |
| 1122 | |
| 1123 | // Invalid RenderPass |
| 1124 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00053"); |
| 1125 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 1126 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 1127 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 1128 | vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info); |
| 1129 | m_errorMonitor->VerifyFound(); |
| 1130 | |
| 1131 | // Valid RenderPass |
| 1132 | VkAttachmentDescription attach[] = { |
| 1133 | {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 1134 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED, |
| 1135 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
| 1136 | }; |
| 1137 | VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}; |
| 1138 | |
| 1139 | VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr}; |
| 1140 | VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr}; |
| 1141 | |
| 1142 | vk_testing::RenderPass rp1; |
| 1143 | rp1.init(*m_device, rpci); |
| 1144 | |
| 1145 | cmd_buffer_inheritance_info.renderPass = rp1.handle(); |
| 1146 | cmd_buffer_inheritance_info.subpass = 0x5; |
| 1147 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00054"); |
| 1148 | vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info); |
| 1149 | m_errorMonitor->VerifyFound(); |
| 1150 | } |
| 1151 | |
| 1152 | TEST_F(VkLayerTest, DynamicRenderingSecondaryCommandBuffer) { |
| 1153 | TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests."); |
| 1154 | |
| 1155 | uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_3); |
| 1156 | if (version < VK_API_VERSION_1_3) { |
| 1157 | printf("%s At least Vulkan version 1.3 is required, skipping test.\n", kSkipPrefix); |
| 1158 | return; |
| 1159 | } |
| 1160 | |
| 1161 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 1162 | |
| 1163 | if (DeviceValidationVersion() < VK_API_VERSION_1_3) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1164 | GTEST_SKIP() << "At least Vulkan version 1.3 is required"; |
Aaron Hagan | b54466d | 2022-02-18 15:02:54 -0500 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 1168 | |
| 1169 | // Force the failure by not setting the Renderpass and Framebuffer fields |
| 1170 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 1171 | cmd_buf_hinfo.renderPass = VkRenderPass(0x1); |
| 1172 | VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 1173 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 1174 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
| 1175 | |
| 1176 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06000"); |
| 1177 | vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info); |
| 1178 | m_errorMonitor->VerifyFound(); |
| 1179 | |
| 1180 | // Valid RenderPass |
| 1181 | VkAttachmentDescription attach[] = { |
| 1182 | {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 1183 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED, |
| 1184 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
| 1185 | }; |
| 1186 | VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}; |
| 1187 | |
| 1188 | VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr}; |
| 1189 | VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr}; |
| 1190 | |
| 1191 | vk_testing::RenderPass rp1; |
| 1192 | rp1.init(*m_device, rpci); |
| 1193 | |
| 1194 | cmd_buf_hinfo.renderPass = rp1.handle(); |
| 1195 | cmd_buf_hinfo.subpass = 0x5; |
| 1196 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06001"); |
| 1197 | vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info); |
| 1198 | m_errorMonitor->VerifyFound(); |
| 1199 | |
| 1200 | cmd_buf_hinfo.renderPass = VK_NULL_HANDLE; |
| 1201 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06002"); |
| 1202 | vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info); |
| 1203 | m_errorMonitor->VerifyFound(); |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1204 | } |
| 1205 | |
| 1206 | TEST_F(VkLayerTest, TestDynamicRenderingPipelineMissingFlags) { |
| 1207 | TEST_DESCRIPTION("Test dynamic rendering with pipeline missing flags."); |
| 1208 | |
| 1209 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 1210 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1211 | AddOptionalExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 1212 | AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1213 | |
| 1214 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1215 | |
| 1216 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1217 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1218 | } |
| 1219 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1220 | if (!IsExtensionsEnabled(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) { |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1221 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1222 | } |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1223 | bool fragment_density = IsExtensionsEnabled(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 1224 | bool shading_rate = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1225 | |
| 1226 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1227 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1228 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1229 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1230 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1231 | } |
| 1232 | |
| 1233 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 1234 | |
| 1235 | auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 1236 | vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2); |
| 1237 | |
| 1238 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 1239 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1240 | |
| 1241 | VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu()); |
| 1242 | ASSERT_TRUE(depthStencilFormat != 0); |
| 1243 | |
| 1244 | VkImageObj image(m_device); |
| 1245 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 1246 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1247 | image_create_info.format = depthStencilFormat; |
| 1248 | image_create_info.extent = {64, 64, 1}; |
| 1249 | image_create_info.mipLevels = 1; |
| 1250 | image_create_info.arrayLayers = 1; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1251 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1252 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1253 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR; |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1254 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1255 | |
| 1256 | image.Init(image_create_info); |
| 1257 | ASSERT_TRUE(image.initialized()); |
| 1258 | |
| 1259 | VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, |
| 1260 | nullptr, |
| 1261 | 0, |
| 1262 | image.handle(), |
| 1263 | VK_IMAGE_VIEW_TYPE_2D, |
| 1264 | depthStencilFormat, |
| 1265 | {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, |
| 1266 | VK_COMPONENT_SWIZZLE_IDENTITY}, |
| 1267 | {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}}; |
| 1268 | |
| 1269 | vk_testing::ImageView depth_image_view; |
| 1270 | depth_image_view.init(*m_device, ivci); |
| 1271 | |
| 1272 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 1273 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 1274 | |
| 1275 | if (shading_rate) { |
| 1276 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06183"); |
| 1277 | VkRenderingFragmentShadingRateAttachmentInfoKHR fragment_shading_rate = |
| 1278 | LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
| 1279 | fragment_shading_rate.imageView = depth_image_view.handle(); |
| 1280 | fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1281 | fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 1282 | |
| 1283 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate); |
ziga-lunarg | aa97cbb | 2022-03-18 19:06:35 +0100 | [diff] [blame] | 1284 | begin_rendering_info.layerCount = 1; |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1285 | begin_rendering_info.colorAttachmentCount = 1; |
| 1286 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 1287 | |
| 1288 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1289 | |
| 1290 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 1291 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 1292 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 1293 | |
| 1294 | CreatePipelineHelper pipe(*this); |
| 1295 | pipe.InitInfo(); |
| 1296 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 1297 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 1298 | pipe.InitState(); |
| 1299 | pipe.CreateGraphicsPipeline(); |
| 1300 | |
| 1301 | m_commandBuffer->begin(); |
| 1302 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1303 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 1304 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 1305 | m_commandBuffer->EndRendering(); |
| 1306 | m_commandBuffer->end(); |
| 1307 | |
| 1308 | m_errorMonitor->VerifyFound(); |
| 1309 | } |
| 1310 | |
| 1311 | if (fragment_density) { |
| 1312 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06184"); |
| 1313 | VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map = |
| 1314 | LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 1315 | fragment_density_map.imageView = depth_image_view.handle(); |
| 1316 | |
| 1317 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map); |
ziga-lunarg | aa97cbb | 2022-03-18 19:06:35 +0100 | [diff] [blame] | 1318 | begin_rendering_info.layerCount = 1; |
ziga-lunarg | 6c8f162 | 2022-03-14 20:14:04 +0100 | [diff] [blame] | 1319 | begin_rendering_info.colorAttachmentCount = 1; |
| 1320 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 1321 | |
| 1322 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1323 | |
| 1324 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 1325 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 1326 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 1327 | |
| 1328 | CreatePipelineHelper pipe(*this); |
| 1329 | pipe.InitInfo(); |
| 1330 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 1331 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 1332 | pipe.InitState(); |
| 1333 | pipe.CreateGraphicsPipeline(); |
| 1334 | |
| 1335 | m_commandBuffer->begin(); |
| 1336 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1337 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 1338 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 1339 | m_commandBuffer->EndRendering(); |
| 1340 | m_commandBuffer->end(); |
| 1341 | |
| 1342 | m_errorMonitor->VerifyFound(); |
| 1343 | } |
| 1344 | } |
ziga-lunarg | bc6d8ad | 2022-03-18 13:04:20 +0100 | [diff] [blame] | 1345 | |
ziga-lunarg | 2c9067e | 2022-03-18 18:33:52 +0100 | [diff] [blame] | 1346 | TEST_F(VkLayerTest, DynamicRenderingLayerCount) { |
| 1347 | TEST_DESCRIPTION("Test dynamic rendering with viewMask 0 and invalid layer count."); |
| 1348 | |
| 1349 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 1350 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1351 | |
| 1352 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1353 | |
| 1354 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1355 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 2c9067e | 2022-03-18 18:33:52 +0100 | [diff] [blame] | 1356 | } |
| 1357 | |
| 1358 | if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) { |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1359 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 2c9067e | 2022-03-18 18:33:52 +0100 | [diff] [blame] | 1360 | } |
| 1361 | |
| 1362 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1363 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1364 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1365 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1366 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 2c9067e | 2022-03-18 18:33:52 +0100 | [diff] [blame] | 1367 | } |
| 1368 | |
| 1369 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1370 | |
| 1371 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 1372 | |
| 1373 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06069"); |
| 1374 | m_commandBuffer->begin(); |
| 1375 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1376 | m_commandBuffer->end(); |
| 1377 | m_errorMonitor->VerifyFound(); |
| 1378 | } |
| 1379 | |
ziga-lunarg | bc6d8ad | 2022-03-18 13:04:20 +0100 | [diff] [blame] | 1380 | TEST_F(VkLayerTest, TestRenderingInfoMismatchedSamples) { |
| 1381 | TEST_DESCRIPTION("Test beginning rendering with mismatched sample counts."); |
| 1382 | |
| 1383 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 1384 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1385 | |
| 1386 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1387 | |
| 1388 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1389 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | bc6d8ad | 2022-03-18 13:04:20 +0100 | [diff] [blame] | 1390 | } |
| 1391 | |
| 1392 | if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) { |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1393 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | bc6d8ad | 2022-03-18 13:04:20 +0100 | [diff] [blame] | 1394 | } |
| 1395 | |
| 1396 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1397 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1398 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1399 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1400 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | bc6d8ad | 2022-03-18 13:04:20 +0100 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1404 | |
| 1405 | VkImageCreateInfo image_ci = LvlInitStruct<VkImageCreateInfo>(); |
| 1406 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 1407 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1408 | image_ci.extent.width = 64; |
| 1409 | image_ci.extent.height = 64; |
| 1410 | image_ci.extent.depth = 1; |
| 1411 | image_ci.mipLevels = 1; |
| 1412 | image_ci.arrayLayers = 1; |
| 1413 | image_ci.samples = VK_SAMPLE_COUNT_2_BIT; |
| 1414 | image_ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 1415 | image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 1416 | |
| 1417 | VkImageObj color_image(m_device); |
| 1418 | color_image.init(&image_ci); |
| 1419 | |
| 1420 | VkImageViewCreateInfo civ_ci = LvlInitStruct<VkImageViewCreateInfo>(); |
| 1421 | civ_ci.image = color_image.handle(); |
| 1422 | civ_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 1423 | civ_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1424 | civ_ci.subresourceRange.layerCount = 1; |
| 1425 | civ_ci.subresourceRange.baseMipLevel = 0; |
| 1426 | civ_ci.subresourceRange.levelCount = 1; |
| 1427 | civ_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1428 | |
| 1429 | vk_testing::ImageView color_image_view; |
| 1430 | color_image_view.init(*m_device, civ_ci); |
| 1431 | |
| 1432 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 1433 | color_attachment.imageView = color_image_view.handle(); |
| 1434 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 1435 | color_attachment.resolveMode = VK_RESOLVE_MODE_NONE; |
| 1436 | |
| 1437 | const VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu()); |
| 1438 | if (depth_format == VK_FORMAT_UNDEFINED) { |
| 1439 | printf("%s requires a depth only format, skipping.\n", kSkipPrefix); |
| 1440 | return; |
| 1441 | } |
| 1442 | |
| 1443 | VkImageObj depth_image(m_device); |
| 1444 | depth_image.Init(64, 64, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL); |
| 1445 | |
| 1446 | VkImageViewCreateInfo div_ci = LvlInitStruct<VkImageViewCreateInfo>(); |
| 1447 | div_ci.image = depth_image.handle(); |
| 1448 | div_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 1449 | div_ci.format = depth_format; |
| 1450 | div_ci.subresourceRange.layerCount = 1; |
| 1451 | div_ci.subresourceRange.baseMipLevel = 0; |
| 1452 | div_ci.subresourceRange.levelCount = 1; |
| 1453 | div_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 1454 | |
| 1455 | vk_testing::ImageView depth_image_view; |
| 1456 | depth_image_view.init(*m_device, div_ci); |
| 1457 | |
| 1458 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 1459 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1460 | depth_attachment.imageView = depth_image_view.handle(); |
| 1461 | depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE; |
| 1462 | |
| 1463 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
ziga-lunarg | aa97cbb | 2022-03-18 19:06:35 +0100 | [diff] [blame] | 1464 | begin_rendering_info.layerCount = 1; |
ziga-lunarg | bc6d8ad | 2022-03-18 13:04:20 +0100 | [diff] [blame] | 1465 | begin_rendering_info.colorAttachmentCount = 1; |
| 1466 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 1467 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 1468 | |
| 1469 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06070"); |
| 1470 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1471 | m_errorMonitor->VerifyFound(); |
| 1472 | } |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1473 | |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1474 | TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRate) { |
| 1475 | TEST_DESCRIPTION("Test BeginRenderingInfo with FragmentShadingRateAttachment."); |
| 1476 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1477 | SetTargetApiVersion(VK_API_VERSION_1_2); |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1478 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1479 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 1480 | |
| 1481 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1482 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1483 | if (DeviceValidationVersion() < VK_API_VERSION_1_2) { |
| 1484 | GTEST_SKIP() << "At least Vulkan version 1.2 is required"; |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1485 | } |
| 1486 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1487 | if (!AreRequiredExtensionsEnabled()) { |
| 1488 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1489 | } |
| 1490 | |
| 1491 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1492 | auto features11 = LvlInitStruct<VkPhysicalDeviceVulkan11Features>(&dynamic_rendering_features); |
| 1493 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&features11); |
| 1494 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1495 | |
| 1496 | if (features11.multiview == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1497 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1498 | } |
| 1499 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1500 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1501 | } |
| 1502 | |
| 1503 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 1504 | |
| 1505 | auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 1506 | vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2); |
| 1507 | |
| 1508 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 1509 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1510 | |
| 1511 | auto image_ci = LvlInitStruct<VkImageCreateInfo>(nullptr); |
| 1512 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 1513 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1514 | image_ci.extent.width = 32; |
| 1515 | image_ci.extent.height = 32; |
| 1516 | image_ci.extent.depth = 1; |
| 1517 | image_ci.mipLevels = 1; |
| 1518 | image_ci.arrayLayers = 2; |
| 1519 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1520 | image_ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
ziga-lunarg | ade1d9e | 2022-04-25 10:59:15 +0200 | [diff] [blame] | 1521 | image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR; |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1522 | |
| 1523 | VkImageObj image(m_device); |
| 1524 | image.init(&image_ci); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1525 | VkImageView image_view = |
| 1526 | image.targetView(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 2, VK_IMAGE_VIEW_TYPE_2D_ARRAY); |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1527 | |
ziga-lunarg | ade1d9e | 2022-04-25 10:59:15 +0200 | [diff] [blame] | 1528 | auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1529 | fragment_shading_rate.imageView = image_view; |
| 1530 | fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1531 | fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 1532 | |
| 1533 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate); |
| 1534 | begin_rendering_info.layerCount = 4; |
| 1535 | |
| 1536 | m_commandBuffer->begin(); |
| 1537 | |
| 1538 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06123"); |
| 1539 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1540 | m_errorMonitor->VerifyFound(); |
| 1541 | |
| 1542 | begin_rendering_info.viewMask = 0xF; |
| 1543 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06124"); |
| 1544 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1545 | m_errorMonitor->VerifyFound(); |
| 1546 | |
ziga-lunarg | ade1d9e | 2022-04-25 10:59:15 +0200 | [diff] [blame] | 1547 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 1548 | color_attachment.imageView = image_view; |
| 1549 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 1550 | |
| 1551 | begin_rendering_info.layerCount = 2; |
| 1552 | begin_rendering_info.colorAttachmentCount = 1; |
| 1553 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 1554 | begin_rendering_info.viewMask = 0; |
| 1555 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06125"); |
| 1556 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1557 | m_errorMonitor->VerifyFound(); |
| 1558 | |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1559 | m_commandBuffer->end(); |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1560 | } |
| 1561 | |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1562 | TEST_F(VkLayerTest, TestDeviceGroupRenderPassBeginInfo) { |
| 1563 | TEST_DESCRIPTION("Test render area of DeviceGroupRenderPassBeginInfo."); |
| 1564 | |
| 1565 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 1566 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1567 | |
| 1568 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1569 | |
| 1570 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1571 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1572 | } |
| 1573 | |
| 1574 | if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) { |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1575 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1576 | } |
| 1577 | |
| 1578 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1579 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1580 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1581 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1582 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1583 | } |
| 1584 | |
| 1585 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 1586 | |
| 1587 | VkRect2D render_area = {}; |
| 1588 | render_area.offset.x = 0; |
| 1589 | render_area.offset.y = 0; |
| 1590 | render_area.extent.width = 32; |
| 1591 | render_area.extent.height = 32; |
| 1592 | |
| 1593 | auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>(); |
| 1594 | device_group_render_pass_begin_info.deviceRenderAreaCount = 1; |
| 1595 | device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area; |
| 1596 | |
| 1597 | VkImageObj colorImage(m_device); |
| 1598 | colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 1599 | VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 1600 | |
| 1601 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 1602 | color_attachment.imageView = colorImageView; |
| 1603 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 1604 | |
| 1605 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&device_group_render_pass_begin_info); |
ziga-lunarg | 1fec633 | 2022-03-20 14:39:54 +0100 | [diff] [blame] | 1606 | begin_rendering_info.layerCount = 1; |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1607 | begin_rendering_info.colorAttachmentCount = 1; |
| 1608 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 1609 | |
| 1610 | m_commandBuffer->begin(); |
| 1611 | |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1612 | m_commandBuffer->BeginRendering(begin_rendering_info); |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1613 | |
| 1614 | render_area.offset.x = 1; |
| 1615 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06083"); |
| 1616 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1617 | m_errorMonitor->VerifyFound(); |
| 1618 | |
| 1619 | render_area.offset.x = 0; |
| 1620 | render_area.offset.y = 16; |
| 1621 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06084"); |
| 1622 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1623 | m_errorMonitor->VerifyFound(); |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1624 | } |
| 1625 | |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1626 | TEST_F(VkLayerTest, TestBeginRenderingInvalidFragmentShadingRateImage) { |
| 1627 | TEST_DESCRIPTION("Test BeginRendering with FragmentShadingRateAttachmentInfo with missing image usage bit."); |
| 1628 | |
| 1629 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 1630 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1631 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 1632 | |
| 1633 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1634 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1635 | if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) { |
| 1636 | GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation."; |
| 1637 | } |
| 1638 | |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1639 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1640 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1641 | } |
| 1642 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1643 | if (!AreRequiredExtensionsEnabled()) { |
| 1644 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1645 | } |
| 1646 | |
| 1647 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1648 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1649 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1650 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1651 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1652 | } |
| 1653 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1654 | |
| 1655 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 1656 | auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 1657 | vk::GetPhysicalDeviceProperties2(gpu(), &properties2); |
| 1658 | |
| 1659 | VkImageObj image(m_device); |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1660 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, |
| 1661 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR); |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1662 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 1663 | |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1664 | VkImageObj invalid_image(m_device); |
| 1665 | invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 1666 | VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 1667 | |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1668 | auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1669 | fragment_shading_rate.imageView = invalid_image_view; |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1670 | fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1671 | fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 1672 | |
| 1673 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate); |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1674 | begin_rendering_info.layerCount = 1; |
| 1675 | |
| 1676 | m_commandBuffer->begin(); |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1677 | |
| 1678 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06148"); |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1679 | m_commandBuffer->BeginRendering(begin_rendering_info); |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1680 | m_errorMonitor->VerifyFound(); |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1681 | fragment_shading_rate.imageView = image_view; |
| 1682 | |
| 1683 | fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width + 1; |
| 1684 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06149"); |
| 1685 | if (fragment_shading_rate.shadingRateAttachmentTexelSize.width > |
| 1686 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.width) { |
| 1687 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06150"); |
| 1688 | } |
| 1689 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1690 | m_errorMonitor->VerifyFound(); |
| 1691 | |
| 1692 | if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.width > 1) { |
| 1693 | fragment_shading_rate.shadingRateAttachmentTexelSize.width = |
| 1694 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.width / 2; |
| 1695 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06151"); |
| 1696 | if (fragment_shading_rate.shadingRateAttachmentTexelSize.height / |
| 1697 | fragment_shading_rate.shadingRateAttachmentTexelSize.width >= |
| 1698 | fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) { |
| 1699 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06156"); |
| 1700 | } |
| 1701 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1702 | m_errorMonitor->VerifyFound(); |
| 1703 | } |
| 1704 | |
| 1705 | fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width; |
| 1706 | |
| 1707 | fragment_shading_rate.shadingRateAttachmentTexelSize.height = |
| 1708 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.height + 1; |
| 1709 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06152"); |
| 1710 | if (fragment_shading_rate.shadingRateAttachmentTexelSize.height > |
| 1711 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.height) { |
| 1712 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06153"); |
| 1713 | } |
| 1714 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1715 | m_errorMonitor->VerifyFound(); |
| 1716 | |
| 1717 | if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.height > 1) { |
| 1718 | fragment_shading_rate.shadingRateAttachmentTexelSize.height = |
| 1719 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.height / 2; |
| 1720 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06154"); |
| 1721 | if (fragment_shading_rate.shadingRateAttachmentTexelSize.width / |
| 1722 | fragment_shading_rate.shadingRateAttachmentTexelSize.height > |
| 1723 | fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) { |
| 1724 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06155"); |
| 1725 | } |
| 1726 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1727 | m_errorMonitor->VerifyFound(); |
| 1728 | } |
| 1729 | |
| 1730 | m_commandBuffer->end(); |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1731 | } |
| 1732 | |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1733 | TEST_F(VkLayerTest, BeginRenderingInvalidDepthAttachmentFormat) { |
| 1734 | TEST_DESCRIPTION("Test begin rendering with a depth attachment that has an invalid format"); |
| 1735 | |
| 1736 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 1737 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1738 | |
| 1739 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1740 | |
| 1741 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1742 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1743 | } |
| 1744 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1745 | if (!AreRequiredExtensionsEnabled()) { |
| 1746 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1747 | } |
| 1748 | |
| 1749 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1750 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1751 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1752 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1753 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1754 | } |
| 1755 | |
| 1756 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1757 | |
| 1758 | VkFormat stencil_format = FindSupportedStencilOnlyFormat(gpu()); |
| 1759 | if (stencil_format == VK_FORMAT_UNDEFINED) { |
| 1760 | printf("%s requires a stencil only format format.\n", kSkipPrefix); |
| 1761 | return; |
| 1762 | } |
| 1763 | |
| 1764 | VkImageObj image(m_device); |
| 1765 | image.Init(32, 32, 1, stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 1766 | VkImageView image_view = image.targetView(stencil_format, VK_IMAGE_ASPECT_STENCIL_BIT); |
| 1767 | |
| 1768 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 1769 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 1770 | depth_attachment.imageView = image_view; |
| 1771 | |
| 1772 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
ziga-lunarg | 1fec633 | 2022-03-20 14:39:54 +0100 | [diff] [blame] | 1773 | begin_rendering_info.layerCount = 1; |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1774 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 1775 | |
| 1776 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06547"); |
| 1777 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1778 | m_errorMonitor->VerifyFound(); |
| 1779 | } |
ziga-lunarg | 4b5bb5b | 2022-03-20 00:49:04 +0100 | [diff] [blame] | 1780 | |
ziga-lunarg | 14a6978 | 2022-03-20 00:39:31 +0100 | [diff] [blame] | 1781 | TEST_F(VkLayerTest, TestFragmentDensityMapRenderArea) { |
| 1782 | TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent."); |
| 1783 | |
| 1784 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 1785 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1786 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 1787 | |
| 1788 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1789 | |
| 1790 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1791 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 14a6978 | 2022-03-20 00:39:31 +0100 | [diff] [blame] | 1792 | } |
| 1793 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1794 | if (!AreRequiredExtensionsEnabled()) { |
| 1795 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 14a6978 | 2022-03-20 00:39:31 +0100 | [diff] [blame] | 1796 | } |
| 1797 | |
| 1798 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1799 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1800 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1801 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1802 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 14a6978 | 2022-03-20 00:39:31 +0100 | [diff] [blame] | 1803 | } |
| 1804 | |
| 1805 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1806 | |
| 1807 | auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>(); |
| 1808 | auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props); |
| 1809 | vk::GetPhysicalDeviceProperties2(gpu(), &props2); |
| 1810 | |
| 1811 | VkImageObj image(m_device); |
ziga-lunarg | 2aa8d59 | 2022-04-25 14:29:13 +0200 | [diff] [blame] | 1812 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, |
| 1813 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT); |
ziga-lunarg | 14a6978 | 2022-03-20 00:39:31 +0100 | [diff] [blame] | 1814 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1); |
| 1815 | |
| 1816 | auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 1817 | fragment_density_map.imageView = image_view; |
ziga-lunarg | 2aa8d59 | 2022-04-25 14:29:13 +0200 | [diff] [blame] | 1818 | fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1819 | |
ziga-lunarg | 14a6978 | 2022-03-20 00:39:31 +0100 | [diff] [blame] | 1820 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map); |
| 1821 | begin_rendering_info.layerCount = 1; |
| 1822 | begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1823 | begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1824 | |
| 1825 | m_commandBuffer->begin(); |
| 1826 | |
| 1827 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06112"); |
| 1828 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1829 | m_errorMonitor->VerifyFound(); |
| 1830 | |
| 1831 | begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1832 | begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1833 | |
| 1834 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06114"); |
| 1835 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1836 | m_errorMonitor->VerifyFound(); |
| 1837 | |
| 1838 | VkRect2D device_render_area = {}; |
| 1839 | device_render_area.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1840 | device_render_area.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1841 | auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>(); |
| 1842 | device_group_render_pass_begin_info.deviceRenderAreaCount = 1; |
| 1843 | device_group_render_pass_begin_info.pDeviceRenderAreas = &device_render_area; |
| 1844 | fragment_density_map.pNext = &device_group_render_pass_begin_info; |
| 1845 | |
| 1846 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06113"); |
| 1847 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1848 | m_errorMonitor->VerifyFound(); |
| 1849 | |
| 1850 | device_render_area.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1851 | device_render_area.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1852 | |
| 1853 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06115"); |
| 1854 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1855 | m_errorMonitor->VerifyFound(); |
| 1856 | |
| 1857 | m_commandBuffer->end(); |
| 1858 | } |
| 1859 | |
ziga-lunarg | 50253b9 | 2022-04-25 14:36:13 +0200 | [diff] [blame] | 1860 | TEST_F(VkLayerTest, TestFragmentDensityMapRenderAreaWithoutDeviceGroupExt) { |
| 1861 | TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent."); |
| 1862 | |
| 1863 | SetTargetApiVersion(VK_API_VERSION_1_0); |
| 1864 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1865 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 1866 | |
| 1867 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1868 | |
| 1869 | if (DeviceValidationVersion() != VK_API_VERSION_1_0) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1870 | GTEST_SKIP() << "Tests for 1.0 only"; |
ziga-lunarg | 50253b9 | 2022-04-25 14:36:13 +0200 | [diff] [blame] | 1871 | } |
| 1872 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1873 | if (!AreRequiredExtensionsEnabled()) { |
| 1874 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 50253b9 | 2022-04-25 14:36:13 +0200 | [diff] [blame] | 1875 | } |
| 1876 | |
| 1877 | auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>( |
| 1878 | vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR")); |
| 1879 | ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr); |
| 1880 | |
| 1881 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1882 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features); |
| 1883 | vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2); |
| 1884 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 1885 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 50253b9 | 2022-04-25 14:36:13 +0200 | [diff] [blame] | 1886 | } |
| 1887 | |
| 1888 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1889 | |
| 1890 | auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>(); |
| 1891 | auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props); |
| 1892 | vk::GetPhysicalDeviceProperties2(gpu(), &props2); |
| 1893 | |
| 1894 | VkImageObj image(m_device); |
| 1895 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, |
| 1896 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT); |
| 1897 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1); |
| 1898 | |
| 1899 | auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 1900 | fragment_density_map.imageView = image_view; |
| 1901 | fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1902 | |
| 1903 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map); |
| 1904 | begin_rendering_info.layerCount = 1; |
| 1905 | begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1906 | begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1907 | |
| 1908 | m_commandBuffer->begin(); |
| 1909 | |
| 1910 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06110"); |
| 1911 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1912 | m_errorMonitor->VerifyFound(); |
| 1913 | |
| 1914 | begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1915 | begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1916 | |
| 1917 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06111"); |
| 1918 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1919 | m_errorMonitor->VerifyFound(); |
| 1920 | |
| 1921 | m_commandBuffer->end(); |
| 1922 | } |
| 1923 | |
ziga-lunarg | e7279ba | 2022-03-31 20:55:27 +0200 | [diff] [blame] | 1924 | TEST_F(VkLayerTest, TestBarrierWithDynamicRendering) { |
| 1925 | TEST_DESCRIPTION("Test setting buffer memory barrier when dynamic rendering is active."); |
| 1926 | |
| 1927 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 1928 | |
| 1929 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1930 | |
| 1931 | if (DeviceValidationVersion() < VK_API_VERSION_1_3) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1932 | GTEST_SKIP() << "At least Vulkan version 1.3 is required"; |
ziga-lunarg | e7279ba | 2022-03-31 20:55:27 +0200 | [diff] [blame] | 1933 | } |
| 1934 | |
| 1935 | auto vk13features = LvlInitStruct<VkPhysicalDeviceVulkan13Features>(); |
| 1936 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&vk13features); |
| 1937 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1938 | if (!vk13features.dynamicRendering) { |
| 1939 | printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix); |
| 1940 | return; |
| 1941 | } |
| 1942 | if (!vk13features.synchronization2) { |
| 1943 | printf("%s Test requires (unsupported) synchronization2, skipping\n", kSkipPrefix); |
| 1944 | return; |
| 1945 | } |
| 1946 | |
| 1947 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1948 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1949 | |
| 1950 | PFN_vkCmdBeginRendering vkCmdBeginRendering = |
| 1951 | reinterpret_cast<PFN_vkCmdBeginRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginRendering")); |
| 1952 | assert(vkCmdBeginRendering != nullptr); |
| 1953 | PFN_vkCmdEndRendering vkCmdEndRendering = |
| 1954 | reinterpret_cast<PFN_vkCmdEndRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndRendering")); |
| 1955 | assert(vkCmdEndRendering != nullptr); |
| 1956 | |
| 1957 | m_commandBuffer->begin(); |
| 1958 | |
| 1959 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 1960 | VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1}; |
| 1961 | begin_rendering_info.renderArea = clear_rect.rect; |
| 1962 | begin_rendering_info.layerCount = 1; |
| 1963 | |
| 1964 | vkCmdBeginRendering(m_commandBuffer->handle(), &begin_rendering_info); |
| 1965 | |
| 1966 | VkBufferObj buffer; |
| 1967 | VkMemoryPropertyFlags mem_reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 1968 | buffer.init_as_src_and_dst(*m_device, 256, mem_reqs); |
| 1969 | |
| 1970 | auto buf_barrier = lvl_init_struct<VkBufferMemoryBarrier2KHR>(); |
| 1971 | buf_barrier.buffer = buffer.handle(); |
| 1972 | buf_barrier.offset = 0; |
| 1973 | buf_barrier.size = VK_WHOLE_SIZE; |
| 1974 | buf_barrier.srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; |
| 1975 | buf_barrier.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; |
| 1976 | |
| 1977 | auto dependency_info = lvl_init_struct<VkDependencyInfoKHR>(); |
| 1978 | dependency_info.bufferMemoryBarrierCount = 1; |
| 1979 | dependency_info.pBufferMemoryBarriers = &buf_barrier; |
| 1980 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier2-None-06191"); |
| 1981 | vk::CmdPipelineBarrier2(m_commandBuffer->handle(), &dependency_info); |
| 1982 | m_errorMonitor->VerifyFound(); |
| 1983 | |
| 1984 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-None-06191"); |
| 1985 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, |
| 1986 | nullptr, 0, nullptr, 0, nullptr); |
| 1987 | m_errorMonitor->VerifyFound(); |
| 1988 | |
| 1989 | vkCmdEndRendering(m_commandBuffer->handle()); |
| 1990 | m_commandBuffer->end(); |
| 1991 | } |
| 1992 | |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 1993 | TEST_F(VkLayerTest, BeginRenderingInvalidStencilAttachmentFormat) { |
| 1994 | TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format"); |
| 1995 | |
| 1996 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 1997 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1998 | |
| 1999 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2000 | |
| 2001 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2002 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
| 2003 | } |
| 2004 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2005 | if (!AreRequiredExtensionsEnabled()) { |
| 2006 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 2007 | } |
| 2008 | |
| 2009 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2010 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2011 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2012 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2013 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 2014 | } |
| 2015 | |
| 2016 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2017 | |
| 2018 | VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu()); |
| 2019 | if (depth_format == VK_FORMAT_UNDEFINED) { |
| 2020 | printf("%s requires a stencil only format format.\n", kSkipPrefix); |
| 2021 | return; |
| 2022 | } |
| 2023 | |
| 2024 | VkImageObj image(m_device); |
| 2025 | image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 2026 | VkImageView image_view = image.targetView(depth_format, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2027 | |
| 2028 | VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2029 | stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL; |
| 2030 | stencil_attachment.imageView = image_view; |
| 2031 | |
| 2032 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2033 | begin_rendering_info.layerCount = 1; |
| 2034 | begin_rendering_info.pStencilAttachment = &stencil_attachment; |
| 2035 | |
| 2036 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06548"); |
| 2037 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2038 | m_errorMonitor->VerifyFound(); |
| 2039 | } |
| 2040 | |
| 2041 | TEST_F(VkLayerTest, TestInheritanceRenderingInfoStencilAttachmentFormat) { |
| 2042 | TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format"); |
| 2043 | |
| 2044 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 2045 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2046 | |
| 2047 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2048 | |
| 2049 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2050 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
| 2051 | } |
| 2052 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2053 | if (!AreRequiredExtensionsEnabled()) { |
| 2054 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 2055 | } |
| 2056 | |
| 2057 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2058 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2059 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2060 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2061 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 2062 | } |
| 2063 | |
| 2064 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2065 | |
| 2066 | VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu()); |
| 2067 | if (depth_format == VK_FORMAT_UNDEFINED) { |
| 2068 | printf("%s requires a stencil only format format.\n", kSkipPrefix); |
| 2069 | return; |
| 2070 | } |
| 2071 | |
| 2072 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2073 | |
| 2074 | auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
| 2075 | cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1; |
| 2076 | cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format; |
| 2077 | cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = depth_format; |
| 2078 | cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = depth_format; |
| 2079 | cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 2080 | |
| 2081 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 2082 | cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info; |
| 2083 | cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE; |
| 2084 | |
| 2085 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 2086 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 2087 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 2088 | |
| 2089 | auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>(); |
| 2090 | cmd_buffer_allocate_info.commandPool = m_commandPool->handle(); |
| 2091 | cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
| 2092 | cmd_buffer_allocate_info.commandBufferCount = 1; |
| 2093 | |
| 2094 | VkCommandBuffer secondary_cmd_buffer; |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 2095 | vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer); |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 2096 | |
| 2097 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541"); |
| 2098 | vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info); |
| 2099 | m_errorMonitor->VerifyFound(); |
| 2100 | } |
ziga-lunarg | eb4a69c | 2022-04-20 21:52:00 +0200 | [diff] [blame] | 2101 | |
| 2102 | TEST_F(VkLayerTest, CreateGraphicsPipelineWithInvalidAttachmentSampleCount) { |
| 2103 | TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set"); |
| 2104 | |
ziga-lunarg | 7f25dff | 2022-05-06 17:49:34 +0200 | [diff] [blame] | 2105 | SetTargetApiVersion(VK_API_VERSION_1_1); |
ziga-lunarg | eb4a69c | 2022-04-20 21:52:00 +0200 | [diff] [blame] | 2106 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2107 | AddRequiredExtensions(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME); |
| 2108 | |
| 2109 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2110 | |
| 2111 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2112 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | eb4a69c | 2022-04-20 21:52:00 +0200 | [diff] [blame] | 2113 | } |
| 2114 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2115 | if (!AreRequiredExtensionsEnabled()) { |
| 2116 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | eb4a69c | 2022-04-20 21:52:00 +0200 | [diff] [blame] | 2117 | } |
| 2118 | |
| 2119 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2120 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2121 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2122 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2123 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | eb4a69c | 2022-04-20 21:52:00 +0200 | [diff] [blame] | 2124 | } |
| 2125 | |
| 2126 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2127 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2128 | |
| 2129 | auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoNV>(); |
| 2130 | sample_count_info_amd.colorAttachmentCount = 1; |
ziga-lunarg | 7f25dff | 2022-05-06 17:49:34 +0200 | [diff] [blame] | 2131 | sample_count_info_amd.depthStencilAttachmentSamples = static_cast<VkSampleCountFlagBits>(0x3); |
ziga-lunarg | eb4a69c | 2022-04-20 21:52:00 +0200 | [diff] [blame] | 2132 | |
| 2133 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&sample_count_info_amd); |
| 2134 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 2135 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 2136 | |
| 2137 | CreatePipelineHelper pipe(*this); |
| 2138 | pipe.InitInfo(); |
| 2139 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 2140 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2141 | pipe.InitState(); |
| 2142 | |
| 2143 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-depthStencilAttachmentSamples-06593"); |
| 2144 | pipe.CreateGraphicsPipeline(); |
| 2145 | m_errorMonitor->VerifyFound(); |
| 2146 | } |
ziga-lunarg | d680bf2 | 2022-04-20 22:01:00 +0200 | [diff] [blame] | 2147 | |
| 2148 | TEST_F(VkLayerTest, CreatePipelineUsingDynamicRenderingWithoutFeature) { |
| 2149 | TEST_DESCRIPTION("Create graphcis pipeline that uses dynamic rendering, but feature is not enabled"); |
| 2150 | |
| 2151 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 2152 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2153 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 2154 | |
| 2155 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2156 | |
| 2157 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2158 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | d680bf2 | 2022-04-20 22:01:00 +0200 | [diff] [blame] | 2159 | } |
| 2160 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2161 | if (!AreRequiredExtensionsEnabled()) { |
| 2162 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | d680bf2 | 2022-04-20 22:01:00 +0200 | [diff] [blame] | 2163 | } |
| 2164 | |
| 2165 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2166 | |
| 2167 | CreatePipelineHelper pipe(*this); |
| 2168 | pipe.InitInfo(); |
| 2169 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2170 | pipe.InitState(); |
| 2171 | |
| 2172 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-dynamicRendering-06576"); |
| 2173 | pipe.CreateGraphicsPipeline(); |
| 2174 | m_errorMonitor->VerifyFound(); |
| 2175 | } |
ziga-lunarg | f20d795 | 2022-04-20 22:11:40 +0200 | [diff] [blame] | 2176 | |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2177 | TEST_F(VkLayerTest, DynamicRenderingAreaGreaterThanAttachmentExtent) { |
| 2178 | TEST_DESCRIPTION("Begin dynamic rendering with render area greater than extent of attachments"); |
| 2179 | |
| 2180 | SetTargetApiVersion(VK_API_VERSION_1_0); |
| 2181 | AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 2182 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2183 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2184 | |
| 2185 | if (DeviceValidationVersion() != VK_API_VERSION_1_0) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2186 | GTEST_SKIP() << "Tests for 1.0 only"; |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2187 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2188 | if (!AreRequiredExtensionsEnabled()) { |
| 2189 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2190 | } |
| 2191 | |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2192 | auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>( |
| 2193 | vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR")); |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2194 | ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr); |
| 2195 | |
| 2196 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2197 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features); |
| 2198 | vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2); |
| 2199 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2200 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2201 | } |
| 2202 | |
| 2203 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2204 | |
| 2205 | VkImageObj colorImage(m_device); |
| 2206 | colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 2207 | VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 2208 | |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2209 | auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2210 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 2211 | color_attachment.imageView = colorImageView; |
| 2212 | |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2213 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2214 | begin_rendering_info.layerCount = 1; |
| 2215 | begin_rendering_info.colorAttachmentCount = 1; |
| 2216 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 2217 | begin_rendering_info.renderArea.extent.width = 64; |
| 2218 | begin_rendering_info.renderArea.extent.height = 32; |
| 2219 | |
| 2220 | m_commandBuffer->begin(); |
| 2221 | |
| 2222 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06075"); |
| 2223 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2224 | m_errorMonitor->VerifyFound(); |
| 2225 | |
| 2226 | begin_rendering_info.renderArea.extent.width = 32; |
| 2227 | begin_rendering_info.renderArea.extent.height = 64; |
| 2228 | |
| 2229 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076"); |
| 2230 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2231 | m_errorMonitor->VerifyFound(); |
| 2232 | |
| 2233 | const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu()); |
| 2234 | if (ds_format != VK_FORMAT_UNDEFINED) { |
| 2235 | VkImageObj depthImage(m_device); |
| 2236 | depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 2237 | VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2238 | |
| 2239 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2240 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 2241 | depth_attachment.imageView = depthImageView; |
| 2242 | |
| 2243 | begin_rendering_info.colorAttachmentCount = 0; |
| 2244 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 2245 | |
| 2246 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076"); |
| 2247 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2248 | m_errorMonitor->VerifyFound(); |
| 2249 | } |
| 2250 | |
| 2251 | m_commandBuffer->end(); |
| 2252 | } |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2253 | |
| 2254 | TEST_F(VkLayerTest, DynamicRenderingDeviceGroupAreaGreaterThanAttachmentExtent) { |
| 2255 | TEST_DESCRIPTION("Begin dynamic rendering with device group with render area greater than extent of attachments"); |
| 2256 | |
| 2257 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2258 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2259 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2260 | |
| 2261 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2262 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2263 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2264 | if (!AreRequiredExtensionsEnabled()) { |
| 2265 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2266 | } |
| 2267 | |
| 2268 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2269 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2270 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2271 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2272 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2276 | |
| 2277 | VkImageObj colorImage(m_device); |
| 2278 | colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 2279 | VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 2280 | |
| 2281 | auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2282 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 2283 | color_attachment.imageView = colorImageView; |
| 2284 | |
| 2285 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2286 | begin_rendering_info.layerCount = 1; |
| 2287 | begin_rendering_info.colorAttachmentCount = 1; |
| 2288 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 2289 | begin_rendering_info.renderArea.extent.width = 64; |
| 2290 | begin_rendering_info.renderArea.extent.height = 32; |
| 2291 | |
| 2292 | m_commandBuffer->begin(); |
| 2293 | |
| 2294 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06079"); |
| 2295 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2296 | m_errorMonitor->VerifyFound(); |
| 2297 | |
| 2298 | begin_rendering_info.renderArea.extent.width = 32; |
| 2299 | begin_rendering_info.renderArea.extent.height = 64; |
| 2300 | |
| 2301 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080"); |
| 2302 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2303 | m_errorMonitor->VerifyFound(); |
| 2304 | |
| 2305 | const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu()); |
| 2306 | if (ds_format != VK_FORMAT_UNDEFINED) { |
| 2307 | VkImageObj depthImage(m_device); |
| 2308 | depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 2309 | VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2310 | |
| 2311 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2312 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 2313 | depth_attachment.imageView = depthImageView; |
| 2314 | |
| 2315 | begin_rendering_info.colorAttachmentCount = 0; |
| 2316 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 2317 | |
| 2318 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080"); |
| 2319 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2320 | m_errorMonitor->VerifyFound(); |
| 2321 | } |
| 2322 | |
| 2323 | m_commandBuffer->end(); |
| 2324 | } |
ziga-lunarg | d4105c1 | 2022-04-21 13:54:20 +0200 | [diff] [blame] | 2325 | |
| 2326 | TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleRenderPass) { |
| 2327 | TEST_DESCRIPTION("Execute secondary command buffers within render pass instance with incompatible render pass"); |
| 2328 | |
| 2329 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2330 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2331 | |
| 2332 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2333 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | d4105c1 | 2022-04-21 13:54:20 +0200 | [diff] [blame] | 2334 | } |
| 2335 | |
| 2336 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2337 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2338 | |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 2339 | VkSubpassDescription subpass = {}; |
ziga-lunarg | d4105c1 | 2022-04-21 13:54:20 +0200 | [diff] [blame] | 2340 | auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>(); |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 2341 | render_pass_ci.subpassCount = 1; |
| 2342 | render_pass_ci.pSubpasses = &subpass; |
ziga-lunarg | d4105c1 | 2022-04-21 13:54:20 +0200 | [diff] [blame] | 2343 | |
| 2344 | vk_testing::RenderPass render_pass; |
| 2345 | render_pass.init(*m_device, render_pass_ci); |
| 2346 | |
| 2347 | VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 2348 | VkCommandBuffer secondary_handle = cb.handle(); |
| 2349 | |
| 2350 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 2351 | cmd_buffer_inheritance_info.renderPass = render_pass.handle(); |
| 2352 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 2353 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 2354 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 2355 | |
| 2356 | cb.begin(&cmd_buffer_begin_info); |
| 2357 | cb.end(); |
| 2358 | |
| 2359 | m_commandBuffer->begin(); |
| 2360 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 2361 | |
| 2362 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020"); |
| 2363 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098"); |
| 2364 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle); |
| 2365 | m_errorMonitor->VerifyFound(); |
| 2366 | |
| 2367 | m_commandBuffer->EndRenderPass(); |
| 2368 | m_commandBuffer->end(); |
| 2369 | } |
ziga-lunarg | 590e029 | 2022-04-21 14:07:22 +0200 | [diff] [blame] | 2370 | |
| 2371 | TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleSubpass) { |
| 2372 | TEST_DESCRIPTION("Execute secondary command buffers with different subpass"); |
| 2373 | |
| 2374 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2375 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2376 | |
| 2377 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2378 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 590e029 | 2022-04-21 14:07:22 +0200 | [diff] [blame] | 2379 | } |
| 2380 | |
| 2381 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2382 | |
| 2383 | VkSubpassDescription subpasses[2] = {}; |
| 2384 | |
| 2385 | auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>(); |
| 2386 | render_pass_ci.subpassCount = 2; |
| 2387 | render_pass_ci.pSubpasses = subpasses; |
| 2388 | |
| 2389 | vk_testing::RenderPass render_pass; |
| 2390 | render_pass.init(*m_device, render_pass_ci); |
| 2391 | |
| 2392 | auto framebuffer_ci = LvlInitStruct<VkFramebufferCreateInfo>(); |
| 2393 | framebuffer_ci.renderPass = render_pass.handle(); |
| 2394 | framebuffer_ci.width = 32; |
| 2395 | framebuffer_ci.height = 32; |
ziga-lunarg | 143bdbf | 2022-05-04 19:04:58 +0200 | [diff] [blame] | 2396 | framebuffer_ci.layers = 1; |
ziga-lunarg | 590e029 | 2022-04-21 14:07:22 +0200 | [diff] [blame] | 2397 | |
| 2398 | vk_testing::Framebuffer framebuffer; |
| 2399 | framebuffer.init(*m_device, framebuffer_ci); |
| 2400 | |
| 2401 | VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 2402 | VkCommandBuffer secondary_handle = cb.handle(); |
| 2403 | |
| 2404 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 2405 | cmd_buffer_inheritance_info.renderPass = render_pass.handle(); |
| 2406 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 2407 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 2408 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 2409 | |
| 2410 | cb.begin(&cmd_buffer_begin_info); |
| 2411 | cb.end(); |
| 2412 | |
| 2413 | auto render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>(); |
| 2414 | render_pass_begin_info.renderPass = render_pass.handle(); |
| 2415 | render_pass_begin_info.renderArea.extent = {32, 32}; |
| 2416 | render_pass_begin_info.framebuffer = framebuffer.handle(); |
| 2417 | |
| 2418 | m_commandBuffer->begin(); |
| 2419 | m_commandBuffer->BeginRenderPass(render_pass_begin_info, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 2420 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 2421 | |
| 2422 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00097"); |
| 2423 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-06019"); |
| 2424 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle); |
| 2425 | m_errorMonitor->VerifyFound(); |
| 2426 | |
| 2427 | m_commandBuffer->EndRenderPass(); |
| 2428 | m_commandBuffer->end(); |
| 2429 | } |
ziga-lunarg | 343193b | 2022-04-21 14:15:17 +0200 | [diff] [blame] | 2430 | |
| 2431 | TEST_F(VkLayerTest, SecondaryCommandBufferInvalidContents) { |
| 2432 | TEST_DESCRIPTION("Execute secondary command buffers within active render pass that was not begun with VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS"); |
| 2433 | |
| 2434 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2435 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2436 | |
| 2437 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2438 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 343193b | 2022-04-21 14:15:17 +0200 | [diff] [blame] | 2439 | } |
| 2440 | |
| 2441 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2442 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2443 | |
ziga-lunarg | 343193b | 2022-04-21 14:15:17 +0200 | [diff] [blame] | 2444 | VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 2445 | VkCommandBuffer secondary_handle = cb.handle(); |
| 2446 | |
| 2447 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 2448 | cmd_buffer_inheritance_info.renderPass = m_renderPass; |
| 2449 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 2450 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 2451 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 2452 | |
| 2453 | cb.begin(&cmd_buffer_begin_info); |
| 2454 | cb.end(); |
| 2455 | |
| 2456 | m_commandBuffer->begin(); |
| 2457 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 2458 | |
| 2459 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-00095"); |
| 2460 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-06018"); |
| 2461 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle); |
| 2462 | m_errorMonitor->VerifyFound(); |
| 2463 | |
| 2464 | m_commandBuffer->EndRenderPass(); |
| 2465 | m_commandBuffer->end(); |
| 2466 | } |
ziga-lunarg | 9104e0a | 2022-04-21 16:45:09 +0200 | [diff] [blame] | 2467 | |
| 2468 | TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoDepthFormat) { |
| 2469 | TEST_DESCRIPTION("Bind pipeline that has RenderingInfo DepthFormat incompatible with previously used pipeline"); |
| 2470 | |
| 2471 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2472 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2473 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2474 | |
| 2475 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2476 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 9104e0a | 2022-04-21 16:45:09 +0200 | [diff] [blame] | 2477 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2478 | if (!AreRequiredExtensionsEnabled()) { |
| 2479 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 9104e0a | 2022-04-21 16:45:09 +0200 | [diff] [blame] | 2480 | } |
| 2481 | |
| 2482 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2483 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2484 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2485 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2486 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 9104e0a | 2022-04-21 16:45:09 +0200 | [diff] [blame] | 2487 | } |
| 2488 | |
| 2489 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2490 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2491 | |
| 2492 | m_errorMonitor->ExpectSuccess(); |
| 2493 | |
| 2494 | std::vector<VkFormat> depth_formats; |
| 2495 | const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT}; |
| 2496 | for (uint32_t i = 0; i < size(ds_formats); ++i) { |
| 2497 | VkFormatProperties format_props; |
| 2498 | vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props); |
| 2499 | |
| 2500 | if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { |
| 2501 | depth_formats.push_back(ds_formats[i]); |
| 2502 | } |
| 2503 | } |
| 2504 | |
| 2505 | if (depth_formats.size() < 2) { |
| 2506 | printf("%s Test requires 2 depth formats, skipping test.\n", kSkipPrefix); |
| 2507 | return; |
| 2508 | } |
| 2509 | |
| 2510 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2511 | pipeline_rendering_info.depthAttachmentFormat = depth_formats[0]; |
| 2512 | |
| 2513 | auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 2514 | |
| 2515 | CreatePipelineHelper pipe1(*this); |
| 2516 | pipe1.InitInfo(); |
| 2517 | pipe1.gp_ci_.pNext = &pipeline_rendering_info; |
| 2518 | pipe1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2519 | pipe1.InitState(); |
| 2520 | pipe1.ds_ci_ = ds_ci; |
| 2521 | pipe1.CreateGraphicsPipeline(); |
| 2522 | |
| 2523 | pipeline_rendering_info.depthAttachmentFormat = depth_formats[1]; |
| 2524 | |
| 2525 | CreatePipelineHelper pipe2(*this); |
| 2526 | pipe2.InitInfo(); |
| 2527 | pipe2.gp_ci_.pNext = &pipeline_rendering_info; |
| 2528 | pipe2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2529 | pipe2.InitState(); |
| 2530 | pipe2.ds_ci_ = ds_ci; |
| 2531 | pipe2.CreateGraphicsPipeline(); |
| 2532 | |
| 2533 | VkImageObj image(m_device); |
| 2534 | image.Init(32, 32, 1, depth_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 2535 | VkImageView depth_image_view = image.targetView(depth_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2536 | |
| 2537 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2538 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 2539 | depth_attachment.imageView = depth_image_view; |
| 2540 | |
| 2541 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2542 | begin_rendering_info.layerCount = 1; |
| 2543 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 2544 | |
| 2545 | m_commandBuffer->begin(); |
| 2546 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2547 | |
| 2548 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_); |
| 2549 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 2550 | |
| 2551 | m_errorMonitor->VerifyNotFound(); |
| 2552 | |
| 2553 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06197"); |
| 2554 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_); |
| 2555 | m_errorMonitor->VerifyFound(); |
| 2556 | |
| 2557 | m_commandBuffer->EndRendering(); |
| 2558 | m_commandBuffer->end(); |
| 2559 | } |
ziga-lunarg | 1ac9b67 | 2022-04-21 17:55:28 +0200 | [diff] [blame] | 2560 | |
| 2561 | TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachments) { |
| 2562 | TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment incompatible with previously used pipeline"); |
| 2563 | |
| 2564 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2565 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2566 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2567 | |
| 2568 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2569 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 1ac9b67 | 2022-04-21 17:55:28 +0200 | [diff] [blame] | 2570 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2571 | if (!AreRequiredExtensionsEnabled()) { |
| 2572 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 1ac9b67 | 2022-04-21 17:55:28 +0200 | [diff] [blame] | 2573 | } |
| 2574 | |
| 2575 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2576 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2577 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2578 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2579 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 1ac9b67 | 2022-04-21 17:55:28 +0200 | [diff] [blame] | 2580 | } |
| 2581 | |
| 2582 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2583 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2584 | |
| 2585 | m_errorMonitor->ExpectSuccess(); |
| 2586 | |
| 2587 | VkFormat format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2588 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2589 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 2590 | pipeline_rendering_info.pColorAttachmentFormats = &format; |
| 2591 | |
| 2592 | CreatePipelineHelper pipe1(*this); |
| 2593 | pipe1.InitInfo(); |
| 2594 | pipe1.gp_ci_.pNext = &pipeline_rendering_info; |
| 2595 | pipe1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2596 | pipe1.InitState(); |
| 2597 | pipe1.CreateGraphicsPipeline(); |
| 2598 | |
| 2599 | format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2600 | |
| 2601 | CreatePipelineHelper pipe2(*this); |
| 2602 | pipe2.InitInfo(); |
| 2603 | pipe2.gp_ci_.pNext = &pipeline_rendering_info; |
| 2604 | pipe2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2605 | pipe2.InitState(); |
| 2606 | pipe2.CreateGraphicsPipeline(); |
| 2607 | |
| 2608 | VkImageObj image(m_device); |
| 2609 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 2610 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 2611 | |
| 2612 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2613 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 2614 | color_attachment.imageView = image_view; |
| 2615 | |
| 2616 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2617 | begin_rendering_info.layerCount = 1; |
| 2618 | begin_rendering_info.colorAttachmentCount = 1; |
| 2619 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 2620 | |
| 2621 | m_commandBuffer->begin(); |
| 2622 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2623 | |
| 2624 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_); |
| 2625 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 2626 | |
| 2627 | m_errorMonitor->VerifyNotFound(); |
| 2628 | |
| 2629 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06196"); |
| 2630 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_); |
| 2631 | m_errorMonitor->VerifyFound(); |
| 2632 | |
| 2633 | m_commandBuffer->EndRendering(); |
| 2634 | m_commandBuffer->end(); |
| 2635 | } |
ziga-lunarg | acd7932 | 2022-04-21 18:36:34 +0200 | [diff] [blame] | 2636 | |
| 2637 | TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachmentCount) { |
| 2638 | TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment count incompatible with previously used pipeline"); |
| 2639 | |
| 2640 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2641 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2642 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2643 | |
| 2644 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2645 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | acd7932 | 2022-04-21 18:36:34 +0200 | [diff] [blame] | 2646 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2647 | if (!AreRequiredExtensionsEnabled()) { |
| 2648 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | acd7932 | 2022-04-21 18:36:34 +0200 | [diff] [blame] | 2649 | } |
| 2650 | |
| 2651 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2652 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2653 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2654 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2655 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | acd7932 | 2022-04-21 18:36:34 +0200 | [diff] [blame] | 2656 | } |
| 2657 | |
| 2658 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2659 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2660 | |
| 2661 | m_errorMonitor->ExpectSuccess(); |
| 2662 | |
| 2663 | VkFormat format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2664 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2665 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 2666 | pipeline_rendering_info.pColorAttachmentFormats = &format; |
| 2667 | |
| 2668 | CreatePipelineHelper pipe1(*this); |
| 2669 | pipe1.InitInfo(); |
| 2670 | pipe1.gp_ci_.pNext = &pipeline_rendering_info; |
| 2671 | pipe1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2672 | pipe1.InitState(); |
| 2673 | pipe1.CreateGraphicsPipeline(); |
| 2674 | |
| 2675 | pipeline_rendering_info.colorAttachmentCount = 0; |
| 2676 | |
| 2677 | CreatePipelineHelper pipe2(*this); |
| 2678 | pipe2.InitInfo(); |
| 2679 | pipe2.gp_ci_.pNext = &pipeline_rendering_info; |
| 2680 | pipe2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2681 | pipe2.InitState(); |
| 2682 | pipe2.CreateGraphicsPipeline(); |
| 2683 | |
| 2684 | VkImageObj image(m_device); |
| 2685 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 2686 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 2687 | |
| 2688 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2689 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 2690 | color_attachment.imageView = image_view; |
| 2691 | |
| 2692 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2693 | begin_rendering_info.layerCount = 1; |
| 2694 | begin_rendering_info.colorAttachmentCount = 1; |
| 2695 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 2696 | |
| 2697 | m_commandBuffer->begin(); |
| 2698 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2699 | |
| 2700 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_); |
| 2701 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 2702 | |
| 2703 | m_errorMonitor->VerifyNotFound(); |
| 2704 | |
| 2705 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06195"); |
| 2706 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_); |
| 2707 | m_errorMonitor->VerifyFound(); |
| 2708 | |
| 2709 | m_commandBuffer->EndRendering(); |
| 2710 | m_commandBuffer->end(); |
ziga-lunarg | e3f1128 | 2022-04-21 18:39:55 +0200 | [diff] [blame] | 2711 | } |
| 2712 | |
| 2713 | TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoStencilFormat) { |
| 2714 | TEST_DESCRIPTION("Bind pipeline that has RenderingInfo StencilFormat incompatible with previously used pipeline"); |
| 2715 | |
| 2716 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2717 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2718 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2719 | |
| 2720 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2721 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | e3f1128 | 2022-04-21 18:39:55 +0200 | [diff] [blame] | 2722 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2723 | if (!AreRequiredExtensionsEnabled()) { |
| 2724 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | e3f1128 | 2022-04-21 18:39:55 +0200 | [diff] [blame] | 2725 | } |
| 2726 | |
| 2727 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2728 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2729 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2730 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2731 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | e3f1128 | 2022-04-21 18:39:55 +0200 | [diff] [blame] | 2732 | } |
| 2733 | |
| 2734 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2735 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2736 | |
| 2737 | m_errorMonitor->ExpectSuccess(); |
| 2738 | |
| 2739 | std::vector<VkFormat> stencil_formats; |
| 2740 | const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT}; |
| 2741 | for (uint32_t i = 0; i < size(ds_formats); ++i) { |
| 2742 | VkFormatProperties format_props; |
| 2743 | vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props); |
| 2744 | |
| 2745 | if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { |
| 2746 | stencil_formats.push_back(ds_formats[i]); |
| 2747 | } |
| 2748 | } |
| 2749 | |
| 2750 | if (stencil_formats.size() < 2) { |
| 2751 | printf("%s Test requires 2 stencil formats, skipping test.\n", kSkipPrefix); |
| 2752 | return; |
| 2753 | } |
| 2754 | |
| 2755 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2756 | pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[0]; |
| 2757 | |
| 2758 | auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 2759 | |
| 2760 | CreatePipelineHelper pipe1(*this); |
| 2761 | pipe1.InitInfo(); |
| 2762 | pipe1.gp_ci_.pNext = &pipeline_rendering_info; |
| 2763 | pipe1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2764 | pipe1.InitState(); |
| 2765 | pipe1.ds_ci_ = ds_ci; |
| 2766 | pipe1.CreateGraphicsPipeline(); |
| 2767 | |
| 2768 | pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[1]; |
| 2769 | |
| 2770 | CreatePipelineHelper pipe2(*this); |
| 2771 | pipe2.InitInfo(); |
| 2772 | pipe2.gp_ci_.pNext = &pipeline_rendering_info; |
| 2773 | pipe2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2774 | pipe2.InitState(); |
| 2775 | pipe2.ds_ci_ = ds_ci; |
| 2776 | pipe2.CreateGraphicsPipeline(); |
| 2777 | |
| 2778 | VkImageObj image(m_device); |
| 2779 | image.Init(32, 32, 1, stencil_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 2780 | VkImageView stencil_image_view = image.targetView(stencil_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2781 | |
| 2782 | VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2783 | stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL; |
| 2784 | stencil_attachment.imageView = stencil_image_view; |
| 2785 | |
| 2786 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2787 | begin_rendering_info.layerCount = 1; |
| 2788 | begin_rendering_info.pStencilAttachment = &stencil_attachment; |
| 2789 | |
| 2790 | m_commandBuffer->begin(); |
| 2791 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2792 | |
| 2793 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_); |
| 2794 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 2795 | |
| 2796 | m_errorMonitor->VerifyNotFound(); |
| 2797 | |
| 2798 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06194"); |
| 2799 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_); |
| 2800 | m_errorMonitor->VerifyFound(); |
| 2801 | |
| 2802 | m_commandBuffer->EndRendering(); |
| 2803 | m_commandBuffer->end(); |
| 2804 | } |
ziga-lunarg | 155ed45 | 2022-04-21 23:54:06 +0200 | [diff] [blame] | 2805 | |
| 2806 | TEST_F(VkLayerTest, DynamicRenderingWithInvalidShaderLayerBuiltIn) { |
| 2807 | TEST_DESCRIPTION("Create invalid pipeline that writes to Layer built-in"); |
| 2808 | |
| 2809 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2810 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2811 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2812 | |
| 2813 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2814 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 155ed45 | 2022-04-21 23:54:06 +0200 | [diff] [blame] | 2815 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2816 | if (!AreRequiredExtensionsEnabled()) { |
| 2817 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 155ed45 | 2022-04-21 23:54:06 +0200 | [diff] [blame] | 2818 | } |
| 2819 | |
| 2820 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2821 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(&dynamic_rendering_features); |
| 2822 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features); |
| 2823 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2824 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2825 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 155ed45 | 2022-04-21 23:54:06 +0200 | [diff] [blame] | 2826 | } |
| 2827 | if (multiview_features.multiview == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2828 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | 155ed45 | 2022-04-21 23:54:06 +0200 | [diff] [blame] | 2829 | } |
| 2830 | if (multiview_features.multiviewGeometryShader == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2831 | GTEST_SKIP() << "Test requires (unsupported) multiviewGeometryShader"; |
ziga-lunarg | 155ed45 | 2022-04-21 23:54:06 +0200 | [diff] [blame] | 2832 | } |
| 2833 | |
| 2834 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2835 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2836 | |
| 2837 | static char const *gsSource = R"glsl( |
| 2838 | #version 450 |
| 2839 | layout (triangles) in; |
| 2840 | layout (triangle_strip) out; |
| 2841 | layout (max_vertices = 1) out; |
| 2842 | void main() { |
| 2843 | gl_Position = vec4(1.0, 0.5, 0.5, 0.0); |
| 2844 | EmitVertex(); |
| 2845 | gl_Layer = 4; |
| 2846 | } |
| 2847 | )glsl"; |
| 2848 | |
| 2849 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 2850 | VkShaderObj gs(this, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT); |
| 2851 | |
| 2852 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2853 | |
| 2854 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2855 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 2856 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 2857 | pipeline_rendering_info.viewMask = 0x1; |
| 2858 | |
| 2859 | CreatePipelineHelper pipe(*this); |
| 2860 | pipe.InitInfo(); |
| 2861 | pipe.shader_stages_ = {vs.GetStageCreateInfo(), gs.GetStageCreateInfo(), pipe.fs_->GetStageCreateInfo()}; |
| 2862 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 2863 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2864 | pipe.InitState(); |
| 2865 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06059"); |
| 2866 | pipe.CreateGraphicsPipeline(); |
| 2867 | m_errorMonitor->VerifyFound(); |
| 2868 | } |
ziga-lunarg | 6feb463 | 2022-04-22 00:20:21 +0200 | [diff] [blame] | 2869 | |
| 2870 | TEST_F(VkLayerTest, DynamicRenderingWithInputAttachmentCapability) { |
| 2871 | TEST_DESCRIPTION("Create invalid pipeline that uses InputAttachment capability"); |
| 2872 | |
| 2873 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2874 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2875 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2876 | |
| 2877 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2878 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 6feb463 | 2022-04-22 00:20:21 +0200 | [diff] [blame] | 2879 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2880 | if (!AreRequiredExtensionsEnabled()) { |
| 2881 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 6feb463 | 2022-04-22 00:20:21 +0200 | [diff] [blame] | 2882 | } |
| 2883 | |
| 2884 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2885 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2886 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2887 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2888 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 6feb463 | 2022-04-22 00:20:21 +0200 | [diff] [blame] | 2889 | } |
| 2890 | |
| 2891 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2892 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2893 | |
sjfricke | 394227a | 2022-06-20 16:47:38 +0900 | [diff] [blame] | 2894 | const char *fsSource = R"( |
ziga-lunarg | 6feb463 | 2022-04-22 00:20:21 +0200 | [diff] [blame] | 2895 | OpCapability Shader |
| 2896 | OpCapability InputAttachment |
| 2897 | %1 = OpExtInstImport "GLSL.std.450" |
| 2898 | OpMemoryModel Logical GLSL450 |
| 2899 | OpEntryPoint Fragment %main "main" |
| 2900 | OpExecutionMode %main OriginUpperLeft |
| 2901 | |
| 2902 | ; Debug Information |
| 2903 | OpSource GLSL 450 |
| 2904 | OpName %main "main" ; id %4 |
| 2905 | |
| 2906 | ; Types, variables and constants |
| 2907 | %void = OpTypeVoid |
| 2908 | %3 = OpTypeFunction %void |
| 2909 | |
| 2910 | ; Function main |
| 2911 | %main = OpFunction %void None %3 |
| 2912 | %5 = OpLabel |
| 2913 | OpReturn |
| 2914 | OpFunctionEnd |
| 2915 | )"; |
| 2916 | |
| 2917 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_ASM); |
| 2918 | |
| 2919 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2920 | |
| 2921 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2922 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 2923 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 2924 | |
| 2925 | CreatePipelineHelper pipe(*this); |
| 2926 | pipe.InitInfo(); |
| 2927 | pipe.shader_stages_ = {pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 2928 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 2929 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2930 | pipe.InitState(); |
| 2931 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06061"); |
| 2932 | pipe.CreateGraphicsPipeline(); |
| 2933 | m_errorMonitor->VerifyFound(); |
| 2934 | } |
ziga-lunarg | a62b6ce | 2022-04-22 14:33:47 +0200 | [diff] [blame] | 2935 | |
| 2936 | TEST_F(VkLayerTest, InvalidRenderingInfoColorAttachmentFormat) { |
| 2937 | TEST_DESCRIPTION("Create pipeline with invalid color attachment format"); |
| 2938 | |
| 2939 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2940 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2941 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2942 | |
| 2943 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2944 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | a62b6ce | 2022-04-22 14:33:47 +0200 | [diff] [blame] | 2945 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2946 | if (!AreRequiredExtensionsEnabled()) { |
| 2947 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | a62b6ce | 2022-04-22 14:33:47 +0200 | [diff] [blame] | 2948 | } |
| 2949 | |
| 2950 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2951 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2952 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2953 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2954 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | a62b6ce | 2022-04-22 14:33:47 +0200 | [diff] [blame] | 2955 | } |
| 2956 | |
| 2957 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2958 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2959 | |
| 2960 | VkFormat color_format = VK_FORMAT_MAX_ENUM; |
| 2961 | |
| 2962 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2963 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 2964 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 2965 | |
| 2966 | CreatePipelineHelper pipe(*this); |
| 2967 | pipe.InitInfo(); |
| 2968 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 2969 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2970 | pipe.InitState(); |
| 2971 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579"); |
| 2972 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580"); |
| 2973 | pipe.CreateGraphicsPipeline(); |
| 2974 | m_errorMonitor->VerifyFound(); |
| 2975 | } |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 2976 | |
| 2977 | TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryViewMask) { |
| 2978 | TEST_DESCRIPTION("Create pipeline with invalid view mask"); |
| 2979 | |
| 2980 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2981 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2982 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 2983 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2984 | |
| 2985 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2986 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 2987 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 2988 | if (!AreRequiredExtensionsEnabled()) { |
| 2989 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 2990 | } |
| 2991 | |
| 2992 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 2993 | auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features); |
| 2994 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features); |
| 2995 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2996 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2997 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2998 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 2999 | } |
| 3000 | if (library_features.graphicsPipelineLibrary == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3001 | GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary"; |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 3002 | } |
| 3003 | if (multiview_features.multiview == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3004 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 3005 | } |
| 3006 | |
| 3007 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3008 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3009 | |
| 3010 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3011 | |
| 3012 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3013 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3014 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 3015 | |
| 3016 | auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info); |
| 3017 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT; |
| 3018 | auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info); |
| 3019 | |
| 3020 | VkPipelineColorBlendAttachmentState color_blend_attachment_state = {}; |
| 3021 | auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>(); |
| 3022 | color_blend_state_create_info.attachmentCount = 1; |
| 3023 | color_blend_state_create_info.pAttachments = &color_blend_attachment_state; |
| 3024 | |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 3025 | CreatePipelineHelper lib(*this); |
| 3026 | lib.cb_ci_ = color_blend_state_create_info; |
| 3027 | lib.InitInfo(); |
| 3028 | lib.gp_ci_.pNext = &library_create_info; |
| 3029 | lib.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3030 | lib.InitState(); |
| 3031 | lib.CreateGraphicsPipeline(); |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 3032 | |
| 3033 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT; |
| 3034 | library_create_info.libraryCount = 1; |
| 3035 | library_create_info.pLibraries = &lib.pipeline_; |
| 3036 | pipeline_rendering_info.viewMask = 0x1; |
| 3037 | |
| 3038 | CreatePipelineHelper pipe(*this); |
| 3039 | pipe.InitInfo(); |
| 3040 | pipe.gp_ci_.pNext = &library_create_info; |
| 3041 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3042 | pipe.InitState(); |
| 3043 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 3044 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626"); |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 3045 | pipe.CreateGraphicsPipeline(); |
| 3046 | m_errorMonitor->VerifyFound(); |
| 3047 | } |
ziga-lunarg | e151ca6 | 2022-04-22 17:40:51 +0200 | [diff] [blame] | 3048 | |
| 3049 | TEST_F(VkLayerTest, InvalidAttachmentSampleCount) { |
| 3050 | TEST_DESCRIPTION("Create pipeline with invalid color attachment samples"); |
| 3051 | |
| 3052 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3053 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3054 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3055 | |
| 3056 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3057 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | e151ca6 | 2022-04-22 17:40:51 +0200 | [diff] [blame] | 3058 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3059 | if (!AreRequiredExtensionsEnabled()) { |
| 3060 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | e151ca6 | 2022-04-22 17:40:51 +0200 | [diff] [blame] | 3061 | } |
| 3062 | |
| 3063 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3064 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3065 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3066 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3067 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | e151ca6 | 2022-04-22 17:40:51 +0200 | [diff] [blame] | 3068 | } |
| 3069 | |
| 3070 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3071 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3072 | |
| 3073 | VkSampleCountFlagBits color_attachment_samples = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM; |
| 3074 | |
| 3075 | auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>(); |
| 3076 | samples_info.colorAttachmentCount = 1; |
| 3077 | samples_info.pColorAttachmentSamples = &color_attachment_samples; |
| 3078 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info); |
| 3079 | |
| 3080 | CreatePipelineHelper pipe(*this); |
| 3081 | pipe.InitInfo(); |
| 3082 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 3083 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3084 | pipe.InitState(); |
| 3085 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592"); |
| 3086 | pipe.CreateGraphicsPipeline(); |
| 3087 | m_errorMonitor->VerifyFound(); |
| 3088 | } |
ziga-lunarg | b81597d | 2022-04-22 19:11:51 +0200 | [diff] [blame] | 3089 | |
| 3090 | TEST_F(VkLayerTest, InvalidDynamicRenderingLibrariesViewMask) { |
| 3091 | TEST_DESCRIPTION("Create pipeline with libaries that have incompatible view mask"); |
| 3092 | |
| 3093 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3094 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3095 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3096 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3097 | |
| 3098 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3099 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | b81597d | 2022-04-22 19:11:51 +0200 | [diff] [blame] | 3100 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3101 | if (!AreRequiredExtensionsEnabled()) { |
| 3102 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | b81597d | 2022-04-22 19:11:51 +0200 | [diff] [blame] | 3103 | } |
| 3104 | |
| 3105 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3106 | auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features); |
| 3107 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features); |
| 3108 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3109 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3110 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3111 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | b81597d | 2022-04-22 19:11:51 +0200 | [diff] [blame] | 3112 | } |
| 3113 | if (library_features.graphicsPipelineLibrary == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3114 | GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary"; |
ziga-lunarg | b81597d | 2022-04-22 19:11:51 +0200 | [diff] [blame] | 3115 | } |
| 3116 | if (multiview_features.multiview == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3117 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | b81597d | 2022-04-22 19:11:51 +0200 | [diff] [blame] | 3118 | } |
| 3119 | |
| 3120 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3121 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3122 | |
| 3123 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3124 | |
| 3125 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3126 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3127 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 3128 | |
| 3129 | auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info); |
| 3130 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT; |
| 3131 | auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info); |
| 3132 | |
| 3133 | VkPipelineColorBlendAttachmentState color_blend_attachment_state = {}; |
| 3134 | auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>(); |
| 3135 | color_blend_state_create_info.attachmentCount = 1; |
| 3136 | color_blend_state_create_info.pAttachments = &color_blend_attachment_state; |
| 3137 | |
| 3138 | m_errorMonitor->ExpectSuccess(); |
| 3139 | CreatePipelineHelper lib1(*this); |
| 3140 | lib1.cb_ci_ = color_blend_state_create_info; |
| 3141 | lib1.InitInfo(); |
| 3142 | lib1.gp_ci_.pNext = &library_create_info; |
| 3143 | lib1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3144 | lib1.InitState(); |
| 3145 | lib1.CreateGraphicsPipeline(); |
| 3146 | |
| 3147 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT; |
| 3148 | pipeline_rendering_info.viewMask = 0x1; |
| 3149 | |
| 3150 | auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 3151 | |
| 3152 | CreatePipelineHelper lib2(*this); |
| 3153 | lib2.cb_ci_ = color_blend_state_create_info; |
| 3154 | lib2.InitInfo(); |
| 3155 | lib2.gp_ci_.pNext = &library_create_info; |
| 3156 | lib2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3157 | lib2.ds_ci_ = ds_ci; |
| 3158 | lib2.InitState(); |
| 3159 | lib2.CreateGraphicsPipeline(); |
| 3160 | m_errorMonitor->VerifyNotFound(); |
| 3161 | |
| 3162 | graphics_library_create_info.flags = |
| 3163 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT; |
| 3164 | library_create_info.libraryCount = 2; |
| 3165 | VkPipeline libraries[2] = {lib1.pipeline_, lib2.pipeline_}; |
| 3166 | library_create_info.pLibraries = libraries; |
| 3167 | pipeline_rendering_info.viewMask = 0; |
| 3168 | |
| 3169 | CreatePipelineHelper pipe(*this); |
| 3170 | pipe.InitInfo(); |
| 3171 | pipe.gp_ci_.pNext = &library_create_info; |
| 3172 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3173 | pipe.InitState(); |
ziga-lunarg | 7f25dff | 2022-05-06 17:49:34 +0200 | [diff] [blame] | 3174 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pLibraries-06627"); |
ziga-lunarg | b81597d | 2022-04-22 19:11:51 +0200 | [diff] [blame] | 3175 | pipe.CreateGraphicsPipeline(); |
| 3176 | m_errorMonitor->VerifyFound(); |
| 3177 | } |
ziga-lunarg | 2e30231 | 2022-04-22 19:47:32 +0200 | [diff] [blame] | 3178 | |
| 3179 | TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryRenderPass) { |
| 3180 | TEST_DESCRIPTION("Create pipeline with invalid library render pass"); |
| 3181 | |
| 3182 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3183 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3184 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3185 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3186 | |
| 3187 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3188 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 2e30231 | 2022-04-22 19:47:32 +0200 | [diff] [blame] | 3189 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3190 | if (!AreRequiredExtensionsEnabled()) { |
| 3191 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 2e30231 | 2022-04-22 19:47:32 +0200 | [diff] [blame] | 3192 | } |
| 3193 | |
| 3194 | auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(); |
| 3195 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features); |
| 3196 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3197 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3198 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3199 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 2e30231 | 2022-04-22 19:47:32 +0200 | [diff] [blame] | 3200 | } |
| 3201 | if (library_features.graphicsPipelineLibrary == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3202 | GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary"; |
ziga-lunarg | 2e30231 | 2022-04-22 19:47:32 +0200 | [diff] [blame] | 3203 | } |
| 3204 | |
| 3205 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3206 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3207 | |
| 3208 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3209 | |
| 3210 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3211 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3212 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 3213 | |
| 3214 | auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info); |
| 3215 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT; |
| 3216 | auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info); |
| 3217 | |
| 3218 | VkPipelineColorBlendAttachmentState color_blend_attachment_state = {}; |
| 3219 | auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>(); |
| 3220 | color_blend_state_create_info.attachmentCount = 1; |
| 3221 | color_blend_state_create_info.pAttachments = &color_blend_attachment_state; |
| 3222 | |
| 3223 | m_errorMonitor->ExpectSuccess(); |
| 3224 | CreatePipelineHelper lib(*this); |
| 3225 | lib.cb_ci_ = color_blend_state_create_info; |
| 3226 | lib.InitInfo(); |
| 3227 | lib.gp_ci_.pNext = &library_create_info; |
| 3228 | lib.InitState(); |
| 3229 | lib.CreateGraphicsPipeline(); |
| 3230 | m_errorMonitor->VerifyNotFound(); |
| 3231 | |
| 3232 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT; |
| 3233 | library_create_info.libraryCount = 1; |
| 3234 | library_create_info.pLibraries = &lib.pipeline_; |
| 3235 | |
| 3236 | CreatePipelineHelper pipe(*this); |
| 3237 | pipe.InitInfo(); |
| 3238 | pipe.gp_ci_.pNext = &library_create_info; |
| 3239 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3240 | pipe.InitState(); |
| 3241 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06625"); |
| 3242 | pipe.CreateGraphicsPipeline(); |
| 3243 | m_errorMonitor->VerifyFound(); |
| 3244 | } |
ziga-lunarg | 7ba5a1c | 2022-04-22 19:56:49 +0200 | [diff] [blame] | 3245 | |
| 3246 | TEST_F(VkLayerTest, PipelineMissingMultisampleState) { |
| 3247 | TEST_DESCRIPTION("Create pipeline with missing multisample state"); |
| 3248 | |
| 3249 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3250 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3251 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3252 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3253 | |
| 3254 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3255 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 7ba5a1c | 2022-04-22 19:56:49 +0200 | [diff] [blame] | 3256 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3257 | if (!AreRequiredExtensionsEnabled()) { |
| 3258 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 7ba5a1c | 2022-04-22 19:56:49 +0200 | [diff] [blame] | 3259 | } |
| 3260 | |
| 3261 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3262 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3263 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3264 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3265 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 7ba5a1c | 2022-04-22 19:56:49 +0200 | [diff] [blame] | 3266 | } |
| 3267 | |
| 3268 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3269 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3270 | |
| 3271 | CreatePipelineHelper pipe(*this); |
| 3272 | pipe.InitInfo(); |
| 3273 | pipe.gp_ci_.pMultisampleState = nullptr; |
| 3274 | pipe.InitState(); |
| 3275 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06631"); |
| 3276 | pipe.CreateGraphicsPipeline(); |
| 3277 | m_errorMonitor->VerifyFound(); |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3278 | } |
| 3279 | |
ziga-lunarg | d773748 | 2022-04-25 11:16:37 +0200 | [diff] [blame] | 3280 | TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachment) { |
| 3281 | TEST_DESCRIPTION("Use invalid VkRenderingFragmentDensityMapAttachmentInfoEXT"); |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3282 | |
| 3283 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3284 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3285 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3286 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3287 | |
| 3288 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3289 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3290 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3291 | if (!AreRequiredExtensionsEnabled()) { |
| 3292 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3293 | } |
| 3294 | |
ziga-lunarg | d773748 | 2022-04-25 11:16:37 +0200 | [diff] [blame] | 3295 | auto multiview_featuers = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3296 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_featuers); |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3297 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3298 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3299 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3300 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3301 | } |
ziga-lunarg | d773748 | 2022-04-25 11:16:37 +0200 | [diff] [blame] | 3302 | if (multiview_featuers.multiview == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3303 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | d773748 | 2022-04-25 11:16:37 +0200 | [diff] [blame] | 3304 | } |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3305 | |
| 3306 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3307 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3308 | |
| 3309 | VkImageObj image(m_device); |
| 3310 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, |
| 3311 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0); |
| 3312 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3313 | |
| 3314 | auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 3315 | rendering_fragment_density.imageView = image_view; |
| 3316 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 3317 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3318 | begin_rendering_info.layerCount = 1; |
| 3319 | |
| 3320 | m_commandBuffer->begin(); |
ziga-lunarg | d773748 | 2022-04-25 11:16:37 +0200 | [diff] [blame] | 3321 | |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3322 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06157"); |
| 3323 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3324 | m_errorMonitor->VerifyFound(); |
ziga-lunarg | d773748 | 2022-04-25 11:16:37 +0200 | [diff] [blame] | 3325 | |
| 3326 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3327 | |
| 3328 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3329 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3330 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3331 | image_create_info.extent = {32, 32, 1}; |
| 3332 | image_create_info.mipLevels = 1; |
| 3333 | image_create_info.arrayLayers = 2; |
| 3334 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3335 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3336 | image_create_info.usage = VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT; |
| 3337 | VkImageObj image2(m_device); |
| 3338 | image2.Init(image_create_info); |
| 3339 | VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 3340 | rendering_fragment_density.imageView = image_view2; |
| 3341 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160"); |
| 3342 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06109"); |
| 3343 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3344 | m_errorMonitor->VerifyFound(); |
| 3345 | |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3346 | m_commandBuffer->end(); |
| 3347 | } |
ziga-lunarg | a81df9d | 2022-04-22 23:33:13 +0200 | [diff] [blame] | 3348 | |
| 3349 | TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentUsage) { |
| 3350 | TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout"); |
| 3351 | |
| 3352 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3353 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3354 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3355 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3356 | |
| 3357 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3358 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | a81df9d | 2022-04-22 23:33:13 +0200 | [diff] [blame] | 3359 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3360 | if (!AreRequiredExtensionsEnabled()) { |
| 3361 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | a81df9d | 2022-04-22 23:33:13 +0200 | [diff] [blame] | 3362 | } |
| 3363 | |
| 3364 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3365 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3366 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3367 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3368 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | a81df9d | 2022-04-22 23:33:13 +0200 | [diff] [blame] | 3369 | } |
| 3370 | |
| 3371 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3372 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3373 | |
| 3374 | VkImageObj image(m_device); |
| 3375 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 3376 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3377 | |
| 3378 | auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 3379 | rendering_fragment_density.imageView = image_view; |
| 3380 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3381 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3382 | begin_rendering_info.layerCount = 1; |
| 3383 | |
| 3384 | m_commandBuffer->begin(); |
| 3385 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06158"); |
| 3386 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3387 | m_errorMonitor->VerifyFound(); |
| 3388 | m_commandBuffer->end(); |
| 3389 | } |
ziga-lunarg | 7c411b3 | 2022-04-22 23:37:48 +0200 | [diff] [blame] | 3390 | |
| 3391 | TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentCreateFlags) { |
| 3392 | TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid image create flags"); |
| 3393 | |
| 3394 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3395 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3396 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3397 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3398 | |
| 3399 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3400 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 7c411b3 | 2022-04-22 23:37:48 +0200 | [diff] [blame] | 3401 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3402 | if (!AreRequiredExtensionsEnabled()) { |
| 3403 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 7c411b3 | 2022-04-22 23:37:48 +0200 | [diff] [blame] | 3404 | } |
| 3405 | |
| 3406 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3407 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3408 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3409 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3410 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 7c411b3 | 2022-04-22 23:37:48 +0200 | [diff] [blame] | 3411 | } |
| 3412 | |
| 3413 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3414 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3415 | |
| 3416 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3417 | image_create_info.flags = VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT; |
| 3418 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3419 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3420 | image_create_info.extent = {32, 32, 4}; |
| 3421 | image_create_info.mipLevels = 1; |
| 3422 | image_create_info.arrayLayers = 1; |
| 3423 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3424 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3425 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT; |
| 3426 | |
| 3427 | VkImageObj image(m_device); |
| 3428 | image.Init(image_create_info); |
| 3429 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3430 | |
| 3431 | auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 3432 | rendering_fragment_density.imageView = image_view; |
| 3433 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3434 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3435 | begin_rendering_info.layerCount = 1; |
| 3436 | |
| 3437 | m_commandBuffer->begin(); |
| 3438 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06159"); |
| 3439 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3440 | m_errorMonitor->VerifyFound(); |
| 3441 | m_commandBuffer->end(); |
| 3442 | } |
ziga-lunarg | 66569a7 | 2022-04-22 23:43:26 +0200 | [diff] [blame] | 3443 | |
| 3444 | TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayerCount) { |
| 3445 | TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid layer count"); |
| 3446 | |
| 3447 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3448 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3449 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3450 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3451 | |
| 3452 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3453 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 66569a7 | 2022-04-22 23:43:26 +0200 | [diff] [blame] | 3454 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3455 | if (!AreRequiredExtensionsEnabled()) { |
| 3456 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 66569a7 | 2022-04-22 23:43:26 +0200 | [diff] [blame] | 3457 | } |
| 3458 | |
| 3459 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3460 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features); |
| 3461 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3462 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3463 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3464 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 66569a7 | 2022-04-22 23:43:26 +0200 | [diff] [blame] | 3465 | } |
| 3466 | if (!multiview_features.multiview) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3467 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | 66569a7 | 2022-04-22 23:43:26 +0200 | [diff] [blame] | 3468 | } |
| 3469 | |
| 3470 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3471 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3472 | |
| 3473 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3474 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3475 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3476 | image_create_info.extent = {32, 32, 4}; |
| 3477 | image_create_info.mipLevels = 1; |
| 3478 | image_create_info.arrayLayers = 2; |
| 3479 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3480 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3481 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT; |
| 3482 | |
| 3483 | VkImageObj image(m_device); |
| 3484 | image.Init(image_create_info); |
| 3485 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3486 | |
| 3487 | auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 3488 | rendering_fragment_density.imageView = image_view; |
| 3489 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3490 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3491 | begin_rendering_info.layerCount = 1; |
| 3492 | begin_rendering_info.viewMask = 0x1; |
| 3493 | |
| 3494 | m_commandBuffer->begin(); |
| 3495 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160"); |
| 3496 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3497 | m_errorMonitor->VerifyFound(); |
| 3498 | m_commandBuffer->end(); |
| 3499 | } |
ziga-lunarg | 323c11d | 2022-04-22 23:56:32 +0200 | [diff] [blame] | 3500 | |
| 3501 | TEST_F(VkLayerTest, InvalidRenderingPNextImageView) { |
| 3502 | TEST_DESCRIPTION( |
| 3503 | "Use different image views in VkRenderingFragmentShadingRateAttachmentInfoKHR and " |
| 3504 | "VkRenderingFragmentDensityMapAttachmentInfoEXT"); |
| 3505 | |
| 3506 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3507 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3508 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3509 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 3510 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3511 | |
| 3512 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3513 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 323c11d | 2022-04-22 23:56:32 +0200 | [diff] [blame] | 3514 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3515 | if (!AreRequiredExtensionsEnabled()) { |
| 3516 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 323c11d | 2022-04-22 23:56:32 +0200 | [diff] [blame] | 3517 | } |
| 3518 | |
| 3519 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3520 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features); |
| 3521 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3522 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3523 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3524 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 323c11d | 2022-04-22 23:56:32 +0200 | [diff] [blame] | 3525 | } |
| 3526 | if (!multiview_features.multiview) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3527 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | 323c11d | 2022-04-22 23:56:32 +0200 | [diff] [blame] | 3528 | } |
| 3529 | |
| 3530 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3531 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3532 | |
| 3533 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 3534 | |
| 3535 | auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 3536 | vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2); |
| 3537 | |
| 3538 | VkImageObj image1(m_device); |
| 3539 | image1.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, |
| 3540 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, |
| 3541 | VK_IMAGE_TILING_LINEAR, 0); |
| 3542 | VkImageView image_view1 = image1.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3543 | VkImageObj image2(m_device); |
| 3544 | image2.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, |
| 3545 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0); |
| 3546 | VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3547 | |
| 3548 | auto rendering_fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
| 3549 | rendering_fragment_shading_rate.imageView = image_view1; |
| 3550 | rendering_fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3551 | rendering_fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 3552 | auto rendering_fragment_density = |
| 3553 | LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(&rendering_fragment_shading_rate); |
| 3554 | rendering_fragment_density.imageView = image_view2; |
| 3555 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3556 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3557 | begin_rendering_info.layerCount = 1; |
| 3558 | begin_rendering_info.viewMask = 0x1; |
| 3559 | |
| 3560 | m_commandBuffer->begin(); |
| 3561 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06126"); |
| 3562 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3563 | m_errorMonitor->VerifyFound(); |
| 3564 | m_commandBuffer->end(); |
| 3565 | } |
ziga-lunarg | 95f20d4 | 2022-04-23 00:06:42 +0200 | [diff] [blame] | 3566 | |
| 3567 | TEST_F(VkLayerTest, InvalidRenderingRenderArea) { |
| 3568 | TEST_DESCRIPTION("Use negative offset in RenderingInfo render area"); |
| 3569 | |
| 3570 | SetTargetApiVersion(VK_API_VERSION_1_0); |
| 3571 | AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 3572 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3573 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3574 | |
| 3575 | if (DeviceValidationVersion() != VK_API_VERSION_1_0) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3576 | GTEST_SKIP() << "Tests for 1.0 only"; |
ziga-lunarg | 95f20d4 | 2022-04-23 00:06:42 +0200 | [diff] [blame] | 3577 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3578 | if (!AreRequiredExtensionsEnabled()) { |
| 3579 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 95f20d4 | 2022-04-23 00:06:42 +0200 | [diff] [blame] | 3580 | } |
| 3581 | |
| 3582 | auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>( |
| 3583 | vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR")); |
| 3584 | ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr); |
| 3585 | |
| 3586 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3587 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features); |
| 3588 | vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2); |
| 3589 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3590 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 95f20d4 | 2022-04-23 00:06:42 +0200 | [diff] [blame] | 3591 | } |
| 3592 | |
| 3593 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3594 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3595 | |
| 3596 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 3597 | begin_rendering_info.layerCount = 1; |
| 3598 | begin_rendering_info.renderArea.offset.x = -1; |
ziga-lunarg | 9b6a95f | 2022-04-23 00:13:38 +0200 | [diff] [blame] | 3599 | begin_rendering_info.renderArea.extent.width = 32; |
| 3600 | begin_rendering_info.renderArea.extent.height = 32; |
ziga-lunarg | 95f20d4 | 2022-04-23 00:06:42 +0200 | [diff] [blame] | 3601 | |
| 3602 | m_commandBuffer->begin(); |
| 3603 | |
| 3604 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06071"); |
| 3605 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3606 | m_errorMonitor->VerifyFound(); |
| 3607 | |
| 3608 | begin_rendering_info.renderArea.offset.x = 0; |
| 3609 | begin_rendering_info.renderArea.offset.y = -1; |
| 3610 | |
| 3611 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06072"); |
| 3612 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3613 | m_errorMonitor->VerifyFound(); |
| 3614 | |
ziga-lunarg | 9b6a95f | 2022-04-23 00:13:38 +0200 | [diff] [blame] | 3615 | begin_rendering_info.renderArea.offset.y = 0; |
| 3616 | begin_rendering_info.renderArea.offset.x = m_device->phy().properties().limits.maxFramebufferWidth - 16; |
| 3617 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06073"); |
| 3618 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3619 | m_errorMonitor->VerifyFound(); |
| 3620 | |
| 3621 | begin_rendering_info.renderArea.offset.x = 0; |
| 3622 | begin_rendering_info.renderArea.offset.y = m_device->phy().properties().limits.maxFramebufferHeight - 16; |
| 3623 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06074"); |
| 3624 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3625 | m_errorMonitor->VerifyFound(); |
| 3626 | |
ziga-lunarg | 95f20d4 | 2022-04-23 00:06:42 +0200 | [diff] [blame] | 3627 | m_commandBuffer->end(); |
| 3628 | } |
ziga-lunarg | 6662a88 | 2022-04-23 00:21:27 +0200 | [diff] [blame] | 3629 | |
| 3630 | TEST_F(VkLayerTest, InvalidRenderingInfoViewMask) { |
| 3631 | TEST_DESCRIPTION("Use negative offset in RenderingInfo render area"); |
| 3632 | |
| 3633 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3634 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3635 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3636 | |
| 3637 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3638 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 6662a88 | 2022-04-23 00:21:27 +0200 | [diff] [blame] | 3639 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3640 | if (!AreRequiredExtensionsEnabled()) { |
| 3641 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 6662a88 | 2022-04-23 00:21:27 +0200 | [diff] [blame] | 3642 | } |
| 3643 | |
| 3644 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3645 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features); |
| 3646 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3647 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3648 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3649 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 6662a88 | 2022-04-23 00:21:27 +0200 | [diff] [blame] | 3650 | } |
| 3651 | if (multiview_features.multiview == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3652 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | 6662a88 | 2022-04-23 00:21:27 +0200 | [diff] [blame] | 3653 | } |
| 3654 | |
| 3655 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3656 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3657 | |
| 3658 | VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>(); |
| 3659 | VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props); |
| 3660 | vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2); |
| 3661 | |
| 3662 | if (multiview_props.maxMultiviewViewCount == 32) { |
| 3663 | printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix); |
| 3664 | return; |
| 3665 | } |
| 3666 | |
| 3667 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 3668 | begin_rendering_info.layerCount = 1; |
| 3669 | begin_rendering_info.renderArea.extent.width = 32; |
| 3670 | begin_rendering_info.renderArea.extent.height = 32; |
| 3671 | begin_rendering_info.viewMask = 1u << multiview_props.maxMultiviewViewCount; |
| 3672 | |
| 3673 | m_commandBuffer->begin(); |
| 3674 | |
| 3675 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06128"); |
| 3676 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3677 | m_errorMonitor->VerifyFound(); |
| 3678 | |
| 3679 | m_commandBuffer->end(); |
| 3680 | } |
ziga-lunarg | ae75b8a | 2022-04-23 10:54:37 +0200 | [diff] [blame] | 3681 | |
| 3682 | TEST_F(VkLayerTest, InvalidRenderingColorAttachmentFormat) { |
| 3683 | TEST_DESCRIPTION("Use format with missing potential format features in rendering color attachment"); |
| 3684 | |
| 3685 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3686 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3687 | AddRequiredExtensions(VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME); |
| 3688 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3689 | |
| 3690 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3691 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | ae75b8a | 2022-04-23 10:54:37 +0200 | [diff] [blame] | 3692 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3693 | if (!AreRequiredExtensionsEnabled()) { |
| 3694 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | ae75b8a | 2022-04-23 10:54:37 +0200 | [diff] [blame] | 3695 | } |
| 3696 | |
| 3697 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 3698 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3699 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3700 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3701 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | ae75b8a | 2022-04-23 10:54:37 +0200 | [diff] [blame] | 3702 | } |
| 3703 | |
| 3704 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3705 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3706 | |
| 3707 | VkFormat format = FindSupportedDepthStencilFormat(gpu()); |
| 3708 | if (format == VK_FORMAT_UNDEFINED) { |
| 3709 | printf("%s No Depth + Stencil format found. Skipped.\n", kSkipPrefix); |
| 3710 | return; |
| 3711 | } |
| 3712 | |
| 3713 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3714 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3715 | pipeline_rendering_info.pColorAttachmentFormats = &format; |
| 3716 | |
| 3717 | CreatePipelineHelper pipe(*this); |
| 3718 | pipe.InitInfo(); |
| 3719 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 3720 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3721 | pipe.InitState(); |
| 3722 | |
| 3723 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06582"); |
| 3724 | pipe.CreateGraphicsPipeline(); |
| 3725 | m_errorMonitor->VerifyFound(); |
| 3726 | } |
ziga-lunarg | eac390f | 2022-04-23 11:05:28 +0200 | [diff] [blame] | 3727 | |
sjfricke | 483c108 | 2022-06-05 10:21:44 +0900 | [diff] [blame] | 3728 | TEST_F(VkLayerTest, InvalidResolveModeWithNonIntegerColorFormat) { |
| 3729 | TEST_DESCRIPTION("Use invalid resolve mode with non integer color format"); |
| 3730 | |
| 3731 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3732 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3733 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3734 | |
| 3735 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3736 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
| 3737 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3738 | if (!AreRequiredExtensionsEnabled()) { |
| 3739 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
sjfricke | 483c108 | 2022-06-05 10:21:44 +0900 | [diff] [blame] | 3740 | } |
| 3741 | |
| 3742 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 3743 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3744 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3745 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3746 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
| 3747 | } |
| 3748 | |
| 3749 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3750 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3751 | |
| 3752 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3753 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3754 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; // not int color |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 3755 | image_create_info.extent = {32, 32, 1}; |
sjfricke | 483c108 | 2022-06-05 10:21:44 +0900 | [diff] [blame] | 3756 | image_create_info.mipLevels = 1; |
| 3757 | image_create_info.arrayLayers = 1; |
| 3758 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
| 3759 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3760 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 3761 | VkImageObj image(m_device); |
| 3762 | image.Init(image_create_info); |
| 3763 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3764 | |
| 3765 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 3766 | color_attachment.imageView = image_view; |
| 3767 | color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; // not allowed for format |
| 3768 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 3769 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3770 | |
| 3771 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 3772 | begin_rendering_info.colorAttachmentCount = 1; |
| 3773 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 3774 | begin_rendering_info.layerCount = 1; |
| 3775 | |
| 3776 | m_commandBuffer->begin(); |
| 3777 | |
| 3778 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06129"); |
| 3779 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3780 | m_errorMonitor->VerifyFound(); |
| 3781 | |
| 3782 | m_commandBuffer->end(); |
| 3783 | } |
| 3784 | |
ziga-lunarg | eac390f | 2022-04-23 11:05:28 +0200 | [diff] [blame] | 3785 | TEST_F(VkLayerTest, InvalidResolveModeWithIntegerColorFormat) { |
| 3786 | TEST_DESCRIPTION("Use invalid resolve mode with integer color format"); |
| 3787 | |
| 3788 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3789 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3790 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3791 | |
| 3792 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3793 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | eac390f | 2022-04-23 11:05:28 +0200 | [diff] [blame] | 3794 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3795 | if (!AreRequiredExtensionsEnabled()) { |
| 3796 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | eac390f | 2022-04-23 11:05:28 +0200 | [diff] [blame] | 3797 | } |
| 3798 | |
| 3799 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 3800 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3801 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3802 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3803 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | eac390f | 2022-04-23 11:05:28 +0200 | [diff] [blame] | 3804 | } |
| 3805 | |
| 3806 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3807 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3808 | |
| 3809 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3810 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3811 | image_create_info.format = VK_FORMAT_R8G8B8A8_UINT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 3812 | image_create_info.extent = {32, 32, 1}; |
ziga-lunarg | eac390f | 2022-04-23 11:05:28 +0200 | [diff] [blame] | 3813 | image_create_info.mipLevels = 1; |
| 3814 | image_create_info.arrayLayers = 1; |
| 3815 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 3816 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3817 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 3818 | VkImageObj image(m_device); |
| 3819 | image.Init(image_create_info); |
| 3820 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 3821 | |
| 3822 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 3823 | color_attachment.imageView = image_view; |
| 3824 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 3825 | color_attachment.resolveMode = VK_RESOLVE_MODE_MAX_BIT; |
| 3826 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3827 | |
| 3828 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 3829 | begin_rendering_info.colorAttachmentCount = 1; |
| 3830 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 3831 | begin_rendering_info.layerCount = 1; |
| 3832 | |
| 3833 | m_commandBuffer->begin(); |
| 3834 | |
| 3835 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06130"); |
| 3836 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3837 | m_errorMonitor->VerifyFound(); |
| 3838 | |
| 3839 | m_commandBuffer->end(); |
| 3840 | } |
ziga-lunarg | df2a320 | 2022-04-23 11:07:46 +0200 | [diff] [blame] | 3841 | |
| 3842 | TEST_F(VkLayerTest, InvalidResolveModeSamples) { |
| 3843 | TEST_DESCRIPTION("Use invalid sample count with resolve mode that is not none"); |
| 3844 | |
| 3845 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3846 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3847 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3848 | |
| 3849 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3850 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | df2a320 | 2022-04-23 11:07:46 +0200 | [diff] [blame] | 3851 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3852 | if (!AreRequiredExtensionsEnabled()) { |
| 3853 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | df2a320 | 2022-04-23 11:07:46 +0200 | [diff] [blame] | 3854 | } |
| 3855 | |
| 3856 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 3857 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3858 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3859 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3860 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | df2a320 | 2022-04-23 11:07:46 +0200 | [diff] [blame] | 3861 | } |
| 3862 | |
| 3863 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3864 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3865 | |
| 3866 | VkImageObj image(m_device); |
| 3867 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 3868 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3869 | |
| 3870 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 3871 | color_attachment.imageView = image_view; |
| 3872 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 3873 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 3874 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3875 | |
| 3876 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 3877 | begin_rendering_info.colorAttachmentCount = 1; |
| 3878 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 3879 | begin_rendering_info.layerCount = 1; |
| 3880 | |
| 3881 | m_commandBuffer->begin(); |
| 3882 | |
| 3883 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06132"); |
| 3884 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3885 | m_errorMonitor->VerifyFound(); |
| 3886 | |
| 3887 | m_commandBuffer->end(); |
| 3888 | } |
ziga-lunarg | b7693aa | 2022-04-23 11:21:57 +0200 | [diff] [blame] | 3889 | |
| 3890 | TEST_F(VkLayerTest, InvalidResolveImageViewSamples) { |
| 3891 | TEST_DESCRIPTION("Use resolve image view with invalid sample count"); |
| 3892 | |
| 3893 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3894 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3895 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3896 | |
| 3897 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3898 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | b7693aa | 2022-04-23 11:21:57 +0200 | [diff] [blame] | 3899 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3900 | if (!AreRequiredExtensionsEnabled()) { |
| 3901 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | b7693aa | 2022-04-23 11:21:57 +0200 | [diff] [blame] | 3902 | } |
| 3903 | |
| 3904 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 3905 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3906 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3907 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3908 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | b7693aa | 2022-04-23 11:21:57 +0200 | [diff] [blame] | 3909 | } |
| 3910 | |
| 3911 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3912 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3913 | |
| 3914 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3915 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3916 | image_create_info.format = VK_FORMAT_R8G8B8A8_UINT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 3917 | image_create_info.extent = {32, 32, 1}; |
ziga-lunarg | b7693aa | 2022-04-23 11:21:57 +0200 | [diff] [blame] | 3918 | image_create_info.mipLevels = 1; |
| 3919 | image_create_info.arrayLayers = 1; |
| 3920 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 3921 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3922 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 3923 | |
| 3924 | VkImageObj image(m_device); |
| 3925 | image.Init(image_create_info); |
| 3926 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 3927 | |
| 3928 | VkImageObj resolve_image(m_device); |
| 3929 | resolve_image.Init(image_create_info); |
| 3930 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 3931 | |
| 3932 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 3933 | color_attachment.imageView = image_view; |
| 3934 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 3935 | color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; |
| 3936 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3937 | color_attachment.resolveImageView = resolve_image_view; |
| 3938 | |
| 3939 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 3940 | begin_rendering_info.colorAttachmentCount = 1; |
| 3941 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 3942 | begin_rendering_info.layerCount = 1; |
| 3943 | |
| 3944 | m_commandBuffer->begin(); |
| 3945 | |
| 3946 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06133"); |
| 3947 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3948 | m_errorMonitor->VerifyFound(); |
| 3949 | |
| 3950 | m_commandBuffer->end(); |
ziga-lunarg | d12cbce | 2022-04-23 11:35:20 +0200 | [diff] [blame] | 3951 | } |
| 3952 | |
| 3953 | TEST_F(VkLayerTest, InvalidResolveImageViewFormatMatch) { |
| 3954 | TEST_DESCRIPTION("Use resolve image view with different format from image view"); |
| 3955 | |
| 3956 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3957 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3958 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3959 | |
| 3960 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3961 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | d12cbce | 2022-04-23 11:35:20 +0200 | [diff] [blame] | 3962 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 3963 | if (!AreRequiredExtensionsEnabled()) { |
| 3964 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | d12cbce | 2022-04-23 11:35:20 +0200 | [diff] [blame] | 3965 | } |
| 3966 | |
| 3967 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 3968 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3969 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3970 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 3971 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | d12cbce | 2022-04-23 11:35:20 +0200 | [diff] [blame] | 3972 | } |
| 3973 | |
| 3974 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3975 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3976 | |
| 3977 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3978 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3979 | image_create_info.format = VK_FORMAT_R8G8B8A8_UINT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 3980 | image_create_info.extent = {32, 32, 1}; |
ziga-lunarg | d12cbce | 2022-04-23 11:35:20 +0200 | [diff] [blame] | 3981 | image_create_info.mipLevels = 1; |
| 3982 | image_create_info.arrayLayers = 1; |
| 3983 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 3984 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3985 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 3986 | |
| 3987 | VkImageObj image(m_device); |
| 3988 | image.Init(image_create_info); |
| 3989 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 3990 | |
| 3991 | VkImageObj resolve_image(m_device); |
| 3992 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 3993 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3994 | |
| 3995 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 3996 | color_attachment.imageView = image_view; |
| 3997 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 3998 | color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; |
| 3999 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 4000 | color_attachment.resolveImageView = resolve_image_view; |
| 4001 | |
| 4002 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4003 | begin_rendering_info.colorAttachmentCount = 1; |
| 4004 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4005 | begin_rendering_info.layerCount = 1; |
| 4006 | |
| 4007 | m_commandBuffer->begin(); |
| 4008 | |
| 4009 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06134"); |
| 4010 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4011 | m_errorMonitor->VerifyFound(); |
| 4012 | |
| 4013 | m_commandBuffer->end(); |
| 4014 | } |
ziga-lunarg | e579a3b | 2022-04-23 11:38:02 +0200 | [diff] [blame] | 4015 | |
| 4016 | TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewLayout) { |
| 4017 | TEST_DESCRIPTION("Use rendering attachment image view with invalid layout"); |
| 4018 | |
| 4019 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4020 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4021 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4022 | |
| 4023 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4024 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | e579a3b | 2022-04-23 11:38:02 +0200 | [diff] [blame] | 4025 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4026 | if (!AreRequiredExtensionsEnabled()) { |
| 4027 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | e579a3b | 2022-04-23 11:38:02 +0200 | [diff] [blame] | 4028 | } |
| 4029 | |
| 4030 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4031 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4032 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4033 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4034 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | e579a3b | 2022-04-23 11:38:02 +0200 | [diff] [blame] | 4035 | } |
| 4036 | |
| 4037 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4038 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4039 | |
| 4040 | VkImageObj image(m_device); |
| 4041 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4042 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4043 | |
| 4044 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4045 | color_attachment.imageView = image_view; |
| 4046 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 4047 | |
| 4048 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4049 | begin_rendering_info.colorAttachmentCount = 1; |
| 4050 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4051 | begin_rendering_info.layerCount = 1; |
| 4052 | |
| 4053 | m_commandBuffer->begin(); |
| 4054 | |
| 4055 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06135"); |
| 4056 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4057 | m_errorMonitor->VerifyFound(); |
| 4058 | |
| 4059 | m_commandBuffer->end(); |
| 4060 | } |
ziga-lunarg | 409f821 | 2022-04-23 11:40:53 +0200 | [diff] [blame] | 4061 | |
| 4062 | TEST_F(VkLayerTest, InvalidResolveImageViewLayout) { |
| 4063 | TEST_DESCRIPTION("Use resolve image view with invalid layout"); |
| 4064 | |
| 4065 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4066 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4067 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4068 | |
| 4069 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4070 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 409f821 | 2022-04-23 11:40:53 +0200 | [diff] [blame] | 4071 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4072 | if (!AreRequiredExtensionsEnabled()) { |
| 4073 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 409f821 | 2022-04-23 11:40:53 +0200 | [diff] [blame] | 4074 | } |
| 4075 | |
| 4076 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4077 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4078 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4079 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4080 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 409f821 | 2022-04-23 11:40:53 +0200 | [diff] [blame] | 4081 | } |
| 4082 | |
| 4083 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4084 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4085 | |
| 4086 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4087 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4088 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4089 | image_create_info.extent = {32, 32, 1}; |
ziga-lunarg | 409f821 | 2022-04-23 11:40:53 +0200 | [diff] [blame] | 4090 | image_create_info.mipLevels = 1; |
| 4091 | image_create_info.arrayLayers = 1; |
| 4092 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4093 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4094 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4095 | |
| 4096 | VkImageObj image(m_device); |
| 4097 | image.Init(image_create_info); |
| 4098 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4099 | |
| 4100 | VkImageObj resolve_image(m_device); |
| 4101 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4102 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4103 | |
| 4104 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4105 | color_attachment.imageView = image_view; |
| 4106 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4107 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4108 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 4109 | color_attachment.resolveImageView = resolve_image_view; |
| 4110 | |
| 4111 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4112 | begin_rendering_info.colorAttachmentCount = 1; |
| 4113 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4114 | begin_rendering_info.layerCount = 1; |
| 4115 | |
| 4116 | m_commandBuffer->begin(); |
| 4117 | |
| 4118 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06136"); |
| 4119 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4120 | m_errorMonitor->VerifyFound(); |
| 4121 | |
| 4122 | m_commandBuffer->end(); |
| 4123 | } |
ziga-lunarg | bbbef24 | 2022-04-23 12:12:10 +0200 | [diff] [blame] | 4124 | |
| 4125 | TEST_F(VkLayerTest, InvalidResolveImageViewLayoutSeparateDepthStencil) { |
| 4126 | TEST_DESCRIPTION("Use resolve image view with invalid layout"); |
| 4127 | |
| 4128 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4129 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4130 | AddRequiredExtensions(VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME); |
| 4131 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4132 | |
| 4133 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4134 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | bbbef24 | 2022-04-23 12:12:10 +0200 | [diff] [blame] | 4135 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4136 | if (!AreRequiredExtensionsEnabled()) { |
| 4137 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | bbbef24 | 2022-04-23 12:12:10 +0200 | [diff] [blame] | 4138 | } |
| 4139 | |
| 4140 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4141 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4142 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4143 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4144 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | bbbef24 | 2022-04-23 12:12:10 +0200 | [diff] [blame] | 4145 | } |
| 4146 | |
| 4147 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4148 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4149 | |
| 4150 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4151 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4152 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4153 | image_create_info.extent = {32, 32, 1}; |
ziga-lunarg | bbbef24 | 2022-04-23 12:12:10 +0200 | [diff] [blame] | 4154 | image_create_info.mipLevels = 1; |
| 4155 | image_create_info.arrayLayers = 1; |
| 4156 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4157 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4158 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4159 | |
| 4160 | VkImageObj image(m_device); |
| 4161 | image.Init(image_create_info); |
| 4162 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4163 | |
| 4164 | VkImageObj resolve_image(m_device); |
| 4165 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4166 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4167 | |
| 4168 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4169 | color_attachment.imageView = image_view; |
| 4170 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4171 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4172 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL; |
| 4173 | color_attachment.resolveImageView = resolve_image_view; |
| 4174 | |
| 4175 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4176 | begin_rendering_info.colorAttachmentCount = 1; |
| 4177 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4178 | begin_rendering_info.layerCount = 1; |
| 4179 | |
| 4180 | m_commandBuffer->begin(); |
| 4181 | |
| 4182 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06137"); |
| 4183 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4184 | m_errorMonitor->VerifyFound(); |
| 4185 | |
| 4186 | m_commandBuffer->end(); |
| 4187 | } |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4188 | |
| 4189 | TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewShadingRateLayout) { |
| 4190 | TEST_DESCRIPTION("Use image view with invalid layout"); |
| 4191 | |
| 4192 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4193 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
sjfricke | 6e8fb40 | 2022-06-05 09:47:58 +0900 | [diff] [blame] | 4194 | AddOptionalExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME); |
| 4195 | AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4196 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4197 | |
| 4198 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4199 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4200 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4201 | if (!AreRequiredExtensionsEnabled()) { |
| 4202 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4203 | } |
| 4204 | |
sjfricke | 6e8fb40 | 2022-06-05 09:47:58 +0900 | [diff] [blame] | 4205 | const bool nv_shading_rate = IsExtensionsEnabled(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME); |
| 4206 | const bool khr_fragment_shading = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 4207 | if (!khr_fragment_shading && !nv_shading_rate) { |
| 4208 | GTEST_SKIP() << "shading rate / fragment shading not supported"; |
| 4209 | } |
| 4210 | |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4211 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4212 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4213 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4214 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4215 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4216 | } |
| 4217 | |
| 4218 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4219 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4220 | |
| 4221 | VkImageObj image(m_device); |
| 4222 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4223 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4224 | |
| 4225 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4226 | color_attachment.imageView = image_view; |
| 4227 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV; |
| 4228 | |
| 4229 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4230 | begin_rendering_info.colorAttachmentCount = 1; |
| 4231 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4232 | begin_rendering_info.layerCount = 1; |
| 4233 | |
| 4234 | m_commandBuffer->begin(); |
| 4235 | |
sjfricke | 6e8fb40 | 2022-06-05 09:47:58 +0900 | [diff] [blame] | 4236 | // SHADING_RATE_OPTIMAL_NV is aliased FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR so VU depends on which extensions |
| 4237 | const char *vuid = |
| 4238 | khr_fragment_shading ? "VUID-VkRenderingAttachmentInfo-imageView-06143" : "VUID-VkRenderingAttachmentInfo-imageView-06138"; |
| 4239 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4240 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4241 | m_errorMonitor->VerifyFound(); |
| 4242 | |
| 4243 | m_commandBuffer->end(); |
| 4244 | } |
| 4245 | |
| 4246 | TEST_F(VkLayerTest, InvalidResolveImageViewShadingRateLayout) { |
| 4247 | TEST_DESCRIPTION("Use resolve image view with invalid shading ratelayout"); |
| 4248 | |
| 4249 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4250 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
sjfricke | 6e8fb40 | 2022-06-05 09:47:58 +0900 | [diff] [blame] | 4251 | AddOptionalExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME); |
| 4252 | AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4253 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4254 | |
| 4255 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4256 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4257 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4258 | if (!AreRequiredExtensionsEnabled()) { |
| 4259 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4260 | } |
| 4261 | |
sjfricke | 6e8fb40 | 2022-06-05 09:47:58 +0900 | [diff] [blame] | 4262 | const bool nv_shading_rate = IsExtensionsEnabled(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME); |
| 4263 | const bool khr_fragment_shading = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 4264 | if (!khr_fragment_shading && !nv_shading_rate) { |
| 4265 | GTEST_SKIP() << "shading rate / fragment shading not supported"; |
| 4266 | } |
| 4267 | |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4268 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4269 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4270 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4271 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4272 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4273 | } |
| 4274 | |
| 4275 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4276 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4277 | |
| 4278 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4279 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4280 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4281 | image_create_info.extent = {32, 32, 1}; |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4282 | image_create_info.mipLevels = 1; |
| 4283 | image_create_info.arrayLayers = 1; |
| 4284 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4285 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4286 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4287 | |
| 4288 | VkImageObj image(m_device); |
| 4289 | image.Init(image_create_info); |
| 4290 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4291 | |
| 4292 | VkImageObj resolve_image(m_device); |
| 4293 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4294 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4295 | |
| 4296 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4297 | color_attachment.imageView = image_view; |
| 4298 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4299 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4300 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV; |
| 4301 | color_attachment.resolveImageView = resolve_image_view; |
| 4302 | |
| 4303 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4304 | begin_rendering_info.colorAttachmentCount = 1; |
| 4305 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4306 | begin_rendering_info.layerCount = 1; |
| 4307 | |
| 4308 | m_commandBuffer->begin(); |
| 4309 | |
sjfricke | 6e8fb40 | 2022-06-05 09:47:58 +0900 | [diff] [blame] | 4310 | // SHADING_RATE_OPTIMAL_NV is aliased FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR so VU depends on which extensions |
| 4311 | const char *vuid = |
| 4312 | khr_fragment_shading ? "VUID-VkRenderingAttachmentInfo-imageView-06144" : "VUID-VkRenderingAttachmentInfo-imageView-06139"; |
| 4313 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4314 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4315 | m_errorMonitor->VerifyFound(); |
| 4316 | |
| 4317 | m_commandBuffer->end(); |
| 4318 | } |
ziga-lunarg | e750395 | 2022-04-23 12:19:14 +0200 | [diff] [blame] | 4319 | |
| 4320 | TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewFragmentDensityLayout) { |
| 4321 | TEST_DESCRIPTION("Use image view with invalid layout"); |
| 4322 | |
| 4323 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4324 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4325 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 4326 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4327 | |
| 4328 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4329 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | e750395 | 2022-04-23 12:19:14 +0200 | [diff] [blame] | 4330 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4331 | if (!AreRequiredExtensionsEnabled()) { |
| 4332 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | e750395 | 2022-04-23 12:19:14 +0200 | [diff] [blame] | 4333 | } |
| 4334 | |
| 4335 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4336 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4337 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4338 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4339 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | e750395 | 2022-04-23 12:19:14 +0200 | [diff] [blame] | 4340 | } |
| 4341 | |
| 4342 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4343 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4344 | |
| 4345 | VkImageObj image(m_device); |
| 4346 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4347 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4348 | |
| 4349 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4350 | color_attachment.imageView = image_view; |
| 4351 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT; |
| 4352 | |
| 4353 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4354 | begin_rendering_info.colorAttachmentCount = 1; |
| 4355 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4356 | begin_rendering_info.layerCount = 1; |
| 4357 | |
| 4358 | m_commandBuffer->begin(); |
| 4359 | |
| 4360 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06140"); |
| 4361 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4362 | m_errorMonitor->VerifyFound(); |
| 4363 | |
| 4364 | m_commandBuffer->end(); |
ziga-lunarg | 10cd0fb | 2022-04-23 12:20:46 +0200 | [diff] [blame] | 4365 | } |
| 4366 | |
| 4367 | TEST_F(VkLayerTest, InvalidResolveImageViewFragmentDensityLayout) { |
| 4368 | TEST_DESCRIPTION("Use resolve image view with invalid fragment density layout"); |
| 4369 | |
| 4370 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4371 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4372 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 4373 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4374 | |
| 4375 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4376 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 10cd0fb | 2022-04-23 12:20:46 +0200 | [diff] [blame] | 4377 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4378 | if (!AreRequiredExtensionsEnabled()) { |
| 4379 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 10cd0fb | 2022-04-23 12:20:46 +0200 | [diff] [blame] | 4380 | } |
| 4381 | |
| 4382 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4383 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4384 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4385 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4386 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 10cd0fb | 2022-04-23 12:20:46 +0200 | [diff] [blame] | 4387 | } |
| 4388 | |
| 4389 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4390 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4391 | |
| 4392 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4393 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4394 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4395 | image_create_info.extent = {32, 32, 4}; |
| 4396 | image_create_info.mipLevels = 1; |
| 4397 | image_create_info.arrayLayers = 1; |
| 4398 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4399 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4400 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4401 | |
| 4402 | VkImageObj image(m_device); |
| 4403 | image.Init(image_create_info); |
| 4404 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4405 | |
| 4406 | VkImageObj resolve_image(m_device); |
| 4407 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4408 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4409 | |
| 4410 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4411 | color_attachment.imageView = image_view; |
| 4412 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4413 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4414 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT; |
| 4415 | color_attachment.resolveImageView = resolve_image_view; |
| 4416 | |
| 4417 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4418 | begin_rendering_info.colorAttachmentCount = 1; |
| 4419 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4420 | begin_rendering_info.layerCount = 1; |
| 4421 | |
| 4422 | m_commandBuffer->begin(); |
| 4423 | |
| 4424 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06141"); |
| 4425 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4426 | m_errorMonitor->VerifyFound(); |
| 4427 | |
| 4428 | m_commandBuffer->end(); |
| 4429 | } |
ziga-lunarg | dfa31d1 | 2022-04-23 12:22:18 +0200 | [diff] [blame] | 4430 | |
| 4431 | TEST_F(VkLayerTest, InvalidResolveImageViewReadOnlyOptimalLayout) { |
| 4432 | TEST_DESCRIPTION("Use resolve image view with invalid read only optimal layout"); |
| 4433 | |
| 4434 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4435 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4436 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4437 | |
| 4438 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4439 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | dfa31d1 | 2022-04-23 12:22:18 +0200 | [diff] [blame] | 4440 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4441 | if (!AreRequiredExtensionsEnabled()) { |
| 4442 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | dfa31d1 | 2022-04-23 12:22:18 +0200 | [diff] [blame] | 4443 | } |
| 4444 | |
| 4445 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4446 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4447 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4448 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4449 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | dfa31d1 | 2022-04-23 12:22:18 +0200 | [diff] [blame] | 4450 | } |
| 4451 | |
| 4452 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4453 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4454 | |
| 4455 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4456 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4457 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4458 | image_create_info.extent = {32, 32, 1}; |
ziga-lunarg | dfa31d1 | 2022-04-23 12:22:18 +0200 | [diff] [blame] | 4459 | image_create_info.mipLevels = 1; |
| 4460 | image_create_info.arrayLayers = 1; |
| 4461 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4462 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4463 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4464 | |
| 4465 | VkImageObj image(m_device); |
| 4466 | image.Init(image_create_info); |
| 4467 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4468 | |
| 4469 | VkImageObj resolve_image(m_device); |
| 4470 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4471 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4472 | |
| 4473 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4474 | color_attachment.imageView = image_view; |
| 4475 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4476 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4477 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL; |
| 4478 | color_attachment.resolveImageView = resolve_image_view; |
| 4479 | |
| 4480 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4481 | begin_rendering_info.colorAttachmentCount = 1; |
| 4482 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4483 | begin_rendering_info.layerCount = 1; |
| 4484 | |
| 4485 | m_commandBuffer->begin(); |
| 4486 | |
| 4487 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06142"); |
| 4488 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4489 | m_errorMonitor->VerifyFound(); |
| 4490 | |
| 4491 | m_commandBuffer->end(); |
| 4492 | } |
ziga-lunarg | 735aa32 | 2022-04-24 14:17:47 +0200 | [diff] [blame] | 4493 | |
| 4494 | TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateImageView) { |
| 4495 | TEST_DESCRIPTION("Test BeginRenderingInfo image view with FragmentShadingRateAttachment."); |
| 4496 | |
| 4497 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4498 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4499 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 4500 | |
| 4501 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4502 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4503 | if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) { |
| 4504 | GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation."; |
| 4505 | } |
| 4506 | |
ziga-lunarg | 735aa32 | 2022-04-24 14:17:47 +0200 | [diff] [blame] | 4507 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4508 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 735aa32 | 2022-04-24 14:17:47 +0200 | [diff] [blame] | 4509 | } |
| 4510 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4511 | if (!AreRequiredExtensionsEnabled()) { |
| 4512 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 735aa32 | 2022-04-24 14:17:47 +0200 | [diff] [blame] | 4513 | } |
| 4514 | |
| 4515 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 4516 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4517 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4518 | |
| 4519 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4520 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 735aa32 | 2022-04-24 14:17:47 +0200 | [diff] [blame] | 4521 | } |
| 4522 | |
| 4523 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 4524 | |
| 4525 | auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 4526 | vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2); |
| 4527 | |
| 4528 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4529 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4530 | |
| 4531 | VkImageObj image(m_device); |
| 4532 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, |
| 4533 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, |
| 4534 | VK_IMAGE_TILING_LINEAR, 0); |
| 4535 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4536 | |
| 4537 | auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
| 4538 | fragment_shading_rate.imageView = image_view; |
| 4539 | fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4540 | fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 4541 | |
| 4542 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate); |
| 4543 | begin_rendering_info.layerCount = 1; |
| 4544 | |
| 4545 | m_commandBuffer->begin(); |
| 4546 | |
| 4547 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06147"); |
| 4548 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4549 | m_errorMonitor->VerifyFound(); |
| 4550 | |
| 4551 | m_commandBuffer->end(); |
| 4552 | } |
ziga-lunarg | 644c055 | 2022-04-24 17:50:58 +0200 | [diff] [blame] | 4553 | |
| 4554 | TEST_F(VkLayerTest, TestRenderingInfoColorAttachment) { |
| 4555 | TEST_DESCRIPTION("Test RenderingInfo color attachment."); |
| 4556 | |
| 4557 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4558 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4559 | |
| 4560 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4561 | |
| 4562 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4563 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 644c055 | 2022-04-24 17:50:58 +0200 | [diff] [blame] | 4564 | } |
| 4565 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4566 | if (!AreRequiredExtensionsEnabled()) { |
| 4567 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 644c055 | 2022-04-24 17:50:58 +0200 | [diff] [blame] | 4568 | } |
| 4569 | |
| 4570 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 4571 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4572 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4573 | |
| 4574 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4575 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 644c055 | 2022-04-24 17:50:58 +0200 | [diff] [blame] | 4576 | } |
| 4577 | |
| 4578 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4579 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4580 | |
| 4581 | VkImageObj invalid_image(m_device); |
| 4582 | invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 4583 | VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4584 | |
| 4585 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4586 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4587 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4588 | image_create_info.extent = {32, 32, 1}; |
ziga-lunarg | 644c055 | 2022-04-24 17:50:58 +0200 | [diff] [blame] | 4589 | image_create_info.mipLevels = 1; |
| 4590 | image_create_info.arrayLayers = 1; |
| 4591 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4592 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4593 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4594 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 4595 | VkImageObj image(m_device); |
| 4596 | image.Init(image_create_info); |
| 4597 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4598 | |
| 4599 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4600 | color_attachment.imageView = invalid_image_view; |
| 4601 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4602 | |
| 4603 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4604 | begin_rendering_info.layerCount = 1; |
| 4605 | begin_rendering_info.colorAttachmentCount = 1; |
| 4606 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4607 | |
| 4608 | m_commandBuffer->begin(); |
| 4609 | |
| 4610 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06087"); |
| 4611 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4612 | m_errorMonitor->VerifyFound(); |
| 4613 | |
| 4614 | color_attachment.imageView = image_view; |
| 4615 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4616 | |
| 4617 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06090"); |
| 4618 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4619 | m_errorMonitor->VerifyFound(); |
| 4620 | |
| 4621 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL; |
| 4622 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06096"); |
| 4623 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4624 | m_errorMonitor->VerifyFound(); |
| 4625 | |
| 4626 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL; |
| 4627 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06100"); |
| 4628 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4629 | m_errorMonitor->VerifyFound(); |
| 4630 | |
| 4631 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4632 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4633 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4634 | |
| 4635 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06091"); |
| 4636 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4637 | m_errorMonitor->VerifyFound(); |
| 4638 | |
| 4639 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL; |
| 4640 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06097"); |
| 4641 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4642 | m_errorMonitor->VerifyFound(); |
| 4643 | |
| 4644 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 4645 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06101"); |
| 4646 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4647 | m_errorMonitor->VerifyFound(); |
| 4648 | |
| 4649 | color_attachment.resolveMode = VK_RESOLVE_MODE_NONE; |
sjfricke | 483c108 | 2022-06-05 10:21:44 +0900 | [diff] [blame] | 4650 | |
ziga-lunarg | 644c055 | 2022-04-24 17:50:58 +0200 | [diff] [blame] | 4651 | const uint32_t max_color_attachments = m_device->phy().properties().limits.maxColorAttachments + 1; |
| 4652 | std::vector<VkRenderingAttachmentInfoKHR> color_attachments(max_color_attachments); |
| 4653 | for (auto &attachment : color_attachments) { |
| 4654 | attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4655 | attachment.imageView = image_view; |
| 4656 | attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4657 | } |
| 4658 | begin_rendering_info.colorAttachmentCount = max_color_attachments; |
| 4659 | begin_rendering_info.pColorAttachments = color_attachments.data(); |
| 4660 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06106"); |
| 4661 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4662 | m_errorMonitor->VerifyFound(); |
| 4663 | |
| 4664 | m_commandBuffer->end(); |
| 4665 | } |
ziga-lunarg | 7a69bd9 | 2022-04-25 00:33:18 +0200 | [diff] [blame] | 4666 | |
| 4667 | TEST_F(VkLayerTest, TestRenderingInfoDepthAttachment) { |
| 4668 | TEST_DESCRIPTION("Test RenderingInfo depth attachment."); |
| 4669 | |
| 4670 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4671 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4672 | AddRequiredExtensions(VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME); |
| 4673 | |
| 4674 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4675 | |
| 4676 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4677 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 7a69bd9 | 2022-04-25 00:33:18 +0200 | [diff] [blame] | 4678 | } |
| 4679 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4680 | if (!AreRequiredExtensionsEnabled()) { |
| 4681 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 7a69bd9 | 2022-04-25 00:33:18 +0200 | [diff] [blame] | 4682 | } |
| 4683 | |
| 4684 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 4685 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4686 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4687 | |
| 4688 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4689 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 7a69bd9 | 2022-04-25 00:33:18 +0200 | [diff] [blame] | 4690 | } |
| 4691 | |
| 4692 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4693 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4694 | |
| 4695 | VkFormat ds_format = FindSupportedDepthStencilFormat(gpu()); |
| 4696 | if (ds_format == VK_FORMAT_UNDEFINED) { |
| 4697 | printf("%s No Depth + Stencil format found, skipping test..\n", kSkipPrefix); |
| 4698 | return; |
| 4699 | } |
| 4700 | |
| 4701 | auto depth_stencil_resolve_properties = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>(); |
| 4702 | auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_properties); |
| 4703 | vk::GetPhysicalDeviceProperties2(gpu(), &properties2); |
| 4704 | bool has_depth_resolve_mode_average = |
| 4705 | (depth_stencil_resolve_properties.supportedDepthResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0; |
| 4706 | bool has_stencil_resolve_mode_average = |
| 4707 | (depth_stencil_resolve_properties.supportedStencilResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0; |
| 4708 | |
| 4709 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4710 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4711 | image_create_info.format = ds_format; |
| 4712 | image_create_info.extent = {32, 32, 1}; |
| 4713 | image_create_info.mipLevels = 1; |
| 4714 | image_create_info.arrayLayers = 1; |
| 4715 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4716 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4717 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 4718 | VkImageObj image(m_device); |
| 4719 | image.Init(image_create_info); |
| 4720 | |
| 4721 | VkImageObj depth_image(m_device); |
| 4722 | depth_image.Init(image_create_info); |
| 4723 | VkImageView depth_image_view = depth_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 4724 | VkImageObj stencil_image(m_device); |
| 4725 | stencil_image.Init(image_create_info); |
| 4726 | VkImageView stencil_image_view = stencil_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 4727 | |
| 4728 | VkImageObj depth_resolvel_image(m_device); |
| 4729 | depth_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 4730 | VkImageView depth_resolve_image_view = |
| 4731 | depth_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 4732 | |
| 4733 | VkImageObj stencil_resolvel_image(m_device); |
| 4734 | stencil_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 4735 | VkImageView stencil_resolve_image_view = |
| 4736 | stencil_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 4737 | |
| 4738 | VkImageObj invalid_image(m_device); |
| 4739 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4740 | invalid_image.Init(image_create_info); |
| 4741 | VkImageView invalid_image_view = invalid_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 4742 | |
| 4743 | auto depth_attachment = LvlInitStruct<VkRenderingAttachmentInfo>(); |
| 4744 | depth_attachment.imageView = depth_image_view; |
| 4745 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4746 | |
| 4747 | auto stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfo>(); |
| 4748 | stencil_attachment.imageView = stencil_image_view; |
| 4749 | stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4750 | |
| 4751 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4752 | begin_rendering_info.layerCount = 1; |
| 4753 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 4754 | begin_rendering_info.pStencilAttachment = &stencil_attachment; |
| 4755 | |
| 4756 | m_commandBuffer->begin(); |
| 4757 | |
| 4758 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06085"); |
| 4759 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4760 | m_errorMonitor->VerifyFound(); |
| 4761 | |
| 4762 | depth_attachment.imageView = VK_NULL_HANDLE; |
| 4763 | stencil_attachment.imageView = VK_NULL_HANDLE; |
| 4764 | depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4765 | depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4766 | depth_attachment.resolveImageView = depth_resolve_image_view; |
| 4767 | stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4768 | stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4769 | stencil_attachment.resolveImageView = stencil_resolve_image_view; |
| 4770 | |
| 4771 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06086"); |
| 4772 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4773 | m_errorMonitor->VerifyFound(); |
| 4774 | |
| 4775 | depth_attachment.imageView = depth_image_view; |
| 4776 | stencil_attachment.imageView = depth_image_view; |
| 4777 | depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4778 | stencil_attachment.resolveImageView = depth_resolve_image_view; |
| 4779 | |
| 4780 | if (!has_depth_resolve_mode_average) { |
| 4781 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06102"); |
| 4782 | } |
| 4783 | if (!has_stencil_resolve_mode_average) { |
| 4784 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06103"); |
| 4785 | } |
| 4786 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06093"); |
| 4787 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4788 | m_errorMonitor->VerifyFound(); |
| 4789 | |
| 4790 | depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL; |
| 4791 | if (has_depth_resolve_mode_average && has_stencil_resolve_mode_average) { |
| 4792 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06098"); |
| 4793 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4794 | m_errorMonitor->VerifyFound(); |
| 4795 | } |
| 4796 | |
| 4797 | depth_attachment.imageView = invalid_image_view; |
| 4798 | stencil_attachment.imageView = invalid_image_view; |
| 4799 | depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE; |
| 4800 | stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE; |
| 4801 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06088"); |
| 4802 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06089"); |
| 4803 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4804 | m_errorMonitor->VerifyFound(); |
| 4805 | |
| 4806 | depth_attachment.imageView = depth_image_view; |
| 4807 | stencil_attachment.imageView = depth_image_view; |
| 4808 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4809 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06092"); |
| 4810 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4811 | m_errorMonitor->VerifyFound(); |
| 4812 | |
| 4813 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4814 | stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4815 | depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4816 | stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4817 | depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4818 | if (depth_stencil_resolve_properties.independentResolveNone == VK_FALSE && has_depth_resolve_mode_average) { |
| 4819 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06104"); |
| 4820 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4821 | m_errorMonitor->VerifyFound(); |
| 4822 | } |
| 4823 | if (depth_stencil_resolve_properties.independentResolve == VK_FALSE && has_depth_resolve_mode_average) { |
| 4824 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06105"); |
| 4825 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4826 | m_errorMonitor->VerifyFound(); |
| 4827 | } |
| 4828 | |
ziga-lunarg | f35a7d7 | 2022-04-25 01:00:41 +0200 | [diff] [blame] | 4829 | stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4830 | stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4831 | if (has_stencil_resolve_mode_average) { |
| 4832 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06095"); |
| 4833 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4834 | m_errorMonitor->VerifyFound(); |
| 4835 | } |
| 4836 | stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL; |
| 4837 | if (has_stencil_resolve_mode_average) { |
| 4838 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06099"); |
| 4839 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4840 | m_errorMonitor->VerifyFound(); |
| 4841 | } |
| 4842 | |
| 4843 | depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE; |
| 4844 | stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE; |
| 4845 | stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4846 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06094"); |
| 4847 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4848 | m_errorMonitor->VerifyFound(); |
| 4849 | |
ziga-lunarg | 7a69bd9 | 2022-04-25 00:33:18 +0200 | [diff] [blame] | 4850 | m_commandBuffer->end(); |
| 4851 | } |
ziga-lunarg | 002e656 | 2022-04-25 00:54:16 +0200 | [diff] [blame] | 4852 | |
| 4853 | TEST_F(VkLayerTest, InvalidRenderingRenderAreaWithDeviceGroupExt) { |
| 4854 | TEST_DESCRIPTION("Use negative offset in RenderingInfo render area"); |
| 4855 | |
| 4856 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4857 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4858 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4859 | |
| 4860 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4861 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 002e656 | 2022-04-25 00:54:16 +0200 | [diff] [blame] | 4862 | } |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4863 | if (!AreRequiredExtensionsEnabled()) { |
| 4864 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 002e656 | 2022-04-25 00:54:16 +0200 | [diff] [blame] | 4865 | } |
| 4866 | |
| 4867 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 4868 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4869 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4870 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4871 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 002e656 | 2022-04-25 00:54:16 +0200 | [diff] [blame] | 4872 | } |
| 4873 | |
| 4874 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4875 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4876 | |
| 4877 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4878 | begin_rendering_info.layerCount = 1; |
| 4879 | begin_rendering_info.renderArea.offset.x = -1; |
| 4880 | begin_rendering_info.renderArea.extent.width = 32; |
| 4881 | begin_rendering_info.renderArea.extent.height = 32; |
| 4882 | |
| 4883 | m_commandBuffer->begin(); |
| 4884 | |
| 4885 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06077"); |
| 4886 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4887 | m_errorMonitor->VerifyFound(); |
| 4888 | |
| 4889 | begin_rendering_info.renderArea.offset.x = 0; |
| 4890 | begin_rendering_info.renderArea.offset.y = -1; |
| 4891 | |
| 4892 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06078"); |
| 4893 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4894 | m_errorMonitor->VerifyFound(); |
| 4895 | |
| 4896 | m_commandBuffer->end(); |
| 4897 | } |
ziga-lunarg | 6e4f9da | 2022-04-25 01:05:22 +0200 | [diff] [blame] | 4898 | |
| 4899 | TEST_F(VkLayerTest, TestDynamicRenderingPipeline) { |
| 4900 | TEST_DESCRIPTION("Use pipeline created with render pass in dynamic render pass."); |
| 4901 | |
| 4902 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4903 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4904 | |
| 4905 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4906 | |
| 4907 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4908 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 6e4f9da | 2022-04-25 01:05:22 +0200 | [diff] [blame] | 4909 | } |
| 4910 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4911 | if (!AreRequiredExtensionsEnabled()) { |
| 4912 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 6e4f9da | 2022-04-25 01:05:22 +0200 | [diff] [blame] | 4913 | } |
| 4914 | |
| 4915 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 4916 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4917 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4918 | |
| 4919 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4920 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 6e4f9da | 2022-04-25 01:05:22 +0200 | [diff] [blame] | 4921 | } |
| 4922 | |
| 4923 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4924 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4925 | |
| 4926 | CreatePipelineHelper pipe(*this); |
| 4927 | pipe.InitInfo(); |
| 4928 | pipe.InitState(); |
| 4929 | pipe.CreateGraphicsPipeline(); |
| 4930 | |
| 4931 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4932 | begin_rendering_info.layerCount = 1; |
| 4933 | |
| 4934 | m_commandBuffer->begin(); |
| 4935 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4936 | |
| 4937 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 4938 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-renderPass-06198"); |
| 4939 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 4940 | m_errorMonitor->VerifyFound(); |
| 4941 | |
| 4942 | m_commandBuffer->EndRendering(); |
| 4943 | m_commandBuffer->end(); |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 4944 | } |
| 4945 | |
| 4946 | TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSize) { |
| 4947 | TEST_DESCRIPTION("Test FragmentShadingRateAttachment size."); |
| 4948 | |
| 4949 | SetTargetApiVersion(VK_API_VERSION_1_0); |
| 4950 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4951 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4952 | AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 4953 | |
| 4954 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4955 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4956 | if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) { |
| 4957 | GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation."; |
| 4958 | } |
| 4959 | |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 4960 | if (DeviceValidationVersion() != VK_API_VERSION_1_0) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4961 | GTEST_SKIP() << "Tests for 1.0 only"; |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 4962 | } |
| 4963 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 4964 | if (!AreRequiredExtensionsEnabled()) { |
| 4965 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 4966 | } |
| 4967 | |
| 4968 | auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>( |
| 4969 | vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR")); |
| 4970 | ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr); |
| 4971 | |
| 4972 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4973 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features); |
| 4974 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&multiview_features); |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 4975 | vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2); |
| 4976 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4977 | if (multiview_features.multiview == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4978 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 4979 | } |
| 4980 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 4981 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 4982 | } |
| 4983 | |
| 4984 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 4985 | |
| 4986 | auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 4987 | vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2); |
| 4988 | |
| 4989 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 4990 | |
| 4991 | VkImageObj image(m_device); |
| 4992 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, |
| 4993 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, |
| 4994 | VK_IMAGE_TILING_LINEAR, 0); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 4995 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 4996 | |
| 4997 | auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
| 4998 | fragment_shading_rate.imageView = image_view; |
| 4999 | fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 5000 | fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 5001 | |
| 5002 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate); |
| 5003 | begin_rendering_info.layerCount = 1; |
| 5004 | begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64; |
| 5005 | |
| 5006 | m_commandBuffer->begin(); |
| 5007 | |
| 5008 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06117"); |
| 5009 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 5010 | m_errorMonitor->VerifyFound(); |
| 5011 | |
| 5012 | begin_rendering_info.renderArea.offset.x = 0; |
| 5013 | begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64; |
| 5014 | |
| 5015 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06118"); |
| 5016 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 5017 | m_errorMonitor->VerifyFound(); |
| 5018 | } |
| 5019 | |
| 5020 | TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSizeWithDeviceGroupExt) { |
| 5021 | TEST_DESCRIPTION("Test FragmentShadingRateAttachment size with device group extension."); |
| 5022 | |
| 5023 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 5024 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 5025 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5026 | AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 5027 | |
| 5028 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 5029 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5030 | if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) { |
| 5031 | GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation."; |
| 5032 | } |
| 5033 | |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 5034 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 5035 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 5036 | } |
| 5037 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 5038 | if (!AreRequiredExtensionsEnabled()) { |
| 5039 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 5040 | } |
| 5041 | |
| 5042 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5043 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features); |
| 5044 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features); |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 5045 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 5046 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5047 | if (multiview_features.multiview == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 5048 | GTEST_SKIP() << "Test requires (unsupported) multiview"; |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 5049 | } |
| 5050 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 5051 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 5052 | } |
| 5053 | |
| 5054 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 5055 | |
| 5056 | auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 5057 | vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2); |
| 5058 | |
| 5059 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 5060 | |
| 5061 | VkImageObj image(m_device); |
| 5062 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, |
| 5063 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, |
| 5064 | VK_IMAGE_TILING_LINEAR, 0); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5065 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 5066 | |
| 5067 | auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
| 5068 | fragment_shading_rate.imageView = image_view; |
| 5069 | fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 5070 | fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 5071 | |
| 5072 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate); |
| 5073 | begin_rendering_info.layerCount = 1; |
| 5074 | begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64; |
| 5075 | |
| 5076 | m_commandBuffer->begin(); |
| 5077 | |
| 5078 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06119"); |
| 5079 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 5080 | m_errorMonitor->VerifyFound(); |
| 5081 | |
| 5082 | begin_rendering_info.renderArea.offset.x = 0; |
| 5083 | begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64; |
| 5084 | |
ziga-lunarg | 8f9de2a | 2022-04-25 15:59:19 +0200 | [diff] [blame] | 5085 | VkRect2D render_area = {}; |
| 5086 | render_area.offset.x = 0; |
| 5087 | render_area.offset.y = 0; |
| 5088 | render_area.extent.width = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.width; |
| 5089 | render_area.extent.height = 32; |
| 5090 | |
| 5091 | auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>(); |
| 5092 | device_group_render_pass_begin_info.deviceRenderAreaCount = 1; |
| 5093 | device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area; |
| 5094 | fragment_shading_rate.pNext = &device_group_render_pass_begin_info; |
| 5095 | |
ziga-lunarg | 7f25dff | 2022-05-06 17:49:34 +0200 | [diff] [blame] | 5096 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06120"); |
ziga-lunarg | 8f9de2a | 2022-04-25 15:59:19 +0200 | [diff] [blame] | 5097 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 5098 | m_errorMonitor->VerifyFound(); |
| 5099 | |
| 5100 | render_area.extent.width = 32; |
| 5101 | render_area.extent.height = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.height; |
| 5102 | |
| 5103 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06122"); |
ziga-lunarg | 6755163 | 2022-04-25 15:20:20 +0200 | [diff] [blame] | 5104 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 5105 | m_errorMonitor->VerifyFound(); |
| 5106 | } |
ziga-lunarg | e966a9a | 2022-04-25 22:42:08 +0200 | [diff] [blame] | 5107 | |
| 5108 | TEST_F(VkLayerTest, TestSuspendingRenderPassInstance) { |
| 5109 | TEST_DESCRIPTION("Test suspending render pass instance."); |
| 5110 | |
| 5111 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 5112 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 5113 | |
| 5114 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 5115 | |
| 5116 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 5117 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | e966a9a | 2022-04-25 22:42:08 +0200 | [diff] [blame] | 5118 | } |
| 5119 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 5120 | if (!AreRequiredExtensionsEnabled()) { |
| 5121 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | e966a9a | 2022-04-25 22:42:08 +0200 | [diff] [blame] | 5122 | } |
| 5123 | |
| 5124 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 5125 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 5126 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 5127 | |
| 5128 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 5129 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | e966a9a | 2022-04-25 22:42:08 +0200 | [diff] [blame] | 5130 | } |
| 5131 | |
| 5132 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 5133 | |
| 5134 | m_errorMonitor->ExpectSuccess(); |
| 5135 | |
| 5136 | VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_); |
| 5137 | VkCommandBufferObj cmd_buffer1(m_device, &command_pool); |
| 5138 | VkCommandBufferObj cmd_buffer2(m_device, &command_pool); |
| 5139 | VkCommandBufferObj cmd_buffer3(m_device, &command_pool); |
| 5140 | |
| 5141 | VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>(); |
| 5142 | suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT; |
| 5143 | suspend_rendering_info.layerCount = 1; |
| 5144 | |
| 5145 | VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>(); |
| 5146 | resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT; |
| 5147 | resume_rendering_info.layerCount = 1; |
| 5148 | |
| 5149 | VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>(); |
| 5150 | rendering_info.layerCount = 1; |
| 5151 | |
| 5152 | auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 5153 | |
| 5154 | cmd_buffer1.begin(&cmd_begin); |
| 5155 | cmd_buffer1.BeginRendering(suspend_rendering_info); |
| 5156 | cmd_buffer1.EndRendering(); |
| 5157 | cmd_buffer1.end(); |
| 5158 | |
| 5159 | cmd_buffer2.begin(&cmd_begin); |
| 5160 | cmd_buffer2.BeginRendering(resume_rendering_info); |
| 5161 | cmd_buffer2.EndRendering(); |
| 5162 | cmd_buffer2.end(); |
| 5163 | |
| 5164 | cmd_buffer3.begin(&cmd_begin); |
| 5165 | cmd_buffer3.BeginRendering(rendering_info); |
| 5166 | cmd_buffer3.EndRendering(); |
| 5167 | cmd_buffer3.end(); |
| 5168 | |
| 5169 | VkCommandBuffer command_buffers[3] = {cmd_buffer1.handle(), cmd_buffer2.handle()}; |
| 5170 | |
| 5171 | VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>(); |
| 5172 | submit_info.commandBufferCount = 2; |
| 5173 | submit_info.pCommandBuffers = command_buffers; |
| 5174 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5175 | vk::QueueWaitIdle(m_device->m_queue); |
| 5176 | |
| 5177 | m_errorMonitor->VerifyNotFound(); |
| 5178 | |
| 5179 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06014"); |
| 5180 | |
| 5181 | submit_info.commandBufferCount = 1; |
| 5182 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5183 | vk::QueueWaitIdle(m_device->m_queue); |
| 5184 | |
| 5185 | m_errorMonitor->VerifyFound(); |
| 5186 | |
| 5187 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06016"); |
| 5188 | |
| 5189 | command_buffers[1] = cmd_buffer3.handle(); |
| 5190 | command_buffers[2] = cmd_buffer2.handle(); |
| 5191 | submit_info.commandBufferCount = 3; |
| 5192 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5193 | vk::QueueWaitIdle(m_device->m_queue); |
| 5194 | |
| 5195 | m_errorMonitor->VerifyFound(); |
| 5196 | |
| 5197 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06193"); |
| 5198 | |
| 5199 | command_buffers[0] = cmd_buffer2.handle(); |
| 5200 | submit_info.commandBufferCount = 1; |
| 5201 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5202 | vk::QueueWaitIdle(m_device->m_queue); |
| 5203 | |
| 5204 | m_errorMonitor->VerifyFound(); |
| 5205 | } |
| 5206 | |
| 5207 | TEST_F(VkLayerTest, TestSuspendingRenderPassInstanceQueueSubmit2) { |
| 5208 | TEST_DESCRIPTION("Test suspending render pass instance with QueueSubmit2."); |
| 5209 | |
| 5210 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 5211 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 5212 | AddRequiredExtensions(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); |
| 5213 | |
| 5214 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 5215 | |
| 5216 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 5217 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | e966a9a | 2022-04-25 22:42:08 +0200 | [diff] [blame] | 5218 | } |
| 5219 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 5220 | if (!AreRequiredExtensionsEnabled()) { |
| 5221 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | e966a9a | 2022-04-25 22:42:08 +0200 | [diff] [blame] | 5222 | } |
| 5223 | |
| 5224 | auto synchronization2 = LvlInitStruct<VkPhysicalDeviceSynchronization2Features>(); |
| 5225 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&synchronization2); |
| 5226 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 5227 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 5228 | |
| 5229 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 5230 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering"; |
ziga-lunarg | e966a9a | 2022-04-25 22:42:08 +0200 | [diff] [blame] | 5231 | } |
| 5232 | if (synchronization2.synchronization2 == VK_FALSE) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 5233 | GTEST_SKIP() << "Test requires (unsupported) synchronization2"; |
ziga-lunarg | e966a9a | 2022-04-25 22:42:08 +0200 | [diff] [blame] | 5234 | } |
| 5235 | |
| 5236 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 5237 | |
| 5238 | auto vkQueueSubmit2KHR = |
| 5239 | reinterpret_cast<PFN_vkQueueSubmit2KHR>(vk::GetDeviceProcAddr(m_device->device(), "vkQueueSubmit2KHR")); |
| 5240 | ASSERT_TRUE(vkQueueSubmit2KHR != nullptr); |
| 5241 | |
| 5242 | m_errorMonitor->ExpectSuccess(); |
| 5243 | |
| 5244 | VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_); |
| 5245 | VkCommandBufferObj cmd_buffer1(m_device, &command_pool); |
| 5246 | VkCommandBufferObj cmd_buffer2(m_device, &command_pool); |
| 5247 | VkCommandBufferObj cmd_buffer3(m_device, &command_pool); |
| 5248 | |
| 5249 | VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>(); |
| 5250 | suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT; |
| 5251 | suspend_rendering_info.layerCount = 1; |
| 5252 | |
| 5253 | VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>(); |
| 5254 | resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT; |
| 5255 | resume_rendering_info.layerCount = 1; |
| 5256 | |
| 5257 | VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>(); |
| 5258 | rendering_info.layerCount = 1; |
| 5259 | |
| 5260 | auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 5261 | |
| 5262 | cmd_buffer1.begin(&cmd_begin); |
| 5263 | cmd_buffer1.BeginRendering(suspend_rendering_info); |
| 5264 | cmd_buffer1.EndRendering(); |
| 5265 | cmd_buffer1.end(); |
| 5266 | |
| 5267 | cmd_buffer2.begin(&cmd_begin); |
| 5268 | cmd_buffer2.BeginRendering(resume_rendering_info); |
| 5269 | cmd_buffer2.EndRendering(); |
| 5270 | cmd_buffer2.end(); |
| 5271 | |
| 5272 | cmd_buffer3.begin(&cmd_begin); |
| 5273 | cmd_buffer3.BeginRendering(rendering_info); |
| 5274 | cmd_buffer3.EndRendering(); |
| 5275 | cmd_buffer3.end(); |
| 5276 | |
| 5277 | VkCommandBufferSubmitInfo command_buffer_submit_info[3]; |
| 5278 | command_buffer_submit_info[0] = LvlInitStruct<VkCommandBufferSubmitInfo>(); |
| 5279 | command_buffer_submit_info[1] = LvlInitStruct<VkCommandBufferSubmitInfo>(); |
| 5280 | command_buffer_submit_info[2] = LvlInitStruct<VkCommandBufferSubmitInfo>(); |
| 5281 | |
| 5282 | command_buffer_submit_info[0].commandBuffer = cmd_buffer1.handle(); |
| 5283 | command_buffer_submit_info[1].commandBuffer = cmd_buffer2.handle(); |
| 5284 | |
| 5285 | VkSubmitInfo2KHR submit_info = LvlInitStruct<VkSubmitInfo2KHR>(); |
| 5286 | submit_info.commandBufferInfoCount = 2; |
| 5287 | submit_info.pCommandBufferInfos = command_buffer_submit_info; |
| 5288 | vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5289 | vk::QueueWaitIdle(m_device->m_queue); |
| 5290 | |
| 5291 | m_errorMonitor->VerifyNotFound(); |
| 5292 | |
| 5293 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06010"); |
| 5294 | |
| 5295 | submit_info.commandBufferInfoCount = 1; |
| 5296 | vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5297 | vk::QueueWaitIdle(m_device->m_queue); |
| 5298 | |
| 5299 | m_errorMonitor->VerifyFound(); |
| 5300 | |
| 5301 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06012"); |
| 5302 | |
| 5303 | command_buffer_submit_info[1].commandBuffer = cmd_buffer3.handle(); |
| 5304 | command_buffer_submit_info[2].commandBuffer = cmd_buffer2.handle(); |
| 5305 | submit_info.commandBufferInfoCount = 3; |
| 5306 | vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5307 | vk::QueueWaitIdle(m_device->m_queue); |
| 5308 | |
| 5309 | m_errorMonitor->VerifyFound(); |
| 5310 | |
| 5311 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06192"); |
| 5312 | |
| 5313 | command_buffer_submit_info[0].commandBuffer = cmd_buffer2.handle(); |
| 5314 | submit_info.commandBufferInfoCount = 1; |
| 5315 | vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5316 | vk::QueueWaitIdle(m_device->m_queue); |
| 5317 | |
| 5318 | m_errorMonitor->VerifyFound(); |
| 5319 | } |