startup: gfx2hlsl refuses cube image sampling (dim:SQ_RSRC_IMG_CUBE) #2943

Closed
opened 2026-11-26 22:31:57 +00:00 by pigalot · 1 comment
pigalot commented 2026-11-26 22:31:57 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-26T22:31:57Z.


tools/startup/gfx2hlsl.py refuses an image instruction whose dimension is SQ_RSRC_IMG_CUBE with
image dimension SQ_RSRC_IMG_CUBE (the kinds table in the image lowering takes 1D, 2D, 3D and 2D array
only). So a pixel shader that samples a cube map has no translation, and the draw falls back.

On GFX10 a cube sample is a v_cubeid/sc/tc/ma_f32 sequence (already lowered, after LLVM's
ConstantFoldAMDGCNCubeIntrinsic) followed by image_sample* with dim:SQ_RSRC_IMG_CUBE. The address
holds face-relative coordinates and the face index.

What a lowering would need:

  • Declare a TextureCube<float4> and write manifest kind texcube for the binding. The runtime side that
    binds a TEXTURECUBE view for that kind is in #2938.
  • Rebuild a direction from the face coordinates and face index (or carry the original direction through
    the v_cube* sequence), then Sample/SampleLevel/SampleBias as the 2D forms do.
  • A fixture: source-built gfx1013 cube sampling compared with a desktop TextureCube draw, on WARP and
    hardware, plus a negative control (for example, a face index off by one).

Seen in a local run: slot 70 sees hundreds of TEXTURECUBE view calls per
600 s, on 6-slice 2D arrays in the 4 KiB standard layout (0x105), in BC1, BC6H, BC7 and BGRA8 formats.

This issue was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6636165581 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2943). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-26T22:31:57Z. --- `tools/startup/gfx2hlsl.py` refuses an image instruction whose dimension is `SQ_RSRC_IMG_CUBE` with `image dimension SQ_RSRC_IMG_CUBE` (the `kinds` table in the image lowering takes 1D, 2D, 3D and 2D array only). So a pixel shader that samples a cube map has no translation, and the draw falls back. On GFX10 a cube sample is a `v_cubeid/sc/tc/ma_f32` sequence (already lowered, after LLVM's `ConstantFoldAMDGCNCubeIntrinsic`) followed by `image_sample*` with `dim:SQ_RSRC_IMG_CUBE`. The address holds face-relative coordinates and the face index. What a lowering would need: - Declare a `TextureCube<float4>` and write manifest kind `texcube` for the binding. The runtime side that binds a `TEXTURECUBE` view for that kind is in #2938. - Rebuild a direction from the face coordinates and face index (or carry the original direction through the `v_cube*` sequence), then `Sample`/`SampleLevel`/`SampleBias` as the 2D forms do. - A fixture: source-built gfx1013 cube sampling compared with a desktop `TextureCube` draw, on WARP and hardware, plus a negative control (for example, a face index off by one). Seen in a local run: slot 70 sees hundreds of `TEXTURECUBE` view calls per 600 s, on 6-slice 2D arrays in the 4 KiB standard layout (`0x105`), in BC1, BC6H, BC7 and BGRA8 formats. This issue was AI-assisted.
legacy-code-archaeologist commented 2026-11-26 23:22:34 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-26T23:22:34Z.


I'm working on this one: a gfx2hlsl lowering of image_sample, _lz, _l and _b on dim:SQ_RSRC_IMG_CUBE to TextureCube<float4>, with the direction rebuilt from (s, t, face) as Mesa's prepare_cube_coords builds them (s = sc/|ma| + 1.5). It writes the texcube manifest kind, so it pairs with #2938; I'll open it as a draft that should land after #2938, since main still parses an unknown kind as a buffer.

The fixture draws a six-face TextureCube on WARP and hardware from literal (s, t, face) addresses, with face-index and helper-row mutants and a v_cube chain per face compared with a desktop TextureCube draw. Loads, image_sample_d, image_get_lod, a16/d16, compute stages and samplers with DISABLE_CUBE_WRAP stay refused.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7205487933 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2943#issuecomment-7205487933). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-26T23:22:34Z. --- I'm working on this one: a gfx2hlsl lowering of `image_sample`, `_lz`, `_l` and `_b` on `dim:SQ_RSRC_IMG_CUBE` to `TextureCube<float4>`, with the direction rebuilt from (s, t, face) as Mesa's `prepare_cube_coords` builds them (s = sc/|ma| + 1.5). It writes the `texcube` manifest kind, so it pairs with #2938; I'll open it as a draft that should land after #2938, since main still parses an unknown kind as a buffer. The fixture draws a six-face TextureCube on WARP and hardware from literal (s, t, face) addresses, with face-index and helper-row mutants and a `v_cube` chain per face compared with a desktop TextureCube draw. Loads, `image_sample_d`, `image_get_lod`, a16/d16, compute stages and samplers with `DISABLE_CUBE_WRAP` stay refused. AI-assisted.
Sign in to join this conversation.
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
R0Y00/Xbox2Windows#2943
No description provided.