OpenGL Renderer: The MSAA sample size is no longer automatically selected and must now be manually selected via GFX3D_Renderer_MultisampleSize.

- All frontends will need to be updated to use the new GFX3D_Renderer_MultisampleSize setting.
- This change obsoletes GFX3D_Renderer_Multisample, which currently does nothing at the moment. It will be removed after all frontends are updated.
This commit is contained in:
rogerman 2018-10-22 10:32:16 -07:00
parent a894000333
commit 94ddf1a467
5 changed files with 170 additions and 93 deletions

View File

@ -532,6 +532,7 @@ extern struct TCommonSettings
, GFX3D_Texture(true) , GFX3D_Texture(true)
, GFX3D_LineHack(true) , GFX3D_LineHack(true)
, GFX3D_Renderer_Multisample(false) , GFX3D_Renderer_Multisample(false)
, GFX3D_Renderer_MultisampleSize(0)
, GFX3D_Renderer_TextureScalingFactor(1) // Possible values: 1, 2, 4 , GFX3D_Renderer_TextureScalingFactor(1) // Possible values: 1, 2, 4
, GFX3D_Renderer_TextureDeposterize(false) , GFX3D_Renderer_TextureDeposterize(false)
, GFX3D_Renderer_TextureSmoothing(false) , GFX3D_Renderer_TextureSmoothing(false)
@ -591,6 +592,7 @@ extern struct TCommonSettings
bool GFX3D_Texture; bool GFX3D_Texture;
bool GFX3D_LineHack; bool GFX3D_LineHack;
bool GFX3D_Renderer_Multisample; bool GFX3D_Renderer_Multisample;
int GFX3D_Renderer_MultisampleSize;
int GFX3D_Renderer_TextureScalingFactor; //must be one of {1,2,4} int GFX3D_Renderer_TextureScalingFactor; //must be one of {1,2,4}
bool GFX3D_Renderer_TextureDeposterize; bool GFX3D_Renderer_TextureDeposterize;
bool GFX3D_Renderer_TextureSmoothing; bool GFX3D_Renderer_TextureSmoothing;

View File

@ -1474,35 +1474,39 @@ FragmentColor* OpenGLRenderer::GetFramebuffer()
return (this->willFlipAndConvertFramebufferOnGPU && this->isPBOSupported) ? this->_mappedFramebuffer : GPU->GetEngineMain()->Get3DFramebufferMain(); return (this->willFlipAndConvertFramebufferOnGPU && this->isPBOSupported) ? this->_mappedFramebuffer : GPU->GetEngineMain()->Get3DFramebufferMain();
} }
GLsizei OpenGLRenderer::GetLimitedMultisampleSize() const GLsizei OpenGLRenderer::GetLimitedMultisampleSize() const
{ {
GLsizei deviceMultisamples = this->_deviceInfo.maxSamples; GLsizei deviceMultisamples = this->_deviceInfo.maxSamples;
GLsizei maxMultisamples = OGLMaxMultisamples_Tier1; u32 workingMultisamples = (u32)this->_selectedMultisampleSize;
if ( (this->_framebufferWidth <= GPU_FRAMEBUFFER_NATIVE_WIDTH * OGLMaxMultisamplesScaleLimit_Tier1) && if (workingMultisamples == 1)
(this->_framebufferHeight <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * OGLMaxMultisamplesScaleLimit_Tier1) )
{ {
maxMultisamples = OGLMaxMultisamples_Tier1; // If this->_selectedMultisampleSize is 1, then just set workingMultisamples to 2
} // by default. This is done to prevent the multisampled FBOs from being resized to
else if ( (this->_framebufferWidth <= GPU_FRAMEBUFFER_NATIVE_WIDTH * OGLMaxMultisamplesScaleLimit_Tier2) && // a meaningless sample size of 1.
(this->_framebufferHeight <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * OGLMaxMultisamplesScaleLimit_Tier2) ) //
{ // As an side, if someone wants to bring back automatic MSAA sample size selection
maxMultisamples = OGLMaxMultisamples_Tier2; // in the future, then this would be the place to reimplement it.
} workingMultisamples = 2;
else if ( (this->_framebufferWidth <= GPU_FRAMEBUFFER_NATIVE_WIDTH * OGLMaxMultisamplesScaleLimit_Tier3) &&
(this->_framebufferHeight <= GPU_FRAMEBUFFER_NATIVE_HEIGHT * OGLMaxMultisamplesScaleLimit_Tier3) )
{
maxMultisamples = OGLMaxMultisamples_Tier3;
} }
else else
{ {
maxMultisamples = OGLMaxMultisamples_Tier4; // Ensure that workingMultisamples is a power-of-two, which is what OpenGL likes.
//
// If workingMultisamples is not a power-of-two, then workingMultisamples is
// increased to the next largest power-of-two.
workingMultisamples--;
workingMultisamples |= workingMultisamples >> 1;
workingMultisamples |= workingMultisamples >> 2;
workingMultisamples |= workingMultisamples >> 4;
workingMultisamples |= workingMultisamples >> 8;
workingMultisamples |= workingMultisamples >> 16;
workingMultisamples++;
} }
if (deviceMultisamples > maxMultisamples) if (deviceMultisamples > workingMultisamples)
{ {
deviceMultisamples = maxMultisamples; deviceMultisamples = workingMultisamples;
} }
return deviceMultisamples; return deviceMultisamples;
@ -1945,7 +1949,16 @@ Render3DError OpenGLRenderer::DrawOtherPolygon(const GLenum polyPrimitive, const
Render3DError OpenGLRenderer::ApplyRenderingSettings(const GFX3D_State &renderState) Render3DError OpenGLRenderer::ApplyRenderingSettings(const GFX3D_State &renderState)
{ {
this->_enableMultisampledRendering = (CommonSettings.GFX3D_Renderer_Multisample && this->isMultisampledFBOSupported); int oldSelectedMultisampleSize = this->_selectedMultisampleSize;
this->_selectedMultisampleSize = CommonSettings.GFX3D_Renderer_MultisampleSize;
this->_enableMultisampledRendering = ((this->_selectedMultisampleSize >= 2) && this->isMultisampledFBOSupported);
if (this->_selectedMultisampleSize != oldSelectedMultisampleSize)
{
GLsizei sampleSize = this->GetLimitedMultisampleSize();
this->ResizeMultisampledFBOs(sampleSize);
}
return Render3D::ApplyRenderingSettings(renderState); return Render3D::ApplyRenderingSettings(renderState);
} }
@ -2169,6 +2182,8 @@ Render3DError OpenGLRenderer_1_2::InitExtensions()
INFO("OpenGL: FBOs are unsupported. Some emulation features will be disabled.\n"); INFO("OpenGL: FBOs are unsupported. Some emulation features will be disabled.\n");
} }
this->_selectedMultisampleSize = CommonSettings.GFX3D_Renderer_MultisampleSize;
// Don't use ARB versions since we're using the EXT versions for backwards compatibility. // Don't use ARB versions since we're using the EXT versions for backwards compatibility.
this->isMultisampledFBOSupported = this->isFBOSupported && this->isMultisampledFBOSupported = this->isFBOSupported &&
this->IsExtensionPresent(&oglExtensionSet, "GL_EXT_framebuffer_multisample"); this->IsExtensionPresent(&oglExtensionSet, "GL_EXT_framebuffer_multisample");
@ -2178,15 +2193,31 @@ Render3DError OpenGLRenderer_1_2::InitExtensions()
glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamplesOGL); glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamplesOGL);
this->_deviceInfo.maxSamples = (u8)maxSamplesOGL; this->_deviceInfo.maxSamples = (u8)maxSamplesOGL;
if (maxSamplesOGL >= 2) if (this->_deviceInfo.maxSamples >= 2)
{ {
// Try and initialize the multisampled FBOs with the GFX3D_Renderer_MultisampleSize.
// However, if the client has this set to 0, then set sampleSize to 2 in order to
// force the generation and the attachments of the buffers at a meaningful sample
// size. If GFX3D_Renderer_MultisampleSize is 0, then we can deallocate the buffer
// memory afterwards.
GLsizei sampleSize = this->GetLimitedMultisampleSize(); GLsizei sampleSize = this->GetLimitedMultisampleSize();
if (sampleSize == 0)
{
sampleSize = 2;
}
error = this->CreateMultisampledFBO(sampleSize); error = this->CreateMultisampledFBO(sampleSize);
if (error != OGLERROR_NOERR) if (error != OGLERROR_NOERR)
{ {
this->isMultisampledFBOSupported = false; this->isMultisampledFBOSupported = false;
} }
// If GFX3D_Renderer_MultisampleSize is 0, then we can deallocate the buffers now
// in order to save some memory.
if (this->_selectedMultisampleSize == 0)
{
this->ResizeMultisampledFBOs(0);
}
} }
else else
{ {
@ -2207,7 +2238,7 @@ Render3DError OpenGLRenderer_1_2::InitExtensions()
this->_deviceInfo.isFogSupported = (this->isShaderSupported && this->isVBOSupported && this->isFBOSupported); this->_deviceInfo.isFogSupported = (this->isShaderSupported && this->isVBOSupported && this->isFBOSupported);
this->_deviceInfo.isTextureSmoothingSupported = this->isShaderSupported; this->_deviceInfo.isTextureSmoothingSupported = this->isShaderSupported;
this->_enableMultisampledRendering = (CommonSettings.GFX3D_Renderer_Multisample && this->isMultisampledFBOSupported); this->_enableMultisampledRendering = ((this->_selectedMultisampleSize >= 2) && this->isMultisampledFBOSupported);
this->InitFinalRenderStates(&oglExtensionSet); // This must be done last this->InitFinalRenderStates(&oglExtensionSet); // This must be done last
@ -2956,6 +2987,38 @@ void OpenGLRenderer_1_2::DestroyMultisampledFBO()
this->isMultisampledFBOSupported = false; this->isMultisampledFBOSupported = false;
} }
void OpenGLRenderer_1_2::ResizeMultisampledFBOs(GLsizei numSamples)
{
OGLRenderRef &OGLRef = *this->ref;
GLsizei w = this->_framebufferWidth;
GLsizei h = this->_framebufferHeight;
if ( !this->isMultisampledFBOSupported ||
(numSamples == 1) ||
(w < GPU_FRAMEBUFFER_NATIVE_WIDTH) || (h < GPU_FRAMEBUFFER_NATIVE_HEIGHT) )
{
return;
}
if (numSamples == 0)
{
w = 0;
h = 0;
numSamples = 2;
}
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGColorID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, numSamples, GL_RGBA, w, h);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGPolyID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, numSamples, GL_RGBA, w, h);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGFogAttrID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, numSamples, GL_RGBA, w, h);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGDepthStencilID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, numSamples, GL_DEPTH24_STENCIL8_EXT, w, h);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGDepthStencilAlphaID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, numSamples, GL_DEPTH24_STENCIL8_EXT, w, h);
}
Render3DError OpenGLRenderer_1_2::InitFinalRenderStates(const std::set<std::string> *oglExtensionSet) Render3DError OpenGLRenderer_1_2::InitFinalRenderStates(const std::set<std::string> *oglExtensionSet)
{ {
OGLRenderRef &OGLRef = *this->ref; OGLRenderRef &OGLRef = *this->ref;
@ -4900,23 +4963,10 @@ Render3DError OpenGLRenderer_1_2::SetFramebufferSize(size_t w, size_t h)
this->_framebufferPixCount = w * h; this->_framebufferPixCount = w * h;
this->_framebufferColorSizeBytes = newFramebufferColorSizeBytes; this->_framebufferColorSizeBytes = newFramebufferColorSizeBytes;
if (this->isMultisampledFBOSupported) // Call ResizeMultisampledFBOs() after _framebufferWidth and _framebufferHeight are set
{ // since this method depends on them.
// Call GetLimitedMultisampleSize() after _framebufferWidth and _framebufferHeight are set GLsizei sampleSize = this->GetLimitedMultisampleSize();
// since this method depends on them. this->ResizeMultisampledFBOs(sampleSize);
GLsizei sampleSize = this->GetLimitedMultisampleSize();
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGColorID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleSize, GL_RGBA, w, h);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGPolyID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleSize, GL_RGBA, w, h);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGFogAttrID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleSize, GL_RGBA, w, h);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGDepthStencilID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleSize, GL_DEPTH24_STENCIL8_EXT, w, h);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMSGDepthStencilAlphaID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleSize, GL_DEPTH24_STENCIL8_EXT, w, h);
}
if (this->isPBOSupported) if (this->isPBOSupported)
{ {

View File

@ -1,7 +1,7 @@
/* /*
Copyright (C) 2006 yopyop Copyright (C) 2006 yopyop
Copyright (C) 2006-2007 shash Copyright (C) 2006-2007 shash
Copyright (C) 2008-2017 DeSmuME team Copyright (C) 2008-2018 DeSmuME team
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -282,21 +282,6 @@ EXTERNOGLEXT(PFNGLTEXBUFFERPROC, glTexBuffer) // Core in v3.1
#define OGLRENDER_VERT_INDEX_BUFFER_COUNT (POLYLIST_SIZE * 6) #define OGLRENDER_VERT_INDEX_BUFFER_COUNT (POLYLIST_SIZE * 6)
enum OGLMaxMultisamples
{
OGLMaxMultisamples_Tier1 = 32,
OGLMaxMultisamples_Tier2 = 16,
OGLMaxMultisamples_Tier3 = 8,
OGLMaxMultisamples_Tier4 = 4,
};
enum OGLMaxMultisamplesScaleLimit
{
OGLMaxMultisamplesScaleLimit_Tier1 = 1,
OGLMaxMultisamplesScaleLimit_Tier2 = 4,
OGLMaxMultisamplesScaleLimit_Tier3 = 8
};
enum OGLVertexAttributeID enum OGLVertexAttributeID
{ {
OGLVertexAttributeID_Position = 0, OGLVertexAttributeID_Position = 0,
@ -534,7 +519,7 @@ struct OGLRenderRef
// Client-side Buffers // Client-side Buffers
GLfloat *color4fBuffer; GLfloat *color4fBuffer;
GLushort *vertIndexBuffer; GLushort *vertIndexBuffer;
CACHE_ALIGN GLushort workingCIColorBuffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT]; CACHE_ALIGN GLushort workingCIColorBuffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT];
CACHE_ALIGN GLuint workingCIDepthStencilBuffer[2][GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT]; CACHE_ALIGN GLuint workingCIDepthStencilBuffer[2][GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT];
CACHE_ALIGN GLuint workingCIFogAttributesBuffer[2][GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT]; CACHE_ALIGN GLuint workingCIFogAttributesBuffer[2][GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT];
@ -617,15 +602,15 @@ public:
void SetDeposterizeBuffer(void *dstBuffer, void *workingBuffer); void SetDeposterizeBuffer(void *dstBuffer, void *workingBuffer);
void SetUpscalingBuffer(void *upscaleBuffer); void SetUpscalingBuffer(void *upscaleBuffer);
}; };
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX2)
class OpenGLRenderer : public Render3D_AVX2 class OpenGLRenderer : public Render3D_AVX2
#elif defined(ENABLE_SSE2) #elif defined(ENABLE_SSE2)
class OpenGLRenderer : public Render3D_SSE2 class OpenGLRenderer : public Render3D_SSE2
#elif defined(ENABLE_ALTIVEC) #elif defined(ENABLE_ALTIVEC)
class OpenGLRenderer : public Render3D_Altivec class OpenGLRenderer : public Render3D_Altivec
#else #else
class OpenGLRenderer : public Render3D class OpenGLRenderer : public Render3D
#endif #endif
{ {
private: private:
@ -662,7 +647,8 @@ protected:
size_t _currentPolyIndex; size_t _currentPolyIndex;
OGLTextureUnitID _lastTextureDrawTarget; OGLTextureUnitID _lastTextureDrawTarget;
bool _enableMultisampledRendering; bool _enableMultisampledRendering;
int _selectedMultisampleSize;
size_t _clearImageIndex; size_t _clearImageIndex;
Render3DError FlushFramebuffer(const FragmentColor *__restrict srcFramebuffer, FragmentColor *__restrict dstFramebufferMain, u16 *__restrict dstFramebuffer16); Render3DError FlushFramebuffer(const FragmentColor *__restrict srcFramebuffer, FragmentColor *__restrict dstFramebufferMain, u16 *__restrict dstFramebuffer16);
@ -680,6 +666,7 @@ protected:
virtual void DestroyFBOs() = 0; virtual void DestroyFBOs() = 0;
virtual Render3DError CreateMultisampledFBO(GLsizei numSamples) = 0; virtual Render3DError CreateMultisampledFBO(GLsizei numSamples) = 0;
virtual void DestroyMultisampledFBO() = 0; virtual void DestroyMultisampledFBO() = 0;
virtual void ResizeMultisampledFBOs(GLsizei numSamples) = 0;
virtual Render3DError InitGeometryProgram(const char *geometryVtxShaderCString, const char *geometryFragShaderCString, virtual Render3DError InitGeometryProgram(const char *geometryVtxShaderCString, const char *geometryFragShaderCString,
const char *geometryAlphaVtxShaderCString, const char *geometryAlphaFragShaderCString, const char *geometryAlphaVtxShaderCString, const char *geometryAlphaFragShaderCString,
const char *geometryMSAlphaVtxShaderCString, const char *geometryMSAlphaFragShaderCString) = 0; const char *geometryMSAlphaVtxShaderCString, const char *geometryMSAlphaFragShaderCString) = 0;
@ -751,6 +738,7 @@ protected:
virtual void DestroyFBOs(); virtual void DestroyFBOs();
virtual Render3DError CreateMultisampledFBO(GLsizei numSamples); virtual Render3DError CreateMultisampledFBO(GLsizei numSamples);
virtual void DestroyMultisampledFBO(); virtual void DestroyMultisampledFBO();
virtual void ResizeMultisampledFBOs(GLsizei numSamples);
virtual Render3DError CreateVAOs(); virtual Render3DError CreateVAOs();
virtual void DestroyVAOs(); virtual void DestroyVAOs();
virtual Render3DError InitFinalRenderStates(const std::set<std::string> *oglExtensionSet); virtual Render3DError InitFinalRenderStates(const std::set<std::string> *oglExtensionSet);

View File

@ -699,20 +699,37 @@ Render3DError OpenGLRenderer_3_2::InitExtensions()
} }
this->isMultisampledFBOSupported = true; this->isMultisampledFBOSupported = true;
this->_selectedMultisampleSize = CommonSettings.GFX3D_Renderer_MultisampleSize;
GLint maxSamplesOGL = 0; GLint maxSamplesOGL = 0;
glGetIntegerv(GL_MAX_SAMPLES, &maxSamplesOGL); glGetIntegerv(GL_MAX_SAMPLES, &maxSamplesOGL);
this->_deviceInfo.maxSamples = (u8)maxSamplesOGL; this->_deviceInfo.maxSamples = (u8)maxSamplesOGL;
if (maxSamplesOGL >= 2) if (this->_deviceInfo.maxSamples >= 2)
{ {
// Try and initialize the multisampled FBOs with the GFX3D_Renderer_MultisampleSize.
// However, if the client has this set to 0, then set sampleSize to 2 in order to
// force the generation and the attachments of the buffers at a meaningful sample
// size. If GFX3D_Renderer_MultisampleSize is 0, then we can deallocate the buffer
// memory afterwards.
GLsizei sampleSize = this->GetLimitedMultisampleSize(); GLsizei sampleSize = this->GetLimitedMultisampleSize();
if (sampleSize == 0)
{
sampleSize = 2;
}
error = this->CreateMultisampledFBO(sampleSize); error = this->CreateMultisampledFBO(sampleSize);
if (error != OGLERROR_NOERR) if (error != OGLERROR_NOERR)
{ {
this->isMultisampledFBOSupported = false; this->isMultisampledFBOSupported = false;
} }
// If GFX3D_Renderer_MultisampleSize is 0, then we can deallocate the buffers now
// in order to save some memory.
if (this->_selectedMultisampleSize == 0)
{
this->ResizeMultisampledFBOs(0);
}
} }
else else
{ {
@ -720,7 +737,7 @@ Render3DError OpenGLRenderer_3_2::InitExtensions()
INFO("OpenGL: Driver does not support at least 2x multisampled FBOs.\n"); INFO("OpenGL: Driver does not support at least 2x multisampled FBOs.\n");
} }
this->_enableMultisampledRendering = (CommonSettings.GFX3D_Renderer_Multisample && this->isMultisampledFBOSupported); this->_enableMultisampledRendering = ((this->_selectedMultisampleSize >= 2) && this->isMultisampledFBOSupported);
this->InitFinalRenderStates(&oglExtensionSet); // This must be done last this->InitFinalRenderStates(&oglExtensionSet); // This must be done last
@ -1140,6 +1157,47 @@ void OpenGLRenderer_3_2::DestroyMultisampledFBO()
this->isMultisampledFBOSupported = false; this->isMultisampledFBOSupported = false;
} }
void OpenGLRenderer_3_2::ResizeMultisampledFBOs(GLsizei numSamples)
{
OGLRenderRef &OGLRef = *this->ref;
GLsizei w = this->_framebufferWidth;
GLsizei h = this->_framebufferHeight;
if ( !this->isMultisampledFBOSupported ||
(numSamples == 1) ||
(w < GPU_FRAMEBUFFER_NATIVE_WIDTH) || (h < GPU_FRAMEBUFFER_NATIVE_HEIGHT) )
{
return;
}
if (numSamples == 0)
{
w = 0;
h = 0;
numSamples = 2;
}
if (this->willUsePerSampleZeroDstPass)
{
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGColorID);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, GL_RGBA, w, h, GL_TRUE);
}
else
{
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGColorID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, numSamples, GL_RGBA, w, h);
}
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGPolyID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, numSamples, GL_RGBA, w, h);
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGFogAttrID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, numSamples, GL_RGBA, w, h);
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGDepthStencilID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, numSamples, GL_DEPTH24_STENCIL8, w, h);
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGDepthStencilAlphaID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, numSamples, GL_DEPTH24_STENCIL8, w, h);
}
Render3DError OpenGLRenderer_3_2::CreateVAOs() Render3DError OpenGLRenderer_3_2::CreateVAOs()
{ {
OGLRenderRef &OGLRef = *this->ref; OGLRenderRef &OGLRef = *this->ref;
@ -2041,32 +2099,10 @@ Render3DError OpenGLRenderer_3_2::SetFramebufferSize(size_t w, size_t h)
this->_framebufferColorSizeBytes = newFramebufferColorSizeBytes; this->_framebufferColorSizeBytes = newFramebufferColorSizeBytes;
this->_framebufferColor = NULL; // Don't need to make a client-side buffer since we will be reading directly from the PBO. this->_framebufferColor = NULL; // Don't need to make a client-side buffer since we will be reading directly from the PBO.
if (this->isMultisampledFBOSupported) // Call ResizeMultisampledFBOs() after _framebufferWidth and _framebufferHeight are set
{ // since this method depends on them.
// Call GetLimitedMultisampleSize() after _framebufferWidth and _framebufferHeight are set GLsizei sampleSize = this->GetLimitedMultisampleSize();
// since this method depends on them. this->ResizeMultisampledFBOs(sampleSize);
GLsizei sampleSize = this->GetLimitedMultisampleSize();
if (this->willUsePerSampleZeroDstPass)
{
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGColorID);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleSize, GL_RGBA, w, h, GL_TRUE);
}
else
{
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGColorID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleSize, GL_RGBA, w, h);
}
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGPolyID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleSize, GL_RGBA, w, h);
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGFogAttrID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleSize, GL_RGBA, w, h);
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGDepthStencilID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleSize, GL_DEPTH24_STENCIL8, w, h);
glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMSGDepthStencilAlphaID);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleSize, GL_DEPTH24_STENCIL8, w, h);
}
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthStencilAlphaID); glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthStencilAlphaID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, w, h, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, w, h, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);

View File

@ -73,6 +73,7 @@ protected:
virtual void DestroyFBOs(); virtual void DestroyFBOs();
virtual Render3DError CreateMultisampledFBO(GLsizei numSamples); virtual Render3DError CreateMultisampledFBO(GLsizei numSamples);
virtual void DestroyMultisampledFBO(); virtual void DestroyMultisampledFBO();
virtual void ResizeMultisampledFBOs(GLsizei numSamples);
virtual Render3DError CreateVAOs(); virtual Render3DError CreateVAOs();
virtual void DestroyVAOs(); virtual void DestroyVAOs();