Skip to content

fix(shader): normalize negative color comparison wrap indices - #2177

Merged
adriadam10 merged 4 commits into
boykopovar:mainfrom
MarcZX10:codex/fix-color-compare-negative-wrap
Oct 10, 2026
Merged

adriadam10 merged 4 commits into
boykopovar:mainfrom
MarcZX10:codex/fix-color-compare-negative-wrap

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Normalize negative texel indices in the emulated color-comparison wrap path before converting them to unsigned image coordinates. Add a point-filtered wrap execution case with texel offsets that produce negative indices. This specifically exercises the failure on Mesa 22.3.6 llvmpipe (LLVM 15.0.6): the base OpSMod path returned 0 where the CPU reference expected 1; the explicit OpSRem normalization passes. The implementation follows repeat addressing (VK_SAMPLER_ADDRESS_MODE_REPEAT) and uses signed remainder semantics with a correction into the nonnegative texel range. See the Vulkan specification and SPIR-V OpSRem. The technical-debt entry records that PS5 behavior has not been measured.

This is distinct from #2092, which expands supported color-comparison descriptor formats and views; it does not change address wrapping.

Tested

Current head 9ffd06ea is rebased onto upstream main at a291ae0f88d3dbee71ebf0226ede547284450fd5. The three-file diff remains limited to the emitter, its execution test, and TechnicalDebt.

  • Linux x86_64, GCC 12.2, Release, Mesa 22.3.6 llvmpipe (LLVM 15.0.6): built libSceAgcDriver and agc_driver_emulated_color_compare_tests; focused CTest agc_driver_emulated_color_compare passes (1/1) with the new negative-offset point-wrap case.
  • Baseline control on the same llvmpipe setup: with main's unmodified OpSMod emitter and the new test case, the test fails at thread 4 (actual 0, expected 1). With this PR's OpSRem normalization, the test passes. The baseline and candidate were built and run from the same Release tree.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD pass.
  • GitHub Build run 38034308447 passed all eligible jobs on this head, including the Ubuntu, macOS, and Windows relinker jobs, register-context matrix, and write-watch tests. The full Linux and Windows Build jobs were skipped by the fork eligibility gate. No PS5 hardware or game runtime was available.

Checklist

  • Based on current main; no other open PR implements the same wrap correction
  • 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 — not applicable to this change
  • No notes, investigation .md files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@MarcZX10
MarcZX10 force-pushed the codex/fix-color-compare-negative-wrap branch from 570e680 to 72c6f98 Compare October 9, 2026 10:55
@MarcZX10

MarcZX10 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

The PR is based on current main (d70b8998), is mergeable, and both Conventions runs pass. The focused Linux color-comparison execution test passes on this head; the full Build is not available to fork contributors under the current workflow. Could a collaborator with write access run Actions → Build for PR #2177 so the Linux, Windows and relinker checks are recorded on this head?

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Oct 9, 2026
@rmz-24

rmz-24 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON, full build plus libs. 72c6f98 cherry-picked onto current main d70b899 (applies cleanly).

  • agc_driver_emulated_color_compare passes on NVIDIA.
  • Full ctest: 510/510.

AI-assisted: yes

@MarcZX10

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the Windows run: it covers the exact head 72c6f98 on current main, and the full Windows CTest passes (510/510), including the NVIDIA emulated color-comparison test. That supplies the Windows evidence. The upstream PR still reports only Conventions; under CONTRIBUTING, could an authorized collaborator run the official Build for this exact head to record Linux and the relinker matrix? I will keep the PR open until that check is available.

@MarcZX10
MarcZX10 force-pushed the codex/fix-color-compare-negative-wrap branch from 72c6f98 to e755aaf Compare October 9, 2026 19:20
@MarcZX10

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Rebased the existing PR linearly onto current main (ae3d5f95) at head e755aaff. The focused diff remains three files. On this head, libSceAgcDriver and the emulated color-comparison test build on Linux, and agc_driver_emulated_color_compare passes (1/1) on lavapipe. Local Conventions and git diff --check pass; the description now records the new base/head and the absence of PS5 runtime evidence.\n\nCould a collaborator with write access run the required upstream Build and relinker matrix for this exact head under #2113?

@MarcZX10
MarcZX10 force-pushed the codex/fix-color-compare-negative-wrap branch from e755aaf to 911d951 Compare October 9, 2026 23:21
@MarcZX10

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Rebased the existing PR onto current main (00dd2ba8) at 911d95157bf6ca3b13a408235524daacb4ac8eff. The focused three-file diff is unchanged. On this head, Linux GCC 12.2 Release/lavapipe built libSceAgcDriver and the emulated color-comparison execution test; agc_driver_emulated_color_compare passes (1/1). Conventions and git diff --check pass. The previous Windows NVIDIA result was for an earlier head and is labeled that way in the description. Could a collaborator with write access run Actions → Build for #2177 on this exact head to record the official Linux, Windows and relinker matrix? PS5 behavior remains unmeasured.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR. Checked on current main + this head (Linux, lavapipe, Release):

  • The new point, wrap case passes without the emitter change (reverted SpirvImageEmitter.cpp, rebuilt, test still passes), so it doesn't pin the fix. It runs with offsets=false, so it never produces a negative texel index either; the existing bilinear, wrap, offsets... case already covers negative indices and passes on main.
  • SPIR-V OpSMod already takes the sign of the divisor (result in [0, extent) for a positive extent), so on a conformant driver the current code is correct. The description says the regression fails with direct OpSMod on llvmpipe (LLVM 15.0.6); I couldn't reproduce that, and no log is attached.
  • docs/dev/TechnicalDebt.md:361 describes a driver workaround as a PS5 behaviour gap; if this is a driver bug it should say which driver/version.

To move forward: provide a test that fails on main and passes with the change (negative texel coordinates or offsets, with the driver and version where it fails), or close the PR if it was not reproducible.

@MarcZX10
MarcZX10 force-pushed the codex/fix-color-compare-negative-wrap branch from 911d951 to 606bc16 Compare October 10, 2026 07:23
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for identifying the missing negative-index case. I added one to the execution regression and reproduced the failure on the named driver.

Current head: 9ffd06ea, rebased onto upstream main a291ae0f.

Emitter Mesa 22.3.6 llvmpipe (LLVM 15.0.6), point wrap with negative texel offset
main (OpSMod) Fails at thread 4: actual 0, expected 1
This PR (OpSRem plus correction) Passes; agc_driver_emulated_color_compare 1/1

Both versions were built and run from the same Linux x86_64 GCC 12.2 Release tree. I updated TechnicalDebt and the PR description to identify this as a Mesa 22.3.6 llvmpipe result. Conventions and git diff --check pass; GitHub checks for the new head are running.

This reproduces a driver-specific regression and validates the workaround on that driver. It does not establish PS5 behavior, which remains unmeasured. Please re-evaluate the change request with the added case and control result.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Current-head CI result

Build run 38034308447 completed successfully on head 9ffd06ea.

Check group Result
Register-context (Ubuntu Debug/Release, macOS Intel Debug/Release) Passed
Write-watch (macOS) Passed
Relinker (Ubuntu, macOS, Windows) Passed
Full Linux and Windows Build Skipped by the fork eligibility gate

The focused Linux regression and baseline-control result are described above. This provides no PS5 hardware or game-runtime evidence. The requested negative-offset case reproduces on the named Mesa/llvmpipe version and passes with the change; please re-review when convenient.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Checked on current main + this head (Linux, Release): agc_driver_emulated_color_compare passes. The new case passes on conformant drivers even without the emitter change (so it only discriminates on the old llvmpipe you named, which we can't reproduce), but the OpSRem + correction is equivalent to OpSMod for a positive extent and harmless elsewhere. Windows/NVIDIA run by @rmz-24 also passes. PS5 behaviour is unmeasured, as recorded in TechnicalDebt. Merging.

@adriadam10
adriadam10 merged commit 0bc8313 into boykopovar:main Oct 10, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants