gpu(native): read the guessed pipelines' polygon offset from the register image #67
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!67
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/67/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Olima34 on GitHub · 2026-11-26 12:50 UTC · original
Olima34:fix/guessed-depth-bias→main· +24 −4 · 2 files · 2 commits · merged 2026-11-26 13:34 UTCWhat this changes
Closes #18: the part left after #25, decoding the depth bias for guessed pipelines.
Graphics::guess_fromnow reads the three polygon offset floats that sit 0x24, 0x20 and 0x1c bytes before the blend block of the 0x1c8 register image (listed in native-host.md as "floats (polygon offset): not used yet") into the guessed state's depth bias.victory-metalalready passes that bias tosetDepthBias:slopeScale:clamp:on every draw since #25.PA_SU_POLY_OFFSET_CLAMP,_FRONT_SCALEand_FRONT_OFFSET(0x28b7c to 0x28b84). They are converted back the way AMD's PAL writes them inCmdSetDepthBiasState: the clamp as it is, the slope scale times 16 ("HW applies a factor of 1/16th to the Z gradients"), and D3D12's integer bias as a float. SoDepthBiasis the offset,SlopeScaledDepthBiasis the scale / 16 andDepthBiasClampis the clamp.POLY_OFFSET_FRONT_ENABLE(bit 11 ofPA_SU_SC_MODE_CNTL) is set. All fourPA_SU_SC_MODE_CNTLvalues in the table set it, along with bit 12, the back face's.This is a guess, and it is marked as one in the code and in native-host.md. I don't have the game, so which float is which was not checked against real images. What supports the guess: the two constants just before the floats (0x8, 0x1000) look like
PA_SU_LINE_CNTLandPA_SC_LINE_CNTL(0x1000 isDX10_DIAMOND_TEST_ENA), so these words look like a raster group. Also, the 16.0 seen is a slope scale of 1 in hardware units. A quick check on images dumped withVICTORY_DUMP_DESC_DIR: the word 0x1c back should only ever hold whole numbers, and 16.0 should be at 0x20 back. If the order turns out different, the fix is one line.The docs change also refreshes the "State" bullet of the guessed-pipelines list. It still said "no culling, depth less-equal with writes", but those have been read from the image since
f280b71.How it was tested
cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: every test passes except the 16 that build the native probe (native_probe,native_list_imports). Those need Homebrew's LLVM (llvm-dlltool), which this Mac doesn't have. This change doesn't touch those crates.cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, also with--all-featurescargo xtask policyvictory-gputests on arm64:blend_is_read_from_the_register_imagenow also checks that the bias is read and handed to Metal in its order (bias, slope scale, clamp), and that there is none withoutPOLY_OFFSET_FRONT_ENABLE. The test fails without the change (left: (0, 0.0, 0.0),right: (29, 0.003, 1.0)). With the Metal Shader Converter 4.0 installed, the wholevictory-gpusuite passes (155 tests, including the Metal render testdepth_bias_resets_between_draws_in_the_same_pass), and so doesvictory-metal(15 tests).Checklist
VICTORY_*variable and documented (none added)@LakshanSivakumar on GitHub · 2026-11-26 13:26 UTC · original · approved these changes
Code, tests, and
docs/native-host.mdchanges look solid:Graphics::guess_fromreadsPA_SU_POLY_OFFSET_CLAMP,_FRONT_SCALE(/ 16.0), and_FRONT_OFFSETintog.biaswhenPOLY_OFFSET_FRONT_ENABLEis set, clearly marked as a guess in code and docs, andblend_is_read_from_the_register_imagepins the field order and enable bit. Approving; waiting on CI to pass before merging.