Repository navigation
D3D12.X: unmap a superseded texture only once the work before it is done - #2270
Open
joeypercia wants to merge 1 commit into
Open
joeypercia wants to merge 1 commit into
joeypercia wants to merge 1 commit into
Conversation
`unmap_superseded` NULL-mapped a placed texture's tiles on the tile-mapping queue the moment a newer placement covered it, with nothing ordering that against work already submitted that copies to or samples the texture. On NVIDIA Ampere and Blackwell GPUs a reserved texture whose tiles go NULL while a copy into it runs removes the device: the synthetic probe on xcl-dev#2057 (copies on one queue, the mapping flipped to NULL on another) gives 0x887a0006 on an RTX 5070 after 1.8 s, and passes on an RTX 4070 Ti (Ada). Title runs on xcl-dev#2057 on those GPUs end in a DRED page fault inside a run of CopyTextureRegion on a live texture. A mark (a fence signal) now goes on every title queue and upload queue, and the unmap, with the return of the texture's tiles, waits in a list until the CPU sees every mark done; `before_execute` makes the ones that are. The mapping queue never waits for a title queue, so the cycle found in xcl-dev#594 (a title queue waiting for work submitted later, behind the mapping queue) can't form. The design is upipibi's and Ali-AbdulHadii's from xcl-dev#594. A texture mapped again before its unmap is made keeps its tiles.
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
vram::unmap_supersededNULL-maps a placed texture's tiles on the tile-mapping queue the moment a newer placement covers it. Nothing orders that against work already submitted that copies to or samples the texture. Changing a reserved texture's mappings under a copy that's running removes the device on at least one NVIDIA Blackwell card. With the probe, which copies on one queue while the mapping flips to NULL on another:0x887A0006after 1.8 s (Dezmonius).Title runs on #2057 on an RTX 5080 and an RTX 3080 Ti end in a DRED page fault on a live texture inside a run of
CopyTextureRegions (kanade333, dhillonjagdeep650-boop). This race is a cause that fits; whether it's the cause of those runs is not shown yet.Now
unmap_supersededputs a mark (a fence signal) on every queue the title submitted to and on XCL's upload queues. The unmap, with the return of the texture's tiles to the pool, waits in a list until the CPU sees every mark done.before_executemakes the ones that are. The mapping queue never waits for a title queue. That is the cycle found in #594: a title queue waiting for work submitted later on another queue, which waits behind the mapping queue. The design is @upipibi's from #594 and the variant @Ali-AbdulHadii ran there. #594 itself (@Abdellah-Khanani) waits on the GPU and conflicts withmainnow. This PR replaces that approach, and I'm happy to close it in favour of an update of #594 if its authors prefer.Part of #1773. Related: #475, #594.
What is in it (
crates/xcl/src/hle/d3d12x/vram.rs, one commit)Pages::mark(a reusable fence per queue),HeldUnmapandPages::release_held.unmap_supersededholds the unmap. If a mark can't be made, the texture stays mapped, as before any unmap.before_executemakes the held unmaps whose marks are done. Their textures are let go of afterPAGESis unlocked, because the last reference's release comes back toforget_pages.remap_if_unmappeddrops a held unmap: the texture never lost its tiles.a_superseded_texture_keeps_its_tiles_until_the_work_before_it_is_done. A title queue's submitted work is held behind a fence. The superseded texture keeps its tiles until that work is done and gets no NULL mapping before then, then the tiles go back. A texture mapped again before its unmap keeps its tiles, and its unmap is dropped. With the unmap made at once (as onmain), the test fails at "no unmap yet".Tested
XCL_ADAPTER=Radeon; Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.8.2502.11; debug for the tests, release for the runs.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4onb7f6b76:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, which fails the same way onmain1a0bbe3on this iGPU (DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115).... ok), not skipped.SKIPPED: RTX 4070 Ti: the wave64 cases of thelower/lower_dxilGPU tests,gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64). RDNA2: the mesh-shader tests. Both:heap_window_out_of_memory_falls_back_to_the_switch_form,pso_measurement_compiles_an_exact_synthetic_record(no Developer Mode),test_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_state, and thelower_dxilf16 / f32 cases the direct backend refuses.Regression run
RTX 4070 Ti (driver 621.40), release builds, 60 s each,
scripts/smoke.ps1 -Game <folder> -Title retail-titleon the newer retail title, one after the other from the same shell with the same settings.main1a0bbe3(this PR's base) and this PR's head (no uncommitted changes):main:
PR:
Not tested
r_null_during_copyqturned into XCL calls, would settle it.title_texturesshadows it).AI use