mirror of https://github.com/PCSX2/pcsx2.git
GS/HW: Implement dithering on blend second pass on some formulas.
Alpha = As or Af Cs + Cd*Alpha, Cs - Cd*Alpha.
This commit is contained in:
parent
8f57d8afe0
commit
df6a33ef7c
|
@ -701,6 +701,7 @@ struct alignas(16) GSHWDrawConfig
|
|||
{
|
||||
BlendState blend;
|
||||
u8 blend_hw;
|
||||
u8 dither;
|
||||
bool enable;
|
||||
};
|
||||
static_assert(sizeof(BlendPass) == 8, "blend pass is 8 bytes");
|
||||
|
|
|
@ -2627,6 +2627,7 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config)
|
|||
if (config.blend_second_pass.enable)
|
||||
{
|
||||
config.ps.blend_hw = config.blend_second_pass.blend_hw;
|
||||
config.ps.dither = config.blend_second_pass.dither;
|
||||
SetupPS(config.ps, &config.cb_ps, config.sampler);
|
||||
SetupOM(config.depth, OMBlendSelector(config.colormask, config.blend_second_pass.blend), config.blend_second_pass.blend.constant);
|
||||
DrawIndexedPrimitive();
|
||||
|
|
|
@ -3950,6 +3950,7 @@ void GSDevice12::RenderHW(GSHWDrawConfig& config)
|
|||
|
||||
pipe.bs = config.blend_second_pass.blend;
|
||||
pipe.ps.blend_hw = config.blend_second_pass.blend_hw;
|
||||
pipe.ps.dither = config.blend_second_pass.dither;
|
||||
if (BindDrawPipeline(pipe))
|
||||
DrawIndexedPrimitive();
|
||||
}
|
||||
|
|
|
@ -4443,14 +4443,17 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, bool& DAT
|
|||
{
|
||||
// Alpha = As or Af.
|
||||
// Cs + Cd*Alpha, Cs - Cd*Alpha.
|
||||
const u8 dither = m_conf.ps.dither;
|
||||
// Render pass 1: Calculate Cd*Alpha with an alpha range of 0-2.
|
||||
m_conf.ps.blend_hw = 2;
|
||||
m_conf.ps.dither = 0;
|
||||
blend.src = GSDevice::DST_COLOR;
|
||||
blend.dst = (m_conf.ps.blend_c == 2) ? GSDevice::CONST_COLOR : GSDevice::SRC1_COLOR;
|
||||
blend.op = GSDevice::OP_ADD;
|
||||
// Render pass 2: Add or subtract result of render pass 1(Cd) from Cs.
|
||||
m_conf.blend_second_pass.enable = true;
|
||||
m_conf.blend_second_pass.blend_hw = 0;
|
||||
m_conf.blend_second_pass.dither = dither;
|
||||
m_conf.blend_second_pass.blend = {true, blend_second_pass.src, GSDevice::CONST_ONE, blend_second_pass.op, GSDevice::CONST_ONE, GSDevice::CONST_ZERO, false, 0};
|
||||
}
|
||||
else if (alpha_c1_high_no_rta_correct && (blend_flag & BLEND_HW5))
|
||||
|
|
|
@ -2587,6 +2587,7 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config)
|
|||
OMSetBlendState();
|
||||
}
|
||||
psel.ps.blend_hw = config.blend_second_pass.blend_hw;
|
||||
psel.ps.dither = config.blend_second_pass.dither;
|
||||
SetupPipeline(psel);
|
||||
SendHWDraw(config, psel.ps.IsFeedbackLoop());
|
||||
}
|
||||
|
|
|
@ -5844,6 +5844,7 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config)
|
|||
|
||||
pipe.bs = config.blend_second_pass.blend;
|
||||
pipe.ps.blend_hw = config.blend_second_pass.blend_hw;
|
||||
pipe.ps.dither = config.blend_second_pass.dither;
|
||||
if (BindDrawPipeline(pipe))
|
||||
DrawIndexedPrimitive();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue