Skip to content

D3D12.X: size large BC texture addresses from the guest layout - #935

Open
Gevroska wants to merge 1 commit into
xcl-dev:mainfrom
Gevroska:xcl-local/committed-bc-texture-size
Open

Gevroska wants to merge 1 commit into
xcl-dev:mainfrom
Gevroska:xcl-local/committed-bc-texture-size

Conversation

@Gevroska

@Gevroska Gevroska commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The committed-texture address fallback can reject a large BC texture whose guest layout fits within the reservation limit. Preserve that layout size when the native resource is created so the fallback can reserve enough CPU address space.

What is in it

  • real.rs uses the supported guest layout when the legacy size estimate rejects a committed BC texture. The wide BC1 regression checks the reservation size and address reuse.
  • The README documents the fallback alongside main’s existing texture support.

Tested

  • Windows 11 25H2, Ryzen 7 5700X, RTX 3080 with driver 616.92, Rust 1.100.0 MSVC and DXC 1.9.2609.5.
  • The 16,384 × 16,384 × 4 BC1 fixture creates the same 512 MiB D3D12 resource in both revisions. Stock main returns no fallback reservation. The update returns the same address on repeated queries and reserves 512 MiB plus 64 KiB.
  • The complete RTX 3080 workspace suites used scripts/test.ps1 --nocapture with four test threads. Stock passed 2,594 tests, and the XG Split wave32 geometry: refuse prefix counts over a mask #44 texture readback and split-worker cache artifact test passed in both revisions. The split-worker test includes the upstream artifact assertions from Tests: verify worker whole-form cache artifacts #3213. The earlier XG Split wave32 geometry: refuse prefix counts over a mask #44 mismatch did not reproduce in the matched current suites.
  • Both suites recorded two additional synthetic-title debug-layer skips because the SDK layers were unavailable.

Libtest totals 2595 passed, 0 failed, 49 ignored, 0 filtered out
28 explicit runtime skip messages
SKIPPED gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64
SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: const_mask, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu: mask_ff0_flbit, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
SKIPPED hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1)
SKIPPED shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)
SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
SKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))

Regression run

Matched 150-second startup smokes used the same title and adapter, separate fresh DXIL caches and on-demand shader preparation (XCL_PREPARE=0). No menu input was sent.

xcl-smoke v1
commit: 7db2f391cefd748d47c7de63d50dd43ebb852185
gpu: NVIDIA GeForce RTX 3080
title: 21222967
seconds: 150
exit: 0x0
frames shown: 3438 (PresentX 3438)
presents per 2 s (last 3): 49 43 52
device removals: 0
crashes: 0
peak commit: 16773 MB
xcl-smoke v1
commit: 421d52b7a9f99a63943c5e06b79f698b51646313
gpu: NVIDIA GeForce RTX 3080
title: 21222967
seconds: 150
exit: 0x0
frames shown: 3590 (PresentX 3590)
presents per 2 s (last 3): 46 52 46
device removals: 0
crashes: 0
peak commit: 16460 MB

Not tested

  • AMD adapters. The retail smokes cover startup and presentation. The wide fallback exercised by the synthetic fixture was unverified in retail.

AI use

  • OpenAI Codex GPT-6 Sol Daybreak and GPT-6.2 Sol assisted with the original implementation and tests. Codex GPT-6.2 Sol rebased the change, ran the current qualification and prepared this description. A separate Codex GPT-6.2 Sol reviewer checked the integration and results.

I reviewed and approved this PR update and its description before publication.

@ettehn

ettehn commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

The two BC1 fixtures on 96a56e0 pass on my RTX 5070 Ti Laptop. There is one more sizing case worth covering: a supported tiled layout can need more space than the legacy estimate even when that estimate fits under the 1 GiB cap. The current early return then discards the XG size. This appears to be a remaining limitation of the original sizing path.

A local change compared the padded guest requirement with the legacy reservation before discarding the original description. It kept the legacy reservation when sufficient and used the recorded layout when more space was needed, with the same cap at reservation time. All four console_format_query_tests passed on Windows, including an additional narrow BC array checked with VirtualQuery. This verifies the reserved CPU range; retail loading and texture upload were outside the test.

OpenAI Codex (GPT-6.2 Astra) assisted with verification.

@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on clean main@beaa245 (713 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
714 passed; 0 failed; 41 ignored   (exit 0)

One more passing test than main: sizing large BC texture addresses from the guest layout is covered and green.

Tree restored afterwards (md5 and a full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head 96a56e0 onto main 9aec53d, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 718 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. large-BC-texture address sizing green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@Gevroska

Copy link
Copy Markdown
Contributor Author

Thanks for testing this. The current fix covers the large-allocation fallback. Your example points to a separate early return that can discard a larger layout size below the cap. I’ll check that path with the narrow BC array before deciding whether to include it in this PR.

@thaqiart139-alt

Copy link
Copy Markdown

Test report for this PR's head 96a56e0, merged into main 689f2db (no conflicts), on AMD RDNA2 with native 64-lane waves and on a 32-lane NVIDIA card.

Tested

  • GPUs: AMD Radeon(TM) Graphics, the RDNA2 iGPU of a Ryzen 7 7800X3D (native wave64, driver 32.0.21045.29003), and NVIDIA GeForce RTX 5070 (driver 32.0.16.2101), chosen with XCL_ADAPTER.
  • System: 32 GB, Windows 11 Home build 26300, Rust 1.100.0, debug, DXC 1.9.2602.17.
  • cargo test --workspace --no-fail-fast -- --test-threads=4:
main 689f2db with this PR
RTX 5070 971 passed, 4 failed, 45 ignored 972 passed, 4 failed, 45 ignored
Radeon iGPU 974 passed, 1 failed, 45 ignored 975 passed, 1 failed, 45 ignored
SKIPPED tests (the same on main and with this PR)
  • RTX 5070:
    • no wave64:
      • gpu::recomp::lower::tests: a_2d_or_3d_group_agrees_with_the_hlsl_path_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, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu
      • gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu, and the wave64 cases of its f16 / f32 / f64 / integer_programs_on_the_gpu
      • gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
    • the wave32 per-lane cases of lower_dxil's f16 arithmetic, f16 packed and f32 conversions: refused ("its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's")
    • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
    • pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode is off)
  • Radeon iGPU:
    • no mesh shaders: gpu::dxil::geometry_tests::gpu_geometry_direct_records, emitted_ms_primitive_attribute_reaches_the_pixel_shader, emitted_ms_ps_draw_a_triangle, gpu_geometry_mode_es_gs_strip, gpu_geometry_mode_es_gs_strip_with_branches, gpu_mesh_mode_two_passes
    • the wave32 and wave64 per-lane cases of lower_dxil's f16 arithmetic, f16 packed and f32 conversions: refused, as above
    • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
    • pso_measurement_compiles_an_exact_synthetic_record (Developer Mode is off)

Not tested

  • a title run (whether a title takes this fallback), Intel, Windows 10; other GPUs; Linux / Wine.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds and tests and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@xpatfussy69x

Copy link
Copy Markdown
Contributor

Test report for head 96a56e0 as pushed (not merged onto current main) – NVIDIA, wave32.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (Ampere, 32-lane waves only), driver 32.0.16.2124; AMD Ryzen 5 7500F; Windows NT 10.0.26300; Rust 1.100.0 (stable-x86_64-pc-windows-msvc); debug; DXC 1.9.2609.5
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 685 passed, 0 failed, 41 ignored
  • SKIPPED GPU tests on this adapter: 2 (no wave64)
  • this PR's GPU test gpu_console_committed_bc_addresses_cover_original_layout ran and passed
  • no XCL_SAMPLE_* data set (game-data tests not run)

One stall, not reproduced. In an earlier full-suite run on this head, four gpu::recomp::tests (gpu_typed_buffer_loads_and_stores, gpu_uma_import_check_at_init, gpu_valu_16_and_64_bit, gpu_wave32_and_wave64_src_vccz_execz) each ran for over 60 s and I stopped the run. I could not make it happen again: cargo test -p xcl --lib gpu::recomp::tests passed on main 568e7db (147 passed, 7 s) and on this head (114 passed, 5 s), and the full-suite run above passed. None of those tests touch this PR's code, so I read it as a one-off on my machine.

Not tested

  • AMD / native wave64; release build; a smoke run on a title (use of the fallback by the retail title); the head merged onto current main

AI use

  • Claude (Claude Opus 5.5) wrote the scripts that ran the tests on my PC, read the logs and wrote and posted this report with my approval; the runs are mine.

@S1m0ne1997

Copy link
Copy Markdown

Test report for 96a56e0ba7127fdb89c47f60bf8f987ec1c9b553 (this PR's head), for #1607.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, rustc 1.100.0 (0ef1bc386 2026-11-09) x86_64-pc-windows-msvc, debug.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 at the head: 685 passed, 0 failed, 41 ignored.
  • SKIPPED (2): gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64).

Regression run (retail title, scripts/smoke.ps1 -Seconds 60, release; main built from the commit in its block, this PR from its head, no uncommitted changes)

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1599 (PresentX 1599)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16384 MB

this PR:

xcl-smoke v1
commit: 96a56e0ba7127fdb89c47f60bf8f987ec1c9b553
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1587 (PresentX 1587)
presents per 2 s (last 3): 60 54 35
device removals: 0
crashes: 0
peak commit: 17922 MB

A first smoke run of this same head crashed: exit 0xc0000005, crashes: 2, no device removal, presents per 2 s (last 3) 57 58 59, frames not logged because the run did not reach its end, peak commit 9 746 MB. That run's block is not pasted because it was made with this branch's older smoke.ps1, which prints the game folder's name instead of its hash (#677). The second run, above, and main's run were clean, so this is 1 crash in 2 runs of this head and 0 in 1 of main: maybe intermittent, maybe unrelated to this PR. I did not look into the crash.

Not tested

  • AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only.

AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.

@Gevroska

Copy link
Copy Markdown
Contributor Author

I reproduced the large BC1 texture reservation failure on Windows with an RTX 3080. I ran the same test on base 6d12f58a and local candidate 7ceb0fbc. Both created the 16,384 × 16,384, four-layer BC1 resource and agreed on its 512 MiB layout. On the base, the CPU address reservation was zero and the test failed. On the candidate, the reservation was 512 MiB plus 64 KiB and the address stayed stable.

I used Codex GPT-6.2 Sol for the first comparison. A separate GPT-6.2 Sol agent repeated both runs on the same adapter and reproduced the failure and pass, with zero skips. This covers the large-texture case. The separate below-cap case remains open.

I’ve carried the change onto b49be183 as local commit b82a8645. Validation of that revision is still in progress.

I reviewed and approved this comment before posting.

@Gevroska

Copy link
Copy Markdown
Contributor Author

I finished validating local candidate b82a8645 against base b49be183 on a GeForce RTX 3080. The base failed to reserve a CPU address for the 16,384 × 16,384, four-layer BC1 texture. The candidate returned a stable reservation of 512 MiB plus 64 KiB.

The standard Windows suite reported 1,436 passed, 0 failed and 47 ignored. I counted 27 structured skip messages and two additional debug-layer skip messages. Both matched 60-second startup runs exited cleanly with zero crashes or device removals: 1,423 frames on the base and 1,457 on the candidate. These runs cover startup. The separate below-cap case and gameplay impact remain unverified.

I used Codex GPT-6 Sol Daybreak for the initial integration and GPT-6.2 Sol for the current-base change, regression test and validation. A separate GPT-6.2 Sol agent independently reviewed the result.

I reviewed and approved this comment before posting.

@Gevroska
Gevroska force-pushed the xcl-local/committed-bc-texture-size branch from 96a56e0 to b82a864 Compare November 26, 2026 22:39
@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #935 at head b82a8645b5bb827c0a65abd98b19149c7f7c5425 (1 commit; exact parent & merge-base: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (b82a8645)

Command Result
cargo test --release -p xcl gpu_console_committed_wide_bc_addresses_cover_original_layout -- --nocapture (3 consecutive runs) 1 passed; 0 failed; 0 ignored; 1336 filtered out × 3 (0.21s, 0.20s, 0.21s); live output on all 3 runs: NVIDIA GeForce RTX 4060: created 16384x16384x4 BC1, XG 0x20000000, D3D12 0x20000000, CPU reserve 0x20010000
cargo test --release -p xcl hle::d3d12x::real:: -- --test-threads=1 (3 consecutive runs) 61 passed; 0 failed; 0 ignored; 1276 filtered out × 3 (2.10s, 2.08s, 2.08s, 0 skipped)
cargo build --release -p xcl Clean build (exit 0, 0 new warnings)

Live test output confirms that on desktop NVIDIA GeForce RTX 4060 (8 GB), the committed 16384x16384x4 BC1_UNORM texture (format 71) retains its 0x20000000-byte XG console layout size and receives the padded 0x20010000-byte CPU fallback reservation (GetGPUVirtualAddress of a committed 16384x16384 texture (format 71, flags 0x0): 0x20010000 bytes ...).

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, cached baseline on the same machine):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

PR #935 (b82a8645b5bb827c0a65abd98b19149c7f7c5425):

xcl-smoke v1
commit: b82a8645b5bb827c0a65abd98b19149c7f7c5425
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1586 (PresentX 1586)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14016 MB

Runtime log observations (xcl.log)

  • 9223 log lines, 0 [ERROR] / device-removal / panic lines.
  • Final draw/memory telemetry in log: 19510 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 14016 MB committed by the process; video memory 6115 MB local, 4682 MB non-local.
  • 0 committed texture GetGPUVirtualAddress fallback reservations logged during the 60 s retail run on title: 29640639.

Limits of coverage

  • The new committed wide BC1 fallback sizing path (COMMITTED_BC_LAYOUT_SIZE private data -> 0x20010000 CPU reserve covering the 0x20000000 console layout) was directly exercised on the RTX 4060 via gpu_console_committed_wide_bc_addresses_cover_original_layout (3/3 pass) and hle::d3d12x::real:: (61/61 × 3).
  • title: 29640639 did not hit the committed wide BC fallback path in 60 s, so the retail smoke confirms zero runtime regression on this title (frame-count delta vs. cached parent smoke reflects single-run startup variance, not this PR).

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@JJAutoCompare

Copy link
Copy Markdown

Tested: Clean b82a8645b5bb827c0a65abd98b19149c7f7c5425, Windows 11 build 26200.9974, Ryzen 7 3800X, Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. cargo test --locked -j 2 -p xcl --lib --no-run then selected layout/format/size filters on the executable: 40 passed. With XCL_ADAPTER=A770, the exact gpu_console_committed_wide_bc_addresses_cover_original_layout and gpu_console_format_allocation_info_is_sane tests each passed. All runs had zero failures, ignores or skips. The wide BC1 case covered a 16,384×16,384 four-layer texture with a 512 MiB guest layout and checked a stable 512 MiB + 64 KiB CPU reservation.

Not tested: Texture sampling, separate below-cap sizing, full workspace suite and retail smoke.

AI use: T3 Code / Codex (gpt-6.2-sol) ran and reran the checks and wrote this report.

@Gevroska
Gevroska force-pushed the xcl-local/committed-bc-texture-size branch 2 times, most recently from e40aecb to d4cebf1 Compare November 28, 2026 18:20
Keep the supported committed BC layout size when the legacy reservation rejects the texture. Cover the native wide BC1 fallback with the fixture that failed before and passed after on the RTX 3080.

Assisted-by: Codex (GPT-6 Sol Daybreak and GPT-6.2 Sol)
(cherry picked from commit b82a864)
(cherry picked from commit d4cebf1)
@Gevroska
Gevroska force-pushed the xcl-local/committed-bc-texture-size branch from d4cebf1 to 421d52b Compare November 28, 2026 22:35
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 28, 2026
@andrewDoing

Copy link
Copy Markdown
Contributor

I reproduced the separate below-cap sizing case on head 421d52b7a9f99a63943c5e06b79f698b51646313, RTX 5070 driver 616.92. I used an 8×8 BC1_UNORM texture, four mips, console layout 0x109. Only the array length differed between the controls.

Layers XG layout size XG byte offset of the last slice's mip-3 BC1 block CPU fallback reservation Native D3D12 allocation
1 0x10000 0x1000 0x20000 0x10000
4 0x40000 0x31000 0x20000 0x10000

Both resources were created through the console committed-resource hook. I checked that neither had a placed title address, that repeated queries returned the same fallback address, and that VirtualQuery reported the reservation. The four-layer resource's legal 8-byte block is wholly outside that reservation. The fixture compared offsets and bounds without touching an unreserved address.

I set XCL_UMA_MB=64 and XCL_COHERENT_MB=64 to exercise the committed fallback under the existing 128 MiB coherent-headroom policy. With the normal larger coherent window the small resource went through placement instead. The supported guest layout is available for both inputs, but remember_committed_bc_layout_size returns early whenever the legacy estimate fits the cap. Considering the guest extent for that case as well would cover the missing slice. This measures CPU address coverage; the fallback does not upload CPU writes to the native texture.

AI use: OpenAI Codex adapted the stock wide-BC test, ran the native controls, and drafted this report.

@Gevroska

Copy link
Copy Markdown
Contributor Author

@andrewDoing, thanks for testing the published head (421d52b7) and for including the one-layer control. Your four-layer result shows the remaining gap clearly: the last mip’s BC1 block starts at 0x31000, beyond the 0x20000 CPU fallback reservation, even though the guest layout covers 0x40000 bytes.

I scoped #935 to the wide-texture case where the legacy estimate exceeds the cap. Your example shows that an estimate can fit under the cap and still leave a valid guest offset outside the reservation. I’d keep the 8×8, four-mip, one-layer versus four-layer comparison as a regression test for a separate below-cap fix. Comparing the offset and reservation size also lets that test demonstrate the bug without touching unreserved memory.

GPT-6.2 Astra drafted this reply from your RTX 5070 measurements and the scope of #935.

I reviewed and approved this comment before posting.

@andrewDoing

Copy link
Copy Markdown
Contributor

For the separate below-cap fix, here is the bounds assertion from the 8×8 BC1 control in a form that can be added alongside the wide-texture regression. Use the same four-mip, 0x109 guest descriptor for both cases, with array length 1 or 4. Set XCL_UMA_MB=64 and XCL_COHERENT_MB=64 in the test process before creating the device. After console committed creation, require title_address to be absent, query the fallback address twice and check equality, then get the reservation's RegionSize via VirtualQuery at that base.

let layout = crate::hle::xg::Texture::new(&desc).unwrap();
let block = layout.element_offset(3, 0, 0, usize::from(layers) - 1);
let end = block.checked_add(8).unwrap(); // one BC1 block, exclusive end
assert_eq!((layout.size(), block), match layers {
    1 => (0x10000, 0x1000),
    4 => (0x40000, 0x31000),
    _ => unreachable!(),
});
assert!(end <= reservation_bytes, "layers={layers}: {end:#x} > {reservation_bytes:#x}");

On 421d52b the one-layer control passes and the four-layer case fails with 0x31008 > 0x20000. This assertion allows larger valid reservations and never forms or dereferences a pointer to the last block. The original native measurements are in the comparison above.

AI-assisted regression note.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head 421d52b

No open or merged PR makes the same change. main's texture_memory still sizes from the PC description and returns None above 1 GiB. The fix only applies to BC textures whose old estimate overflows: the XG layout size is kept as private data at creation. The Build and test (Windows, no GPU) check is red and its log has expired. Rerun it to see whether the failure comes from this PR.

Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.