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