VideoCommon: Better logic op invert approximation

This commit is contained in:
TellowKrinkle
2022-07-13 03:56:33 -05:00
parent d380d43209
commit 600ad5f498
6 changed files with 139 additions and 33 deletions

View File

@ -1092,6 +1092,26 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
" TevResult &= 0xff;\n"
" }}\n");
}
else if (!host_config.backend_logic_op)
{
out.Write(" // Helpers for logic op blending approximations\n"
" if (logic_op_enable) {{\n"
" switch (logic_op_mode) {{\n");
out.Write(" case {}: // Clear\n", static_cast<u32>(LogicOp::Clear));
out.Write(" TevResult = int4(0, 0, 0, 0);\n"
" break;\n");
out.Write(" case {}: // Copy Inverted\n", static_cast<u32>(LogicOp::CopyInverted));
out.Write(" TevResult ^= 0xff;\n"
" break;\n");
out.Write(" case {}: // Set\n", static_cast<u32>(LogicOp::Set));
out.Write(" case {}: // Invert\n", static_cast<u32>(LogicOp::Invert));
out.Write(" TevResult = int4(255, 255, 255, 255);\n"
" break;\n");
out.Write(" default:\n"
" break;\n"
" }}\n"
" }}\n");
}
// Some backends require that the shader outputs be uint when writing to a uint render target for
// logic op.