Skip to content

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

Done

Description

@pigalot

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 startup: bind cube views of console-layout textures in slot 70 #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.

Activity

  1. legacy-code-archaeologist commented on Nov 26, 2026

    @legacy-code-archaeologist
    Contributor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions