mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
VideoBackends: Reimplement SSAA, now for D3D + OGL
This commit is contained in:
@ -94,21 +94,37 @@ bool cInterfaceGLX::Create(void *window_handle)
|
||||
// Get an appropriate visual
|
||||
XVisualInfo* vi = glXGetVisualFromFBConfig(dpy, fbconfig);
|
||||
|
||||
s_glxError = false;
|
||||
XErrorHandler oldHandler = XSetErrorHandler(&ctxErrorHandler);
|
||||
|
||||
// Create a GLX context.
|
||||
// We try to get a 3.3 core profile, else we try it with anything we get.
|
||||
// We try to get a 4.0 core profile, else we try 3.3, else try it with anything we get.
|
||||
int context_attribs[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
||||
None
|
||||
};
|
||||
s_glxError = false;
|
||||
XErrorHandler oldHandler = XSetErrorHandler(&ctxErrorHandler);
|
||||
ctx = glXCreateContextAttribs(dpy, fbconfig, 0, True, context_attribs);
|
||||
XSync(dpy, False);
|
||||
if (!ctx || s_glxError)
|
||||
{
|
||||
int context_attribs_33[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
||||
None
|
||||
};
|
||||
s_glxError = false;
|
||||
ctx = glXCreateContextAttribs(dpy, fbconfig, 0, True, context_attribs_33);
|
||||
XSync(dpy, False);
|
||||
|
||||
}
|
||||
if (!ctx || s_glxError)
|
||||
{
|
||||
int context_attribs_legacy[] =
|
||||
{
|
||||
@ -119,11 +135,12 @@ bool cInterfaceGLX::Create(void *window_handle)
|
||||
s_glxError = false;
|
||||
ctx = glXCreateContextAttribs(dpy, fbconfig, 0, True, context_attribs_legacy);
|
||||
XSync(dpy, False);
|
||||
if (!ctx || s_glxError)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Unable to create GL context.");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
if (!ctx || s_glxError)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Unable to create GL context.");
|
||||
return false;
|
||||
}
|
||||
XSetErrorHandler(oldHandler);
|
||||
|
||||
|
@ -58,6 +58,10 @@ static std::string GetGLSLVersionString()
|
||||
return "#version 140";
|
||||
case GLSL_150:
|
||||
return "#version 150";
|
||||
case GLSL_330:
|
||||
return "#version 330";
|
||||
case GLSL_400:
|
||||
return "#version 400";
|
||||
default:
|
||||
// Shouldn't ever hit this
|
||||
return "#version ERROR";
|
||||
@ -552,7 +556,6 @@ void ProgramShaderCache::CreateHeader()
|
||||
"%s\n" // early-z
|
||||
"%s\n" // 420pack
|
||||
"%s\n" // msaa
|
||||
"%s\n" // sample shading
|
||||
"%s\n" // Sampler binding
|
||||
"%s\n" // storage buffer
|
||||
"%s\n" // shader5
|
||||
@ -585,17 +588,16 @@ void ProgramShaderCache::CreateHeader()
|
||||
"#define lerp mix\n"
|
||||
|
||||
, GetGLSLVersionString().c_str()
|
||||
, v<GLSL_140 ? "#extension GL_ARB_uniform_buffer_object : enable" : ""
|
||||
, v < GLSL_140 ? "#extension GL_ARB_uniform_buffer_object : enable" : ""
|
||||
, !is_glsles && g_ActiveConfig.backend_info.bSupportsEarlyZ ? "#extension GL_ARB_shader_image_load_store : enable" : ""
|
||||
, (g_ActiveConfig.backend_info.bSupportsBindingLayout && v < GLSLES_310) ? "#extension GL_ARB_shading_language_420pack : enable" : ""
|
||||
, (g_ogl_config.bSupportsMSAA && v < GLSL_150) ? "#extension GL_ARB_texture_multisample : enable" : ""
|
||||
, (v < GLSLES_300 && g_ActiveConfig.backend_info.bSupportsSSAA) ? "#extension GL_ARB_sample_shading : enable" : ""
|
||||
, g_ActiveConfig.backend_info.bSupportsBindingLayout ? "#define SAMPLER_BINDING(x) layout(binding = x)" : "#define SAMPLER_BINDING(x)"
|
||||
, g_ActiveConfig.backend_info.bSupportsBBox ? "#extension GL_ARB_shader_storage_buffer_object : enable" : ""
|
||||
, !is_glsles && g_ActiveConfig.backend_info.bSupportsGSInstancing ? "#extension GL_ARB_gpu_shader5 : enable" : ""
|
||||
, v < GLSL_400 && g_ActiveConfig.backend_info.bSupportsGSInstancing ? "#extension GL_ARB_gpu_shader5 : enable" : ""
|
||||
, SupportedESPointSize.c_str()
|
||||
, g_ogl_config.bSupportsAEP ? "#extension GL_ANDROID_extension_pack_es31a : enable" : ""
|
||||
, v<GLSL_140 && g_ActiveConfig.backend_info.bSupportsPaletteConversion ? "#extension GL_ARB_texture_buffer_object : enable" : ""
|
||||
, v < GLSL_140 && g_ActiveConfig.backend_info.bSupportsPaletteConversion ? "#extension GL_ARB_texture_buffer_object : enable" : ""
|
||||
, SupportedESTextureBuffer.c_str()
|
||||
, is_glsles && g_ActiveConfig.backend_info.bSupportsDualSourceBlend ? "#extension GL_EXT_blend_func_extended : enable" : ""
|
||||
|
||||
|
@ -88,7 +88,6 @@ 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;
|
||||
|
||||
@ -136,27 +135,6 @@ static int GetNumMSAASamples(int MSAAMode)
|
||||
return g_ogl_config.max_samples;
|
||||
}
|
||||
|
||||
static void ApplySSAASettings()
|
||||
{
|
||||
if (g_ActiveConfig.bSSAA)
|
||||
{
|
||||
if (g_ActiveConfig.backend_info.bSupportsSSAA)
|
||||
{
|
||||
glEnable(GL_SAMPLE_SHADING_ARB);
|
||||
glMinSampleShading(1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
const char *s_source;
|
||||
@ -483,8 +461,6 @@ 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_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") ||
|
||||
@ -514,6 +490,7 @@ 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_Config.backend_info.bSupportsSSAA = g_ogl_config.bSupportsAEP;
|
||||
g_ogl_config.bSupportsMSAA = true;
|
||||
g_ogl_config.bSupports2DTextureStorage = true;
|
||||
if (g_ActiveConfig.iStereoMode > 0 && g_ActiveConfig.iMultisampleMode > 1 && !g_ogl_config.bSupports3DTextureStorage)
|
||||
@ -555,16 +532,28 @@ Renderer::Renderer()
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSL_130;
|
||||
g_Config.backend_info.bSupportsEarlyZ = false; // layout keyword is only supported on glsl150+
|
||||
g_Config.backend_info.bSupportsGeometryShaders = false; // geometry shaders are only supported on glsl150+
|
||||
g_Config.backend_info.bSupportsSSAA = false; // sample shading is only supported on glsl400+
|
||||
}
|
||||
else if (strstr(g_ogl_config.glsl_version, "1.40"))
|
||||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSL_140;
|
||||
g_Config.backend_info.bSupportsEarlyZ = false; // layout keyword is only supported on glsl150+
|
||||
g_Config.backend_info.bSupportsGeometryShaders = false; // geometry shaders are only supported on glsl150+
|
||||
g_Config.backend_info.bSupportsSSAA = false; // sample shading is only supported on glsl400+
|
||||
}
|
||||
else if (strstr(g_ogl_config.glsl_version, "1.50"))
|
||||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSL_150;
|
||||
g_Config.backend_info.bSupportsSSAA = false; // sample shading is only supported on glsl400+
|
||||
}
|
||||
else if (strstr(g_ogl_config.glsl_version, "3.30"))
|
||||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSL_330;
|
||||
g_Config.backend_info.bSupportsSSAA = false; // sample shading is only supported on glsl400+
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSL_150;
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSL_400;
|
||||
}
|
||||
|
||||
// Desktop OpenGL can't have the Android Extension Pack
|
||||
@ -638,9 +627,7 @@ Renderer::Renderer()
|
||||
);
|
||||
|
||||
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
|
||||
s_last_ssaa_mode = g_ActiveConfig.bSSAA;
|
||||
s_MSAASamples = GetNumMSAASamples(s_last_multisample_mode);
|
||||
ApplySSAASettings();
|
||||
|
||||
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
|
||||
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
|
||||
@ -1691,21 +1678,19 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
|
||||
{
|
||||
TargetSizeChanged = true;
|
||||
}
|
||||
if (TargetSizeChanged || xfbchanged || WindowResized || s_last_ssaa_mode != g_ActiveConfig.bSSAA ||
|
||||
if (TargetSizeChanged || xfbchanged || WindowResized ||
|
||||
(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_ssaa_mode != g_ActiveConfig.bSSAA ||
|
||||
if (TargetSizeChanged ||
|
||||
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();
|
||||
|
||||
delete g_framebuffer_manager;
|
||||
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,
|
||||
|
@ -16,7 +16,9 @@ enum GLSL_VERSION
|
||||
{
|
||||
GLSL_130,
|
||||
GLSL_140,
|
||||
GLSL_150, // and above
|
||||
GLSL_150,
|
||||
GLSL_330,
|
||||
GLSL_400, // and above
|
||||
GLSLES_300, // GLES 3.0
|
||||
GLSLES_310, // GLES 3.1
|
||||
GLSLES_320, // GLES 3.2
|
||||
|
Reference in New Issue
Block a user