mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
VideoCommon: Make dst_alpha state implicit.
This commit is contained in:
@ -156,13 +156,15 @@ static const char* tevAOutputTable[] = {"prev.a", "c0.a", "c1.a", "c2.a"};
|
||||
// leak
|
||||
// into this UID; This is really unhelpful if these UIDs ever move from one machine to
|
||||
// another.
|
||||
PixelShaderUid GetPixelShaderUid(DSTALPHA_MODE dstAlphaMode)
|
||||
PixelShaderUid GetPixelShaderUid()
|
||||
{
|
||||
PixelShaderUid out;
|
||||
pixel_shader_uid_data* uid_data = out.GetUidData<pixel_shader_uid_data>();
|
||||
memset(uid_data, 0, sizeof(*uid_data));
|
||||
|
||||
uid_data->dstAlphaMode = dstAlphaMode;
|
||||
uid_data->useDstAlpha = bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate &&
|
||||
bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
|
||||
|
||||
uid_data->genMode_numindstages = bpmem.genMode.numindstages;
|
||||
uid_data->genMode_numtevstages = bpmem.genMode.numtevstages;
|
||||
uid_data->genMode_numtexgens = bpmem.genMode.numtexgens;
|
||||
@ -327,13 +329,9 @@ PixelShaderUid GetPixelShaderUid(DSTALPHA_MODE dstAlphaMode)
|
||||
uid_data->ztex_op = bpmem.ztex2.op;
|
||||
uid_data->early_ztest = bpmem.UseEarlyDepthTest();
|
||||
uid_data->fog_fsel = bpmem.fog.c_proj_fsel.fsel;
|
||||
|
||||
if (dstAlphaMode != DSTALPHA_ALPHA_PASS)
|
||||
{
|
||||
uid_data->fog_fsel = bpmem.fog.c_proj_fsel.fsel;
|
||||
uid_data->fog_proj = bpmem.fog.c_proj_fsel.proj;
|
||||
uid_data->fog_RangeBaseEnabled = bpmem.fogRange.Base.Enabled;
|
||||
}
|
||||
uid_data->fog_fsel = bpmem.fog.c_proj_fsel.fsel;
|
||||
uid_data->fog_proj = bpmem.fog.c_proj_fsel.proj;
|
||||
uid_data->fog_RangeBaseEnabled = bpmem.fogRange.Base.Enabled;
|
||||
|
||||
return out;
|
||||
}
|
||||
@ -510,7 +508,7 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const pixel_shader_uid_data*
|
||||
const bool use_dual_source =
|
||||
g_ActiveConfig.backend_info.bSupportsDualSourceBlend &&
|
||||
(!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_DUAL_SOURCE_BLENDING) ||
|
||||
uid_data->dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND);
|
||||
uid_data->useDstAlpha);
|
||||
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
{
|
||||
@ -795,8 +793,7 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const pixel_shader_uid_data*
|
||||
out.Write("\tprev.rgb = (prev.rgb - (prev.rgb >> 6)) + abs(dither.y * 3 - dither.x * 2);\n");
|
||||
}
|
||||
|
||||
if (uid_data->dstAlphaMode != DSTALPHA_ALPHA_PASS)
|
||||
WriteFog(out, uid_data);
|
||||
WriteFog(out, uid_data);
|
||||
|
||||
// Write the color and alpha values to the framebuffer
|
||||
WriteColor(out, uid_data, use_dual_source);
|
||||
@ -1308,7 +1305,7 @@ static void WriteColor(ShaderCode& out, const pixel_shader_uid_data* uid_data, b
|
||||
|
||||
// Colors will be blended against the 8-bit alpha from ocol1 and
|
||||
// the 6-bit alpha from ocol0 will be written to the framebuffer
|
||||
if (uid_data->dstAlphaMode == DSTALPHA_NONE)
|
||||
if (!uid_data->useDstAlpha)
|
||||
{
|
||||
out.Write("\tocol0.a = float(prev.a >> 2) / 63.0;\n");
|
||||
if (use_dual_source)
|
||||
@ -1322,7 +1319,7 @@ static void WriteColor(ShaderCode& out, const pixel_shader_uid_data* uid_data, b
|
||||
// Use dual-source color blending to perform dst alpha in a single pass
|
||||
if (use_dual_source)
|
||||
{
|
||||
if (uid_data->dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
|
||||
if (uid_data->useDstAlpha)
|
||||
out.Write("\tocol1.a = float(prev.a) / 255.0;\n");
|
||||
else
|
||||
out.Write("\tocol1.a = float(" I_ALPHA ".a) / 255.0;\n");
|
||||
|
Reference in New Issue
Block a user