Skip to content

Shaders: support cube dimension in descriptor_data - #317

Open
tarcisioads wants to merge 1 commit into
Marvisak:mainfrom
tarcisioads:shader/cube-msaa-descriptor-data
Open

tarcisioads wants to merge 1 commit into
Marvisak:mainfrom
tarcisioads:shader/cube-msaa-descriptor-data

Conversation

@tarcisioads

@tarcisioads tarcisioads commented Nov 24, 2026 •

Copy link
Copy Markdown

Support cube (dim = 3) image dimensions when a shader reads a resource descriptor's metadata words as data (descriptor_data in crates/victory-shader/src/emit/lower.rs):

  • Map dim = 3 => 5 (TextureCube) in descriptor_data.
  • Hardcode cube depth = 6 before - 1 (yielding 5, matching the RDNA2 ISA descriptor table for 6 faces) and add 11 (SQ_RSRC_IMG_CUBE) to the hardware type table in word 3.
  • Drop the unreachable MSAA arms until MSAA image instructions lower.
  • Add unit test cube_descriptor_data_lowers verifying SFI0 RESOURCE_HEAP emission.

Verification

  • cargo test -p victory-shader (119 passed, 0 failed, 1 ignored benchmark on macOS; Windows dxil.dll validation not run)
  • cargo xtask policy (ok)

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Review note on the MSAA case. For kinds 3 and 8 (MSAA) the level count is set to 1:

let levels = if uav || matches!(kind, 3 | 8) { one } else { field(self, 3) };

so the descriptor's last-level field comes out as 0. The RDNA 2 ISA's image resource table defines that field differently for MSAA:

last level: smallest mip level in resource view. For MSAA, holds log2(number of samples).

Code that reads the sample count from the descriptor would get 1 sample. The host view's sample count is available (getDimensions on a Texture2DMS returns it), so the field could hold its log2.

For the cube case, #109 hardcodes the depth field as 5, which matches the same table ("depth: ... last array slice for a 2D-array or 1D-array or cube-map"); here it is taken from getDimensions component 2, which a TextureCube does not expose, so the two PRs disagree and #109's value is the one the table gives.

From the document and reading the diff only; I have no copy of the title.

@tarcisioads

Copy link
Copy Markdown
Author

Rebased onto main (ffe310e) and addressed @r4tedx's review notes in 8133754:

  • Set Cube (kind = 5) depth to 5 (6 faces - 1).
  • Set MSAA (kind = 3 | 8) last_level to firstbitLo(samples) (log2(samples) from getDimensions component 3).
  • Updated cube_and_msaa_descriptor_data_lower for the new resource::track signature; cargo test -p victory-shader (97 passed, 0 failed on macOS).

@Yaekai

Yaekai commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head 8133754:

  • cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests: 103 passed, 0 failed.
  • cargo clippy -p victory-shader -- -D warnings: 0 warnings.
  • Live GTA VI (1.0.2.1, --console series-s, 19-min world run): no regressions. Ready to merge!

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. Recommending a look, not approving.

  • The lowering is unchanged since the earlier note and is right by reading. descriptor_data in crates/victory-shader/src/emit/lower.rs maps dim 3 to TextureCube, writes type 11 in word 3 (0xFAC | 11 << 28), and gives word 4 a depth of 6 - 1 = 5. That matches the public RDNA2 image descriptor table, and Lower::image already treats dim 3 as a single cube. Cube loads and stores are still refused in Lower::image, so no UAV cube handle can come out of a shader that translates.
  • New in this head: cube_descriptor_data_lowers now checks a test-only has_cube_descriptor_consts flag, built on Module::has_i32. It asserts that the cube type word 0xB000_0FAC and the face count 6 are in the emitted module, alongside the shared shift and mask constants. That covers the type and depth values the earlier note asked for. It checks that the constants are present, not which word each one lands in, which is enough here.
  • No separate dxil.dll validation of a cube shader has been reported. CI runs the workspace tests on Windows and passes.

CI: check passing.


Generated by Claude Code

@tarcisioads
tarcisioads force-pushed the shader/cube-msaa-descriptor-data branch from 23fd508 to 5a7ef38 Compare November 25, 2026 00:34
@tarcisioads tarcisioads changed the title Shaders: support cube and MSAA dimensions in descriptor_data Shaders: support cube dimension in descriptor_data Nov 25, 2026
@tarcisioads

Copy link
Copy Markdown
Author

Addressed the triage feedback:

  • Scoped this PR to Cube (dim = 3, depth = 5, SQ_RSRC_IMG_CUBE = 11), dropping the unreachable MSAA arms (and the firstbitLo.i32 call) until MSAA image instructions lower.
  • Updated the unit test to cube_descriptor_data_lowers and verified SFI0 RESOURCE_HEAP emission.
  • cargo test -p victory-shader (119 passed, 0 failed on macOS).

@tarcisioads
tarcisioads force-pushed the shader/cube-msaa-descriptor-data branch from 5a7ef38 to a2dddc3 Compare November 25, 2026 10:45
alex3112 pushed a commit to alex3112/VIctory that referenced this pull request Nov 25, 2026
…escriptor_data) into the integration

Our descriptor data (skewed loads, twin loads, the six faces of a cube, the level query only when word 3 is read) stays; the multisampled dimensions, their type codes and their level-less size query are taken from the PR, with its test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
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.

4 participants