D3D12.X: coalesce released shared sampler ranges and fix view/census checks in console_heap #2261
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2261
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2261/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Decodere on GitHub · 2026-11-25 11:45 UTC · original
Decodere:fix-1991-global-sampler-heap-bugs→main· +154 −3 · 1 files · 1 commits · merged 2026-11-25 18:16 UTCWhat is in it
Follow-up to #1991 fixing three bugs in
crates/xcl/src/hle/d3d12x/console_heap.rs(GLOBAL_SAMPLERshared shader-visible PC sampler heap):release_global_sampler):release_global_samplerpreviously pushed raw(first, count)entries ontos.freewithout guardingcount == 0or callingmerge_release(&mut s.free, first, count)(unlikerelease_global). Because D3D12 capsGLOBAL_SAMPLERat 2048 descriptors (2047 usable) and small/tail sampler pages reserve< 8slots, freeing adjacent small sampler heaps left unmerged shards (e.g.[(1, 4), (5, 4)]) that could not satisfy an 8-slotSAMPLER_PAGE_SLOTSrequest, causing premature exhaustion and fallback to reserved zero-sampler slot 0. Guardif count == 0 { return; }and coalesce viamerge_release(&mut s.free, first, count).in_global(obj):in_global(obj)checkedh.obj == obj && !h.pages.is_empty()without!h.sampler. Once #1991 populatedh.pagesfor shared sampler heaps,in_globalfalsely returnedtruefor every shared sampler heap (even though it queries membership in the shared view heap). Add&& !h.sampler.census()(sampler_own_index):census()compared samplerw[3] & 0xFFF == kinstead of the slot's actual index inGLOBAL_SAMPLER, misreporting live shared samplers as"with another"underXCL_TRACE_FRAME. Extractsampler_own_index(&h.pages, k)(returningf + (k % SAMPLER_PAGE_SLOTS)when mapped, orsampler_unmapped_index(!pages.is_empty(), k)when unmapped/unhosted — matchingslot()and view-heapown_index) and use it incensus().Tested
1.9.2609.5(01b62ad4), release build.0 passed, 3 failed:release_global_sampler_merges_adjacent_ranges_and_ignores_zero_countsaw unmerged[(5, 4), (1, 4), (1, 0)]instead of[(1, 8)],in_global_excludes_shared_sampler_heapsfailed!in_global(0xC100), andsampler_own_index_tracks_mapped_pages_and_fallbacksreturned0instead of1).cargo test --release -p xcl --lib hle::d3d12x::console_heap::tests -- --test-threads=4 --nocapture): 12 passed, 0 failed, 0 ignored (0.24 s; all 9 existingconsole_heaptests including real RTX 4060 shared-heap tests + 3 new pure-CPU CI-safe tests:release_global_sampler_merges_adjacent_ranges_and_ignores_zero_count,in_global_excludes_shared_sampler_heaps, andsampler_own_index_tracks_mapped_pages_and_fallbacks).cargo build --release --workspaceandcargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture): 23 test binaries, 1246 passed, 0 failed, 46 ignored, plus 27 runtimeSKIPPEDlines (20no wave64on RTX 4060,3wave32 per-lane formrefusedby driver,2missingd3d12SDKLayers.dll/ D3D12 debug layer,1driver shader cache toggle unavailable,1no heap windows).Regression run
Baseline (
origin/main426a5a74):PR head (
a45cffdc):Not tested
#[ignore]tests on this machine.XCL_TRACE_FRAMElog output from a retail title saturatingGLOBAL_SAMPLER(thesampler_own_indexmapping,in_globalseparation, andrelease_global_samplercoalescing/unregister paths are verified by the new deterministic unit tests, while normal shared sampler/view heap runtime operation is verified byconsole_heap::testsand the 60 s RTX 4060 smoke run).AI use
Implemented and verified with Google Antigravity (Gemini 4 Neon). All code changes, failing-first and post-fix unit tests, full workspace release tests, and paired 60 s RTX 4060 smoke runs were reviewed and executed locally.
@DavidM1911 on GitHub · 2026-11-25 16:53 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@futurepro62 on GitHub · 2026-11-25 15:19 UTC · original · edited 2026-11-25 17:09 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
a45cffd(on its base426a5a7).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1234 passed, 0 failed, 44 ignored. SKIPPED (no wave64, no xgameruntime.dll):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,test_title_draws_with_a_root_signature_under_the_debug_layer,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.release_global_sampler_merges_adjacent_ranges_and_ignores_zero_count,in_global_excludes_shared_sampler_heaps,sampler_own_index_tracks_mapped_pages_and_fallbacks.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1175 passed, 1 failed, 26 ignored. The failure isgpu::recomp::tests::gpu_image_get_resinfo_past_last_level(the AMD driver returns the clamped level's sizes, e.g.2D mip 0x1: [4, 2, 0, 1], where the test expects[0, 0, 0, 1]). It reproduced when run alone. It is not caused by this PR: the PR's base426a5a7has that test but not main's AMD fix for it,ea088a5("image_get_resinfo past the last level gives 0 sizes on AMD too"). Main06c9f55passes it on the same iGPU, so a rebase onto current main should clear it.--skipleaves out tests that fail on main568e7dbtoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use