summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.cpp
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2024-04-20 01:35:31 -0500
committeriwubcode <iwubcode@users.noreply.github.com>2024-04-28 18:15:27 -0500
commit9d28c371e71586bbbf88a401cb3a160a9f139842 (patch)
tree8f542cd72d13f33e8ca523925ee5f4381a0e59b5 /Source/Core/VideoCommon/PixelShaderGen.cpp
parentefed26ceee6d5a31f8ef4f173cfb55dc2c70347c (diff)
VideoCommon: allow custom shaders to set the alpha value for use when blending is enabled
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp40
1 files changed, 16 insertions, 24 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index bf574b8fda..b5090b362b 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -1315,16 +1315,6 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
WriteFog(out, uid_data);
- 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
- const bool use_dual_source = !uid_data->no_dual_src || uid_data->blend_enable;
- WriteColor(out, api_type, uid_data, use_dual_source);
-
for (std::size_t i = 0; i < custom_details.shaders.size(); i++)
{
const auto& shader_details = custom_details.shaders[i];
@@ -1332,24 +1322,26 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
if (!shader_details.custom_shader.empty())
{
out.Write("\t{{\n");
- if (uid_data->uint_output)
- {
- out.Write("\t\tcustom_data.final_color = float4(ocol0.x / 255.0, ocol0.y / 255.0, ocol0.z "
- "/ 255.0, ocol0.w / 255.0);\n");
- out.Write("\t\tfloat3 custom_output = {}_{}(custom_data).xyz;\n",
- CUSTOM_PIXELSHADER_COLOR_FUNC, i);
- out.Write("\t\tocol0.xyz = uint3(custom_output.x * 255, custom_output.y * 255, "
- "custom_output.z * 255);\n");
- }
- else
- {
- out.Write("\t\tcustom_data.final_color = ocol0;\n");
- out.Write("\t\tocol0.xyz = {}_{}(custom_data).xyz;\n", CUSTOM_PIXELSHADER_COLOR_FUNC, i);
- }
+ out.Write("\t\tcustom_data.final_color = float4(prev.r / 255.0, prev.g / 255.0, prev.b "
+ "/ 255.0, prev.a / 255.0);\n");
+ out.Write("\t\tCustomShaderOutput custom_output = {}_{}(custom_data);\n",
+ CUSTOM_PIXELSHADER_COLOR_FUNC, i);
+ out.Write("\t\tprev = int4(custom_output.main_rt.r * 255, custom_output.main_rt.g * 255, "
+ "custom_output.main_rt.b * 255, custom_output.main_rt.a * 255);\n");
out.Write("\t}}\n\n");
}
}
+ 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
+ const bool use_dual_source = !uid_data->no_dual_src || uid_data->blend_enable;
+ WriteColor(out, api_type, uid_data, use_dual_source);
+
if (uid_data->blend_enable)
WriteBlend(out, uid_data);
else if (use_framebuffer_fetch)