1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Remove FBOTextureFormats usage

This commit is contained in:
Sergey Lipskiy 2017-01-14 19:26:02 +07:00
parent a30c317c4b
commit 09a5b414c4
16 changed files with 90 additions and 213 deletions

View File

@ -285,7 +285,6 @@
<ClCompile Include="..\..\src\F3DGOLDEN.cpp" /> <ClCompile Include="..\..\src\F3DGOLDEN.cpp" />
<ClCompile Include="..\..\src\F3DSETA.cpp" /> <ClCompile Include="..\..\src\F3DSETA.cpp" />
<ClCompile Include="..\..\src\F3DBETA.cpp" /> <ClCompile Include="..\..\src\F3DBETA.cpp" />
<ClCompile Include="..\..\src\FBOTextureFormats.cpp" />
<ClCompile Include="..\..\src\FrameBuffer.cpp" /> <ClCompile Include="..\..\src\FrameBuffer.cpp" />
<ClCompile Include="..\..\src\FrameBufferInfo.cpp" /> <ClCompile Include="..\..\src\FrameBufferInfo.cpp" />
<ClCompile Include="..\..\src\GBI.cpp" /> <ClCompile Include="..\..\src\GBI.cpp" />
@ -427,7 +426,6 @@
<ClInclude Include="..\..\src\F3DEX2MM.h" /> <ClInclude Include="..\..\src\F3DEX2MM.h" />
<ClInclude Include="..\..\src\F3DGOLDEN.h" /> <ClInclude Include="..\..\src\F3DGOLDEN.h" />
<ClInclude Include="..\..\src\F3DSETA.h" /> <ClInclude Include="..\..\src\F3DSETA.h" />
<ClInclude Include="..\..\src\FBOTextureFormats.h" />
<ClInclude Include="..\..\src\FrameBuffer.h" /> <ClInclude Include="..\..\src\FrameBuffer.h" />
<ClInclude Include="..\..\src\FrameBufferInfo.h" /> <ClInclude Include="..\..\src\FrameBufferInfo.h" />
<ClInclude Include="..\..\src\FrameBufferInfoAPI.h" /> <ClInclude Include="..\..\src\FrameBufferInfoAPI.h" />

View File

@ -236,9 +236,6 @@
<ClCompile Include="..\..\src\DepthBufferRender\DepthBufferRender.cpp"> <ClCompile Include="..\..\src\DepthBufferRender\DepthBufferRender.cpp">
<Filter>Source Files\DepthBufferRender</Filter> <Filter>Source Files\DepthBufferRender</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\FBOTextureFormats.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\convert.cpp"> <ClCompile Include="..\..\src\convert.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -508,9 +505,6 @@
<ClInclude Include="..\..\src\DepthBufferRender\DepthBufferRender.h"> <ClInclude Include="..\..\src\DepthBufferRender\DepthBufferRender.h">
<Filter>Header Files\DepthBufferRender</Filter> <Filter>Header Files\DepthBufferRender</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\FBOTextureFormats.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\inc\glext.h"> <ClInclude Include="..\..\src\inc\glext.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>

View File

@ -4,7 +4,6 @@
#include "ColorBufferToRDRAM.h" #include "ColorBufferToRDRAM.h"
#include "WriteToRDRAM.h" #include "WriteToRDRAM.h"
#include <FBOTextureFormats.h>
#include <FrameBuffer.h> #include <FrameBuffer.h>
#include <Config.h> #include <Config.h>
#include <N64.h> #include <N64.h>
@ -76,13 +75,14 @@ void ColorBufferToRDRAM::_initFBTexture(void)
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
{ {
const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
graphics::Context::InitTextureParams params; graphics::Context::InitTextureParams params;
params.handle = graphics::ObjectHandle(m_pTexture->glName); params.handle = graphics::ObjectHandle(m_pTexture->glName);
params.width = m_pTexture->realWidth; params.width = m_pTexture->realWidth;
params.height = m_pTexture->realHeight; params.height = m_pTexture->realHeight;
params.internalFormat = fboFormats.colorInternalFormat; params.internalFormat = fbTexFormat.colorInternalFormat;
params.format = fboFormats.colorFormat; params.format = fbTexFormat.colorFormat;
params.dataType = fboFormats.colorType; params.dataType = fbTexFormat.colorType;
gfxContext.init2DTexture(params); gfxContext.init2DTexture(params);
} }
{ {
@ -153,7 +153,7 @@ bool ColorBufferToRDRAM::_prepareCopy(u32 _startAddress)
m_lastBufferWidth = pBuffer->m_width; m_lastBufferWidth = pBuffer->m_width;
m_lastBufferHeight = pBuffer->m_height; m_lastBufferHeight = pBuffer->m_height;
_initFBTexture(); _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; m_pCurFrameBuffer = pBuffer;

View File

@ -1,6 +1,6 @@
#include <OpenGL.h> #include <OpenGL.h>
#include <Textures.h> #include <Textures.h>
#include <FBOTextureFormats.h> #include <Graphics/Context.h>
#if defined(EGL) || defined(GLESX) #if defined(EGL) || defined(GLESX)
#include <inc/ARB_buffer_storage.h> #include <inc/ARB_buffer_storage.h>
@ -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) 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; GLenum colorFormat, colorType, colorFormatBytes;
if (_size > G_IM_SIZ_8b) { if (_size > G_IM_SIZ_8b) {
colorFormat = fboFormats.colorFormat; colorFormat = GLenum(fbTexFormat.colorFormat);
colorType = fboFormats.colorType; colorType = GLenum(fbTexFormat.colorType);
colorFormatBytes = fboFormats.colorFormatBytes; colorFormatBytes = GLenum(fbTexFormat.colorFormatBytes);
} else { } else {
colorFormat = fboFormats.monochromeFormat; colorFormat = GLenum(fbTexFormat.monochromeFormat);
colorType = fboFormats.monochromeType; colorType = GLenum(fbTexFormat.monochromeType);
colorFormatBytes = fboFormats.monochromeFormatBytes; colorFormatBytes = GLenum(fbTexFormat.monochromeFormatBytes);
} }
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_PBO[m_curIndex]); glBindBuffer(GL_PIXEL_PACK_BUFFER, m_PBO[m_curIndex]);

View File

@ -1,5 +1,5 @@
#include "ColorBufferToRDRAM.h" #include "ColorBufferToRDRAM.h"
#include <FBOTextureFormats.h> #include <Graphics/Context.h>
#include "ColorBufferToRDRAM_GL.h" #include "ColorBufferToRDRAM_GL.h"
ColorBufferToRDRAM_GL::ColorBufferToRDRAM_GL() 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) 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; GLenum colorFormat, colorType, colorFormatBytes;
if (_size > G_IM_SIZ_8b) { if (_size > G_IM_SIZ_8b) {
colorFormat = fboFormats.colorFormat; colorFormat = GLenum(fbTexFormat.colorFormat);
colorType = fboFormats.colorType; colorType = GLenum(fbTexFormat.colorType);
colorFormatBytes = fboFormats.colorFormatBytes; colorFormatBytes = GLenum(fbTexFormat.colorFormatBytes);
} else { } else {
colorFormat = fboFormats.monochromeFormat; colorFormat = GLenum(fbTexFormat.monochromeFormat);
colorType = fboFormats.monochromeType; colorType = GLenum(fbTexFormat.monochromeType);
colorFormatBytes = fboFormats.monochromeFormatBytes; colorFormatBytes = GLenum(fbTexFormat.monochromeFormatBytes);
} }
// If Sync, read pixels from the buffer, copy them to RDRAM. // If Sync, read pixels from the buffer, copy them to RDRAM.

View File

@ -1,7 +1,6 @@
#include "ColorBufferToRDRAM.h" #include "ColorBufferToRDRAM.h"
#include <Textures.h> #include <Textures.h>
#include <FBOTextureFormats.h>
class ColorBufferToRDRAM_GL : public ColorBufferToRDRAM class ColorBufferToRDRAM_GL : public ColorBufferToRDRAM
{ {

View File

@ -5,7 +5,6 @@
#include "DepthBufferToRDRAM.h" #include "DepthBufferToRDRAM.h"
#include "WriteToRDRAM.h" #include "WriteToRDRAM.h"
#include <FBOTextureFormats.h>
#include <FrameBuffer.h> #include <FrameBuffer.h>
#include <DepthBuffer.h> #include <DepthBuffer.h>
#include <Textures.h> #include <Textures.h>
@ -68,13 +67,14 @@ void DepthBufferToRDRAM::init()
m_pDepthTexture->textureBytes = m_pDepthTexture->realWidth * m_pDepthTexture->realHeight * sizeof(float); m_pDepthTexture->textureBytes = m_pDepthTexture->realWidth * m_pDepthTexture->realHeight * sizeof(float);
textureCache().addFrameBufferTextureSize(m_pDepthTexture->textureBytes); textureCache().addFrameBufferTextureSize(m_pDepthTexture->textureBytes);
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
graphics::Context::InitTextureParams initParams; graphics::Context::InitTextureParams initParams;
initParams.handle = graphics::ObjectHandle(m_pColorTexture->glName); initParams.handle = graphics::ObjectHandle(m_pColorTexture->glName);
initParams.width = m_pColorTexture->realWidth; initParams.width = m_pColorTexture->realWidth;
initParams.height = m_pColorTexture->realHeight; initParams.height = m_pColorTexture->realHeight;
initParams.internalFormat = fboFormats.monochromeInternalFormat; initParams.internalFormat = fbTexFormats.monochromeInternalFormat;
initParams.format = fboFormats.monochromeFormat; initParams.format = fbTexFormats.monochromeFormat;
initParams.dataType = fboFormats.monochromeType; initParams.dataType = fbTexFormats.monochromeType;
gfxContext.init2DTexture(initParams); gfxContext.init2DTexture(initParams);
graphics::Context::TexParameters setParams; graphics::Context::TexParameters setParams;
@ -88,9 +88,9 @@ void DepthBufferToRDRAM::init()
initParams.handle = graphics::ObjectHandle(m_pDepthTexture->glName); initParams.handle = graphics::ObjectHandle(m_pDepthTexture->glName);
initParams.width = m_pDepthTexture->realWidth; initParams.width = m_pDepthTexture->realWidth;
initParams.height = m_pDepthTexture->realHeight; initParams.height = m_pDepthTexture->realHeight;
initParams.internalFormat = fboFormats.depthInternalFormat; initParams.internalFormat = fbTexFormats.depthInternalFormat;
initParams.format = fboFormats.depthFormat; initParams.format = fbTexFormats.depthFormat;
initParams.dataType = fboFormats.depthType; initParams.dataType = fbTexFormats.depthType;
gfxContext.init2DTexture(initParams); gfxContext.init2DTexture(initParams);
setParams.handle = graphics::ObjectHandle(m_pDepthTexture->glName); 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); PBOBinder binder(GL_PIXEL_PACK_BUFFER, m_PBO);
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); 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) if (pixelData == nullptr)
return false; return false;

View File

@ -1,6 +1,5 @@
#include "RDRAMtoColorBuffer.h" #include "RDRAMtoColorBuffer.h"
#include <FBOTextureFormats.h>
#include <FrameBufferInfo.h> #include <FrameBufferInfo.h>
#include <FrameBuffer.h> #include <FrameBuffer.h>
#include <Combiner.h> #include <Combiner.h>
@ -40,13 +39,14 @@ void RDRAMtoColorBuffer::init()
m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight * 4; m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight * 4;
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
graphics::Context::InitTextureParams initParams; graphics::Context::InitTextureParams initParams;
initParams.handle = graphics::ObjectHandle(m_pTexture->glName); initParams.handle = graphics::ObjectHandle(m_pTexture->glName);
initParams.width = m_pTexture->realWidth; initParams.width = m_pTexture->realWidth;
initParams.height = m_pTexture->realHeight; initParams.height = m_pTexture->realHeight;
initParams.internalFormat = fboFormats.colorInternalFormat; initParams.internalFormat = fbTexFormats.colorInternalFormat;
initParams.format = fboFormats.colorFormat; initParams.format = fbTexFormats.colorFormat;
initParams.dataType = fboFormats.colorType; initParams.dataType = fbTexFormats.colorType;
gfxContext.init2DTexture(initParams); gfxContext.init2DTexture(initParams);
graphics::Context::TexParameters setParams; graphics::Context::TexParameters setParams;
@ -254,10 +254,11 @@ void RDRAMtoColorBuffer::copyFromRDRAM(u32 _address, bool _bCFB)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, m_pTexture->glName); glBindTexture(GL_TEXTURE_2D, m_pTexture->glName);
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
#ifndef GLES2 #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 #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 #endif
m_pTexture->scaleS = 1.0f / (float)m_pTexture->realWidth; m_pTexture->scaleS = 1.0f / (float)m_pTexture->realWidth;

View File

@ -11,7 +11,6 @@
#include "VI.h" #include "VI.h"
#include "Config.h" #include "Config.h"
#include "Debug.h" #include "Debug.h"
#include "FBOTextureFormats.h"
#include <Graphics/Context.h> #include <Graphics/Context.h>
#include <Graphics/Parameters.h> #include <Graphics/Parameters.h>
@ -66,6 +65,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
if (!video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0 || m_pDepthImageTexture != nullptr) if (!video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0 || m_pDepthImageTexture != nullptr)
return; return;
const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
m_pDepthImageTexture = textureCache().addFrameBufferTexture(false); m_pDepthImageTexture = textureCache().addFrameBufferTexture(false);
m_pDepthImageTexture->width = (u32)(_pBuffer->m_pTexture->width); m_pDepthImageTexture->width = (u32)(_pBuffer->m_pTexture->width);
@ -84,7 +84,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
m_pDepthImageTexture->mirrorT = 0; m_pDepthImageTexture->mirrorT = 0;
m_pDepthImageTexture->realWidth = m_pDepthImageTexture->width; m_pDepthImageTexture->realWidth = m_pDepthImageTexture->width;
m_pDepthImageTexture->realHeight = m_pDepthImageTexture->height; 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); textureCache().addFrameBufferTextureSize(m_pDepthImageTexture->textureBytes);
{ {
@ -92,9 +92,9 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
params.handle = graphics::ObjectHandle(m_pDepthImageTexture->glName); params.handle = graphics::ObjectHandle(m_pDepthImageTexture->glName);
params.width = m_pDepthImageTexture->realWidth; params.width = m_pDepthImageTexture->realWidth;
params.height = m_pDepthImageTexture->realHeight; params.height = m_pDepthImageTexture->realHeight;
params.internalFormat = fboFormats.depthImageInternalFormat; params.internalFormat = fbTexFormat.depthImageInternalFormat;
params.format = fboFormats.depthImageFormat; params.format = fbTexFormat.depthImageFormat;
params.dataType = fboFormats.depthImageType; params.dataType = fbTexFormat.depthImageType;
gfxContext.init2DTexture(params); gfxContext.init2DTexture(params);
} }
{ {
@ -125,14 +125,15 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture * _pTexture, bool _multisample) void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture * _pTexture, bool _multisample)
{ {
const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
if (_pBuffer != nullptr) { if (_pBuffer != nullptr) {
_pTexture->width = (u32)(_pBuffer->m_pTexture->width); _pTexture->width = (u32)(_pBuffer->m_pTexture->width);
_pTexture->height = (u32)(_pBuffer->m_pTexture->height); _pTexture->height = (u32)(_pBuffer->m_pTexture->height);
_pTexture->address = _pBuffer->m_startAddress; _pTexture->address = _pBuffer->m_startAddress;
_pTexture->clampWidth = _pBuffer->m_width; _pTexture->clampWidth = _pBuffer->m_width;
_pTexture->clampHeight = _pBuffer->m_height; _pTexture->clampHeight = _pBuffer->m_height;
} } else {
else {
if (config.frameBufferEmulation.nativeResFactor == 0) { if (config.frameBufferEmulation.nativeResFactor == 0) {
_pTexture->width = video().getWidth(); _pTexture->width = video().getWidth();
_pTexture->height = video().getHeight(); _pTexture->height = video().getHeight();
@ -155,7 +156,7 @@ void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture
_pTexture->mirrorT = 0; _pTexture->mirrorT = 0;
_pTexture->realWidth = _pTexture->width; _pTexture->realWidth = _pTexture->width;
_pTexture->realHeight = _pTexture->height; _pTexture->realHeight = _pTexture->height;
_pTexture->textureBytes = _pTexture->realWidth * _pTexture->realHeight * fboFormats.depthFormatBytes; _pTexture->textureBytes = _pTexture->realWidth * _pTexture->realHeight * fbTexFormat.depthFormatBytes;
textureCache().addFrameBufferTextureSize(_pTexture->textureBytes); textureCache().addFrameBufferTextureSize(_pTexture->textureBytes);
{ {
@ -164,9 +165,9 @@ void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture
params.msaaLevel = _multisample ? config.video.multisampling : 0U; params.msaaLevel = _multisample ? config.video.multisampling : 0U;
params.width = _pTexture->realWidth; params.width = _pTexture->realWidth;
params.height = _pTexture->realHeight; params.height = _pTexture->realHeight;
params.internalFormat = fboFormats.depthInternalFormat; params.internalFormat = fbTexFormat.depthInternalFormat;
params.format = fboFormats.depthFormat; params.format = fbTexFormat.depthFormat;
params.dataType = fboFormats.depthType; params.dataType = fbTexFormat.depthType;
gfxContext.init2DTexture(params); gfxContext.init2DTexture(params);
} }
_pTexture->frameBufferTexture = _multisample ? CachedTexture::fbMultiSample : CachedTexture::fbOneSample; _pTexture->frameBufferTexture = _multisample ? CachedTexture::fbMultiSample : CachedTexture::fbOneSample;
@ -205,7 +206,7 @@ void DepthBuffer::_initDepthBufferRenderbuffer(FrameBuffer * _pBuffer)
graphics::Context::InitRenderbufferParams params; graphics::Context::InitRenderbufferParams params;
params.handle = renderbufHandle; params.handle = renderbufHandle;
params.target = graphics::target::RENDERBUFFER; params.target = graphics::target::RENDERBUFFER;
params.format = fboFormats.depthInternalFormat; params.format = gfxContext.getFramebufferTextureFormats().depthInternalFormat;
params.width = m_depthRenderbufferWidth; params.width = m_depthRenderbufferWidth;
params.height = height; params.height = height;
gfxContext.initRenderbuffer(params); gfxContext.initRenderbuffer(params);
@ -324,7 +325,8 @@ void DepthBuffer::activateDepthBufferTexture(FrameBuffer * _pBuffer)
void DepthBuffer::bindDepthImageTexture() void DepthBuffer::bindDepthImageTexture()
{ {
#ifdef GL_IMAGE_TEXTURES_SUPPORT #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 #endif
} }
@ -440,6 +442,9 @@ void DepthBufferList::clearBuffer(u32 _ulx, u32 _uly, u32 _lrx, u32 _lry)
{ {
if (m_pCurrent == nullptr) if (m_pCurrent == nullptr)
return; return;
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
m_pCurrent->m_cleared = true; m_pCurrent->m_cleared = true;
m_pCurrent->m_ulx = _ulx; m_pCurrent->m_ulx = _ulx;
m_pCurrent->m_uly = _uly; 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) if (m_pCurrent->m_depthImageFBO == 0 || !video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0)
return; return;
float color[4] = {1.0f, 1.0f, 0.0f, 1.0f}; 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); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pCurrent->m_depthImageFBO);
const u32 cycleType = gDP.otherMode.cycleType; const u32 cycleType = gDP.otherMode.cycleType;
gDP.otherMode.cycleType = G_CYC_FILL; gDP.otherMode.cycleType = G_CYC_FILL;
video().getRender().drawRect(_ulx, _uly, _lrx, _lry, color); video().getRender().drawRect(_ulx, _uly, _lrx, _lry, color);
gDP.otherMode.cycleType = cycleType; 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(); frameBufferList().setCurrentDrawBuffer();
#endif // GL_IMAGE_TEXTURES_SUPPORT #endif // GL_IMAGE_TEXTURES_SUPPORT
} }

View File

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

View File

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

View File

@ -17,7 +17,6 @@
#include "Debug.h" #include "Debug.h"
#include "PostProcessor.h" #include "PostProcessor.h"
#include "FrameBufferInfo.h" #include "FrameBufferInfo.h"
#include "FBOTextureFormats.h"
#include "Log.h" #include "Log.h"
#include "BufferCopy/ColorBufferToRDRAM.h" #include "BufferCopy/ColorBufferToRDRAM.h"
@ -57,6 +56,8 @@ FrameBuffer::~FrameBuffer()
void FrameBuffer::_initTexture(u16 _width, u16 _height, u16 _format, u16 _size, CachedTexture *_pTexture) 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->width = (u32)(_width * m_scaleX);
_pTexture->height = (u32)(_height * m_scaleY); _pTexture->height = (u32)(_height * m_scaleY);
_pTexture->format = _format; _pTexture->format = _format;
@ -75,15 +76,16 @@ void FrameBuffer::_initTexture(u16 _width, u16 _height, u16 _format, u16 _size,
_pTexture->realHeight = _pTexture->height; _pTexture->realHeight = _pTexture->height;
_pTexture->textureBytes = _pTexture->realWidth * _pTexture->realHeight; _pTexture->textureBytes = _pTexture->realWidth * _pTexture->realHeight;
if (_size > G_IM_SIZ_8b) if (_size > G_IM_SIZ_8b)
_pTexture->textureBytes *= fboFormats.colorFormatBytes; _pTexture->textureBytes *= fbTexFormats.colorFormatBytes;
else else
_pTexture->textureBytes *= fboFormats.monochromeFormatBytes; _pTexture->textureBytes *= fbTexFormats.monochromeFormatBytes;
textureCache().addFrameBufferTextureSize(_pTexture->textureBytes); textureCache().addFrameBufferTextureSize(_pTexture->textureBytes);
} }
void FrameBuffer::_setAndAttachTexture(u32 _fbo, CachedTexture *_pTexture, u32 _t, bool _multisampling) void FrameBuffer::_setAndAttachTexture(u32 _fbo, CachedTexture *_pTexture, u32 _t, bool _multisampling)
{ {
{ {
const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
graphics::Context::InitTextureParams params; graphics::Context::InitTextureParams params;
params.handle = graphics::ObjectHandle(_pTexture->glName); params.handle = graphics::ObjectHandle(_pTexture->glName);
if (_multisampling) if (_multisampling)
@ -91,14 +93,14 @@ void FrameBuffer::_setAndAttachTexture(u32 _fbo, CachedTexture *_pTexture, u32 _
params.width = _pTexture->realWidth; params.width = _pTexture->realWidth;
params.height = _pTexture->realHeight; params.height = _pTexture->realHeight;
if (_pTexture->size > G_IM_SIZ_8b) { if (_pTexture->size > G_IM_SIZ_8b) {
params.internalFormat = fboFormats.colorInternalFormat; params.internalFormat = fbTexFormat.colorInternalFormat;
params.format = fboFormats.colorFormat; params.format = fbTexFormat.colorFormat;
params.dataType = fboFormats.colorType; params.dataType = fbTexFormat.colorType;
} }
else { else {
params.internalFormat = fboFormats.monochromeInternalFormat; params.internalFormat = fbTexFormat.monochromeInternalFormat;
params.format = fboFormats.monochromeFormat; params.format = fbTexFormat.monochromeFormat;
params.dataType = fboFormats.monochromeType; params.dataType = fbTexFormat.monochromeType;
} }
gfxContext.init2DTexture(params); gfxContext.init2DTexture(params);
} }

View File

@ -24,7 +24,6 @@
#include "PostProcessor.h" #include "PostProcessor.h"
#include "ShaderUtils.h" #include "ShaderUtils.h"
#include "SoftwareRender.h" #include "SoftwareRender.h"
#include "FBOTextureFormats.h"
#include "TextureFilterHandler.h" #include "TextureFilterHandler.h"
#include "NoiseTexture.h" #include "NoiseTexture.h"
#include "ZlutTexture.h" #include "ZlutTexture.h"
@ -398,13 +397,14 @@ void OGLRender::TexrectDrawer::init()
m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight * 4; m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight * 4;
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
graphics::Context::InitTextureParams initParams; graphics::Context::InitTextureParams initParams;
initParams.handle = graphics::ObjectHandle(m_pTexture->glName); initParams.handle = graphics::ObjectHandle(m_pTexture->glName);
initParams.width = m_pTexture->realWidth; initParams.width = m_pTexture->realWidth;
initParams.height = m_pTexture->realHeight; initParams.height = m_pTexture->realHeight;
initParams.internalFormat = fboFormats.colorInternalFormat; initParams.internalFormat = fbTexFormats.colorInternalFormat;
initParams.format = fboFormats.colorFormat; initParams.format = fbTexFormats.colorFormat;
initParams.dataType = fboFormats.colorType; initParams.dataType = fbTexFormats.colorType;
gfxContext.init2DTexture(initParams); gfxContext.init2DTexture(initParams);
graphics::Context::TexParameters setParams; graphics::Context::TexParameters setParams;
@ -2076,8 +2076,6 @@ void OGLRender::_initExtensions()
m_oglRenderer = glrAdreno; m_oglRenderer = glrAdreno;
LOG(LOG_VERBOSE, "OpenGL renderer: %s\n", strRenderer); LOG(LOG_VERBOSE, "OpenGL renderer: %s\n", strRenderer);
fboFormats.init();
GLfloat lineWidthRange[2] = {0.0f, 0.0f}; GLfloat lineWidthRange[2] = {0.0f, 0.0f};
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, lineWidthRange); glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, lineWidthRange);
m_maxLineWidth = lineWidthRange[1]; m_maxLineWidth = lineWidthRange[1];

View File

@ -4,7 +4,6 @@
#include "gDP.h" #include "gDP.h"
#include "VI.h" #include "VI.h"
#include "Textures.h" #include "Textures.h"
#include "FBOTextureFormats.h"
#include "PaletteTexture.h" #include "PaletteTexture.h"
#include "DepthBuffer.h" #include "DepthBuffer.h"
@ -39,14 +38,15 @@ void PaletteTexture::init()
#endif #endif
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
graphics::Context::InitTextureParams initParams; graphics::Context::InitTextureParams initParams;
initParams.handle = graphics::ObjectHandle(m_pTexture->glName); initParams.handle = graphics::ObjectHandle(m_pTexture->glName);
initParams.ImageUnit = graphics::textureImageUnits::Tlut; initParams.ImageUnit = graphics::textureImageUnits::Tlut;
initParams.width = m_pTexture->realWidth; initParams.width = m_pTexture->realWidth;
initParams.height = m_pTexture->realHeight; initParams.height = m_pTexture->realHeight;
initParams.internalFormat = fboFormats.lutInternalFormat; initParams.internalFormat = fbTexFormats.lutInternalFormat;
initParams.format = fboFormats.lutFormat; initParams.format = fbTexFormats.lutFormat;
initParams.dataType = fboFormats.lutType; initParams.dataType = fbTexFormats.lutType;
gfxContext.init2DTexture(initParams); gfxContext.init2DTexture(initParams);
graphics::Context::TexParameters setParams; graphics::Context::TexParameters setParams;
@ -66,7 +66,8 @@ void PaletteTexture::init()
void PaletteTexture::destroy() 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); textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = nullptr; m_pTexture = nullptr;
m_pbuf.reset(); m_pbuf.reset();
@ -91,16 +92,17 @@ void PaletteTexture::update()
palette[i] = swapword(src[i * 4]); palette[i] = swapword(src[i * 4]);
m_pbuf->closeWriteBuffer(); m_pbuf->closeWriteBuffer();
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
graphics::Context::UpdateTextureDataParams params; graphics::Context::UpdateTextureDataParams params;
params.handle = graphics::ObjectHandle(m_pTexture->glName); params.handle = graphics::ObjectHandle(m_pTexture->glName);
params.ImageUnit = graphics::textureImageUnits::Tlut; params.ImageUnit = graphics::textureImageUnits::Tlut;
params.textureUnitIndex = graphics::textureIndices::PaletteTex; params.textureUnitIndex = graphics::textureIndices::PaletteTex;
params.width = m_pTexture->realWidth; params.width = m_pTexture->realWidth;
params.height = m_pTexture->realHeight; params.height = m_pTexture->realHeight;
params.format = fboFormats.lutFormat; params.format = fbTexFormats.lutFormat;
params.internalFormat = fboFormats.lutInternalFormat; params.internalFormat = fbTexFormats.lutInternalFormat;
params.dataType = fboFormats.lutType; params.dataType = fbTexFormats.lutType;
params.data = m_pbuf->getData(); 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); gfxContext.update2DTexture(params);
} }

View File

@ -19,7 +19,6 @@
#include "RSP.h" #include "RSP.h"
#include "Config.h" #include "Config.h"
#include "ShaderUtils.h" #include "ShaderUtils.h"
#include <FBOTextureFormats.h>
#include "Log.h" #include "Log.h"
#include <Graphics/Context.h> #include <Graphics/Context.h>

View File

@ -1,6 +1,5 @@
#include "Graphics/Context.h" #include "Graphics/Context.h"
#include "Graphics/Parameters.h" #include "Graphics/Parameters.h"
#include "FBOTextureFormats.h"
#include "DepthBuffer.h" #include "DepthBuffer.h"
#include "Config.h" #include "Config.h"
#include "Textures.h" #include "Textures.h"
@ -41,14 +40,15 @@ void ZlutTexture::init()
m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight * sizeof(zLUT[0]); m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight * sizeof(zLUT[0]);
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
graphics::Context::InitTextureParams initParams; graphics::Context::InitTextureParams initParams;
initParams.handle = graphics::ObjectHandle(m_pTexture->glName); initParams.handle = graphics::ObjectHandle(m_pTexture->glName);
initParams.ImageUnit = graphics::textureImageUnits::Zlut; initParams.ImageUnit = graphics::textureImageUnits::Zlut;
initParams.width = m_pTexture->realWidth; initParams.width = m_pTexture->realWidth;
initParams.height = m_pTexture->realHeight; initParams.height = m_pTexture->realHeight;
initParams.internalFormat = fboFormats.lutInternalFormat; initParams.internalFormat = fbTexFormats.lutInternalFormat;
initParams.format = fboFormats.lutFormat; initParams.format = fbTexFormats.lutFormat;
initParams.dataType = fboFormats.lutType; initParams.dataType = fbTexFormats.lutType;
initParams.data = zLUT; initParams.data = zLUT;
gfxContext.init2DTexture(initParams); gfxContext.init2DTexture(initParams);
@ -64,7 +64,8 @@ void ZlutTexture::init()
} }
void ZlutTexture::destroy() { 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); textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = nullptr; m_pTexture = nullptr;
} }