XG: check the tiled source before copying a subresource #992

Open
github-bot wants to merge 3 commits from github-bot/gh-992 into main AGit
Owner

@⁠Marukooh on GitHub · 2026-11-24 10:04 UTC · original
Marukooh:xg-check-copy-source → main · +210 −13 · 4 files · 3 commits · draft

Stacked on #976 and #684. Only the top commit, 3c36945, belongs to this PR.

CopyFromSubresource now checks the backing source range before detiling a volume or array slice. An unreadable source returns E_INVALIDARG before modifying the destination. This addresses the source check noted in the review of #684.

What is in it

  • Validate the source span for each existing detiling path. Keep the existing shader-blob limit for shader callers and use the shared range check for texture backing.
  • Cover unreadable 2D and 3D backing in a synthetic regression case.

Tested

  • Windows GNU Release cross-build with Rust 1.98.0 on CachyOS. Proton Experimental, patched vkd3d-proton 3.1, Intel Core i9-14900KF, RTX 5070 Ti (620.73.04), and DXC 1.9.2609.5.

  • The new synthetic case ended the test process on the #976 base. On this head the XG group passes 7/7 and the shader group passes 4/4, with zero failures or ignores in either filter.

  • Workspace suite under Proton: 719 passed, 4 failed, and 41 ignored, with 2 GPU skip markers included in those totals. Failures were in XAudio2, the synthetic-title end-to-end test, PLS quota, and predication. The full suite is not green.

Regression run

Same retail title and 60-second limit on both builds under Proton, using the smoke helper from #257 and VKD3D_CONFIG=ignore_shared_fence,single_queue. The Windows process-commit counter reported 0 MB under Wine.

xcl-smoke v1
commit: 6bac4b4419886acc940d479dcf8815d0b1804435
gpu: NVIDIA GeForce RTX 5070 Ti
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1387 (PresentX 1387)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: 3c3694501863ccd143a1e909324a9b22cb24e83d
gpu: NVIDIA GeForce RTX 5070 Ti
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1372 (PresentX 1372)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

Native Windows, a native retail smoke pair, and a long run through world loading.

AI use

OpenAI Codex (GPT-6) wrote the change and its test, ran the local checks, and prepared the description.

**@⁠Marukooh** on GitHub · 2026-11-24 10:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/992) `Marukooh:xg-check-copy-source` → `main` · +210 −13 · 4 files · 3 commits · draft Stacked on #976 and #684. Only the top commit, `3c36945`, belongs to this PR. `CopyFromSubresource` now checks the backing source range before detiling a volume or array slice. An unreadable source returns `E_INVALIDARG` before modifying the destination. This addresses the source check noted in the review of #684. **What is in it** - Validate the source span for each existing detiling path. Keep the existing shader-blob limit for shader callers and use the shared range check for texture backing. - Cover unreadable 2D and 3D backing in a synthetic regression case. **Tested** - Windows GNU Release cross-build with Rust 1.98.0 on CachyOS. Proton Experimental, patched vkd3d-proton 3.1, Intel Core i9-14900KF, RTX 5070 Ti (620.73.04), and DXC 1.9.2609.5. - The new synthetic case ended the test process on the #976 base. On this head the XG group passes 7/7 and the shader group passes 4/4, with zero failures or ignores in either filter. - Workspace suite under Proton: 719 passed, 4 failed, and 41 ignored, with 2 GPU skip markers included in those totals. Failures were in XAudio2, the synthetic-title end-to-end test, PLS quota, and predication. The full suite is not green. **Regression run** Same retail title and 60-second limit on both builds under Proton, using the smoke helper from #257 and `VKD3D_CONFIG=ignore_shared_fence,single_queue`. The Windows process-commit counter reported 0 MB under Wine. ``` xcl-smoke v1 commit: 6bac4b4419886acc940d479dcf8815d0b1804435 gpu: NVIDIA GeForce RTX 5070 Ti title: RetailTitle seconds: 60 exit: 0x0 frames shown: 1387 (PresentX 1387) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 0 MB ``` ``` xcl-smoke v1 commit: 3c3694501863ccd143a1e909324a9b22cb24e83d gpu: NVIDIA GeForce RTX 5070 Ti title: RetailTitle seconds: 60 exit: 0x0 frames shown: 1372 (PresentX 1372) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 0 MB ``` **Not tested** Native Windows, a native retail smoke pair, and a long run through world loading. **AI use** OpenAI Codex (GPT-6) wrote the change and its test, ran the local checks, and prepared the description.
CopyFromSubresource (vtable slot #9) takes an extra u32 argument before
src: (dst, plane, sub, arg4, src, row_pitch, slice_pitch). With the old
6-argument signature, src was decoded as row_pitch and rows were copied
far outside dst, causing access violations (#477, #662).

Update copy_from and xg_oracle to the 7-argument ABI, validate row_pitch,
3D slice_pitch, and destination span readability before writing (logging
a bounded warning and returning E_INVALIDARG on invalid spans), and add
2D, 3D, and invalid-span unit tests.

Fixes #477
Part of #662
Reject read-only destinations before detiling and copying rows. Reuse the existing committed writable-span check and cover a committed read-only allocation in the XG regression test.

Assisted-by: OpenAI Codex (GPT-6)
Validate the backing range before detiling in both the array and volume paths. Keep the shader-blob size limit for existing callers while allowing larger texture backing.

Assisted-by: OpenAI Codex (GPT-6)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:39:31 +00:00
Author
Owner

@⁠dcastell1 on GitHub · 2026-11-24 10:21 UTC · original

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 main@02bfd1d (baseline 727 passed, 0 failed, 41 ignored on this box; the head of this PR is based on 9aec53d, which is why the base is stated):

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

Four more passing tests than the baseline; checking the tiled source before copying a subresource ships its own coverage and it runs green here.

Tree restored afterwards (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.

**@⁠dcastell1** on GitHub · 2026-11-24 10:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/992#issuecomment-7128677422) 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 `main@02bfd1d` (baseline **727 passed, 0 failed, 41 ignored** on this box; the head of this PR is based on `9aec53d`, which is why the base is stated): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 731 passed; 0 failed; 41 ignored (exit 0) ``` Four more passing tests than the baseline; checking the tiled source before copying a subresource ships its own coverage and it runs green here. Tree restored afterwards (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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 12:30 UTC · original

Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.

  • cargo test -p xcl --lib hle::xg::: 7 passed, 0 failed — includes the new copy_from_rejects_unreadable_source for the tiled-source check.
  • cargo test -p xcl --test xg_oracle: 6 passed, 0 failed, 12 ignored (sample-gated prints ignored; all runnable oracle comparisons pass).

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

**@⁠DavidM1911** on GitHub · 2026-11-24 12:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/992#issuecomment-7131545673) Independent verification, merged onto current `main` `384f7f7` locally (clean merge). **Machine:** Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug. - `cargo test -p xcl --lib hle::xg::`: **7 passed, 0 failed** — includes the new `copy_from_rejects_unreadable_source` for the tiled-source check. - `cargo test -p xcl --test xg_oracle`: **6 passed, 0 failed, 12 ignored** (sample-gated prints ignored; all runnable oracle comparisons pass). AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 03:32 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 03:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/992#issuecomment-7181802423) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/992/head:github-bot/gh-992'
git switch 'github-bot/gh-992'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-992'
git switch 'github-bot/gh-992'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-992'
git switch 'github-bot/gh-992'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-992'
git switch 'main'
git merge --squash 'github-bot/gh-992'
git switch 'main'
git merge --ff-only 'github-bot/gh-992'
git switch 'main'
git merge 'github-bot/gh-992'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.