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

Closed
tedin7 wants to merge 2 commits from upstream-pr/109 into main
tedin7 commented 2026-11-24 00:36:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tedin7 on 2026-11-24T00:36:09Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6571876053 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/109). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T00:36:09Z. --- 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.
DaviTostes commented 2026-11-24 06:54:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:09:59Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7118823358 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7118823358). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T01:09:59Z. --- 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.
tedin7 commented 2026-11-24 06:55:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tedin7 on 2026-11-24T02:48:31Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120498212 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7120498212). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T02:48:31Z. --- 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.
ifBars commented 2026-11-24 06:55:20 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120818693 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7120818693). Originally posted by [ifBars](https://github.com/ifBars) on 2026-11-24T03:09:06Z. --- 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)
tedin7 commented 2026-11-24 06:55:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tedin7 on 2026-11-24T03:13:04Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120882056 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7120882056). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:13:04Z. --- 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.
upstream-sync closed this pull request 2026-11-25 00:05:16 +00:00
Marvisak commented 2026-11-25 00:06:55 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148028377 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/109#issuecomment-7148028377). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:00:11Z. --- 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

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!109
No description provided.