Skip to content

D3D12: Render Passes Keep What They Draw Again - #474

Merged
dttdrv merged 2 commits into
mainfrom
renderpass-depth-discard
Dec 5, 2026
Merged

dttdrv merged 2 commits into
mainfrom
renderpass-depth-discard

Conversation

@dttdrv

@dttdrv dttdrv commented Dec 5, 2026

Copy link
Copy Markdown
Owner

This fixes two ways a D3D12 render pass lost what it drew since discards were added (#372). vkd3d-proton's test_renderpass_rendering passes again with both.

BeginRenderPass works out a depth stencil buffer's access from both of its planes, starting from a D3D12_RENDER_PASS_BEGINNING_ACCESS{} and a D3D12_RENDER_PASS_ENDING_ACCESS{} meant as "nothing discarded". DISCARD is 0 in both enums, so every depth stencil buffer in a render pass was discarded as the pass began and as it ended: depth and stencil a draw wrote were not stored, and a plane the pass preserved was not loaded. Both now start as PRESERVE.

A discarding access is also declared for one view, but the pass discarded the view's whole texture. Where a pass's targets are slices of one array texture and one of them ends with DISCARD, the others lost what was drawn to them. A pass now discards a texture only through a view of all of it, the way DiscardResource already ignores a region.

d3d12_render_pass gains a depth stencil part (a pass that draws depth and stencil and preserves both, then one that clears only the depth and keeps the stencil) and a part with two slices of one array texture, the second discarded. Both fault patches are caught, and the render pass and discard tests pass on native, 9, 8 and 7 and their Metal 3 runs.

…s are discarded

BeginRenderPass made a depth stencil buffer's access from both planes' accesses, starting from
D3D12_RENDER_PASS_BEGINNING_ACCESS{} and D3D12_RENDER_PASS_ENDING_ACCESS{} as the accesses that discard nothing. DISCARD
is both types' 0, so every depth stencil buffer was discarded as the pass began and as it ended: what a draw wrote to it
was not stored, and a plane the pass preserved was not loaded. They now start as PRESERVE.

d3d12_render_pass draws depth and stencil in a pass that preserves both and reads them back, then clears only the
depth in a second pass and reads that the stencil stayed, the two checks of vkd3d-proton's test_renderpass_rendering
that failed. Its fault d3d12_render_pass.5 puts the zeroed accesses back.
A render pass's discarding access is declared for one view, but BeginRenderPass discarded the view's whole texture:
a pass whose targets were three slices of one array texture, the third ending DISCARD, lost what it drew to the
second (vkd3d-proton's test_renderpass_rendering, line 1646). It now discards only through a view of every mip,
slice and W slice of the texture, and a view of some of it discards nothing, as DiscardResource of a region does.

d3d12_render_pass draws two slices of one array texture in a pass that discards the second and reads that the first
kept what was drawn. Its fault d3d12_render_pass.6 takes the check out.
@dttdrv
dttdrv merged commit 46fa326 into main Dec 5, 2026
19 checks passed
@dttdrv
dttdrv deleted the renderpass-depth-discard branch December 5, 2026 10:36
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.

1 participant