Skip to content

video_core: Emulate scaled min/max blending - #4768

Open
meh7an wants to merge 3 commits into
shadps4-emu:mainfrom
meh7an:fix/minmax-blend-factors
Open

video_core: Emulate scaled min/max blending#4768
meh7an wants to merge 3 commits into
shadps4-emu:mainfrom
meh7an:fix/minmax-blend-factors

Conversation

@meh7an

@meh7an meh7an commented Jul 29, 2026

Copy link
Copy Markdown

The problem

On GCN the color blender applies blend factors to min/max operations; Vulkan ignores them by spec. A pipeline blending MIN/MAX with src_factor=SRC_COLOR, dst_factor=DST_COLOR expects min/max(src*src, dst*dst) — squared-domain accumulation — but gets plain min/max(src, dst). This is the case the existing "Unimplemented use of min/max blend op with blend factor not equal to one" warning points at. God of War 3 Remastered builds its screen-space light/shadow accumulation with exactly this state, washing out environment materials and leaving its stochastic shadow dither unresolved on screen.

The fix

Flag the pattern in the graphics pipeline key; the fragment shader squares its RGB output for that attachment at export and the Vulkan blend factors are forced to ONE, so fixed-function min/max produces exactly min/max(src^2, dst^2) like the hardware does. Clear values 0 and 1 are fixed points of the transform, so the attachment stays coherent end to end. Pipelines without this blend state are unaffected.

@raphaelthegreat

Copy link
Copy Markdown
Contributor

The scaled min/max blending thing I would consider as an acceptable workaround for now since full min/max blending emulation is cumbersome. However the readback thing is a hack and not that clean. The real issue that needs solving is having texture cache properly validate rendering a subrect of an image with same pitch

@meh7an meh7an changed the title video_core: Emulate scaled min/max blending and small target readbacks video_core: Emulate scaled min/max blending Jul 29, 2026
@meh7an
meh7an force-pushed the fix/minmax-blend-factors branch from 39a0f5d to 623aabc Compare July 29, 2026 05:21
@meh7an
meh7an marked this pull request as draft July 29, 2026 05:35
@meh7an
meh7an force-pushed the fix/minmax-blend-factors branch from 91bad68 to 623aabc Compare July 29, 2026 06:13
@meh7an
meh7an marked this pull request as ready for review July 29, 2026 06:17
color_buffer.swizzle = col_buf.Swizzle();

const auto& bc = regs.blend_control[cb];
color_buffer.blend_self_scale =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is true add a warning log so it can be known when this emulation triggers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants