summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/Render.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/Render.cpp115
1 files changed, 70 insertions, 45 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index 428492c72a..9ee96bb724 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -508,12 +508,12 @@ Renderer::Renderer()
1 :
GLExtensions::Supports("GL_EXT_geometry_point_size") ? 2 : 0;
g_ogl_config.SupportedESTextureBuffer = GLExtensions::Supports("VERSION_GLES_3_2") ?
- ES_TEXBUF_TYPE::TEXBUF_CORE :
+ EsTexbufType::TexbufCore :
GLExtensions::Supports("GL_OES_texture_buffer") ?
- ES_TEXBUF_TYPE::TEXBUF_OES :
+ EsTexbufType::TexbufOes :
GLExtensions::Supports("GL_EXT_texture_buffer") ?
- ES_TEXBUF_TYPE::TEXBUF_EXT :
- ES_TEXBUF_TYPE::TEXBUF_NONE;
+ EsTexbufType::TexbufExt :
+ EsTexbufType::TexbufNone;
g_ogl_config.bSupportsGLSLCache = true;
g_ogl_config.bSupportsGLSync = true;
@@ -522,16 +522,31 @@ Renderer::Renderer()
// depth clamping.
g_Config.backend_info.bSupportsDepthClamp = false;
+ if (GLExtensions::Supports("GL_EXT_shader_framebuffer_fetch"))
+ {
+ g_ogl_config.SupportedFramebufferFetch = EsFbFetchType::FbFetchExt;
+ }
+ else if (GLExtensions::Supports("GL_ARM_shader_framebuffer_fetch"))
+ {
+ g_ogl_config.SupportedFramebufferFetch = EsFbFetchType::FbFetchArm;
+ }
+ else
+ {
+ g_ogl_config.SupportedFramebufferFetch = EsFbFetchType::FbFetchNone;
+ }
+ g_Config.backend_info.bSupportsFramebufferFetch =
+ g_ogl_config.SupportedFramebufferFetch != EsFbFetchType::FbFetchNone;
+
if (GLExtensions::Version() == 300)
{
- g_ogl_config.eSupportedGLSLVersion = GLSLES_300;
+ g_ogl_config.eSupportedGLSLVersion = GlslEs300;
g_ogl_config.bSupportsAEP = false;
g_ogl_config.bSupportsTextureStorage = true;
g_Config.backend_info.bSupportsGeometryShaders = false;
}
else if (GLExtensions::Version() == 310)
{
- g_ogl_config.eSupportedGLSLVersion = GLSLES_310;
+ g_ogl_config.eSupportedGLSLVersion = GlslEs310;
g_ogl_config.bSupportsAEP = GLExtensions::Supports("GL_ANDROID_extension_pack_es31a");
g_Config.backend_info.bSupportsBindingLayout = true;
g_ogl_config.bSupportsImageLoadStore = true;
@@ -556,7 +571,7 @@ Renderer::Renderer()
}
else
{
- g_ogl_config.eSupportedGLSLVersion = GLSLES_320;
+ g_ogl_config.eSupportedGLSLVersion = GlslEs320;
g_ogl_config.bSupportsAEP = GLExtensions::Supports("GL_ANDROID_extension_pack_es31a");
g_Config.backend_info.bSupportsBindingLayout = true;
g_ogl_config.bSupportsImageLoadStore = true;
@@ -589,7 +604,7 @@ Renderer::Renderer()
}
else if (GLExtensions::Version() == 300)
{
- g_ogl_config.eSupportedGLSLVersion = GLSL_130;
+ g_ogl_config.eSupportedGLSLVersion = Glsl130;
g_ogl_config.bSupportsImageLoadStore = false; // layout keyword is only supported on glsl150+
g_ogl_config.bSupportsConservativeDepth =
false; // layout keyword is only supported on glsl150+
@@ -598,7 +613,7 @@ Renderer::Renderer()
}
else if (GLExtensions::Version() == 310)
{
- g_ogl_config.eSupportedGLSLVersion = GLSL_140;
+ g_ogl_config.eSupportedGLSLVersion = Glsl140;
g_ogl_config.bSupportsImageLoadStore = false; // layout keyword is only supported on glsl150+
g_ogl_config.bSupportsConservativeDepth =
false; // layout keyword is only supported on glsl150+
@@ -607,16 +622,16 @@ Renderer::Renderer()
}
else if (GLExtensions::Version() == 320)
{
- g_ogl_config.eSupportedGLSLVersion = GLSL_150;
+ g_ogl_config.eSupportedGLSLVersion = Glsl150;
}
else if (GLExtensions::Version() == 330)
{
- g_ogl_config.eSupportedGLSLVersion = GLSL_330;
+ g_ogl_config.eSupportedGLSLVersion = Glsl330;
}
else if (GLExtensions::Version() >= 430)
{
// TODO: We should really parse the GL_SHADING_LANGUAGE_VERSION token.
- g_ogl_config.eSupportedGLSLVersion = GLSL_430;
+ g_ogl_config.eSupportedGLSLVersion = Glsl430;
g_ogl_config.bSupportsTextureStorage = true;
g_ogl_config.bSupportsImageLoadStore = true;
g_Config.backend_info.bSupportsSSAA = true;
@@ -628,7 +643,7 @@ Renderer::Renderer()
}
else
{
- g_ogl_config.eSupportedGLSLVersion = GLSL_400;
+ g_ogl_config.eSupportedGLSLVersion = Glsl400;
g_Config.backend_info.bSupportsSSAA = true;
if (GLExtensions::Version() == 420)
@@ -1275,44 +1290,54 @@ void Renderer::SetBlendingState(const BlendingState& state)
bool useDualSource =
state.usedualsrc && g_ActiveConfig.backend_info.bSupportsDualSourceBlend &&
(!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_DUAL_SOURCE_BLENDING) || state.dstalpha);
+ // Only use shader blend if we need to and we don't support dual-source blending directly
+ bool useShaderBlend = !useDualSource && state.usedualsrc && state.dstalpha &&
+ g_ActiveConfig.backend_info.bSupportsFramebufferFetch;
- const GLenum src_factors[8] = {
- GL_ZERO,
- GL_ONE,
- GL_DST_COLOR,
- GL_ONE_MINUS_DST_COLOR,
- useDualSource ? GL_SRC1_ALPHA : (GLenum)GL_SRC_ALPHA,
- useDualSource ? GL_ONE_MINUS_SRC1_ALPHA : (GLenum)GL_ONE_MINUS_SRC_ALPHA,
- GL_DST_ALPHA,
- GL_ONE_MINUS_DST_ALPHA};
- const GLenum dst_factors[8] = {
- GL_ZERO,
- GL_ONE,
- GL_SRC_COLOR,
- GL_ONE_MINUS_SRC_COLOR,
- useDualSource ? GL_SRC1_ALPHA : (GLenum)GL_SRC_ALPHA,
- useDualSource ? GL_ONE_MINUS_SRC1_ALPHA : (GLenum)GL_ONE_MINUS_SRC_ALPHA,
- GL_DST_ALPHA,
- GL_ONE_MINUS_DST_ALPHA};
-
- if (state.blendenable)
+ if (useShaderBlend)
{
- glEnable(GL_BLEND);
+ glDisable(GL_BLEND);
}
else
{
- glDisable(GL_BLEND);
- }
+ const GLenum src_factors[8] = {
+ GL_ZERO,
+ GL_ONE,
+ GL_DST_COLOR,
+ GL_ONE_MINUS_DST_COLOR,
+ useDualSource ? GL_SRC1_ALPHA : (GLenum)GL_SRC_ALPHA,
+ useDualSource ? GL_ONE_MINUS_SRC1_ALPHA : (GLenum)GL_ONE_MINUS_SRC_ALPHA,
+ GL_DST_ALPHA,
+ GL_ONE_MINUS_DST_ALPHA};
+ const GLenum dst_factors[8] = {
+ GL_ZERO,
+ GL_ONE,
+ GL_SRC_COLOR,
+ GL_ONE_MINUS_SRC_COLOR,
+ useDualSource ? GL_SRC1_ALPHA : (GLenum)GL_SRC_ALPHA,
+ useDualSource ? GL_ONE_MINUS_SRC1_ALPHA : (GLenum)GL_ONE_MINUS_SRC_ALPHA,
+ GL_DST_ALPHA,
+ GL_ONE_MINUS_DST_ALPHA};
+
+ if (state.blendenable)
+ {
+ glEnable(GL_BLEND);
+ }
+ else
+ {
+ glDisable(GL_BLEND);
+ }
- // Always call glBlendEquationSeparate and glBlendFuncSeparate, even when
- // GL_BLEND is disabled, as a workaround for some bugs (possibly graphics
- // driver issues?). See https://bugs.dolphin-emu.org/issues/10120 : "Sonic
- // Adventure 2 Battle: graphics crash when loading first Dark level"
- GLenum equation = state.subtract ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD;
- GLenum equationAlpha = state.subtractAlpha ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD;
- glBlendEquationSeparate(equation, equationAlpha);
- glBlendFuncSeparate(src_factors[state.srcfactor], dst_factors[state.dstfactor],
- src_factors[state.srcfactoralpha], dst_factors[state.dstfactoralpha]);
+ // Always call glBlendEquationSeparate and glBlendFuncSeparate, even when
+ // GL_BLEND is disabled, as a workaround for some bugs (possibly graphics
+ // driver issues?). See https://bugs.dolphin-emu.org/issues/10120 : "Sonic
+ // Adventure 2 Battle: graphics crash when loading first Dark level"
+ GLenum equation = state.subtract ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD;
+ GLenum equationAlpha = state.subtractAlpha ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD;
+ glBlendEquationSeparate(equation, equationAlpha);
+ glBlendFuncSeparate(src_factors[state.srcfactor], dst_factors[state.dstfactor],
+ src_factors[state.srcfactoralpha], dst_factors[state.dstfactoralpha]);
+ }
const GLenum logic_op_codes[16] = {
GL_CLEAR, GL_AND, GL_AND_REVERSE, GL_COPY, GL_AND_INVERTED, GL_NOOP,