victory-gpu: guard port 5 table CBVs on hosts without raw twins #643

Open
Zuwei-Wang wants to merge 1 commit from upstream-pr/643 into a-publier
Zuwei-Wang commented 2026-11-27 16:00:37 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Zuwei-Wang on 2026-11-27T16:00:37Z.


Summary

When VICTORY_PORT_CBV=1 is enabled on hosts whose shader-visible view heaps do not support raw twins (e.g. NVIDIA GPUs capped at 1,000,000 views, or runs with VICTORY_RAW_VIEWS=0), victory_shader::emit::raw_views() stays 0 and translated shaders read table/heap constant buffers from the primary CBV slot (while root constant buffers still run as root SRVs).

Previously, three GPU-side paths did not check for raw twins:

  1. descriptor::host::make_twinned routed View::Constant through constant_twinned(..., None), which wrote a null CBV into the primary slot for non-256-byte-aligned addresses and returned Some(...) instead of falling back (None).
  2. port_cbv::in_place_on() stayed true, causing draw.rs to run shadow::find() + constant_raw_at() on every table constant buffer each frame only to fail on self.twin(index) and miscount all of them as "not on 16 bytes".
  3. Neither startup (probe_view_limit) nor port_cbv::log explained why table CBVs fell back on hosts without raw twins.

Changes

  • crates/victory-gpu/src/port_cbv.rs: gate in_place_on() on has_raw_twins() (victory_shader::emit::raw_views() != 0), log the fallback clearly in port_cbv::log(), and add unit test table_in_place_requires_raw_twins.
  • crates/victory-gpu/src/descriptor/host.rs: require a non-optional twin handle in constant_twinned, fall through to the standard 256-byte-aligned CBV path in make_constant when no twin slot exists, warn once in probe_view_limit when VICTORY_PORT_CBV=1 runs without raw twins, and add D3D12 unit test port_cbv_without_twin_rejects_unaligned_constant_buffer.
  • README.md: document the raw-twin requirement for table CBVs under VICTORY_PORT_CBV=1.

Testing (Windows 11, Ryzen 7 9800X3D, NVIDIA GeForce RTX 5070 Ti 16 GB)

  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test -p victory-gpu -p xtask --locked
  • cargo test -p victory-gpu --all-features --locked -- --test-threads=1
<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5529560841 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/643). Originally posted by [Zuwei-Wang](https://github.com/Zuwei-Wang) on 2026-11-27T16:00:37Z. --- ## Summary When `VICTORY_PORT_CBV=1` is enabled on hosts whose shader-visible view heaps do not support raw twins (e.g. NVIDIA GPUs capped at 1,000,000 views, or runs with `VICTORY_RAW_VIEWS=0`), `victory_shader::emit::raw_views()` stays `0` and translated shaders read table/heap constant buffers from the primary CBV slot (while root constant buffers still run as root SRVs). Previously, three GPU-side paths did not check for raw twins: 1. `descriptor::host::make_twinned` routed `View::Constant` through `constant_twinned(..., None)`, which wrote a **null CBV** into the primary slot for non-256-byte-aligned addresses and returned `Some(...)` instead of falling back (`None`). 2. `port_cbv::in_place_on()` stayed `true`, causing `draw.rs` to run `shadow::find()` + `constant_raw_at()` on every table constant buffer each frame only to fail on `self.twin(index)` and miscount all of them as `"not on 16 bytes"`. 3. Neither startup (`probe_view_limit`) nor `port_cbv::log` explained why table CBVs fell back on hosts without raw twins. ## Changes - `crates/victory-gpu/src/port_cbv.rs`: gate `in_place_on()` on `has_raw_twins()` (`victory_shader::emit::raw_views() != 0`), log the fallback clearly in `port_cbv::log()`, and add unit test `table_in_place_requires_raw_twins`. - `crates/victory-gpu/src/descriptor/host.rs`: require a non-optional twin handle in `constant_twinned`, fall through to the standard 256-byte-aligned CBV path in `make_constant` when no twin slot exists, warn once in `probe_view_limit` when `VICTORY_PORT_CBV=1` runs without raw twins, and add D3D12 unit test `port_cbv_without_twin_rejects_unaligned_constant_buffer`. - `README.md`: document the raw-twin requirement for table CBVs under `VICTORY_PORT_CBV=1`. ## Testing (Windows 11, Ryzen 7 9800X3D, NVIDIA GeForce RTX 5070 Ti 16 GB) - `cargo clippy --workspace --all-targets --locked -- -D warnings` - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - `cargo test -p victory-gpu -p xtask --locked` - `cargo test -p victory-gpu --all-features --locked -- --test-threads=1`
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/643:upstream-pr/643'
git switch 'upstream-pr/643'

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 'a-publier'
git merge --no-ff 'upstream-pr/643'
git switch 'upstream-pr/643'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/643'
git switch 'upstream-pr/643'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'upstream-pr/643'
git switch 'a-publier'
git merge --squash 'upstream-pr/643'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/643'
git switch 'a-publier'
git merge 'upstream-pr/643'
git push origin 'a-publier'
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
Belobug/VIctory-Belobug-AMD!643
No description provided.