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