mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 20:28:56 +00:00
VideoCommon: Better logic op invert approximation
This commit is contained in:
parent
d380d43209
commit
600ad5f498
6 changed files with 139 additions and 33 deletions
|
@ -744,6 +744,7 @@ static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_dat
|
|||
bool per_pixel_depth, bool use_dual_source);
|
||||
static void WriteFog(ShaderCode& out, const pixel_shader_uid_data* uid_data);
|
||||
static void WriteLogicOp(ShaderCode& out, const pixel_shader_uid_data* uid_data);
|
||||
static void WriteLogicOpBlend(ShaderCode& out, const pixel_shader_uid_data* uid_data);
|
||||
static void WriteColor(ShaderCode& out, APIType api_type, const pixel_shader_uid_data* uid_data,
|
||||
bool use_dual_source);
|
||||
static void WriteBlend(ShaderCode& out, const pixel_shader_uid_data* uid_data);
|
||||
|
@ -1148,6 +1149,8 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
|
|||
|
||||
if (uid_data->logic_op_enable)
|
||||
WriteLogicOp(out, uid_data);
|
||||
else if (uid_data->emulate_logic_op_with_blend)
|
||||
WriteLogicOpBlend(out, uid_data);
|
||||
|
||||
// Write the color and alpha values to the framebuffer
|
||||
// If using shader blend, we still use the separate alpha
|
||||
|
@ -1803,6 +1806,29 @@ static void WriteLogicOp(ShaderCode& out, const pixel_shader_uid_data* uid_data)
|
|||
out.Write("\tprev = ({}) & 0xff;\n", logic_op_mode[uid_data->logic_op_mode]);
|
||||
}
|
||||
|
||||
static void WriteLogicOpBlend(ShaderCode& out, const pixel_shader_uid_data* uid_data)
|
||||
{
|
||||
switch (static_cast<LogicOp>(uid_data->logic_op_mode))
|
||||
{
|
||||
case LogicOp::Clear:
|
||||
case LogicOp::NoOp:
|
||||
out.Write("\tprev = int4(0, 0, 0, 0);\n");
|
||||
break;
|
||||
case LogicOp::Copy:
|
||||
// Do nothing!
|
||||
break;
|
||||
case LogicOp::CopyInverted:
|
||||
out.Write("\tprev ^= 255;\n");
|
||||
break;
|
||||
case LogicOp::Set:
|
||||
case LogicOp::Invert: // In cooperation with blend
|
||||
out.Write("\tprev = int4(255, 255, 255, 255);\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteColor(ShaderCode& out, APIType api_type, const pixel_shader_uid_data* uid_data,
|
||||
bool use_dual_source)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue