From 6ba63887073d184511d53cbb540eaf546109eed2 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 11 Feb 2022 23:36:02 -0600 Subject: [PATCH] Actually test compatible depth/stencil attachment formats These tests claimed to test "compatible" depth resolve formats, i.e., resolving to a depth-only format from a depth/stencil format. However, it only set the depth-only format on the renderpass and not on the single-sampled image. This meant it was in violation of the following VU because the image view and attachment format didn't match: VUID-VkRenderPassBeginInfo-framebuffer-03216 If framebuffer was created with a VkFramebufferCreateInfo::flags value that included VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, each element of the pAttachments member of a VkRenderPassAttachmentBeginInfo structure included in the pNext chain must be a VkImageView of an image created with a value of VkImageViewCreateInfo::format equal to the corresponding value of VkAttachmentDescription::format in renderPass Unfortunately, once I fixed the format, it turned into a bit of a rabbit hole because aspects were also messed up various places and then layouts as well. Components: Vulkan Affects: dEQP-VK.renderpass2.depth_stencil_resolve.*separate_layouts.* Change-Id: I34f5dd2cbccae2a695cbe05a22908ba544b0a6a6 --- .../vktRenderPassDepthStencilResolveTests.cpp | 150 +++++++++++---------- 1 file changed, 78 insertions(+), 72 deletions(-) diff --git a/external/vulkancts/modules/vulkan/renderpass/vktRenderPassDepthStencilResolveTests.cpp b/external/vulkancts/modules/vulkan/renderpass/vktRenderPassDepthStencilResolveTests.cpp index c118860..756f8ad 100644 --- a/external/vulkancts/modules/vulkan/renderpass/vktRenderPassDepthStencilResolveTests.cpp +++ b/external/vulkancts/modules/vulkan/renderpass/vktRenderPassDepthStencilResolveTests.cpp @@ -85,6 +85,16 @@ de::SharedPtr safeSharedPtr (T* ptr) } } +VkImageAspectFlags +aspectFlagsForFormat(VkFormat vkformat) +{ + const tcu::TextureFormat format(mapVkFormat(vkformat)); + VkImageAspectFlags aspectFlags = + ((tcu::hasDepthComponent(format.order) ? static_cast(vk::VK_IMAGE_ASPECT_DEPTH_BIT) : 0u) | + (tcu::hasStencilComponent(format.order) ? static_cast(vk::VK_IMAGE_ASPECT_STENCIL_BIT) : 0u)); + return aspectFlags; +} + enum VerifyBuffer { VB_DEPTH = 0, @@ -112,6 +122,16 @@ struct TestConfig bool unusedResolve; tcu::Maybe compatibleFormat; bool sampleMask; + + VkFormat resolveFormat() const + { + return compatibleFormat ? compatibleFormat.get() : format; + } + + VkImageAspectFlags resolveAspectFlags() const + { + return aspectFlagsForFormat(resolveFormat()); + } }; // Auxiliar class to group depth formats by compatibility in bit size and format. Note there is at most one alternative format for @@ -177,9 +197,9 @@ protected: bool isSupportedFormat (Context& context, VkFormat format) const; VkSampleCountFlagBits sampleCountBitFromSampleCount (deUint32 count) const; - VkImageSp createImage (deUint32 sampleCount, VkImageUsageFlags additionalUsage = 0u); + VkImageSp createImage (VkFormat vkformat, deUint32 sampleCount, VkImageUsageFlags additionalUsage = 0u); AllocationSp createImageMemory (VkImageSp image); - VkImageViewSp createImageView (VkImageSp image, deUint32 baseArrayLayer); + VkImageViewSp createImageView (VkImageSp image, VkFormat vkformat, deUint32 baseArrayLayer); AllocationSp createBufferMemory (void); VkBufferSp createBuffer (void); @@ -232,13 +252,13 @@ DepthStencilResolveTest::DepthStencilResolveTest (Context& context, TestConfig c , m_commandPool (createCommandPool(context.getDeviceInterface(), context.getDevice(), VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, context.getUniversalQueueFamilyIndex())) - , m_multisampleImage (createImage(m_config.sampleCount, VK_IMAGE_USAGE_TRANSFER_SRC_BIT)) + , m_multisampleImage (createImage(m_config.format, m_config.sampleCount, VK_IMAGE_USAGE_TRANSFER_SRC_BIT)) , m_multisampleImageMemory (createImageMemory(m_multisampleImage)) - , m_multisampleImageView (createImageView(m_multisampleImage, 0u)) + , m_multisampleImageView (createImageView(m_multisampleImage, m_config.format, 0u)) - , m_singlesampleImage (createImage(1, (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | (config.unusedResolve ? static_cast(VK_IMAGE_USAGE_TRANSFER_DST_BIT) : 0u)))) + , m_singlesampleImage (createImage(m_config.resolveFormat(), 1, (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | (config.unusedResolve ? static_cast(VK_IMAGE_USAGE_TRANSFER_DST_BIT) : 0u)))) , m_singlesampleImageMemory (createImageMemory(m_singlesampleImage)) - , m_singlesampleImageView (createImageView(m_singlesampleImage, m_config.resolveBaseLayer)) + , m_singlesampleImageView (createImageView(m_singlesampleImage, m_config.resolveFormat(), m_config.resolveBaseLayer)) , m_buffer (createBuffer()) , m_bufferMemory (createBufferMemory()) @@ -252,7 +272,8 @@ DepthStencilResolveTest::DepthStencilResolveTest (Context& context, TestConfig c m_renderPass.push_back(createRenderPass(m_config.format, i)); m_renderPipeline.push_back(createRenderPipeline(*m_renderPass[i], i, *m_renderPipelineLayout)); } - m_framebuffer = createFramebuffer(*m_renderPass[0], m_multisampleImageView, m_singlesampleImageView); + m_framebuffer = createFramebuffer(m_config.compatibleFormat ? *m_renderPassCompatible : *m_renderPass[0], + m_multisampleImageView, m_singlesampleImageView); } DepthStencilResolveTest::~DepthStencilResolveTest (void) @@ -338,7 +359,7 @@ VkSampleCountFlagBits DepthStencilResolveTest::sampleCountBitFromSampleCount (de } } -VkImageSp DepthStencilResolveTest::createImage (deUint32 sampleCount, VkImageUsageFlags additionalUsage) +VkImageSp DepthStencilResolveTest::createImage (VkFormat vkformat, deUint32 sampleCount, VkImageUsageFlags additionalUsage) { const tcu::TextureFormat format(mapVkFormat(m_config.format)); const VkImageTiling imageTiling(VK_IMAGE_TILING_OPTIMAL); @@ -384,7 +405,7 @@ VkImageSp DepthStencilResolveTest::createImage (deUint32 sampleCount, VkImageUsa DE_NULL, 0u, VK_IMAGE_TYPE_2D, - m_config.format, + vkformat, imageExtent, 1u, m_config.imageLayers, @@ -409,11 +430,11 @@ AllocationSp DepthStencilResolveTest::createImageMemory (VkImageSp image) return safeSharedPtr(allocation.release()); } -VkImageViewSp DepthStencilResolveTest::createImageView (VkImageSp image, deUint32 baseArrayLayer) +VkImageViewSp DepthStencilResolveTest::createImageView (VkImageSp image, VkFormat vkformat, deUint32 baseArrayLayer) { const VkImageSubresourceRange range = { - m_config.aspectFlag, + aspectFlagsForFormat(vkformat), 0u, 1u, baseArrayLayer, @@ -427,7 +448,7 @@ VkImageViewSp DepthStencilResolveTest::createImageView (VkImageSp image, deUint3 0u, **image, (m_config.viewLayers > 1) ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D, - m_config.format, + vkformat, makeComponentMappingRGBA(), range, }; @@ -439,71 +460,41 @@ Move DepthStencilResolveTest::createRenderPass(VkFormat vkformat, const VkSampleCountFlagBits samples(sampleCountBitFromSampleCount(m_config.sampleCount)); VkImageLayout layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; - VkAttachmentReferenceStencilLayoutKHR stencilLayout = - { - VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR, - DE_NULL, - VK_IMAGE_LAYOUT_UNDEFINED, - }; - void * attachmentRefStencil = DE_NULL; + VkImageLayout stencilLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; VkImageLayout finalLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; - VkAttachmentDescriptionStencilLayoutKHR multisampleStencilFinalLayout = - { - VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR, - DE_NULL, - VK_IMAGE_LAYOUT_UNDEFINED, - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - }; - VkAttachmentDescriptionStencilLayoutKHR singlesampleStencilFinalLayout = - { - VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR, - DE_NULL, - VK_IMAGE_LAYOUT_UNDEFINED, - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - }; - void * multisampleAttachmentDescriptionStencil = DE_NULL; - void * singlesampleAttachmentDescriptionStencil = DE_NULL; + VkImageLayout stencilFinalLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; if (m_config.separateDepthStencilLayouts) { if (m_config.verifyBuffer == VB_DEPTH) { layout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL_KHR; - stencilLayout.stencilLayout = VK_IMAGE_LAYOUT_GENERAL; - finalLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; - multisampleStencilFinalLayout.stencilFinalLayout = VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL_KHR; // This aspect should be unused. - singlesampleStencilFinalLayout.stencilFinalLayout = VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL_KHR; // This aspect should be unused. + stencilLayout = VK_IMAGE_LAYOUT_GENERAL; } else { - layout = m_config.sampleMask ? VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR : VK_IMAGE_LAYOUT_GENERAL; - stencilLayout.stencilLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR; - finalLayout = VK_IMAGE_LAYOUT_GENERAL; // This aspect should be unused. - multisampleStencilFinalLayout.stencilFinalLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; - singlesampleStencilFinalLayout.stencilFinalLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; + layout = VK_IMAGE_LAYOUT_GENERAL; + stencilLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR; } - attachmentRefStencil = &stencilLayout; - multisampleAttachmentDescriptionStencil = &multisampleStencilFinalLayout; - singlesampleAttachmentDescriptionStencil = &singlesampleStencilFinalLayout; - } - - if (renderPassNo != 0) - { - multisampleStencilFinalLayout.stencilInitialLayout = stencilLayout.stencilLayout; - singlesampleStencilFinalLayout.stencilInitialLayout = stencilLayout.stencilLayout; } if (renderPassNo != m_numRenderPasses - 1) { finalLayout = layout; - multisampleStencilFinalLayout.stencilFinalLayout = layout; - singlesampleStencilFinalLayout.stencilFinalLayout = layout; + stencilFinalLayout = stencilLayout; } + const VkAttachmentDescriptionStencilLayoutKHR multisampleAttachmentStencilLayout = + { + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR, // VkStructureType sType; + DE_NULL, // const void* pNext; + (renderPassNo == 0) ? VK_IMAGE_LAYOUT_UNDEFINED : stencilLayout, // VkImageLayout initialLayout; + stencilFinalLayout, + }; const AttachmentDescription2 multisampleAttachment // VkAttachmentDescription2 ( // VkStructureType sType; - multisampleAttachmentDescriptionStencil, // const void* pNext; + m_config.separateDepthStencilLayouts ? &multisampleAttachmentStencilLayout : DE_NULL, // const void* pNext; 0u, // VkAttachmentDescriptionFlags flags; m_config.format, // VkFormat format; samples, // VkSampleCountFlagBits samples; @@ -514,30 +505,40 @@ Move DepthStencilResolveTest::createRenderPass(VkFormat vkformat, (renderPassNo == 0) ? VK_IMAGE_LAYOUT_UNDEFINED : layout, // VkImageLayout initialLayout; finalLayout // VkImageLayout finalLayout; ); + const VkAttachmentReferenceStencilLayoutKHR multisampleAttachmentRefStencilLayout = + { + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR, // VkStructureType sType; + DE_NULL, // const void* pNext; + stencilLayout // VkImageLayout stencilLayout; + }; const AttachmentReference2 multisampleAttachmentRef // VkAttachmentReference2 ( // VkStructureType sType; - attachmentRefStencil, // const void* pNext; + m_config.separateDepthStencilLayouts ? &multisampleAttachmentRefStencilLayout : DE_NULL, // const void* pNext; 0u, // deUint32 attachment; layout, // VkImageLayout layout; m_config.aspectFlag // VkImageAspectFlags aspectMask; ); vk::VkImageLayout singleSampleInitialLayout = (m_config.unusedResolve ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED); + vk::VkImageLayout singleSampleStencilInitialLayout = (m_config.unusedResolve ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED); if (renderPassNo != 0) + { singleSampleInitialLayout = layout; - if (m_config.separateDepthStencilLayouts && m_config.verifyBuffer == VB_STENCIL) - singlesampleStencilFinalLayout.stencilInitialLayout = singleSampleInitialLayout; - - const tcu::TextureFormat format (mapVkFormat(vkformat)); - VkImageAspectFlags aspectFlags = - ((tcu::hasDepthComponent(format.order) ? static_cast(vk::VK_IMAGE_ASPECT_DEPTH_BIT) : 0u) | - (tcu::hasStencilComponent(format.order) ? static_cast(vk::VK_IMAGE_ASPECT_STENCIL_BIT) : 0u)); + singleSampleStencilInitialLayout = stencilLayout; + } + const VkAttachmentDescriptionStencilLayoutKHR singlesampleAttachmentStencilLayout = + { + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR, // VkStructureType sType; + DE_NULL, // const void* pNext; + singleSampleStencilInitialLayout, // VkImageLayout initialLayout; + stencilFinalLayout, + }; const AttachmentDescription2 singlesampleAttachment // VkAttachmentDescription2 ( // VkStructureType sType; - singlesampleAttachmentDescriptionStencil, // const void* pNext; + m_config.separateDepthStencilLayouts ? &singlesampleAttachmentStencilLayout : DE_NULL, // const void* pNext; 0u, // VkAttachmentDescriptionFlags flags; vkformat, // VkFormat format; VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; @@ -548,13 +549,20 @@ Move DepthStencilResolveTest::createRenderPass(VkFormat vkformat, singleSampleInitialLayout, // VkImageLayout initialLayout; finalLayout // VkImageLayout finalLayout; ); - AttachmentReference2 singlesampleAttachmentRef // VkAttachmentReference2 + + const VkAttachmentReferenceStencilLayoutKHR singlesampleAttachmentRefStencilLayout = + { + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR, // VkStructureType sType; + DE_NULL, // const void* pNext; + stencilLayout // VkImageLayout stencilLayout; + }; + const AttachmentReference2 singlesampleAttachmentRef // VkAttachmentReference2 ( // VkStructureType sType; - attachmentRefStencil, // const void* pNext; + m_config.separateDepthStencilLayouts ? &singlesampleAttachmentRefStencilLayout : DE_NULL, // const void* pNext; ((m_config.unusedResolve || renderPassNo != m_numRenderPasses - 1) ? VK_ATTACHMENT_UNUSED : 1u), // deUint32 attachment; layout, // VkImageLayout layout; - aspectFlags // VkImageAspectFlags aspectMask; + aspectFlagsForFormat(vkformat) // VkImageAspectFlags aspectMask; ); std::vector attachments; @@ -832,12 +840,10 @@ void DepthStencilResolveTest::submit (void) // the render pass so it has the expected values. if (m_config.unusedResolve) { - const tcu::TextureFormat format (mapVkFormat(m_config.format)); const Unique commandBuffer (allocateCommandBuffer(m_vkd, m_device, *m_commandPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY)); const vk::VkImageSubresourceRange imageRange = { - ((tcu::hasDepthComponent(format.order) ? static_cast(vk::VK_IMAGE_ASPECT_DEPTH_BIT) : 0u) | - (tcu::hasStencilComponent(format.order) ? static_cast(vk::VK_IMAGE_ASPECT_STENCIL_BIT) : 0u)), + m_config.resolveAspectFlags(), 0u, VK_REMAINING_MIP_LEVELS, 0u, @@ -992,7 +998,7 @@ void DepthStencilResolveTest::submit (void) **m_singlesampleImage, { - (m_config.separateDepthStencilLayouts) ? VkImageAspectFlags(testingDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT) : m_config.aspectFlag, + (m_config.separateDepthStencilLayouts) ? VkImageAspectFlags(testingDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT) : m_config.resolveAspectFlags(), 0u, 1u, 0u, -- 2.7.4