X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=external%2Fvulkancts%2Fmodules%2Fvulkan%2Frenderpass%2FvktRenderPassTests.cpp;h=26bb471b4dc3c28d8a671930f6c1b7afded9575d;hb=HEAD;hp=7cfc9eb28799b56f4c6c26d2b29fff5788b8b55b;hpb=5ce0ccb3a98e01cc5ba04b508d8c20ac8df92334;p=platform%2Fupstream%2FVK-GL-CTS.git diff --git a/external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp b/external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp index 7cfc9eb..26bb471 100644 --- a/external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp +++ b/external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp @@ -23,11 +23,13 @@ #include "vktRenderPassTests.hpp" #include "vktRenderPassTestsUtil.hpp" - +#include "vktRenderPassGroupParams.hpp" #include "vktRenderPassMultisampleTests.hpp" #include "vktRenderPassMultisampleResolveTests.hpp" #include "vktRenderPassSampleReadTests.hpp" +#ifndef CTS_USES_VULKANSC #include "vktRenderPassSparseRenderTargetTests.hpp" +#endif // CTS_USES_VULKANSC #include "vktRenderPassSubpassDependencyTests.hpp" #include "vktRenderPassUnusedAttachmentTests.hpp" #include "vktRenderPassUnusedClearAttachmentTests.hpp" @@ -35,8 +37,14 @@ #include "vktRenderPassUnusedAttachmentSparseFillingTests.hpp" #include "vktRenderPassFragmentDensityMapTests.hpp" #include "vktRenderPassMultipleSubpassesMultipleCommandBuffersTests.hpp" +#ifndef CTS_USES_VULKANSC #include "vktRenderPassLoadStoreOpNoneTests.hpp" #include "vktDynamicRenderingTests.hpp" +#endif // CTS_USES_VULKANSC +#include "vktRenderPassDepthStencilWriteConditionsTests.hpp" +#include "vktRenderPassSubpassMergeFeedbackTests.hpp" +#include "vktDynamicRenderingRandomTests.hpp" +#include "vktRenderPassDitheringTests.hpp" #include "vktTestCaseUtil.hpp" #include "vktTestGroupUtil.hpp" @@ -54,6 +62,9 @@ #include "vkTypeUtil.hpp" #include "vkCmdUtil.hpp" #include "vkObjUtil.hpp" +#include "vkBufferWithMemory.hpp" +#include "vkImageWithMemory.hpp" +#include "vkBarrierUtil.hpp" #include "tcuFloat.hpp" #include "tcuFormatUtil.hpp" @@ -118,15 +129,15 @@ enum AllocationKind struct TestConfigExternal { - TestConfigExternal (AllocationKind allocationKind_, - RenderingType renderingType_) + TestConfigExternal (AllocationKind allocationKind_, + const SharedGroupParams groupParams_) : allocationKind (allocationKind_) - , renderingType (renderingType_) + , groupParams (groupParams_) { } - AllocationKind allocationKind; - RenderingType renderingType; + AllocationKind allocationKind; + const SharedGroupParams groupParams; }; de::MovePtr allocateBuffer (const InstanceInterface& vki, @@ -757,7 +768,7 @@ struct TestConfig deUint32 seed_, deUint32 drawStartNdx_, AllocationKind allocationKind_, - RenderingType renderingType_, + SharedGroupParams groupParams_, vector requiredFeatures_ = vector()) : renderPass (renderPass_) , renderTypes (renderTypes_) @@ -770,7 +781,7 @@ struct TestConfig , seed (seed_) , drawStartNdx (drawStartNdx_) , allocationKind (allocationKind_) - , renderingType (renderingType_) + , groupParams (groupParams_) , requiredFeatures (requiredFeatures_) { DepthValuesArray shuffledDepthValues (&DEPTH_VALUES[0], &DEPTH_VALUES[DE_LENGTH_OF_ARRAY(DEPTH_VALUES)]); @@ -793,7 +804,7 @@ struct TestConfig deUint32 seed; deUint32 drawStartNdx; AllocationKind allocationKind; - RenderingType renderingType; + SharedGroupParams groupParams; vector requiredFeatures; DepthValuesArray depthValues; }; @@ -1770,7 +1781,6 @@ private: void beginCommandBuffer (const DeviceInterface& vk, VkCommandBuffer cmdBuffer, - VkCommandBufferUsageFlags pBeginInfo_flags, VkRenderPass pInheritanceInfo_renderPass, deUint32 pInheritanceInfo_subpass, VkFramebuffer pInheritanceInfo_framebuffer, @@ -1778,9 +1788,11 @@ void beginCommandBuffer (const DeviceInterface& vk, VkQueryControlFlags pInheritanceInfo_queryFlags, VkQueryPipelineStatisticFlags pInheritanceInfo_pipelineStatistics, const SubpassRenderInfo* pRenderInfo = 0, - bool dynamicRenderPass = false ) + bool dynamicRenderPass = false, + bool secondaryCmdBufferCompletelyContainsRenderpass = false) { - VkCommandBufferInheritanceInfo pInheritanceInfo = + VkCommandBufferUsageFlags usageFlags = (VkCommandBufferUsageFlags)0; + VkCommandBufferInheritanceInfo pInheritanceInfo { VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, DE_NULL, @@ -1791,21 +1803,19 @@ void beginCommandBuffer (const DeviceInterface& vk, pInheritanceInfo_queryFlags, pInheritanceInfo_pipelineStatistics, }; - std::vector colorAttachmentFormats; - VkCommandBufferInheritanceRenderingInfoKHR inheritanceRenderingInfo - { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR, - DE_NULL, - 0u, - 0u, - 0u, - DE_NULL, - VK_FORMAT_UNDEFINED, - VK_FORMAT_UNDEFINED, - VK_SAMPLE_COUNT_1_BIT, - }; - if (pRenderInfo) + +#ifndef CTS_USES_VULKANSC + + std::vector colorAttachmentFormats; + VkCommandBufferInheritanceRenderingInfoKHR inheritanceRenderingInfo = initVulkanStructure(); + + if (dynamicRenderPass && pRenderInfo) { + if (secondaryCmdBufferCompletelyContainsRenderpass) + inheritanceRenderingInfo.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT; + else + usageFlags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; + for (deUint32 i = 0; i < pRenderInfo->getColorAttachmentCount(); ++i) colorAttachmentFormats.push_back(pRenderInfo->getColorAttachment(i).getFormat()); @@ -1813,22 +1823,37 @@ void beginCommandBuffer (const DeviceInterface& vk, inheritanceRenderingInfo.pColorAttachmentFormats = colorAttachmentFormats.data(); if (pRenderInfo->getDepthStencilAttachment()) { - inheritanceRenderingInfo.depthAttachmentFormat = pRenderInfo->getDepthStencilAttachment()->getFormat(); - inheritanceRenderingInfo.stencilAttachmentFormat = pRenderInfo->getDepthStencilAttachment()->getFormat(); + const VkFormat dsFormat = pRenderInfo->getDepthStencilAttachment()->getFormat(); + inheritanceRenderingInfo.depthAttachmentFormat = tcu::hasDepthComponent(mapVkFormat(dsFormat).order) ? dsFormat : VK_FORMAT_UNDEFINED; + inheritanceRenderingInfo.stencilAttachmentFormat = tcu::hasStencilComponent(mapVkFormat(dsFormat).order) ? dsFormat : VK_FORMAT_UNDEFINED; } + if (pRenderInfo->getColorAttachmentCount()) inheritanceRenderingInfo.rasterizationSamples = pRenderInfo->getColorAttachment(0).getSamples(); else if (pRenderInfo->getDepthStencilAttachment()) inheritanceRenderingInfo.rasterizationSamples = pRenderInfo->getDepthStencilAttachment()->getSamples(); + else + inheritanceRenderingInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; - if (dynamicRenderPass) - pInheritanceInfo.pNext = &inheritanceRenderingInfo; + pInheritanceInfo.pNext = &inheritanceRenderingInfo; } - const VkCommandBufferBeginInfo pBeginInfo = + else if (!secondaryCmdBufferCompletelyContainsRenderpass) + usageFlags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; +#else + + DE_UNREF(pRenderInfo); + DE_UNREF(dynamicRenderPass); + DE_UNREF(secondaryCmdBufferCompletelyContainsRenderpass); + + usageFlags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; + +#endif // CTS_USES_VULKANSC + + const VkCommandBufferBeginInfo pBeginInfo { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, DE_NULL, - pBeginInfo_flags, + usageFlags, &pInheritanceInfo, }; VK_CHECK(vk.beginCommandBuffer(cmdBuffer, &pBeginInfo)); @@ -1985,6 +2010,8 @@ Move createSubpassPipeline (const DeviceInterface& vk, ? VK_TRUE : VK_FALSE; + VkStencilOp stencilOp = writeStencil ? VK_STENCIL_OP_REPLACE : VK_STENCIL_OP_KEEP; + const VkPipelineDepthStencilStateCreateInfo depthStencilState = { VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType @@ -1996,18 +2023,18 @@ Move createSubpassPipeline (const DeviceInterface& vk, VK_FALSE, // depthBoundsEnable writeStencil, // stencilTestEnable { - VK_STENCIL_OP_REPLACE, // stencilFailOp - VK_STENCIL_OP_REPLACE, // stencilPassOp - VK_STENCIL_OP_REPLACE, // stencilDepthFailOp + stencilOp, // stencilFailOp + stencilOp, // stencilPassOp + stencilOp, // stencilDepthFailOp VK_COMPARE_OP_ALWAYS, // stencilCompareOp ~0u, // stencilCompareMask ~0u, // stencilWriteMask ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference }, // front { - VK_STENCIL_OP_REPLACE, // stencilFailOp - VK_STENCIL_OP_REPLACE, // stencilPassOp - VK_STENCIL_OP_REPLACE, // stencilDepthFailOp + stencilOp, // stencilFailOp + stencilOp, // stencilPassOp + stencilOp, // stencilDepthFailOp VK_COMPARE_OP_ALWAYS, // stencilCompareOp ~0u, // stencilCompareMask ~0u, // stencilWriteMask @@ -2030,17 +2057,31 @@ Move createSubpassPipeline (const DeviceInterface& vk, { 0.0f, 0.0f, 0.0f, 0.0f } // blendConst }; +#ifndef CTS_USES_VULKANSC std::vector colorAttachmentFormats; for (deUint32 i = 0; i < renderInfo.getColorAttachmentCount(); ++i) colorAttachmentFormats.push_back(renderInfo.getColorAttachment(i).getFormat()); - vk::VkFormat depthStencilFormat = VK_FORMAT_UNDEFINED; + vk::VkFormat depthFormat = VK_FORMAT_UNDEFINED; + vk::VkFormat stencilFormat = VK_FORMAT_UNDEFINED; if (renderInfo.getDepthStencilAttachment()) { const Attachment& attachment = *renderInfo.getDepthStencilAttachment(); - depthStencilFormat = attachment.getFormat(); + vk::VkFormat depthStencilFormat = attachment.getFormat(); + if (depthStencilFormat != VK_FORMAT_UNDEFINED) + { + if (tcu::hasDepthComponent(mapVkFormat(depthStencilFormat).order)) + { + depthFormat = depthStencilFormat; + } + if (tcu::hasStencilComponent(mapVkFormat(depthStencilFormat).order)) + { + stencilFormat = depthStencilFormat; + } + } } + VkPipelineRenderingCreateInfoKHR renderingCreateInfo { VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR, @@ -2048,9 +2089,10 @@ Move createSubpassPipeline (const DeviceInterface& vk, 0u, static_cast(colorAttachmentFormats.size()), colorAttachmentFormats.data(), - depthStencilFormat, - depthStencilFormat + depthFormat, + stencilFormat }; +#endif // CTS_USES_VULKANSC return makeGraphicsPipeline(vk, // const DeviceInterface& vk device, // const VkDevice device @@ -2072,31 +2114,176 @@ Move createSubpassPipeline (const DeviceInterface& vk, renderInfo.getOmitBlendState() ? DE_NULL : &blendState, // const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo DE_NULL, // const VkPipelineDynamicStateCreateInfo* dynamicStateCreateInfo +#ifndef CTS_USES_VULKANSC (renderPass == DE_NULL) ? &renderingCreateInfo : DE_NULL); // const void* pNext) +#else + DE_NULL); // const void* pNext) +#endif // CTS_USES_VULKANSC +} + +#ifndef CTS_USES_VULKANSC +void beginDynamicRendering(const DeviceInterface& vk, + VkCommandBuffer commandBuffer, + const RenderPass& renderPassInfo, + const vector >& attachmentResources, + const VkRect2D& renderArea, + const vector >& renderPassClearValues, + const VkRenderingFlagsKHR renderingFlags = 0u) +{ + const float clearNan = tcu::Float32::nan().asFloat(); + const VkClearValue clearValueNan = makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan); + + // translate structures that were prepared to construct renderpass to structures needed for dynamic rendering + + std::vector colorAttachmentVect; + const Subpass& subpassInfo = renderPassInfo.getSubpasses()[0]; + const vector& colorAttachmentsInfo = subpassInfo.getColorAttachments(); + const vector& resolveAttachmentsInfo = subpassInfo.getResolveAttachments(); + + for (deUint32 i = 0; i < colorAttachmentsInfo.size(); ++i) + { + const AttachmentReference& colorAttachmentReference = colorAttachmentsInfo[i]; + const deUint32 colorAttachmentIndex = colorAttachmentReference.getAttachment(); + const Attachment& colorAttachmentInfo = renderPassInfo.getAttachments()[colorAttachmentIndex]; + + VkResolveModeFlagBits resolveMode = VK_RESOLVE_MODE_NONE; + VkImageView resolveImageView = DE_NULL; + VkImageLayout resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED; + + // handle resolve attachments if they were specified + if (!resolveAttachmentsInfo.empty()) + { + const AttachmentReference& resolveAttachmentReference = resolveAttachmentsInfo[i]; + const deUint32 resolveAttachmentIndex = resolveAttachmentReference.getAttachment(); + const Attachment& resolveAttachmentInfo = renderPassInfo.getAttachments()[resolveAttachmentIndex]; + + resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; + resolveImageView = attachmentResources[resolveAttachmentIndex]->getAttachmentView(); + resolveImageLayout = resolveAttachmentInfo.getInitialLayout(); + } + + colorAttachmentVect.push_back({ + vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType + DE_NULL, // const void* pNext + attachmentResources[colorAttachmentIndex]->getAttachmentView(), // VkImageView imageView + colorAttachmentReference.getImageLayout(), // VkImageLayout imageLayout + resolveMode, // VkResolveModeFlagBits resolveMode + resolveImageView, // VkImageView resolveImageView + resolveImageLayout, // VkImageLayout resolveImageLayout + colorAttachmentInfo.getLoadOp(), // VkAttachmentLoadOp loadOp + colorAttachmentInfo.getStoreOp(), // VkAttachmentStoreOp storeOp + (renderPassClearValues[colorAttachmentIndex] ? + *renderPassClearValues[colorAttachmentIndex] : + clearValueNan) // VkClearValue clearValue + }); + } + + VkRenderingAttachmentInfoKHR* pDepthAttachment = DE_NULL; + VkRenderingAttachmentInfoKHR* pStencilAttachment = DE_NULL; + VkRenderingAttachmentInfoKHR depthAttachment + { + vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType; + DE_NULL, // const void* pNext; + DE_NULL, // VkImageView imageView; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout imageLayout; + VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode; + DE_NULL, // VkImageView resolveImageView; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout; + VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; + clearValueNan // VkClearValue clearValue; + }; + VkRenderingAttachmentInfoKHR stencilAttachment = depthAttachment; + const AttachmentReference& depthStencilAttachmentReference = subpassInfo.getDepthStencilAttachment(); + const deUint32 dsAttachmentIndex = depthStencilAttachmentReference.getAttachment(); + + if (dsAttachmentIndex != VK_ATTACHMENT_UNUSED) + { + const Attachment& dsAttachmentInfo = renderPassInfo.getAttachments()[dsAttachmentIndex]; + const tcu::TextureFormat format = mapVkFormat(dsAttachmentInfo.getFormat()); + + if (tcu::hasDepthComponent(format.order)) + { + depthAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView(); + depthAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout(); + depthAttachment.loadOp = dsAttachmentInfo.getLoadOp(); + depthAttachment.storeOp = dsAttachmentInfo.getStoreOp(); + + if (renderPassClearValues[dsAttachmentIndex]) + depthAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex]; + + pDepthAttachment = &depthAttachment; + } + + if (tcu::hasStencilComponent(format.order)) + { + stencilAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView(); + stencilAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout(); + stencilAttachment.loadOp = dsAttachmentInfo.getStencilLoadOp(); + stencilAttachment.storeOp = dsAttachmentInfo.getStencilStoreOp(); + + if (renderPassClearValues[dsAttachmentIndex]) + stencilAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex]; + + pStencilAttachment = &stencilAttachment; + } + } + + vk::VkRenderingInfoKHR renderingInfo + { + vk::VK_STRUCTURE_TYPE_RENDERING_INFO_KHR, + DE_NULL, + renderingFlags, // VkRenderingFlagsKHR flags; + renderArea, // VkRect2D renderArea; + 1u, // deUint32 layerCount; + 0u, // deUint32 viewMask; + static_cast(colorAttachmentVect.size()), // deUint32 colorAttachmentCount; + colorAttachmentVect.empty() ? DE_NULL : &colorAttachmentVect[0], // const VkRenderingAttachmentInfoKHR* pColorAttachments; + pDepthAttachment, // const VkRenderingAttachmentInfoKHR* pDepthAttachment; + pStencilAttachment // const VkRenderingAttachmentInfoKHR* pStencilAttachment; + }; + + vk.cmdBeginRendering(commandBuffer, &renderingInfo); +} + +void endDynamicRendering(const DeviceInterface& vk, VkCommandBuffer commandBuffer) +{ + vk.cmdEndRendering(commandBuffer); } +#endif // CTS_USES_VULKANSC class SubpassRenderer { public: - SubpassRenderer (Context& context, - const DeviceInterface& vk, - VkDevice device, - Allocator& allocator, - VkRenderPass renderPass, - VkFramebuffer framebuffer, - VkCommandPool commandBufferPool, - deUint32 queueFamilyIndex, - const vector& attachmentImages, - const vector >& attachmentViews, - const SubpassRenderInfo& renderInfo, - const vector& attachmentInfos, - const AllocationKind allocationKind, - const bool dynamicRendering) + SubpassRenderer (Context& context, + const DeviceInterface& vk, + VkDevice device, + Allocator& allocator, + const RenderPass& renderPassInfo, + const vector >& attachmentResources, + const VkRect2D& renderArea, + const vector >& renderPassClearValues, + VkRenderPass renderPass, + VkFramebuffer framebuffer, + VkCommandPool commandBufferPool, + deUint32 queueFamilyIndex, + const vector& attachmentImages, + const vector >& attachmentViews, + const SubpassRenderInfo& renderInfo, + const AllocationKind allocationKind, + const bool dynamicRendering, + const bool secondaryCmdBufferCompletelyContainsDynamicRenderpass) : m_renderInfo (renderInfo) { + // unreference values not used by Vulkan SC, no need to pu this under ifdef + DE_UNREF(attachmentResources); + DE_UNREF(renderArea); + DE_UNREF(renderPassClearValues); + const InstanceInterface& vki = context.getInstanceInterface(); const VkPhysicalDevice& physDevice = context.getPhysicalDevice(); + const vector& attachmentInfos = renderPassInfo.getAttachments(); const deUint32 subpassIndex = renderInfo.getSubpassIndex(); vector bindings; @@ -2343,15 +2530,27 @@ public: { m_commandBuffer = allocateCommandBuffer(vk, device, commandBufferPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); - beginCommandBuffer(vk, *m_commandBuffer, vk::VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, renderPass, subpassIndex, framebuffer, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0, &renderInfo, dynamicRendering); - pushRenderCommands(vk, *m_commandBuffer); + beginCommandBuffer(vk, *m_commandBuffer, renderPass, subpassIndex, framebuffer, VK_FALSE, (VkQueryControlFlags)0, + (VkQueryPipelineStatisticFlags)0, &renderInfo, dynamicRendering, secondaryCmdBufferCompletelyContainsDynamicRenderpass); + + if (dynamicRendering && secondaryCmdBufferCompletelyContainsDynamicRenderpass) + { +#ifndef CTS_USES_VULKANSC + beginDynamicRendering(vk, *m_commandBuffer, renderPassInfo, attachmentResources, renderArea, renderPassClearValues); + pushRenderCommands(vk, *m_commandBuffer); + endDynamicRendering(vk, *m_commandBuffer); +#endif // CTS_USES_VULKANSC + } + else + pushRenderCommands(vk, *m_commandBuffer); + endCommandBuffer(vk, *m_commandBuffer); } } bool isSecondary (void) const { - return m_commandBuffer; + return !!m_commandBuffer; } VkCommandBuffer getCommandBuffer (void) const @@ -2684,8 +2883,7 @@ void pushRenderPassCommands (const DeviceInterface& vk, VkRenderPass renderPass, VkFramebuffer framebuffer, const vector >& subpassRenderers, - const UVec2& renderPos, - const UVec2& renderSize, + const VkRect2D& renderArea, const vector >& renderPassClearValues, TestConfig::RenderTypes render) { @@ -2702,12 +2900,6 @@ void pushRenderPassCommands (const DeviceInterface& vk, } { - const VkRect2D renderArea = - { - { (deInt32)renderPos.x(), (deInt32)renderPos.y() }, - { renderSize.x(), renderSize.y() } - }; - for (size_t subpassNdx = 0; subpassNdx < subpassRenderers.size(); subpassNdx++) { const VkSubpassContents contents = subpassRenderers[subpassNdx]->isSecondary() ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS : VK_SUBPASS_CONTENTS_INLINE; @@ -2743,81 +2935,35 @@ void pushRenderPassCommands (const DeviceInterface& vk, } } +#ifndef CTS_USES_VULKANSC void pushDynamicRenderingCommands (const DeviceInterface& vk, VkCommandBuffer commandBuffer, const RenderPass& renderPassInfo, const vector >& attachmentResources, const vector >& subpassRenderers, - const UVec2& renderPos, - const UVec2& renderSize, + const VkRect2D& renderArea, const vector >& renderPassClearValues, deUint32 queueIndex, - TestConfig::RenderTypes render) + TestConfig::RenderTypes renderType, + bool secondaryCmdBufferCompletelyContainsDynamicRenderpass) { - const float clearNan = tcu::Float32::nan().asFloat(); - const VkClearValue clearValueNan = makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan); - DE_ASSERT(subpassRenderers.size() == 1); - VkRenderingFlagsKHR renderingFlags = 0u; - if (subpassRenderers[0]->isSecondary()) - renderingFlags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; + vector imageBarriersBeforeRendering; + vector imageBarriersAfterRendering; - const VkRect2D renderArea - { - { (deInt32)renderPos.x(), (deInt32)renderPos.y() }, - { renderSize.x(), renderSize.y() } - }; - - // translate structures that were prepared to construct renderpass to structures needed for dynamic rendering - - vector imageBarriersBeforeRendering; - vector imageBarriersAfterRendering; - std::vector colorAttachmentVect; - const Subpass& subpassInfo = renderPassInfo.getSubpasses()[0]; - const vector& colorAttachmentsInfo = subpassInfo.getColorAttachments(); - const vector& resolveAttachmentsInfo = subpassInfo.getResolveAttachments(); + const Subpass& subpassInfo = renderPassInfo.getSubpasses()[0]; + const vector& colorAttachmentsInfo = subpassInfo.getColorAttachments(); for (deUint32 i = 0 ; i < colorAttachmentsInfo.size() ; ++i) { - const AttachmentReference& colorAttachmentReference = colorAttachmentsInfo[i]; - const deUint32 colorAttachmentIndex = colorAttachmentReference.getAttachment(); - const Attachment& colorAttachmentInfo = renderPassInfo.getAttachments()[colorAttachmentIndex]; + const AttachmentReference& colorAttachmentReference = colorAttachmentsInfo[i]; + const deUint32 colorAttachmentIndex = colorAttachmentReference.getAttachment(); + const Attachment& colorAttachmentInfo = renderPassInfo.getAttachments()[colorAttachmentIndex]; - VkResolveModeFlagBits resolveMode = VK_RESOLVE_MODE_NONE; - VkImageView resolveImageView = DE_NULL; - VkImageLayout resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED; - - // handle resolve attachments if they were specified - if (!resolveAttachmentsInfo.empty()) - { - const AttachmentReference& resolveAttachmentReference = resolveAttachmentsInfo[i]; - const deUint32 resolveAttachmentIndex = resolveAttachmentReference.getAttachment(); - const Attachment& resolveAttachmentInfo = renderPassInfo.getAttachments()[resolveAttachmentIndex]; - - resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; - resolveImageView = attachmentResources[resolveAttachmentIndex]->getAttachmentView(); - resolveImageLayout = resolveAttachmentInfo.getInitialLayout(); - } - - colorAttachmentVect.push_back({ - vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType - DE_NULL, // const void* pNext - attachmentResources[colorAttachmentIndex]->getAttachmentView(), // VkImageView imageView - colorAttachmentReference.getImageLayout(), // VkImageLayout imageLayout - resolveMode, // VkResolveModeFlagBits resolveMode - resolveImageView, // VkImageView resolveImageView - resolveImageLayout, // VkImageLayout resolveImageLayout - colorAttachmentInfo.getLoadOp(), // VkAttachmentLoadOp loadOp - colorAttachmentInfo.getStoreOp(), // VkAttachmentStoreOp storeOp - (renderPassClearValues[colorAttachmentIndex] ? - *renderPassClearValues[colorAttachmentIndex] : - clearValueNan) // VkClearValue clearValue - }); - - const VkImageLayout initialLayout = colorAttachmentInfo.getInitialLayout(); - const VkImageLayout renderingLayout = colorAttachmentReference.getImageLayout(); - const VkImageLayout finalLayout = colorAttachmentInfo.getFinalLayout(); + const VkImageLayout initialLayout = colorAttachmentInfo.getInitialLayout(); + const VkImageLayout renderingLayout = colorAttachmentReference.getImageLayout(); + const VkImageLayout finalLayout = colorAttachmentInfo.getFinalLayout(); const VkImageMemoryBarrier barrierBeforeRendering { @@ -2870,59 +3016,16 @@ void pushDynamicRenderingCommands (const DeviceInterface& vk, imageBarriersAfterRendering.push_back(barrierAfterRendering); } - VkRenderingAttachmentInfoKHR* pDepthAttachment = DE_NULL; - VkRenderingAttachmentInfoKHR* pStencilAttachment = DE_NULL; - VkRenderingAttachmentInfoKHR depthAttachment - { - vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType; - DE_NULL, // const void* pNext; - DE_NULL, // VkImageView imageView; - VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout imageLayout; - VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode; - DE_NULL, // VkImageView resolveImageView; - VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout; - VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp; - VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; - clearValueNan // VkClearValue clearValue; - }; - VkRenderingAttachmentInfoKHR stencilAttachment = depthAttachment; const AttachmentReference& depthStencilAttachmentReference = subpassInfo.getDepthStencilAttachment(); const deUint32 dsAttachmentIndex = depthStencilAttachmentReference.getAttachment(); if (dsAttachmentIndex != VK_ATTACHMENT_UNUSED) { const Attachment& dsAttachmentInfo = renderPassInfo.getAttachments()[dsAttachmentIndex]; - const tcu::TextureFormat format = mapVkFormat(dsAttachmentInfo.getFormat()); - if (tcu::hasDepthComponent(format.order)) - { - depthAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView(); - depthAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout(); - depthAttachment.loadOp = dsAttachmentInfo.getLoadOp(); - depthAttachment.storeOp = dsAttachmentInfo.getStoreOp(); - - if (renderPassClearValues[dsAttachmentIndex]) - depthAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex]; - - pDepthAttachment = &depthAttachment; - } - - if (tcu::hasStencilComponent(format.order)) - { - stencilAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView(); - stencilAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout(); - stencilAttachment.loadOp = dsAttachmentInfo.getStencilLoadOp(); - stencilAttachment.storeOp = dsAttachmentInfo.getStencilStoreOp(); - - if (renderPassClearValues[dsAttachmentIndex]) - stencilAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex]; - - pStencilAttachment = &stencilAttachment; - } - - const VkImageLayout initialLayout = dsAttachmentInfo.getInitialLayout(); - const VkImageLayout renderingLayout = depthStencilAttachmentReference.getImageLayout(); - const VkImageLayout finalLayout = dsAttachmentInfo.getFinalLayout(); + const VkImageLayout initialLayout = dsAttachmentInfo.getInitialLayout(); + const VkImageLayout renderingLayout = depthStencilAttachmentReference.getImageLayout(); + const VkImageLayout finalLayout = dsAttachmentInfo.getFinalLayout(); const VkImageMemoryBarrier barrierBeforeRendering { @@ -2985,23 +3088,24 @@ void pushDynamicRenderingCommands (const DeviceInterface& vk, (deUint32)imageBarriersBeforeRendering.size(), &imageBarriersBeforeRendering[0]); - vk::VkRenderingInfoKHR renderingInfo + bool executeRenderCommands = (renderType != TestConfig::RENDERTYPES_NONE); + + if (secondaryCmdBufferCompletelyContainsDynamicRenderpass) { - vk::VK_STRUCTURE_TYPE_RENDERING_INFO_KHR, - DE_NULL, - renderingFlags, // VkRenderingFlagsKHR flags; - renderArea, // VkRect2D renderArea; - 1u, // deUint32 layerCount; - 0u, // deUint32 viewMask; - static_cast(colorAttachmentVect.size()), // deUint32 colorAttachmentCount; - colorAttachmentVect.empty() ? DE_NULL : &colorAttachmentVect[0], // const VkRenderingAttachmentInfoKHR* pColorAttachments; - pDepthAttachment, // const VkRenderingAttachmentInfoKHR* pDepthAttachment; - pStencilAttachment // const VkRenderingAttachmentInfoKHR* pStencilAttachment; - }; + // when secondary command buffer completely contains dynamic renderpass + // then we need to execute it even when render type is none + executeRenderCommands = true; + } + else + { + VkRenderingFlagsKHR renderingFlags = 0u; + if (subpassRenderers[0]->isSecondary()) + renderingFlags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; - vk.cmdBeginRenderingKHR(commandBuffer, &renderingInfo); + beginDynamicRendering(vk, commandBuffer, renderPassInfo, attachmentResources, renderArea, renderPassClearValues, renderingFlags); + } - if (render) + if (executeRenderCommands) { if (subpassRenderers[0]->isSecondary()) { @@ -3012,7 +3116,8 @@ void pushDynamicRenderingCommands (const DeviceInterface& vk, subpassRenderers[0]->pushRenderCommands(vk, commandBuffer); } - vk.cmdEndRenderingKHR(commandBuffer); + if (!secondaryCmdBufferCompletelyContainsDynamicRenderpass) + endDynamicRendering(vk, commandBuffer); if (!imageBarriersAfterRendering.empty()) vk.cmdPipelineBarrier(commandBuffer, @@ -3024,6 +3129,7 @@ void pushDynamicRenderingCommands (const DeviceInterface& vk, (deUint32)imageBarriersAfterRendering.size(), &imageBarriersAfterRendering[0]); } +#endif // CTS_USES_VULKANSC void pushRenderPassCommands (const DeviceInterface& vk, VkCommandBuffer commandBuffer, @@ -3032,21 +3138,31 @@ void pushRenderPassCommands (const DeviceInterface& vk, const vector >& attachmentResources, VkFramebuffer framebuffer, const vector >& subpassRenderers, - const UVec2& renderPos, - const UVec2& renderSize, + const VkRect2D& renderArea, const vector >& renderPassClearValues, deUint32 queueIndex, TestConfig::RenderTypes render, - RenderingType renderingType) + RenderingType renderingType, + bool secondaryCmdBufferCompletelyContainsDynamicRenderpass) { + // unreference arguments not used by Vulkan SC, no need to put them under ifdef + DE_UNREF(renderPassInfo); + DE_UNREF(attachmentResources); + DE_UNREF(queueIndex); + DE_UNREF(secondaryCmdBufferCompletelyContainsDynamicRenderpass); + switch (renderingType) { case RENDERING_TYPE_RENDERPASS_LEGACY: - return pushRenderPassCommands(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render); + return pushRenderPassCommands(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderArea, renderPassClearValues, render); case RENDERING_TYPE_RENDERPASS2: - return pushRenderPassCommands(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render); + return pushRenderPassCommands(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderArea, renderPassClearValues, render); + +#ifndef CTS_USES_VULKANSC case RENDERING_TYPE_DYNAMIC_RENDERING: - return pushDynamicRenderingCommands(vk, commandBuffer, renderPassInfo, attachmentResources, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, render); + return pushDynamicRenderingCommands(vk, commandBuffer, renderPassInfo, attachmentResources, subpassRenderers, renderArea, renderPassClearValues, queueIndex, render, secondaryCmdBufferCompletelyContainsDynamicRenderpass); +#endif // CTS_USES_VULKANSC + default: TCU_THROW(InternalError, "Impossible"); } @@ -4990,10 +5106,10 @@ tcu::TestStatus renderPassTest (Context& context, TestConfig config) vector subpassIsSecondary; vector subpassRenderInfo; - if (config.renderingType == RENDERING_TYPE_RENDERPASS2) + if (config.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2) context.requireDeviceFunctionality("VK_KHR_create_renderpass2"); - if (config.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) + if (config.groupParams->renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) context.requireDeviceFunctionality("VK_KHR_dynamic_rendering"); if (config.allocationKind == ALLOCATION_KIND_DEDICATED) @@ -5114,8 +5230,8 @@ tcu::TestStatus renderPassTest (Context& context, TestConfig config) vector > inputAttachmentViews; Move renderPass; - if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) - renderPass = createRenderPass(vk, device, renderPassInfo, config.renderingType); + if (config.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) + renderPass = createRenderPass(vk, device, renderPassInfo, config.groupParams->renderingType); for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++) { @@ -5128,23 +5244,39 @@ tcu::TestStatus renderPassTest (Context& context, TestConfig config) inputAttachmentViews.push_back(attachmentResources[attachmentNdx]->getInputAttachmentViews()); } - beginCommandBuffer(vk, *initializeImagesCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0); + beginCommandBuffer(vk, *initializeImagesCommandBuffer, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0); pushImageInitializationCommands(vk, *initializeImagesCommandBuffer, renderPassInfo.getAttachments(), attachmentResources, queueIndex, imageClearValues); endCommandBuffer(vk, *initializeImagesCommandBuffer); { Move framebuffer; - if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) + if (config.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) framebuffer = createFramebuffer(vk, device, *renderPass, targetSize, attachmentViews); + const VkRect2D renderArea + { + { (deInt32)renderPos.x(), (deInt32)renderPos.y() }, + { renderSize.x(), renderSize.y() } + }; + const bool dynamicRendering = (config.groupParams->renderingType == RENDERING_TYPE_DYNAMIC_RENDERING); + const bool secondaryCmdBufferCompletelyContainsDynamicRenderpass = (config.commandBufferTypes == TestConfig::COMMANDBUFFERTYPES_SECONDARY) && + config.groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass; + for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++) - subpassRenderers.push_back(de::SharedPtr(new SubpassRenderer(context, vk, device, allocator, *renderPass, *framebuffer, *commandBufferPool, queueIndex, attachmentImages, inputAttachmentViews, subpassRenderInfo[subpassNdx], config.renderPass.getAttachments(), config.allocationKind, config.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING))); + { + subpassRenderers.push_back(de::SharedPtr(new SubpassRenderer(context, vk, device, allocator, renderPassInfo, attachmentResources, + renderArea, renderPassClearValues, *renderPass, *framebuffer, + *commandBufferPool, queueIndex, attachmentImages, inputAttachmentViews, + subpassRenderInfo[subpassNdx], config.allocationKind, dynamicRendering, + secondaryCmdBufferCompletelyContainsDynamicRenderpass))); + } - beginCommandBuffer(vk, *renderCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0); - pushRenderPassCommands(vk, *renderCommandBuffer, *renderPass, renderPassInfo, attachmentResources, *framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, config.renderTypes, config.renderingType); + beginCommandBuffer(vk, *renderCommandBuffer, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0); + pushRenderPassCommands(vk, *renderCommandBuffer, *renderPass, renderPassInfo, attachmentResources, *framebuffer, subpassRenderers, renderArea, + renderPassClearValues, queueIndex, config.renderTypes, config.groupParams->renderingType, secondaryCmdBufferCompletelyContainsDynamicRenderpass); endCommandBuffer(vk, *renderCommandBuffer); - beginCommandBuffer(vk, *readImagesToBuffersCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0); + beginCommandBuffer(vk, *readImagesToBuffersCommandBuffer, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0); pushReadImagesToBuffers(vk, *readImagesToBuffersCommandBuffer, queueIndex, attachmentResources, renderPassInfo.getAttachments(), attachmentIsLazy, targetSize); endCommandBuffer(vk, *readImagesToBuffersCommandBuffer); { @@ -5160,7 +5292,10 @@ tcu::TestStatus renderPassTest (Context& context, TestConfig config) waitForFences(vk, device, 1, &fence.get(), VK_TRUE, ~0ull); } } - +#ifdef CTS_USES_VULKANSC + if (!context.getTestContext().getCommandLine().isSubProcess()) + return tcu::TestStatus::pass("Pass"); +#endif if (logAndVerifyImages(log, vk, device, attachmentResources, attachmentIsLazy, renderPassInfo, renderPassClearValues, imageClearValues, subpassRenderInfo, targetSize, config)) return tcu::TestStatus::pass("Pass"); else @@ -5168,6 +5303,198 @@ tcu::TestStatus renderPassTest (Context& context, TestConfig config) } } +class RenderPassNoDrawLoadStoreTestCase : public vkt::TestCase +{ +public: + RenderPassNoDrawLoadStoreTestCase(tcu::TestContext& context, const std::string& name, const std::string& description, bool useRenderPass2); + TestInstance* createInstance (Context& context) const override; +private: + bool m_renderPass2; +}; + +class RenderPassNoDrawLoadStoreTestInstance : public vkt::TestInstance +{ +public: + RenderPassNoDrawLoadStoreTestInstance(Context& context, bool useRenderPass2); + + template + Move createRenderPass (const DeviceInterface& vk, VkDevice vkDevice, RenderingType type); + virtual tcu::TestStatus iterate(void); +private: + bool m_renderPass2; +}; + +RenderPassNoDrawLoadStoreTestCase::RenderPassNoDrawLoadStoreTestCase(tcu::TestContext& context, const std::string& name, const std::string& description, bool useRenderPass2) + : vkt::TestCase(context, name, description), m_renderPass2(useRenderPass2) {} + +RenderPassNoDrawLoadStoreTestInstance::RenderPassNoDrawLoadStoreTestInstance(Context& context, bool useRenderPass2) : vkt::TestInstance(context), m_renderPass2(useRenderPass2) { } + +TestInstance* RenderPassNoDrawLoadStoreTestCase::createInstance(Context& context) const { + return new RenderPassNoDrawLoadStoreTestInstance(context, m_renderPass2); +} + +template +Move RenderPassNoDrawLoadStoreTestInstance::createRenderPass (const DeviceInterface& vk, + VkDevice vkDevice, + RenderingType type) +{ + const VkImageAspectFlags aspectMask = type == RENDERING_TYPE_RENDERPASS_LEGACY ? 0 : VK_IMAGE_ASPECT_COLOR_BIT; + + const AttachmentDesc attachmentDescription = + // Result attachment + AttachmentDesc ( + nullptr, // const void* pNext + (VkAttachmentDescriptionFlags)0, // VkAttachmentDescriptionFlags flags + VK_FORMAT_R8G8B8A8_UNORM, // VkFormat format + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples + VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp + VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout + ); + + const AttachmentRef resultAttachmentRefSubpass0 ( + nullptr, // const void* pNext + 0u, // deUint32 attachment + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout layout + aspectMask // VkImageAspectFlags aspectMask + ); + + const SubpassDesc subpassDescription = + SubpassDesc ( + nullptr, + (VkSubpassDescriptionFlags)0, // VkSubpassDescriptionFlags flags + VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint + 0u, // deUint32 viewMask + 0u, // deUint32 inputAttachmentCount + nullptr, // const VkAttachmentReference* pInputAttachments + 1u, // deUint32 colorAttachmentCount + &resultAttachmentRefSubpass0, // const VkAttachmentReference* pColorAttachments + nullptr, // const VkAttachmentReference* pResolveAttachments + nullptr, // const VkAttachmentReference* pDepthStencilAttachment + 0u, // deUint32 preserveAttachmentCount + nullptr // const deUint32* pPreserveAttachments + ); + + const RenderPassCreateInfo renderPassInfo ( + nullptr, // const void* pNext + (VkRenderPassCreateFlags)0, // VkRenderPassCreateFlags flags + 1u, // deUint32 attachmentCount + &attachmentDescription, // const VkAttachmentDescription* pAttachments + 1u, // deUint32 subpassCount + &subpassDescription, // const VkSubpassDescription* pSubpasses + 0u, // deUint32 dependencyCount + nullptr, // const VkSubpassDependency* pDependencies + 0u, // deUint32 correlatedViewMaskCount + nullptr // const deUint32* pCorrelatedViewMasks + ); + return renderPassInfo.createRenderPass(vk, vkDevice); +} + +tcu::TestStatus RenderPassNoDrawLoadStoreTestInstance::iterate() { + const auto& vkd = m_context.getDeviceInterface(); + const auto device = m_context.getDevice(); + auto& alloc = m_context.getDefaultAllocator(); + + auto imageFormat = VK_FORMAT_R8G8B8A8_UNORM; + auto imageExtent = makeExtent3D(1, 1, 1u); + + const tcu::IVec3 imageDim (static_cast(imageExtent.width), static_cast(imageExtent.height), static_cast(imageExtent.depth)); + const tcu::IVec2 imageSize (imageDim.x(), imageDim.y()); + + const std::vector viewports { makeViewport(imageExtent) }; + const std::vector scissors { makeRect2D(imageExtent) }; + + de::MovePtr colorAttachment; + + const auto qIndex = m_context.getUniversalQueueFamilyIndex(); + + const auto subresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u); + const auto imageUsage = static_cast(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT); + const VkImageCreateInfo imageCreateInfo = + { + VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0u, // VkImageCreateFlags flags; + VK_IMAGE_TYPE_2D, // VkImageType imageType; + imageFormat, // VkFormat format; + imageExtent, // VkExtent3D extent; + 1u, // deUint32 mipLevels; + 1u, // deUint32 arrayLayers; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling; + imageUsage, // VkImageUsageFlags usage; + VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; + 0u, // deUint32 queueFamilyIndexCount; + nullptr, // const deUint32* pQueueFamilyIndices; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; + }; + + colorAttachment = de::MovePtr(new ImageWithMemory(vkd, device, alloc, imageCreateInfo, MemoryRequirement::Any)); + auto colorAttachmentView = makeImageView(vkd, device, colorAttachment->get(), VK_IMAGE_VIEW_TYPE_2D, imageFormat, subresourceRange); + + const auto tcuFormat = mapVkFormat(imageFormat); + const auto outBufferSize = static_cast(static_cast(tcu::getPixelSize(tcuFormat)) * imageExtent.width * imageExtent.height); + + BufferWithMemory outBuffer (vkd, device, alloc, makeBufferCreateInfo(outBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT), MemoryRequirement::HostVisible); + auto& outBufferAlloc = outBuffer.getAllocation(); + void* outBufferData = outBufferAlloc.getHostPtr(); + + Move renderPass; + if (m_renderPass2) { + renderPass = createRenderPass + (vkd, device, RENDERING_TYPE_RENDERPASS_LEGACY); + } else { + renderPass = createRenderPass + (vkd, device, RENDERING_TYPE_RENDERPASS2); + } + + // Framebuffer. + const auto framebuffer = makeFramebuffer(vkd, device, renderPass.get(), colorAttachmentView.get(), imageExtent.width, imageExtent.height); + + const auto clearValueColor = makeClearValueColor(tcu::Vec4(1.0f, 0.0f, 1.0f, 1.0f)); + + auto graphicsPipelineLayout = makePipelineLayout(vkd, device); + auto commandPool = createCommandPool(vkd, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, qIndex); + auto commandBuffer = allocateCommandBuffer(vkd, device, commandPool.get(), VK_COMMAND_BUFFER_LEVEL_PRIMARY); + + beginCommandBuffer(vkd, commandBuffer.get()); + + const VkRenderPassBeginInfo renderPassBeginInfo = + { + VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + *renderPass, // VkRenderPass renderPass; + *framebuffer, // VkFramebuffer framebuffer; + scissors.at(0), // VkRect2D renderArea; + 1, // uint32_t clearValueCount; + &clearValueColor, // const VkClearValue* pClearValues; + }; + vkd.cmdBeginRenderPass(*commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); + vkd.cmdEndRenderPass(*commandBuffer); + auto barrier = makeImageMemoryBarrier(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT, + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, colorAttachment->get(), subresourceRange); + cmdPipelineImageMemoryBarrier(vkd, *commandBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, &barrier); + copyImageToBuffer(vkd, commandBuffer.get(), colorAttachment.get()->get(), outBuffer.get(), imageSize); + endCommandBuffer(vkd, commandBuffer.get()); + submitCommandsAndWait(vkd, device, m_context.getUniversalQueue(), commandBuffer.get()); + invalidateAlloc(vkd, device, outBufferAlloc); + + tcu::ConstPixelBufferAccess outPixels(tcuFormat, imageDim, outBufferData); + auto pixel = outPixels.getPixel(0, 0); + auto expected = tcu::Vec4(1.0f, 0.0f, 1.0f, 1.0f); + + if (pixel != expected) { + std::stringstream output("Pixel isn't equal to clear color: "); + output << pixel << " instead of " << expected; + return tcu::TestStatus::fail(output.str()); + } + + return tcu::TestStatus::pass("Pass"); +} + static const VkFormat s_coreColorFormats[] = { VK_FORMAT_R5G6B5_UNORM_PACK16, @@ -5334,7 +5661,7 @@ void addAttachmentTests (tcu::TestCaseGroup* group, const TestConfigExternal tes }; tcu::TestContext& testCtx (group->getTestContext()); - bool useDynamicRendering (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING); + bool useDynamicRendering (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_DYNAMIC_RENDERING); de::Random rng (1433774382u); for (size_t attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++) @@ -5432,12 +5759,21 @@ void addAttachmentTests (tcu::TestCaseGroup* group, const TestConfigExternal tes const UVec2 renderPos = rng.choose(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions)); const UVec2 renderSize = rng.choose(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes)); - // skip dynamic rendering cases (that don't add coverage) - // this can be done not earlier than after grabbing all random numbers as - // we need to make sure that those tests that will be created for dynamic - // rendering have corresponding renderpass tests with the same name - if (useDynamicRendering && !executeForDynamicRendering) - continue; + if (useDynamicRendering) + { + // skip dynamic rendering cases (that don't add coverage) this can be done not earlier than after grabbing all + // random numbers as we need to make sure that those tests that will be created for dynamic rendering have + // corresponding renderpass tests with the same name + if (!executeForDynamicRendering) + continue; + + // dont repeat non secondary buffer cases when testing secondaryCmdBufferCompletelyContainsDynamicRenderpass flag + if (testConfigExternal.groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass && + (commandBuffer != TestConfig::COMMANDBUFFERTYPES_SECONDARY)) + { + continue; + } + } const TestConfig testConfig (renderPass, render, @@ -5450,7 +5786,7 @@ void addAttachmentTests (tcu::TestCaseGroup* group, const TestConfigExternal tes 1293809, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig); } @@ -5496,7 +5832,7 @@ void addAttachmentWriteMaskTests (tcu::TestCaseGroup* group, const TestConfigExt const VkAttachmentLoadOp stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; const VkAttachmentStoreOp stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; const VkImageLayout initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - const VkImageLayout finalizeLayout = (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) + const VkImageLayout finalizeLayout = (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? initialLayout : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL; @@ -5534,7 +5870,7 @@ void addAttachmentWriteMaskTests (tcu::TestCaseGroup* group, const TestConfigExt 1293809, drawStartNdx, testConfigExternal.allocationKind, - testConfigExternal.renderingType, + testConfigExternal.groupParams, requiredFeatures); addFunctionCaseWithPrograms(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), checkSupport, createTestShaders, renderPassTest, testConfig); @@ -5879,7 +6215,7 @@ void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigEx lastUseOfAttachment[inputAttachmentIndex] = just(subpassIndex); VkImageAspectFlags aspect = 0u; - if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2) + if (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2) { bool col = colorAttachments.find(inputAttachmentIndex) != colorAttachments.end(); aspect = col ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; @@ -5910,7 +6246,8 @@ void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigEx | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT, + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT + | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, dependencyFlags); for (SubpassDependency& dependency : deps) @@ -5918,7 +6255,7 @@ void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigEx if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass) { const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; - const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; + const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT; dependency.setDstAccessMask(newSrcFlags); dependency.setDstAccessMask(newDstFlags); foundDuplicate = true; @@ -6008,7 +6345,7 @@ void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigEx 80329, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig); } @@ -6148,7 +6485,7 @@ void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigEx for (size_t subpassNdx = 1; subpassNdx < attachmentCount; subpassNdx++) { - const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2) ? VK_IMAGE_ASPECT_COLOR_BIT : static_cast(0); + const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2) ? VK_IMAGE_ASPECT_COLOR_BIT : static_cast(0); subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u, vector(1, AttachmentReference((deUint32)(subpassNdx - 1), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)), vector(1, AttachmentReference((deUint32)(subpassNdx), rng.choose(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))), @@ -6187,7 +6524,7 @@ void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigEx | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, - VK_ACCESS_COLOR_ATTACHMENT_READ_BIT, + (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT), byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u)); } @@ -6204,7 +6541,7 @@ void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigEx 80329, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig); } @@ -6249,7 +6586,7 @@ void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(group, "color", "Single color attachment case.", createTestShaders, renderPassTest, testConfig); } @@ -6283,7 +6620,7 @@ void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(group, "depth", "Single depth attachment case.", createTestShaders, renderPassTest, testConfig); } @@ -6317,7 +6654,7 @@ void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(group, "stencil", "Single stencil attachment case.", createTestShaders, renderPassTest, testConfig); } @@ -6351,7 +6688,7 @@ void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(group, "depth_stencil", "Single depth stencil attachment case.", createTestShaders, renderPassTest, testConfig); } @@ -6398,7 +6735,7 @@ void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(group, "color_depth", "Color and depth attachment case.", createTestShaders, renderPassTest, testConfig); } @@ -6445,7 +6782,7 @@ void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(group, "color_stencil", "Color and stencil attachment case.", createTestShaders, renderPassTest, testConfig); } @@ -6492,7 +6829,7 @@ void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(group, "color_depth_stencil", "Color, depth and stencil attachment case.", createTestShaders, renderPassTest, testConfig); } @@ -6519,13 +6856,13 @@ void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(group, "no_attachments", "No attachments case.", createTestShaders, renderPassTest, testConfig); } // color_unused_omit_blend_state - if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) + if (testConfigExternal.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) { vector subpasses; @@ -6571,7 +6908,7 @@ void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(group, "color_unused_omit_blend_state", "Two unused color attachment case without blend state", createTestShaders, renderPassTest, testConfig); } } @@ -6666,7 +7003,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); } @@ -6674,7 +7011,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon formatGroup->addChild(loadOpGroup.release()); } - if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) + if (testConfigExternal.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) { de::MovePtr inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input")); @@ -6685,7 +7022,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++) { - const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2) + const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2) ? static_cast(VK_IMAGE_ASPECT_COLOR_BIT) : static_cast(0); const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op; @@ -6695,7 +7032,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon { const bool useInputAspect = useInputAspectNdx != 0; - if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect) + if (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect) continue; for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++) @@ -6773,7 +7110,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 89246, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "")); addFunctionCaseWithPrograms(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -6850,7 +7187,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 89246, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "")); addFunctionCaseWithPrograms(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -6917,7 +7254,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); addFunctionCaseWithPrograms(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); } @@ -6952,7 +7289,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (string(renderTypes[renderTypeNdx].str) + "_depth_read_only"); addFunctionCaseWithPrograms(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -6986,7 +7323,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 90239, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (string(renderTypes[renderTypeNdx].str) + "_stencil_read_only"); addFunctionCaseWithPrograms(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -6997,7 +7334,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon formatGroup->addChild(loadOpGroup.release()); } - if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) + if (testConfigExternal.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) { de::MovePtr inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input")); @@ -7008,7 +7345,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++) { - const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2) + const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2) ? formatAspectFlags : static_cast(0); const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op; @@ -7018,7 +7355,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon { const bool useInputAspect = useInputAspectNdx != 0; - if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect) + if (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect) continue; for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++) @@ -7096,7 +7433,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 89246, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "")); addFunctionCaseWithPrograms(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -7175,7 +7512,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 89246, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "")); addFunctionCaseWithPrograms(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -7259,7 +7596,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 89246, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only"); addFunctionCaseWithPrograms(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -7338,7 +7675,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 89246, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only"); addFunctionCaseWithPrograms(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -7419,7 +7756,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 89246, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only"); addFunctionCaseWithPrograms(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -7499,7 +7836,7 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon 89246, 0, testConfigExternal.allocationKind, - testConfigExternal.renderingType); + testConfigExternal.groupParams); const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only"); addFunctionCaseWithPrograms(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig); @@ -7522,79 +7859,106 @@ void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testCon } } -void addRenderPassTests (tcu::TestCaseGroup* group, const AllocationKind allocationKind, const RenderingType renderingType) +void addRenderPassTests (tcu::TestCaseGroup* group, const AllocationKind allocationKind, const SharedGroupParams groupParams) { - const TestConfigExternal testConfigExternal (allocationKind, renderingType); + // tests added by this function have both primary and secondary cases and there is no need to repeat them for useSecondaryCmdBuffer flag; + // but cases defined in other files that are later added to those groups in createRenderPassTestsInternal had to be adjusted and run + // for useSecondaryCmdBuffer flag + if (groupParams->useSecondaryCmdBuffer && !groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass) + return; + + const TestConfigExternal testConfigExternal (allocationKind, groupParams); + + // don't repeat cases that don't use CommandBufferTypes::COMMANDBUFFERTYPES_SECONDARY + if (!groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass) + { + addTestGroup(group, "simple", "Simple basic render pass tests", addSimpleTests, testConfigExternal); + addTestGroup(group, "formats", "Tests for different image formats.", addFormatTests, testConfigExternal); + } - addTestGroup(group, "simple", "Simple basic render pass tests", addSimpleTests, testConfigExternal); - addTestGroup(group, "formats", "Tests for different image formats.", addFormatTests, testConfigExternal); addTestGroup(group, "attachment", "Attachment format and count tests with load and store ops and image layouts", addAttachmentTests, testConfigExternal); - addTestGroup(group, "attachment_write_mask", "Attachment write mask tests", addAttachmentWriteMaskTests, testConfigExternal); - if (renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) + // don't repeat cases that don't use CommandBufferTypes::COMMANDBUFFERTYPES_SECONDARY + if (!groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass) + addTestGroup(group, "attachment_write_mask", "Attachment write mask tests", addAttachmentWriteMaskTests, testConfigExternal); + + if (groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING) addTestGroup(group, "attachment_allocation", "Attachment allocation tests", addAttachmentAllocationTests, testConfigExternal); } -de::MovePtr createSuballocationTests(tcu::TestContext& testCtx, RenderingType renderingType) +de::MovePtr createSuballocationTests(tcu::TestContext& testCtx, const SharedGroupParams groupParams) { de::MovePtr suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation RenderPass Tests")); - addRenderPassTests(suballocationTestsGroup.get(), ALLOCATION_KIND_SUBALLOCATED, renderingType); + addRenderPassTests(suballocationTestsGroup.get(), ALLOCATION_KIND_SUBALLOCATED, groupParams); return suballocationTestsGroup; } -de::MovePtr createDedicatedAllocationTests(tcu::TestContext& testCtx, RenderingType renderingType) +de::MovePtr createDedicatedAllocationTests(tcu::TestContext& testCtx, const SharedGroupParams groupParams) { de::MovePtr dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "RenderPass Tests For Dedicated Allocation")); - addRenderPassTests(dedicatedAllocationTestsGroup.get(), ALLOCATION_KIND_DEDICATED, renderingType); + addRenderPassTests(dedicatedAllocationTestsGroup.get(), ALLOCATION_KIND_DEDICATED, groupParams); return dedicatedAllocationTestsGroup; } -tcu::TestCaseGroup* createRenderPassTestsInternal (tcu::TestContext& testCtx, RenderingType renderingType) +tcu::TestCaseGroup* createRenderPassTestsInternal (tcu::TestContext& testCtx, const char* groupName, const SharedGroupParams groupParams) { - const char* renderingTestsGroupName = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "renderpass" : - (renderingType == RENDERING_TYPE_RENDERPASS2) ? "renderpass2" : - (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "dynamic_rendering" : - ""; - const char* renderingTestsGroupDescription = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "RenderPass Tests" : - (renderingType == RENDERING_TYPE_RENDERPASS2) ? "RenderPass2 Tests" : - (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "Dynamic Rendering Tests" : - ""; - - de::MovePtr renderingTests (new tcu::TestCaseGroup(testCtx, renderingTestsGroupName, renderingTestsGroupDescription)); - de::MovePtr suballocationTestGroup = createSuballocationTests(testCtx, renderingType); - de::MovePtr dedicatedAllocationTestGroup = createDedicatedAllocationTests(testCtx, renderingType); + de::MovePtr renderingTests (new tcu::TestCaseGroup(testCtx, groupName, "")); + de::MovePtr suballocationTestGroup = createSuballocationTests(testCtx, groupParams); + de::MovePtr dedicatedAllocationTestGroup = createDedicatedAllocationTests(testCtx, groupParams); + de::MovePtr noDrawGroup {new tcu::TestCaseGroup{testCtx, "no_draws", ""}}; + + const RenderingType renderingType = groupParams->renderingType; switch (renderingType) { case RENDERING_TYPE_RENDERPASS_LEGACY: suballocationTestGroup->addChild(createRenderPassMultisampleTests(testCtx)); - suballocationTestGroup->addChild(createRenderPassMultisampleResolveTests(testCtx)); + suballocationTestGroup->addChild(createRenderPassMultisampleResolveTests(testCtx, groupParams)); suballocationTestGroup->addChild(createRenderPassSubpassDependencyTests(testCtx)); suballocationTestGroup->addChild(createRenderPassSampleReadTests(testCtx)); - suballocationTestGroup->addChild(createRenderPassSparseRenderTargetTests(testCtx)); + noDrawGroup->addChild(new RenderPassNoDrawLoadStoreTestCase(testCtx, "render_pass_no_draw_clear_load_store", "Test clears in a renderpass with no drawing commands", false)); + +#ifndef CTS_USES_VULKANSC + suballocationTestGroup->addChild(createRenderPassSparseRenderTargetTests(testCtx, groupParams)); + renderingTests->addChild(createDepthStencilWriteConditionsTests(testCtx)); +#endif // CTS_USES_VULKANSC renderingTests->addChild(createRenderPassMultipleSubpassesMultipleCommandBuffersTests(testCtx)); + break; case RENDERING_TYPE_RENDERPASS2: suballocationTestGroup->addChild(createRenderPass2MultisampleTests(testCtx)); - suballocationTestGroup->addChild(createRenderPass2MultisampleResolveTests(testCtx)); + suballocationTestGroup->addChild(createRenderPass2MultisampleResolveTests(testCtx, groupParams)); suballocationTestGroup->addChild(createRenderPass2SubpassDependencyTests(testCtx)); suballocationTestGroup->addChild(createRenderPass2SampleReadTests(testCtx)); - suballocationTestGroup->addChild(createRenderPass2SparseRenderTargetTests(testCtx)); + noDrawGroup->addChild(new RenderPassNoDrawLoadStoreTestCase(testCtx, "render_pass2_no_draw_clear_load_store", "Test clears in a renderpass with no drawing commands", true)); + +#ifndef CTS_USES_VULKANSC + suballocationTestGroup->addChild(createRenderPass2SparseRenderTargetTests(testCtx, groupParams)); +#endif // CTS_USES_VULKANSC renderingTests->addChild(createRenderPass2DepthStencilResolveTests(testCtx)); break; +#ifndef CTS_USES_VULKANSC case RENDERING_TYPE_DYNAMIC_RENDERING: - suballocationTestGroup->addChild(createDynamicRenderingMultisampleResolveTests(testCtx)); - suballocationTestGroup->addChild(createDynamicRenderingSparseRenderTargetTests(testCtx)); + suballocationTestGroup->addChild(createDynamicRenderingMultisampleResolveTests(testCtx, groupParams)); + suballocationTestGroup->addChild(createDynamicRenderingSparseRenderTargetTests(testCtx, groupParams)); + + if (groupParams->useSecondaryCmdBuffer == false) + { + renderingTests->addChild(createDynamicRenderingRandomTests(testCtx)); + renderingTests->addChild(createDynamicRenderingBasicTests(testCtx)); + } + break; +#endif // CTS_USES_VULKANSC - renderingTests->addChild(createDynamicRenderingBasicTests(testCtx)); + default: break; } @@ -7604,12 +7968,23 @@ tcu::TestCaseGroup* createRenderPassTestsInternal (tcu::TestContext& testCtx, Re suballocationTestGroup->addChild(createRenderPassUnusedAttachmentSparseFillingTests(testCtx, renderingType)); } - suballocationTestGroup->addChild(createRenderPassUnusedClearAttachmentTests(testCtx, renderingType)); - suballocationTestGroup->addChild(createRenderPassLoadStoreOpNoneTests(testCtx, renderingType)); + suballocationTestGroup->addChild(createRenderPassUnusedClearAttachmentTests(testCtx, groupParams)); + +#ifndef CTS_USES_VULKANSC + suballocationTestGroup->addChild(createRenderPassLoadStoreOpNoneTests(testCtx, groupParams)); + + if (renderingType == RENDERING_TYPE_RENDERPASS2) + { + suballocationTestGroup->addChild(createRenderPassSubpassMergeFeedbackTests(testCtx, renderingType)); + } + + renderingTests->addChild(createFragmentDensityMapTests(testCtx, groupParams)); + renderingTests->addChild(createRenderPassDitheringTests(testCtx, renderingType)); +#endif // CTS_USES_VULKANSC renderingTests->addChild(suballocationTestGroup.release()); renderingTests->addChild(dedicatedAllocationTestGroup.release()); - renderingTests->addChild(createFragmentDensityMapTests(testCtx, renderingType)); + renderingTests->addChild(noDrawGroup.release()); return renderingTests.release(); } @@ -7618,17 +7993,55 @@ tcu::TestCaseGroup* createRenderPassTestsInternal (tcu::TestContext& testCtx, Re tcu::TestCaseGroup* createRenderPassTests (tcu::TestContext& testCtx) { - return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_RENDERPASS_LEGACY); + SharedGroupParams groupParams( + new GroupParams + { + RENDERING_TYPE_RENDERPASS_LEGACY, // RenderingType renderingType; + false, // bool useSecondaryCmdBuffer; + false, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass; + }); + return createRenderPassTestsInternal(testCtx, "renderpass", groupParams); } tcu::TestCaseGroup* createRenderPass2Tests (tcu::TestContext& testCtx) { - return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_RENDERPASS2); + SharedGroupParams groupParams( + new GroupParams + { + RENDERING_TYPE_RENDERPASS2, // RenderingType renderingType; + false, // bool useSecondaryCmdBuffer; + false, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass; + }); + return createRenderPassTestsInternal(testCtx, "renderpass2", groupParams); } tcu::TestCaseGroup* createDynamicRenderingTests(tcu::TestContext& testCtx) { - return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_DYNAMIC_RENDERING); + de::MovePtr dynamicRenderingGroup(new tcu::TestCaseGroup(testCtx, "dynamic_rendering", "Draw using VK_KHR_dynamic_rendering")); + + dynamicRenderingGroup->addChild(createRenderPassTestsInternal(testCtx, "primary_cmd_buff", SharedGroupParams( + new GroupParams + { + RENDERING_TYPE_DYNAMIC_RENDERING, // RenderingType renderingType; + false, // bool useSecondaryCmdBuffer; + false, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass; + }))); + dynamicRenderingGroup->addChild(createRenderPassTestsInternal(testCtx, "partial_secondary_cmd_buff", SharedGroupParams( + new GroupParams + { + RENDERING_TYPE_DYNAMIC_RENDERING, // RenderingType renderingType; + true, // bool useSecondaryCmdBuffer; + false, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass; + }))); + dynamicRenderingGroup->addChild(createRenderPassTestsInternal(testCtx, "complete_secondary_cmd_buff", SharedGroupParams( + new GroupParams + { + RENDERING_TYPE_DYNAMIC_RENDERING, // RenderingType renderingType; + true, // bool useSecondaryCmdBuffer; + true, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass; + }))); + + return dynamicRenderingGroup.release(); } } // vkt