feat(agc): blend constant color factors into 11_11_10 float color targets #20010
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20010"
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 c1b3r-p3d1a on 2026-11-14T11:42:23Z.
What
A blend into an 11_11_10 float color target whose
CB_BLEND_CONTROLnamesCONSTANT_COLOR(13),ONE_MINUS_CONSTANT_COLOR(14),CONSTANT_ALPHA(19) orONE_MINUS_CONSTANT_ALPHA(20) stopped withblending into an 11_11_10 float color target with a constant color factor is not implemented. These four factors now blend in the pixel-interlock merge that already serves the other factors of this format.PackedBlendControl(State.cpp) accepts the four factors.ExportTargetMergescopies the draw's blend constants into the newTargetMerge::blendConstantswhen the merge's control names one of them, and leaves zeros otherwise so other draws keep their shader keys. The constants come fromState::blendConstants, whichDecodeStatealready orders by the target's component mapping for the host blend constants, so each field takes the constant of the export channel it stores.PackedBlendFactor(SpirvModuleEmitter.cpp) returns the field's constant, its complement, the alpha constant or its complement as fp32 constants, multiplied like the other factors. MIN and MAX keep ignoring the factors.u32per merge at the end of the request (version 65; main's version 64 holds the split state); older requests decode them as 0.The factor values are the GFX10
CB_BLEND0_CONTROLenumerations in Mesa's sid.h (V_028780_BLEND_CONSTANT_COLORand the three after it), the same valuesblendFactorinState.cppalready maps for the other targets. The CB's precision for this format and which field each constant reaches are not measured on a console; the debt file says so in a new entry. Still throwing: dual-source factors, unknown factors and combine functions, multisampled and volume targets.Tested
Windows 11, AMD Radeon RX 7700 XT (driver 32.0.32015.7029), WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh r7), Release, on
mainb69e0de889(head775fee3c3a).agc_driver_packed_float_blend: three new cases draw into the tiled 256x128 target with distinct red, green, blue and alpha constants and compare every stored word with the CPU reference:CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,CONSTANT_ALPHA, ONE_MINUS_CONSTANT_ALPHA, and a subtractingCONSTANT_COLOR, ONE. The test now reports 14 single blends.agc_driver_graphics: the former throw check now decodes aCONSTANT_COLORblend, checks that the merge carries the constants in the target's field order (blue, green, red, alpha for the standard swap), that a blend without a constant factor carries zeros, and that the static shader key separates two merges that differ only in a constant.agc_shader_memory,request_serializer: the merge fixture carries constants, round-trips them and reads versions 49, 53 and 54 without them. The version-62 fixtures move to 64.Mutations: five planted bugs each fail a test: complementing
CONSTANT_COLOR, reversing the field order of the constants in the shader, using the color constant forCONSTANT_ALPHA, reversing the constants in the driver, and dropping them on deserialization. Leaving them out of the cache key survived, so I added the key check above.Related run:
ctest -R '(blend|merge|packed|color_target|serializ|draw_cache|^agc_driver_graphics$|^agc_shader_memory$)'passes 109 of 109 (run onf0c9b11f91, before the rebase; the five suites named above pass again after it).Validation layer:
agc_driver_packed_float_blendandagc_driver_packed_float_color_targetwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(1.4.368),ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1: the loader inserts the layer, both pass, 0VUID-lines.After merging
main0694c4cbd6(head3634b00ab9):request_serializer,agc_driver_graphicsandagc_driver_packed_float_blendpass on Windows;agc_shader_memory,agc_shader_memory_coherent_atomic_loadsandrequest_serializerpass on WSL Ubuntu 24.04 (GCC 13.3), because Windows Defender quarantines the freshly linkedagc_shader_memory_tests.exeon this machine.Conventions:
python tools/check_conventions.py --base origin/mainpasses.Staged copies: a rebuilt
libSceAgcDriver.prxis not copied over the copies staged inbuild/testson Windows (#17895), so I copied it before each run.Not run: the whole
agc_/shadersuite, Linux, other vendors, and a title that blends this way.cdae47f333:request_serializerround-trips the constants of two merges, writes and reads none for a lone zero-mask merge, and rejects a truncated tail; it passes on Windows 11 and WSL Ubuntu 24.04, and fails when the constants are written for zero-mask merges, not read back, or written altered.b450a8d68c: following Colewiz7's RDNA2 (gfx1036) measurement, each finite constant is cut to a 12-bit significand before the products.agc_driver_packed_float_blend(with a newONE_MINUS_CONSTANT_COLOR,ZEROcase on0x3f7ffff0),agc_driver_graphicsandrequest_serializerpass on Windows 11 (AMD RX 7700 XT) and WSL Ubuntu 24.04 (llvmpipe), and the blend test fails with the fp32 constant;agc_shader_memorypasses on WSL.289ffb3c29: each merge record carries its own blend constants after its slices, written and read under the same non-zero mask check, instead of a tail loop after the request.request_serializer,agc_driver_packed_float_blendandagc_driver_graphicspass on Windows 11;agc_shader_memoryandrequest_serializerpass on WSL Ubuntu 24.04;request_serializerfails when the reader skips the constants.be32749fa9: mergedmain959d9cbb99. Main's #14561 took serialization version 63, so its new single-sample dither test expects 64 and treats 64 as valid; the version-62 fixture checks that no non-zero-mask merge (and so no blend constant) is present before relabelling.request_serializer,agc_driver_packed_float_blendand the 56agc_driver_graphicstests pass on Windows 11; the 54agc_shader_*tests pass on WSL Ubuntu 24.04. Conventions pass.b5a13ae813: mergedmain6f6f6c8e6b. Main took serialization version 64 for the split state, which merged with no conflict but would have read main's version 64 requests as holding blend constants. The constants are now read from version 65 on, and a new check decodes a version 64 merge without them. A planted bug reading them from 64 failsrequest_serializer.request_serializer,agc_driver_packed_float_blend, theagc_driver_graphicstests and theagc_shader_*tests (74 in all) pass on Windows 11. Conventions pass.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)Note: main now writes version 64 (split state) and rejects 58-61; this PR writes 65, as does #19821 (mine). #15343, #14561 and #9508 also change the request serialization; whichever lands second renumbers, and I will do that here if this one is second. #9748 rewrites the same
PackedBlendControlfactor check for 10_11_11 unorm targets and keeps the constant factors throwing; the two changes conflict on those lines only. Merge previews are clean with the other 127 open PRs that touch these files and merge cleanly withmain.Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T11:54:10Z.
Review: COMMENTED
Reviewed — no blocking findings
The implementation and changed-line context support the described blend-factor path, but I did not run the reported checks or verify behavior on a PS5.
What I ran
Reviewed head
775fee3c3a4ed1f73289ace8eb99528f4bf6e286using the prepared diff andrepo_read.pyfor targeted source ranges. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
Not verified
I did not run the author-reported tests, validation layer, or convention check. I did not verify Windows results, other GPUs, Linux, or physical-console behavior. The PR description reports these checks and notes that no title exercising this path was run. I read the added lines for all 12 changed files, including targeted ranges from the two files excluded from the prepared full-text bundle.
To get this to a good state
Nothing is required. Optional: compare a constant-factor blend against a console capture to resolve the documented precision and component-mapping uncertainty.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T08:31:30Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected implementation and reported checks support merging.
What I ran
Reviewed head
3634b00ab9f268fa5b379676c5c4e77621f60cbc. No commands or tests were run in this review; reported test results below are from the PR description.Read
description.md,commits.md,manifest.json, anddiff.patch. Read changed source filesDrawLookup.cpp,State.cpp,PackedFloatBlend.cpp,CacheKey.hpp,RequestSerializer.cpp,Recompiler.cpp,Recompiler.hpp,SpirvModuleEmitter.cpp, andRequestSerializerTests.cpp. Read targeted context inState.cppandSpirvModuleEmitter.cpp. The changed test filesGraphics.cppandShaderMemory.cppwere not read;files.jsonwas unavailable.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
Graphics.cppandShaderMemory.cppwas not read, and tests were not run independently. The PR reports focused tests passing on the stated Windows and WSL environments; those results are author-reported. Console precision and which blend constant field reaches each output channel remain unmeasured, as acknowledged in the changed debt entry.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T13:26:31Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: serialize blend constants for every target merge so deserialization reads the same sequence.
What I ran
Inspected the prepared diff and the pinned head
3c2f58e26377d379f5c547fd96ebff5b90486d08using the review reader. No tests were run.Results
Findings
Blocking
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp:976skips blend constants for merges whose mask is zero, but the version 64 deserializer reads four words for every target merge (core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp:1066-1068). A pixel request containing a zero-mask merge will therefore serialize fewer words than the decoder expects, causing it to consume following data as constants or fail decoding. Keep the serialized and deserialized merge iteration conditions consistent.Non-blocking
None.
Not verified
No tests were run. The full text of
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded as too large for the review folder; the changed hunks were visible in the prepared diff but were not read through the reader. Other changed files were not read in full; the findings are based on the cited changed lines and inspected serializer implementation.To get this to a good state
Serialize four blend constant words for every target merge, matching the deserializer, then run the request serializer and affected graphics tests.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T20:56:35Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix version 64 merge-constant alignment so serialized requests with target merges round-trip correctly.
What I ran
Reviewed head
b450a8d68cd0a45edecfcc68268ded2e47eec4fbusingrepo_read.pyagainst the prepared diff and pinned repository files. No test commands were run; results reported in the PR description are author-reported.Results
Findings
Blocking
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp:977Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp, whose full text was excluded as too large. Their relevant changed regions were read through the pinned reader.dist/,build/, and.svgfiles; their contents were not reviewed.To get this to a good state
Fix the version 64 serialization/deserialization alignment and rerun the request serializer tests, including empty and nonempty merge lists.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T22:15:36Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed the prepared diff for head
289ffb3c293dca220fb7ed1d1d2657074fde9043and inspected targeted source ranges throughrepo_read.py. No tests or build commands were run.Results
Findings
Blocking
None.
Non-blocking
Graphics.cppandShaderMemory.cppwas excluded from the review bundle; only relevant ranges were inspected. Consider ensuring those tests run on the final head.Not verified
No tests or build were run. Full-file review was not completed for
Graphics.cppandShaderMemory.cpp; other changed files were inspected only in the targeted ranges needed for this review. The PR description reports platform and hardware runs, but those results were not independently verified.To get this to a good state
Nothing is required. The optional point above is to ensure the excluded test files’ coverage runs on the final head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T10:41:33Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the code reviewed; the author-reported checks were not run in this review.
What I ran
Reviewed head
be32749fa9be737dc7c179a89ef1a2ce7a922beeusingrepo_read.pyto read the prepared diff and targeted source ranges. No build or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The test files
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere read only in targeted changed ranges; their full contents were not reviewed. No tests were run. The PR description notes that console behavior, gfx1013, and non-Windows environments were not verified. All changed files listed in the manifest were inspected through the diff; source review covered the changed implementation files and targeted test ranges.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T15:57:30Z.
Review: COMMENTED
Actionable comments posted: 1
38bf1dac-574d-4dfb-874a-5ba90543b804Reviewing files that changed from the base of the PR and between
6f6f6c8e6bandb5a13ae813.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/execution/PackedFloatBlend.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/ControlFlow/src/RequestSerializer.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppcore/shader/recompiler/tests/RequestSerializerTests.cppdocs/dev/debt/libSceAgcDriver.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T16:01:17Z.
Review: COMMENTED
Reviewed — comments
Changes are required before merge: resolve the per-channel blend constant ordering for 11_11_10 targets.
What I ran
Reviewed head
b5a13ae81338b57a259a66bb6b0a024d83e32012using the prepared description, manifest, diff, and repository readerrepo_read.py. No commands or tests were run by me; reported test results below are from the PR description.Results
Findings
Blocking
None verified.
Non-blocking
State::blendConstantsis copied as a fixed four-element array, while the description says the order is already transformed for host blend constants. The new shader selects each channel's constant using the export component index (core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:2373,core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp:611). The tested standard swap checks only a singleCONSTANT_COLORblend, and the runtime cases use matching channels; I could not confirm from the inspected source that reversed component mapping selects the constant associated with the channel stored in each field. Please add a case with distinct constants and reversed mapping, or document/verify why the current index is correct.Not verified
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp; targeted changed ranges were inspected through the reader. No claim is made about their uninspected portions.files.json, which was unavailable through the repository reader. The manifest lists 11 changed files, all marked included except those two test files.To get this to a good state
Nothing is required; the point above is optional.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:29:10Z.
Review: COMMENTED
I compiled the exact request serializers for this PR and #19821. Both write version 65 and can read their own pixel captures. The blend reader rejected the point-sprite capture with
emulated barycentrics without a graphics context. The point-sprite reader rejected the blend capture as truncated. The blend reader also rejected the #22251 version 65 tessellation capture. Please reconcile version assignments before these formats are used for saved requests.The trial merge onto
c1601e56d5was clean. These were native format tests. Paired graphics execution is pending.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.