Skip to content

Commit

Permalink
VideoCommon: allow custom shaders to set the alpha value for use when…
Browse files Browse the repository at this point in the history
… blending is enabled
  • Loading branch information
iwubcode committed Apr 20, 2024
1 parent 0e7346a commit 1ea2381
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
20 changes: 13 additions & 7 deletions Source/Core/VideoCommon/PixelShaderGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,17 +1334,23 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
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");
out.Write("\t\tcustom_data.final_color = float4(ocol0.r / 255.0, ocol0.g / 255.0, ocol0.b "
"/ 255.0, ocol0.a / 255.0);\n");
out.Write("\t\tfloat4 custom_output = {}_{}(custom_data);\n", CUSTOM_PIXELSHADER_COLOR_FUNC,
i);
out.Write("\t\tocol0 = uint4(custom_output.r * 255, custom_output.g * 255, "
"custom_output.b * 255, custom_output.a * 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\tocol0 = {}_{}(custom_data);\n", CUSTOM_PIXELSHADER_COLOR_FUNC, i);

if (use_dual_source)
{
out.Write("\t\tocol1.a = ocol0.a;\n");
out.Write("\t\tocol0.a = 1.0;\n");
}
}
out.Write("\t}}\n\n");
}
Expand Down
20 changes: 13 additions & 7 deletions Source/Core/VideoCommon/UberShaderPixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1603,17 +1603,23 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
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");
out.Write("\t\tcustom_data.final_color = float4(ocol0.r / 255.0, ocol0.g / 255.0, ocol0.b "
"/ 255.0, ocol0.a / 255.0);\n");
out.Write("\t\tfloat3 custom_output = {}_{}(custom_data);\n", CUSTOM_PIXELSHADER_COLOR_FUNC,
i);
out.Write("\t\tocol0 = uint4(custom_output.r * 255, custom_output.g * 255, "
"custom_output.b * 255, custom_output.a * 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\tocol0 = {}_{}(custom_data);\n", CUSTOM_PIXELSHADER_COLOR_FUNC, i);

if (use_dual_source || use_framebuffer_fetch)
{
out.Write("\t\tocol1.a = ocol0.a;\n");
out.Write("\t\tocol0.a = 1.0;\n");
}
}
out.Write("\t}}\n\n");
}
Expand Down

0 comments on commit 1ea2381

Please sign in to comment.