Skip to content

Game: name rasterisers from the pack's register images - #3047

Open
zed6000 wants to merge 1 commit into
Marvisak:mainfrom
zed6000:pr-raster-registers
Open

zed6000 wants to merge 1 commit into
Marvisak:mainfrom
zed6000:pr-raster-registers

Conversation

@zed6000

@zed6000 zed6000 commented Nov 26, 2026

Copy link
Copy Markdown

Closes the rasteriser half of #2930.

translate --cache --pipelines skipped 852 of the pack's pipelines as rasteriser state not named: 6 of the pack's 18 rasteriser hashes have slope biases (and for 5, a DepthBiasClamp) that raster_space doesn't list. The register images do keep the rasteriser. In the fixed part registers() reads, the 7 words from +0x28 are PA_CL_CLIP_CNTL, PA_SU_SC_MODE_CNTL, two unused words, PA_SU_POLY_OFFSET_CLAMP, _FRONT_SCALE and _FRONT_OFFSET.

raster_from_registers reads cull (CULL_FRONT → 2, CULL_BACK → 3, neither → 1), winding (FACE clear → counter-clockwise), depth clip (both ZCLIP_*_DISABLE clear), the clamp as is, the slope bias as scale / 16 and the integer bias as the offset. It enumerates b13–b15, which these words don't hold. Wireframe, both-faces culling and non-integer offsets give nothing. name_from_registers tries it for every record whose rasteriser is still wanted, before the enumeration. As before, a description counts only if its CityHash64 is the record's.

Measured on shaders.rpf 1.0.2.1 (offline, RX 7900 XTX):

  • For all 24,619 records whose rasteriser main already names, the registers give the named description in every field.
  • All 18 rasteriser hashes are named (3 database, 15 registers). Records with all three states named go from 24,477 to 25,329 of 25,471. Named::find time is unchanged (~85 ms).
  • translate --cache --pipelines: rasteriser state not named goes from 852 to 0. Every pipeline was created and none refused. One of the newly named pipelines is in an earlier game run's early-pipelines.txt under the same key, which includes the whole D3D12 rasteriser description.
  • cargo test -p victory-game 17/0 (2 new tests, on synthetic registers), and cargo clippy -p victory-game -p victory --all-targets --locked -- -D warnings clean.

This doesn't conflict in purpose with #2575 / #2787: with every rasteriser named from the registers, their early stop ends raster_space immediately.

No game data: the tests use made-up register values.

🤖 Generated with Claude Code

The pack's register images keep the rasteriser registers 0x28 bytes into
the fixed part (PA_CL_CLIP_CNTL, PA_SU_SC_MODE_CNTL, the poly-offset
clamp, front scale and front offset). Reading cull, winding, depth clip,
clamp, slope (scale / 16) and bias from them names every rasteriser hash
of the pack, including six whose clamped, fractional slope biases no
enumeration reached: all three states of 25,329 of 25,471 records are
named instead of 24,477, so the pre-build makes 852 more pipelines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of 3c4c7d85 (crates/victory-game/src/pipelines.rs).

Verified the AMD GFX10 rasteriser register decoding against rasterizer_desc and raster_space:

  • PA_CL_CLIP_CNTL bits 26–27 (ZCLIP_NEAR_DISABLE | ZCLIP_FAR_DISABLE) -> b[12] (depth_clip).
  • PA_SU_SC_MODE_CNTL bits 0–1 (CULL_FRONT | CULL_BACK) -> 1/2/3, bit 2 (FACE) -> ccw, bits 3–4 (POLY_MODE) -> solid-only filter.
  • PA_SU_POLY_OFFSET_CLAMP, _FRONT_SCALE / 16.0, and _FRONT_OFFSET (with fract() == 0.0 and (-128.0..=127.0) range check that also rejects NaN/infinities).
  • Tail enumeration (0..16) covers the exact [b[13], b[14], b[15]] space that raster_space uses, deduplicated by (rasterizer_hash, regs) so Named::find stays fast and exact via CityHash64.

Clean, focused, and well tested.

@kotekompotek kotekompotek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: raster_registers locates the rasteriser image at base+0x28 (0x74/0xc8 by shader stage, matching registers), raster_from_registers rejects wireframe/both-culled/fractional-bias cases that D3D12 can't express, decodes cull, winding, depth-clip, clamp verbatim and slope bias as scale/16, then enumerates only the three unkept tail bytes. tried_raster dedups repeated images. The test asserts the exact 16-byte block for a decoded case plus every rejection path.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Verdict: merge candidate. crates/victory-game/src/pipelines.rs: raster_registers reads the 7 words from 0x28 into the fixed part of the register image, which ends exactly where registers() starts (0x44). raster_from_registers decodes cull from PA_SU_SC_MODE_CNTL bits 0-1 (none/front/back as D3D12 1/2/3, both culled skipped), winding from FACE (bit 2), wireframe from POLY_MODE (bits 3-4), and depth clip from the two ZCLIP_*_DISABLE bits (26-27) of PA_CL_CLIP_CNTL. These bit positions match the public RDNA2 register reference. The slope scale over 16 is how AMD hardware stores the slope bias. A candidate still counts only when its CityHash64 equals the record's hash, so a wrong decode would name nothing rather than name the wrong state. Named::find tries it before the enumeration, and the tests use synthetic register values.

CI: check passing. #3048 is stacked on this PR.


Generated by Claude Code

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