Shaders: rebuild a cube image descriptor for code that reads its dwords #109

Closed
github-bot wants to merge 2 commits from gh-pr/109/head into gh-pr/109/base
Owner

@⁠tedin7 on GitHub · 2026-11-24 00:36 UTC · original
tedin7:vic-descriptor-cube → main · +87 −5 · 1 files · 2 commits · closed without merging

What

  • descriptor_data now rebuilds the GFX10 descriptor dwords of a cube view (dim 3): resource kind 5, type 11 in dword 3, depth dword 5 (six faces, no cube array), width and height from getDimensions.

Why

  • Code that reads a descriptor's size bits as numbers stopped at an image dimension (cube or MSAA) for a cube, although image_get_resinfo and cube sampling already handle cube views. MSAA is still refused.

Tested

  • Linux x86_64 only. Commands run:
    • cargo test -j4 -p victory-shader cube_descriptor before the change: fails with Unsupported { offset: 28, what: "an image dimension (cube or MSAA)" }.
    • cargo test -j4 -p victory-shader after the change: 52 passed, 0 failed (the new test included).
    • cargo clippy -j4 -p victory-shader --tests: no new warnings (existing: dead_code constant_color in emit/mod.rs, a boolean-simplification note in resource.rs).
    • rustfmt --edition 2024 --check on lower.rs: clean.
  • The test uses synthetic machine code (no game data) and checks that lowering succeeds, not the emitted DXIL values.
  • NOT run: Windows runtime, GPU, or a real console shader.
  • A similar lowers() test helper is added by the other open scalar PRs in the same tests module, so a trivial merge conflict there is possible.
  • A 2D control in the same test lowers both before and after.
**@⁠tedin7** on GitHub · 2026-11-24 00:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/109) `tedin7:vic-descriptor-cube` → `main` · +87 −5 · 1 files · 2 commits · closed without merging What - `descriptor_data` now rebuilds the GFX10 descriptor dwords of a cube view (dim 3): resource kind 5, type 11 in dword 3, depth dword 5 (six faces, no cube array), width and height from `getDimensions`. Why - Code that reads a descriptor's size bits as numbers stopped at `an image dimension (cube or MSAA)` for a cube, although `image_get_resinfo` and cube sampling already handle cube views. MSAA is still refused. Tested - Linux x86_64 only. Commands run: - `cargo test -j4 -p victory-shader cube_descriptor` before the change: fails with `Unsupported { offset: 28, what: "an image dimension (cube or MSAA)" }`. - `cargo test -j4 -p victory-shader` after the change: 52 passed, 0 failed (the new test included). - `cargo clippy -j4 -p victory-shader --tests`: no new warnings (existing: dead_code `constant_color` in emit/mod.rs, a boolean-simplification note in resource.rs). - `rustfmt --edition 2024 --check` on lower.rs: clean. - The test uses synthetic machine code (no game data) and checks that lowering succeeds, not the emitted DXIL values. - NOT run: Windows runtime, GPU, or a real console shader. - A similar `lowers()` test helper is added by the other open scalar PRs in the same tests module, so a trivial merge conflict there is possible. - A 2D control in the same test lowers both before and after.
descriptor_data refused a cube view (dim 3) although image_get_resinfo and cube sampling handle it, so a shader that sizes a cube from descriptor bits failed to translate.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:50:28 +00:00
github-bot closed this pull request 2026-11-26 03:50:29 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:09 UTC · original

Tested 743b1e2 on Arch Linux x86_64, rustc 1.98.1: pass.

  • cargo test -p victory-shader: 52 passed, 0 failed (2 test binaries).
  • The diff adds no test for the cube descriptor dwords, so this only shows the existing suite stays green; a fixture that reads a cube descriptor's size bits would cover it.
  • The full workspace still needs #112 for the victory-gpu E0425.
**@⁠DaviTostes** on GitHub · 2026-11-24 01:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7118823358) Tested `743b1e2` on **Arch Linux x86_64, rustc 1.98.1**: **pass**. - `cargo test -p victory-shader`: **52 passed, 0 failed** (2 test binaries). - The diff adds no test for the cube descriptor dwords, so this only shows the existing suite stays green; a fixture that reads a cube descriptor's size bits would cover it. - The full workspace still needs #112 for the `victory-gpu` E0425.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 02:48 UTC · original

Thanks for testing, DaviTostes. A note in case it was missed: the PR does carry a test, cube_descriptor_dwords_read_as_data in emit/lower.rs (last hunk of the diff). It loads a cube descriptor, runs image_get_resinfo on it and branches on its depth dword (5). On main it fails with "an image dimension (cube or MSAA)" and it passes with the fix. It checks that the program translates, not the final dword values: those would need the GPU or a DXIL evaluator, which I did not run.

**@⁠tedin7** on GitHub · 2026-11-24 02:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7120498212) Thanks for testing, DaviTostes. A note in case it was missed: the PR does carry a test, `cube_descriptor_dwords_read_as_data` in `emit/lower.rs` (last hunk of the diff). It loads a cube descriptor, runs `image_get_resinfo` on it and branches on its depth dword (5). On `main` it fails with "an image dimension (cube or MSAA)" and it passes with the fix. It checks that the program translates, not the final dword values: those would need the GPU or a DXIL evaluator, which I did not run.
Author
Owner

@⁠ifBars on GitHub · 2026-11-24 03:09 UTC · original

I tested the cube SRV change on Windows with the SDK DXIL validator. An observable synthetic shader reading the dimensions and type now translates. I held the raw depth/base-array word in our adaptation. A six-face host view alone does not establish that the original descriptor encodes 5 in DEPTH.

AMD's table gives cube image type 11 and describes DEPTH and BASE_ARRAY separately. RadeonSI also provides a concrete different encoding: for a single cube it sets the last layer to the first, then uses that last layer as the texture state's depth on GFX10. This does not establish the Xbox encoding either. Do you have a native cube descriptor or a field-value test that establishes 5 for the guest cases this PR handles? AMD RDNA 2 ISA, image resource definition · RadeonSI cube view setup · GFX10 descriptor packing

**@⁠ifBars** on GitHub · 2026-11-24 03:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7120818693) I tested the cube SRV change on Windows with the SDK DXIL validator. An observable synthetic shader reading the dimensions and type now translates. I held the raw depth/base-array word in our adaptation. A six-face host view alone does not establish that the original descriptor encodes 5 in DEPTH. AMD's table gives cube image type 11 and describes DEPTH and BASE_ARRAY separately. RadeonSI also provides a concrete different encoding: for a single cube it sets the last layer to the first, then uses that last layer as the texture state's depth on GFX10. This does not establish the Xbox encoding either. Do you have a native cube descriptor or a field-value test that establishes 5 for the guest cases this PR handles? [AMD RDNA 2 ISA, image resource definition](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content#page=75) · [RadeonSI cube view setup](https://chromium.googlesource.com/external/gitlab.freedesktop.org/mesa/mesa/+/25882ee52dc088e4342473498465118a554eb70f/src/gallium/drivers/radeonsi/si_state.c#3947) · [GFX10 descriptor packing](https://chromium.googlesource.com/external/gitlab.freedesktop.org/mesa/mesa/+/25882ee52dc088e4342473498465118a554eb70f/src/amd/common/ac_descriptors.c#537)
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 03:13 UTC · original

Thanks ifBars, fair point. No: I do not have a native cube descriptor, and nothing in this repo (victory-shader or victory-gpu) establishes DEPTH=5. I took 5 from the six-face host view and from how this code already treats arrays (DEPTH as count minus 1), which is an inference, not evidence. Your RadeonSI reading (last layer = first layer for a single cube on GFX10) contradicts it, and I cannot rule it out.

I pushed a follow-up commit that stops claiming it: for a cube, the translator still gives the width/height dword and the type dword (type 11, per the AMD table), but the depth dword (dword 4) is no longer produced, so a program that reads it is refused as before. The test now branches on the type dword, and asserts that reading the depth dword of a cube is still refused. cargo test -p victory-shader: 52 passed; clippy and rustfmt --edition 2024 --check clean, on Linux x86_64. I did not run Windows, a GPU or the DXIL validator. The cube load/store and sampling paths are not affected.

**@⁠tedin7** on GitHub · 2026-11-24 03:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7120882056) Thanks ifBars, fair point. No: I do not have a native cube descriptor, and nothing in this repo (victory-shader or victory-gpu) establishes DEPTH=5. I took 5 from the six-face host view and from how this code already treats arrays (DEPTH as count minus 1), which is an inference, not evidence. Your RadeonSI reading (last layer = first layer for a single cube on GFX10) contradicts it, and I cannot rule it out. I pushed a follow-up commit that stops claiming it: for a cube, the translator still gives the width/height dword and the type dword (type 11, per the AMD table), but the depth dword (dword 4) is no longer produced, so a program that reads it is refused as before. The test now branches on the type dword, and asserts that reading the depth dword of a cube is still refused. `cargo test -p victory-shader`: 52 passed; clippy and `rustfmt --edition 2024 --check` clean, on Linux x86_64. I did not run Windows, a GPU or the DXIL validator. The cube load/store and sampling paths are not affected.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:00 UTC · original

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #317. Cube views in descriptor_data. Same change as #317, which also covers MSAA and fills the depth dword as the public driver does; neither has a title program behind it.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7148028377) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #317. Cube views in descriptor_data. Same change as #317, which also covers MSAA and fills the depth dword as the public driver does; neither has a title program behind it. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!109
No description provided.