mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-09 18:45:40 +00:00
OGL: Fix changing MSAA mode during emulation.
Fixes issue 4469. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7525 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
423db843b7
commit
e29e317580
@ -118,6 +118,7 @@ static File::IOFile f_pFrameDump;
|
|||||||
// 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA.
|
// 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA.
|
||||||
static int s_MSAASamples = 1;
|
static int s_MSAASamples = 1;
|
||||||
static int s_MSAACoverageSamples = 0;
|
static int s_MSAACoverageSamples = 0;
|
||||||
|
static int s_LastMultisampleMode = 0;
|
||||||
|
|
||||||
bool s_bHaveFramebufferBlit = false; // export to FramebufferManager.cpp
|
bool s_bHaveFramebufferBlit = false; // export to FramebufferManager.cpp
|
||||||
static bool s_bHaveCoverageMSAA = false;
|
static bool s_bHaveCoverageMSAA = false;
|
||||||
@ -191,6 +192,55 @@ void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int GetNumMSAASamples(int MSAAMode)
|
||||||
|
{
|
||||||
|
// required for MSAA
|
||||||
|
if (!s_bHaveFramebufferBlit)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
switch (MSAAMode)
|
||||||
|
{
|
||||||
|
case MULTISAMPLE_OFF:
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
case MULTISAMPLE_2X:
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
case MULTISAMPLE_4X:
|
||||||
|
case MULTISAMPLE_CSAA_8X:
|
||||||
|
case MULTISAMPLE_CSAA_16X:
|
||||||
|
return 4;
|
||||||
|
|
||||||
|
case MULTISAMPLE_8X:
|
||||||
|
case MULTISAMPLE_CSAA_8XQ:
|
||||||
|
case MULTISAMPLE_CSAA_16XQ:
|
||||||
|
return 8;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetNumMSAACoverageSamples(int MSAAMode)
|
||||||
|
{
|
||||||
|
if (!s_bHaveCoverageMSAA)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (g_ActiveConfig.iMultisampleMode)
|
||||||
|
{
|
||||||
|
case MULTISAMPLE_CSAA_8X:
|
||||||
|
case MULTISAMPLE_CSAA_8XQ:
|
||||||
|
return 8;
|
||||||
|
|
||||||
|
case MULTISAMPLE_CSAA_16X:
|
||||||
|
case MULTISAMPLE_CSAA_16XQ:
|
||||||
|
return 16;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Init functions
|
// Init functions
|
||||||
Renderer::Renderer()
|
Renderer::Renderer()
|
||||||
{
|
{
|
||||||
@ -198,51 +248,11 @@ Renderer::Renderer()
|
|||||||
OSDInternalH = 0;
|
OSDInternalH = 0;
|
||||||
|
|
||||||
s_fps=0;
|
s_fps=0;
|
||||||
|
s_blendMode = 0;
|
||||||
#if defined _WIN32 || defined HAVE_LIBAV
|
#if defined _WIN32 || defined HAVE_LIBAV
|
||||||
s_bAVIDumping = false;
|
s_bAVIDumping = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool bSuccess = true;
|
|
||||||
s_blendMode = 0;
|
|
||||||
s_MSAACoverageSamples = 0;
|
|
||||||
GLint numvertexattribs = 0;
|
|
||||||
|
|
||||||
switch (g_ActiveConfig.iMultisampleMode)
|
|
||||||
{
|
|
||||||
case MULTISAMPLE_OFF:
|
|
||||||
s_MSAASamples = 1;
|
|
||||||
break;
|
|
||||||
case MULTISAMPLE_2X:
|
|
||||||
s_MSAASamples = 2;
|
|
||||||
break;
|
|
||||||
case MULTISAMPLE_4X:
|
|
||||||
s_MSAASamples = 4;
|
|
||||||
break;
|
|
||||||
case MULTISAMPLE_8X:
|
|
||||||
s_MSAASamples = 8;
|
|
||||||
break;
|
|
||||||
case MULTISAMPLE_CSAA_8X:
|
|
||||||
s_MSAASamples = 4;
|
|
||||||
s_MSAACoverageSamples = 8;
|
|
||||||
break;
|
|
||||||
case MULTISAMPLE_CSAA_8XQ:
|
|
||||||
s_MSAASamples = 8;
|
|
||||||
s_MSAACoverageSamples = 8;
|
|
||||||
break;
|
|
||||||
case MULTISAMPLE_CSAA_16X:
|
|
||||||
s_MSAASamples = 4;
|
|
||||||
s_MSAACoverageSamples = 16;
|
|
||||||
break;
|
|
||||||
case MULTISAMPLE_CSAA_16XQ:
|
|
||||||
s_MSAASamples = 8;
|
|
||||||
s_MSAACoverageSamples = 16;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
s_MSAASamples = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined HAVE_CG && HAVE_CG
|
#if defined HAVE_CG && HAVE_CG
|
||||||
g_cgcontext = cgCreateContext();
|
g_cgcontext = cgCreateContext();
|
||||||
cgGetError();
|
cgGetError();
|
||||||
@ -268,6 +278,8 @@ Renderer::Renderer()
|
|||||||
glGetString(GL_RENDERER),
|
glGetString(GL_RENDERER),
|
||||||
glGetString(GL_VERSION)).c_str(), 5000);
|
glGetString(GL_VERSION)).c_str(), 5000);
|
||||||
|
|
||||||
|
bool bSuccess = true;
|
||||||
|
GLint numvertexattribs = 0;
|
||||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs);
|
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs);
|
||||||
if (numvertexattribs < 11)
|
if (numvertexattribs < 11)
|
||||||
{
|
{
|
||||||
@ -299,17 +311,11 @@ Renderer::Renderer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
s_bHaveFramebufferBlit = strstr(ptoken, "GL_EXT_framebuffer_blit") != NULL;
|
s_bHaveFramebufferBlit = strstr(ptoken, "GL_EXT_framebuffer_blit") != NULL;
|
||||||
if (!s_bHaveFramebufferBlit)
|
|
||||||
{
|
|
||||||
// MSAA ain't gonna work. turn it off if enabled.
|
|
||||||
s_MSAASamples = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
s_bHaveCoverageMSAA = strstr(ptoken, "GL_NV_framebuffer_multisample_coverage") != NULL;
|
s_bHaveCoverageMSAA = strstr(ptoken, "GL_NV_framebuffer_multisample_coverage") != NULL;
|
||||||
if (!s_bHaveCoverageMSAA)
|
|
||||||
{
|
s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode;
|
||||||
s_MSAACoverageSamples = 0;
|
s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode);
|
||||||
}
|
s_MSAACoverageSamples = GetNumMSAACoverageSamples(s_LastMultisampleMode);
|
||||||
|
|
||||||
if (!bSuccess)
|
if (!bSuccess)
|
||||||
return; // TODO: fail
|
return; // TODO: fail
|
||||||
@ -1270,7 +1276,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||||||
SetWindowSize(fbWidth, fbHeight);
|
SetWindowSize(fbWidth, fbHeight);
|
||||||
|
|
||||||
OpenGL_Update(); // just updates the render window position and the backbuffer size
|
OpenGL_Update(); // just updates the render window position and the backbuffer size
|
||||||
|
|
||||||
bool xfbchanged = false;
|
bool xfbchanged = false;
|
||||||
|
|
||||||
if (s_XFB_width != fbWidth || s_XFB_height != fbHeight)
|
if (s_XFB_width != fbWidth || s_XFB_height != fbHeight)
|
||||||
@ -1295,14 +1301,18 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xfbchanged || WindowResized)
|
if (xfbchanged || WindowResized || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode))
|
||||||
{
|
{
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
||||||
|
|
||||||
CalculateXYScale(dst_rect);
|
CalculateXYScale(dst_rect);
|
||||||
|
|
||||||
if (CalculateTargetSize())
|
if (CalculateTargetSize() || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode))
|
||||||
{
|
{
|
||||||
|
s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode;
|
||||||
|
s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode);
|
||||||
|
s_MSAACoverageSamples = GetNumMSAACoverageSamples(s_LastMultisampleMode);
|
||||||
|
|
||||||
delete g_framebuffer_manager;
|
delete g_framebuffer_manager;
|
||||||
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,
|
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,
|
||||||
s_MSAASamples, s_MSAACoverageSamples);
|
s_MSAASamples, s_MSAACoverageSamples);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user