feat(agc): apply the color logic operation of CB_COLOR_CONTROL #9348
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9348"
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 klosixgaming-arch on 2026-10-21T19:04:37Z.
What
CB_COLOR_CONTROLcarries a ROP3 code in bits 16 to 23. The driver accepted only the copy code (0xcc) and threw for every other one, so a draw that asks for a color logic operation stopped the process. The code is now decoded into the draw state (State::colorRop), keyed in the pipeline cache key and in the pipeline journal, and applied through the Vulkan logic operation of the color blend state. The device enables thelogicOpfeature when it has it.Cyberpunk 2077 (PPSA03974) stops with this about 31 minutes into a session, after character creation:
AGC graphics: only normal color rendering with copy ROP is supported (CB_COLOR_CONTROL 0x005a0010, mode normal)ROP3 0x5a with mode normal.
Reading of the code:
CB_COLOR_CONTROL.ROP3takes 28 codes, in two forms: source and destination (pqrspqrs, 0xcc is copy) or brush and destination (pqpqrsrs, the brush is the shader color), as the R6xx 3D register reference describes the field and Mesa'sROP3enum lists (both quoted by wachi35676 in this PR; I could not open them myself). In both forms bits 7:6 and 1:0 hold the same function, soLogicOpFromRopreads bits 0, 1, 6 and 7. That makes 0xcc copy, 0x66 and 0x5a XOR, 0x88 and 0xa0 AND, 0xee and 0xfa OR.Throws rather than guessing:
logicOpfeatureThe pipeline journal file format moves from 6 to 7 because the state it stores gains a field. #8365 and #8542 change the line that holds that constant, so whichever of them merges second needs a trivial rebase.
Tested
Windows 11 (10.0.26200), NVIDIA GeForce RTX 5090, driver 617.42, WinLibs GCC 15.2.0, Release, on
maina6646f846. Vulkan validation layer 1.4.363 (VK_LAYER_KHRONOS_validation, inserted for the instance in the run),ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1.agc_driver_color_logic_op(tests/execution/ColorLogicOp.cpp): fills a 64x16 R8G8B8A8 target with a byte pattern, draws a covering triangle that exports (0.2, 0.4, 0.6, 0.8) (bytes 0x33, 0x66, 0x99, 0xcc) with ROP 0xcc, 0x5a, 0x88, 0xee and 0xcc again, and checks every byte against copy, XOR, AND, OR and copy. Passes. It skips on a device withoutlogicOp.agc_driver_graphics: new decode cases (0x5a0010 decodes tocolorRop0x5a andVK_LOGIC_OP_XOR, the copy code decodes as copy, fourteen ROP3 codes map to the expected operation, exactly 28 of the 256 codes are accepted, 0x5b is refused, a logic operation with blending throws). Passes. The existing check thatCB_COLOR_CONTROL0xcc0013 is refused with "copy ROP" still passes.agc_driver_color1555_target,agc_driver_packed_unorm_color_target,agc_driver_dual_source_blend,agc_driver_reversed_order_blend. All pass.agc_driver_graphics,agc_driver_color_logic_op,agc_driver_color1555_targetandagc_driver_dual_source_blendproduced 0VUID-.mainthe new tests cannot be built becauseState::colorRopdoes not exist. Whatmaindoes with the draw is the message above, taken from the game log.agc_pipeline_journal,agc_pipeline_journal_long_pathsandagc_pipeline_journal_extended_paths(journal format 7): pass.python tools/check_conventions.py --base origin/main: passed.I have not run the game on this build yet, so I do not claim it gets past the stop in the title or that the XOR output looks right there; the tests show the logic operation is applied to the target bytes as specified.
Checklist
main; no other open PR implements the same functions (the overlap check lists file overlaps only).mdfiles or images added to the repositoryAI-assisted: yes. Written with AI assistance and reviewed by me.
Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-21T22:59:30Z.
AMD run and a source for the ROP3 reading. Head
b142ad1fmerged onto maina6dcea927(clean merge,9cf202581).Host: Windows 11 (10.0.26300), Ryzen 5 9600X, WinLibs GCC 15.2.0, Release. GPUs: NVIDIA RTX 5070 Ti (617.42) and AMD Radeon RDNA2 iGPU
1002:13c0(proprietary 32.0.21042.62,ANYPS5_GPU=AMD).ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, no validation layer.agc_driver_color_logic_oppasses on both GPUs, with GPL and withAPS5_NO_GPL=1. The AMD device exposeslogicOp, so the test runs on AMD rather than skipping.blend.logicOpEnable = VK_TRUEchanged toVK_FALSEinPipeline.cpp, the test fails on both GPUs withROP3 0x5a into an 8_8_8_8 unorm target: pixel (0, 0) channel 0 is 51, expected 56. 51 is the copied source byte 0x33.agc_driver_graphics*, the color-target, blend and pipeline-journal tests includingagc_pipeline_journal*after the format 6→7 bump, mesh, indirect and others): the results match main on both GPUs. The only failures are main's existing local ones (image_array_window_past_layer_limitdoes not build under MinGW;agc_driver_tessellationfails on AMD).tools/check_conventions.py --base a6dcea927passes.On the reading of the code ("no register documentation confirms the pattern operand is the source color"):
docs/AMD/old/R6xx_3D_Registers.pdf),CB_COLOR_CONTROL.ROP3[23:16], says: "This field supports the 28 boolean ops that combine either source and dest or brush and dest, with brush provided by the shader in place of source. ROP3 codes that use both src and brush are emulated in software. Allowed ROP3 codes have either the form pqrspqrs (for source/dest ops) or pqpqrsrs (for brush/dest ops). The code 0xCC (11001100) copies the source to the destination". 0x5a (01011010) has the brush/dest form, so it is brush XOR dest, and the brush is the shader color.src/amd/registers/gfx10.jsonROP3enum has exactly those 28 values: 16 named source/dest codes (0x66 XOR, 0x88 AND, …) and 12X_0X..codes (0x05, 0x0a, 0x0f, 0x50, 0x5a, 0x5f, 0xa0, 0xa5, 0xaf, 0xf0, 0xf5, 0xfa), which are the brush/dest functions. radeonsi writesfunc | func << 4(si_state.c) and RADV writes theV_028808_ROP3_*values.LogicOpFromRop's index from bits 0, 1, 6 and 7 gives the sameVkLogicOpwhether the code is the source or the brush form. The table also matches Mesa'sPIPE_LOGICOPorder. The debt line could cite this instead of saying no documentation exists. A code that uses both src and brush (outside both forms) is "emulated in software" on the console. The PR maps such codes as if brush were source. Throwing on codes outside the two forms might be safer.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:11:38Z.
Review: APPROVED
Reviewed exact head
191dddae77. The ROP3 decoding is confined to the documented source/brush forms; pipeline state, cache key, register decode key, and journal codec all include the operation, and unsupported blend/format/device combinations fail explicitly. The added tests exercise the logic-op byte results, code mapping/refusal, and journal format; the PR reports zero Vulkan validation VUIDs on the listed Windows/NVIDIA runs. Local diff check, conventions, and test-registration checks pass. I could not run the AGC executable in this host: the available older AnyPS5 test binary aborts before startup because this CPU lacks required x86 extensions. The PR reports the new tests cannot be built on main becauseState::colorRopis absent there; hosted product jobs are skipped. The Cyberpunk title behavior remains unverified, as the PR states.