shader: lower pull-model barycentrics (<I/W, J/W, 1/W>) and supply 1/W for pixel POS_W_FLOAT #561

Open
opened 2026-11-28 04:24:19 +00:00 by github-bot · 2 comments
Owner

@⁠Sheffy007 on GitHub · 2026-11-28 04:24 UTC · original

Refs #258, #410, #525.

Two pixel-shader hardware input bugs remain on main now that SPI_PS_INPUT_ENA / SPI_PS_INPUT_ADDR is decoded from the register image (1cf0fbc0):

  1. Pull-model barycentrics (Barycentric::PerspectivePullModel, SPI_PS_INPUT_ADDR bit 3) are refused as "barycentrics read directly" (11 pixel shaders in #525).

    • On GFX10 hardware, PERSP_PULL_MODEL_ENA populates three entry VGPRs with pixel-centre <I/W, J/W, 1/W> (AMD LGC LowerInOut::visitEvalIjOffsetSmoothOp), which shaders read as data to evaluate derivatives/offsets and recover perspective (I, J).
    • Lower::barycentric currently returns Val::Missing(BARYCENTRICS_READ) for B::PerspectivePullModel, which is the only path left that emits "barycentrics read directly" on pixel shaders.
    • In DXIL, SV_Position.w is clip-space W and perspective-centre SV_Barycentrics.yz are (I, J), so <I/W, J/W, 1/W> can be lowered directly as <SV_Barycentrics.y / SV_Position.w, SV_Barycentrics.z / SV_Position.w, 1.0 / SV_Position.w> (declaring SV_Position in ISG1 when the program did not already have one).
  2. Input::Position(3) (POS_W_FLOAT, SPI_PS_INPUT_ADDR bit 11) supplies W instead of 1/W.

    • On GFX10 hardware, POS_W_FLOAT holds 1/W (so console HLSL shaders that read SV_Position.w already emit v_rcp_f32 on that entry VGPR, matching AMD LGC LowerInOut's BuiltInFragCoord lowering when !noReciprocalFragCoordW).
    • Lower::input(Input::Position(3)) currently returns DXIL loadInput of SV_Position.w (W) without inverting it, causing console pixel shaders' v_rcp_f32 to compute 1/W instead of W (off by W^2 whenever W != 1).
**@⁠Sheffy007** on GitHub · 2026-11-28 04:24 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/557) Refs #258, #410, #525. Two pixel-shader hardware input bugs remain on `main` now that `SPI_PS_INPUT_ENA` / `SPI_PS_INPUT_ADDR` is decoded from the register image (`1cf0fbc0`): 1. **Pull-model barycentrics (`Barycentric::PerspectivePullModel`, `SPI_PS_INPUT_ADDR` bit 3) are refused as `"barycentrics read directly"` (11 pixel shaders in #525).** - On GFX10 hardware, `PERSP_PULL_MODEL_ENA` populates three entry VGPRs with pixel-centre `<I/W, J/W, 1/W>` (AMD LGC `LowerInOut::visitEvalIjOffsetSmoothOp`), which shaders read as data to evaluate derivatives/offsets and recover perspective `(I, J)`. - `Lower::barycentric` currently returns `Val::Missing(BARYCENTRICS_READ)` for `B::PerspectivePullModel`, which is the only path left that emits `"barycentrics read directly"` on pixel shaders. - In DXIL, `SV_Position.w` is clip-space `W` and perspective-centre `SV_Barycentrics.yz` are `(I, J)`, so `<I/W, J/W, 1/W>` can be lowered directly as `<SV_Barycentrics.y / SV_Position.w, SV_Barycentrics.z / SV_Position.w, 1.0 / SV_Position.w>` (declaring `SV_Position` in `ISG1` when the program did not already have one). 2. **`Input::Position(3)` (`POS_W_FLOAT`, `SPI_PS_INPUT_ADDR` bit 11) supplies `W` instead of `1/W`.** - On GFX10 hardware, `POS_W_FLOAT` holds `1/W` (so console HLSL shaders that read `SV_Position.w` already emit `v_rcp_f32` on that entry VGPR, matching AMD LGC `LowerInOut`'s `BuiltInFragCoord` lowering when `!noReciprocalFragCoordW`). - `Lower::input(Input::Position(3))` currently returns DXIL `loadInput` of `SV_Position.w` (`W`) without inverting it, causing console pixel shaders' `v_rcp_f32` to compute `1/W` instead of `W` (off by `W^2` whenever `W != 1`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 04:24:19 +00:00
Author
Owner

@⁠Sheffy007 on GitHub · 2026-11-28 04:24 UTC · original

/claim

**@⁠Sheffy007** on GitHub · 2026-11-28 04:24 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/557#issuecomment-7234009558) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 04:24 UTC · original

Claimed by @⁠Sheffy007. Open a draft pull request with Refs #557 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-28 04:24 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/557#issuecomment-7234012267) Claimed by @⁠Sheffy007. Open a draft pull request with `Refs #557` in its description within 24 hours, or the claim expires.
This discussion has been locked. Commenting is limited to contributors.
No description provided.