Fix D3D12 depth format and stencil barrier issues in Render Graph
This commit is contained in:
@@ -294,7 +294,7 @@ internal class RenderGraphBuilder : IRasterRenderGraphBuilder, IComputeRenderGra
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDepthAttachment(Identifier<RGTexture> texture, AccessFlags flags = AccessFlags.ReadWrite)
|
||||
public void SetDepthAttachment(Identifier<RGTexture> texture, AccessFlags flags = AccessFlags.WriteAll)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
|
||||
@@ -144,11 +144,13 @@ internal sealed class RenderGraphExecutor
|
||||
? nativePass.depthAttachment.storeOp
|
||||
: AttachmentStoreOp.DontCare,
|
||||
StencilLoadOp = nativePass.hasDepthAttachment
|
||||
? nativePass.depthAttachment.loadOp
|
||||
? nativePass.depthAttachment.stencilLoadOp
|
||||
: AttachmentLoadOp.DontCare,
|
||||
StencilStoreOp = nativePass.hasDepthAttachment
|
||||
? nativePass.depthAttachment.storeOp
|
||||
: AttachmentStoreOp.DontCare
|
||||
? nativePass.depthAttachment.stencilStoreOp
|
||||
: AttachmentStoreOp.DontCare,
|
||||
HasStencil = nativePass.hasDepthAttachment &&
|
||||
(_resources.GetResource(nativePass.depthAttachment.texture).rgTextureDesc.format == TextureFormat.D24_UNorm_S8_UInt)
|
||||
};
|
||||
|
||||
commandBuffer.BeginRenderPass(new Span<PassRenderTargetDesc>(pPassRTDescs, nativePass.colorAttachmentCount), depthDesc);
|
||||
|
||||
@@ -365,6 +365,18 @@ internal sealed class RenderGraphNativePassBuilder
|
||||
attachment.storeOp = AttachmentStoreOp.Store;
|
||||
}
|
||||
|
||||
var hasStencil = resource.rgTextureDesc.format == TextureFormat.D24_UNorm_S8_UInt;
|
||||
if (hasStencil)
|
||||
{
|
||||
attachment.stencilLoadOp = attachment.loadOp;
|
||||
attachment.stencilStoreOp = attachment.storeOp;
|
||||
}
|
||||
else
|
||||
{
|
||||
attachment.stencilLoadOp = AttachmentLoadOp.DontCare;
|
||||
attachment.stencilStoreOp = AttachmentStoreOp.DontCare;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,6 +384,8 @@ internal struct DepthStencilInfo
|
||||
public AccessFlags access;
|
||||
public AttachmentLoadOp loadOp;
|
||||
public AttachmentStoreOp storeOp;
|
||||
public AttachmentLoadOp stencilLoadOp;
|
||||
public AttachmentStoreOp stencilStoreOp;
|
||||
public float clearDepth;
|
||||
public byte clearStencil;
|
||||
}
|
||||
Reference in New Issue
Block a user