Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend D3D11 Depth Test Overlay #3118

Conversation

Zorro666
Copy link
Collaborator

@Zorro666 Zorro666 commented Nov 7, 2023

Description

D3D11 Replay support for Issue #2858

This is a PR in a sequence of PRs which all together complete the implementation of the feature.
Future PRs will cover replay support for D3D12, Vulkan and extending the automated overlay tests GL_Overlay_Test, D3D11_Overlay_Test, D3D12_Overlay_Test, VK_Overlay_Test.

The feature enables supporting shader exported depth for the Depth Test overlay by replaying the draw using the pixel shader from the capture instead of a replacement shader. Depth test passing pixels are identified by using the stencil buffer to generate a stencil mask.

If the depth buffer used for the draw does not have a stencil buffer then a new depth buffer is created with a depth+stencil format and a fullscreen pass is used to copy depth from the original depth buffer to the newly created depth+stencil buffer.

Changes to existing implementation

  • Don't write depth or stencil during the reply of failing pixels
  • No need to restore depth-stencil after replay of failing pixels

Tested on Windows using changes to D3D11_Overlay_Test

The change makes the pixel shader write out depth 0.0 for a small rectangle just bottom-left of the centre

Before (using v1.29) : the rectangle of output depth 0.0 is shown as failing the depth test

Depth Buffer format D24_S8
image
Depth Buffer format D32_S8
image
Depth Buffer format D16 MSAA
image
Depth Buffer format D32 MSAA
image

After : the rectangle of output depth 0.0 is shown as passing the depth test

Depth Buffer format D24_S8
image
Depth Buffer format D32_S8
image
Depth Buffer format D16 MSAA
image
Depth Buffer format D32 MSAA
image

Support shader exported depth by replaying using the capture pixel shader to determine passing pixels

Don't write depth or stencil during the reply of failing pixels
No need to restore depth-stencil after replay of failing pixels

void RENDERDOC_DepthCopyPS(float4 pos : SV_Position, out float depth : SV_Depth)
{
int2 srcCoord = int2(int(pos.x), int(pos.y));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: I believe this could just be int2 srcCoord = int2(pos.xy);.

@Zorro666 Zorro666 merged commit e1e179b into baldurk:v1.x Nov 9, 2023
16 checks passed
@Zorro666 Zorro666 deleted the support-shader-exported-depth-in-depth-test-overlay-d3d11 branch November 9, 2023 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants