void beginRendering(const DeviceInterface& vk,
const VkCommandBuffer commandBuffer,
const VkImageView colorImageView,
- const VkImageView depthImageView,
+ const VkImageView depthStencilImageView,
+ const bool useStencilAttachment,
const VkRect2D& renderArea,
const VkClearValue& clearColorValue,
const VkClearValue& clearDepthValue,
clearColorValue // VkClearValue clearValue;
};
- VkRenderingAttachmentInfoKHR depthAttachment
+ VkRenderingAttachmentInfoKHR depthStencilAttachment
{
VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType;
DE_NULL, // const void* pNext;
- depthImageView, // VkImageView imageView;
+ depthStencilImageView, // VkImageView imageView;
depthImageLayout, // VkImageLayout imageLayout;
VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode;
DE_NULL, // VkImageView resolveImageView;
{
VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,
DE_NULL,
- renderingFlags, // VkRenderingFlagsKHR flags;
- renderArea, // VkRect2D renderArea;
- layerCount, // deUint32 layerCount;
- viewMask, // deUint32 viewMask;
- 1u, // deUint32 colorAttachmentCount;
- &colorAttachment, // const VkRenderingAttachmentInfoKHR* pColorAttachments;
- &depthAttachment, // const VkRenderingAttachmentInfoKHR* pDepthAttachment;
- DE_NULL, // const VkRenderingAttachmentInfoKHR* pStencilAttachment;
+ renderingFlags, // VkRenderingFlagsKHR flags;
+ renderArea, // VkRect2D renderArea;
+ layerCount, // deUint32 layerCount;
+ viewMask, // deUint32 viewMask;
+ 1u, // deUint32 colorAttachmentCount;
+ &colorAttachment, // const VkRenderingAttachmentInfoKHR* pColorAttachments;
+ &depthStencilAttachment, // const VkRenderingAttachmentInfoKHR* pDepthAttachment;
+ useStencilAttachment ? &depthStencilAttachment : DE_NULL, // const VkRenderingAttachmentInfoKHR* pStencilAttachment;
};
vk.cmdBeginRenderingKHR(commandBuffer, &renderingInfo);
void beginRendering (const DeviceInterface& vk,
const VkCommandBuffer commandBuffer,
const VkImageView colorImageView,
- const VkImageView depthImageView,
+ const VkImageView depthStencilImageView,
+ const bool useStencilAttachment,
const VkRect2D& renderArea,
const VkClearValue& clearColorValue,
const VkClearValue& clearDepthValue,
}
if (m_params.useDynamicRendering)
- beginRendering(vk, *cmdBuffer, *m_colorTargetView, *m_depthTargetView, makeRect2D(kImageExtent), clearColor, clearDepth);
+ beginRendering(vk, *cmdBuffer, *m_colorTargetView, *m_depthTargetView, false, makeRect2D(kImageExtent), clearColor, clearDepth);
else
beginRenderPass(vk, *cmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(kImageExtent));
if (m_params.useDynamicRendering)
{
- // Transition color attachment to the proper initial layout for dynamic rendering
+ // Transition color and depth stencil attachment to the proper initial layout for dynamic rendering
const auto colorPreBarrier = makeImageMemoryBarrier(
0u,
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
vkd.cmdPipelineBarrier(
cmdBuffer,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
- (VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT),
+ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
0u, 0u, nullptr, 0u, nullptr, 1u, &colorPreBarrier);
- beginRendering(vkd, cmdBuffer, *colorBufferView, *dsBufferView, scissor, clearValues[0], clearValues[1],
+ const auto dsPreBarrier = makeImageMemoryBarrier(
+ 0u,
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
+ VK_IMAGE_LAYOUT_UNDEFINED,
+ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
+ dsBuffer.get(), dsSubresourceRange);
+
+ vkd.cmdPipelineBarrier(
+ cmdBuffer,
+ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
+ (VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT),
+ 0u, 0u, nullptr, 0u, nullptr, 1u, &dsPreBarrier);
+
+ beginRendering(vkd, cmdBuffer, *colorBufferView, *dsBufferView, true, scissor, clearValues[0], clearValues[1],
vk::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
VK_ATTACHMENT_LOAD_OP_CLEAR);
}