Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PixelShaderGen: only use dual-source if bpmem requires dual-src blending #6219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ void SHADER::SetProgramBindings(bool is_compute)
// So we do support extended blending
// So we need to set a few more things here.
// Bind our out locations
// Note: on macOS, this can cause graphical issues if ocol1 exists in the fragment shader but
// we're not actually doing dual-source blending.
glBindFragDataLocationIndexed(glprogid, 0, 0, "ocol0");
glBindFragDataLocationIndexed(glprogid, 0, 1, "ocol1");
}
Expand Down
8 changes: 7 additions & 1 deletion Source/Core/VideoCommon/PixelShaderGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "VideoCommon/DriverDetails.h"
#include "VideoCommon/LightingShaderGen.h"
#include "VideoCommon/NativeVertexFormat.h"
#include "VideoCommon/RenderState.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h"
Expand Down Expand Up @@ -177,6 +178,11 @@ PixelShaderUid GetPixelShaderUid()
uid_data->dither = bpmem.blendmode.dither && uid_data->rgba6_format;
uid_data->uint_output = bpmem.blendmode.UseLogicOp();

BlendingState state{};
state.Generate(bpmem);
uid_data->blendEnable = state.blendenable;
uid_data->useDualSource = state.usedualsrc;

u32 numStages = uid_data->genMode_numtevstages + 1;

const bool forced_early_z =
Expand Down Expand Up @@ -516,7 +522,7 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const ShaderHostConfig& host

// Only use dual-source blending when required on drivers that don't support it very well.
const bool use_dual_source =
host_config.backend_dual_source_blend &&
uid_data->blendEnable && uid_data->useDualSource && host_config.backend_dual_source_blend &&
(!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_DUAL_SOURCE_BLENDING) ||
uid_data->useDstAlpha);

Expand Down
4 changes: 3 additions & 1 deletion Source/Core/VideoCommon/PixelShaderGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ struct pixel_shader_uid_data
u32 rgba6_format : 1;
u32 dither : 1;
u32 uint_output : 1;
u32 pad : 15;
u32 blendEnable : 1;
u32 useDualSource : 1;
u32 pad : 13;

u32 texMtxInfo_n_projection : 8; // 8x1 bit
u32 tevindref_bi0 : 3;
Expand Down