D3D12.X: track sampled texture resident and SRV-sampled texels #2730
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!2730
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2730"
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?
@O5-7 on GitHub · 2026-11-26 09:06 UTC · original
O5-7:vram/ws5-texel-accounting→main· +446 −3 · 3 files · 3 commits · openWhat is in it
TexelMeta(virtual texels, resident texels, and deduplicated per-(slice, mip)coverage acrossTexture1D/Texture2D/Texture3D/arrays/cubes, resolvingres.GetDesc()andMipLevels == 0full mip chains) on placed sampled textures incrates/xcl/src/hle/d3d12x/vram.rs, updated on placement,map_levels,unmap_superseded,remap_if_unmapped,forget_pages, and SRV creation (dev_create_srv_xincrates/xcl/src/hle/d3d12x/real.rs).texture residency: N sampled (M with SRV); texels X.XM resident / Y.YM srv-sampled / Z.ZM virtual (P% resident)line inXCL_ACTIVITY=1right aftermemory:incrates/xcl/src/host.rs(keeping thememory:line untouched; texels live on their own line next tomemory_report::Snapshot::partsas suggested on #2697).Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release build (cargo build --release -p xcl).cargo test -p xcl --lib vram::tests -- --nocaptureon head2e63cbcf: 24 passed, 0 failed, 1 ignored (churn_update_tile_mappings_timing), including 5 texel accounting unit tests (mip_texels_and_range_for_2d_array_3d_and_1d,srv_coverage_respects_most_detailed_mip_levels_min_lod_clamp_and_slices,texel_meta_unions_overlapping_srv_ranges_without_double_counting,texel_meta_tracks_array_slice_coverage_without_overcounting,texel_meta_resolves_implicit_zero_mip_levels_to_full_chain). (cargo test --workspace -- --test-threads=4: 1438 passed, 0 failed, 47 ignored on base PR commit5c09fc39.)Regression run
Not tested
9cc6a39ewere run, and#[ignore]hardware/oracle tests were skipped.TexelStats(by design: this accounts placed sampled textures invram::PAGES).AI use
MipLevels=0fixes, unit tests, and regression runs, reviewed and verified locally.@luckyteagirl on GitHub · 2026-11-26 09:12 UTC · original · reviewed
On
5c09fc3,srv_mip_rangeextracts only mip fields fromTexture1DArray,Texture2DArray, andTextureCubeArraySRVs.record_srvthen deduplicates only by mip bit andmask_texelscounts each selected mip using the resource's fullDepthOrArraySize. For a 64×64 six-slice 2D array with an explicit mip-0 SRV exposing only slice 0, the newsrv-sampledcounter adds 24,576 texels rather than the 4,096 the view can sample. A second SRV exposing slice 1 adds zero because mip 0 is already marked. That makes the array/cube-array metric insensitive to slice coverage despite this PR claiming SRV-sampled texels.Could the coverage union include array slices as well as mip levels, or label the current number as a whole-mip upper bound? A CPU fixture with one-slice, duplicate, and different-slice SRVs could assert increments of 4,096, 0, and 4,096 respectively. This is source review only; I did not run the fixture or a title.
@luckyteagirl on GitHub · 2026-11-26 10:51 UTC · original · reviewed
On
5c09fc3924200753340b6900e664aea0faf2c48c, could the texel metadata use the created resource's resolved mip count when the input descriptor hasMipLevels=0? D3D12 defines zero as requesting the maximum mip chain.place_on_pagescreates the reserved resource, but then passes the original descriptor toTexelMeta::from_desc, wheredesc.MipLevels.max(1)treats zero as one level. For a supported 64×64 non-array sampled texture, a default full-resource SRV should cover seven levels / 5,461 texels; the new counters record only mip 0 / 4,096. This is separate from the array-slice coverage point already posted. Could metadata useres.GetDesc()(or expand the zero sentinel) and include an implicit-full-chain fixture? This is source and D3D12-contract review with arithmetic; I did not run the GPU fixture.AI use: OpenAI Codex (GPT-6.2 Sol) found the mismatch; a second GPT-6.2 Sol agent and OpenAI Codex (GPT-6.2 Astra) independently checked the creation path and wrote this review.
@O5-7 on GitHub · 2026-11-26 12:04 UTC · original
@luckyteagirl Addressed both review points in
2e63cbcf:(slice, mip)pair (srv_coverage+TexelMeta::srv_extra_slicesfor slices>= 1), handlingTexture1DArray/Texture2DArray(FirstArraySlice+ArraySize) andTextureCubeArray(First2DArrayFace+NumCubes * 6) without overcounting unsampled slices. Addedtexel_meta_tracks_array_slice_coverage_without_overcountingasserting4096,0,4096increments on single-slice / duplicate / next-slice SRVs.MipLevels == 0to the full mip chain via bothres.GetDesc()inplace_on_pagesandresolved_mip_levels()inTexelMeta::from_desc. Addedtexel_meta_resolves_implicit_zero_mip_levels_to_full_chain(64x64MipLevels: 0->7levels /5461texels).Re-verified
cargo test -p xcl --lib vram::tests(24 passed, 0 failed, 1 ignored) and 60 ssmoke.ps1on2e63cbcf.@Prime1997 on GitHub · 2026-11-26 13:06 UTC · original · reviewed
Good within the reviewed scope; retain for integration. The resident-versus-SRV-covered texture accounting is worth keeping as preparation for memory diagnostics.
Clean PR head
2e63cbcf565d7309e10da2cddbec37c40e0eb990, based directly on current mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7.Targeted result: 6 passed, 0 failed, 0 ignored, 0 skipped. Each exact filter ran in a fresh process:
hle::d3d12x::vram::tests::the_tiles_of_a_texture_are_grouped_by_its_levelshle::d3d12x::vram::tests::mip_texels_and_range_for_2d_array_3d_and_1dhle::d3d12x::vram::tests::srv_coverage_respects_most_detailed_mip_levels_min_lod_clamp_and_sliceshle::d3d12x::vram::tests::texel_meta_unions_overlapping_srv_ranges_without_double_countinghle::d3d12x::vram::tests::texel_meta_tracks_array_slice_coverage_without_overcountinghle::d3d12x::vram::tests::texel_meta_resolves_implicit_zero_mip_levels_to_full_chainBuild:
cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated-target>. Run:<test-exe> <each-exact-filter-above> --exact --test-threads=1 --nocapture. Private executable/target paths are placeholders. Windows 11 Pro 26200, i5-10400, 32 GiB RAM, Rust 1.100.0 MSVC debug. These selected fixtures did not dispatch GPU work.Not tested: Six CPU bookkeeping tests passed. SRV coverage means the union of created views, not texels actually read by shaders; no eviction or VRAM saving was demonstrated. No whole suite or retail smoke was run for this batch; this is not merge certification.
AI use: Codex (GPT-6) reviewed source, ran the selected tests and verified raw results. Optional temporary Discord for coordinating contributor work, testing and comparing results.
@Decodere on GitHub · 2026-11-26 13:10 UTC · original
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2730 at
2e63cbcf565d7309e10da2cddbec37c40e0eb990(parent5c09fc3924200753340b6900e664aea0faf2c48c; merge-baseorigin/mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.Setup
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200rustc 1.100.0 (0ef1bc386 2026-11-09), DXC1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)title: 29640639viascripts/smoke.ps1 -Seconds 60(XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)Targeted RTX 4060 release unit tests (
2e63cbcf)cargo test --release -p xcl --lib hle::d3d12x::vram:: -- --test-threads=4: 24 passed, 0 failed, 1 ignored (2.45 s,churn_update_tile_mappings_timingignored,0skipped, exit0), covering all 5 new texel/SRV-coverage tests (mip_texels_and_range_for_2d_array_3d_and_1d,srv_coverage_respects_most_detailed_mip_levels_min_lod_clamp_and_slices,texel_meta_resolves_implicit_zero_mip_levels_to_full_chain,texel_meta_tracks_array_slice_coverage_without_overcounting, andtexel_meta_unions_overlapping_srv_ranges_without_double_counting).cargo test --release -p xcl --lib hle::d3d12x::real:: -- --test-threads=4: 60 passed, 0 failed, 0 ignored (0.64 s,0skipped, exit0).Live 8 GB RTX 4060
texture residency:telemetry (XCL_ACTIVITY=1, 60 s)29legacymemory:lines paired with28texture residency:lines (4.0 s .. 58.0 s);0/28invariant violations (with_srv <= sampled,resident <= virtual, andsrv-sampled <= virtualheld on every sample;scripts/smoke.ps1parsing unaffected).exit: 0x0,1597frames shown,60 60 60steady-state presents per 2 s,0device removals,0crashes,14021 MBpeak commit vsorigin/mainb49be183's14018 MB/1518frames).Paired 60 s RTX 4060 smoke (
b49be183vs2e63cbcf)Merge-base
origin/main(b49be183):PR #2730 head (
2e63cbcf):Limits of coverage
2e63cbcf(only targetedhle::d3d12x::vram::andhle::d3d12x::real::release tests plus paired quiet 60 s smoke).97%texel residency (527sampled textures); extended world-load mip-eviction / lower-residency regimes were not exercised here.RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.AI use
Ran the targeted release unit tests, paired quiet 60 s smoke runs, and
xcl.loginvariant checks with assistance from Google Antigravity (Gemini 4 Neon); all test counts, verbatim log lines, and smoke blocks were taken directly fromcargo test,xcl.log, andscripts/smoke.ps1outputs.@Prime1997 on GitHub · 2026-11-26 13:41 UTC · original · reviewed
Disposition correction: needs a label change; retain the accounting work. My earlier six passing CPU tests and their stated scope remain valid. However, the runtime label
srv-sampledinhost.rsoverstates what this measures:vram.rsORs coverage from SRVs created during the resource lifetime and retains that union until resource removal. It does not observe which mip levels shaders sampled, and replacing a view does not subtract its old coverage.Please label the output as lifetime created-SRV coverage (or equivalent wording), reserving sampled terminology for actual usage evidence. The implementation and tests remain useful preparation; the naming change is needed before treating this as sampled-memory telemetry. No additional native test is needed to establish this source-level wording mismatch.
AI use: Codex (GPT-6) cross-checked the runtime label against its accounting call paths and earlier test evidence. Optional temporary Discord for coordinating contributor work, testing and comparing results.
@O5-7 on GitHub · 2026-11-27 12:25 UTC · original
@Prime1997 Good catch — renamed srv_sampled_texels to srv_covered_texels in TexelStats/TexelMeta and changed the XCL_ACTIVITY label from srv-sampled to created-srv, with updated doc comments clarifying it tracks the cumulative lifetime union of created SRVs for live placed sampled textures rather than shader-observed sampling (updated in
fc5ec2f3).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.