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