diff options
| author | JMC47 <JMC4789@gmail.com> | 2024-06-11 21:13:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-11 21:13:24 -0400 |
| commit | 16c7869ab27852b4c9289355cb42ca1b5b8bfbf2 (patch) | |
| tree | d9ba4cb43237f8f9c62021f321a50004c2103ed4 /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | 04c246d11f60719d20af67c230cfe0a866dcaf54 (diff) | |
| parent | 9d28c371e71586bbbf88a401cb3a160a9f139842 (diff) | |
Merge pull request #12721 from iwubcode/custom_shader_alpha
VideoCommon: allow custom shaders to set the alpha value
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index de57501aad..a76681634f 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) |
