Skip to content

Shaders: lower MSAA image_load and image_get_resinfo - #328

Open
tarcisioads wants to merge 1 commit into
Marvisak:mainfrom
tarcisioads:shader/msaa-image-load
Open

tarcisioads wants to merge 1 commit into
Marvisak:mainfrom
tarcisioads:shader/msaa-image-load

Conversation

@tarcisioads

Copy link
Copy Markdown

Support 2DMS (dim = 6) and 2DMSArray (dim = 7) image dimensions for image_load and image_get_resinfo in crates/victory-shader/src/emit/lower.rs:

  • Map dim = 6 => (3, 2) and dim = 7 => (8, 3) in image() for image_load and image_get_resinfo.
  • In image_get_resinfo (op 72), pass undef as the mip argument of dx.op.getDimensions for MSAA (kind 3 | 8) and treat 2DMS (kind = 3) as [true, true, false, true] (width, height, -, sample count).
  • In image_load (op 66), forward sample_index (addr_val(self, coords)) into the mipLevelOrSample parameter of dx.op.textureLoad.
  • Add unit test msaa_image_load_and_get_resinfo_lower covering image_load and image_get_resinfo for both dim = 6 and dim = 7.

Verification

  • cargo test -p victory-shader (57/57 passed on macOS; Windows dxil.dll validation not run)
  • rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower.rs (ok)
  • cargo xtask policy (ok)

@jeremygold02

Copy link
Copy Markdown
Contributor

Tested PR #328 at head 6d7602daf690bd5ec6d3b7ecac653a2e3bf7b9f0 (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at 6d7602daf690bd5ec6d3b7ecac653a2e3bf7b9f0.

  • cargo test --locked -p victory-shader msaa_image_load_and_get_resinfo_lower — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 69 filtered out; finished in 0.00s ); cases: emit::lower::tests::msaa_image_load_and_get_resinfo_lower.

Behavior covered: Checks MSAA image_load and image_get_resinfo lowering in the shader emitter.
Code: crates/victory-shader/src/emit/lower.rs

@tarcisioads

Copy link
Copy Markdown
Author

Rebased onto main (ffe310e) in 91e7742 and updated msaa_image_load_and_get_resinfo_lower for the new resource::track signature. cargo test -p victory-shader (97 passed, 0 failed on macOS).

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work. The resource kinds are right (dim 6 → Texture2DMS, dim 7 → Texture2DMSArray) and the image_load address order matches Lower::image in crates/victory-shader/src/emit/lower.rs. But this changes shader semantics without evidence on two points:

  1. image_get_resinfo channel w: on GFX10, resinfo returns the mip count in w, while DXIL getDimensions on MS textures returns the sample count there, and this patch passes DXIL's w straight through for kinds 3 and 8. Please show what the console returns (RDNA2 ISA, LLVM/Mesa lowering, or the title's code), or write the console's value.
  2. Fragment vs sample index: the RDNA2 MSAA load takes a fragment index, which can map to samples via FMASK. Forwarding it as the sample index is only right if they are equal here; mark it as a shortcut: or show that it holds.

The test only checks that lower returns Ok, and its comments don't match its words. A DXIL validator run of the MSAA load and resinfo forms would help a lot.

CI: no check runs on the head commit.


Generated by Claude Code

@tarcisioads

Copy link
Copy Markdown
Author

Addressed the triage feedback:

  1. In image_get_resinfo (op 72), MSAA (kind = 3 | 8) now returns 1 in channel w (matching RDNA2 IMAGE_GET_RESINFO mip count, rather than passing through DXIL's sample count).
  2. Documented the // shortcut: on image_load MSAA (forwarding fragment index as sample index, assuming no FMASK remapping).
  3. Fixed the comments in msaa_image_load_and_get_resinfo_lower to match the encoded words and added an assertion on the emitted SFI0 RESOURCE_HEAP feature bit.
  • cargo test -p victory-shader (119 passed, 0 failed on macOS; dxil.dll validation still needs Windows).

@tarcisioads
tarcisioads force-pushed the shader/msaa-image-load branch from 1192e48 to 62baee7 Compare November 25, 2026 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants