fix(shader): normalize offset perspective barycentrics after interpolation #7831
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7831"
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?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T09:29:32Z.
What
Fixes perspective-correct barycentric reads at sample and center offsets when the host lacks native fragment barycentric support. The emulation path interpolates reciprocal clip-W weighted vertex basis values with
NoPerspective, then normalizes the selected component to recover perspective-correct barycentrics. Geometry and tessellation emulation layouts are updated, along with shader disk cache format and layout regression checks.Tested
Linux, AnyPS5 shader recompiler/AGC driver.
cmake --build /tmp/AnyPS5-7794-build --target agc_driver_pixel_sample_iteration_tests agc_driver_graphics_tests --parallel 4passed.python3 tools/check_conventions.py --base upstream/mainandgit diff --checkpassed. Targeted CTest launch aborted before test code because this host's Xeon E5-1620 v2 lacks AnyPS5's required AVX2/BMI/FMA CPU features. No RADV GPU is available here; GPU validation remains outstanding.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-19T10:44:02Z.
First GPU run, on AMD and Windows. AMD Radeon 860M (RDNA 3.5,
1002:1114), driver 32.0.13058.8001, Windows 11, WinLibs GCC 15.2.0, Release,ANYPS5_NO_SHADER_CACHE=1. Head merged intomain118266aec(clean merge). "Main's sources" means this PR's test files overmain's other files.agc_driver_pixel_sample_iterationandagc_driver_graphicspass 3 of 3.Graphics.cppchecks don't build againstmain's sources. They use the newBarycentricEmulationlayout, e.g.reciprocalWLocation.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by root-over on 2026-10-19T14:11:39Z.
RADV run, the case from #7825: Linux (Ubuntu, kernel 7.0), Ryzen 5 5625U iGPU (Vega, RADV RENOIR, Mesa 26.0.8, no
fragmentShaderBarycentric), GCC 15.2.0, Release.main04078b107againstmainwith this head (c56766911) merged (a clean merge), same build directory.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1,ctest -V, each device selected withVK_DRIVER_FILES.main, RADVmain, lavapipeagc_driver_pixel_sample_iterationagc_driver_pixel_barycentric_emulationagc_driver_graphicsagc_fragment_barycentricOn
mainRADV still fails as reported in #7825:4x PERSP_SAMPLE, POS and ANCILLARY run once per pixel: pixel (0, 0) slot 0 read the barycentrics (0.001464, 0.998083), expected (0.001473, 0.997545) at (0.375000, 0.125000). With this PR,pixel_sample_iterationandpixel_barycentric_emulationpass 5 of 5 on RADV (--repeat until-fail:5).None of the four logs contains
VUID-.VK_LAYER_KHRONOS_validationisn't installed on this machine, though, so this run doesn't count as a validation-layer comparison.Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T14:32:31Z.
AMD and Intel Windows data: the 29 tests built from
tests/Graphics.cpppass with this PR on an AMD RX 9070 XT and an Intel UHD 770.Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This headc56766911merged intomain85029a00f.tests/Graphics.cppThere is no run without the change: the test diff uses the new
BarycentricEmulationLayout::reciprocalWLocationand the newBarycentricEmulationinitializer, so it does not build onmainalone.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by root-over on 2026-10-19T14:32:59Z.
Follow-up with
VK_LAYER_KHRONOS_validationnow installed: same machine, same four tests, currentmainbcdee66d1againstmainwithc56766911merged,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -V, on RADV and lavapipe.agc_driver_pixel_sample_iterationfails onmainwith RADV and passes with this PR. Everything else passes on both builds and both drivers.was not found but was requested by env var VK_INSTANCE_LAYERS.VUID-VkGraphicsPipelineCreateInfo-pLibraries-06681errors, all fromagc_driver_pixel_barycentric_emulation, with or without this PR and on both drivers ("descriptor set layout at index 1 ... in the fragment shader state is NULL"). This PR adds no newVUID-. The existing error looks like what #7722 addresses.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T16:52:06Z.
Thanks for the AMD/Windows, RADV, lavapipe, Intel, and validation-layer runs. Together they show the target
agc_driver_pixel_sample_iterationregression on main and a pass with this change on RADV and AMD, while the broader graphics tests pass on the reported devices. The 12VUID-VkGraphicsPipelineCreateInfo-pLibraries-06681messages reproduce on both versions and are not introduced by this PR. I also note there is no source-only baseline for the new-layout tests because they depend on this PR’sBarycentricEmulationlayout.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T08:04:58Z.
Rebased this PR onto current
mainas53643d3b. The conflict resolution keeps both this change’s reciprocal-W interpolation and main’s mesh barycentric position inputs; the cache encoder/decoder preserve both metadata additions in matching order.check_conventions.pyandgit diff --checkpass on the new head. The AMD, Intel, RADV and lavapipe test results above were fromc56766911, before rebase, and have not been rerun on this head. This host cannot run the focused test executables because its Xeon E5-1620 v2 lacks the project’s required AVX2/BMI/FMA features; the filesystem also has only 1.2 GiB free, so a clean rebuild is not available here.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T08:05:09Z.
Rebased this PR onto current main as 53643d3b. The conflict resolution keeps both this change’s reciprocal-W interpolation and main’s mesh barycentric position inputs; the cache encoder/decoder preserve both metadata additions in matching order. check_conventions.py and git diff --check pass on the new head. The AMD, Intel, RADV and lavapipe test results above were from c56766911, before rebase, and have not been rerun on this head. This host cannot run the focused test executables because its Xeon E5-1620 v2 lacks the project’s required AVX2/BMI/FMA features; the filesystem also has only 1.2 GiB free, so a clean rebuild is not available here.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T11:26:27Z.
Review: CHANGES_REQUESTED
Rechecked against current main: the reciprocal-W normalization and main's mesh barycentric inputs still coexist, and the merge is clean. One point left:
core/shader/recompiler/ShaderDiskCache.hpp:16: the PR addsShaderInfo::smoothOffsetBarycentricsandBarycentricEmulation::smoothOffsetto the serialized format but doesn't bumpFormatVersion(still 41 on main), so existing v41 caches would be decoded misaligned. Bump it to 42.With that, this is ready to merge.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T18:14:27Z.
Addressed the cache-format review in
b4b231470e: the changedShaderInfoandBarycentricEmulationserialization now use format version 44, and the existing disk-cache test verifies that the immediately previous format is rejected.I used 44 rather than 42 because two other open cache-format changes already occupy the intervening versions: #7689 uses 43, and #6924 also changes serialized cache records. This keeps the format identifier distinct regardless of merge order. The code change is one focused commit; I did not add merge or empty commits.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T18:44:02Z.
Thanks for catching the cache compatibility issue. The current head
b4b231470ebumpsShaderDiskCache::FormatVersionfrom 41 to 44, so existing v41 entries are rejected instead of decoded with the added fields. I used 44 because the open #6924 and #7689 branches reserve 42 and 43 respectively. The updated head passes the local conventions check andgit diff --check.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T20:39:18Z.
The current PR head
b4b231470ealready addresses this:fix(shader): bump cache format for barycentric metadatachangesFormatVersionfrom 41 to 44. I verified the current head file. This is above the requested 42 because main has advanced the cache format since the review. Could you recheck the current head and update the review state if this resolves your remaining concern?Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T21:10:39Z.
@adriadam10 could you take another look? Your remaining point is addressed on b4b231470e:
ShaderDiskCache.hppnow bumpsFormatVersionto 44 for the newsmoothOffsetBarycentrics/smoothOffsetfields, and the serialization matches it. From our side the change reads correctly: offset smooth barycentrics are interpolated as lambda/w without perspective and then normalized, so they come out perspective-correct, and the path only runs where barycentrics are emulated.Once you're happy, it goes to full CI on this head. Several open PRs bump the same
FormatVersion, so whichever lands later takes the next free number.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:40:03Z.
The cache-format issue is fixed on current head
b4b231470e21d852a1d000e067660ec006f86a98; it uses format version 44 so the newly serialized barycentric fields do not collide with the other open version bumps. The exact-head focused Linux tests and validation comparison are in the thread, and the separate runtime check reports the targeted pixel-sample test passing on RADV. Could you re-review this head and confirm the cache-version point is clear?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T01:37:51Z.
Review: COMMENTED
Rechecked the current head
b4b231470e21d852a1d000e067660ec006f86a98: the serialized barycentric fields now bump the cache format from 41 to 44, so the v41 misdecode concern is addressed. The author-facing follow-ups here have asked for a re-review several times; revieweradriadam10should now be able to dismiss the old CHANGES_REQUESTED state if satisfied.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T01:43:03Z.
Rebased the PR onto current
main(557682ca44b08c51e5a51a42ecb2d8a9e3d41f9c) after resolving the sole conflict inShaderDiskCache.hpp. Current main uses format 42; this PR keeps format 44 because the new serialized barycentric fields need their own invalidating version above the intervening open format changes. The two original commits remain authored by MarcZX10.git diff --checkandpython3 tools/check_conventions.py --base upstream/mainpass on headb67f0d277d5da3a216b5bf09626598c3242c6ad7. The CI checks have not completed yet.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T01:44:48Z.
CI has now completed on exact head b67f0d277d5da3a216b5bf09626598c3242c6ad7: eligibility, conventions, labels and the progress report pass. Runtime build jobs (Linux, Windows, relinker, register-context and write-watch) were skipped by workflow gating, so this is not a runtime validation result. The outstanding review state is still the cache-version request; current main is format 42 and this PR uses 44 to avoid the other open serialization changes.
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T06:40:16Z.
A Windows GPU run, since the PR's runtime CI jobs were skipped. It ran on an RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200, MinGW GCC 15.2.0, Release,
ANYPS5_REQUIRE_VULKAN=1, comparingmainec7eacc62withmainmerged with this headb67f0d277(the merge is clean).AMD's driver reports
fragmentShaderBarycentric, so the emulation path doesn't run here by default. For the emulation runs I forced it locally:FragmentShaderBarycentricUsablereturnedfalse, a change that is not committed.Four tests:
agc_driver_pixel_sample_iteration,agc_driver_pixel_barycentric_emulation,agc_driver_mesh_barycentric_emulationandagc_driver_pixel_sample_coverage. All four pass 3 of 3 in every setup:mainagc_driver_pixel_sample_iterationruns all 21 draws under emulation.So AMD's proprietary compiler doesn't show the RADV behaviour from #7825:
main's emulation already passes there, and this PR keeps it passing on both paths.Not run: the validation layer, RADV, and titles.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T07:27:38Z.
Thanks for the independent Windows GPU matrix. The forced emulation runs exercise the path implicated by #7825 on gfx1031, while the native runs check the driver-supported path; the 3/3 results are useful and clearly scoped. I have asked @adriadam10 to reassess the cache-version correction and this additional evidence together.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T17:47:18Z.
Review: CHANGES_REQUESTED
The normalization and the serialized-field changes look right. One point left:
core/shader/recompiler/ShaderDiskCache.hpp:16: main already reachedFormatVersion44, so the PR's 44 no longer invalidates anything and v44 caches would be decoded misaligned. Bump it to 45 (the existing test then still checks the previous version is rejected).With that, this is ready to merge.
Imported from boykopovar/AnyPS5. Originally posted by ryanc2112 on 2026-10-22T14:44:47Z.
RADV / Polaris run at
b67f0d277: this device has nofragmentShaderBarycentric, so the pixel shader takes the barycentric emulation path natively, the #7825 case. SteamOS 3.8.28, AMD Radeon RX 570 (RADV POLARIS10), Mesa 26.2.5, GCC 16.2.1, Release, merged ontomain4777caca3(clean) vsmain, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.agc_driver_pixel_sample_iterationonmainfails with the numbers in #7825:4x PERSP_SAMPLE, POS and ANCILLARY run once per pixel: pixel (0, 0) slot 0 read the barycentrics (0.001464, 0.998083), expected (0.001473, 0.997545) at (0.375000, 0.125000). With the PR:pixel sample iteration tests passed (21 draws), 3/3.pixel_sample_iterationfail → pass; the remaining failure,sample_order_recipe_depth_locations(#9759), fails the same on both.agc_*+texture_format_lookup(867 on both): failures 5 onmain→ 4 with the PR, the only change beingpixel_sample_iteration. No new failures; identical validation output (6×VUID-VkWriteDescriptorSet-descriptorType-00337on both, from #9759's test).AI-assisted: yes.