From c6ccebc28a01bdf6ba431c3d1d466748d4b13367 Mon Sep 17 00:00:00 2001 From: Mohankumar Nekkarakalaya Date: Mon, 10 Jan 2022 14:36:17 -0800 Subject: [PATCH] Fix vkAttachmentRateTests The VkRenderingFragmentShadingRateAttachmentInfoKHR struct has its shadingRateAttachmentTexelSize member set to the dimension of FSR attachment, instead of attachmentTexelSize provided by the test. A graphics pipeline used to draw FSR attachment, which is then used to draw another color attachment. But the VkPipelineRenderingCreateInfoKHR used by this pipeline sets the color format to that of the color attachment, instead of FSR attachment Affects: dEQP-VK.fragment_shading_rate.dynamic_rendering.attachment_rate.* Components: Vulkan VK-GL-CTS issue: 3439 Change-Id: I36dad0f7dfa267c702fb611cd3b1b285fe0bb339 --- .../vktAttachmentRateTests.cpp | 46 +++++++++++++--------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/external/vulkancts/modules/vulkan/fragment_shading_rate/vktAttachmentRateTests.cpp b/external/vulkancts/modules/vulkan/fragment_shading_rate/vktAttachmentRateTests.cpp index 77a38bb..e321864 100644 --- a/external/vulkancts/modules/vulkan/fragment_shading_rate/vktAttachmentRateTests.cpp +++ b/external/vulkancts/modules/vulkan/fragment_shading_rate/vktAttachmentRateTests.cpp @@ -148,6 +148,7 @@ private: Move buildPipelineLayout (const VkDescriptorSetLayout* setLayouts = DE_NULL) const; Move buildGraphicsPipeline (deUint32 subpass, VkRenderPass renderPass, + VkFormat cbFormat, VkPipelineLayout layout, VkShaderModule vertShader, VkShaderModule fragShader, @@ -161,7 +162,9 @@ private: const VkRenderPass renderPass, const VkFramebuffer framebuffer, const VkRect2D& renderArea, - const std::vector& attachmentInfo) const; + const std::vector& attachmentInfo, + const deUint32 srTileWidth = 0, + const deUint32 srTileHeight = 0) const; void finishRendering (const VkCommandBuffer commandBuffer) const; bool verifyUsingAtomicChecks (deUint32 tileWidth, @@ -539,7 +542,7 @@ Move AttachmentRateInstance::buildPipelineLayout(const VkDescr return createPipelineLayout(m_context.getDeviceInterface(), device, &pipelineLayoutCreateInfo, NULL); } -Move AttachmentRateInstance::buildGraphicsPipeline(deUint32 subpass, VkRenderPass renderPass, VkPipelineLayout pipelineLayout, +Move AttachmentRateInstance::buildGraphicsPipeline(deUint32 subpass, VkRenderPass renderPass, VkFormat cbFormat, VkPipelineLayout pipelineLayout, VkShaderModule vertShader, VkShaderModule fragShader, bool useShadingRate) const { std::vector pipelineShaderStageParams(2, @@ -700,7 +703,7 @@ Move AttachmentRateInstance::buildGraphicsPipeline(deUint32 subpass, pNext, 0u, 1u, - &m_cbFormat, + &cbFormat, VK_FORMAT_UNDEFINED, VK_FORMAT_UNDEFINED }; @@ -708,7 +711,7 @@ Move AttachmentRateInstance::buildGraphicsPipeline(deUint32 subpass, if (m_params->useDynamicRendering) pNext = &renderingCreateInfo; - const VkGraphicsPipelineCreateInfo pipelineCreateInfo + VkGraphicsPipelineCreateInfo pipelineCreateInfo { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType pNext, // const void* pNext @@ -731,6 +734,9 @@ Move AttachmentRateInstance::buildGraphicsPipeline(deUint32 subpass, 0 // deInt32 basePipelineIndex; }; + if (useShadingRate && m_params->useDynamicRendering) + pipelineCreateInfo.flags |= VK_PIPELINE_CREATE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR; + VkDevice device = m_device.get() ? *m_device : m_context.getDevice(); return createGraphicsPipeline(m_context.getDeviceInterface(), device, DE_NULL, &pipelineCreateInfo); } @@ -779,7 +785,9 @@ void AttachmentRateInstance::startRendering(const VkCommandBuffer commandBuf const VkRenderPass renderPass, const VkFramebuffer framebuffer, const VkRect2D& renderArea, - const std::vector& attachmentInfo) const + const std::vector& attachmentInfo, + const deUint32 srTileWidth, + const deUint32 srTileHeight) const { const DeviceInterface& vk (m_context.getDeviceInterface()); std::vector clearColor (attachmentInfo.size(), makeClearValueColorU32(0, 0, 0, 0)); @@ -828,7 +836,7 @@ void AttachmentRateInstance::startRendering(const VkCommandBuffer commandBuf (attachmentInfo[1].usage & VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR)) { shadingRateAttachmentInfo.imageView = attachmentInfo[1].view; - shadingRateAttachmentInfo.shadingRateAttachmentTexelSize = { attachmentInfo[1].width, attachmentInfo[1].height }; + shadingRateAttachmentInfo.shadingRateAttachmentTexelSize = { srTileWidth, srTileHeight }; renderingInfo.pNext = &shadingRateAttachmentInfo; } @@ -1108,7 +1116,7 @@ bool AttachmentRateInstance::runComputeShaderMode(void) Move graphicsPipelineLayout = buildPipelineLayout(&(*m_counterBufferDescriptorSetLayout)); Move computePipeline = buildComputePipeline(*compShader, *computePipelineLayout); Move renderPass = buildRenderPass(m_cbFormat, tileWidth, tileHeight); - Move graphicsPipeline = buildGraphicsPipeline(0, *renderPass, *graphicsPipelineLayout, *vertShader, *fragShader); + Move graphicsPipeline = buildGraphicsPipeline(0, *renderPass, m_cbFormat, *graphicsPipelineLayout, *vertShader, *fragShader); std::vector attachmentInfo { @@ -1165,7 +1173,7 @@ bool AttachmentRateInstance::runComputeShaderMode(void) m_defaultImageSubresourceRange); vk.cmdPipelineBarrier(*cmdBuffer, srcStageMask, dstStageMask, 0, 0, DE_NULL, 0, DE_NULL, 1, &cbImageBarrier); - startRendering(*cmdBuffer, *renderPass, *framebuffer, makeRect2D(m_cbWidth, m_cbHeight), attachmentInfo); + startRendering(*cmdBuffer, *renderPass, *framebuffer, makeRect2D(m_cbWidth, m_cbHeight), attachmentInfo, tileWidth, tileHeight); // draw single triangle to cb vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *graphicsPipelineLayout, 0, 1, &(*m_counterBufferDescriptorSet), 0, DE_NULL); @@ -1243,8 +1251,8 @@ bool AttachmentRateInstance::runFragmentShaderMode(void) Move ratePipelineLayout = buildPipelineLayout(&(*m_counterBufferDescriptorSetLayout)); Move setupRenderPass = buildRenderPass(m_params->srFormat); Move rateRenderPass = buildRenderPass(m_cbFormat, tileWidth, tileHeight); - Move setupPipeline = buildGraphicsPipeline(0, *setupRenderPass, *setupPipelineLayout, *vertSetupShader, *fragSetupShader, DE_FALSE); - Move ratePipeline = buildGraphicsPipeline(0, *rateRenderPass, *ratePipelineLayout, *vertShader, *fragShader); + Move setupPipeline = buildGraphicsPipeline(0, *setupRenderPass, m_params->srFormat, *setupPipelineLayout, *vertSetupShader, *fragSetupShader, DE_FALSE); + Move ratePipeline = buildGraphicsPipeline(0, *rateRenderPass, m_cbFormat, *ratePipelineLayout, *vertShader, *fragShader); std::vector setupAttachmentInfo { @@ -1308,7 +1316,7 @@ bool AttachmentRateInstance::runFragmentShaderMode(void) m_defaultImageSubresourceRange); vk.cmdPipelineBarrier(*cmdBuffer, srcStageMask, dstStageMask, 0, 0, DE_NULL, 0, DE_NULL, 1, &cbImageBarrier); - startRendering(*cmdBuffer, *rateRenderPass, *rateFramebuffer, makeRect2D(m_cbWidth, m_cbHeight), rateAttachmentInfo); + startRendering(*cmdBuffer, *rateRenderPass, *rateFramebuffer, makeRect2D(m_cbWidth, m_cbHeight), rateAttachmentInfo, tileWidth, tileHeight); // draw single triangle to cb vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *ratePipelineLayout, 0, 1, &(*m_counterBufferDescriptorSet), 0, DE_NULL); @@ -1383,7 +1391,7 @@ bool AttachmentRateInstance::runCopyMode (void) Move graphicsPipelineLayout = buildPipelineLayout(&(*m_counterBufferDescriptorSetLayout)); Move renderPass = buildRenderPass(m_cbFormat, tileWidth, tileHeight); - Move graphicsPipeline = buildGraphicsPipeline(0, *renderPass, *graphicsPipelineLayout, *vertShader, *fragShader); + Move graphicsPipeline = buildGraphicsPipeline(0, *renderPass, m_cbFormat, *graphicsPipelineLayout, *vertShader, *fragShader); std::vector attachmentInfo { @@ -1459,7 +1467,7 @@ bool AttachmentRateInstance::runCopyMode (void) m_defaultImageSubresourceRange); vk.cmdPipelineBarrier(*cmdBuffer, srcStageMask, dstStageMask, 0, 0, DE_NULL, 0, DE_NULL, 1, &cbImageBarrier); - startRendering(*cmdBuffer, *renderPass, *framebuffer, makeRect2D(m_cbWidth, m_cbHeight), attachmentInfo); + startRendering(*cmdBuffer, *renderPass, *framebuffer, makeRect2D(m_cbWidth, m_cbHeight), attachmentInfo, tileWidth, tileHeight); // draw single triangle to cb vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *graphicsPipelineLayout, 0, 1, &(*m_counterBufferDescriptorSet), 0, DE_NULL); @@ -1627,7 +1635,7 @@ bool AttachmentRateInstance::runCopyModeOnTransferQueue(void) Move graphicsPipelineLayout = buildPipelineLayout(&(*m_counterBufferDescriptorSetLayout)); Move renderPass = buildRenderPass(m_cbFormat, tileWidth, tileHeight); - Move graphicsPipeline = buildGraphicsPipeline(0, *renderPass, *graphicsPipelineLayout, *vertShader, *fragShader); + Move graphicsPipeline = buildGraphicsPipeline(0, *renderPass, m_cbFormat, *graphicsPipelineLayout, *vertShader, *fragShader); std::vector attachmentInfo { @@ -1726,7 +1734,7 @@ bool AttachmentRateInstance::runCopyModeOnTransferQueue(void) m_defaultImageSubresourceRange); vk.cmdPipelineBarrier(*graphicsCmdBuffer, srcStageMask, dstStageMask, 0, 0, DE_NULL, 0, DE_NULL, 1, &cbImageBarrier); - startRendering(*graphicsCmdBuffer, *renderPass, *framebuffer, makeRect2D(m_cbWidth, m_cbHeight), attachmentInfo); + startRendering(*graphicsCmdBuffer, *renderPass, *framebuffer, makeRect2D(m_cbWidth, m_cbHeight), attachmentInfo, tileWidth, tileHeight); // draw single triangle to cb vk.cmdBindDescriptorSets(*graphicsCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *graphicsPipelineLayout, 0, 1, &(*m_counterBufferDescriptorSet), 0, DE_NULL); @@ -1845,7 +1853,7 @@ bool AttachmentRateInstance::runFillLinearTiledImage(void) Move graphicsPipelineLayout = buildPipelineLayout(&(*m_counterBufferDescriptorSetLayout)); Move renderPass = buildRenderPass(m_cbFormat, tileWidth, tileHeight); - Move graphicsPipeline = buildGraphicsPipeline(0, *renderPass, *graphicsPipelineLayout, *vertShader, *fragShader); + Move graphicsPipeline = buildGraphicsPipeline(0, *renderPass, m_cbFormat, *graphicsPipelineLayout, *vertShader, *fragShader); std::vector attachmentInfo { @@ -1882,7 +1890,7 @@ bool AttachmentRateInstance::runFillLinearTiledImage(void) m_defaultImageSubresourceRange); vk.cmdPipelineBarrier(*cmdBuffer, srcStageMask, dstStageMask, 0, 0, DE_NULL, 0, DE_NULL, 1, &cbImageBarrier); - startRendering(*cmdBuffer, *renderPass, *framebuffer, makeRect2D(m_cbWidth, m_cbHeight), attachmentInfo); + startRendering(*cmdBuffer, *renderPass, *framebuffer, makeRect2D(m_cbWidth, m_cbHeight), attachmentInfo, tileWidth, tileHeight); // draw single triangle to cb vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *graphicsPipelineLayout, 0, 1, &(*m_counterBufferDescriptorSet), 0, DE_NULL); @@ -1967,8 +1975,8 @@ bool AttachmentRateInstance::runTwoSubpassMode(void) Move renderPass = buildRenderPass(m_cbFormat, m_minTileSize.width, m_minTileSize.height, m_maxTileSize.width, m_maxTileSize.height); Move pipelineLayout = buildPipelineLayout(&(*m_counterBufferDescriptorSetLayout)); - Move graphicsPipeline0 = buildGraphicsPipeline(0, *renderPass, *pipelineLayout, *vertShader0, *fragShader); - Move graphicsPipeline1 = buildGraphicsPipeline(1, *renderPass, *pipelineLayout, *vertShader1, *fragShader); + Move graphicsPipeline0 = buildGraphicsPipeline(0, *renderPass, m_cbFormat, *pipelineLayout, *vertShader0, *fragShader); + Move graphicsPipeline1 = buildGraphicsPipeline(1, *renderPass, m_cbFormat, *pipelineLayout, *vertShader1, *fragShader); std::vector attachmentInfo { -- 2.7.4