Shaders: support cube dimension in descriptor_data #317

Open
tarcisioads wants to merge 1 commit from upstream-pr/317 into main
tarcisioads commented 2026-11-24 02:15:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-24T02:15:46Z.


Support cube (dim = 3) image dimensions when a shader reads a resource descriptor's metadata words as data (descriptor_data in crates/victory-shader/src/emit/lower.rs):

  • Map dim = 3 => 5 (TextureCube) in descriptor_data.
  • Hardcode cube depth = 6 before - 1 (yielding 5, matching the RDNA2 ISA descriptor table for 6 faces) and add 11 (SQ_RSRC_IMG_CUBE) to the hardware type table in word 3.
  • Drop the unreachable MSAA arms until MSAA image instructions lower.
  • Add unit test cube_descriptor_data_lowers verifying SFI0 RESOURCE_HEAP emission.

Verification

  • cargo test -p victory-shader (119 passed, 0 failed, 1 ignored benchmark on macOS; Windows dxil.dll validation not run)
  • cargo xtask policy (ok)
<!-- greyfinch-sync:Marvisak/VIctory:issue:5464802251 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/317). Originally posted by [tarcisioads](https://github.com/tarcisioads) on 2026-11-24T02:15:46Z. --- Support cube (`dim = 3`) image dimensions when a shader reads a resource descriptor's metadata words as data (`descriptor_data` in `crates/victory-shader/src/emit/lower.rs`): - Map `dim = 3 => 5` (`TextureCube`) in `descriptor_data`. - Hardcode cube `depth = 6` before `- 1` (yielding `5`, matching the RDNA2 ISA descriptor table for 6 faces) and add `11` (`SQ_RSRC_IMG_CUBE`) to the hardware type table in word 3. - Drop the unreachable MSAA arms until MSAA image instructions lower. - Add unit test `cube_descriptor_data_lowers` verifying `SFI0` `RESOURCE_HEAP` emission. ### Verification - `cargo test -p victory-shader` (119 passed, 0 failed, 1 ignored benchmark on macOS; Windows `dxil.dll` validation not run) - `cargo xtask policy` (ok)
r4tedx commented 2026-11-24 06:55:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T03:09:02Z.


Review note on the MSAA case. For kinds 3 and 8 (MSAA) the level count is set to 1:

let levels = if uav || matches!(kind, 3 | 8) { one } else { field(self, 3) };

so the descriptor's last-level field comes out as 0. The RDNA 2 ISA's image resource table defines that field differently for MSAA:

last level: smallest mip level in resource view. For MSAA, holds log2(number of samples).

Code that reads the sample count from the descriptor would get 1 sample. The host view's sample count is available (getDimensions on a Texture2DMS returns it), so the field could hold its log2.

For the cube case, #109 hardcodes the depth field as 5, which matches the same table ("depth: ... last array slice for a 2D-array or 1D-array or cube-map"); here it is taken from getDimensions component 2, which a TextureCube does not expose, so the two PRs disagree and #109's value is the one the table gives.

From the document and reading the diff only; I have no copy of the title.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120817729 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/317#issuecomment-7120817729). Originally posted by [r4tedx](https://github.com/r4tedx) on 2026-11-24T03:09:02Z. --- Review note on the MSAA case. For kinds 3 and 8 (MSAA) the level count is set to 1: ```rust let levels = if uav || matches!(kind, 3 | 8) { one } else { field(self, 3) }; ``` so the descriptor's last-level field comes out as 0. The RDNA 2 ISA's image resource table defines that field differently for MSAA: > last level: smallest mip level in resource view. For MSAA, holds log2(number of samples). Code that reads the sample count from the descriptor would get 1 sample. The host view's sample count is available (`getDimensions` on a `Texture2DMS` returns it), so the field could hold its log2. For the cube case, #109 hardcodes the depth field as 5, which matches the same table ("depth: ... last array slice for a 2D-array or 1D-array or cube-map"); here it is taken from `getDimensions` component 2, which a `TextureCube` does not expose, so the two PRs disagree and #109's value is the one the table gives. From the document and reading the diff only; I have no copy of the title.
tarcisioads commented 2026-11-24 12:04:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-24T11:18:52Z.


Rebased onto main (ffe310e) and addressed @r4tedx's review notes in 8133754:

  • Set Cube (kind = 5) depth to 5 (6 faces - 1).
  • Set MSAA (kind = 3 | 8) last_level to firstbitLo(samples) (log2(samples) from getDimensions component 3).
  • Updated cube_and_msaa_descriptor_data_lower for the new resource::track signature; cargo test -p victory-shader (97 passed, 0 failed on macOS).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7129936784 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/317#issuecomment-7129936784). Originally posted by [tarcisioads](https://github.com/tarcisioads) on 2026-11-24T11:18:52Z. --- Rebased onto `main` (`ffe310e`) and addressed @r4tedx's review notes in `8133754`: - Set Cube (`kind = 5`) `depth` to `5` (6 faces - 1). - Set MSAA (`kind = 3 | 8`) `last_level` to `firstbitLo(samples)` (`log2(samples)` from `getDimensions` component 3). - Updated `cube_and_msaa_descriptor_data_lower` for the new `resource::track` signature; `cargo test -p victory-shader` (97 passed, 0 failed on macOS).
Yaekai commented 2026-11-24 17:04:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Yaekai on 2026-11-24T16:38:24Z.


Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head 8133754:

  • cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests: 103 passed, 0 failed.
  • cargo clippy -p victory-shader -- -D warnings: 0 warnings.
  • Live GTA VI (1.0.2.1, --console series-s, 19-min world run): no regressions. Ready to merge!
<!-- greyfinch-sync:Marvisak/VIctory:comment:7137979488 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/317#issuecomment-7137979488). Originally posted by [Yaekai](https://github.com/Yaekai) on 2026-11-24T16:38:24Z. --- Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head `8133754`: - `cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests`: 103 passed, 0 failed. - `cargo clippy -p victory-shader -- -D warnings`: 0 warnings. - Live GTA VI (`1.0.2.1`, `--console series-s`, 19-min world run): no regressions. Ready to merge!
upstream-sync changed title from [PR #317] Shaders: support cube and MSAA dimensions in descriptor_data to [PR #317] Shaders: support cube dimension in descriptor_data 2026-11-25 01:03:20 +00:00
Marvisak commented 2026-11-25 01:07:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:30:45Z.


Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/bitcode.rs and crates/victory-shader/src/emit/lower.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148584480 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/317#issuecomment-7148584480). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:30:45Z. --- <!-- victory-triage v1 head=a2dddc33b1c0314b394d947323222e738cf12726 verdict=needs-rebase at=2026-11-25T22:33:00Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: `main` has moved since the last triage, and the branch now conflicts in `crates/victory-shader/src/emit/bitcode.rs` and `crates/victory-shader/src/emit/lower.rs`. It will be reviewed again once it is rebased onto current `main`. Previous verdict for this head: merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
tarcisioads commented 2026-11-25 01:08:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-25T00:34:25Z.


Addressed the triage feedback:

  • Scoped this PR to Cube (dim = 3, depth = 5, SQ_RSRC_IMG_CUBE = 11), dropping the unreachable MSAA arms (and the firstbitLo.i32 call) until MSAA image instructions lower.
  • Updated the unit test to cube_descriptor_data_lowers and verified SFI0 RESOURCE_HEAP emission.
  • cargo test -p victory-shader (119 passed, 0 failed on macOS).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7148652148 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/317#issuecomment-7148652148). Originally posted by [tarcisioads](https://github.com/tarcisioads) on 2026-11-25T00:34:25Z. --- Addressed the triage feedback: - Scoped this PR to Cube (`dim = 3`, `depth = 5`, `SQ_RSRC_IMG_CUBE = 11`), dropping the unreachable MSAA arms (and the `firstbitLo.i32` call) until MSAA image instructions lower. - Updated the unit test to `cube_descriptor_data_lowers` and verified `SFI0` `RESOURCE_HEAP` emission. - `cargo test -p victory-shader` (119 passed, 0 failed on macOS).
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/317:upstream-pr/317'
git switch 'upstream-pr/317'

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/317'
git switch 'upstream-pr/317'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/317'
git switch 'upstream-pr/317'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/317'
git switch 'main'
git merge --squash 'upstream-pr/317'
git switch 'main'
git merge --ff-only 'upstream-pr/317'
git switch 'main'
git merge 'upstream-pr/317'
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
Marvisak/VIctory!317
No description provided.