Skip to content

Commit

Permalink
D3D12: Add render pass flag for read-only depth stencil attachment
Browse files Browse the repository at this point in the history
This patch adds missing D3D12 render pass flag for read-only depth
stencil attachment. Without the flag the D3D12 debug layer will
report `RENDER_PASS_LOCAL_DEPTH_STENCIL_ERROR`.

Note that currently we only add these two flags with Windows SDK
26100 as they are not supported in previous Windows SDKs.

Bug: chromium:381742470
Test: dawn_end2end_tests
Change-Id: Id0d282e42017bf92917b0df299091ba311a9e55a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/217774
Reviewed-by: Loko Kung <[email protected]>
Commit-Queue: Jiawei Shao <[email protected]>
Reviewed-by: Kai Ninomiya <[email protected]>
  • Loading branch information
Jiawei-Shao authored and Dawn LUCI CQ committed Dec 10, 2024
1 parent 6f3bd8a commit 66bf64e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/dawn/native/d3d12/CommandBufferD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,8 @@ MaybeError CommandBuffer::SetupRenderPass(CommandRecordingContext* commandContex
device->GetD3D12Device()->CreateDepthStencilView(
ToBackend(view->GetTexture())->GetD3D12Resource(), &viewDesc, baseDescriptor);

renderPassBuilder->SetDepthStencilView(baseDescriptor);
renderPassBuilder->SetDepthStencilView(baseDescriptor, attachmentInfo.depthReadOnly,
attachmentInfo.stencilReadOnly);

const bool hasDepth = view->GetTexture()->GetFormat().HasDepth();
const bool hasStencil = view->GetTexture()->GetFormat().HasStencil();
Expand Down
12 changes: 11 additions & 1 deletion src/dawn/native/d3d12/RenderPassBuilderD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,18 @@ void RenderPassBuilder::SetRenderTargetView(ColorAttachmentIndex attachmentIndex
}
}

void RenderPassBuilder::SetDepthStencilView(D3D12_CPU_DESCRIPTOR_HANDLE baseDescriptor) {
void RenderPassBuilder::SetDepthStencilView(D3D12_CPU_DESCRIPTOR_HANDLE baseDescriptor,
bool isDepthReadOnly,
bool isStencilReadOnly) {
mRenderPassDepthStencilDesc.cpuDescriptor = baseDescriptor;
#if D3D12_SDK_VERSION >= 612
if (isDepthReadOnly) {
mRenderPassFlags |= D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_DEPTH;
}
if (isStencilReadOnly) {
mRenderPassFlags |= D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_STENCIL;
}
#endif
}

ColorAttachmentIndex RenderPassBuilder::GetHighestColorAttachmentIndexPlusOne() const {
Expand Down
4 changes: 3 additions & 1 deletion src/dawn/native/d3d12/RenderPassBuilderD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class RenderPassBuilder {
void SetRenderTargetView(ColorAttachmentIndex attachmentIndex,
D3D12_CPU_DESCRIPTOR_HANDLE baseDescriptor,
bool isNullRTV);
void SetDepthStencilView(D3D12_CPU_DESCRIPTOR_HANDLE baseDescriptor);
void SetDepthStencilView(D3D12_CPU_DESCRIPTOR_HANDLE baseDescriptor,
bool isDepthReadOnly,
bool isStencilReadOnly);

private:
ColorAttachmentIndex mHighestColorAttachmentIndexPlusOne{uint8_t(0)};
Expand Down

0 comments on commit 66bf64e

Please sign in to comment.