mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Change type of CachedTexture name to graphics::ObjectHandle
This commit is contained in:
parent
ed7cc2c1f5
commit
4e459c7645
|
@ -21,6 +21,8 @@
|
||||||
#include <Graphics/Parameters.h>
|
#include <Graphics/Parameters.h>
|
||||||
#include <DisplayWindow.h>
|
#include <DisplayWindow.h>
|
||||||
|
|
||||||
|
using namespace graphics;
|
||||||
|
|
||||||
ColorBufferToRDRAM::ColorBufferToRDRAM()
|
ColorBufferToRDRAM::ColorBufferToRDRAM()
|
||||||
: m_FBO(0)
|
: m_FBO(0)
|
||||||
, m_pTexture(nullptr)
|
, m_pTexture(nullptr)
|
||||||
|
@ -76,9 +78,9 @@ void ColorBufferToRDRAM::_initFBTexture(void)
|
||||||
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
|
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
|
||||||
|
|
||||||
{
|
{
|
||||||
const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
|
const FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(m_pTexture->glName);
|
params.handle = m_pTexture->name;
|
||||||
params.width = m_pTexture->realWidth;
|
params.width = m_pTexture->realWidth;
|
||||||
params.height = m_pTexture->realHeight;
|
params.height = m_pTexture->realHeight;
|
||||||
params.internalFormat = fbTexFormat.colorInternalFormat;
|
params.internalFormat = fbTexFormat.colorInternalFormat;
|
||||||
|
@ -87,21 +89,21 @@ void ColorBufferToRDRAM::_initFBTexture(void)
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
graphics::Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle = graphics::ObjectHandle(m_pTexture->glName);
|
params.handle = m_pTexture->name;
|
||||||
params.target = graphics::target::TEXTURE_2D;
|
params.target = target::TEXTURE_2D;
|
||||||
params.textureUnitIndex = graphics::textureIndices::Tex[0];
|
params.textureUnitIndex = textureIndices::Tex[0];
|
||||||
params.minFilter = graphics::textureParameters::FILTER_LINEAR;
|
params.minFilter = textureParameters::FILTER_LINEAR;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_LINEAR;
|
params.magFilter = textureParameters::FILTER_LINEAR;
|
||||||
gfxContext.setTextureParameters(params);
|
gfxContext.setTextureParameters(params);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
graphics::Context::FrameBufferRenderTarget bufTarget;
|
Context::FrameBufferRenderTarget bufTarget;
|
||||||
bufTarget.bufferHandle = graphics::ObjectHandle(m_FBO);
|
bufTarget.bufferHandle = ObjectHandle(m_FBO);
|
||||||
bufTarget.bufferTarget = graphics::bufferTarget::DRAW_FRAMEBUFFER;
|
bufTarget.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
||||||
bufTarget.attachment = graphics::bufferAttachment::COLOR_ATTACHMENT0;
|
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
||||||
bufTarget.textureTarget = graphics::target::TEXTURE_2D;
|
bufTarget.textureTarget = target::TEXTURE_2D;
|
||||||
bufTarget.textureHandle = graphics::ObjectHandle(m_pTexture->glName);
|
bufTarget.textureHandle = m_pTexture->name;
|
||||||
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,21 +166,21 @@ bool ColorBufferToRDRAM::_prepareCopy(u32 _startAddress)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics::ObjectHandle readBuffer;
|
ObjectHandle readBuffer;
|
||||||
|
|
||||||
if (config.video.multisampling != 0) {
|
if (config.video.multisampling != 0) {
|
||||||
m_pCurFrameBuffer->resolveMultisampledTexture();
|
m_pCurFrameBuffer->resolveMultisampledTexture();
|
||||||
//glBindFramebuffer(GL_READ_FRAMEBUFFER, m_pCurFrameBuffer->m_resolveFBO);
|
//glBindFramebuffer(GL_READ_FRAMEBUFFER, m_pCurFrameBuffer->m_resolveFBO);
|
||||||
readBuffer = graphics::ObjectHandle(m_pCurFrameBuffer->m_resolveFBO);
|
readBuffer = ObjectHandle(m_pCurFrameBuffer->m_resolveFBO);
|
||||||
} else {
|
} else {
|
||||||
// glBindFramebuffer(GL_READ_FRAMEBUFFER, m_pCurFrameBuffer->m_FBO);
|
// glBindFramebuffer(GL_READ_FRAMEBUFFER, m_pCurFrameBuffer->m_FBO);
|
||||||
readBuffer = graphics::ObjectHandle(m_pCurFrameBuffer->m_FBO);
|
readBuffer = ObjectHandle(m_pCurFrameBuffer->m_FBO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (m_pCurFrameBuffer->m_scaleX != 1.0f || m_pCurFrameBuffer->m_scaleY != 1.0f) {
|
if (m_pCurFrameBuffer->m_scaleX != 1.0f || m_pCurFrameBuffer->m_scaleY != 1.0f) {
|
||||||
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO);
|
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO);
|
||||||
graphics::ObjectHandle drawBuffer(m_FBO);
|
ObjectHandle drawBuffer(m_FBO);
|
||||||
|
|
||||||
u32 x0 = 0;
|
u32 x0 = 0;
|
||||||
u32 width, height;
|
u32 width, height;
|
||||||
|
@ -210,15 +212,15 @@ bool ColorBufferToRDRAM::_prepareCopy(u32 _startAddress)
|
||||||
blitParams.dstY1 = VI.height;
|
blitParams.dstY1 = VI.height;
|
||||||
blitParams.dstWidth = m_pTexture->realWidth;
|
blitParams.dstWidth = m_pTexture->realWidth;
|
||||||
blitParams.dstHeight = m_pTexture->realHeight;
|
blitParams.dstHeight = m_pTexture->realHeight;
|
||||||
blitParams.filter = graphics::textureParameters::FILTER_NEAREST;
|
blitParams.filter = textureParameters::FILTER_NEAREST;
|
||||||
blitParams.tex[0] = pInputTexture;
|
blitParams.tex[0] = pInputTexture;
|
||||||
blitParams.combiner = CombinerInfo::get().getTexrectCopyProgram();
|
blitParams.combiner = CombinerInfo::get().getTexrectCopyProgram();
|
||||||
blitParams.readBuffer = readBuffer;
|
blitParams.readBuffer = readBuffer;
|
||||||
blitParams.drawBuffer = drawBuffer;
|
blitParams.drawBuffer = drawBuffer;
|
||||||
blitParams.mask = graphics::blitMask::COLOR_BUFFER;
|
blitParams.mask = blitMask::COLOR_BUFFER;
|
||||||
wnd.getDrawer().blitOrCopyTexturedRect(blitParams);
|
wnd.getDrawer().blitOrCopyTexturedRect(blitParams);
|
||||||
|
|
||||||
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, graphics::ObjectHandle(m_FBO));
|
gfxContext.bindFramebuffer(bufferTarget::READ_FRAMEBUFFER, ObjectHandle(m_FBO));
|
||||||
// glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO);
|
// glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <Graphics/Parameters.h>
|
#include <Graphics/Parameters.h>
|
||||||
#include <DisplayWindow.h>
|
#include <DisplayWindow.h>
|
||||||
|
|
||||||
|
using namespace graphics;
|
||||||
|
|
||||||
#ifndef GLES2
|
#ifndef GLES2
|
||||||
|
|
||||||
DepthBufferToRDRAM::DepthBufferToRDRAM()
|
DepthBufferToRDRAM::DepthBufferToRDRAM()
|
||||||
|
@ -68,9 +70,9 @@ 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();
|
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||||
graphics::Context::InitTextureParams initParams;
|
Context::InitTextureParams initParams;
|
||||||
initParams.handle = graphics::ObjectHandle(m_pColorTexture->glName);
|
initParams.handle = m_pColorTexture->name;
|
||||||
initParams.width = m_pColorTexture->realWidth;
|
initParams.width = m_pColorTexture->realWidth;
|
||||||
initParams.height = m_pColorTexture->realHeight;
|
initParams.height = m_pColorTexture->realHeight;
|
||||||
initParams.internalFormat = fbTexFormats.monochromeInternalFormat;
|
initParams.internalFormat = fbTexFormats.monochromeInternalFormat;
|
||||||
|
@ -78,15 +80,15 @@ void DepthBufferToRDRAM::init()
|
||||||
initParams.dataType = fbTexFormats.monochromeType;
|
initParams.dataType = fbTexFormats.monochromeType;
|
||||||
gfxContext.init2DTexture(initParams);
|
gfxContext.init2DTexture(initParams);
|
||||||
|
|
||||||
graphics::Context::TexParameters setParams;
|
Context::TexParameters setParams;
|
||||||
setParams.handle = graphics::ObjectHandle(m_pColorTexture->glName);
|
setParams.handle = m_pColorTexture->name;
|
||||||
setParams.target = graphics::target::TEXTURE_2D;
|
setParams.target = target::TEXTURE_2D;
|
||||||
setParams.textureUnitIndex = graphics::textureIndices::Tex[0];
|
setParams.textureUnitIndex = textureIndices::Tex[0];
|
||||||
setParams.minFilter = graphics::textureParameters::FILTER_NEAREST;
|
setParams.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
setParams.magFilter = graphics::textureParameters::FILTER_NEAREST;
|
setParams.magFilter = textureParameters::FILTER_NEAREST;
|
||||||
gfxContext.setTextureParameters(setParams);
|
gfxContext.setTextureParameters(setParams);
|
||||||
|
|
||||||
initParams.handle = graphics::ObjectHandle(m_pDepthTexture->glName);
|
initParams.handle = m_pDepthTexture->name;
|
||||||
initParams.width = m_pDepthTexture->realWidth;
|
initParams.width = m_pDepthTexture->realWidth;
|
||||||
initParams.height = m_pDepthTexture->realHeight;
|
initParams.height = m_pDepthTexture->realHeight;
|
||||||
initParams.internalFormat = fbTexFormats.depthInternalFormat;
|
initParams.internalFormat = fbTexFormats.depthInternalFormat;
|
||||||
|
@ -94,21 +96,21 @@ void DepthBufferToRDRAM::init()
|
||||||
initParams.dataType = fbTexFormats.depthType;
|
initParams.dataType = fbTexFormats.depthType;
|
||||||
gfxContext.init2DTexture(initParams);
|
gfxContext.init2DTexture(initParams);
|
||||||
|
|
||||||
setParams.handle = graphics::ObjectHandle(m_pDepthTexture->glName);
|
setParams.handle = m_pDepthTexture->name;
|
||||||
gfxContext.setTextureParameters(setParams);
|
gfxContext.setTextureParameters(setParams);
|
||||||
|
|
||||||
graphics::ObjectHandle fboHandle = gfxContext.createFramebuffer();
|
ObjectHandle fboHandle = gfxContext.createFramebuffer();
|
||||||
m_FBO = GLuint(fboHandle);
|
m_FBO = GLuint(fboHandle);
|
||||||
graphics::Context::FrameBufferRenderTarget bufTarget;
|
Context::FrameBufferRenderTarget bufTarget;
|
||||||
bufTarget.bufferHandle = fboHandle;
|
bufTarget.bufferHandle = fboHandle;
|
||||||
bufTarget.bufferTarget = graphics::bufferTarget::DRAW_FRAMEBUFFER;
|
bufTarget.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
||||||
bufTarget.attachment = graphics::bufferAttachment::COLOR_ATTACHMENT0;
|
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
||||||
bufTarget.textureTarget = graphics::target::TEXTURE_2D;
|
bufTarget.textureTarget = target::TEXTURE_2D;
|
||||||
bufTarget.textureHandle = graphics::ObjectHandle(m_pColorTexture->glName);
|
bufTarget.textureHandle = m_pColorTexture->name;
|
||||||
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
||||||
|
|
||||||
bufTarget.attachment = graphics::bufferAttachment::DEPTH_ATTACHMENT;
|
bufTarget.attachment = bufferAttachment::DEPTH_ATTACHMENT;
|
||||||
bufTarget.textureHandle = graphics::ObjectHandle(m_pDepthTexture->glName);
|
bufTarget.textureHandle = m_pDepthTexture->name;
|
||||||
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
||||||
|
|
||||||
// check if everything is OK
|
// check if everything is OK
|
||||||
|
@ -212,7 +214,7 @@ 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);
|
||||||
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||||
glReadPixels(x0, y0, width, height, GLenum(fbTexFormats.depthFormat), GLenum(fbTexFormats.depthType), 0);
|
glReadPixels(x0, y0, width, height, GLenum(fbTexFormats.depthFormat), GLenum(fbTexFormats.depthType), 0);
|
||||||
|
|
||||||
GLubyte* pixelData = (GLubyte*)glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, width * height * fbTexFormats.depthFormatBytes, GL_MAP_READ_BIT);
|
GLubyte* pixelData = (GLubyte*)glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, width * height * fbTexFormats.depthFormatBytes, GL_MAP_READ_BIT);
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include <Graphics/Parameters.h>
|
#include <Graphics/Parameters.h>
|
||||||
#include <DisplayWindow.h>
|
#include <DisplayWindow.h>
|
||||||
|
|
||||||
|
using namespace graphics;
|
||||||
|
|
||||||
RDRAMtoColorBuffer::RDRAMtoColorBuffer()
|
RDRAMtoColorBuffer::RDRAMtoColorBuffer()
|
||||||
: m_pCurBuffer(nullptr)
|
: m_pCurBuffer(nullptr)
|
||||||
, m_pTexture(nullptr)
|
, m_pTexture(nullptr)
|
||||||
|
@ -40,9 +42,9 @@ 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();
|
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||||
graphics::Context::InitTextureParams initParams;
|
Context::InitTextureParams initParams;
|
||||||
initParams.handle = graphics::ObjectHandle(m_pTexture->glName);
|
initParams.handle = m_pTexture->name;
|
||||||
initParams.width = m_pTexture->realWidth;
|
initParams.width = m_pTexture->realWidth;
|
||||||
initParams.height = m_pTexture->realHeight;
|
initParams.height = m_pTexture->realHeight;
|
||||||
initParams.internalFormat = fbTexFormats.colorInternalFormat;
|
initParams.internalFormat = fbTexFormats.colorInternalFormat;
|
||||||
|
@ -50,12 +52,12 @@ void RDRAMtoColorBuffer::init()
|
||||||
initParams.dataType = fbTexFormats.colorType;
|
initParams.dataType = fbTexFormats.colorType;
|
||||||
gfxContext.init2DTexture(initParams);
|
gfxContext.init2DTexture(initParams);
|
||||||
|
|
||||||
graphics::Context::TexParameters setParams;
|
Context::TexParameters setParams;
|
||||||
setParams.handle = graphics::ObjectHandle(m_pTexture->glName);
|
setParams.handle = m_pTexture->name;
|
||||||
setParams.target = graphics::target::TEXTURE_2D;
|
setParams.target = target::TEXTURE_2D;
|
||||||
setParams.textureUnitIndex = graphics::textureIndices::Tex[0];
|
setParams.textureUnitIndex = textureIndices::Tex[0];
|
||||||
setParams.minFilter = graphics::textureParameters::FILTER_LINEAR;
|
setParams.minFilter = textureParameters::FILTER_LINEAR;
|
||||||
setParams.magFilter = graphics::textureParameters::FILTER_LINEAR;
|
setParams.magFilter = textureParameters::FILTER_LINEAR;
|
||||||
gfxContext.setTextureParameters(setParams);
|
gfxContext.setTextureParameters(setParams);
|
||||||
|
|
||||||
// Generate Pixel Buffer Object. Initialize it later
|
// Generate Pixel Buffer Object. Initialize it later
|
||||||
|
@ -254,8 +256,8 @@ void RDRAMtoColorBuffer::copyFromRDRAM(u32 _address, bool _bCFB)
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
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, GLuint(m_pTexture->name));
|
||||||
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||||
#ifndef GLES2
|
#ifndef GLES2
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GLenum(fbTexFormats.colorFormat), GLenum(fbTexFormats.colorType), 0);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GLenum(fbTexFormats.colorFormat), GLenum(fbTexFormats.colorType), 0);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -90,7 +90,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
||||||
|
|
||||||
{
|
{
|
||||||
Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = ObjectHandle(m_pDepthImageTexture->glName);
|
params.handle = m_pDepthImageTexture->name;
|
||||||
params.width = m_pDepthImageTexture->realWidth;
|
params.width = m_pDepthImageTexture->realWidth;
|
||||||
params.height = m_pDepthImageTexture->realHeight;
|
params.height = m_pDepthImageTexture->realHeight;
|
||||||
params.internalFormat = fbTexFormat.depthImageInternalFormat;
|
params.internalFormat = fbTexFormat.depthImageInternalFormat;
|
||||||
|
@ -100,7 +100,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle = ObjectHandle(m_pDepthImageTexture->glName);
|
params.handle =m_pDepthImageTexture->name;
|
||||||
params.target = target::TEXTURE_2D;
|
params.target = target::TEXTURE_2D;
|
||||||
params.textureUnitIndex = textureIndices::Tex[0];
|
params.textureUnitIndex = textureIndices::Tex[0];
|
||||||
params.minFilter = textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
|
@ -113,7 +113,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
||||||
bufTarget.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
bufTarget.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
||||||
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
||||||
bufTarget.textureTarget = target::TEXTURE_2D;
|
bufTarget.textureTarget = target::TEXTURE_2D;
|
||||||
bufTarget.textureHandle = ObjectHandle(m_pDepthImageTexture->glName);
|
bufTarget.textureHandle = m_pDepthImageTexture->name;
|
||||||
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture
|
||||||
|
|
||||||
{
|
{
|
||||||
Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
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;
|
||||||
|
@ -172,7 +172,7 @@ void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture
|
||||||
_pTexture->frameBufferTexture = _multisample ? CachedTexture::fbMultiSample : CachedTexture::fbOneSample;
|
_pTexture->frameBufferTexture = _multisample ? CachedTexture::fbMultiSample : CachedTexture::fbOneSample;
|
||||||
{
|
{
|
||||||
Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle = ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
params.target = _multisample ? target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
params.target = _multisample ? target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
||||||
params.textureUnitIndex = textureIndices::Tex[0];
|
params.textureUnitIndex = textureIndices::Tex[0];
|
||||||
params.minFilter = textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
|
@ -217,7 +217,7 @@ void DepthBuffer::setDepthAttachment(ObjectHandle _fbo, Parameter _target)
|
||||||
params.bufferHandle = _fbo;
|
params.bufferHandle = _fbo;
|
||||||
params.bufferTarget = _target;
|
params.bufferTarget = _target;
|
||||||
if (gfxContext.isSupported(SpecialFeatures::DepthFramebufferTextures)) {
|
if (gfxContext.isSupported(SpecialFeatures::DepthFramebufferTextures)) {
|
||||||
params.textureHandle = ObjectHandle(m_pDepthBufferTexture->glName);
|
params.textureHandle = m_pDepthBufferTexture->name;
|
||||||
params.textureTarget = config.video.multisampling != 0 ? target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
params.textureTarget = config.video.multisampling != 0 ? target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
||||||
} else {
|
} else {
|
||||||
params.textureHandle = m_depthRenderbuffer;
|
params.textureHandle = m_depthRenderbuffer;
|
||||||
|
@ -258,7 +258,7 @@ CachedTexture * DepthBuffer::resolveDepthBufferTexture(FrameBuffer * _pBuffer)
|
||||||
targetParams.attachment = bufferAttachment::DEPTH_ATTACHMENT;
|
targetParams.attachment = bufferAttachment::DEPTH_ATTACHMENT;
|
||||||
targetParams.bufferHandle = _pBuffer->m_resolveFBO;
|
targetParams.bufferHandle = _pBuffer->m_resolveFBO;
|
||||||
targetParams.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
targetParams.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
||||||
targetParams.textureHandle = ObjectHandle(m_pResolveDepthBufferTexture->glName);
|
targetParams.textureHandle = m_pResolveDepthBufferTexture->name;
|
||||||
targetParams.textureTarget = target::TEXTURE_2D;
|
targetParams.textureTarget = target::TEXTURE_2D;
|
||||||
gfxContext.addFrameBufferRenderTarget(targetParams);
|
gfxContext.addFrameBufferRenderTarget(targetParams);
|
||||||
|
|
||||||
|
@ -301,14 +301,14 @@ CachedTexture * DepthBuffer::copyDepthBufferTexture(FrameBuffer * _pBuffer)
|
||||||
targetParams.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
targetParams.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
||||||
targetParams.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
targetParams.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
||||||
targetParams.textureHandle = _pBuffer->m_pTexture->frameBufferTexture == CachedTexture::fbMultiSample ?
|
targetParams.textureHandle = _pBuffer->m_pTexture->frameBufferTexture == CachedTexture::fbMultiSample ?
|
||||||
ObjectHandle(_pBuffer->m_pResolveTexture->glName) :
|
_pBuffer->m_pResolveTexture->name :
|
||||||
ObjectHandle(_pBuffer->m_pTexture->glName);
|
_pBuffer->m_pTexture->name;
|
||||||
targetParams.textureTarget = target::TEXTURE_2D;
|
targetParams.textureTarget = target::TEXTURE_2D;
|
||||||
|
|
||||||
gfxContext.addFrameBufferRenderTarget(targetParams);
|
gfxContext.addFrameBufferRenderTarget(targetParams);
|
||||||
|
|
||||||
targetParams.attachment = bufferAttachment::DEPTH_ATTACHMENT;
|
targetParams.attachment = bufferAttachment::DEPTH_ATTACHMENT;
|
||||||
targetParams.textureHandle = ObjectHandle(m_pDepthBufferCopyTexture->glName);
|
targetParams.textureHandle = m_pDepthBufferCopyTexture->name;
|
||||||
|
|
||||||
gfxContext.addFrameBufferRenderTarget(targetParams);
|
gfxContext.addFrameBufferRenderTarget(targetParams);
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ void DepthBuffer::bindDepthImageTexture()
|
||||||
|
|
||||||
Context::BindImageTextureParameters bindParams;
|
Context::BindImageTextureParameters bindParams;
|
||||||
bindParams.imageUnit = textureImageUnits::Depth;
|
bindParams.imageUnit = textureImageUnits::Depth;
|
||||||
bindParams.texture = ObjectHandle(m_pDepthImageTexture->glName);
|
bindParams.texture = m_pDepthImageTexture->name;
|
||||||
bindParams.accessMode = textureImageAccessMode::READ_WRITE;
|
bindParams.accessMode = textureImageAccessMode::READ_WRITE;
|
||||||
bindParams.textureFormat = gfxContext.getFramebufferTextureFormats().depthImageInternalFormat;
|
bindParams.textureFormat = gfxContext.getFramebufferTextureFormats().depthImageInternalFormat;
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ void DepthBufferList::clearBuffer(u32 _ulx, u32 _uly, u32 _lrx, u32 _lry)
|
||||||
dwnd().getDrawer().drawRect(_ulx, _uly, _lrx, _lry, color);
|
dwnd().getDrawer().drawRect(_ulx, _uly, _lrx, _lry, color);
|
||||||
gDP.otherMode.cycleType = cycleType;
|
gDP.otherMode.cycleType = cycleType;
|
||||||
|
|
||||||
bindParams.texture = ObjectHandle(m_pCurrent->m_pDepthImageTexture->glName);
|
bindParams.texture = m_pCurrent->m_pDepthImageTexture->name;
|
||||||
gfxContext.bindImageTexture(bindParams);
|
gfxContext.bindImageTexture(bindParams);
|
||||||
|
|
||||||
frameBufferList().setCurrentDrawBuffer();
|
frameBufferList().setCurrentDrawBuffer();
|
||||||
|
|
|
@ -89,7 +89,7 @@ void FrameBuffer::_setAndAttachTexture(ObjectHandle _fbo, CachedTexture *_pTextu
|
||||||
{
|
{
|
||||||
const FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
|
const FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
|
||||||
Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
if (_multisampling)
|
if (_multisampling)
|
||||||
params.msaaLevel = config.video.multisampling;
|
params.msaaLevel = config.video.multisampling;
|
||||||
params.width = _pTexture->realWidth;
|
params.width = _pTexture->realWidth;
|
||||||
|
@ -108,7 +108,7 @@ void FrameBuffer::_setAndAttachTexture(ObjectHandle _fbo, CachedTexture *_pTextu
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle = ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
params.target = _multisampling ? target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
params.target = _multisampling ? target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
||||||
params.textureUnitIndex = textureIndices::Tex[_t];
|
params.textureUnitIndex = textureIndices::Tex[_t];
|
||||||
params.minFilter = textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
|
@ -121,7 +121,7 @@ void FrameBuffer::_setAndAttachTexture(ObjectHandle _fbo, CachedTexture *_pTextu
|
||||||
bufTarget.bufferTarget = bufferTarget::FRAMEBUFFER;
|
bufTarget.bufferTarget = bufferTarget::FRAMEBUFFER;
|
||||||
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
||||||
bufTarget.textureTarget = _multisampling ? target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
bufTarget.textureTarget = _multisampling ? target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
||||||
bufTarget.textureHandle = ObjectHandle(_pTexture->glName);
|
bufTarget.textureHandle = _pTexture->name;
|
||||||
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
||||||
}
|
}
|
||||||
assert(checkFBO());
|
assert(checkFBO());
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace graphics {
|
||||||
explicit operator u32() const { return m_name; }
|
explicit operator u32() const { return m_name; }
|
||||||
bool operator==(const ObjectHandle & _other) const { return m_name == _other.m_name; }
|
bool operator==(const ObjectHandle & _other) const { return m_name == _other.m_name; }
|
||||||
bool operator!=(const ObjectHandle & _other) const { return m_name != _other.m_name; }
|
bool operator!=(const ObjectHandle & _other) const { return m_name != _other.m_name; }
|
||||||
|
bool operator<(const ObjectHandle & _other) const { return m_name < _other.m_name; }
|
||||||
|
|
||||||
bool isNotNull() const { return m_name != 0; }
|
bool isNotNull() const { return m_name != 0; }
|
||||||
|
|
||||||
|
|
|
@ -584,12 +584,12 @@ void GraphicsDrawer::_updateStates(DrawingState _drawingState) const
|
||||||
if (pDepthTexture == nullptr)
|
if (pDepthTexture == nullptr)
|
||||||
return;
|
return;
|
||||||
Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle = graphics::ObjectHandle(pDepthTexture->glName);
|
params.handle = pDepthTexture->name;
|
||||||
params.target = graphics::target::TEXTURE_2D;
|
params.target = target::TEXTURE_2D;
|
||||||
params.textureUnitIndex = graphics::textureIndices::DepthTex;
|
params.textureUnitIndex = textureIndices::DepthTex;
|
||||||
params.maxMipmapLevel = 0;
|
params.maxMipmapLevel = 0;
|
||||||
params.minFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.magFilter = textureParameters::FILTER_NEAREST;
|
||||||
gfxContext.setTextureParameters(params);
|
gfxContext.setTextureParameters(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1180,7 +1180,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
||||||
texParams.wrapT = textureParameters::WRAP_CLAMP_TO_EDGE;
|
texParams.wrapT = textureParameters::WRAP_CLAMP_TO_EDGE;
|
||||||
|
|
||||||
if (texParams.wrapS.isValid() || texParams.wrapT.isValid()) {
|
if (texParams.wrapS.isValid() || texParams.wrapT.isValid()) {
|
||||||
texParams.handle = ObjectHandle(cache.current[t]->glName);
|
texParams.handle = cache.current[t]->name;
|
||||||
texParams.target = cache.current[t]->frameBufferTexture == CachedTexture::fbMultiSample ?
|
texParams.target = cache.current[t]->frameBufferTexture == CachedTexture::fbMultiSample ?
|
||||||
target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
||||||
texParams.textureUnitIndex = textureIndices::Tex[t];
|
texParams.textureUnitIndex = textureIndices::Tex[t];
|
||||||
|
@ -1196,7 +1196,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
||||||
|
|
||||||
if (gDP.otherMode.cycleType == G_CYC_COPY) {
|
if (gDP.otherMode.cycleType == G_CYC_COPY) {
|
||||||
Context::TexParameters texParams;
|
Context::TexParameters texParams;
|
||||||
texParams.handle = ObjectHandle(cache.current[0]->glName);
|
texParams.handle = cache.current[0]->name;
|
||||||
texParams.target = cache.current[0]->frameBufferTexture == CachedTexture::fbMultiSample ?
|
texParams.target = cache.current[0]->frameBufferTexture == CachedTexture::fbMultiSample ?
|
||||||
target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
||||||
texParams.textureUnitIndex = textureIndices::Tex[0];
|
texParams.textureUnitIndex = textureIndices::Tex[0];
|
||||||
|
@ -1446,22 +1446,22 @@ void GraphicsDrawer::copyTexturedRect(const CopyRectParams & _params)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Context::TexParameters texParams;
|
Context::TexParameters texParams;
|
||||||
texParams.handle = graphics::ObjectHandle(tex->glName);
|
texParams.handle = tex->name;
|
||||||
texParams.textureUnitIndex = graphics::textureIndices::Tex[i];
|
texParams.textureUnitIndex = textureIndices::Tex[i];
|
||||||
texParams.target = tex->frameBufferTexture == CachedTexture::fbMultiSample ?
|
texParams.target = tex->frameBufferTexture == CachedTexture::fbMultiSample ?
|
||||||
graphics::target::TEXTURE_2D_MULTISAMPLE : graphics::target::TEXTURE_2D;
|
target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D;
|
||||||
texParams.minFilter = _params.filter;
|
texParams.minFilter = _params.filter;
|
||||||
texParams.magFilter = _params.filter;
|
texParams.magFilter = _params.filter;
|
||||||
texParams.wrapS = graphics::textureParameters::WRAP_CLAMP_TO_EDGE;
|
texParams.wrapS = textureParameters::WRAP_CLAMP_TO_EDGE;
|
||||||
texParams.wrapT = graphics::textureParameters::WRAP_CLAMP_TO_EDGE;
|
texParams.wrapT = textureParameters::WRAP_CLAMP_TO_EDGE;
|
||||||
gfxContext.setTextureParameters(texParams);
|
gfxContext.setTextureParameters(texParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxContext.setViewport(0, 0, _params.dstWidth, _params.dstHeight);
|
gfxContext.setViewport(0, 0, _params.dstWidth, _params.dstHeight);
|
||||||
gfxContext.enable(graphics::enable::CULL_FACE, false);
|
gfxContext.enable(enable::CULL_FACE, false);
|
||||||
gfxContext.enable(graphics::enable::BLEND, false);
|
gfxContext.enable(enable::BLEND, false);
|
||||||
gfxContext.enable(graphics::enable::DEPTH_TEST, false);
|
gfxContext.enable(enable::DEPTH_TEST, false);
|
||||||
gfxContext.enable(graphics::enable::SCISSOR_TEST, false);
|
gfxContext.enable(enable::SCISSOR_TEST, false);
|
||||||
gfxContext.enableDepthWrite(false);
|
gfxContext.enableDepthWrite(false);
|
||||||
|
|
||||||
Context::DrawRectParameters rectParams;
|
Context::DrawRectParameters rectParams;
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include "NoiseTexture.h"
|
#include "NoiseTexture.h"
|
||||||
#include "DisplayWindow.h"
|
#include "DisplayWindow.h"
|
||||||
|
|
||||||
|
using namespace graphics;
|
||||||
|
|
||||||
NoiseTexture g_noiseTexture;
|
NoiseTexture g_noiseTexture;
|
||||||
|
|
||||||
NoiseTexture::NoiseTexture()
|
NoiseTexture::NoiseTexture()
|
||||||
|
@ -35,22 +37,22 @@ void NoiseTexture::init()
|
||||||
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
|
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
|
||||||
|
|
||||||
{
|
{
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(m_pTexture->glName);
|
params.handle = m_pTexture->name;
|
||||||
params.width = m_pTexture->realWidth;
|
params.width = m_pTexture->realWidth;
|
||||||
params.height = m_pTexture->realHeight;
|
params.height = m_pTexture->realHeight;
|
||||||
params.internalFormat = graphics::internalcolor::RED;
|
params.internalFormat = internalcolor::RED;
|
||||||
params.format = graphics::color::RED;
|
params.format = color::RED;
|
||||||
params.dataType = graphics::datatype::UNSIGNED_BYTE;
|
params.dataType = datatype::UNSIGNED_BYTE;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
graphics::Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle = graphics::ObjectHandle(m_pTexture->glName);
|
params.handle = m_pTexture->name;
|
||||||
params.target = graphics::target::TEXTURE_2D;
|
params.target = target::TEXTURE_2D;
|
||||||
params.textureUnitIndex = graphics::textureIndices::NoiseTex;
|
params.textureUnitIndex = textureIndices::NoiseTex;
|
||||||
params.minFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.magFilter = textureParameters::FILTER_NEAREST;
|
||||||
gfxContext.setTextureParameters(params);
|
gfxContext.setTextureParameters(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ void NoiseTexture::update()
|
||||||
if (dataSize == 0)
|
if (dataSize == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
graphics::PixelBufferBinder<graphics::PixelWriteBuffer> binder(m_pbuf.get());
|
PixelBufferBinder<PixelWriteBuffer> binder(m_pbuf.get());
|
||||||
GLubyte* ptr = (GLubyte*)m_pbuf->getWriteBuffer(dataSize);
|
GLubyte* ptr = (GLubyte*)m_pbuf->getWriteBuffer(dataSize);
|
||||||
if (ptr == nullptr) {
|
if (ptr == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -86,13 +88,13 @@ void NoiseTexture::update()
|
||||||
}
|
}
|
||||||
m_pbuf->closeWriteBuffer();
|
m_pbuf->closeWriteBuffer();
|
||||||
|
|
||||||
graphics::Context::UpdateTextureDataParams params;
|
Context::UpdateTextureDataParams params;
|
||||||
params.handle = graphics::ObjectHandle(m_pTexture->glName);
|
params.handle = m_pTexture->name;
|
||||||
params.textureUnitIndex = graphics::textureIndices::NoiseTex;
|
params.textureUnitIndex = textureIndices::NoiseTex;
|
||||||
params.width = VI.width;
|
params.width = VI.width;
|
||||||
params.height = VI.height;
|
params.height = VI.height;
|
||||||
params.format = graphics::color::RED;
|
params.format = color::RED;
|
||||||
params.dataType = graphics::datatype::UNSIGNED_BYTE;
|
params.dataType = datatype::UNSIGNED_BYTE;
|
||||||
params.data = m_pbuf->getData();
|
params.data = m_pbuf->getData();
|
||||||
gfxContext.update2DTexture(params);
|
gfxContext.update2DTexture(params);
|
||||||
|
|
||||||
|
|
|
@ -405,7 +405,7 @@ void OGLRender::TexrectDrawer::init()
|
||||||
|
|
||||||
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
const graphics::FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||||
graphics::Context::InitTextureParams initParams;
|
graphics::Context::InitTextureParams initParams;
|
||||||
initParams.handle = graphics::ObjectHandle(m_pTexture->glName);
|
initParams.handle = m_pTexture->name;
|
||||||
initParams.width = m_pTexture->realWidth;
|
initParams.width = m_pTexture->realWidth;
|
||||||
initParams.height = m_pTexture->realHeight;
|
initParams.height = m_pTexture->realHeight;
|
||||||
initParams.internalFormat = fbTexFormats.colorInternalFormat;
|
initParams.internalFormat = fbTexFormats.colorInternalFormat;
|
||||||
|
@ -414,7 +414,7 @@ void OGLRender::TexrectDrawer::init()
|
||||||
gfxContext.init2DTexture(initParams);
|
gfxContext.init2DTexture(initParams);
|
||||||
|
|
||||||
graphics::Context::TexParameters setParams;
|
graphics::Context::TexParameters setParams;
|
||||||
setParams.handle = graphics::ObjectHandle(m_pTexture->glName);
|
setParams.handle = m_pTexture->name;
|
||||||
setParams.target = graphics::target::TEXTURE_2D;
|
setParams.target = graphics::target::TEXTURE_2D;
|
||||||
setParams.minFilter = graphics::textureParameters::FILTER_LINEAR;
|
setParams.minFilter = graphics::textureParameters::FILTER_LINEAR;
|
||||||
setParams.magFilter = graphics::textureParameters::FILTER_LINEAR;
|
setParams.magFilter = graphics::textureParameters::FILTER_LINEAR;
|
||||||
|
@ -427,7 +427,7 @@ void OGLRender::TexrectDrawer::init()
|
||||||
bufTarget.bufferTarget = graphics::bufferTarget::DRAW_FRAMEBUFFER;
|
bufTarget.bufferTarget = graphics::bufferTarget::DRAW_FRAMEBUFFER;
|
||||||
bufTarget.attachment = graphics::bufferAttachment::COLOR_ATTACHMENT0;
|
bufTarget.attachment = graphics::bufferAttachment::COLOR_ATTACHMENT0;
|
||||||
bufTarget.textureTarget = graphics::target::TEXTURE_2D;
|
bufTarget.textureTarget = graphics::target::TEXTURE_2D;
|
||||||
bufTarget.textureHandle = graphics::ObjectHandle(m_pTexture->glName);
|
bufTarget.textureHandle = m_pTexture->name;
|
||||||
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
||||||
|
|
||||||
// check if everything is OK
|
// check if everything is OK
|
||||||
|
@ -1210,7 +1210,7 @@ void OGLRender::_updateStates(RENDER_STATE _renderState) const
|
||||||
if (pDepthTexture == nullptr)
|
if (pDepthTexture == nullptr)
|
||||||
return;
|
return;
|
||||||
glActiveTexture(GL_TEXTURE0 + g_depthTexIndex);
|
glActiveTexture(GL_TEXTURE0 + g_depthTexIndex);
|
||||||
glBindTexture(GL_TEXTURE_2D, pDepthTexture->glName);
|
glBindTexture(GL_TEXTURE_2D, GLuint(pDepthTexture->name));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
|
|
@ -41,7 +41,7 @@ void PaletteTexture::init()
|
||||||
|
|
||||||
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||||
Context::InitTextureParams initParams;
|
Context::InitTextureParams initParams;
|
||||||
initParams.handle = ObjectHandle(m_pTexture->glName);
|
initParams.handle = m_pTexture->name;
|
||||||
initParams.ImageUnit = textureImageUnits::Tlut;
|
initParams.ImageUnit = textureImageUnits::Tlut;
|
||||||
initParams.width = m_pTexture->realWidth;
|
initParams.width = m_pTexture->realWidth;
|
||||||
initParams.height = m_pTexture->realHeight;
|
initParams.height = m_pTexture->realHeight;
|
||||||
|
@ -51,7 +51,7 @@ void PaletteTexture::init()
|
||||||
gfxContext.init2DTexture(initParams);
|
gfxContext.init2DTexture(initParams);
|
||||||
|
|
||||||
Context::TexParameters setParams;
|
Context::TexParameters setParams;
|
||||||
setParams.handle = ObjectHandle(m_pTexture->glName);
|
setParams.handle = m_pTexture->name;
|
||||||
setParams.target = target::TEXTURE_2D;
|
setParams.target = target::TEXTURE_2D;
|
||||||
setParams.textureUnitIndex = textureIndices::PaletteTex;
|
setParams.textureUnitIndex = textureIndices::PaletteTex;
|
||||||
setParams.minFilter = textureParameters::FILTER_NEAREST;
|
setParams.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
|
@ -103,7 +103,7 @@ void PaletteTexture::update()
|
||||||
|
|
||||||
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||||
Context::UpdateTextureDataParams params;
|
Context::UpdateTextureDataParams params;
|
||||||
params.handle = ObjectHandle(m_pTexture->glName);
|
params.handle = m_pTexture->name;
|
||||||
params.ImageUnit = textureImageUnits::Tlut;
|
params.ImageUnit = textureImageUnits::Tlut;
|
||||||
params.textureUnitIndex = textureIndices::PaletteTex;
|
params.textureUnitIndex = textureIndices::PaletteTex;
|
||||||
params.width = m_pTexture->realWidth;
|
params.width = m_pTexture->realWidth;
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include <Graphics/Parameters.h>
|
#include <Graphics/Parameters.h>
|
||||||
#include "DisplayWindow.h"
|
#include "DisplayWindow.h"
|
||||||
|
|
||||||
|
using namespace graphics;
|
||||||
|
|
||||||
#define NEW_POST_PROCESSOR
|
#define NEW_POST_PROCESSOR
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
|
@ -252,20 +254,20 @@ void _initTexture(CachedTexture * pTexture)
|
||||||
pTexture->textureBytes = pTexture->realWidth * pTexture->realHeight * 4;
|
pTexture->textureBytes = pTexture->realWidth * pTexture->realHeight * 4;
|
||||||
textureCache().addFrameBufferTextureSize(pTexture->textureBytes);
|
textureCache().addFrameBufferTextureSize(pTexture->textureBytes);
|
||||||
|
|
||||||
graphics::Context::InitTextureParams initParams;
|
Context::InitTextureParams initParams;
|
||||||
initParams.handle = graphics::ObjectHandle(pTexture->glName);
|
initParams.handle = pTexture->name;
|
||||||
initParams.width = pTexture->realWidth;
|
initParams.width = pTexture->realWidth;
|
||||||
initParams.height = pTexture->realHeight;
|
initParams.height = pTexture->realHeight;
|
||||||
initParams.internalFormat = graphics::internalcolor::RGBA;
|
initParams.internalFormat = internalcolor::RGBA;
|
||||||
initParams.format = graphics::color::RGBA;
|
initParams.format = color::RGBA;
|
||||||
initParams.dataType = graphics::datatype::UNSIGNED_BYTE;
|
initParams.dataType = datatype::UNSIGNED_BYTE;
|
||||||
gfxContext.init2DTexture(initParams);
|
gfxContext.init2DTexture(initParams);
|
||||||
|
|
||||||
graphics::Context::TexParameters setParams;
|
Context::TexParameters setParams;
|
||||||
setParams.handle = graphics::ObjectHandle(pTexture->glName);
|
setParams.handle = pTexture->name;
|
||||||
setParams.target = graphics::target::TEXTURE_2D;
|
setParams.target = target::TEXTURE_2D;
|
||||||
setParams.minFilter = graphics::textureParameters::FILTER_NEAREST;
|
setParams.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
setParams.magFilter = graphics::textureParameters::FILTER_NEAREST;
|
setParams.magFilter = textureParameters::FILTER_NEAREST;
|
||||||
gfxContext.setTextureParameters(setParams);
|
gfxContext.setTextureParameters(setParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,22 +280,22 @@ CachedTexture * _createTexture()
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void _initFBO(graphics::ObjectHandle _FBO, CachedTexture * _pTexture)
|
void _initFBO(ObjectHandle _FBO, CachedTexture * _pTexture)
|
||||||
{
|
{
|
||||||
graphics::Context::FrameBufferRenderTarget bufTarget;
|
Context::FrameBufferRenderTarget bufTarget;
|
||||||
bufTarget.bufferHandle = _FBO;
|
bufTarget.bufferHandle = _FBO;
|
||||||
bufTarget.bufferTarget = graphics::bufferTarget::DRAW_FRAMEBUFFER;
|
bufTarget.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
||||||
bufTarget.attachment = graphics::bufferAttachment::COLOR_ATTACHMENT0;
|
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
||||||
bufTarget.textureTarget = graphics::target::TEXTURE_2D;
|
bufTarget.textureTarget = target::TEXTURE_2D;
|
||||||
bufTarget.textureHandle = graphics::ObjectHandle(_pTexture->glName);
|
bufTarget.textureHandle = _pTexture->name;
|
||||||
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
||||||
assert(checkFBO());
|
assert(checkFBO());
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
graphics::ObjectHandle _createFBO(CachedTexture * _pTexture)
|
ObjectHandle _createFBO(CachedTexture * _pTexture)
|
||||||
{
|
{
|
||||||
graphics::ObjectHandle FBO = gfxContext.createFramebuffer();
|
ObjectHandle FBO = gfxContext.createFramebuffer();
|
||||||
_initFBO(FBO, _pTexture);
|
_initFBO(FBO, _pTexture);
|
||||||
return FBO;
|
return FBO;
|
||||||
}
|
}
|
||||||
|
@ -311,10 +313,10 @@ void PostProcessor::_initCommon()
|
||||||
{
|
{
|
||||||
m_pResultBuffer = new FrameBuffer();
|
m_pResultBuffer = new FrameBuffer();
|
||||||
_initTexture(m_pResultBuffer->m_pTexture);
|
_initTexture(m_pResultBuffer->m_pTexture);
|
||||||
_initFBO(graphics::ObjectHandle(m_pResultBuffer->m_FBO), m_pResultBuffer->m_pTexture);
|
_initFBO(ObjectHandle(m_pResultBuffer->m_FBO), m_pResultBuffer->m_pTexture);
|
||||||
|
|
||||||
gfxContext.bindFramebuffer(graphics::bufferTarget::DRAW_FRAMEBUFFER,
|
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER,
|
||||||
graphics::ObjectHandle());
|
ObjectHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessor::_initGammaCorrection()
|
void PostProcessor::_initGammaCorrection()
|
||||||
|
@ -478,14 +480,14 @@ void PostProcessor::_preDraw(FrameBuffer * _pBuffer)
|
||||||
} else
|
} else
|
||||||
m_pTextureOriginal = _pBuffer->m_pTexture;
|
m_pTextureOriginal = _pBuffer->m_pTexture;
|
||||||
|
|
||||||
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER,
|
gfxContext.bindFramebuffer(bufferTarget::READ_FRAMEBUFFER,
|
||||||
graphics::ObjectHandle());
|
ObjectHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessor::_postDraw()
|
void PostProcessor::_postDraw()
|
||||||
{
|
{
|
||||||
gfxContext.bindFramebuffer(graphics::bufferTarget::DRAW_FRAMEBUFFER,
|
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER,
|
||||||
graphics::ObjectHandle());
|
ObjectHandle());
|
||||||
|
|
||||||
gfxContext.resetShaderProgram();
|
gfxContext.resetShaderProgram();
|
||||||
}
|
}
|
||||||
|
@ -578,8 +580,8 @@ FrameBuffer * PostProcessor::doGammaCorrection(FrameBuffer * _pBuffer)
|
||||||
|
|
||||||
_preDraw(_pBuffer);
|
_preDraw(_pBuffer);
|
||||||
|
|
||||||
gfxContext.bindFramebuffer(graphics::bufferTarget::DRAW_FRAMEBUFFER,
|
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER,
|
||||||
graphics::ObjectHandle(m_pResultBuffer->m_FBO));
|
ObjectHandle(m_pResultBuffer->m_FBO));
|
||||||
|
|
||||||
CachedTexture * pDstTex = m_pResultBuffer->m_pTexture;
|
CachedTexture * pDstTex = m_pResultBuffer->m_pTexture;
|
||||||
GraphicsDrawer::CopyRectParams copyParams;
|
GraphicsDrawer::CopyRectParams copyParams;
|
||||||
|
@ -597,7 +599,7 @@ FrameBuffer * PostProcessor::doGammaCorrection(FrameBuffer * _pBuffer)
|
||||||
copyParams.dstWidth = pDstTex->realWidth;
|
copyParams.dstWidth = pDstTex->realWidth;
|
||||||
copyParams.dstHeight = pDstTex->realHeight;
|
copyParams.dstHeight = pDstTex->realHeight;
|
||||||
copyParams.tex[0] = m_pTextureOriginal;
|
copyParams.tex[0] = m_pTextureOriginal;
|
||||||
copyParams.filter = graphics::textureParameters::FILTER_NEAREST;
|
copyParams.filter = textureParameters::FILTER_NEAREST;
|
||||||
copyParams.combiner = m_gammaCorrectionProgram.get();
|
copyParams.combiner = m_gammaCorrectionProgram.get();
|
||||||
|
|
||||||
dwnd().getDrawer().copyTexturedRect(copyParams);
|
dwnd().getDrawer().copyTexturedRect(copyParams);
|
||||||
|
@ -617,8 +619,8 @@ FrameBuffer * PostProcessor::doOrientationCorrection(FrameBuffer * _pBuffer)
|
||||||
_preDraw(_pBuffer);
|
_preDraw(_pBuffer);
|
||||||
|
|
||||||
|
|
||||||
gfxContext.bindFramebuffer(graphics::bufferTarget::DRAW_FRAMEBUFFER,
|
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER,
|
||||||
graphics::ObjectHandle(m_pResultBuffer->m_FBO));
|
ObjectHandle(m_pResultBuffer->m_FBO));
|
||||||
|
|
||||||
CachedTexture * pDstTex = m_pResultBuffer->m_pTexture;
|
CachedTexture * pDstTex = m_pResultBuffer->m_pTexture;
|
||||||
GraphicsDrawer::CopyRectParams copyParams;
|
GraphicsDrawer::CopyRectParams copyParams;
|
||||||
|
@ -636,7 +638,7 @@ FrameBuffer * PostProcessor::doOrientationCorrection(FrameBuffer * _pBuffer)
|
||||||
copyParams.dstWidth = pDstTex->realWidth;
|
copyParams.dstWidth = pDstTex->realWidth;
|
||||||
copyParams.dstHeight = pDstTex->realHeight;
|
copyParams.dstHeight = pDstTex->realHeight;
|
||||||
copyParams.tex[0] = m_pTextureOriginal;
|
copyParams.tex[0] = m_pTextureOriginal;
|
||||||
copyParams.filter = graphics::textureParameters::FILTER_NEAREST;
|
copyParams.filter = textureParameters::FILTER_NEAREST;
|
||||||
copyParams.combiner = m_orientationCorrectionProgram.get();
|
copyParams.combiner = m_orientationCorrectionProgram.get();
|
||||||
|
|
||||||
dwnd().getDrawer().copyTexturedRect(copyParams);
|
dwnd().getDrawer().copyTexturedRect(copyParams);
|
||||||
|
|
205
src/Textures.cpp
205
src/Textures.cpp
|
@ -21,6 +21,7 @@
|
||||||
#include "DisplayWindow.h"
|
#include "DisplayWindow.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace graphics;
|
||||||
|
|
||||||
inline u32 GetNone( u64 *src, u16 x, u16 i, u8 palette )
|
inline u32 GetNone( u64 *src, u16 x, u16 i, u8 palette )
|
||||||
{
|
{
|
||||||
|
@ -472,15 +473,15 @@ void TextureCache::init()
|
||||||
m_pDummy = addFrameBufferTexture(false); // we don't want to remove dummy texture
|
m_pDummy = addFrameBufferTexture(false); // we don't want to remove dummy texture
|
||||||
_initDummyTexture(m_pDummy);
|
_initDummyTexture(m_pDummy);
|
||||||
|
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(m_pDummy->glName);
|
params.handle = m_pDummy->name;
|
||||||
params.mipMapLevel = 0;
|
params.mipMapLevel = 0;
|
||||||
params.msaaLevel = 0;
|
params.msaaLevel = 0;
|
||||||
params.width = m_pDummy->realWidth;
|
params.width = m_pDummy->realWidth;
|
||||||
params.height = m_pDummy->realHeight;
|
params.height = m_pDummy->realHeight;
|
||||||
params.format = graphics::color::RGBA;
|
params.format = color::RGBA;
|
||||||
params.internalFormat = graphics::internalcolor::RGBA;
|
params.internalFormat = internalcolor::RGBA;
|
||||||
params.dataType = graphics::datatype::UNSIGNED_BYTE;
|
params.dataType = datatype::UNSIGNED_BYTE;
|
||||||
params.data = dummyTexture;
|
params.data = dummyTexture;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
|
|
||||||
|
@ -491,19 +492,19 @@ void TextureCache::init()
|
||||||
|
|
||||||
|
|
||||||
m_pMSDummy = nullptr;
|
m_pMSDummy = nullptr;
|
||||||
if (config.video.multisampling != 0 && gfxContext.isSupported(graphics::SpecialFeatures::Multisampling)) {
|
if (config.video.multisampling != 0 && gfxContext.isSupported(SpecialFeatures::Multisampling)) {
|
||||||
m_pMSDummy = addFrameBufferTexture(true); // we don't want to remove dummy texture
|
m_pMSDummy = addFrameBufferTexture(true); // we don't want to remove dummy texture
|
||||||
_initDummyTexture(m_pMSDummy);
|
_initDummyTexture(m_pMSDummy);
|
||||||
|
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(m_pMSDummy->glName);
|
params.handle = m_pMSDummy->name;
|
||||||
params.mipMapLevel = 0;
|
params.mipMapLevel = 0;
|
||||||
params.msaaLevel = config.video.multisampling;
|
params.msaaLevel = config.video.multisampling;
|
||||||
params.width = m_pMSDummy->realWidth;
|
params.width = m_pMSDummy->realWidth;
|
||||||
params.height = m_pMSDummy->realHeight;
|
params.height = m_pMSDummy->realHeight;
|
||||||
params.format = graphics::color::RGBA;
|
params.format = color::RGBA;
|
||||||
params.internalFormat = graphics::internalcolor::RGBA;
|
params.internalFormat = internalcolor::RGBA;
|
||||||
params.dataType = graphics::datatype::UNSIGNED_BYTE;
|
params.dataType = datatype::UNSIGNED_BYTE;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
|
|
||||||
activateMSDummy(0);
|
activateMSDummy(0);
|
||||||
|
@ -518,12 +519,12 @@ void TextureCache::destroy()
|
||||||
current[0] = current[1] = nullptr;
|
current[0] = current[1] = nullptr;
|
||||||
|
|
||||||
for (Textures::const_iterator cur = m_textures.cbegin(); cur != m_textures.cend(); ++cur)
|
for (Textures::const_iterator cur = m_textures.cbegin(); cur != m_textures.cend(); ++cur)
|
||||||
glDeleteTextures( 1, &cur->glName );
|
gfxContext.deleteTexture(cur->name);
|
||||||
m_textures.clear();
|
m_textures.clear();
|
||||||
m_lruTextureLocations.clear();
|
m_lruTextureLocations.clear();
|
||||||
|
|
||||||
for (FBTextures::const_iterator cur = m_fbTextures.cbegin(); cur != m_fbTextures.cend(); ++cur)
|
for (FBTextures::const_iterator cur = m_fbTextures.cbegin(); cur != m_fbTextures.cend(); ++cur)
|
||||||
glDeleteTextures( 1, &cur->second.glName );
|
gfxContext.deleteTexture(cur->second.name);
|
||||||
m_fbTextures.clear();
|
m_fbTextures.clear();
|
||||||
|
|
||||||
m_cachedBytes = 0;
|
m_cachedBytes = 0;
|
||||||
|
@ -539,7 +540,7 @@ void TextureCache::_checkCacheSize()
|
||||||
if (m_textures.size() >= maxCacheSize) {
|
if (m_textures.size() >= maxCacheSize) {
|
||||||
CachedTexture& clsTex = m_textures.back();
|
CachedTexture& clsTex = m_textures.back();
|
||||||
m_cachedBytes -= clsTex.textureBytes;
|
m_cachedBytes -= clsTex.textureBytes;
|
||||||
glDeleteTextures(1, &clsTex.glName);
|
gfxContext.deleteTexture(clsTex.name);
|
||||||
m_lruTextureLocations.erase(clsTex.crc);
|
m_lruTextureLocations.erase(clsTex.crc);
|
||||||
m_textures.pop_back();
|
m_textures.pop_back();
|
||||||
}
|
}
|
||||||
|
@ -552,7 +553,7 @@ void TextureCache::_checkCacheSize()
|
||||||
--iter;
|
--iter;
|
||||||
CachedTexture& tex = *iter;
|
CachedTexture& tex = *iter;
|
||||||
m_cachedBytes -= tex.textureBytes;
|
m_cachedBytes -= tex.textureBytes;
|
||||||
glDeleteTextures(1, &tex.glName);
|
gfxContext.deleteTexture(tex.name);
|
||||||
m_lruTextureLocations.erase(tex.crc);
|
m_lruTextureLocations.erase(tex.crc);
|
||||||
} while (m_cachedBytes > m_maxBytes && iter != m_textures.cbegin());
|
} while (m_cachedBytes > m_maxBytes && iter != m_textures.cbegin());
|
||||||
m_textures.erase(iter, m_textures.end());
|
m_textures.erase(iter, m_textures.end());
|
||||||
|
@ -563,7 +564,7 @@ CachedTexture * TextureCache::_addTexture(u32 _crc32)
|
||||||
if (m_curUnpackAlignment == 0)
|
if (m_curUnpackAlignment == 0)
|
||||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &m_curUnpackAlignment);
|
glGetIntegerv(GL_UNPACK_ALIGNMENT, &m_curUnpackAlignment);
|
||||||
_checkCacheSize();
|
_checkCacheSize();
|
||||||
m_textures.emplace_front(u32(gfxContext.createTexture(graphics::target::TEXTURE_2D)));
|
m_textures.emplace_front(gfxContext.createTexture(target::TEXTURE_2D));
|
||||||
Textures::iterator new_iter = m_textures.begin();
|
Textures::iterator new_iter = m_textures.begin();
|
||||||
new_iter->crc = _crc32;
|
new_iter->crc = _crc32;
|
||||||
m_lruTextureLocations.insert(std::pair<u32, Textures::iterator>(_crc32, new_iter));
|
m_lruTextureLocations.insert(std::pair<u32, Textures::iterator>(_crc32, new_iter));
|
||||||
|
@ -574,18 +575,18 @@ void TextureCache::removeFrameBufferTexture(CachedTexture * _pTexture)
|
||||||
{
|
{
|
||||||
if (_pTexture == nullptr)
|
if (_pTexture == nullptr)
|
||||||
return;
|
return;
|
||||||
FBTextures::const_iterator iter = m_fbTextures.find(_pTexture->glName);
|
FBTextures::const_iterator iter = m_fbTextures.find(_pTexture->name);
|
||||||
assert(iter != m_fbTextures.cend());
|
assert(iter != m_fbTextures.cend());
|
||||||
m_cachedBytes -= iter->second.textureBytes;
|
m_cachedBytes -= iter->second.textureBytes;
|
||||||
gfxContext.deleteTexture(graphics::ObjectHandle(iter->second.glName));
|
gfxContext.deleteTexture(ObjectHandle(iter->second.name));
|
||||||
m_fbTextures.erase(iter);
|
m_fbTextures.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedTexture * TextureCache::addFrameBufferTexture(bool _multisample)
|
CachedTexture * TextureCache::addFrameBufferTexture(bool _multisample)
|
||||||
{
|
{
|
||||||
_checkCacheSize();
|
_checkCacheSize();
|
||||||
u32 texName(gfxContext.createTexture(_multisample ?
|
ObjectHandle texName(gfxContext.createTexture(_multisample ?
|
||||||
graphics::target::TEXTURE_2D_MULTISAMPLE : graphics::target::TEXTURE_2D));
|
target::TEXTURE_2D_MULTISAMPLE : target::TEXTURE_2D));
|
||||||
m_fbTextures.emplace(texName, texName);
|
m_fbTextures.emplace(texName, texName);
|
||||||
return &m_fbTextures.at(texName);
|
return &m_fbTextures.at(texName);
|
||||||
}
|
}
|
||||||
|
@ -748,15 +749,15 @@ bool TextureCache::_loadHiresBackground(CachedTexture *_pTexture)
|
||||||
bpl, paladdr);
|
bpl, paladdr);
|
||||||
GHQTexInfo ghqTexInfo;
|
GHQTexInfo ghqTexInfo;
|
||||||
if (txfilter_hirestex(_pTexture->crc, ricecrc, palette, &ghqTexInfo)) {
|
if (txfilter_hirestex(_pTexture->crc, ricecrc, palette, &ghqTexInfo)) {
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
params.mipMapLevel = 0;
|
params.mipMapLevel = 0;
|
||||||
params.msaaLevel = 0;
|
params.msaaLevel = 0;
|
||||||
params.width = ghqTexInfo.width;
|
params.width = ghqTexInfo.width;
|
||||||
params.height = ghqTexInfo.height;
|
params.height = ghqTexInfo.height;
|
||||||
params.format = graphics::Parameter(ghqTexInfo.texture_format);
|
params.format = Parameter(ghqTexInfo.texture_format);
|
||||||
params.internalFormat = graphics::Parameter(ghqTexInfo.format);
|
params.internalFormat = Parameter(ghqTexInfo.format);
|
||||||
params.dataType = graphics::Parameter(ghqTexInfo.pixel_type);
|
params.dataType = Parameter(ghqTexInfo.pixel_type);
|
||||||
params.data = ghqTexInfo.data;
|
params.data = ghqTexInfo.data;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
|
|
||||||
|
@ -835,15 +836,15 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
|
||||||
ghqTexInfo.format != GL_RGBA &&
|
ghqTexInfo.format != GL_RGBA &&
|
||||||
m_curUnpackAlignment > 1)
|
m_curUnpackAlignment > 1)
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(pTexture->glName);
|
params.handle = pTexture->name;
|
||||||
params.mipMapLevel = 0;
|
params.mipMapLevel = 0;
|
||||||
params.msaaLevel = 0;
|
params.msaaLevel = 0;
|
||||||
params.width = ghqTexInfo.width;
|
params.width = ghqTexInfo.width;
|
||||||
params.height = ghqTexInfo.height;
|
params.height = ghqTexInfo.height;
|
||||||
params.format = graphics::Parameter(ghqTexInfo.texture_format);
|
params.format = Parameter(ghqTexInfo.texture_format);
|
||||||
params.internalFormat = graphics::Parameter(ghqTexInfo.format);
|
params.internalFormat = Parameter(ghqTexInfo.format);
|
||||||
params.dataType = graphics::Parameter(ghqTexInfo.pixel_type);
|
params.dataType = Parameter(ghqTexInfo.pixel_type);
|
||||||
params.data = ghqTexInfo.data;
|
params.data = ghqTexInfo.data;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
_updateCachedTexture(ghqTexInfo, pTexture);
|
_updateCachedTexture(ghqTexInfo, pTexture);
|
||||||
|
@ -853,15 +854,15 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
|
||||||
if (!bLoaded) {
|
if (!bLoaded) {
|
||||||
if (pTexture->realWidth % 2 != 0 && glInternalFormat != GL_RGBA)
|
if (pTexture->realWidth % 2 != 0 && glInternalFormat != GL_RGBA)
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(pTexture->glName);
|
params.handle = pTexture->name;
|
||||||
params.mipMapLevel = 0;
|
params.mipMapLevel = 0;
|
||||||
params.msaaLevel = 0;
|
params.msaaLevel = 0;
|
||||||
params.width = pTexture->realWidth;
|
params.width = pTexture->realWidth;
|
||||||
params.height = pTexture->realHeight;
|
params.height = pTexture->realHeight;
|
||||||
params.format = graphics::color::RGBA;
|
params.format = color::RGBA;
|
||||||
params.internalFormat = graphics::Parameter(glInternalFormat);
|
params.internalFormat = Parameter(glInternalFormat);
|
||||||
params.dataType = graphics::Parameter(glType);
|
params.dataType = Parameter(glType);
|
||||||
params.data = pDest;
|
params.data = pDest;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
}
|
}
|
||||||
|
@ -915,15 +916,15 @@ bool TextureCache::_loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 &
|
||||||
_ricecrc = txfilter_checksum(addr, tile_width, tile_height, (unsigned short)(_pTexture->format << 8 | _pTexture->size), bpl, paladdr);
|
_ricecrc = txfilter_checksum(addr, tile_width, tile_height, (unsigned short)(_pTexture->format << 8 | _pTexture->size), bpl, paladdr);
|
||||||
GHQTexInfo ghqTexInfo;
|
GHQTexInfo ghqTexInfo;
|
||||||
if (txfilter_hirestex(_pTexture->crc, _ricecrc, palette, &ghqTexInfo)) {
|
if (txfilter_hirestex(_pTexture->crc, _ricecrc, palette, &ghqTexInfo)) {
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
params.mipMapLevel = 0;
|
params.mipMapLevel = 0;
|
||||||
params.msaaLevel = 0;
|
params.msaaLevel = 0;
|
||||||
params.width = ghqTexInfo.width;
|
params.width = ghqTexInfo.width;
|
||||||
params.height = ghqTexInfo.height;
|
params.height = ghqTexInfo.height;
|
||||||
params.internalFormat = graphics::Parameter(ghqTexInfo.format);
|
params.internalFormat = Parameter(ghqTexInfo.format);
|
||||||
params.format = graphics::Parameter(ghqTexInfo.texture_format);
|
params.format = Parameter(ghqTexInfo.texture_format);
|
||||||
params.dataType = graphics::Parameter(ghqTexInfo.pixel_type);
|
params.dataType = Parameter(ghqTexInfo.pixel_type);
|
||||||
params.data = ghqTexInfo.data;
|
params.data = ghqTexInfo.data;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
assert(!isGLError());
|
assert(!isGLError());
|
||||||
|
@ -945,15 +946,15 @@ void TextureCache::_loadDepthTexture(CachedTexture * _pTexture, u16* _pDest)
|
||||||
for (u32 t = 0; t < numTexels; ++t)
|
for (u32 t = 0; t < numTexels; ++t)
|
||||||
pDestF[t] = _pDest[t] / 65535.0f;
|
pDestF[t] = _pDest[t] / 65535.0f;
|
||||||
|
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
params.mipMapLevel = 0;
|
params.mipMapLevel = 0;
|
||||||
params.msaaLevel = 0;
|
params.msaaLevel = 0;
|
||||||
params.width = _pTexture->realWidth;
|
params.width = _pTexture->realWidth;
|
||||||
params.height = _pTexture->realHeight;
|
params.height = _pTexture->realHeight;
|
||||||
params.internalFormat = graphics::internalcolor::RED;
|
params.internalFormat = internalcolor::RED;
|
||||||
params.format = graphics::color::RED;
|
params.format = color::RED;
|
||||||
params.dataType = graphics::datatype::FLOAT;
|
params.dataType = datatype::FLOAT;
|
||||||
params.data = pDestF;
|
params.data = pDestF;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
free(pDestF);
|
free(pDestF);
|
||||||
|
@ -1116,7 +1117,8 @@ void TextureCache::_load(u32 _tile, CachedTexture *_pTexture)
|
||||||
if (config.generalEmulation.enableLOD != 0 && gSP.texture.level > 1)
|
if (config.generalEmulation.enableLOD != 0 && gSP.texture.level > 1)
|
||||||
_pTexture->max_level = static_cast<u8>(_tile == 0 ? 0 : gSP.texture.level - 1);
|
_pTexture->max_level = static_cast<u8>(_tile == 0 ? 0 : gSP.texture.level - 1);
|
||||||
|
|
||||||
CachedTexture tmptex(0);
|
ObjectHandle name;
|
||||||
|
CachedTexture tmptex(name);
|
||||||
memcpy(&tmptex, _pTexture, sizeof(CachedTexture));
|
memcpy(&tmptex, _pTexture, sizeof(CachedTexture));
|
||||||
|
|
||||||
line = tmptex.line;
|
line = tmptex.line;
|
||||||
|
@ -1149,15 +1151,15 @@ void TextureCache::_load(u32 _tile, CachedTexture *_pTexture)
|
||||||
if (txfilter_filter((u8*)pDest, tmptex.realWidth, tmptex.realHeight,
|
if (txfilter_filter((u8*)pDest, tmptex.realWidth, tmptex.realHeight,
|
||||||
glInternalFormat, (uint64)_pTexture->crc,
|
glInternalFormat, (uint64)_pTexture->crc,
|
||||||
&ghqTexInfo) != 0 && ghqTexInfo.data != nullptr) {
|
&ghqTexInfo) != 0 && ghqTexInfo.data != nullptr) {
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
params.mipMapLevel = 0;
|
params.mipMapLevel = 0;
|
||||||
params.msaaLevel = 0;
|
params.msaaLevel = 0;
|
||||||
params.width = ghqTexInfo.width;
|
params.width = ghqTexInfo.width;
|
||||||
params.height = ghqTexInfo.height;
|
params.height = ghqTexInfo.height;
|
||||||
params.internalFormat = graphics::Parameter(ghqTexInfo.format);
|
params.internalFormat = Parameter(ghqTexInfo.format);
|
||||||
params.format = graphics::Parameter(ghqTexInfo.texture_format);
|
params.format = Parameter(ghqTexInfo.texture_format);
|
||||||
params.dataType = graphics::Parameter(ghqTexInfo.pixel_type);
|
params.dataType = Parameter(ghqTexInfo.pixel_type);
|
||||||
params.data = ghqTexInfo.data;
|
params.data = ghqTexInfo.data;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
_updateCachedTexture(ghqTexInfo, _pTexture);
|
_updateCachedTexture(ghqTexInfo, _pTexture);
|
||||||
|
@ -1169,16 +1171,16 @@ void TextureCache::_load(u32 _tile, CachedTexture *_pTexture)
|
||||||
glInternalFormat != GL_RGBA &&
|
glInternalFormat != GL_RGBA &&
|
||||||
m_curUnpackAlignment > 1)
|
m_curUnpackAlignment > 1)
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
||||||
graphics::Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = graphics::ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
params.mipMapLevel = mipLevel;
|
params.mipMapLevel = mipLevel;
|
||||||
params.mipMapLevels = _pTexture->max_level + 1;
|
params.mipMapLevels = _pTexture->max_level + 1;
|
||||||
params.msaaLevel = 0;
|
params.msaaLevel = 0;
|
||||||
params.width = tmptex.realWidth;
|
params.width = tmptex.realWidth;
|
||||||
params.height = tmptex.realHeight;
|
params.height = tmptex.realHeight;
|
||||||
params.internalFormat = graphics::Parameter(glInternalFormat);
|
params.internalFormat = Parameter(glInternalFormat);
|
||||||
params.format = graphics::color::RGBA;
|
params.format = color::RGBA;
|
||||||
params.dataType = graphics::Parameter(glType);
|
params.dataType = Parameter(glType);
|
||||||
params.data = pDest;
|
params.data = pDest;
|
||||||
gfxContext.init2DTexture(params);
|
gfxContext.init2DTexture(params);
|
||||||
}
|
}
|
||||||
|
@ -1249,69 +1251,69 @@ u32 _calculateCRC(u32 _t, const TextureParams & _params, u32 _bytes)
|
||||||
void TextureCache::activateTexture(u32 _t, CachedTexture *_pTexture)
|
void TextureCache::activateTexture(u32 _t, CachedTexture *_pTexture)
|
||||||
{
|
{
|
||||||
|
|
||||||
graphics::Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle = graphics::ObjectHandle(_pTexture->glName);
|
params.handle = _pTexture->name;
|
||||||
if (config.video.multisampling > 0 && _pTexture->frameBufferTexture == CachedTexture::fbMultiSample) {
|
if (config.video.multisampling > 0 && _pTexture->frameBufferTexture == CachedTexture::fbMultiSample) {
|
||||||
params.target = graphics::target::TEXTURE_2D_MULTISAMPLE;
|
params.target = target::TEXTURE_2D_MULTISAMPLE;
|
||||||
params.textureUnitIndex = graphics::textureIndices::MSTex[_t];
|
params.textureUnitIndex = textureIndices::MSTex[_t];
|
||||||
} else {
|
} else {
|
||||||
params.target = graphics::target::TEXTURE_2D;
|
params.target = target::TEXTURE_2D;
|
||||||
params.textureUnitIndex = graphics::textureIndices::Tex[_t];
|
params.textureUnitIndex = textureIndices::Tex[_t];
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool bUseBilinear = (gDP.otherMode.textureFilter | (gSP.objRendermode&G_OBJRM_BILERP)) != 0;
|
const bool bUseBilinear = (gDP.otherMode.textureFilter | (gSP.objRendermode&G_OBJRM_BILERP)) != 0;
|
||||||
const bool bUseLOD = currentCombiner()->usesLOD();
|
const bool bUseLOD = currentCombiner()->usesLOD();
|
||||||
const GLint texLevel = bUseLOD ? _pTexture->max_level : 0;
|
const GLint texLevel = bUseLOD ? _pTexture->max_level : 0;
|
||||||
params.maxMipmapLevel = graphics::Parameter(texLevel);
|
params.maxMipmapLevel = Parameter(texLevel);
|
||||||
|
|
||||||
if (config.texture.bilinearMode == BILINEAR_STANDARD) {
|
if (config.texture.bilinearMode == BILINEAR_STANDARD) {
|
||||||
if (bUseBilinear) {
|
if (bUseBilinear) {
|
||||||
if (texLevel > 0)
|
if (texLevel > 0)
|
||||||
params.minFilter = graphics::textureParameters::FILTER_LINEAR_MIPMAP_NEAREST;
|
params.minFilter = textureParameters::FILTER_LINEAR_MIPMAP_NEAREST;
|
||||||
else
|
else
|
||||||
params.minFilter = graphics::textureParameters::FILTER_LINEAR;
|
params.minFilter = textureParameters::FILTER_LINEAR;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_LINEAR;
|
params.magFilter = textureParameters::FILTER_LINEAR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (texLevel > 0)
|
if (texLevel > 0)
|
||||||
params.minFilter = graphics::textureParameters::FILTER_NEAREST_MIPMAP_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST_MIPMAP_NEAREST;
|
||||||
else
|
else
|
||||||
params.minFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.magFilter = textureParameters::FILTER_NEAREST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // 3 point filter
|
else { // 3 point filter
|
||||||
if (texLevel > 0) { // Apply standard bilinear to mipmap textures
|
if (texLevel > 0) { // Apply standard bilinear to mipmap textures
|
||||||
if (bUseBilinear) {
|
if (bUseBilinear) {
|
||||||
params.minFilter = graphics::textureParameters::FILTER_LINEAR_MIPMAP_NEAREST;
|
params.minFilter = textureParameters::FILTER_LINEAR_MIPMAP_NEAREST;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_LINEAR;
|
params.magFilter = textureParameters::FILTER_LINEAR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
params.minFilter = graphics::textureParameters::FILTER_NEAREST_MIPMAP_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST_MIPMAP_NEAREST;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.magFilter = textureParameters::FILTER_NEAREST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (bUseBilinear && config.generalEmulation.enableLOD != 0 && bUseLOD) { // Apply standard bilinear to first tile of mipmap texture
|
else if (bUseBilinear && config.generalEmulation.enableLOD != 0 && bUseLOD) { // Apply standard bilinear to first tile of mipmap texture
|
||||||
params.minFilter = graphics::textureParameters::FILTER_LINEAR;
|
params.minFilter = textureParameters::FILTER_LINEAR;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_LINEAR;
|
params.magFilter = textureParameters::FILTER_LINEAR;
|
||||||
}
|
}
|
||||||
else { // Don't use texture filter. Texture will be filtered by 3 point filter shader
|
else { // Don't use texture filter. Texture will be filtered by 3 point filter shader
|
||||||
params.minFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.magFilter = textureParameters::FILTER_NEAREST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set clamping modes
|
// Set clamping modes
|
||||||
params.wrapS = _pTexture->clampS ? graphics::textureParameters::WRAP_CLAMP_TO_EDGE :
|
params.wrapS = _pTexture->clampS ? textureParameters::WRAP_CLAMP_TO_EDGE :
|
||||||
_pTexture->mirrorS ? graphics::textureParameters::WRAP_MIRRORED_REPEAT
|
_pTexture->mirrorS ? textureParameters::WRAP_MIRRORED_REPEAT
|
||||||
: graphics::textureParameters::WRAP_REPEAT;
|
: textureParameters::WRAP_REPEAT;
|
||||||
params.wrapT = _pTexture->clampT ? graphics::textureParameters::WRAP_CLAMP_TO_EDGE :
|
params.wrapT = _pTexture->clampT ? textureParameters::WRAP_CLAMP_TO_EDGE :
|
||||||
_pTexture->mirrorT ? graphics::textureParameters::WRAP_MIRRORED_REPEAT
|
_pTexture->mirrorT ? textureParameters::WRAP_MIRRORED_REPEAT
|
||||||
: graphics::textureParameters::WRAP_REPEAT;
|
: textureParameters::WRAP_REPEAT;
|
||||||
|
|
||||||
if (dwnd().getDrawer().getDrawingState() == DrawingState::Triangle && config.texture.maxAnisotropyF > 0.0f)
|
if (dwnd().getDrawer().getDrawingState() == DrawingState::Triangle && config.texture.maxAnisotropyF > 0.0f)
|
||||||
params.maxAnisotropy = graphics::Parameter(config.texture.maxAnisotropyF);
|
params.maxAnisotropy = Parameter(config.texture.maxAnisotropyF);
|
||||||
|
|
||||||
gfxContext.setTextureParameters(params);
|
gfxContext.setTextureParameters(params);
|
||||||
|
|
||||||
|
@ -1320,23 +1322,23 @@ void TextureCache::activateTexture(u32 _t, CachedTexture *_pTexture)
|
||||||
|
|
||||||
void TextureCache::activateDummy(u32 _t)
|
void TextureCache::activateDummy(u32 _t)
|
||||||
{
|
{
|
||||||
graphics::Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle = graphics::ObjectHandle(m_pDummy->glName);
|
params.handle = m_pDummy->name;
|
||||||
params.target = graphics::target::TEXTURE_2D;
|
params.target = target::TEXTURE_2D;
|
||||||
params.textureUnitIndex = graphics::textureIndices::Tex[_t];
|
params.textureUnitIndex = textureIndices::Tex[_t];
|
||||||
params.minFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.magFilter = textureParameters::FILTER_NEAREST;
|
||||||
gfxContext.setTextureParameters(params);
|
gfxContext.setTextureParameters(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::activateMSDummy(u32 _t)
|
void TextureCache::activateMSDummy(u32 _t)
|
||||||
{
|
{
|
||||||
graphics::Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle = graphics::ObjectHandle(m_pMSDummy->glName);
|
params.handle = m_pMSDummy->name;
|
||||||
params.target = graphics::target::TEXTURE_2D_MULTISAMPLE;
|
params.target = target::TEXTURE_2D_MULTISAMPLE;
|
||||||
params.textureUnitIndex = graphics::textureIndices::MSTex[_t];
|
params.textureUnitIndex = textureIndices::MSTex[_t];
|
||||||
params.minFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
params.magFilter = graphics::textureParameters::FILTER_NEAREST;
|
params.magFilter = textureParameters::FILTER_NEAREST;
|
||||||
gfxContext.setTextureParameters(params);
|
gfxContext.setTextureParameters(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1378,7 +1380,7 @@ void TextureCache::_updateBackground()
|
||||||
glActiveTexture( GL_TEXTURE0 );
|
glActiveTexture( GL_TEXTURE0 );
|
||||||
CachedTexture * pCurrent = _addTexture(crc);
|
CachedTexture * pCurrent = _addTexture(crc);
|
||||||
|
|
||||||
glBindTexture( GL_TEXTURE_2D, pCurrent->glName );
|
glBindTexture( GL_TEXTURE_2D, GLuint(pCurrent->name) );
|
||||||
|
|
||||||
pCurrent->address = gSP.bgImage.address;
|
pCurrent->address = gSP.bgImage.address;
|
||||||
|
|
||||||
|
@ -1424,13 +1426,10 @@ void TextureCache::_clear()
|
||||||
{
|
{
|
||||||
current[0] = current[1] = nullptr;
|
current[0] = current[1] = nullptr;
|
||||||
|
|
||||||
std::vector<GLuint> textureNames;
|
for (auto cur = m_textures.cbegin(); cur != m_textures.cend(); ++cur) {
|
||||||
textureNames.reserve(m_textures.size());
|
|
||||||
for (Textures::const_iterator cur = m_textures.cbegin(); cur != m_textures.cend(); ++cur) {
|
|
||||||
m_cachedBytes -= cur->textureBytes;
|
m_cachedBytes -= cur->textureBytes;
|
||||||
textureNames.push_back(cur->glName);
|
gfxContext.deleteTexture(cur->name);
|
||||||
}
|
}
|
||||||
glDeleteTextures(textureNames.size(), textureNames.data());
|
|
||||||
m_textures.clear();
|
m_textures.clear();
|
||||||
m_lruTextureLocations.clear();
|
m_lruTextureLocations.clear();
|
||||||
}
|
}
|
||||||
|
@ -1531,7 +1530,7 @@ void TextureCache::update(u32 _t)
|
||||||
|
|
||||||
CachedTexture * pCurrent = _addTexture(crc);
|
CachedTexture * pCurrent = _addTexture(crc);
|
||||||
|
|
||||||
glBindTexture( GL_TEXTURE_2D, pCurrent->glName );
|
glBindTexture( GL_TEXTURE_2D, GLuint(pCurrent->name) );
|
||||||
|
|
||||||
pCurrent->address = gDP.loadInfo[pTile->tmem].texAddress;
|
pCurrent->address = gDP.loadInfo[pTile->tmem].texAddress;
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,15 @@
|
||||||
|
|
||||||
#include "CRC.h"
|
#include "CRC.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
|
#include "Graphics/ObjectHandle.h"
|
||||||
|
|
||||||
typedef u32 (*GetTexelFunc)( u64 *src, u16 x, u16 i, u8 palette );
|
typedef u32 (*GetTexelFunc)( u64 *src, u16 x, u16 i, u8 palette );
|
||||||
|
|
||||||
struct CachedTexture
|
struct CachedTexture
|
||||||
{
|
{
|
||||||
CachedTexture(u32 _glName) : glName(_glName), max_level(0), frameBufferTexture(fbNone), bHDTexture(false) {}
|
CachedTexture(graphics::ObjectHandle _name) : name(_name), max_level(0), frameBufferTexture(fbNone), bHDTexture(false) {}
|
||||||
|
|
||||||
u32 glName;
|
graphics::ObjectHandle name;
|
||||||
u32 crc;
|
u32 crc;
|
||||||
// float fulS, fulT;
|
// float fulS, fulT;
|
||||||
// WORD ulS, ulT, lrS, lrT;
|
// WORD ulS, ulT, lrS, lrT;
|
||||||
|
@ -83,7 +84,7 @@ private:
|
||||||
|
|
||||||
typedef std::list<CachedTexture> Textures;
|
typedef std::list<CachedTexture> Textures;
|
||||||
typedef std::map<u32, Textures::iterator> Texture_Locations;
|
typedef std::map<u32, Textures::iterator> Texture_Locations;
|
||||||
typedef std::map<u32, CachedTexture> FBTextures;
|
typedef std::map<graphics::ObjectHandle, CachedTexture> FBTextures;
|
||||||
Textures m_textures;
|
Textures m_textures;
|
||||||
Texture_Locations m_lruTextureLocations;
|
Texture_Locations m_lruTextureLocations;
|
||||||
FBTextures m_fbTextures;
|
FBTextures m_fbTextures;
|
||||||
|
|
|
@ -43,7 +43,7 @@ void ZlutTexture::init()
|
||||||
|
|
||||||
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||||
Context::InitTextureParams initParams;
|
Context::InitTextureParams initParams;
|
||||||
initParams.handle = ObjectHandle(m_pTexture->glName);
|
initParams.handle = m_pTexture->name;
|
||||||
initParams.ImageUnit = textureImageUnits::Zlut;
|
initParams.ImageUnit = textureImageUnits::Zlut;
|
||||||
initParams.width = m_pTexture->realWidth;
|
initParams.width = m_pTexture->realWidth;
|
||||||
initParams.height = m_pTexture->realHeight;
|
initParams.height = m_pTexture->realHeight;
|
||||||
|
@ -54,7 +54,7 @@ void ZlutTexture::init()
|
||||||
gfxContext.init2DTexture(initParams);
|
gfxContext.init2DTexture(initParams);
|
||||||
|
|
||||||
Context::TexParameters setParams;
|
Context::TexParameters setParams;
|
||||||
setParams.handle = ObjectHandle(m_pTexture->glName);
|
setParams.handle = m_pTexture->name;
|
||||||
setParams.target = target::TEXTURE_2D;
|
setParams.target = target::TEXTURE_2D;
|
||||||
setParams.textureUnitIndex = textureIndices::ZLUTTex;
|
setParams.textureUnitIndex = textureIndices::ZLUTTex;
|
||||||
setParams.minFilter = textureParameters::FILTER_NEAREST;
|
setParams.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user