fix(shader): read the ancillary render target index as 0 #4842
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4842"
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 LeandroLP23 on 2026-10-12T23:27:48Z.
What
Fixes #4800.
The packed pixel ancillary lowering now uses the constant 0 for the render target index field (bits 16+) instead of reading the
Layerbuiltin.Why 0 is right. No pre-rasterization stage writes
Layertoday:State.cppignores the vertex layer and viewport exports ofPA_CL_VS_OUT_CNTL.paClVsOutCntlis never set, so noLayeroutput is emitted.When the last pre-rasterization stage has no
Layeroutput, Vulkan uses the first layer (Layer). So the value the field stood for is 0.Why reading
Layeris wrong here. On AMD's Windows driver, a fragment shader that consumes the unwrittenLayerloses its colour writes, even when the value never reaches the output. lavapipe returns 0, so CI didn't see it.#4800 has the module dumps and the edited-module runs that isolate this:
gl_SampleIDreplaced by 0: still loses the writes.gl_Layerreplaced by 0: writes land.gl_Layerloaded but unused: writes land.The
shader.mddebt entry for the packed ancillary word now says where the 0 comes from. #423 and #1077 (@alfalfa-star) make layered draws exportLayerthroughPA_CL_VS_OUT_CNTL. Once they land, those draws need the real value: readLayerwhen the draw exports it, and 0 otherwise, which is the case this change covers. Nothing onmainexports it yet, so I left that condition out.Tested
Windows 11 (26300), AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, onmain43e3a70f8:agc_driver_relative_ancillary: failed onmainon this GPU; passes 3/3 with this change.pixel_ancillary: 3/3. It now requires the render target index field to be 0 for rows whose layer is not 0.ctest -R '^agc_' -j 1(shader cache emptied): 445/445.ctest -E '^agc_' -j 4: 574/574.main'sConstantFolder.cpp,pixel_ancillaryandagc_driver_relative_ancillaryboth fail.main: Stremio Plus, Capy Mobile, DriftCheck, EVO Player, DOOM and OpenRCT2.conventions_ci_gate, because my fork runs the oldbuild.ymlwithout file filters, whichmain's checker rejects. It is not this change.tools/check_conventions.py --base origin/mainandgit diff --checkpass.Not run on Linux locally. No title on hand reads the ancillary layer field; that is #2548's set: Stray, Kena, Lies of P and others.
Overlap. #4031 (@AlxcBTW) also changes
lowerPackedAncillaryandPixelAncillary.cpp: it adds the primitive class field. The two don't depend on each other. Whichever merges second has to take this into account:Layerread: the whole-word composition,insertBuiltin(..., StageInputKind::Layer)shifted by 16. With this change that read becomes the same constant 0.pixel_ancillarycases need to agree on the field.I merged #4031's head
dd8403112onto this branch locally and applied the same 0 at that read. Its newagc_driver_pixel_ancillary_wordthen passes on this AMD GPU, 3/3, where it failed on #4031 alone, and so doesagc_driver_relative_ancillary.pixel_ancillaryneeds that merge reconciled. If #4031 goes in first, I'll rebase this one and do it.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 oneandonlydean on 2026-10-13T01:03:32Z.
#4031 is merged, so I rebased this onto it and pushed (
3334e41e45, your commit and message kept). TheConstantFolder.cppchange is the same: the render target index field is a constant 0, and the helper #4031 added now takesSampleIdonly. The debt entry indocs/dev/debt/shader.mdis merged with the one #4031 added. Full build is running;agc_driver_relative_ancillaryon AMD is the part we can't run here.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-13T06:00:13Z.
Confirmed on AMD after the merge:
main88107b7de(with #4031 and this), Windows 11, Radeon 860M (driver 32.0.13058.8001), Release.agc_driver_relative_ancillary,agc_driver_pixel_ancillary_wordandpixel_ancillarypass 3/3, andctest -R '^agc_' -j 1is 460/460. Thanks for carrying it over #4031.