diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index 6ad948467..791c4bda9 100755 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -1878,9 +1878,28 @@ Render3DError OpenGLRenderer_1_2::InitExtensions() if (maxSamplesOGL >= 2) { - if (maxSamplesOGL > OGLRENDER_MAX_MULTISAMPLES) + GLint maxMultisamples = OGLMaxMultisamples_Tier1; + + if ( (this->_framebufferWidth <= GPU_FRAMEBUFFER_NATIVE_WIDTH) && (this->_framebufferHeight <= GPU_FRAMEBUFFER_NATIVE_HEIGHT) ) { - maxSamplesOGL = OGLRENDER_MAX_MULTISAMPLES; + maxMultisamples = OGLMaxMultisamples_Tier1; + } + else if ( (this->_framebufferWidth <= GPU_FRAMEBUFFER_NATIVE_WIDTH * 2) && (this->_framebufferHeight <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2) ) + { + maxMultisamples = OGLMaxMultisamples_Tier2; + } + else if ( (this->_framebufferWidth <= GPU_FRAMEBUFFER_NATIVE_WIDTH * 8) && (this->_framebufferHeight <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * 8) ) + { + maxMultisamples = OGLMaxMultisamples_Tier3; + } + else + { + maxMultisamples = OGLMaxMultisamples_Tier4; + } + + if (maxSamplesOGL > maxMultisamples) + { + maxSamplesOGL = maxMultisamples; } error = this->CreateMultisampledFBO(maxSamplesOGL); @@ -4451,9 +4470,28 @@ Render3DError OpenGLRenderer_1_2::SetFramebufferSize(size_t w, size_t h) if (this->isMultisampledFBOSupported) { GLsizei maxSamplesOGL = (GLsizei)this->_deviceInfo.maxSamples; - if (maxSamplesOGL > OGLRENDER_MAX_MULTISAMPLES) + GLint maxMultisamples = OGLMaxMultisamples_Tier1; + + if ( (w <= GPU_FRAMEBUFFER_NATIVE_WIDTH) && (h <= GPU_FRAMEBUFFER_NATIVE_HEIGHT) ) { - maxSamplesOGL = OGLRENDER_MAX_MULTISAMPLES; + maxMultisamples = OGLMaxMultisamples_Tier1; + } + else if ( (w <= GPU_FRAMEBUFFER_NATIVE_WIDTH * 2) && (h <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2) ) + { + maxMultisamples = OGLMaxMultisamples_Tier2; + } + else if ( (w <= GPU_FRAMEBUFFER_NATIVE_WIDTH * 8) && (h <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * 8) ) + { + maxMultisamples = OGLMaxMultisamples_Tier3; + } + else + { + maxMultisamples = OGLMaxMultisamples_Tier4; + } + + if (maxSamplesOGL > maxMultisamples) + { + maxSamplesOGL = maxMultisamples; } glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGColorID); diff --git a/desmume/src/OGLRender.h b/desmume/src/OGLRender.h index 0607586a3..347803c84 100755 --- a/desmume/src/OGLRender.h +++ b/desmume/src/OGLRender.h @@ -280,9 +280,16 @@ EXTERNOGLEXT(PFNGLTEXBUFFERPROC, glTexBuffer) // Core in v3.1 #define OGLRENDER_MINIMUM_DRIVER_VERSION_REQUIRED_MINOR 2 #define OGLRENDER_MINIMUM_DRIVER_VERSION_REQUIRED_REVISION 0 -#define OGLRENDER_MAX_MULTISAMPLES 8 #define OGLRENDER_VERT_INDEX_BUFFER_COUNT (POLYLIST_SIZE * 6) +enum OGLMaxMultisamples +{ + OGLMaxMultisamples_Tier1 = 32, + OGLMaxMultisamples_Tier2 = 16, + OGLMaxMultisamples_Tier3 = 8, + OGLMaxMultisamples_Tier4 = 4, +}; + enum OGLVertexAttributeID { OGLVertexAttributeID_Position = 0, diff --git a/desmume/src/OGLRender_3_2.cpp b/desmume/src/OGLRender_3_2.cpp index 9fc84040b..c6dd267b8 100644 --- a/desmume/src/OGLRender_3_2.cpp +++ b/desmume/src/OGLRender_3_2.cpp @@ -703,9 +703,28 @@ Render3DError OpenGLRenderer_3_2::InitExtensions() if (maxSamplesOGL >= 2) { - if (maxSamplesOGL > OGLRENDER_MAX_MULTISAMPLES) + GLint maxMultisamples = OGLMaxMultisamples_Tier1; + + if ( (this->_framebufferWidth <= GPU_FRAMEBUFFER_NATIVE_WIDTH) && (this->_framebufferHeight <= GPU_FRAMEBUFFER_NATIVE_HEIGHT) ) { - maxSamplesOGL = OGLRENDER_MAX_MULTISAMPLES; + maxMultisamples = OGLMaxMultisamples_Tier1; + } + else if ( (this->_framebufferWidth <= GPU_FRAMEBUFFER_NATIVE_WIDTH * 2) && (this->_framebufferHeight <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2) ) + { + maxMultisamples = OGLMaxMultisamples_Tier2; + } + else if ( (this->_framebufferWidth <= GPU_FRAMEBUFFER_NATIVE_WIDTH * 8) && (this->_framebufferHeight <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * 8) ) + { + maxMultisamples = OGLMaxMultisamples_Tier3; + } + else + { + maxMultisamples = OGLMaxMultisamples_Tier4; + } + + if (maxSamplesOGL > maxMultisamples) + { + maxSamplesOGL = maxMultisamples; } error = this->CreateMultisampledFBO(maxSamplesOGL); @@ -2008,9 +2027,28 @@ Render3DError OpenGLRenderer_3_2::SetFramebufferSize(size_t w, size_t h) if (this->isMultisampledFBOSupported) { GLsizei maxSamplesOGL = (GLsizei)this->_deviceInfo.maxSamples; - if (maxSamplesOGL > OGLRENDER_MAX_MULTISAMPLES) + GLint maxMultisamples = OGLMaxMultisamples_Tier1; + + if ( (w <= GPU_FRAMEBUFFER_NATIVE_WIDTH) && (h <= GPU_FRAMEBUFFER_NATIVE_HEIGHT) ) { - maxSamplesOGL = OGLRENDER_MAX_MULTISAMPLES; + maxMultisamples = OGLMaxMultisamples_Tier1; + } + else if ( (w <= GPU_FRAMEBUFFER_NATIVE_WIDTH * 2) && (h <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2) ) + { + maxMultisamples = OGLMaxMultisamples_Tier2; + } + else if ( (w <= GPU_FRAMEBUFFER_NATIVE_WIDTH * 8) && (h <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * 8) ) + { + maxMultisamples = OGLMaxMultisamples_Tier3; + } + else + { + maxMultisamples = OGLMaxMultisamples_Tier4; + } + + if (maxSamplesOGL > maxMultisamples) + { + maxSamplesOGL = maxMultisamples; } if (this->willUsePerSampleZeroDstPass)