1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Use glTexStorage2DMultisample instead of glTexImage2DMultisample for OpenGL.

The same code with GLES3X.
This commit is contained in:
Sergey Lipskiy 2016-11-13 11:42:14 +07:00
parent 8a92860271
commit 263ddf4baa
5 changed files with 7 additions and 17 deletions

View File

@ -145,11 +145,7 @@ void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture
#ifdef GL_MULTISAMPLING_SUPPORT
if (_multisample) {
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _pTexture->glName);
#if defined(GLES3_1)
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, GL_DEPTH_COMPONENT24, _pTexture->realWidth, _pTexture->realHeight, false);
#else
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, GL_DEPTH_COMPONENT, _pTexture->realWidth, _pTexture->realHeight, false);
#endif
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, fboFormats.depthInternalFormat, _pTexture->realWidth, _pTexture->realHeight, false);
_pTexture->frameBufferTexture = CachedTexture::fbMultiSample;
} else
#endif // GL_MULTISAMPLING_SUPPORT

View File

@ -141,17 +141,10 @@ void FrameBuffer::init(u32 _address, u32 _endAddress, u16 _format, u16 _size, u1
#ifdef GL_MULTISAMPLING_SUPPORT
if (config.video.multisampling != 0) {
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_pTexture->glName);
#if defined(GLES3_1)
if (_size > G_IM_SIZ_8b)
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, GL_RGBA8, m_pTexture->realWidth, m_pTexture->realHeight, false);
else
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, fboFormats.monochromeInternalFormat, m_pTexture->realWidth, m_pTexture->realHeight, false);
#else
if (_size > G_IM_SIZ_8b)
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, GL_RGBA8, m_pTexture->realWidth, m_pTexture->realHeight, false);
else
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, fboFormats.monochromeInternalFormat, m_pTexture->realWidth, m_pTexture->realHeight, false);
#endif
m_pTexture->frameBufferTexture = CachedTexture::fbMultiSample;
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_pTexture->glName, 0);

View File

@ -489,13 +489,8 @@ void TextureCache::init()
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_pMSDummy->glName);
#if defined(GLES3_1)
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling,
GL_RGBA8, m_pMSDummy->realWidth, m_pMSDummy->realHeight, false);
#else
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling,
GL_RGBA8, m_pMSDummy->realWidth, m_pMSDummy->realHeight, false);
#endif
activateMSDummy(0);
activateMSDummy(1);

View File

@ -84,6 +84,7 @@ PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
PFNGLTEXSTORAGE2DMULTISAMPLEPROC glTexStorage2DMultisample;
PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
@ -190,6 +191,10 @@ void initGLFunctions()
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)glGetProcAddress( "glGenFramebuffers" );
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)glGetProcAddress( "glFramebufferTexture2D" );
glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)glGetProcAddress("glTexImage2DMultisample");
glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC)glGetProcAddress("glTexStorage2DMultisample");
if (glTexStorage2DMultisample == nullptr)
// Dirty hack to enable MSAA for GL below 4.3
glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC)glTexImage2DMultisample;
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)glGetProcAddress( "glGenRenderbuffers" );
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)glGetProcAddress( "glBindRenderbuffer" );
glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)glGetProcAddress( "glRenderbufferStorage" );

View File

@ -74,6 +74,7 @@ extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
extern PFNGLTEXSTORAGE2DMULTISAMPLEPROC glTexStorage2DMultisample;
extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;