diff --git a/projects/msvc12/GLideN64.vcxproj b/projects/msvc12/GLideN64.vcxproj index e0497820..e3e5d7c7 100644 --- a/projects/msvc12/GLideN64.vcxproj +++ b/projects/msvc12/GLideN64.vcxproj @@ -285,7 +285,6 @@ - @@ -427,7 +426,6 @@ - diff --git a/projects/msvc12/GLideN64.vcxproj.filters b/projects/msvc12/GLideN64.vcxproj.filters index ee909d79..01910819 100644 --- a/projects/msvc12/GLideN64.vcxproj.filters +++ b/projects/msvc12/GLideN64.vcxproj.filters @@ -236,9 +236,6 @@ Source Files\DepthBufferRender - - Source Files - Source Files @@ -508,9 +505,6 @@ Header Files\DepthBufferRender - - Header Files - Header Files diff --git a/src/BufferCopy/ColorBufferToRDRAM.cpp b/src/BufferCopy/ColorBufferToRDRAM.cpp index f65218f2..7ef14500 100644 --- a/src/BufferCopy/ColorBufferToRDRAM.cpp +++ b/src/BufferCopy/ColorBufferToRDRAM.cpp @@ -4,7 +4,6 @@ #include "ColorBufferToRDRAM.h" #include "WriteToRDRAM.h" -#include #include #include #include @@ -76,13 +75,14 @@ void ColorBufferToRDRAM::_initFBTexture(void) textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); { + const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); graphics::Context::InitTextureParams params; params.handle = graphics::ObjectHandle(m_pTexture->glName); params.width = m_pTexture->realWidth; params.height = m_pTexture->realHeight; - params.internalFormat = fboFormats.colorInternalFormat; - params.format = fboFormats.colorFormat; - params.dataType = fboFormats.colorType; + params.internalFormat = fbTexFormat.colorInternalFormat; + params.format = fbTexFormat.colorFormat; + params.dataType = fbTexFormat.colorType; gfxContext.init2DTexture(params); } { @@ -153,7 +153,7 @@ bool ColorBufferToRDRAM::_prepareCopy(u32 _startAddress) m_lastBufferWidth = pBuffer->m_width; m_lastBufferHeight = pBuffer->m_height; _initFBTexture(); - m_pixelData.resize(m_pTexture->realWidth * m_pTexture->realHeight * fboFormats.colorFormatBytes); + m_pixelData.resize(m_pTexture->realWidth * m_pTexture->realHeight * gfxContext.getFramebufferTextureFormats().colorFormatBytes); } m_pCurFrameBuffer = pBuffer; diff --git a/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.cpp b/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.cpp index e1958913..a5ed7f6a 100644 --- a/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.cpp +++ b/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #if defined(EGL) || defined(GLESX) #include @@ -54,15 +54,16 @@ void ColorBufferToRDRAM_BufferStorageExt::_destroyBuffers(void) bool ColorBufferToRDRAM_BufferStorageExt::_readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) { + const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); GLenum colorFormat, colorType, colorFormatBytes; if (_size > G_IM_SIZ_8b) { - colorFormat = fboFormats.colorFormat; - colorType = fboFormats.colorType; - colorFormatBytes = fboFormats.colorFormatBytes; + colorFormat = GLenum(fbTexFormat.colorFormat); + colorType = GLenum(fbTexFormat.colorType); + colorFormatBytes = GLenum(fbTexFormat.colorFormatBytes); } else { - colorFormat = fboFormats.monochromeFormat; - colorType = fboFormats.monochromeType; - colorFormatBytes = fboFormats.monochromeFormatBytes; + colorFormat = GLenum(fbTexFormat.monochromeFormat); + colorType = GLenum(fbTexFormat.monochromeType); + colorFormatBytes = GLenum(fbTexFormat.monochromeFormatBytes); } glBindBuffer(GL_PIXEL_PACK_BUFFER, m_PBO[m_curIndex]); diff --git a/src/BufferCopy/ColorBufferToRDRAM_GL.cpp b/src/BufferCopy/ColorBufferToRDRAM_GL.cpp index d778ec63..b6b7280f 100644 --- a/src/BufferCopy/ColorBufferToRDRAM_GL.cpp +++ b/src/BufferCopy/ColorBufferToRDRAM_GL.cpp @@ -1,5 +1,5 @@ #include "ColorBufferToRDRAM.h" -#include +#include #include "ColorBufferToRDRAM_GL.h" ColorBufferToRDRAM_GL::ColorBufferToRDRAM_GL() @@ -38,15 +38,16 @@ void ColorBufferToRDRAM_GL::_initBuffers(void) bool ColorBufferToRDRAM_GL::_readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) { + const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); GLenum colorFormat, colorType, colorFormatBytes; if (_size > G_IM_SIZ_8b) { - colorFormat = fboFormats.colorFormat; - colorType = fboFormats.colorType; - colorFormatBytes = fboFormats.colorFormatBytes; + colorFormat = GLenum(fbTexFormat.colorFormat); + colorType = GLenum(fbTexFormat.colorType); + colorFormatBytes = GLenum(fbTexFormat.colorFormatBytes); } else { - colorFormat = fboFormats.monochromeFormat; - colorType = fboFormats.monochromeType; - colorFormatBytes = fboFormats.monochromeFormatBytes; + colorFormat = GLenum(fbTexFormat.monochromeFormat); + colorType = GLenum(fbTexFormat.monochromeType); + colorFormatBytes = GLenum(fbTexFormat.monochromeFormatBytes); } // If Sync, read pixels from the buffer, copy them to RDRAM. diff --git a/src/BufferCopy/ColorBufferToRDRAM_GL.h b/src/BufferCopy/ColorBufferToRDRAM_GL.h index c1cf764c..79113ca3 100644 --- a/src/BufferCopy/ColorBufferToRDRAM_GL.h +++ b/src/BufferCopy/ColorBufferToRDRAM_GL.h @@ -1,7 +1,6 @@ #include "ColorBufferToRDRAM.h" #include -#include class ColorBufferToRDRAM_GL : public ColorBufferToRDRAM { diff --git a/src/BufferCopy/DepthBufferToRDRAM.cpp b/src/BufferCopy/DepthBufferToRDRAM.cpp index 3138e483..b73f577e 100644 --- a/src/BufferCopy/DepthBufferToRDRAM.cpp +++ b/src/BufferCopy/DepthBufferToRDRAM.cpp @@ -5,7 +5,6 @@ #include "DepthBufferToRDRAM.h" #include "WriteToRDRAM.h" -#include #include #include #include @@ -68,13 +67,14 @@ void DepthBufferToRDRAM::init() m_pDepthTexture->textureBytes = m_pDepthTexture->realWidth * m_pDepthTexture->realHeight * sizeof(float); textureCache().addFrameBufferTextureSize(m_pDepthTexture->textureBytes); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); graphics::Context::InitTextureParams initParams; initParams.handle = graphics::ObjectHandle(m_pColorTexture->glName); initParams.width = m_pColorTexture->realWidth; initParams.height = m_pColorTexture->realHeight; - initParams.internalFormat = fboFormats.monochromeInternalFormat; - initParams.format = fboFormats.monochromeFormat; - initParams.dataType = fboFormats.monochromeType; + initParams.internalFormat = fbTexFormats.monochromeInternalFormat; + initParams.format = fbTexFormats.monochromeFormat; + initParams.dataType = fbTexFormats.monochromeType; gfxContext.init2DTexture(initParams); graphics::Context::TexParameters setParams; @@ -88,9 +88,9 @@ void DepthBufferToRDRAM::init() initParams.handle = graphics::ObjectHandle(m_pDepthTexture->glName); initParams.width = m_pDepthTexture->realWidth; initParams.height = m_pDepthTexture->realHeight; - initParams.internalFormat = fboFormats.depthInternalFormat; - initParams.format = fboFormats.depthFormat; - initParams.dataType = fboFormats.depthType; + initParams.internalFormat = fbTexFormats.depthInternalFormat; + initParams.format = fbTexFormats.depthFormat; + initParams.dataType = fbTexFormats.depthType; gfxContext.init2DTexture(initParams); setParams.handle = graphics::ObjectHandle(m_pDepthTexture->glName); @@ -211,9 +211,10 @@ bool DepthBufferToRDRAM::_copy(u32 _startAddress, u32 _endAddress) PBOBinder binder(GL_PIXEL_PACK_BUFFER, m_PBO); glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); - glReadPixels(x0, y0, width, height, fboFormats.depthFormat, fboFormats.depthType, 0); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); + glReadPixels(x0, y0, width, height, GLenum(fbTexFormats.depthFormat), GLenum(fbTexFormats.depthType), 0); - GLubyte* pixelData = (GLubyte*)glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, width * height * fboFormats.depthFormatBytes, GL_MAP_READ_BIT); + GLubyte* pixelData = (GLubyte*)glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, width * height * fbTexFormats.depthFormatBytes, GL_MAP_READ_BIT); if (pixelData == nullptr) return false; diff --git a/src/BufferCopy/RDRAMtoColorBuffer.cpp b/src/BufferCopy/RDRAMtoColorBuffer.cpp index 83fc05ab..21e8f741 100644 --- a/src/BufferCopy/RDRAMtoColorBuffer.cpp +++ b/src/BufferCopy/RDRAMtoColorBuffer.cpp @@ -1,6 +1,5 @@ #include "RDRAMtoColorBuffer.h" -#include #include #include #include @@ -40,13 +39,14 @@ void RDRAMtoColorBuffer::init() m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight * 4; textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); graphics::Context::InitTextureParams initParams; initParams.handle = graphics::ObjectHandle(m_pTexture->glName); initParams.width = m_pTexture->realWidth; initParams.height = m_pTexture->realHeight; - initParams.internalFormat = fboFormats.colorInternalFormat; - initParams.format = fboFormats.colorFormat; - initParams.dataType = fboFormats.colorType; + initParams.internalFormat = fbTexFormats.colorInternalFormat; + initParams.format = fbTexFormats.colorFormat; + initParams.dataType = fbTexFormats.colorType; gfxContext.init2DTexture(initParams); graphics::Context::TexParameters setParams; @@ -254,10 +254,11 @@ void RDRAMtoColorBuffer::copyFromRDRAM(u32 _address, bool _bCFB) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBindTexture(GL_TEXTURE_2D, m_pTexture->glName); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); #ifndef GLES2 - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, fboFormats.colorFormat, fboFormats.colorType, 0); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GLenum(fbTexFormats.colorFormat), GLenum(fbTexFormats.colorType), 0); #else - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, fboFormats.colorFormat, fboFormats.colorType, ptr); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GLenum(fbTexFormats.colorFormat), GLenum(fbTexFormats.colorType), ptr); #endif m_pTexture->scaleS = 1.0f / (float)m_pTexture->realWidth; diff --git a/src/DepthBuffer.cpp b/src/DepthBuffer.cpp index f4fd3738..f8cfbcc8 100644 --- a/src/DepthBuffer.cpp +++ b/src/DepthBuffer.cpp @@ -11,7 +11,6 @@ #include "VI.h" #include "Config.h" #include "Debug.h" -#include "FBOTextureFormats.h" #include #include @@ -66,6 +65,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer) if (!video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0 || m_pDepthImageTexture != nullptr) return; + const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); m_pDepthImageTexture = textureCache().addFrameBufferTexture(false); m_pDepthImageTexture->width = (u32)(_pBuffer->m_pTexture->width); @@ -84,7 +84,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer) m_pDepthImageTexture->mirrorT = 0; m_pDepthImageTexture->realWidth = m_pDepthImageTexture->width; m_pDepthImageTexture->realHeight = m_pDepthImageTexture->height; - m_pDepthImageTexture->textureBytes = m_pDepthImageTexture->realWidth * m_pDepthImageTexture->realHeight * fboFormats.depthImageFormatBytes; + m_pDepthImageTexture->textureBytes = m_pDepthImageTexture->realWidth * m_pDepthImageTexture->realHeight * fbTexFormat.depthImageFormatBytes; textureCache().addFrameBufferTextureSize(m_pDepthImageTexture->textureBytes); { @@ -92,9 +92,9 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer) params.handle = graphics::ObjectHandle(m_pDepthImageTexture->glName); params.width = m_pDepthImageTexture->realWidth; params.height = m_pDepthImageTexture->realHeight; - params.internalFormat = fboFormats.depthImageInternalFormat; - params.format = fboFormats.depthImageFormat; - params.dataType = fboFormats.depthImageType; + params.internalFormat = fbTexFormat.depthImageInternalFormat; + params.format = fbTexFormat.depthImageFormat; + params.dataType = fbTexFormat.depthImageType; gfxContext.init2DTexture(params); } { @@ -125,14 +125,15 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer) void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture * _pTexture, bool _multisample) { + const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); + if (_pBuffer != nullptr) { _pTexture->width = (u32)(_pBuffer->m_pTexture->width); _pTexture->height = (u32)(_pBuffer->m_pTexture->height); _pTexture->address = _pBuffer->m_startAddress; _pTexture->clampWidth = _pBuffer->m_width; _pTexture->clampHeight = _pBuffer->m_height; - } - else { + } else { if (config.frameBufferEmulation.nativeResFactor == 0) { _pTexture->width = video().getWidth(); _pTexture->height = video().getHeight(); @@ -155,7 +156,7 @@ void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture _pTexture->mirrorT = 0; _pTexture->realWidth = _pTexture->width; _pTexture->realHeight = _pTexture->height; - _pTexture->textureBytes = _pTexture->realWidth * _pTexture->realHeight * fboFormats.depthFormatBytes; + _pTexture->textureBytes = _pTexture->realWidth * _pTexture->realHeight * fbTexFormat.depthFormatBytes; textureCache().addFrameBufferTextureSize(_pTexture->textureBytes); { @@ -164,9 +165,9 @@ void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture params.msaaLevel = _multisample ? config.video.multisampling : 0U; params.width = _pTexture->realWidth; params.height = _pTexture->realHeight; - params.internalFormat = fboFormats.depthInternalFormat; - params.format = fboFormats.depthFormat; - params.dataType = fboFormats.depthType; + params.internalFormat = fbTexFormat.depthInternalFormat; + params.format = fbTexFormat.depthFormat; + params.dataType = fbTexFormat.depthType; gfxContext.init2DTexture(params); } _pTexture->frameBufferTexture = _multisample ? CachedTexture::fbMultiSample : CachedTexture::fbOneSample; @@ -205,7 +206,7 @@ void DepthBuffer::_initDepthBufferRenderbuffer(FrameBuffer * _pBuffer) graphics::Context::InitRenderbufferParams params; params.handle = renderbufHandle; params.target = graphics::target::RENDERBUFFER; - params.format = fboFormats.depthInternalFormat; + params.format = gfxContext.getFramebufferTextureFormats().depthInternalFormat; params.width = m_depthRenderbufferWidth; params.height = height; gfxContext.initRenderbuffer(params); @@ -324,7 +325,8 @@ void DepthBuffer::activateDepthBufferTexture(FrameBuffer * _pBuffer) void DepthBuffer::bindDepthImageTexture() { #ifdef GL_IMAGE_TEXTURES_SUPPORT - glBindImageTexture(depthImageUnit, m_pDepthImageTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, fboFormats.depthImageInternalFormat); + glBindImageTexture(depthImageUnit, m_pDepthImageTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, + GLenum(gfxContext.getFramebufferTextureFormats().depthImageInternalFormat)); #endif } @@ -440,6 +442,9 @@ void DepthBufferList::clearBuffer(u32 _ulx, u32 _uly, u32 _lrx, u32 _lry) { if (m_pCurrent == nullptr) return; + + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); + m_pCurrent->m_cleared = true; m_pCurrent->m_ulx = _ulx; m_pCurrent->m_uly = _uly; @@ -449,13 +454,13 @@ void DepthBufferList::clearBuffer(u32 _ulx, u32 _uly, u32 _lrx, u32 _lry) if (m_pCurrent->m_depthImageFBO == 0 || !video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0) return; float color[4] = {1.0f, 1.0f, 0.0f, 1.0f}; - glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, fboFormats.depthImageInternalFormat); + glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GLenum(fbTexFormats.depthImageInternalFormat)); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pCurrent->m_depthImageFBO); const u32 cycleType = gDP.otherMode.cycleType; gDP.otherMode.cycleType = G_CYC_FILL; video().getRender().drawRect(_ulx, _uly, _lrx, _lry, color); gDP.otherMode.cycleType = cycleType; - glBindImageTexture(depthImageUnit, m_pCurrent->m_pDepthImageTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, fboFormats.depthImageInternalFormat); + glBindImageTexture(depthImageUnit, m_pCurrent->m_pDepthImageTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GLenum(fbTexFormats.depthImageInternalFormat)); frameBufferList().setCurrentDrawBuffer(); #endif // GL_IMAGE_TEXTURES_SUPPORT } diff --git a/src/FBOTextureFormats.cpp b/src/FBOTextureFormats.cpp deleted file mode 100644 index d07ce0c6..00000000 --- a/src/FBOTextureFormats.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "FBOTextureFormats.h" - -FBOTextureFormats fboFormats; - -void FBOTextureFormats::init() -{ -#ifdef GLES2 - monochromeInternalFormat = GL_RGB; - monochromeFormat = GL_RGB; - monochromeType = GL_UNSIGNED_SHORT_5_6_5; - monochromeFormatBytes = 2; - -#ifndef USE_DEPTH_RENDERBUFFER - depthInternalFormat = GL_DEPTH_COMPONENT; - depthFormatBytes = 4; -#else - depthInternalFormat = GL_DEPTH_COMPONENT16; - depthFormatBytes = 2; -#endif - - depthFormat = GL_DEPTH_COMPONENT; - depthType = GL_UNSIGNED_INT; - - if (OGLVideo::isExtensionSupported("GL_OES_rgb8_rgba8")) { - colorInternalFormat = GL_RGBA; - colorFormat = GL_RGBA; - colorType = GL_UNSIGNED_BYTE; - colorFormatBytes = 4; - } else { - colorInternalFormat = GL_RGB; - colorFormat = GL_RGB; - colorType = GL_UNSIGNED_SHORT_5_6_5; - colorFormatBytes = 2; - } -#elif defined(GLES3) || defined (GLES3_1) - colorInternalFormat = GL_RGBA8; - colorFormat = GL_RGBA; - colorType = GL_UNSIGNED_BYTE; - colorFormatBytes = 4; - - monochromeInternalFormat = GL_R8; - monochromeFormat = GL_RED; - monochromeType = GL_UNSIGNED_BYTE; - monochromeFormatBytes = 1; - - depthInternalFormat = GL_DEPTH_COMPONENT24; - depthFormat = GL_DEPTH_COMPONENT; - depthType = GL_UNSIGNED_INT; - depthFormatBytes = 4; - - depthImageInternalFormat = GL_RGBA32F; - depthImageFormat = GL_RGBA; - depthImageType = GL_FLOAT; - depthImageFormatBytes = 16; - - lutInternalFormat = GL_R32UI; - lutFormat = GL_RED_INTEGER; - lutType = GL_UNSIGNED_INT; - lutFormatBytes = 4; -#else - colorInternalFormat = GL_RGBA; - colorFormat = GL_RGBA; - colorType = GL_UNSIGNED_BYTE; - colorFormatBytes = 4; - - monochromeInternalFormat = GL_RED; - monochromeFormat = GL_RED; - monochromeType = GL_UNSIGNED_BYTE; - monochromeFormatBytes = 1; - - depthInternalFormat = GL_DEPTH_COMPONENT; - depthFormat = GL_DEPTH_COMPONENT; - depthType = GL_FLOAT; - depthFormatBytes = 4; - - depthImageInternalFormat = GL_RG32F; - depthImageFormat = GL_RG; - depthImageType = GL_FLOAT; - depthImageFormatBytes = 8; - - lutInternalFormat = GL_R16; - lutFormat = GL_RED; - lutType = GL_UNSIGNED_SHORT; - lutFormatBytes = 2; - -#endif -} diff --git a/src/FBOTextureFormats.h b/src/FBOTextureFormats.h deleted file mode 100644 index 7201a145..00000000 --- a/src/FBOTextureFormats.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef FBOTEXTUREFORMATS_H -#define FBOTEXTUREFORMATS_H - -#include "OpenGL.h" - -struct FBOTextureFormats -{ - GLint colorInternalFormat; - GLenum colorFormat; - GLenum colorType; - u32 colorFormatBytes; - - GLint monochromeInternalFormat; - GLenum monochromeFormat; - GLenum monochromeType; - u32 monochromeFormatBytes; - - GLint depthInternalFormat; - GLenum depthFormat; - GLenum depthType; - u32 depthFormatBytes; - - GLint depthImageInternalFormat; - GLenum depthImageFormat; - GLenum depthImageType; - u32 depthImageFormatBytes; - - GLint lutInternalFormat; - GLenum lutFormat; - GLenum lutType; - u32 lutFormatBytes; - - void init(); -}; - -extern FBOTextureFormats fboFormats; - -#endif // FBOTEXTUREFORMATS_H diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 54a39677..0518a627 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -17,7 +17,6 @@ #include "Debug.h" #include "PostProcessor.h" #include "FrameBufferInfo.h" -#include "FBOTextureFormats.h" #include "Log.h" #include "BufferCopy/ColorBufferToRDRAM.h" @@ -57,6 +56,8 @@ FrameBuffer::~FrameBuffer() void FrameBuffer::_initTexture(u16 _width, u16 _height, u16 _format, u16 _size, CachedTexture *_pTexture) { + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); + _pTexture->width = (u32)(_width * m_scaleX); _pTexture->height = (u32)(_height * m_scaleY); _pTexture->format = _format; @@ -75,15 +76,16 @@ void FrameBuffer::_initTexture(u16 _width, u16 _height, u16 _format, u16 _size, _pTexture->realHeight = _pTexture->height; _pTexture->textureBytes = _pTexture->realWidth * _pTexture->realHeight; if (_size > G_IM_SIZ_8b) - _pTexture->textureBytes *= fboFormats.colorFormatBytes; + _pTexture->textureBytes *= fbTexFormats.colorFormatBytes; else - _pTexture->textureBytes *= fboFormats.monochromeFormatBytes; + _pTexture->textureBytes *= fbTexFormats.monochromeFormatBytes; textureCache().addFrameBufferTextureSize(_pTexture->textureBytes); } void FrameBuffer::_setAndAttachTexture(u32 _fbo, CachedTexture *_pTexture, u32 _t, bool _multisampling) { { + const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); graphics::Context::InitTextureParams params; params.handle = graphics::ObjectHandle(_pTexture->glName); if (_multisampling) @@ -91,14 +93,14 @@ void FrameBuffer::_setAndAttachTexture(u32 _fbo, CachedTexture *_pTexture, u32 _ params.width = _pTexture->realWidth; params.height = _pTexture->realHeight; if (_pTexture->size > G_IM_SIZ_8b) { - params.internalFormat = fboFormats.colorInternalFormat; - params.format = fboFormats.colorFormat; - params.dataType = fboFormats.colorType; + params.internalFormat = fbTexFormat.colorInternalFormat; + params.format = fbTexFormat.colorFormat; + params.dataType = fbTexFormat.colorType; } else { - params.internalFormat = fboFormats.monochromeInternalFormat; - params.format = fboFormats.monochromeFormat; - params.dataType = fboFormats.monochromeType; + params.internalFormat = fbTexFormat.monochromeInternalFormat; + params.format = fbTexFormat.monochromeFormat; + params.dataType = fbTexFormat.monochromeType; } gfxContext.init2DTexture(params); } diff --git a/src/OpenGL.cpp b/src/OpenGL.cpp index 75d6d9af..04303139 100644 --- a/src/OpenGL.cpp +++ b/src/OpenGL.cpp @@ -24,7 +24,6 @@ #include "PostProcessor.h" #include "ShaderUtils.h" #include "SoftwareRender.h" -#include "FBOTextureFormats.h" #include "TextureFilterHandler.h" #include "NoiseTexture.h" #include "ZlutTexture.h" @@ -398,13 +397,14 @@ void OGLRender::TexrectDrawer::init() m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight * 4; textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); graphics::Context::InitTextureParams initParams; initParams.handle = graphics::ObjectHandle(m_pTexture->glName); initParams.width = m_pTexture->realWidth; initParams.height = m_pTexture->realHeight; - initParams.internalFormat = fboFormats.colorInternalFormat; - initParams.format = fboFormats.colorFormat; - initParams.dataType = fboFormats.colorType; + initParams.internalFormat = fbTexFormats.colorInternalFormat; + initParams.format = fbTexFormats.colorFormat; + initParams.dataType = fbTexFormats.colorType; gfxContext.init2DTexture(initParams); graphics::Context::TexParameters setParams; @@ -2076,8 +2076,6 @@ void OGLRender::_initExtensions() m_oglRenderer = glrAdreno; LOG(LOG_VERBOSE, "OpenGL renderer: %s\n", strRenderer); - fboFormats.init(); - GLfloat lineWidthRange[2] = {0.0f, 0.0f}; glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, lineWidthRange); m_maxLineWidth = lineWidthRange[1]; diff --git a/src/PaletteTexture.cpp b/src/PaletteTexture.cpp index 93bf5459..3afcf931 100644 --- a/src/PaletteTexture.cpp +++ b/src/PaletteTexture.cpp @@ -4,7 +4,6 @@ #include "gDP.h" #include "VI.h" #include "Textures.h" -#include "FBOTextureFormats.h" #include "PaletteTexture.h" #include "DepthBuffer.h" @@ -39,14 +38,15 @@ void PaletteTexture::init() #endif textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); graphics::Context::InitTextureParams initParams; initParams.handle = graphics::ObjectHandle(m_pTexture->glName); initParams.ImageUnit = graphics::textureImageUnits::Tlut; initParams.width = m_pTexture->realWidth; initParams.height = m_pTexture->realHeight; - initParams.internalFormat = fboFormats.lutInternalFormat; - initParams.format = fboFormats.lutFormat; - initParams.dataType = fboFormats.lutType; + initParams.internalFormat = fbTexFormats.lutInternalFormat; + initParams.format = fbTexFormats.lutFormat; + initParams.dataType = fbTexFormats.lutType; gfxContext.init2DTexture(initParams); graphics::Context::TexParameters setParams; @@ -66,7 +66,8 @@ void PaletteTexture::init() void PaletteTexture::destroy() { - glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, fboFormats.lutInternalFormat); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); + glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GLenum(fbTexFormats.lutInternalFormat)); textureCache().removeFrameBufferTexture(m_pTexture); m_pTexture = nullptr; m_pbuf.reset(); @@ -91,16 +92,17 @@ void PaletteTexture::update() palette[i] = swapword(src[i * 4]); m_pbuf->closeWriteBuffer(); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); graphics::Context::UpdateTextureDataParams params; params.handle = graphics::ObjectHandle(m_pTexture->glName); params.ImageUnit = graphics::textureImageUnits::Tlut; params.textureUnitIndex = graphics::textureIndices::PaletteTex; params.width = m_pTexture->realWidth; params.height = m_pTexture->realHeight; - params.format = fboFormats.lutFormat; - params.internalFormat = fboFormats.lutInternalFormat; - params.dataType = fboFormats.lutType; + params.format = fbTexFormats.lutFormat; + params.internalFormat = fbTexFormats.lutInternalFormat; + params.dataType = fbTexFormats.lutType; params.data = m_pbuf->getData(); - glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, fboFormats.lutInternalFormat); + glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GLenum(fbTexFormats.lutInternalFormat)); gfxContext.update2DTexture(params); } diff --git a/src/TextDrawer.cpp b/src/TextDrawer.cpp index f7c6117a..593e27f6 100644 --- a/src/TextDrawer.cpp +++ b/src/TextDrawer.cpp @@ -19,7 +19,6 @@ #include "RSP.h" #include "Config.h" #include "ShaderUtils.h" -#include #include "Log.h" #include diff --git a/src/ZlutTexture.cpp b/src/ZlutTexture.cpp index 95a81ab3..eaeafa42 100644 --- a/src/ZlutTexture.cpp +++ b/src/ZlutTexture.cpp @@ -1,6 +1,5 @@ #include "Graphics/Context.h" #include "Graphics/Parameters.h" -#include "FBOTextureFormats.h" #include "DepthBuffer.h" #include "Config.h" #include "Textures.h" @@ -41,14 +40,15 @@ void ZlutTexture::init() m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight * sizeof(zLUT[0]); textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); graphics::Context::InitTextureParams initParams; initParams.handle = graphics::ObjectHandle(m_pTexture->glName); initParams.ImageUnit = graphics::textureImageUnits::Zlut; initParams.width = m_pTexture->realWidth; initParams.height = m_pTexture->realHeight; - initParams.internalFormat = fboFormats.lutInternalFormat; - initParams.format = fboFormats.lutFormat; - initParams.dataType = fboFormats.lutType; + initParams.internalFormat = fbTexFormats.lutInternalFormat; + initParams.format = fbTexFormats.lutFormat; + initParams.dataType = fbTexFormats.lutType; initParams.data = zLUT; gfxContext.init2DTexture(initParams); @@ -64,7 +64,8 @@ void ZlutTexture::init() } void ZlutTexture::destroy() { - glBindImageTexture(ZlutImageUnit, 0, 0, GL_FALSE, GL_FALSE, GL_READ_ONLY, fboFormats.lutInternalFormat); + const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats(); + glBindImageTexture(ZlutImageUnit, 0, 0, GL_FALSE, GL_FALSE, GL_READ_ONLY, GLenum(fbTexFormats.lutInternalFormat)); textureCache().removeFrameBufferTexture(m_pTexture); m_pTexture = nullptr; }