Permalink
Browse files

OpenGL Renderer: Make the MSAA sample size limit based on the framebu…

…ffer size instead of being fixed at 8xMSAA.

- The MSAA sample size limit is now based on the following sizes:
1x Native Resolution - 32xMSAA
2x Native Resolution - 16xMSAA
3x-8x Native Resolution - 8xMSAA
9x and greater Native Resolution - 4xMSAA
  • Loading branch information...
rogerman committed Aug 27, 2017
1 parent e6d5a8f commit 2379dc1e413f45a13b3f771892ac2562d96dde9a
Showing with 92 additions and 9 deletions.
  1. +42 −4 desmume/src/OGLRender.cpp
  2. +8 −1 desmume/src/OGLRender.h
  3. +42 −4 desmume/src/OGLRender_3_2.cpp
View
@@ -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) )
{
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 = OGLRENDER_MAX_MULTISAMPLES;
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) )
{
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 = OGLRENDER_MAX_MULTISAMPLES;
maxSamplesOGL = maxMultisamples;
}
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGColorID);
View
@@ -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,
@@ -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) )
{
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 = OGLRENDER_MAX_MULTISAMPLES;
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) )
{
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 = OGLRENDER_MAX_MULTISAMPLES;
maxSamplesOGL = maxMultisamples;
}
if (this->willUsePerSampleZeroDstPass)

0 comments on commit 2379dc1

Please sign in to comment.