Skip to content

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

Closed
tedin7 wants to merge 2 commits into
Marvisak:mainfrom
tedin7:vic-descriptor-cube
Closed

tedin7 wants to merge 2 commits into
Marvisak:mainfrom
tedin7:vic-descriptor-cube

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.
@DaviTostes

Copy link
Copy Markdown

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 Build: Linux workspace, contributor setup and CI #112 for the victory-gpu E0425.

@tedin7

tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

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

ifBars commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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

@tedin7

tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

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.

@Marvisak

Copy link
Copy Markdown
Owner

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 Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants