summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/Render.cpp
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2015-09-05 05:31:04 -0500
committerRyan Houdek <Sonicadvance1@gmail.com>2015-09-05 05:31:04 -0500
commit1773f6a2df4544342197519b119618ce3ab0594f (patch)
treeb36256d962371720e6aff1e1c9483d773670f577 /Source/Core/VideoBackends/OGL/Render.cpp
parent0f3263ac6344fff53a588c392be5328506036c1a (diff)
parent7650117c266b3eed1c3bdae0feb2828a6482bfe0 (diff)
Merge pull request #2934 from Sonicadvance1/GLES_proper_SSAA
Properly support MSAA and SSAA as separate features(+GLES)
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/Render.cpp61
1 files changed, 36 insertions, 25 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index 638685d92c..95059819c1 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -73,10 +73,8 @@ enum MultisampleMode
MULTISAMPLE_2X,
MULTISAMPLE_4X,
MULTISAMPLE_8X,
- MULTISAMPLE_SSAA_4X,
};
-
VideoConfig g_ogl_config;
// Declarations and definitions
@@ -90,6 +88,7 @@ static RasterFont* s_pfont = nullptr;
// 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA.
static int s_MSAASamples = 1;
static int s_last_multisample_mode = 0;
+static bool s_last_ssaa_mode = false;
static bool s_last_stereo_mode = false;
static bool s_last_xfb_mode = false;
@@ -119,14 +118,12 @@ static int GetNumMSAASamples(int MSAAMode)
break;
case MULTISAMPLE_4X:
- case MULTISAMPLE_SSAA_4X:
samples = 4;
break;
case MULTISAMPLE_8X:
samples = 8;
break;
-
default:
samples = 1;
}
@@ -141,28 +138,23 @@ static int GetNumMSAASamples(int MSAAMode)
static void ApplySSAASettings()
{
- // GLES3 doesn't support SSAA
- if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
+ if (g_ActiveConfig.bSSAA)
{
- if (g_ActiveConfig.iMultisampleMode == MULTISAMPLE_SSAA_4X)
+ if (g_ActiveConfig.backend_info.bSupportsSSAA)
{
- if (g_ogl_config.bSupportSampleShading)
- {
- glEnable(GL_SAMPLE_SHADING_ARB);
- GLfloat min_sample_shading_value = static_cast<GLfloat>(s_MSAASamples);
- glMinSampleShading(min_sample_shading_value);
- }
- else
- {
- // TODO: move this to InitBackendInfo
- OSD::AddMessage("SSAA Anti Aliasing isn't supported by your GPU.", 10000);
- }
+ glEnable(GL_SAMPLE_SHADING_ARB);
+ glMinSampleShading(1.0f);
}
- else if (g_ogl_config.bSupportSampleShading)
+ else
{
- glDisable(GL_SAMPLE_SHADING_ARB);
+ // TODO: move this to InitBackendInfo
+ OSD::AddMessage("SSAA Anti Aliasing isn't supported by your GPU.", 10000);
}
}
+ else if (g_ActiveConfig.backend_info.bSupportsSSAA)
+ {
+ glDisable(GL_SAMPLE_SHADING_ARB);
+ }
}
static void GLAPIENTRY ErrorCallback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, const void* userParam)
@@ -491,11 +483,15 @@ Renderer::Renderer()
g_ogl_config.bSupportsGLBufferStorage = GLExtensions::Supports("GL_ARB_buffer_storage") ||
GLExtensions::Supports("GL_EXT_buffer_storage");
g_ogl_config.bSupportsMSAA = GLExtensions::Supports("GL_ARB_texture_multisample");
- g_ogl_config.bSupportSampleShading = GLExtensions::Supports("GL_ARB_sample_shading");
+ g_ActiveConfig.backend_info.bSupportsSSAA = GLExtensions::Supports("GL_ARB_sample_shading") ||
+ GLExtensions::Supports("GL_OES_sample_shading");
g_ogl_config.bSupportOGL31 = GLExtensions::Version() >= 310;
g_ogl_config.bSupportViewportFloat = GLExtensions::Supports("GL_ARB_viewport_array");
g_ogl_config.bSupportsDebug = GLExtensions::Supports("GL_KHR_debug") ||
GLExtensions::Supports("GL_ARB_debug_output");
+ g_ogl_config.bSupports3DTextureStorage = GLExtensions::Supports("GL_ARB_texture_storage_multisample") ||
+ GLExtensions::Supports("GL_OES_texture_storage_multisample_2d_array");
+ g_ogl_config.bSupports2DTextureStorage = GLExtensions::Supports("GL_ARB_texture_storage_multisample");
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
{
@@ -518,6 +514,14 @@ Renderer::Renderer()
g_Config.backend_info.bSupportsEarlyZ = true;
g_Config.backend_info.bSupportsGeometryShaders = g_ogl_config.bSupportsAEP;
g_Config.backend_info.bSupportsGSInstancing = g_Config.backend_info.bSupportsGeometryShaders && g_ogl_config.SupportedESPointSize > 0;
+ g_ogl_config.bSupportsMSAA = true;
+ g_ogl_config.bSupports2DTextureStorage = true;
+ if (g_ActiveConfig.iStereoMode > 0 && g_ActiveConfig.iMultisampleMode > 1 && !g_ogl_config.bSupports3DTextureStorage)
+ {
+ // GLES 3.1 can't support stereo rendering and MSAA
+ OSD::AddMessage("MSAA Stereo rendering isn't supported by your GPU.", 10000);
+ g_ActiveConfig.iMultisampleMode = 1;
+ }
}
else
{
@@ -528,10 +532,13 @@ Renderer::Renderer()
g_Config.backend_info.bSupportsGeometryShaders = true;
g_Config.backend_info.bSupportsGSInstancing = g_ogl_config.SupportedESPointSize > 0;
g_Config.backend_info.bSupportsPaletteConversion = true;
+ g_Config.backend_info.bSupportsSSAA = true;
g_ogl_config.bSupportsCopySubImage = true;
g_ogl_config.bSupportsGLBaseVertex = true;
- g_ogl_config.bSupportSampleShading = true;
g_ogl_config.bSupportsDebug = true;
+ g_ogl_config.bSupportsMSAA = true;
+ g_ogl_config.bSupports2DTextureStorage = true;
+ g_ogl_config.bSupports3DTextureStorage = true;
}
}
else
@@ -624,13 +631,14 @@ Renderer::Renderer()
g_ogl_config.bSupportsGLBufferStorage ? "" : "BufferStorage ",
g_ogl_config.bSupportsGLSync ? "" : "Sync ",
g_ogl_config.bSupportsMSAA ? "" : "MSAA ",
- g_ogl_config.bSupportSampleShading ? "" : "SSAA ",
+ g_ActiveConfig.backend_info.bSupportsSSAA ? "" : "SSAA ",
g_ActiveConfig.backend_info.bSupportsGSInstancing ? "" : "GSInstancing ",
g_ActiveConfig.backend_info.bSupportsClipControl ? "" : "ClipControl ",
g_ogl_config.bSupportsCopySubImage ? "" : "CopyImageSubData "
);
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
+ s_last_ssaa_mode = g_ActiveConfig.bSSAA;
s_MSAASamples = GetNumMSAASamples(s_last_multisample_mode);
ApplySSAASettings();
@@ -1683,16 +1691,19 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
{
TargetSizeChanged = true;
}
- if (TargetSizeChanged || xfbchanged || WindowResized || (s_last_multisample_mode != g_ActiveConfig.iMultisampleMode) || (s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0)))
+ if (TargetSizeChanged || xfbchanged || WindowResized || s_last_ssaa_mode != g_ActiveConfig.bSSAA ||
+ (s_last_multisample_mode != g_ActiveConfig.iMultisampleMode) || (s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0)))
{
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
- if (TargetSizeChanged || s_last_multisample_mode != g_ActiveConfig.iMultisampleMode || s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
+ if (TargetSizeChanged || s_last_ssaa_mode != g_ActiveConfig.bSSAA ||
+ s_last_multisample_mode != g_ActiveConfig.iMultisampleMode || s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
{
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
+ s_last_ssaa_mode = g_ActiveConfig.bSSAA;
s_MSAASamples = GetNumMSAASamples(s_last_multisample_mode);
ApplySSAASettings();