Fix D3D12 depth format and stencil barrier issues in Render Graph

This commit is contained in:
2026-04-01 15:28:25 +09:00
parent a00cb27529
commit 3157596b5d
8 changed files with 65 additions and 10 deletions

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;
}
}
}
}

View File

@@ -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;
}