OpenGL Renderer: Make the MSAA sample size limit based on the framebuffer 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
This commit is contained in:
rogerman 2017-08-26 22:41:53 -07:00
parent e6d5a8fbe1
commit 2379dc1e41
3 changed files with 92 additions and 9 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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)