Support separate depth and stencil attachments during dynamic rendering #1878
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the introduction of
VK_KHR_dynamic_rendering
, Vulkan permitted separate depth and stencil attachments, which Metal always supported, although in Vulkan, the two attachments are, for the time being, restricted to the same pixel format and image view.This PR implements depth and stencil attachments as separate attachments, and fixes attachment Metal validation errors in the process. This PR is more than strictly necessary to fix the reported Metal validation issues, but better aligns MoltenVK with Metal depth and stencil handling, and is positioned for a potential future enhancement to Vulkan, where separate depth and stencil formats might be supported in the future.
MVKRenderSubpass
add separategetDepthFormat()
&getStencilFormat()
, andisDepthAttachmentUsed()
&isStencilAttachmentUsed()
and use instead of testing pixel format for depth and stencil components.MVKRenderingAttachmentIterator
class to consistently iterate, and take actions, on the attachments in VkRenderingInfo to create syntheticMVKRenderPass
and extract image views and clear colors.mvkCreateRenderPass()
andmvkCreateFramebuffer()
in favor of additional constructors, and removemvkGetDepthStencilFormat()
in favor of retrieving formats for separate depth and stencil attachments.MVKRenderpass
constructors reorganize order of adding attachments and subpasses, and connecting the two.MVKRenderPassAttachment
toMVKAttachmentDescription
.MVKPipeline
reorganize member variables to minimize gaps in content and remove unnecessary_isRasterizingDepthStencil
member var (unrelated).MVKPipeline
validate depth & stencil formats before setting frag shader depth and stencil builtins, and before setting formats inMTLRenderPipelineDescriptor
.MVKCmdClearAttachments
always set depth/stencil format if subpass includes a depth or stencil attachment, even if they are not being cleared.MVKRenderingAttachmentIterator
add synthetic attachment if depth or stencil attachment is not provided, but image format of underlyingMVKImage
supports both depth and stencil.This PR fixes issue #1579.