fix(shader): preserve raw fragment exports for integer attachments #6235
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6235"
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 firesand on 2026-10-15T06:09:42Z.
What
Raw32 fragment exports currently get a floating-point SPIR-V interface even when the color attachment is UINT or SINT: the interface is selected from the export encoding alone, with only UINT16 mode 7 treated as integer. Carry the attachment's numeric type into shader preparation so modes 1/2/3/9 preserve unsigned words or bitcast signed words through matching output interfaces. Keep packed UNORM on its existing logical-float/packing path.
Include the numeric type in draw and shader cache identities, and serialize it in request format 30. Older captures keep their previous automatic mode-based behavior. Reject compressed raw32 integer exports; signed16 mode 8, integer blending and integer alpha-to-coverage remain unsupported.
The GPU regression covers raw signed/unsigned bits, defined-channel mappings, separate UINT/SINT MRTs and one registered shader switching float→UINT→SINT→float without reusing an incompatible interface. It also covers compressed-raw32 refusal and existing UINT16 preparation. Existing graphics fixtures now distinguish integer attachments from float and packed UNORM attachments.
Semantics: AMD's SI register reference, SPI_SHADER_COL_FORMAT at 0x28714, permits float or signed/unsigned integer raw32 formats. Pinned Mesa export lowering preserves the 32-bit values and defines the R/RG/GFX10+RA placement; format selection selects the corresponding raw formats. RDNA2 ISA §11.1/Table 56 defines compressed exports as 16-bit components. Missing-component defaults have not been verified on native hardware; tests exclude those channels and the limitation is recorded in docs/dev/debt/shader.md. Vulkan readbacks do not constitute a native console oracle.
Related work: #5200 changes reversed-component-order blending and touches shared state/cache/serializer files. It does not implement this integer-output fix. No dependency on it is introduced; merging either may require rebasing the other. Targeted open-PR searches found no direct duplicate.
Tested
Release build and patched
libstarget passed. The final 1,230-test CTest run completed with 1,217 passed, 12 expected device/display skips, and one allocator failure. All changed shader, cache, serialization and graphics tests passed.guest_allocator_failuresreportsmalloc(300 GiB): succeeded despite RLIMIT_DATA; the same unchanged test fails identically on main on this host. Its cause is outside this patch and remains unresolved. CTest therefore exits 8; this is not an all-green run.d92a8dad390af1807cc91622b924252141816a5a; candidate:911920f04450f7e063235a988fe79681d210e261(one commit). Remote main was rechecked after validation.runtime export mapping uses the wrong scalar typebefore drawing. The candidate's--raw32-integercase passes with GPU readback. The two-line baseline patch is included below.ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build --output-on-failure --timeout 120 -j1; 234.87 seconds. Skip checker accepts all 12 skips: one missingVK_EXT_shader_stencil_exportand 11 offscreen display tests.APS5_NO_GPL=1. Conventions, test registration (883 executables) and whitespace checks pass. Validation excerpts and the baseline reproduction patch are included below; full JUnit and build logs are retained locally.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryValidation excerpts and baseline reproduction
Final candidate
911920f04, GCC 16.2.1, Gentoo Linux, kernel 7.2.9-cachyos-dist, NVIDIA RTX 4090 driver 615.78.08:Independent build from base
d92a8dad3with unchanged production code and only this fixture patch:Baseline results:
Candidate direct regression:
The candidate fixture supplies the new numeric-type field and checks GPU readback. Main's original API lacks that field; its test-only reproduction checks the resulting SPIR-V scalar mismatch before drawing. No game assets or title-specific patches are required.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-18T19:21:41Z.
Review: CHANGES_REQUESTED
Thanks, the approach (carry the attachment's numeric type into the request and cache keys) looks right. Points to fix before this can merge:
mainin 9 files (State.cpp,ShaderValidation.cpp,SpirvModuleEmitter.cpp,Recompiler.hpp,RequestSerializer.cpp,DrawRegisterKey.cpp,Graphics.cpp,ShaderMemory.cpp,RequestSerializerTests.cpp).mainis already at request serialization version 32 (this PR bumps 29 to 30), so the version, the base64 prefixes and the byte-level fixtures inRequestSerializerTests.cpp/ShaderMemory.cppneed redoing on top of 32, with older versions still replaying.ColorOutputTypeOf(State.cpp:1081) is incomplete.mainalready decodesVK_FORMAT_R8G8_UINT(State.cpp:800) but it is missing from the Uint cases, so an 8_8 UINT target falls back to Float (also reported by @Amoenus on911920f04, with a proposed fix). OnlyR32_SINTis Sint: every other SINT format the decoder can produce would silently get a float interface. Please derive the type from the format family (or list every UINT/SINT format the decoder returns) and add a test row per format.Welcome to push the rebased version.
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-21T18:19:32Z.
A title that hits this: Art Swap PPSA99318 v1.2.0 writes a float fragment output into an
R8_UINTcolor attachment.output of type float4 is not compatible with a MTLPixelFormatR8Uint color attachment.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T02:30:15Z.
Another title on Apple M2 (macOS 26, MoltenVK, Rosetta) that stops on this: PS5CEMU-HAR PPSA99360 5.0.0, converted with
--trap-sdk-syscall-stubs, stops at 4 s with MoltenVK'soutput of type float4 is not compatible with a MTLPixelFormatR8Uint color attachmentfromvkCreateGraphicsPipelines(result -3), the same as Art Swap above. Not run with this PR applied.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T01:47:19Z.
Review: CHANGES_REQUESTED
Still blocked on a rebase, and it is no longer mechanical. Checked against current
main:State.cpp,State.hpp,ShaderValidation.cpp,Recompiler.hpp,CacheKey.hpp,DrawRegisterKey.cpp,SpirvModuleEmitter.cpp,RequestSerializer.cppand four test files.mainis at request serialization version 46 (this PR bumps 29 to 30), so the version, the base64 prefixes and the byte-level fixtures need redoing on top of 46, with older versions still replaying.mainnow has its own integer-export mechanism:ColorTarget::uintExport(State.hpp:67, set fromslotExport == 7inState.cpp:1492, added in45541350bb) and the matchingvertex:u32x4check inShaderValidation.cpp:728-730. This PR'sColorOutputTypeoverlaps it. Please fold one into the other (for example deriveuintExportfrom the new per-attachment type, or drop it) so there is one place that decides the interface, keeping the "blending into an unsigned integer target is unsupported" check and the UINT16_ABGR tests working.ColorOutputTypeOf(State.cpp:1081) is incomplete (unchanged from our earlier comment):VK_FORMAT_R8G8_UINTfalls back to Float, and onlyR32_SINTis Sint. Derive the type from the format family, or list every UINT/SINT format the decoder returns, and add a test row per format.Alexius0815 posted a rebase of this commit (https://github.com/Alexius0815/AnyPS5/tree/contrib/integer-attachment-exports) that can be a starting point, but it predates the
uintExportinteraction and the current serializer version. Welcome to push the rebased version.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:55:22Z.
Review: CHANGES_REQUESTED
Reviewed — comments
Changes are required before merge: resolve the signed integer attachment format mapping before treating signed raw32 output as supported.
What I ran
Reviewed head
911920f04450f7e063235a988fe79681d210e261. No commands or tests were run in this review; author-reported validation is not treated as a run performed here.Results
Findings
Blocking
ColorOutputTypeOfclassifies onlyVK_FORMAT_R32_SINTas signed, while unsigned formats include multiple component widths and counts. A signed attachment such asVK_FORMAT_R32G32B32A32_SINTtherefore resolves toFloat, causing the output interface and validation expectation to disagree with the integer attachment. This contradicts the stated signed integer attachment support and can reject valid shader output preparation or emit an incompatible float interface. Handle all supported signed integer formats consistently (or explicitly reject unsupported formats). Evidence:core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:113.Non-blocking
None.
Not verified
Full text was read for all changed files marked included in the manifest except
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, which the manifest marks excluded as too large. The changed hunks and relevant lines for the blocker were reviewed. No build, tests, negative control, native console behavior, or external CI was verified. Author-reported test results appear in the PR description.To get this to a good state
Add signed-format classification for the supported Vulkan signed integer formats, or reject the unsupported ones explicitly, then rerun the shader and graphics tests covering signed integer attachments.
Pull request closed