Skip to content

Commit

Permalink
GSdx: AMD Legacy SSO workaround.
Browse files Browse the repository at this point in the history
Add dual source blending workaround for legacy drivers.

Idea is to keep two separate workarounds. The current workaround on
master doesn't play well with the catalyst drivers. Display is white or
flickers white.
  • Loading branch information
lightningterror committed Jun 11, 2018
1 parent 6bd5afe commit 9f52a08
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
21 changes: 9 additions & 12 deletions plugins/GSdx/GLLoader.cpp
Expand Up @@ -342,18 +342,15 @@ namespace GLLoader {
// Name changed but driver is still bad!
if (strstr(vendor, "Advanced Micro Devices") || strstr(vendor, "ATI Technologies Inc.") || strstr(vendor, "ATI"))
vendor_id_amd = true;
/*if (vendor_id_amd && (
strstr((const char*)&s[v], " 10.") || // Blacklist all 2010 AMD drivers.
strstr((const char*)&s[v], " 11.") || // Blacklist all 2011 AMD drivers.
strstr((const char*)&s[v], " 12.") || // Blacklist all 2012 AMD drivers.
strstr((const char*)&s[v], " 13.") || // Blacklist all 2013 AMD drivers.
strstr((const char*)&s[v], " 14.") || // Blacklist all 2014 AMD drivers.
strstr((const char*)&s[v], " 15.") || // Blacklist all 2015 AMD drivers.
strstr((const char*)&s[v], " 16.") || // Blacklist all 2016 AMD drivers.
strstr((const char*)&s[v], " 17.") // Blacklist all 2017 AMD drivers for now.
))
if (vendor_id_amd && (
// Idea is to also have a working 2015 legacy driver so while we are at it why not blacklist older versions just in case.
// This should affect only Catalyst drivers.
strstr((const char*)&s[v], "atiumdag") ||
strstr((const char*)&s[v], "14.") ||
strstr((const char*)&s[v], "15.")))

amd_legacy_buggy_driver = true;
*/

if (strstr(vendor, "NVIDIA Corporation"))
vendor_id_nvidia = true;

Expand All @@ -365,7 +362,7 @@ namespace GLLoader {
mesa_driver = !vendor_id_nvidia && !vendor_id_amd;
#endif

buggy_sso_dual_src = vendor_id_intel || vendor_id_amd /*|| amd_legacy_buggy_driver*/;
buggy_sso_dual_src = vendor_id_intel || vendor_id_amd && !amd_legacy_buggy_driver;

if (theApp.GetConfigI("override_geometry_shader") != -1) {
found_geometry_shader = theApp.GetConfigB("override_geometry_shader");
Expand Down
20 changes: 18 additions & 2 deletions plugins/GSdx/GSDeviceOGL.cpp
Expand Up @@ -1747,13 +1747,29 @@ void GSDeviceOGL::OMSetBlendState(uint8 blend_index, uint8 blend_factor, bool is

if (GLState::eq_RGB != b.op) {
GLState::eq_RGB = b.op;
glBlendEquationSeparate(b.op, GL_FUNC_ADD);
glBlendEquationSeparateiARB(0, b.op, GL_FUNC_ADD);
}

if (GLState::f_sRGB != b.src || GLState::f_dRGB != b.dst) {
GLState::f_sRGB = b.src;
GLState::f_dRGB = b.dst;
glBlendFuncSeparate(b.src, b.dst, GL_ONE, GL_ZERO);

// Catalyst legacy 2015 and older doesn't like the new SSO partial workaround so let's use the old workaround to get a partially working gl render.
// Some elements are semi transparent but it's better than having a white screen.
uint16 src = b.src;
uint16 dst = b.dst;
if (GLLoader::amd_legacy_buggy_driver) {
if (src == GL_SRC1_ALPHA)
src = GL_SRC_ALPHA;
else if (src == GL_ONE_MINUS_SRC1_ALPHA)
src = GL_ONE_MINUS_SRC_ALPHA;

if (dst == GL_SRC1_ALPHA)
dst = GL_SRC_ALPHA;
else if (dst == GL_ONE_MINUS_SRC1_ALPHA)
dst = GL_ONE_MINUS_SRC_ALPHA;
}
glBlendFuncSeparateiARB(0, src, dst, GL_ONE, GL_ZERO);
}

} else {
Expand Down
3 changes: 3 additions & 0 deletions plugins/GSdx/GSWnd.cpp
Expand Up @@ -95,6 +95,9 @@ void GSWndGL::PopulateGlFunction()
GL_EXT_LOAD_OPT(glGetInteger64v);
GL_EXT_LOAD_OPT(glCreateQueries);
GL_EXT_LOAD_OPT(glDeleteQueries);
// GL4.0
GL_EXT_LOAD_OPT(glBlendEquationSeparateiARB);
GL_EXT_LOAD_OPT(glBlendFuncSeparateiARB);
// GL4.1
GL_EXT_LOAD(glCreateShaderProgramv);
GL_EXT_LOAD(glBindProgramPipeline);
Expand Down

0 comments on commit 9f52a08

Please sign in to comment.