XG: require writable memory for CopyFromSubresource #976

Open
github-bot wants to merge 2 commits from github-bot/gh-976 into main AGit
Owner

@⁠Marukooh on GitHub · 2026-11-24 09:48 UTC · original
Marukooh:xg-require-writable-copy-destination → main · +160 −9 · 3 files · 2 commits · draft

Stacked on #684. Only the top commit, 807fbfb, belongs to this PR.

CopyFromSubresource writes rows to the caller's destination. The range check in #684 also accepts committed read-only memory. Use the existing DirectStorage writable-range check so the call returns E_INVALIDARG before copying to a read-only destination. This addresses the destination check noted in the review of #684.

What is in it

  • Check that the destination is writable before copying, keeping the span arithmetic and size limit from #684.
  • Extend the XG regression test with a committed read-only allocation.

Tested

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

  • On 807fbfb, the workspace cross-build and test build succeeded. Under Proton, XG tests passed 6/6 and DirectStorage tests passed 13/13 (zero failed or ignored in either filter).

  • With just the regression assertion added to the upstream #684 head e56dbc3, the read-only case terminated the synthetic test process. It returns E_INVALIDARG and passes on this PR.

  • Workspace attempt under Proton: cargo test --locked --release --workspace --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4. The test binaries reported 708 passed, 14 failed and 41 ignored, with 89 GPU skip markers included in those totals. Several suites hit Vulkan device-initialization failures. The doctest target could not launch rustdoc in this setup. The full run is not green.

Regression run

Both 60-second smoke runs used the same retail title on the RTX 5070 Ti with Proton and the scripts/linux/smoke.sh helper from #257. Both used VKD3D_CONFIG=ignore_shared_fence,single_queue after the default Vulkan device creation failed. The Windows process-commit counter reported 0 MB under Wine, so these runs do not measure peak commit.

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: 807fbfbc91c884933db7c0c0f14b521b827fc487
gpu: NVIDIA GeForce RTX 5070 Ti
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1383 (PresentX 1383)
presents per 2 s (last 3): 60 60 56
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

Native Windows and the native retail smoke pair.

AI use

OpenAI Codex (GPT-6) wrote the follow-up and its regression case, ran the local checks, and prepared this description.

**@⁠Marukooh** on GitHub · 2026-11-24 09:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/976) `Marukooh:xg-require-writable-copy-destination` → `main` · +160 −9 · 3 files · 2 commits · draft Stacked on #684. Only the top commit, `807fbfb`, belongs to this PR. `CopyFromSubresource` writes rows to the caller's destination. The range check in #684 also accepts committed read-only memory. Use the existing DirectStorage writable-range check so the call returns `E_INVALIDARG` before copying to a read-only destination. This addresses the destination check noted in the review of #684. **What is in it** - Check that the destination is writable before copying, keeping the span arithmetic and size limit from #684. - Extend the XG regression test with a committed read-only allocation. **Tested** - CachyOS, Intel Core i9-14900KF, NVIDIA RTX 5070 Ti (driver 620.73.04), Proton Experimental, patched vkd3d-proton 3.1, DXC 1.9.2609.5. Windows GNU Release build with Rust 1.98.0. - On `807fbfb`, the workspace cross-build and test build succeeded. Under Proton, XG tests passed 6/6 and DirectStorage tests passed 13/13 (zero failed or ignored in either filter). - With just the regression assertion added to the upstream #684 head `e56dbc3`, the read-only case terminated the synthetic test process. It returns `E_INVALIDARG` and passes on this PR. - Workspace attempt under Proton: `cargo test --locked --release --workspace --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`. The test binaries reported 708 passed, 14 failed and 41 ignored, with 89 GPU skip markers included in those totals. Several suites hit Vulkan device-initialization failures. The doctest target could not launch rustdoc in this setup. The full run is not green. **Regression run** Both 60-second smoke runs used the same retail title on the RTX 5070 Ti with Proton and the `scripts/linux/smoke.sh` helper from #257. Both used `VKD3D_CONFIG=ignore_shared_fence,single_queue` after the default Vulkan device creation failed. The Windows process-commit counter reported 0 MB under Wine, so these runs do not measure peak commit. ``` 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: 807fbfbc91c884933db7c0c0f14b521b827fc487 gpu: NVIDIA GeForce RTX 5070 Ti title: RetailTitle seconds: 60 exit: 0x0 frames shown: 1383 (PresentX 1383) presents per 2 s (last 3): 60 60 56 device removals: 0 crashes: 0 peak commit: 0 MB ``` **Not tested** Native Windows and the native retail smoke pair. **AI use** OpenAI Codex (GPT-6) wrote the follow-up and its regression case, ran the local checks, and prepared this 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:38:52 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 12:28 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::: 6 passed, 0 failed — includes the new copy_from_rejects_invalid_dst_span covering the writable-memory requirement.
  • cargo test -p xcl --test xg_oracle: 6 passed, 0 failed, 12 ignored (console-library comparisons need XCL_SAMPLE_*; the layout/copy oracle tests that run locally all pass).

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

**@⁠DavidM1911** on GitHub · 2026-11-24 12:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/976#issuecomment-7131498555) 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::`: **6 passed, 0 failed** — includes the new `copy_from_rejects_invalid_dst_span` covering the writable-memory requirement. - `cargo test -p xcl --test xg_oracle`: **6 passed, 0 failed, 12 ignored** (console-library comparisons need `XCL_SAMPLE_*`; the layout/copy oracle tests that run locally all pass). AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 03:23 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:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/976#issuecomment-7181677704) 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/976/head:github-bot/gh-976'
git switch 'github-bot/gh-976'

Merge

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