fix(shader): normalize negative color compare wrap indices #1262

Closed
MarcZX10 wants to merge 5 commits from upstream-pr/1262 into main
MarcZX10 commented 2026-10-07 20:15:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-07T20:15:08Z.


What

Normalize negative texel indices into the image extent when emulating color-texture comparison sampling with wrap addressing. Add point-filtered wrap coverage alongside the existing bilinear wrap checks.

Tested

  • Reproduced the failure on Debian Linux with llvmpipe (LLVM 15.0.6): negative coordinates returned 0 where point wrap expected 1 and bilinear wrap expected 0.35.
  • Built agc_driver_emulated_color_compare_tests with GCC 12.2.
  • Focused CTest agc_driver_emulated_color_compare: passed, including point and bilinear wrap, offsets, border modes, and unsupported-mode rejection checks.
  • tools/check_conventions.py --base upstream/main: passed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4777945431 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1262). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-07T20:15:08Z. --- ### What Normalize negative texel indices into the image extent when emulating color-texture comparison sampling with wrap addressing. Add point-filtered wrap coverage alongside the existing bilinear wrap checks. ### Tested - Reproduced the failure on Debian Linux with llvmpipe (LLVM 15.0.6): negative coordinates returned 0 where point wrap expected 1 and bilinear wrap expected 0.35. - Built `agc_driver_emulated_color_compare_tests` with GCC 12.2. - Focused CTest `agc_driver_emulated_color_compare`: passed, including point and bilinear wrap, offsets, border modes, and unsupported-mode rejection checks. - `tools/check_conventions.py --base upstream/main`: passed. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-08 10:12:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T10:12:23Z.

Review: CHANGES_REQUESTED


Thanks for the PR. Two issues:

  • The new point, wrap row passes without the change: reverting SpirvImageEmitter.cpp and rebuilding agc_driver_emulated_color_compare_tests, the test still passes on RADV and on the lavapipe CI installs (Mesa 25.2.8, LLVM 20). A test that passes on main doesn't cover the fix.
  • SPIR-V defines OpSMod as taking the sign of operand 2 (extent, always positive here), so OpSMod and the OpSRem + correction give the same result on any conformant driver. This reads as a workaround for a bug in llvmpipe/LLVM 15, not a semantic fix.

Please show a conformant driver (version and output) where OpSMod returns a wrong value for these inputs, and make the test fail on main in Linux CI, or drop the PR. If it is a driver bug, say so in the TechnicalDebt entry instead of describing it as an unmeasured hardware behaviour.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5455017731 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1262#pullrequestreview-5455017731). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T10:12:23Z. **Review:** CHANGES_REQUESTED --- Thanks for the PR. Two issues: - The new `point, wrap` row passes without the change: reverting `SpirvImageEmitter.cpp` and rebuilding `agc_driver_emulated_color_compare_tests`, the test still passes on RADV and on the lavapipe CI installs (Mesa 25.2.8, LLVM 20). A test that passes on `main` doesn't cover the fix. - SPIR-V defines `OpSMod` as taking the sign of operand 2 (`extent`, always positive here), so `OpSMod` and the `OpSRem` + correction give the same result on any conformant driver. This reads as a workaround for a bug in llvmpipe/LLVM 15, not a semantic fix. Please show a conformant driver (version and output) where `OpSMod` returns a wrong value for these inputs, and make the test fail on `main` in Linux CI, or drop the PR. If it is a driver bug, say so in the TechnicalDebt entry instead of describing it as an unmeasured hardware behaviour.
MarcZX10 commented 2026-10-08 10:22:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-08T10:22:59Z.


Closing for now. The reported failure reproduces on llvmpipe LLVM 15.0.6, but the change is a workaround for that driver behavior rather than a SPIR-V semantic fix, and the added test passes on the current Linux CI driver without the change. I do not have evidence of incorrect OpSMod behavior on a conformant driver. I will reopen if that evidence becomes available or if this is retained explicitly as a driver-specific workaround.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6057787864 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1262#issuecomment-6057787864). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-08T10:22:59Z. --- Closing for now. The reported failure reproduces on llvmpipe LLVM 15.0.6, but the change is a workaround for that driver behavior rather than a SPIR-V semantic fix, and the added test passes on the current Linux CI driver without the change. I do not have evidence of incorrect OpSMod behavior on a conformant driver. I will reopen if that evidence becomes available or if this is retained explicitly as a driver-specific workaround.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1262
No description provided.