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 | 6f7647f | 2022-04-18 20:10:04 +0200 | [diff] [blame] | 1599 | image_ci.usage = 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 | |
| 1605 | VkRenderingFragmentShadingRateAttachmentInfoKHR fragment_shading_rate = |
| 1606 | LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
| 1607 | fragment_shading_rate.imageView = image_view; |
| 1608 | fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1609 | fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 1610 | |
| 1611 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate); |
| 1612 | begin_rendering_info.layerCount = 4; |
| 1613 | |
| 1614 | m_commandBuffer->begin(); |
| 1615 | |
| 1616 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06123"); |
| 1617 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1618 | m_errorMonitor->VerifyFound(); |
| 1619 | |
| 1620 | begin_rendering_info.viewMask = 0xF; |
| 1621 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06124"); |
| 1622 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1623 | m_errorMonitor->VerifyFound(); |
| 1624 | |
| 1625 | m_commandBuffer->end(); |
ziga-lunarg | b7fec14 | 2022-03-18 22:08:17 +0100 | [diff] [blame] | 1626 | } |
| 1627 | |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1628 | TEST_F(VkLayerTest, TestDeviceGroupRenderPassBeginInfo) { |
| 1629 | TEST_DESCRIPTION("Test render area of DeviceGroupRenderPassBeginInfo."); |
| 1630 | |
| 1631 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 1632 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1633 | |
| 1634 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1635 | |
| 1636 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1637 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1638 | } |
| 1639 | |
| 1640 | if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) { |
| 1641 | printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1642 | return; |
| 1643 | } |
| 1644 | |
| 1645 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1646 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1647 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1648 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 1649 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 1650 | return; |
| 1651 | } |
| 1652 | |
| 1653 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 1654 | |
| 1655 | VkRect2D render_area = {}; |
| 1656 | render_area.offset.x = 0; |
| 1657 | render_area.offset.y = 0; |
| 1658 | render_area.extent.width = 32; |
| 1659 | render_area.extent.height = 32; |
| 1660 | |
| 1661 | auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>(); |
| 1662 | device_group_render_pass_begin_info.deviceRenderAreaCount = 1; |
| 1663 | device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area; |
| 1664 | |
| 1665 | VkImageObj colorImage(m_device); |
| 1666 | colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 1667 | VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 1668 | |
| 1669 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 1670 | color_attachment.imageView = colorImageView; |
| 1671 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 1672 | |
| 1673 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&device_group_render_pass_begin_info); |
ziga-lunarg | 1fec633 | 2022-03-20 14:39:54 +0100 | [diff] [blame] | 1674 | begin_rendering_info.layerCount = 1; |
ziga-lunarg | 7e7138c | 2022-03-18 19:02:31 +0100 | [diff] [blame] | 1675 | begin_rendering_info.colorAttachmentCount = 1; |
| 1676 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 1677 | |
| 1678 | m_commandBuffer->begin(); |
| 1679 | |
| 1680 | m_errorMonitor->ExpectSuccess(); |
| 1681 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1682 | m_errorMonitor->VerifyNotFound(); |
| 1683 | |
| 1684 | render_area.offset.x = 1; |
| 1685 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06083"); |
| 1686 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1687 | m_errorMonitor->VerifyFound(); |
| 1688 | |
| 1689 | render_area.offset.x = 0; |
| 1690 | render_area.offset.y = 16; |
| 1691 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06084"); |
| 1692 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1693 | m_errorMonitor->VerifyFound(); |
| 1694 | |
| 1695 | m_commandBuffer->end(); |
| 1696 | } |
| 1697 | |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1698 | TEST_F(VkLayerTest, TestBeginRenderingInvalidFragmentShadingRateImage) { |
| 1699 | TEST_DESCRIPTION("Test BeginRendering with FragmentShadingRateAttachmentInfo with missing image usage bit."); |
| 1700 | |
| 1701 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 1702 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1703 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 1704 | |
| 1705 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1706 | |
| 1707 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1708 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1709 | } |
| 1710 | |
| 1711 | if (!AreRequestedExtensionsEnabled()) { |
sjfricke | c935ec7 | 2022-05-19 15:26:10 +0900 | [diff] [blame] | 1712 | GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1713 | } |
| 1714 | |
| 1715 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1716 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1717 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1718 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 1719 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 1720 | return; |
| 1721 | } |
| 1722 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1723 | |
| 1724 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 1725 | auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 1726 | vk::GetPhysicalDeviceProperties2(gpu(), &properties2); |
| 1727 | |
| 1728 | VkImageObj image(m_device); |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1729 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, |
| 1730 | 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] | 1731 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 1732 | |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1733 | VkImageObj invalid_image(m_device); |
| 1734 | invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 1735 | VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 1736 | |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1737 | auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1738 | fragment_shading_rate.imageView = invalid_image_view; |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1739 | fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1740 | fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 1741 | |
| 1742 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate); |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1743 | begin_rendering_info.layerCount = 1; |
| 1744 | |
| 1745 | m_commandBuffer->begin(); |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1746 | |
| 1747 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06148"); |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1748 | m_commandBuffer->BeginRendering(begin_rendering_info); |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1749 | m_errorMonitor->VerifyFound(); |
ziga-lunarg | d3de6ce | 2022-03-18 21:14:57 +0100 | [diff] [blame] | 1750 | fragment_shading_rate.imageView = image_view; |
| 1751 | |
| 1752 | fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width + 1; |
| 1753 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06149"); |
| 1754 | if (fragment_shading_rate.shadingRateAttachmentTexelSize.width > |
| 1755 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.width) { |
| 1756 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06150"); |
| 1757 | } |
| 1758 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1759 | m_errorMonitor->VerifyFound(); |
| 1760 | |
| 1761 | if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.width > 1) { |
| 1762 | fragment_shading_rate.shadingRateAttachmentTexelSize.width = |
| 1763 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.width / 2; |
| 1764 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06151"); |
| 1765 | if (fragment_shading_rate.shadingRateAttachmentTexelSize.height / |
| 1766 | fragment_shading_rate.shadingRateAttachmentTexelSize.width >= |
| 1767 | fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) { |
| 1768 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06156"); |
| 1769 | } |
| 1770 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1771 | m_errorMonitor->VerifyFound(); |
| 1772 | } |
| 1773 | |
| 1774 | fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width; |
| 1775 | |
| 1776 | fragment_shading_rate.shadingRateAttachmentTexelSize.height = |
| 1777 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.height + 1; |
| 1778 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06152"); |
| 1779 | if (fragment_shading_rate.shadingRateAttachmentTexelSize.height > |
| 1780 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.height) { |
| 1781 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06153"); |
| 1782 | } |
| 1783 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1784 | m_errorMonitor->VerifyFound(); |
| 1785 | |
| 1786 | if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.height > 1) { |
| 1787 | fragment_shading_rate.shadingRateAttachmentTexelSize.height = |
| 1788 | fsr_properties.minFragmentShadingRateAttachmentTexelSize.height / 2; |
| 1789 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06154"); |
| 1790 | if (fragment_shading_rate.shadingRateAttachmentTexelSize.width / |
| 1791 | fragment_shading_rate.shadingRateAttachmentTexelSize.height > |
| 1792 | fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) { |
| 1793 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06155"); |
| 1794 | } |
| 1795 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1796 | m_errorMonitor->VerifyFound(); |
| 1797 | } |
| 1798 | |
| 1799 | m_commandBuffer->end(); |
ziga-lunarg | 184a20b | 2022-03-18 20:54:48 +0100 | [diff] [blame] | 1800 | } |
| 1801 | |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1802 | TEST_F(VkLayerTest, BeginRenderingInvalidDepthAttachmentFormat) { |
| 1803 | TEST_DESCRIPTION("Test begin rendering with a depth attachment that has an invalid format"); |
| 1804 | |
| 1805 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 1806 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1807 | |
| 1808 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1809 | |
| 1810 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1811 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1812 | } |
| 1813 | |
| 1814 | if (!AreRequestedExtensionsEnabled()) { |
sjfricke | c935ec7 | 2022-05-19 15:26:10 +0900 | [diff] [blame] | 1815 | GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported"; |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1816 | } |
| 1817 | |
| 1818 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1819 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1820 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1821 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 1822 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 1823 | return; |
| 1824 | } |
| 1825 | |
| 1826 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1827 | |
| 1828 | VkFormat stencil_format = FindSupportedStencilOnlyFormat(gpu()); |
| 1829 | if (stencil_format == VK_FORMAT_UNDEFINED) { |
| 1830 | printf("%s requires a stencil only format format.\n", kSkipPrefix); |
| 1831 | return; |
| 1832 | } |
| 1833 | |
| 1834 | VkImageObj image(m_device); |
| 1835 | image.Init(32, 32, 1, stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 1836 | VkImageView image_view = image.targetView(stencil_format, VK_IMAGE_ASPECT_STENCIL_BIT); |
| 1837 | |
| 1838 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 1839 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 1840 | depth_attachment.imageView = image_view; |
| 1841 | |
| 1842 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
ziga-lunarg | 1fec633 | 2022-03-20 14:39:54 +0100 | [diff] [blame] | 1843 | begin_rendering_info.layerCount = 1; |
ziga-lunarg | ec0ac1c | 2022-03-18 19:25:17 +0100 | [diff] [blame] | 1844 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 1845 | |
| 1846 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06547"); |
| 1847 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1848 | m_errorMonitor->VerifyFound(); |
| 1849 | } |
ziga-lunarg | 4b5bb5b | 2022-03-20 00:49:04 +0100 | [diff] [blame] | 1850 | |
ziga-lunarg | 14a6978 | 2022-03-20 00:39:31 +0100 | [diff] [blame] | 1851 | TEST_F(VkLayerTest, TestFragmentDensityMapRenderArea) { |
| 1852 | TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent."); |
| 1853 | |
| 1854 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 1855 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1856 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 1857 | |
| 1858 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1859 | |
| 1860 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1861 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 14a6978 | 2022-03-20 00:39:31 +0100 | [diff] [blame] | 1862 | } |
| 1863 | |
| 1864 | if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) { |
| 1865 | printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 1866 | return; |
| 1867 | } |
| 1868 | |
| 1869 | if (!DeviceExtensionSupported(gpu(), nullptr, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME)) { |
| 1870 | printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 1871 | return; |
| 1872 | } |
| 1873 | |
| 1874 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 1875 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 1876 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1877 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 1878 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 1879 | return; |
| 1880 | } |
| 1881 | |
| 1882 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1883 | |
| 1884 | auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>(); |
| 1885 | auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props); |
| 1886 | vk::GetPhysicalDeviceProperties2(gpu(), &props2); |
| 1887 | |
| 1888 | VkImageObj image(m_device); |
| 1889 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 1890 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1); |
| 1891 | |
| 1892 | auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 1893 | fragment_density_map.imageView = image_view; |
| 1894 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map); |
| 1895 | begin_rendering_info.layerCount = 1; |
| 1896 | begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1897 | begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1898 | |
| 1899 | m_commandBuffer->begin(); |
| 1900 | |
| 1901 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06112"); |
| 1902 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1903 | m_errorMonitor->VerifyFound(); |
| 1904 | |
| 1905 | begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1906 | begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1907 | |
| 1908 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06114"); |
| 1909 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1910 | m_errorMonitor->VerifyFound(); |
| 1911 | |
| 1912 | VkRect2D device_render_area = {}; |
| 1913 | device_render_area.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1914 | device_render_area.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1915 | auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>(); |
| 1916 | device_group_render_pass_begin_info.deviceRenderAreaCount = 1; |
| 1917 | device_group_render_pass_begin_info.pDeviceRenderAreas = &device_render_area; |
| 1918 | fragment_density_map.pNext = &device_group_render_pass_begin_info; |
| 1919 | |
| 1920 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06113"); |
| 1921 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1922 | m_errorMonitor->VerifyFound(); |
| 1923 | |
| 1924 | device_render_area.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width; |
| 1925 | device_render_area.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height; |
| 1926 | |
| 1927 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06115"); |
| 1928 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 1929 | m_errorMonitor->VerifyFound(); |
| 1930 | |
| 1931 | m_commandBuffer->end(); |
| 1932 | } |
| 1933 | |
ziga-lunarg | e7279ba | 2022-03-31 20:55:27 +0200 | [diff] [blame] | 1934 | TEST_F(VkLayerTest, TestBarrierWithDynamicRendering) { |
| 1935 | TEST_DESCRIPTION("Test setting buffer memory barrier when dynamic rendering is active."); |
| 1936 | |
| 1937 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 1938 | |
| 1939 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1940 | |
| 1941 | if (DeviceValidationVersion() < VK_API_VERSION_1_3) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1942 | GTEST_SKIP() << "At least Vulkan version 1.3 is required"; |
ziga-lunarg | e7279ba | 2022-03-31 20:55:27 +0200 | [diff] [blame] | 1943 | } |
| 1944 | |
| 1945 | auto vk13features = LvlInitStruct<VkPhysicalDeviceVulkan13Features>(); |
| 1946 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&vk13features); |
| 1947 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 1948 | if (!vk13features.dynamicRendering) { |
| 1949 | printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix); |
| 1950 | return; |
| 1951 | } |
| 1952 | if (!vk13features.synchronization2) { |
| 1953 | printf("%s Test requires (unsupported) synchronization2, skipping\n", kSkipPrefix); |
| 1954 | return; |
| 1955 | } |
| 1956 | |
| 1957 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1958 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1959 | |
| 1960 | PFN_vkCmdBeginRendering vkCmdBeginRendering = |
| 1961 | reinterpret_cast<PFN_vkCmdBeginRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginRendering")); |
| 1962 | assert(vkCmdBeginRendering != nullptr); |
| 1963 | PFN_vkCmdEndRendering vkCmdEndRendering = |
| 1964 | reinterpret_cast<PFN_vkCmdEndRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndRendering")); |
| 1965 | assert(vkCmdEndRendering != nullptr); |
| 1966 | |
| 1967 | m_commandBuffer->begin(); |
| 1968 | |
| 1969 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 1970 | VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1}; |
| 1971 | begin_rendering_info.renderArea = clear_rect.rect; |
| 1972 | begin_rendering_info.layerCount = 1; |
| 1973 | |
| 1974 | vkCmdBeginRendering(m_commandBuffer->handle(), &begin_rendering_info); |
| 1975 | |
| 1976 | VkBufferObj buffer; |
| 1977 | VkMemoryPropertyFlags mem_reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 1978 | buffer.init_as_src_and_dst(*m_device, 256, mem_reqs); |
| 1979 | |
| 1980 | auto buf_barrier = lvl_init_struct<VkBufferMemoryBarrier2KHR>(); |
| 1981 | buf_barrier.buffer = buffer.handle(); |
| 1982 | buf_barrier.offset = 0; |
| 1983 | buf_barrier.size = VK_WHOLE_SIZE; |
| 1984 | buf_barrier.srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; |
| 1985 | buf_barrier.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; |
| 1986 | |
| 1987 | auto dependency_info = lvl_init_struct<VkDependencyInfoKHR>(); |
| 1988 | dependency_info.bufferMemoryBarrierCount = 1; |
| 1989 | dependency_info.pBufferMemoryBarriers = &buf_barrier; |
| 1990 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier2-None-06191"); |
| 1991 | vk::CmdPipelineBarrier2(m_commandBuffer->handle(), &dependency_info); |
| 1992 | m_errorMonitor->VerifyFound(); |
| 1993 | |
| 1994 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-None-06191"); |
| 1995 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, |
| 1996 | nullptr, 0, nullptr, 0, nullptr); |
| 1997 | m_errorMonitor->VerifyFound(); |
| 1998 | |
| 1999 | vkCmdEndRendering(m_commandBuffer->handle()); |
| 2000 | m_commandBuffer->end(); |
| 2001 | } |
| 2002 | |
ziga-lunarg | ce90b52 | 2022-04-27 23:59:46 +0200 | [diff] [blame] | 2003 | TEST_F(VkLayerTest, UseStencilAttachmentWithIntegerFormat) { |
| 2004 | TEST_DESCRIPTION("Use stencil attachment with integer format"); |
| 2005 | |
| 2006 | m_errorMonitor->ExpectSuccess(); |
| 2007 | |
| 2008 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2009 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2010 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2011 | |
| 2012 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 2013 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2014 | return; |
ziga-lunarg | ce90b52 | 2022-04-27 23:59:46 +0200 | [diff] [blame] | 2015 | } |
| 2016 | if (!AreRequestedExtensionsEnabled()) { |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 2017 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2018 | return; |
ziga-lunarg | ce90b52 | 2022-04-27 23:59:46 +0200 | [diff] [blame] | 2019 | } |
| 2020 | |
| 2021 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 2022 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2023 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2024 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2025 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2026 | return; |
| 2027 | } |
| 2028 | |
| 2029 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2030 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2031 | |
| 2032 | if (ImageFormatIsSupported(gpu(), VK_FORMAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) { |
| 2033 | printf("%s VK_FORMAT_S8_UINT format not supported, skipping test.\n", kSkipPrefix); |
| 2034 | return; |
| 2035 | } |
| 2036 | |
| 2037 | auto depth_stencil_resolve_properties = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>(); |
| 2038 | auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_properties); |
| 2039 | vk::GetPhysicalDeviceProperties2(gpu(), &properties2); |
| 2040 | if (depth_stencil_resolve_properties.supportedStencilResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) { |
| 2041 | printf("%s VK_RESOLVE_MODE_AVERAGE_BIT not supported for VK_FORMAT_S8_UINT, skipping test.\n", kSkipPrefix); |
| 2042 | return; |
| 2043 | } |
| 2044 | |
| 2045 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 2046 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2047 | image_create_info.format = VK_FORMAT_S8_UINT; |
| 2048 | image_create_info.extent = {32, 32, 1}; |
| 2049 | image_create_info.mipLevels = 1; |
| 2050 | image_create_info.arrayLayers = 1; |
| 2051 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 2052 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2053 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 2054 | VkImageObj image(m_device); |
| 2055 | image.Init(image_create_info); |
| 2056 | VkImageView image_view = image.targetView(VK_FORMAT_S8_UINT, VK_IMAGE_ASPECT_STENCIL_BIT); |
| 2057 | |
| 2058 | VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2059 | stencil_attachment.imageView = image_view; |
| 2060 | stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 2061 | stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 2062 | stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 2063 | |
| 2064 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2065 | begin_rendering_info.pStencilAttachment = &stencil_attachment; |
| 2066 | begin_rendering_info.layerCount = 1; |
| 2067 | |
| 2068 | m_commandBuffer->begin(); |
| 2069 | |
| 2070 | m_errorMonitor->VerifyNotFound(); |
| 2071 | |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 2072 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06131"); |
ziga-lunarg | ce90b52 | 2022-04-27 23:59:46 +0200 | [diff] [blame] | 2073 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2074 | m_errorMonitor->VerifyFound(); |
| 2075 | |
| 2076 | m_commandBuffer->end(); |
| 2077 | } |
ziga-lunarg | 5e0a245 | 2022-04-20 19:29:37 +0200 | [diff] [blame] | 2078 | |
| 2079 | TEST_F(VkLayerTest, BeginRenderingInvalidStencilAttachmentFormat) { |
| 2080 | TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format"); |
| 2081 | |
| 2082 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 2083 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2084 | |
| 2085 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2086 | |
| 2087 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2088 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
| 2089 | } |
| 2090 | |
| 2091 | if (!AreRequestedExtensionsEnabled()) { |
| 2092 | GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported"; |
| 2093 | } |
| 2094 | |
| 2095 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2096 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2097 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2098 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2099 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2100 | return; |
| 2101 | } |
| 2102 | |
| 2103 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2104 | |
| 2105 | VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu()); |
| 2106 | if (depth_format == VK_FORMAT_UNDEFINED) { |
| 2107 | printf("%s requires a stencil only format format.\n", kSkipPrefix); |
| 2108 | return; |
| 2109 | } |
| 2110 | |
| 2111 | VkImageObj image(m_device); |
| 2112 | image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 2113 | VkImageView image_view = image.targetView(depth_format, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2114 | |
| 2115 | VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2116 | stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL; |
| 2117 | stencil_attachment.imageView = image_view; |
| 2118 | |
| 2119 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2120 | begin_rendering_info.layerCount = 1; |
| 2121 | begin_rendering_info.pStencilAttachment = &stencil_attachment; |
| 2122 | |
| 2123 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06548"); |
| 2124 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2125 | m_errorMonitor->VerifyFound(); |
| 2126 | } |
| 2127 | |
| 2128 | TEST_F(VkLayerTest, TestInheritanceRenderingInfoStencilAttachmentFormat) { |
| 2129 | TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format"); |
| 2130 | |
| 2131 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 2132 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2133 | |
| 2134 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2135 | |
| 2136 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2137 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
| 2138 | } |
| 2139 | |
| 2140 | if (!AreRequestedExtensionsEnabled()) { |
| 2141 | GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported"; |
| 2142 | } |
| 2143 | |
| 2144 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2145 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2146 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2147 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2148 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2149 | return; |
| 2150 | } |
| 2151 | |
| 2152 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2153 | |
| 2154 | VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu()); |
| 2155 | if (depth_format == VK_FORMAT_UNDEFINED) { |
| 2156 | printf("%s requires a stencil only format format.\n", kSkipPrefix); |
| 2157 | return; |
| 2158 | } |
| 2159 | |
| 2160 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2161 | |
| 2162 | auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
| 2163 | cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1; |
| 2164 | cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format; |
| 2165 | cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = depth_format; |
| 2166 | cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = depth_format; |
| 2167 | cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 2168 | |
| 2169 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 2170 | cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info; |
| 2171 | cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE; |
| 2172 | |
| 2173 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 2174 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 2175 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 2176 | |
| 2177 | auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>(); |
| 2178 | cmd_buffer_allocate_info.commandPool = m_commandPool->handle(); |
| 2179 | cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
| 2180 | cmd_buffer_allocate_info.commandBufferCount = 1; |
| 2181 | |
| 2182 | VkCommandBuffer secondary_cmd_buffer; |
| 2183 | VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer); |
| 2184 | |
| 2185 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541"); |
| 2186 | vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info); |
| 2187 | m_errorMonitor->VerifyFound(); |
| 2188 | } |
ziga-lunarg | eb4a69c | 2022-04-20 21:52:00 +0200 | [diff] [blame] | 2189 | |
| 2190 | TEST_F(VkLayerTest, CreateGraphicsPipelineWithInvalidAttachmentSampleCount) { |
| 2191 | TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set"); |
| 2192 | |
| 2193 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 2194 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2195 | AddRequiredExtensions(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME); |
| 2196 | |
| 2197 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2198 | |
| 2199 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2200 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2201 | return; |
| 2202 | } |
| 2203 | |
| 2204 | if (!AreRequestedExtensionsEnabled()) { |
| 2205 | printf("%s Extension %s or %s not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 2206 | VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME); |
| 2207 | return; |
| 2208 | } |
| 2209 | |
| 2210 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2211 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2212 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2213 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2214 | printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix); |
| 2215 | return; |
| 2216 | } |
| 2217 | |
| 2218 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2219 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2220 | |
| 2221 | auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoNV>(); |
| 2222 | sample_count_info_amd.colorAttachmentCount = 1; |
| 2223 | sample_count_info_amd.depthStencilAttachmentSamples = static_cast<VkSampleCountFlagBits>(0x00000400); |
| 2224 | |
| 2225 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&sample_count_info_amd); |
| 2226 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 2227 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 2228 | |
| 2229 | CreatePipelineHelper pipe(*this); |
| 2230 | pipe.InitInfo(); |
| 2231 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 2232 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2233 | pipe.InitState(); |
| 2234 | |
| 2235 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-depthStencilAttachmentSamples-06593"); |
| 2236 | pipe.CreateGraphicsPipeline(); |
| 2237 | m_errorMonitor->VerifyFound(); |
| 2238 | } |
ziga-lunarg | d680bf2 | 2022-04-20 22:01:00 +0200 | [diff] [blame] | 2239 | |
| 2240 | TEST_F(VkLayerTest, CreatePipelineUsingDynamicRenderingWithoutFeature) { |
| 2241 | TEST_DESCRIPTION("Create graphcis pipeline that uses dynamic rendering, but feature is not enabled"); |
| 2242 | |
| 2243 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 2244 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2245 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 2246 | |
| 2247 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2248 | |
| 2249 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2250 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2251 | return; |
| 2252 | } |
| 2253 | |
| 2254 | if (!AreRequestedExtensionsEnabled()) { |
| 2255 | printf("%s Extension %s or %s not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 2256 | VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 2257 | return; |
| 2258 | } |
| 2259 | |
| 2260 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2261 | |
| 2262 | CreatePipelineHelper pipe(*this); |
| 2263 | pipe.InitInfo(); |
| 2264 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2265 | pipe.InitState(); |
| 2266 | |
| 2267 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-dynamicRendering-06576"); |
| 2268 | pipe.CreateGraphicsPipeline(); |
| 2269 | m_errorMonitor->VerifyFound(); |
| 2270 | } |
ziga-lunarg | f20d795 | 2022-04-20 22:11:40 +0200 | [diff] [blame] | 2271 | |
| 2272 | TEST_F(VkLayerTest, CreateGraphicsPipelineWithMissingMultisampleState) { |
| 2273 | TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set"); |
| 2274 | |
| 2275 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2276 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2277 | |
| 2278 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2279 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2280 | return; |
| 2281 | } |
| 2282 | |
| 2283 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2284 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2285 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2286 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2287 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2288 | return; |
| 2289 | } |
| 2290 | |
| 2291 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2292 | |
| 2293 | CreatePipelineHelper pipe(*this); |
| 2294 | pipe.InitInfo(); |
| 2295 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2296 | pipe.gp_ci_.pMultisampleState = nullptr; |
| 2297 | pipe.InitState(); |
| 2298 | |
| 2299 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pMultisampleState-06630"); |
| 2300 | pipe.CreateGraphicsPipeline(); |
| 2301 | m_errorMonitor->VerifyFound(); |
| 2302 | } |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2303 | |
| 2304 | TEST_F(VkLayerTest, DynamicRenderingAreaGreaterThanAttachmentExtent) { |
| 2305 | TEST_DESCRIPTION("Begin dynamic rendering with render area greater than extent of attachments"); |
| 2306 | |
| 2307 | SetTargetApiVersion(VK_API_VERSION_1_0); |
| 2308 | AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 2309 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2310 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2311 | |
| 2312 | if (DeviceValidationVersion() != VK_API_VERSION_1_0) { |
| 2313 | printf("%s Tests requires Vulkan 1.0, skipping test\n", kSkipPrefix); |
| 2314 | return; |
| 2315 | } |
| 2316 | if (!AreRequestedExtensionsEnabled()) { |
| 2317 | printf("%s Extension %s not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2318 | return; |
| 2319 | } |
| 2320 | |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2321 | auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>( |
| 2322 | vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR")); |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2323 | ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr); |
| 2324 | |
| 2325 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2326 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features); |
| 2327 | vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2); |
| 2328 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2329 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2330 | return; |
| 2331 | } |
| 2332 | |
| 2333 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2334 | |
| 2335 | VkImageObj colorImage(m_device); |
| 2336 | colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 2337 | VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 2338 | |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2339 | auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2340 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 2341 | color_attachment.imageView = colorImageView; |
| 2342 | |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2343 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
ziga-lunarg | 6ed1dad | 2022-04-20 23:14:53 +0200 | [diff] [blame] | 2344 | begin_rendering_info.layerCount = 1; |
| 2345 | begin_rendering_info.colorAttachmentCount = 1; |
| 2346 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 2347 | begin_rendering_info.renderArea.extent.width = 64; |
| 2348 | begin_rendering_info.renderArea.extent.height = 32; |
| 2349 | |
| 2350 | m_commandBuffer->begin(); |
| 2351 | |
| 2352 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06075"); |
| 2353 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2354 | m_errorMonitor->VerifyFound(); |
| 2355 | |
| 2356 | begin_rendering_info.renderArea.extent.width = 32; |
| 2357 | begin_rendering_info.renderArea.extent.height = 64; |
| 2358 | |
| 2359 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076"); |
| 2360 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2361 | m_errorMonitor->VerifyFound(); |
| 2362 | |
| 2363 | const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu()); |
| 2364 | if (ds_format != VK_FORMAT_UNDEFINED) { |
| 2365 | VkImageObj depthImage(m_device); |
| 2366 | depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 2367 | VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2368 | |
| 2369 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2370 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 2371 | depth_attachment.imageView = depthImageView; |
| 2372 | |
| 2373 | begin_rendering_info.colorAttachmentCount = 0; |
| 2374 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 2375 | |
| 2376 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076"); |
| 2377 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2378 | m_errorMonitor->VerifyFound(); |
| 2379 | } |
| 2380 | |
| 2381 | m_commandBuffer->end(); |
| 2382 | } |
ziga-lunarg | a51287c | 2022-04-20 23:24:37 +0200 | [diff] [blame] | 2383 | |
| 2384 | TEST_F(VkLayerTest, DynamicRenderingDeviceGroupAreaGreaterThanAttachmentExtent) { |
| 2385 | TEST_DESCRIPTION("Begin dynamic rendering with device group with render area greater than extent of attachments"); |
| 2386 | |
| 2387 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2388 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2389 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2390 | |
| 2391 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2392 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2393 | return; |
| 2394 | } |
| 2395 | if (!AreRequestedExtensionsEnabled()) { |
| 2396 | printf("%s Extension %s not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2397 | return; |
| 2398 | } |
| 2399 | |
| 2400 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2401 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2402 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2403 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2404 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2405 | return; |
| 2406 | } |
| 2407 | |
| 2408 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2409 | |
| 2410 | VkImageObj colorImage(m_device); |
| 2411 | colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 2412 | VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 2413 | |
| 2414 | auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2415 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 2416 | color_attachment.imageView = colorImageView; |
| 2417 | |
| 2418 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2419 | begin_rendering_info.layerCount = 1; |
| 2420 | begin_rendering_info.colorAttachmentCount = 1; |
| 2421 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 2422 | begin_rendering_info.renderArea.extent.width = 64; |
| 2423 | begin_rendering_info.renderArea.extent.height = 32; |
| 2424 | |
| 2425 | m_commandBuffer->begin(); |
| 2426 | |
| 2427 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06079"); |
| 2428 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2429 | m_errorMonitor->VerifyFound(); |
| 2430 | |
| 2431 | begin_rendering_info.renderArea.extent.width = 32; |
| 2432 | begin_rendering_info.renderArea.extent.height = 64; |
| 2433 | |
| 2434 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080"); |
| 2435 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2436 | m_errorMonitor->VerifyFound(); |
| 2437 | |
| 2438 | const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu()); |
| 2439 | if (ds_format != VK_FORMAT_UNDEFINED) { |
| 2440 | VkImageObj depthImage(m_device); |
| 2441 | depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 2442 | VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2443 | |
| 2444 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2445 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 2446 | depth_attachment.imageView = depthImageView; |
| 2447 | |
| 2448 | begin_rendering_info.colorAttachmentCount = 0; |
| 2449 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 2450 | |
| 2451 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080"); |
| 2452 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2453 | m_errorMonitor->VerifyFound(); |
| 2454 | } |
| 2455 | |
| 2456 | m_commandBuffer->end(); |
| 2457 | } |
ziga-lunarg | d4105c1 | 2022-04-21 13:54:20 +0200 | [diff] [blame] | 2458 | |
| 2459 | TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleRenderPass) { |
| 2460 | TEST_DESCRIPTION("Execute secondary command buffers within render pass instance with incompatible render pass"); |
| 2461 | |
| 2462 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2463 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2464 | |
| 2465 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2466 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2467 | return; |
| 2468 | } |
| 2469 | |
| 2470 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2471 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2472 | |
| 2473 | auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>(); |
| 2474 | |
| 2475 | vk_testing::RenderPass render_pass; |
| 2476 | render_pass.init(*m_device, render_pass_ci); |
| 2477 | |
| 2478 | VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 2479 | VkCommandBuffer secondary_handle = cb.handle(); |
| 2480 | |
| 2481 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 2482 | cmd_buffer_inheritance_info.renderPass = render_pass.handle(); |
| 2483 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 2484 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 2485 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 2486 | |
| 2487 | cb.begin(&cmd_buffer_begin_info); |
| 2488 | cb.end(); |
| 2489 | |
| 2490 | m_commandBuffer->begin(); |
| 2491 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 2492 | |
| 2493 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020"); |
| 2494 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098"); |
| 2495 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle); |
| 2496 | m_errorMonitor->VerifyFound(); |
| 2497 | |
| 2498 | m_commandBuffer->EndRenderPass(); |
| 2499 | m_commandBuffer->end(); |
| 2500 | } |
ziga-lunarg | 590e029 | 2022-04-21 14:07:22 +0200 | [diff] [blame] | 2501 | |
| 2502 | TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleSubpass) { |
| 2503 | TEST_DESCRIPTION("Execute secondary command buffers with different subpass"); |
| 2504 | |
| 2505 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2506 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2507 | |
| 2508 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2509 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2510 | return; |
| 2511 | } |
| 2512 | |
| 2513 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2514 | |
| 2515 | VkSubpassDescription subpasses[2] = {}; |
| 2516 | |
| 2517 | auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>(); |
| 2518 | render_pass_ci.subpassCount = 2; |
| 2519 | render_pass_ci.pSubpasses = subpasses; |
| 2520 | |
| 2521 | vk_testing::RenderPass render_pass; |
| 2522 | render_pass.init(*m_device, render_pass_ci); |
| 2523 | |
| 2524 | auto framebuffer_ci = LvlInitStruct<VkFramebufferCreateInfo>(); |
| 2525 | framebuffer_ci.renderPass = render_pass.handle(); |
| 2526 | framebuffer_ci.width = 32; |
| 2527 | framebuffer_ci.height = 32; |
| 2528 | |
| 2529 | vk_testing::Framebuffer framebuffer; |
| 2530 | framebuffer.init(*m_device, framebuffer_ci); |
| 2531 | |
| 2532 | VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 2533 | VkCommandBuffer secondary_handle = cb.handle(); |
| 2534 | |
| 2535 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 2536 | cmd_buffer_inheritance_info.renderPass = render_pass.handle(); |
| 2537 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 2538 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 2539 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 2540 | |
| 2541 | cb.begin(&cmd_buffer_begin_info); |
| 2542 | cb.end(); |
| 2543 | |
| 2544 | auto render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>(); |
| 2545 | render_pass_begin_info.renderPass = render_pass.handle(); |
| 2546 | render_pass_begin_info.renderArea.extent = {32, 32}; |
| 2547 | render_pass_begin_info.framebuffer = framebuffer.handle(); |
| 2548 | |
| 2549 | m_commandBuffer->begin(); |
| 2550 | m_commandBuffer->BeginRenderPass(render_pass_begin_info, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 2551 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 2552 | |
| 2553 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00097"); |
| 2554 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-06019"); |
| 2555 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle); |
| 2556 | m_errorMonitor->VerifyFound(); |
| 2557 | |
| 2558 | m_commandBuffer->EndRenderPass(); |
| 2559 | m_commandBuffer->end(); |
| 2560 | } |
ziga-lunarg | 343193b | 2022-04-21 14:15:17 +0200 | [diff] [blame] | 2561 | |
| 2562 | TEST_F(VkLayerTest, SecondaryCommandBufferInvalidContents) { |
| 2563 | TEST_DESCRIPTION("Execute secondary command buffers within active render pass that was not begun with VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS"); |
| 2564 | |
| 2565 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2566 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2567 | |
| 2568 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2569 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2570 | return; |
| 2571 | } |
| 2572 | |
| 2573 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2574 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2575 | |
| 2576 | auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>(); |
| 2577 | |
| 2578 | VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 2579 | VkCommandBuffer secondary_handle = cb.handle(); |
| 2580 | |
| 2581 | auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 2582 | cmd_buffer_inheritance_info.renderPass = m_renderPass; |
| 2583 | VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 2584 | cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 2585 | cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info; |
| 2586 | |
| 2587 | cb.begin(&cmd_buffer_begin_info); |
| 2588 | cb.end(); |
| 2589 | |
| 2590 | m_commandBuffer->begin(); |
| 2591 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 2592 | |
| 2593 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-00095"); |
| 2594 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-06018"); |
| 2595 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle); |
| 2596 | m_errorMonitor->VerifyFound(); |
| 2597 | |
| 2598 | m_commandBuffer->EndRenderPass(); |
| 2599 | m_commandBuffer->end(); |
| 2600 | } |
ziga-lunarg | 9104e0a | 2022-04-21 16:45:09 +0200 | [diff] [blame] | 2601 | |
| 2602 | TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoDepthFormat) { |
| 2603 | TEST_DESCRIPTION("Bind pipeline that has RenderingInfo DepthFormat incompatible with previously used pipeline"); |
| 2604 | |
| 2605 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2606 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2607 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2608 | |
| 2609 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2610 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2611 | return; |
| 2612 | } |
| 2613 | if (!AreRequestedExtensionsEnabled()) { |
| 2614 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2615 | return; |
| 2616 | } |
| 2617 | |
| 2618 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2619 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2620 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2621 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2622 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2623 | return; |
| 2624 | } |
| 2625 | |
| 2626 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2627 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2628 | |
| 2629 | m_errorMonitor->ExpectSuccess(); |
| 2630 | |
| 2631 | std::vector<VkFormat> depth_formats; |
| 2632 | const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT}; |
| 2633 | for (uint32_t i = 0; i < size(ds_formats); ++i) { |
| 2634 | VkFormatProperties format_props; |
| 2635 | vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props); |
| 2636 | |
| 2637 | if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { |
| 2638 | depth_formats.push_back(ds_formats[i]); |
| 2639 | } |
| 2640 | } |
| 2641 | |
| 2642 | if (depth_formats.size() < 2) { |
| 2643 | printf("%s Test requires 2 depth formats, skipping test.\n", kSkipPrefix); |
| 2644 | return; |
| 2645 | } |
| 2646 | |
| 2647 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2648 | pipeline_rendering_info.depthAttachmentFormat = depth_formats[0]; |
| 2649 | |
| 2650 | auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 2651 | |
| 2652 | CreatePipelineHelper pipe1(*this); |
| 2653 | pipe1.InitInfo(); |
| 2654 | pipe1.gp_ci_.pNext = &pipeline_rendering_info; |
| 2655 | pipe1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2656 | pipe1.InitState(); |
| 2657 | pipe1.ds_ci_ = ds_ci; |
| 2658 | pipe1.CreateGraphicsPipeline(); |
| 2659 | |
| 2660 | pipeline_rendering_info.depthAttachmentFormat = depth_formats[1]; |
| 2661 | |
| 2662 | CreatePipelineHelper pipe2(*this); |
| 2663 | pipe2.InitInfo(); |
| 2664 | pipe2.gp_ci_.pNext = &pipeline_rendering_info; |
| 2665 | pipe2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2666 | pipe2.InitState(); |
| 2667 | pipe2.ds_ci_ = ds_ci; |
| 2668 | pipe2.CreateGraphicsPipeline(); |
| 2669 | |
| 2670 | VkImageObj image(m_device); |
| 2671 | image.Init(32, 32, 1, depth_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 2672 | VkImageView depth_image_view = image.targetView(depth_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2673 | |
| 2674 | VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2675 | depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 2676 | depth_attachment.imageView = depth_image_view; |
| 2677 | |
| 2678 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2679 | begin_rendering_info.layerCount = 1; |
| 2680 | begin_rendering_info.pDepthAttachment = &depth_attachment; |
| 2681 | |
| 2682 | m_commandBuffer->begin(); |
| 2683 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2684 | |
| 2685 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_); |
| 2686 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 2687 | |
| 2688 | m_errorMonitor->VerifyNotFound(); |
| 2689 | |
| 2690 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06197"); |
| 2691 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_); |
| 2692 | m_errorMonitor->VerifyFound(); |
| 2693 | |
| 2694 | m_commandBuffer->EndRendering(); |
| 2695 | m_commandBuffer->end(); |
| 2696 | } |
ziga-lunarg | 1ac9b67 | 2022-04-21 17:55:28 +0200 | [diff] [blame] | 2697 | |
| 2698 | TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachments) { |
| 2699 | TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment incompatible with previously used pipeline"); |
| 2700 | |
| 2701 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2702 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2703 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2704 | |
| 2705 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2706 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2707 | return; |
| 2708 | } |
| 2709 | if (!AreRequestedExtensionsEnabled()) { |
| 2710 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2711 | return; |
| 2712 | } |
| 2713 | |
| 2714 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2715 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2716 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2717 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2718 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2719 | return; |
| 2720 | } |
| 2721 | |
| 2722 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2723 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2724 | |
| 2725 | m_errorMonitor->ExpectSuccess(); |
| 2726 | |
| 2727 | VkFormat format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2728 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2729 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 2730 | pipeline_rendering_info.pColorAttachmentFormats = &format; |
| 2731 | |
| 2732 | CreatePipelineHelper pipe1(*this); |
| 2733 | pipe1.InitInfo(); |
| 2734 | pipe1.gp_ci_.pNext = &pipeline_rendering_info; |
| 2735 | pipe1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2736 | pipe1.InitState(); |
| 2737 | pipe1.CreateGraphicsPipeline(); |
| 2738 | |
| 2739 | format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2740 | |
| 2741 | CreatePipelineHelper pipe2(*this); |
| 2742 | pipe2.InitInfo(); |
| 2743 | pipe2.gp_ci_.pNext = &pipeline_rendering_info; |
| 2744 | pipe2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2745 | pipe2.InitState(); |
| 2746 | pipe2.CreateGraphicsPipeline(); |
| 2747 | |
| 2748 | VkImageObj image(m_device); |
| 2749 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 2750 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 2751 | |
| 2752 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2753 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 2754 | color_attachment.imageView = image_view; |
| 2755 | |
| 2756 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2757 | begin_rendering_info.layerCount = 1; |
| 2758 | begin_rendering_info.colorAttachmentCount = 1; |
| 2759 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 2760 | |
| 2761 | m_commandBuffer->begin(); |
| 2762 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2763 | |
| 2764 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_); |
| 2765 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 2766 | |
| 2767 | m_errorMonitor->VerifyNotFound(); |
| 2768 | |
| 2769 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06196"); |
| 2770 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_); |
| 2771 | m_errorMonitor->VerifyFound(); |
| 2772 | |
| 2773 | m_commandBuffer->EndRendering(); |
| 2774 | m_commandBuffer->end(); |
| 2775 | } |
ziga-lunarg | acd7932 | 2022-04-21 18:36:34 +0200 | [diff] [blame] | 2776 | |
| 2777 | TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachmentCount) { |
| 2778 | TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment count incompatible with previously used pipeline"); |
| 2779 | |
| 2780 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2781 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2782 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2783 | |
| 2784 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2785 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2786 | return; |
| 2787 | } |
| 2788 | if (!AreRequestedExtensionsEnabled()) { |
| 2789 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2790 | return; |
| 2791 | } |
| 2792 | |
| 2793 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2794 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2795 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2796 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2797 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2798 | return; |
| 2799 | } |
| 2800 | |
| 2801 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2802 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2803 | |
| 2804 | m_errorMonitor->ExpectSuccess(); |
| 2805 | |
| 2806 | VkFormat format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2807 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2808 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 2809 | pipeline_rendering_info.pColorAttachmentFormats = &format; |
| 2810 | |
| 2811 | CreatePipelineHelper pipe1(*this); |
| 2812 | pipe1.InitInfo(); |
| 2813 | pipe1.gp_ci_.pNext = &pipeline_rendering_info; |
| 2814 | pipe1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2815 | pipe1.InitState(); |
| 2816 | pipe1.CreateGraphicsPipeline(); |
| 2817 | |
| 2818 | pipeline_rendering_info.colorAttachmentCount = 0; |
| 2819 | |
| 2820 | CreatePipelineHelper pipe2(*this); |
| 2821 | pipe2.InitInfo(); |
| 2822 | pipe2.gp_ci_.pNext = &pipeline_rendering_info; |
| 2823 | pipe2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2824 | pipe2.InitState(); |
| 2825 | pipe2.CreateGraphicsPipeline(); |
| 2826 | |
| 2827 | VkImageObj image(m_device); |
| 2828 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 2829 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 2830 | |
| 2831 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2832 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 2833 | color_attachment.imageView = image_view; |
| 2834 | |
| 2835 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2836 | begin_rendering_info.layerCount = 1; |
| 2837 | begin_rendering_info.colorAttachmentCount = 1; |
| 2838 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 2839 | |
| 2840 | m_commandBuffer->begin(); |
| 2841 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2842 | |
| 2843 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_); |
| 2844 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 2845 | |
| 2846 | m_errorMonitor->VerifyNotFound(); |
| 2847 | |
| 2848 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06195"); |
| 2849 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_); |
| 2850 | m_errorMonitor->VerifyFound(); |
| 2851 | |
| 2852 | m_commandBuffer->EndRendering(); |
| 2853 | m_commandBuffer->end(); |
ziga-lunarg | e3f1128 | 2022-04-21 18:39:55 +0200 | [diff] [blame] | 2854 | } |
| 2855 | |
| 2856 | TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoStencilFormat) { |
| 2857 | TEST_DESCRIPTION("Bind pipeline that has RenderingInfo StencilFormat incompatible with previously used pipeline"); |
| 2858 | |
| 2859 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2860 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2861 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2862 | |
| 2863 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2864 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2865 | return; |
| 2866 | } |
| 2867 | if (!AreRequestedExtensionsEnabled()) { |
| 2868 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2869 | return; |
| 2870 | } |
| 2871 | |
| 2872 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2873 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 2874 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2875 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2876 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2877 | return; |
| 2878 | } |
| 2879 | |
| 2880 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2881 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2882 | |
| 2883 | m_errorMonitor->ExpectSuccess(); |
| 2884 | |
| 2885 | std::vector<VkFormat> stencil_formats; |
| 2886 | const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT}; |
| 2887 | for (uint32_t i = 0; i < size(ds_formats); ++i) { |
| 2888 | VkFormatProperties format_props; |
| 2889 | vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props); |
| 2890 | |
| 2891 | if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { |
| 2892 | stencil_formats.push_back(ds_formats[i]); |
| 2893 | } |
| 2894 | } |
| 2895 | |
| 2896 | if (stencil_formats.size() < 2) { |
| 2897 | printf("%s Test requires 2 stencil formats, skipping test.\n", kSkipPrefix); |
| 2898 | return; |
| 2899 | } |
| 2900 | |
| 2901 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 2902 | pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[0]; |
| 2903 | |
| 2904 | auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 2905 | |
| 2906 | CreatePipelineHelper pipe1(*this); |
| 2907 | pipe1.InitInfo(); |
| 2908 | pipe1.gp_ci_.pNext = &pipeline_rendering_info; |
| 2909 | pipe1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2910 | pipe1.InitState(); |
| 2911 | pipe1.ds_ci_ = ds_ci; |
| 2912 | pipe1.CreateGraphicsPipeline(); |
| 2913 | |
| 2914 | pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[1]; |
| 2915 | |
| 2916 | CreatePipelineHelper pipe2(*this); |
| 2917 | pipe2.InitInfo(); |
| 2918 | pipe2.gp_ci_.pNext = &pipeline_rendering_info; |
| 2919 | pipe2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 2920 | pipe2.InitState(); |
| 2921 | pipe2.ds_ci_ = ds_ci; |
| 2922 | pipe2.CreateGraphicsPipeline(); |
| 2923 | |
| 2924 | VkImageObj image(m_device); |
| 2925 | image.Init(32, 32, 1, stencil_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 2926 | VkImageView stencil_image_view = image.targetView(stencil_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2927 | |
| 2928 | VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 2929 | stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL; |
| 2930 | stencil_attachment.imageView = stencil_image_view; |
| 2931 | |
| 2932 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 2933 | begin_rendering_info.layerCount = 1; |
| 2934 | begin_rendering_info.pStencilAttachment = &stencil_attachment; |
| 2935 | |
| 2936 | m_commandBuffer->begin(); |
| 2937 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 2938 | |
| 2939 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_); |
| 2940 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 2941 | |
| 2942 | m_errorMonitor->VerifyNotFound(); |
| 2943 | |
| 2944 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06194"); |
| 2945 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_); |
| 2946 | m_errorMonitor->VerifyFound(); |
| 2947 | |
| 2948 | m_commandBuffer->EndRendering(); |
| 2949 | m_commandBuffer->end(); |
| 2950 | } |
ziga-lunarg | 155ed45 | 2022-04-21 23:54:06 +0200 | [diff] [blame] | 2951 | |
| 2952 | TEST_F(VkLayerTest, DynamicRenderingWithInvalidShaderLayerBuiltIn) { |
| 2953 | TEST_DESCRIPTION("Create invalid pipeline that writes to Layer built-in"); |
| 2954 | |
| 2955 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2956 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2957 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 2958 | |
| 2959 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 2960 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 2961 | return; |
| 2962 | } |
| 2963 | if (!AreRequestedExtensionsEnabled()) { |
| 2964 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 2965 | return; |
| 2966 | } |
| 2967 | |
| 2968 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 2969 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(&dynamic_rendering_features); |
| 2970 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features); |
| 2971 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 2972 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 2973 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 2974 | return; |
| 2975 | } |
| 2976 | if (multiview_features.multiview == VK_FALSE) { |
| 2977 | printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix); |
| 2978 | return; |
| 2979 | } |
| 2980 | if (multiview_features.multiviewGeometryShader == VK_FALSE) { |
| 2981 | printf("%s Test requires (unsupported) multiviewGeometryShader , skipping\n", kSkipPrefix); |
| 2982 | return; |
| 2983 | } |
| 2984 | |
| 2985 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 2986 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2987 | |
| 2988 | static char const *gsSource = R"glsl( |
| 2989 | #version 450 |
| 2990 | layout (triangles) in; |
| 2991 | layout (triangle_strip) out; |
| 2992 | layout (max_vertices = 1) out; |
| 2993 | void main() { |
| 2994 | gl_Position = vec4(1.0, 0.5, 0.5, 0.0); |
| 2995 | EmitVertex(); |
| 2996 | gl_Layer = 4; |
| 2997 | } |
| 2998 | )glsl"; |
| 2999 | |
| 3000 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 3001 | VkShaderObj gs(this, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT); |
| 3002 | |
| 3003 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3004 | |
| 3005 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3006 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3007 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 3008 | pipeline_rendering_info.viewMask = 0x1; |
| 3009 | |
| 3010 | CreatePipelineHelper pipe(*this); |
| 3011 | pipe.InitInfo(); |
| 3012 | pipe.shader_stages_ = {vs.GetStageCreateInfo(), gs.GetStageCreateInfo(), pipe.fs_->GetStageCreateInfo()}; |
| 3013 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 3014 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3015 | pipe.InitState(); |
| 3016 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06059"); |
| 3017 | pipe.CreateGraphicsPipeline(); |
| 3018 | m_errorMonitor->VerifyFound(); |
| 3019 | } |
ziga-lunarg | 6feb463 | 2022-04-22 00:20:21 +0200 | [diff] [blame] | 3020 | |
| 3021 | TEST_F(VkLayerTest, DynamicRenderingWithInputAttachmentCapability) { |
| 3022 | TEST_DESCRIPTION("Create invalid pipeline that uses InputAttachment capability"); |
| 3023 | |
| 3024 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3025 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3026 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3027 | |
| 3028 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3029 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3030 | return; |
| 3031 | } |
| 3032 | if (!AreRequestedExtensionsEnabled()) { |
| 3033 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3034 | return; |
| 3035 | } |
| 3036 | |
| 3037 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3038 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3039 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3040 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3041 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3042 | return; |
| 3043 | } |
| 3044 | |
| 3045 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3046 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3047 | |
| 3048 | const std::string fsSource = R"( |
| 3049 | OpCapability Shader |
| 3050 | OpCapability InputAttachment |
| 3051 | %1 = OpExtInstImport "GLSL.std.450" |
| 3052 | OpMemoryModel Logical GLSL450 |
| 3053 | OpEntryPoint Fragment %main "main" |
| 3054 | OpExecutionMode %main OriginUpperLeft |
| 3055 | |
| 3056 | ; Debug Information |
| 3057 | OpSource GLSL 450 |
| 3058 | OpName %main "main" ; id %4 |
| 3059 | |
| 3060 | ; Types, variables and constants |
| 3061 | %void = OpTypeVoid |
| 3062 | %3 = OpTypeFunction %void |
| 3063 | |
| 3064 | ; Function main |
| 3065 | %main = OpFunction %void None %3 |
| 3066 | %5 = OpLabel |
| 3067 | OpReturn |
| 3068 | OpFunctionEnd |
| 3069 | )"; |
| 3070 | |
| 3071 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_ASM); |
| 3072 | |
| 3073 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3074 | |
| 3075 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3076 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3077 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 3078 | |
| 3079 | CreatePipelineHelper pipe(*this); |
| 3080 | pipe.InitInfo(); |
| 3081 | pipe.shader_stages_ = {pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 3082 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 3083 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3084 | pipe.InitState(); |
| 3085 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06061"); |
| 3086 | pipe.CreateGraphicsPipeline(); |
| 3087 | m_errorMonitor->VerifyFound(); |
| 3088 | } |
ziga-lunarg | a62b6ce | 2022-04-22 14:33:47 +0200 | [diff] [blame] | 3089 | |
| 3090 | TEST_F(VkLayerTest, InvalidRenderingInfoColorAttachmentFormat) { |
| 3091 | TEST_DESCRIPTION("Create pipeline with invalid color attachment format"); |
| 3092 | |
| 3093 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3094 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3095 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3096 | |
| 3097 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3098 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3099 | return; |
| 3100 | } |
| 3101 | if (!AreRequestedExtensionsEnabled()) { |
| 3102 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3103 | return; |
| 3104 | } |
| 3105 | |
| 3106 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3107 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3108 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3109 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3110 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3111 | return; |
| 3112 | } |
| 3113 | |
| 3114 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3115 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3116 | |
| 3117 | VkFormat color_format = VK_FORMAT_MAX_ENUM; |
| 3118 | |
| 3119 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3120 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3121 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 3122 | |
| 3123 | CreatePipelineHelper pipe(*this); |
| 3124 | pipe.InitInfo(); |
| 3125 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 3126 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3127 | pipe.InitState(); |
| 3128 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579"); |
| 3129 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580"); |
| 3130 | pipe.CreateGraphicsPipeline(); |
| 3131 | m_errorMonitor->VerifyFound(); |
| 3132 | } |
ziga-lunarg | f7fb920 | 2022-04-22 17:19:10 +0200 | [diff] [blame] | 3133 | |
| 3134 | TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryViewMask) { |
| 3135 | TEST_DESCRIPTION("Create pipeline with invalid view mask"); |
| 3136 | |
| 3137 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3138 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3139 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3140 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3141 | |
| 3142 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3143 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3144 | return; |
| 3145 | } |
| 3146 | if (!AreRequestedExtensionsEnabled()) { |
| 3147 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3148 | VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3149 | return; |
| 3150 | } |
| 3151 | |
| 3152 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3153 | auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features); |
| 3154 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features); |
| 3155 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3156 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3157 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3158 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3159 | return; |
| 3160 | } |
| 3161 | if (library_features.graphicsPipelineLibrary == VK_FALSE) { |
| 3162 | printf("%s Test requires (unsupported) graphicsPipelineLibrary , skipping\n", kSkipPrefix); |
| 3163 | return; |
| 3164 | } |
| 3165 | if (multiview_features.multiview == VK_FALSE) { |
| 3166 | printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix); |
| 3167 | return; |
| 3168 | } |
| 3169 | |
| 3170 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3171 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3172 | |
| 3173 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3174 | |
| 3175 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3176 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3177 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 3178 | |
| 3179 | auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info); |
| 3180 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT; |
| 3181 | auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info); |
| 3182 | |
| 3183 | VkPipelineColorBlendAttachmentState color_blend_attachment_state = {}; |
| 3184 | auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>(); |
| 3185 | color_blend_state_create_info.attachmentCount = 1; |
| 3186 | color_blend_state_create_info.pAttachments = &color_blend_attachment_state; |
| 3187 | |
| 3188 | m_errorMonitor->ExpectSuccess(); |
| 3189 | CreatePipelineHelper lib(*this); |
| 3190 | lib.cb_ci_ = color_blend_state_create_info; |
| 3191 | lib.InitInfo(); |
| 3192 | lib.gp_ci_.pNext = &library_create_info; |
| 3193 | lib.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3194 | lib.InitState(); |
| 3195 | lib.CreateGraphicsPipeline(); |
| 3196 | m_errorMonitor->VerifyNotFound(); |
| 3197 | |
| 3198 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT; |
| 3199 | library_create_info.libraryCount = 1; |
| 3200 | library_create_info.pLibraries = &lib.pipeline_; |
| 3201 | pipeline_rendering_info.viewMask = 0x1; |
| 3202 | |
| 3203 | CreatePipelineHelper pipe(*this); |
| 3204 | pipe.InitInfo(); |
| 3205 | pipe.gp_ci_.pNext = &library_create_info; |
| 3206 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3207 | pipe.InitState(); |
| 3208 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626"); |
| 3209 | pipe.CreateGraphicsPipeline(); |
| 3210 | m_errorMonitor->VerifyFound(); |
| 3211 | } |
ziga-lunarg | e151ca6 | 2022-04-22 17:40:51 +0200 | [diff] [blame] | 3212 | |
| 3213 | TEST_F(VkLayerTest, InvalidAttachmentSampleCount) { |
| 3214 | TEST_DESCRIPTION("Create pipeline with invalid color attachment samples"); |
| 3215 | |
| 3216 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3217 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3218 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3219 | |
| 3220 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3221 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3222 | return; |
| 3223 | } |
| 3224 | if (!AreRequestedExtensionsEnabled()) { |
| 3225 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3226 | return; |
| 3227 | } |
| 3228 | |
| 3229 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3230 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3231 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3232 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3233 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3234 | return; |
| 3235 | } |
| 3236 | |
| 3237 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3238 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3239 | |
| 3240 | VkSampleCountFlagBits color_attachment_samples = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM; |
| 3241 | |
| 3242 | auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>(); |
| 3243 | samples_info.colorAttachmentCount = 1; |
| 3244 | samples_info.pColorAttachmentSamples = &color_attachment_samples; |
| 3245 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info); |
| 3246 | |
| 3247 | CreatePipelineHelper pipe(*this); |
| 3248 | pipe.InitInfo(); |
| 3249 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 3250 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3251 | pipe.InitState(); |
| 3252 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592"); |
| 3253 | pipe.CreateGraphicsPipeline(); |
| 3254 | m_errorMonitor->VerifyFound(); |
| 3255 | } |
ziga-lunarg | b81597d | 2022-04-22 19:11:51 +0200 | [diff] [blame] | 3256 | |
| 3257 | TEST_F(VkLayerTest, InvalidDynamicRenderingLibrariesViewMask) { |
| 3258 | TEST_DESCRIPTION("Create pipeline with libaries that have incompatible view mask"); |
| 3259 | |
| 3260 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3261 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3262 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3263 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3264 | |
| 3265 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3266 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3267 | return; |
| 3268 | } |
| 3269 | if (!AreRequestedExtensionsEnabled()) { |
| 3270 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3271 | VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3272 | return; |
| 3273 | } |
| 3274 | |
| 3275 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3276 | auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features); |
| 3277 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features); |
| 3278 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3279 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3280 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3281 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3282 | return; |
| 3283 | } |
| 3284 | if (library_features.graphicsPipelineLibrary == VK_FALSE) { |
| 3285 | printf("%s Test requires (unsupported) graphicsPipelineLibrary , skipping\n", kSkipPrefix); |
| 3286 | return; |
| 3287 | } |
| 3288 | if (multiview_features.multiview == VK_FALSE) { |
| 3289 | printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix); |
| 3290 | return; |
| 3291 | } |
| 3292 | |
| 3293 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3294 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3295 | |
| 3296 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3297 | |
| 3298 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3299 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3300 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 3301 | |
| 3302 | auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info); |
| 3303 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT; |
| 3304 | auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info); |
| 3305 | |
| 3306 | VkPipelineColorBlendAttachmentState color_blend_attachment_state = {}; |
| 3307 | auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>(); |
| 3308 | color_blend_state_create_info.attachmentCount = 1; |
| 3309 | color_blend_state_create_info.pAttachments = &color_blend_attachment_state; |
| 3310 | |
| 3311 | m_errorMonitor->ExpectSuccess(); |
| 3312 | CreatePipelineHelper lib1(*this); |
| 3313 | lib1.cb_ci_ = color_blend_state_create_info; |
| 3314 | lib1.InitInfo(); |
| 3315 | lib1.gp_ci_.pNext = &library_create_info; |
| 3316 | lib1.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3317 | lib1.InitState(); |
| 3318 | lib1.CreateGraphicsPipeline(); |
| 3319 | |
| 3320 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT; |
| 3321 | pipeline_rendering_info.viewMask = 0x1; |
| 3322 | |
| 3323 | auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>(); |
| 3324 | |
| 3325 | CreatePipelineHelper lib2(*this); |
| 3326 | lib2.cb_ci_ = color_blend_state_create_info; |
| 3327 | lib2.InitInfo(); |
| 3328 | lib2.gp_ci_.pNext = &library_create_info; |
| 3329 | lib2.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3330 | lib2.ds_ci_ = ds_ci; |
| 3331 | lib2.InitState(); |
| 3332 | lib2.CreateGraphicsPipeline(); |
| 3333 | m_errorMonitor->VerifyNotFound(); |
| 3334 | |
| 3335 | graphics_library_create_info.flags = |
| 3336 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT; |
| 3337 | library_create_info.libraryCount = 2; |
| 3338 | VkPipeline libraries[2] = {lib1.pipeline_, lib2.pipeline_}; |
| 3339 | library_create_info.pLibraries = libraries; |
| 3340 | pipeline_rendering_info.viewMask = 0; |
| 3341 | |
| 3342 | CreatePipelineHelper pipe(*this); |
| 3343 | pipe.InitInfo(); |
| 3344 | pipe.gp_ci_.pNext = &library_create_info; |
| 3345 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3346 | pipe.InitState(); |
| 3347 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06627"); |
| 3348 | pipe.CreateGraphicsPipeline(); |
| 3349 | m_errorMonitor->VerifyFound(); |
| 3350 | } |
ziga-lunarg | 2e30231 | 2022-04-22 19:47:32 +0200 | [diff] [blame] | 3351 | |
| 3352 | TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryRenderPass) { |
| 3353 | TEST_DESCRIPTION("Create pipeline with invalid library render pass"); |
| 3354 | |
| 3355 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3356 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3357 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3358 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3359 | |
| 3360 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3361 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3362 | return; |
| 3363 | } |
| 3364 | if (!AreRequestedExtensionsEnabled()) { |
| 3365 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3366 | VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3367 | return; |
| 3368 | } |
| 3369 | |
| 3370 | auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(); |
| 3371 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features); |
| 3372 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3373 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3374 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3375 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3376 | return; |
| 3377 | } |
| 3378 | if (library_features.graphicsPipelineLibrary == VK_FALSE) { |
| 3379 | printf("%s Test requires (unsupported) graphicsPipelineLibrary , skipping\n", kSkipPrefix); |
| 3380 | return; |
| 3381 | } |
| 3382 | |
| 3383 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3384 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3385 | |
| 3386 | VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3387 | |
| 3388 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3389 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3390 | pipeline_rendering_info.pColorAttachmentFormats = &color_format; |
| 3391 | |
| 3392 | auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info); |
| 3393 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT; |
| 3394 | auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info); |
| 3395 | |
| 3396 | VkPipelineColorBlendAttachmentState color_blend_attachment_state = {}; |
| 3397 | auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>(); |
| 3398 | color_blend_state_create_info.attachmentCount = 1; |
| 3399 | color_blend_state_create_info.pAttachments = &color_blend_attachment_state; |
| 3400 | |
| 3401 | m_errorMonitor->ExpectSuccess(); |
| 3402 | CreatePipelineHelper lib(*this); |
| 3403 | lib.cb_ci_ = color_blend_state_create_info; |
| 3404 | lib.InitInfo(); |
| 3405 | lib.gp_ci_.pNext = &library_create_info; |
| 3406 | lib.InitState(); |
| 3407 | lib.CreateGraphicsPipeline(); |
| 3408 | m_errorMonitor->VerifyNotFound(); |
| 3409 | |
| 3410 | graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT; |
| 3411 | library_create_info.libraryCount = 1; |
| 3412 | library_create_info.pLibraries = &lib.pipeline_; |
| 3413 | |
| 3414 | CreatePipelineHelper pipe(*this); |
| 3415 | pipe.InitInfo(); |
| 3416 | pipe.gp_ci_.pNext = &library_create_info; |
| 3417 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3418 | pipe.InitState(); |
| 3419 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06625"); |
| 3420 | pipe.CreateGraphicsPipeline(); |
| 3421 | m_errorMonitor->VerifyFound(); |
| 3422 | } |
ziga-lunarg | 7ba5a1c | 2022-04-22 19:56:49 +0200 | [diff] [blame] | 3423 | |
| 3424 | TEST_F(VkLayerTest, PipelineMissingMultisampleState) { |
| 3425 | TEST_DESCRIPTION("Create pipeline with missing multisample state"); |
| 3426 | |
| 3427 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3428 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3429 | AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3430 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3431 | |
| 3432 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3433 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3434 | return; |
| 3435 | } |
| 3436 | if (!AreRequestedExtensionsEnabled()) { |
| 3437 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3438 | VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 3439 | return; |
| 3440 | } |
| 3441 | |
| 3442 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3443 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3444 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3445 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3446 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3447 | return; |
| 3448 | } |
| 3449 | |
| 3450 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3451 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3452 | |
| 3453 | CreatePipelineHelper pipe(*this); |
| 3454 | pipe.InitInfo(); |
| 3455 | pipe.gp_ci_.pMultisampleState = nullptr; |
| 3456 | pipe.InitState(); |
| 3457 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06631"); |
| 3458 | pipe.CreateGraphicsPipeline(); |
| 3459 | m_errorMonitor->VerifyFound(); |
ziga-lunarg | 1422253 | 2022-04-22 23:27:17 +0200 | [diff] [blame] | 3460 | } |
| 3461 | |
| 3462 | TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayout) { |
| 3463 | TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout"); |
| 3464 | |
| 3465 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3466 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3467 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3468 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3469 | |
| 3470 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3471 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3472 | return; |
| 3473 | } |
| 3474 | if (!AreRequestedExtensionsEnabled()) { |
| 3475 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3476 | VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3477 | return; |
| 3478 | } |
| 3479 | |
| 3480 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3481 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3482 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3483 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3484 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3485 | return; |
| 3486 | } |
| 3487 | |
| 3488 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3489 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3490 | |
| 3491 | VkImageObj image(m_device); |
| 3492 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, |
| 3493 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0); |
| 3494 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3495 | |
| 3496 | auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 3497 | rendering_fragment_density.imageView = image_view; |
| 3498 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 3499 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3500 | begin_rendering_info.layerCount = 1; |
| 3501 | |
| 3502 | m_commandBuffer->begin(); |
| 3503 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06157"); |
| 3504 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3505 | m_errorMonitor->VerifyFound(); |
| 3506 | m_commandBuffer->end(); |
| 3507 | } |
ziga-lunarg | a81df9d | 2022-04-22 23:33:13 +0200 | [diff] [blame] | 3508 | |
| 3509 | TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentUsage) { |
| 3510 | TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout"); |
| 3511 | |
| 3512 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3513 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3514 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3515 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3516 | |
| 3517 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3518 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3519 | return; |
| 3520 | } |
| 3521 | if (!AreRequestedExtensionsEnabled()) { |
| 3522 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3523 | VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3524 | return; |
| 3525 | } |
| 3526 | |
| 3527 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3528 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3529 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3530 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3531 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3532 | return; |
| 3533 | } |
| 3534 | |
| 3535 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3536 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3537 | |
| 3538 | VkImageObj image(m_device); |
| 3539 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); |
| 3540 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3541 | |
| 3542 | auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 3543 | rendering_fragment_density.imageView = image_view; |
| 3544 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3545 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3546 | begin_rendering_info.layerCount = 1; |
| 3547 | |
| 3548 | m_commandBuffer->begin(); |
| 3549 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06158"); |
| 3550 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3551 | m_errorMonitor->VerifyFound(); |
| 3552 | m_commandBuffer->end(); |
| 3553 | } |
ziga-lunarg | 7c411b3 | 2022-04-22 23:37:48 +0200 | [diff] [blame] | 3554 | |
| 3555 | TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentCreateFlags) { |
| 3556 | TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid image create flags"); |
| 3557 | |
| 3558 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3559 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3560 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3561 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3562 | |
| 3563 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3564 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3565 | return; |
| 3566 | } |
| 3567 | if (!AreRequestedExtensionsEnabled()) { |
| 3568 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3569 | VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3570 | return; |
| 3571 | } |
| 3572 | |
| 3573 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3574 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3575 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3576 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3577 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3578 | return; |
| 3579 | } |
| 3580 | |
| 3581 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3582 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3583 | |
| 3584 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3585 | image_create_info.flags = VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT; |
| 3586 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3587 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3588 | image_create_info.extent = {32, 32, 4}; |
| 3589 | image_create_info.mipLevels = 1; |
| 3590 | image_create_info.arrayLayers = 1; |
| 3591 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3592 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3593 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT; |
| 3594 | |
| 3595 | VkImageObj image(m_device); |
| 3596 | image.Init(image_create_info); |
| 3597 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3598 | |
| 3599 | auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 3600 | rendering_fragment_density.imageView = image_view; |
| 3601 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3602 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3603 | begin_rendering_info.layerCount = 1; |
| 3604 | |
| 3605 | m_commandBuffer->begin(); |
| 3606 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06159"); |
| 3607 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3608 | m_errorMonitor->VerifyFound(); |
| 3609 | m_commandBuffer->end(); |
| 3610 | } |
ziga-lunarg | 66569a7 | 2022-04-22 23:43:26 +0200 | [diff] [blame] | 3611 | |
| 3612 | TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayerCount) { |
| 3613 | TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid layer count"); |
| 3614 | |
| 3615 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3616 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3617 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3618 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3619 | |
| 3620 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3621 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3622 | return; |
| 3623 | } |
| 3624 | if (!AreRequestedExtensionsEnabled()) { |
| 3625 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3626 | VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3627 | return; |
| 3628 | } |
| 3629 | |
| 3630 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3631 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features); |
| 3632 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3633 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3634 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3635 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3636 | return; |
| 3637 | } |
| 3638 | if (!multiview_features.multiview) { |
| 3639 | printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix); |
| 3640 | return; |
| 3641 | } |
| 3642 | |
| 3643 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3644 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3645 | |
| 3646 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3647 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3648 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3649 | image_create_info.extent = {32, 32, 4}; |
| 3650 | image_create_info.mipLevels = 1; |
| 3651 | image_create_info.arrayLayers = 2; |
| 3652 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3653 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3654 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT; |
| 3655 | |
| 3656 | VkImageObj image(m_device); |
| 3657 | image.Init(image_create_info); |
| 3658 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3659 | |
| 3660 | auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(); |
| 3661 | rendering_fragment_density.imageView = image_view; |
| 3662 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3663 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3664 | begin_rendering_info.layerCount = 1; |
| 3665 | begin_rendering_info.viewMask = 0x1; |
| 3666 | |
| 3667 | m_commandBuffer->begin(); |
| 3668 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160"); |
| 3669 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3670 | m_errorMonitor->VerifyFound(); |
| 3671 | m_commandBuffer->end(); |
| 3672 | } |
ziga-lunarg | 323c11d | 2022-04-22 23:56:32 +0200 | [diff] [blame] | 3673 | |
| 3674 | TEST_F(VkLayerTest, InvalidRenderingPNextImageView) { |
| 3675 | TEST_DESCRIPTION( |
| 3676 | "Use different image views in VkRenderingFragmentShadingRateAttachmentInfoKHR and " |
| 3677 | "VkRenderingFragmentDensityMapAttachmentInfoEXT"); |
| 3678 | |
| 3679 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3680 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3681 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 3682 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 3683 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3684 | |
| 3685 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3686 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3687 | return; |
| 3688 | } |
| 3689 | if (!AreRequestedExtensionsEnabled()) { |
| 3690 | printf("%s %s or %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3691 | VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 3692 | return; |
| 3693 | } |
| 3694 | |
| 3695 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3696 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features); |
| 3697 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3698 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3699 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3700 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3701 | return; |
| 3702 | } |
| 3703 | if (!multiview_features.multiview) { |
| 3704 | printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix); |
| 3705 | return; |
| 3706 | } |
| 3707 | |
| 3708 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3709 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3710 | |
| 3711 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 3712 | |
| 3713 | auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 3714 | vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2); |
| 3715 | |
| 3716 | VkImageObj image1(m_device); |
| 3717 | image1.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, |
| 3718 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, |
| 3719 | VK_IMAGE_TILING_LINEAR, 0); |
| 3720 | VkImageView image_view1 = image1.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3721 | VkImageObj image2(m_device); |
| 3722 | image2.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, |
| 3723 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0); |
| 3724 | VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 3725 | |
| 3726 | auto rendering_fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>(); |
| 3727 | rendering_fragment_shading_rate.imageView = image_view1; |
| 3728 | rendering_fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3729 | rendering_fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 3730 | auto rendering_fragment_density = |
| 3731 | LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(&rendering_fragment_shading_rate); |
| 3732 | rendering_fragment_density.imageView = image_view2; |
| 3733 | rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3734 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density); |
| 3735 | begin_rendering_info.layerCount = 1; |
| 3736 | begin_rendering_info.viewMask = 0x1; |
| 3737 | |
| 3738 | m_commandBuffer->begin(); |
| 3739 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06126"); |
| 3740 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3741 | m_errorMonitor->VerifyFound(); |
| 3742 | m_commandBuffer->end(); |
| 3743 | } |
ziga-lunarg | 95f20d4 | 2022-04-23 00:06:42 +0200 | [diff] [blame] | 3744 | |
| 3745 | TEST_F(VkLayerTest, InvalidRenderingRenderArea) { |
| 3746 | TEST_DESCRIPTION("Use negative offset in RenderingInfo render area"); |
| 3747 | |
| 3748 | SetTargetApiVersion(VK_API_VERSION_1_0); |
| 3749 | AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 3750 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3751 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3752 | |
| 3753 | if (DeviceValidationVersion() != VK_API_VERSION_1_0) { |
| 3754 | printf("%s Tests requires Vulkan 1.0, skipping test\n", kSkipPrefix); |
| 3755 | return; |
| 3756 | } |
| 3757 | if (!AreRequestedExtensionsEnabled()) { |
| 3758 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3759 | return; |
| 3760 | } |
| 3761 | |
| 3762 | auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>( |
| 3763 | vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR")); |
| 3764 | ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr); |
| 3765 | |
| 3766 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(); |
| 3767 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features); |
| 3768 | vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2); |
| 3769 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3770 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3771 | return; |
| 3772 | } |
| 3773 | |
| 3774 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3775 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3776 | |
| 3777 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 3778 | begin_rendering_info.layerCount = 1; |
| 3779 | begin_rendering_info.renderArea.offset.x = -1; |
ziga-lunarg | 9b6a95f | 2022-04-23 00:13:38 +0200 | [diff] [blame] | 3780 | begin_rendering_info.renderArea.extent.width = 32; |
| 3781 | begin_rendering_info.renderArea.extent.height = 32; |
ziga-lunarg | 95f20d4 | 2022-04-23 00:06:42 +0200 | [diff] [blame] | 3782 | |
| 3783 | m_commandBuffer->begin(); |
| 3784 | |
| 3785 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06071"); |
| 3786 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3787 | m_errorMonitor->VerifyFound(); |
| 3788 | |
| 3789 | begin_rendering_info.renderArea.offset.x = 0; |
| 3790 | begin_rendering_info.renderArea.offset.y = -1; |
| 3791 | |
| 3792 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06072"); |
| 3793 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3794 | m_errorMonitor->VerifyFound(); |
| 3795 | |
ziga-lunarg | 9b6a95f | 2022-04-23 00:13:38 +0200 | [diff] [blame] | 3796 | begin_rendering_info.renderArea.offset.y = 0; |
| 3797 | begin_rendering_info.renderArea.offset.x = m_device->phy().properties().limits.maxFramebufferWidth - 16; |
| 3798 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06073"); |
| 3799 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3800 | m_errorMonitor->VerifyFound(); |
| 3801 | |
| 3802 | begin_rendering_info.renderArea.offset.x = 0; |
| 3803 | begin_rendering_info.renderArea.offset.y = m_device->phy().properties().limits.maxFramebufferHeight - 16; |
| 3804 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06074"); |
| 3805 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3806 | m_errorMonitor->VerifyFound(); |
| 3807 | |
ziga-lunarg | 95f20d4 | 2022-04-23 00:06:42 +0200 | [diff] [blame] | 3808 | m_commandBuffer->end(); |
| 3809 | } |
ziga-lunarg | 6662a88 | 2022-04-23 00:21:27 +0200 | [diff] [blame] | 3810 | |
| 3811 | TEST_F(VkLayerTest, InvalidRenderingInfoViewMask) { |
| 3812 | TEST_DESCRIPTION("Use negative offset in RenderingInfo render area"); |
| 3813 | |
| 3814 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3815 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3816 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3817 | |
| 3818 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3819 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3820 | return; |
| 3821 | } |
| 3822 | if (!AreRequestedExtensionsEnabled()) { |
| 3823 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3824 | return; |
| 3825 | } |
| 3826 | |
| 3827 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 3828 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features); |
| 3829 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3830 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3831 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3832 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3833 | return; |
| 3834 | } |
| 3835 | if (multiview_features.multiview == VK_FALSE) { |
| 3836 | printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix); |
| 3837 | return; |
| 3838 | } |
| 3839 | |
| 3840 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3841 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3842 | |
| 3843 | VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>(); |
| 3844 | VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props); |
| 3845 | vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2); |
| 3846 | |
| 3847 | if (multiview_props.maxMultiviewViewCount == 32) { |
| 3848 | printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix); |
| 3849 | return; |
| 3850 | } |
| 3851 | |
| 3852 | auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 3853 | begin_rendering_info.layerCount = 1; |
| 3854 | begin_rendering_info.renderArea.extent.width = 32; |
| 3855 | begin_rendering_info.renderArea.extent.height = 32; |
| 3856 | begin_rendering_info.viewMask = 1u << multiview_props.maxMultiviewViewCount; |
| 3857 | |
| 3858 | m_commandBuffer->begin(); |
| 3859 | |
| 3860 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06128"); |
| 3861 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3862 | m_errorMonitor->VerifyFound(); |
| 3863 | |
| 3864 | m_commandBuffer->end(); |
| 3865 | } |
ziga-lunarg | ae75b8a | 2022-04-23 10:54:37 +0200 | [diff] [blame] | 3866 | |
| 3867 | TEST_F(VkLayerTest, InvalidRenderingColorAttachmentFormat) { |
| 3868 | TEST_DESCRIPTION("Use format with missing potential format features in rendering color attachment"); |
| 3869 | |
| 3870 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3871 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3872 | AddRequiredExtensions(VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME); |
| 3873 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3874 | |
| 3875 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3876 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3877 | return; |
| 3878 | } |
| 3879 | if (!AreRequestedExtensionsEnabled()) { |
| 3880 | printf("%s %s or %s is not supported, skipping test.\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 3881 | VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME); |
| 3882 | return; |
| 3883 | } |
| 3884 | |
| 3885 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 3886 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3887 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3888 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3889 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3890 | return; |
| 3891 | } |
| 3892 | |
| 3893 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3894 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3895 | |
| 3896 | VkFormat format = FindSupportedDepthStencilFormat(gpu()); |
| 3897 | if (format == VK_FORMAT_UNDEFINED) { |
| 3898 | printf("%s No Depth + Stencil format found. Skipped.\n", kSkipPrefix); |
| 3899 | return; |
| 3900 | } |
| 3901 | |
| 3902 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 3903 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 3904 | pipeline_rendering_info.pColorAttachmentFormats = &format; |
| 3905 | |
| 3906 | CreatePipelineHelper pipe(*this); |
| 3907 | pipe.InitInfo(); |
| 3908 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 3909 | pipe.gp_ci_.renderPass = VK_NULL_HANDLE; |
| 3910 | pipe.InitState(); |
| 3911 | |
| 3912 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06582"); |
| 3913 | pipe.CreateGraphicsPipeline(); |
| 3914 | m_errorMonitor->VerifyFound(); |
| 3915 | } |
ziga-lunarg | eac390f | 2022-04-23 11:05:28 +0200 | [diff] [blame] | 3916 | |
| 3917 | TEST_F(VkLayerTest, InvalidResolveModeWithIntegerColorFormat) { |
| 3918 | TEST_DESCRIPTION("Use invalid resolve mode with integer color format"); |
| 3919 | |
| 3920 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3921 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3922 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3923 | |
| 3924 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3925 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3926 | return; |
| 3927 | } |
| 3928 | if (!AreRequestedExtensionsEnabled()) { |
| 3929 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3930 | return; |
| 3931 | } |
| 3932 | |
| 3933 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 3934 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3935 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3936 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3937 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3938 | return; |
| 3939 | } |
| 3940 | |
| 3941 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 3942 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3943 | |
| 3944 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 3945 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3946 | image_create_info.format = VK_FORMAT_R8G8B8A8_UINT; |
| 3947 | image_create_info.extent = {32, 32, 4}; |
| 3948 | image_create_info.mipLevels = 1; |
| 3949 | image_create_info.arrayLayers = 1; |
| 3950 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 3951 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3952 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 3953 | VkImageObj image(m_device); |
| 3954 | image.Init(image_create_info); |
| 3955 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 3956 | |
| 3957 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 3958 | color_attachment.imageView = image_view; |
| 3959 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 3960 | color_attachment.resolveMode = VK_RESOLVE_MODE_MAX_BIT; |
| 3961 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 3962 | |
| 3963 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 3964 | begin_rendering_info.colorAttachmentCount = 1; |
| 3965 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 3966 | begin_rendering_info.layerCount = 1; |
| 3967 | |
| 3968 | m_commandBuffer->begin(); |
| 3969 | |
| 3970 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06130"); |
| 3971 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 3972 | m_errorMonitor->VerifyFound(); |
| 3973 | |
| 3974 | m_commandBuffer->end(); |
| 3975 | } |
ziga-lunarg | df2a320 | 2022-04-23 11:07:46 +0200 | [diff] [blame] | 3976 | |
| 3977 | TEST_F(VkLayerTest, InvalidResolveModeSamples) { |
| 3978 | TEST_DESCRIPTION("Use invalid sample count with resolve mode that is not none"); |
| 3979 | |
| 3980 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 3981 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3982 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3983 | |
| 3984 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 3985 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 3986 | return; |
| 3987 | } |
| 3988 | if (!AreRequestedExtensionsEnabled()) { |
| 3989 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 3990 | return; |
| 3991 | } |
| 3992 | |
| 3993 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 3994 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 3995 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 3996 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 3997 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 3998 | return; |
| 3999 | } |
| 4000 | |
| 4001 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4002 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4003 | |
| 4004 | VkImageObj image(m_device); |
| 4005 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4006 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4007 | |
| 4008 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4009 | color_attachment.imageView = image_view; |
| 4010 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4011 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4012 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 4013 | |
| 4014 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4015 | begin_rendering_info.colorAttachmentCount = 1; |
| 4016 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4017 | begin_rendering_info.layerCount = 1; |
| 4018 | |
| 4019 | m_commandBuffer->begin(); |
| 4020 | |
| 4021 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06132"); |
| 4022 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4023 | m_errorMonitor->VerifyFound(); |
| 4024 | |
| 4025 | m_commandBuffer->end(); |
| 4026 | } |
ziga-lunarg | b7693aa | 2022-04-23 11:21:57 +0200 | [diff] [blame] | 4027 | |
| 4028 | TEST_F(VkLayerTest, InvalidResolveImageViewSamples) { |
| 4029 | TEST_DESCRIPTION("Use resolve image view with invalid sample count"); |
| 4030 | |
| 4031 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4032 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4033 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4034 | |
| 4035 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4036 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4037 | return; |
| 4038 | } |
| 4039 | if (!AreRequestedExtensionsEnabled()) { |
| 4040 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4041 | return; |
| 4042 | } |
| 4043 | |
| 4044 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4045 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4046 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4047 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4048 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4049 | return; |
| 4050 | } |
| 4051 | |
| 4052 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4053 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4054 | |
| 4055 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4056 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4057 | image_create_info.format = VK_FORMAT_R8G8B8A8_UINT; |
| 4058 | image_create_info.extent = {32, 32, 4}; |
| 4059 | image_create_info.mipLevels = 1; |
| 4060 | image_create_info.arrayLayers = 1; |
| 4061 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4062 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4063 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4064 | |
| 4065 | VkImageObj image(m_device); |
| 4066 | image.Init(image_create_info); |
| 4067 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 4068 | |
| 4069 | VkImageObj resolve_image(m_device); |
| 4070 | resolve_image.Init(image_create_info); |
| 4071 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 4072 | |
| 4073 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4074 | color_attachment.imageView = image_view; |
| 4075 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4076 | color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; |
| 4077 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 4078 | color_attachment.resolveImageView = resolve_image_view; |
| 4079 | |
| 4080 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4081 | begin_rendering_info.colorAttachmentCount = 1; |
| 4082 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4083 | begin_rendering_info.layerCount = 1; |
| 4084 | |
| 4085 | m_commandBuffer->begin(); |
| 4086 | |
| 4087 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06133"); |
| 4088 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4089 | m_errorMonitor->VerifyFound(); |
| 4090 | |
| 4091 | m_commandBuffer->end(); |
ziga-lunarg | d12cbce | 2022-04-23 11:35:20 +0200 | [diff] [blame] | 4092 | } |
| 4093 | |
| 4094 | TEST_F(VkLayerTest, InvalidResolveImageViewFormatMatch) { |
| 4095 | TEST_DESCRIPTION("Use resolve image view with different format from image view"); |
| 4096 | |
| 4097 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4098 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4099 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4100 | |
| 4101 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4102 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4103 | return; |
| 4104 | } |
| 4105 | if (!AreRequestedExtensionsEnabled()) { |
| 4106 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4107 | return; |
| 4108 | } |
| 4109 | |
| 4110 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4111 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4112 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4113 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4114 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4115 | return; |
| 4116 | } |
| 4117 | |
| 4118 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4119 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4120 | |
| 4121 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4122 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4123 | image_create_info.format = VK_FORMAT_R8G8B8A8_UINT; |
| 4124 | image_create_info.extent = {32, 32, 4}; |
| 4125 | image_create_info.mipLevels = 1; |
| 4126 | image_create_info.arrayLayers = 1; |
| 4127 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4128 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4129 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4130 | |
| 4131 | VkImageObj image(m_device); |
| 4132 | image.Init(image_create_info); |
| 4133 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT); |
| 4134 | |
| 4135 | VkImageObj resolve_image(m_device); |
| 4136 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4137 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4138 | |
| 4139 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4140 | color_attachment.imageView = image_view; |
| 4141 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4142 | color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; |
| 4143 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 4144 | color_attachment.resolveImageView = resolve_image_view; |
| 4145 | |
| 4146 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4147 | begin_rendering_info.colorAttachmentCount = 1; |
| 4148 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4149 | begin_rendering_info.layerCount = 1; |
| 4150 | |
| 4151 | m_commandBuffer->begin(); |
| 4152 | |
| 4153 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06134"); |
| 4154 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4155 | m_errorMonitor->VerifyFound(); |
| 4156 | |
| 4157 | m_commandBuffer->end(); |
| 4158 | } |
ziga-lunarg | e579a3b | 2022-04-23 11:38:02 +0200 | [diff] [blame] | 4159 | |
| 4160 | TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewLayout) { |
| 4161 | TEST_DESCRIPTION("Use rendering attachment image view with invalid layout"); |
| 4162 | |
| 4163 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4164 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4165 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4166 | |
| 4167 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4168 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4169 | return; |
| 4170 | } |
| 4171 | if (!AreRequestedExtensionsEnabled()) { |
| 4172 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4173 | return; |
| 4174 | } |
| 4175 | |
| 4176 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4177 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4178 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4179 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4180 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4181 | return; |
| 4182 | } |
| 4183 | |
| 4184 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4185 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4186 | |
| 4187 | VkImageObj image(m_device); |
| 4188 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4189 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4190 | |
| 4191 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4192 | color_attachment.imageView = image_view; |
| 4193 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 4194 | |
| 4195 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4196 | begin_rendering_info.colorAttachmentCount = 1; |
| 4197 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4198 | begin_rendering_info.layerCount = 1; |
| 4199 | |
| 4200 | m_commandBuffer->begin(); |
| 4201 | |
| 4202 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06135"); |
| 4203 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4204 | m_errorMonitor->VerifyFound(); |
| 4205 | |
| 4206 | m_commandBuffer->end(); |
| 4207 | } |
ziga-lunarg | 409f821 | 2022-04-23 11:40:53 +0200 | [diff] [blame] | 4208 | |
| 4209 | TEST_F(VkLayerTest, InvalidResolveImageViewLayout) { |
| 4210 | TEST_DESCRIPTION("Use resolve image view with invalid layout"); |
| 4211 | |
| 4212 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4213 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4214 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4215 | |
| 4216 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4217 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4218 | return; |
| 4219 | } |
| 4220 | if (!AreRequestedExtensionsEnabled()) { |
| 4221 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4222 | return; |
| 4223 | } |
| 4224 | |
| 4225 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4226 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4227 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4228 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4229 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4230 | return; |
| 4231 | } |
| 4232 | |
| 4233 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4234 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4235 | |
| 4236 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4237 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4238 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4239 | image_create_info.extent = {32, 32, 4}; |
| 4240 | image_create_info.mipLevels = 1; |
| 4241 | image_create_info.arrayLayers = 1; |
| 4242 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4243 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4244 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4245 | |
| 4246 | VkImageObj image(m_device); |
| 4247 | image.Init(image_create_info); |
| 4248 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4249 | |
| 4250 | VkImageObj resolve_image(m_device); |
| 4251 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4252 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4253 | |
| 4254 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4255 | color_attachment.imageView = image_view; |
| 4256 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4257 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4258 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 4259 | color_attachment.resolveImageView = resolve_image_view; |
| 4260 | |
| 4261 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4262 | begin_rendering_info.colorAttachmentCount = 1; |
| 4263 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4264 | begin_rendering_info.layerCount = 1; |
| 4265 | |
| 4266 | m_commandBuffer->begin(); |
| 4267 | |
| 4268 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06136"); |
| 4269 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4270 | m_errorMonitor->VerifyFound(); |
| 4271 | |
| 4272 | m_commandBuffer->end(); |
| 4273 | } |
ziga-lunarg | bbbef24 | 2022-04-23 12:12:10 +0200 | [diff] [blame] | 4274 | |
| 4275 | TEST_F(VkLayerTest, InvalidResolveImageViewLayoutSeparateDepthStencil) { |
| 4276 | TEST_DESCRIPTION("Use resolve image view with invalid layout"); |
| 4277 | |
| 4278 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4279 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4280 | AddRequiredExtensions(VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME); |
| 4281 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4282 | |
| 4283 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4284 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4285 | return; |
| 4286 | } |
| 4287 | if (!AreRequestedExtensionsEnabled()) { |
| 4288 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 4289 | VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME); |
| 4290 | return; |
| 4291 | } |
| 4292 | |
| 4293 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4294 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4295 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4296 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4297 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4298 | return; |
| 4299 | } |
| 4300 | |
| 4301 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4302 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4303 | |
| 4304 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4305 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4306 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4307 | image_create_info.extent = {32, 32, 4}; |
| 4308 | image_create_info.mipLevels = 1; |
| 4309 | image_create_info.arrayLayers = 1; |
| 4310 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4311 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4312 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4313 | |
| 4314 | VkImageObj image(m_device); |
| 4315 | image.Init(image_create_info); |
| 4316 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4317 | |
| 4318 | VkImageObj resolve_image(m_device); |
| 4319 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4320 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4321 | |
| 4322 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4323 | color_attachment.imageView = image_view; |
| 4324 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4325 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4326 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL; |
| 4327 | color_attachment.resolveImageView = resolve_image_view; |
| 4328 | |
| 4329 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4330 | begin_rendering_info.colorAttachmentCount = 1; |
| 4331 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4332 | begin_rendering_info.layerCount = 1; |
| 4333 | |
| 4334 | m_commandBuffer->begin(); |
| 4335 | |
| 4336 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06137"); |
| 4337 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4338 | m_errorMonitor->VerifyFound(); |
| 4339 | |
| 4340 | m_commandBuffer->end(); |
| 4341 | } |
ziga-lunarg | 7d2c111 | 2022-04-23 12:17:33 +0200 | [diff] [blame] | 4342 | |
| 4343 | TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewShadingRateLayout) { |
| 4344 | TEST_DESCRIPTION("Use image view with invalid layout"); |
| 4345 | |
| 4346 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4347 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4348 | AddRequiredExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME); |
| 4349 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4350 | |
| 4351 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4352 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4353 | return; |
| 4354 | } |
| 4355 | if (!AreRequestedExtensionsEnabled()) { |
| 4356 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 4357 | VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME); |
| 4358 | return; |
| 4359 | } |
| 4360 | |
| 4361 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4362 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4363 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4364 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4365 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4366 | return; |
| 4367 | } |
| 4368 | |
| 4369 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4370 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4371 | |
| 4372 | VkImageObj image(m_device); |
| 4373 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4374 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4375 | |
| 4376 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4377 | color_attachment.imageView = image_view; |
| 4378 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV; |
| 4379 | |
| 4380 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4381 | begin_rendering_info.colorAttachmentCount = 1; |
| 4382 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4383 | begin_rendering_info.layerCount = 1; |
| 4384 | |
| 4385 | m_commandBuffer->begin(); |
| 4386 | |
| 4387 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06138"); |
| 4388 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06143"); |
| 4389 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4390 | m_errorMonitor->VerifyFound(); |
| 4391 | |
| 4392 | m_commandBuffer->end(); |
| 4393 | } |
| 4394 | |
| 4395 | TEST_F(VkLayerTest, InvalidResolveImageViewShadingRateLayout) { |
| 4396 | TEST_DESCRIPTION("Use resolve image view with invalid shading ratelayout"); |
| 4397 | |
| 4398 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4399 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4400 | AddRequiredExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME); |
| 4401 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4402 | |
| 4403 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4404 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4405 | return; |
| 4406 | } |
| 4407 | if (!AreRequestedExtensionsEnabled()) { |
| 4408 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 4409 | VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME); |
| 4410 | return; |
| 4411 | } |
| 4412 | |
| 4413 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4414 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4415 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4416 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4417 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4418 | return; |
| 4419 | } |
| 4420 | |
| 4421 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4422 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4423 | |
| 4424 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4425 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4426 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4427 | image_create_info.extent = {32, 32, 4}; |
| 4428 | image_create_info.mipLevels = 1; |
| 4429 | image_create_info.arrayLayers = 1; |
| 4430 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4431 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4432 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4433 | |
| 4434 | VkImageObj image(m_device); |
| 4435 | image.Init(image_create_info); |
| 4436 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4437 | |
| 4438 | VkImageObj resolve_image(m_device); |
| 4439 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4440 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4441 | |
| 4442 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4443 | color_attachment.imageView = image_view; |
| 4444 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4445 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4446 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV; |
| 4447 | color_attachment.resolveImageView = resolve_image_view; |
| 4448 | |
| 4449 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4450 | begin_rendering_info.colorAttachmentCount = 1; |
| 4451 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4452 | begin_rendering_info.layerCount = 1; |
| 4453 | |
| 4454 | m_commandBuffer->begin(); |
| 4455 | |
| 4456 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06139"); |
| 4457 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06144"); |
| 4458 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4459 | m_errorMonitor->VerifyFound(); |
| 4460 | |
| 4461 | m_commandBuffer->end(); |
| 4462 | } |
ziga-lunarg | e750395 | 2022-04-23 12:19:14 +0200 | [diff] [blame] | 4463 | |
| 4464 | TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewFragmentDensityLayout) { |
| 4465 | TEST_DESCRIPTION("Use image view with invalid layout"); |
| 4466 | |
| 4467 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4468 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4469 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 4470 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4471 | |
| 4472 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4473 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4474 | return; |
| 4475 | } |
| 4476 | if (!AreRequestedExtensionsEnabled()) { |
| 4477 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 4478 | VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 4479 | return; |
| 4480 | } |
| 4481 | |
| 4482 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4483 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4484 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4485 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4486 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4487 | return; |
| 4488 | } |
| 4489 | |
| 4490 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4491 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4492 | |
| 4493 | VkImageObj image(m_device); |
| 4494 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4495 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4496 | |
| 4497 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4498 | color_attachment.imageView = image_view; |
| 4499 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT; |
| 4500 | |
| 4501 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4502 | begin_rendering_info.colorAttachmentCount = 1; |
| 4503 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4504 | begin_rendering_info.layerCount = 1; |
| 4505 | |
| 4506 | m_commandBuffer->begin(); |
| 4507 | |
| 4508 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06140"); |
| 4509 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4510 | m_errorMonitor->VerifyFound(); |
| 4511 | |
| 4512 | m_commandBuffer->end(); |
ziga-lunarg | 10cd0fb | 2022-04-23 12:20:46 +0200 | [diff] [blame] | 4513 | } |
| 4514 | |
| 4515 | TEST_F(VkLayerTest, InvalidResolveImageViewFragmentDensityLayout) { |
| 4516 | TEST_DESCRIPTION("Use resolve image view with invalid fragment density layout"); |
| 4517 | |
| 4518 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4519 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4520 | AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 4521 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4522 | |
| 4523 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4524 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4525 | return; |
| 4526 | } |
| 4527 | if (!AreRequestedExtensionsEnabled()) { |
| 4528 | printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, |
| 4529 | VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 4530 | return; |
| 4531 | } |
| 4532 | |
| 4533 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4534 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4535 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4536 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4537 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4538 | return; |
| 4539 | } |
| 4540 | |
| 4541 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4542 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4543 | |
| 4544 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4545 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4546 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4547 | image_create_info.extent = {32, 32, 4}; |
| 4548 | image_create_info.mipLevels = 1; |
| 4549 | image_create_info.arrayLayers = 1; |
| 4550 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4551 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4552 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4553 | |
| 4554 | VkImageObj image(m_device); |
| 4555 | image.Init(image_create_info); |
| 4556 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4557 | |
| 4558 | VkImageObj resolve_image(m_device); |
| 4559 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4560 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4561 | |
| 4562 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4563 | color_attachment.imageView = image_view; |
| 4564 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4565 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4566 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT; |
| 4567 | color_attachment.resolveImageView = resolve_image_view; |
| 4568 | |
| 4569 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4570 | begin_rendering_info.colorAttachmentCount = 1; |
| 4571 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4572 | begin_rendering_info.layerCount = 1; |
| 4573 | |
| 4574 | m_commandBuffer->begin(); |
| 4575 | |
| 4576 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06141"); |
| 4577 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4578 | m_errorMonitor->VerifyFound(); |
| 4579 | |
| 4580 | m_commandBuffer->end(); |
| 4581 | } |
ziga-lunarg | dfa31d1 | 2022-04-23 12:22:18 +0200 | [diff] [blame^] | 4582 | |
| 4583 | TEST_F(VkLayerTest, InvalidResolveImageViewReadOnlyOptimalLayout) { |
| 4584 | TEST_DESCRIPTION("Use resolve image view with invalid read only optimal layout"); |
| 4585 | |
| 4586 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 4587 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4588 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 4589 | |
| 4590 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 4591 | printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix); |
| 4592 | return; |
| 4593 | } |
| 4594 | if (!AreRequestedExtensionsEnabled()) { |
| 4595 | printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 4596 | return; |
| 4597 | } |
| 4598 | |
| 4599 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
| 4600 | auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features); |
| 4601 | vk::GetPhysicalDeviceFeatures2(gpu(), &features2); |
| 4602 | if (dynamic_rendering_features.dynamicRendering == VK_FALSE) { |
| 4603 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 4604 | return; |
| 4605 | } |
| 4606 | |
| 4607 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 4608 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4609 | |
| 4610 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 4611 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4612 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4613 | image_create_info.extent = {32, 32, 4}; |
| 4614 | image_create_info.mipLevels = 1; |
| 4615 | image_create_info.arrayLayers = 1; |
| 4616 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 4617 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4618 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4619 | |
| 4620 | VkImageObj image(m_device); |
| 4621 | image.Init(image_create_info); |
| 4622 | VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4623 | |
| 4624 | VkImageObj resolve_image(m_device); |
| 4625 | resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
| 4626 | VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 4627 | |
| 4628 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
| 4629 | color_attachment.imageView = image_view; |
| 4630 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4631 | color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; |
| 4632 | color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL; |
| 4633 | color_attachment.resolveImageView = resolve_image_view; |
| 4634 | |
| 4635 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
| 4636 | begin_rendering_info.colorAttachmentCount = 1; |
| 4637 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 4638 | begin_rendering_info.layerCount = 1; |
| 4639 | |
| 4640 | m_commandBuffer->begin(); |
| 4641 | |
| 4642 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06142"); |
| 4643 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 4644 | m_errorMonitor->VerifyFound(); |
| 4645 | |
| 4646 | m_commandBuffer->end(); |
| 4647 | } |