XG: require writable memory for CopyFromSubresource #970

Open
Marukooh wants to merge 2 commits from upstream-pr/976 into main
Marukooh commented 2026-11-24 09:48:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Marukooh on 2026-11-24T09:48:14Z.


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.

<!-- greyfinch-sync:ivall/xcl:issue:5469810053 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/976). Originally posted by [Marukooh](https://github.com/Marukooh) on 2026-11-24T09:48:14Z. --- 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.
DavidM1911 commented 2026-11-24 13:03:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T12:28:51Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7131498555 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/976#issuecomment-7131498555). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T12:28:51Z. --- 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 commented 2026-11-26 04:07:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T03:23:31Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7181677704 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/976#issuecomment-7181677704). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T03:23:31Z. --- 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
github-actions[bot] commented 2026-11-30 08:42:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:42:01Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273233573 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/976#issuecomment-7273233573). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:42:01Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 04:34:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:34:38Z.


Triage (#1607) – head 807fbfb

Stacked on #684 (its commit af9f9bb is the same patch as #684's e56dbc3); only 807fbfb is this PR's own: the CopyFromSubresource destination check goes from shader::readable to dstorage::writable, with a read-only test case. No other open PR makes that change.
Main has changed since this was opened. adccb7d ("XG CopyInto/FromSubresource take the newer library's added argument") already handles the 7-argument ABI, and it handles both forms per call through copy_args, because a retail game calls both. The base commit hardcodes copy_from to the 7-argument form, so a rebase has to keep main's copy_args and put only the destination span and writable checks on top of it.
Recommendation: keep open.

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

<!-- greyfinch-sync:ivall/xcl:comment:7300874690 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/976#issuecomment-7300874690). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:34:38Z. --- **Triage (#1607)** – head 807fbfb Stacked on #684 (its commit af9f9bb is the same patch as #684's e56dbc3); only 807fbfb is this PR's own: the CopyFromSubresource destination check goes from `shader::readable` to `dstorage::writable`, with a read-only test case. No other open PR makes that change. Main has changed since this was opened. adccb7d ("XG CopyInto/FromSubresource take the newer library's added argument") already handles the 7-argument ABI, and it handles both forms per call through `copy_args`, because a retail game calls both. The base commit hardcodes `copy_from` to the 7-argument form, so a rebase has to keep main's `copy_args` and put only the destination span and writable checks on top of it. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Royalflamejlh commented 2026-12-02 22:50:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:50:49Z.


@Marukooh the base of this moved: #684 is carried on by #3738, rebased onto main's copy_args, and it already uses your dstorage::writable check (credited in its commit), so this PR may have nothing left after it; #992 can rebase onto #3738.

AI use: Claude Code (Claude Opus 5.5) wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7361236190 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/976#issuecomment-7361236190). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:50:49Z. --- @Marukooh the base of this moved: #684 is carried on by #3738, rebased onto `main`'s `copy_args`, and it already uses your `dstorage::writable` check (credited in its commit), so this PR may have nothing left after it; #992 can rebase onto #3738. AI use: Claude Code (Claude Opus 5.5) wrote this.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/976:upstream-pr/976'
git switch 'upstream-pr/976'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/976'
git switch 'upstream-pr/976'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/976'
git switch 'upstream-pr/976'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/976'
git switch 'main'
git merge --squash 'upstream-pr/976'
git switch 'main'
git merge --ff-only 'upstream-pr/976'
git switch 'main'
git merge 'upstream-pr/976'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!970
No description provided.