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

Fix internal texture formats for GLES 2.0

This commit is contained in:
Sergey Lipskiy 2017-02-10 16:58:17 +07:00
parent 66fed934c5
commit e011ee56b5
6 changed files with 22 additions and 19 deletions

View File

@ -135,9 +135,9 @@ void Context::bindImageTexture(const BindImageTextureParameters & _params)
m_impl->bindImageTexture(_params); m_impl->bindImageTexture(_params);
} }
u32 Context::convertGHQTextureFormat(u32 _format) const u32 Context::convertInternalTextureFormat(u32 _format) const
{ {
return m_impl->convertGHQTextureFormat(_format); return m_impl->convertInternalTextureFormat(_format);
} }
/*---------------Framebuffer-------------*/ /*---------------Framebuffer-------------*/

View File

@ -138,7 +138,7 @@ namespace graphics {
void bindImageTexture(const BindImageTextureParameters & _params); void bindImageTexture(const BindImageTextureParameters & _params);
u32 convertGHQTextureFormat(u32 _format) const; u32 convertInternalTextureFormat(u32 _format) const;
/*---------------Framebuffer-------------*/ /*---------------Framebuffer-------------*/

View File

@ -33,7 +33,7 @@ namespace graphics {
virtual s32 getTextureUnpackAlignment() const = 0; virtual s32 getTextureUnpackAlignment() const = 0;
virtual s32 getMaxTextureSize() const = 0; virtual s32 getMaxTextureSize() const = 0;
virtual void bindImageTexture(const Context::BindImageTextureParameters & _params) = 0; virtual void bindImageTexture(const Context::BindImageTextureParameters & _params) = 0;
virtual u32 convertGHQTextureFormat(u32 _format) const = 0; virtual u32 convertInternalTextureFormat(u32 _format) const = 0;
virtual FramebufferTextureFormats * getFramebufferTextureFormats() = 0; virtual FramebufferTextureFormats * getFramebufferTextureFormats() = 0;
virtual ObjectHandle createFramebuffer() = 0; virtual ObjectHandle createFramebuffer() = 0;
virtual void deleteFramebuffer(ObjectHandle _name) = 0; virtual void deleteFramebuffer(ObjectHandle _name) = 0;

View File

@ -33,12 +33,6 @@ void ContextImpl::init()
// Correct buffer target parameters, since GLES2 knows only GL_FRAMEBUFFER // Correct buffer target parameters, since GLES2 knows only GL_FRAMEBUFFER
graphics::bufferTarget::DRAW_FRAMEBUFFER = graphics::bufferTarget::FRAMEBUFFER; graphics::bufferTarget::DRAW_FRAMEBUFFER = graphics::bufferTarget::FRAMEBUFFER;
graphics::bufferTarget::READ_FRAMEBUFFER = graphics::bufferTarget::FRAMEBUFFER; graphics::bufferTarget::READ_FRAMEBUFFER = graphics::bufferTarget::FRAMEBUFFER;
// Replace internal color format parameters on formats supported by GLES2
graphics::internalcolorFormat::RGB8 = graphics::InternalColorFormatParam(GL_RGB);
graphics::internalcolorFormat::RGBA8 = graphics::InternalColorFormatParam(GL_RGBA);
graphics::internalcolorFormat::RGBA4 = graphics::InternalColorFormatParam(GL_RGBA);
graphics::internalcolorFormat::RGB5_A1 = graphics::InternalColorFormatParam(GL_RGBA);
} }
if (!m_cachedFunctions) if (!m_cachedFunctions)
@ -227,12 +221,21 @@ void ContextImpl::bindImageTexture(const graphics::Context::BindImageTexturePara
glBindImageTexture(GLuint(_params.imageUnit), GLuint(_params.texture), 0, GL_FALSE, 0, GLenum(_params.accessMode), GLenum(_params.textureFormat)); glBindImageTexture(GLuint(_params.imageUnit), GLuint(_params.texture), 0, GL_FALSE, 0, GLenum(_params.accessMode), GLenum(_params.textureFormat));
} }
u32 ContextImpl::convertGHQTextureFormat(u32 _format) const u32 ContextImpl::convertInternalTextureFormat(u32 _format) const
{ {
if (!m_glInfo.isGLES2) if (!m_glInfo.isGLES2)
return _format; return _format;
switch (_format) {
case GL_RGB8:
return GL_RGB;
case GL_RGBA8:
case GL_RGBA4:
case GL_RGB5_A1:
return GL_RGBA; return GL_RGBA;
}
return _format;
} }
/*---------------Framebuffer-------------*/ /*---------------Framebuffer-------------*/

View File

@ -69,7 +69,7 @@ namespace opengl {
void bindImageTexture(const graphics::Context::BindImageTextureParameters & _params) override; void bindImageTexture(const graphics::Context::BindImageTextureParameters & _params) override;
u32 convertGHQTextureFormat(u32 _format) const override; u32 convertInternalTextureFormat(u32 _format) const override;
/*---------------Framebuffer-------------*/ /*---------------Framebuffer-------------*/

View File

@ -898,7 +898,7 @@ 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)) {
ghqTexInfo.format = gfxContext.convertGHQTextureFormat(ghqTexInfo.format); ghqTexInfo.format = gfxContext.convertInternalTextureFormat(ghqTexInfo.format);
Context::InitTextureParams params; Context::InitTextureParams params;
params.handle = _pTexture->name; params.handle = _pTexture->name;
params.mipMapLevel = 0; params.mipMapLevel = 0;
@ -989,7 +989,7 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
m_curUnpackAlignment > 1) m_curUnpackAlignment > 1)
gfxContext.setTextureUnpackAlignment(2); gfxContext.setTextureUnpackAlignment(2);
ghqTexInfo.format = gfxContext.convertGHQTextureFormat(ghqTexInfo.format); ghqTexInfo.format = gfxContext.convertInternalTextureFormat(ghqTexInfo.format);
Context::InitTextureParams params; Context::InitTextureParams params;
params.handle = pTexture->name; params.handle = pTexture->name;
params.mipMapLevel = 0; params.mipMapLevel = 0;
@ -1015,7 +1015,7 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
params.width = pTexture->realWidth; params.width = pTexture->realWidth;
params.height = pTexture->realHeight; params.height = pTexture->realHeight;
params.format = colorFormat::RGBA; params.format = colorFormat::RGBA;
params.internalFormat = glInternalFormat; params.internalFormat = gfxContext.convertInternalTextureFormat(u32(glInternalFormat));
params.dataType = glType; params.dataType = glType;
params.data = pDest; params.data = pDest;
gfxContext.init2DTexture(params); gfxContext.init2DTexture(params);
@ -1070,7 +1070,7 @@ 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)) {
ghqTexInfo.format = gfxContext.convertGHQTextureFormat(ghqTexInfo.format); ghqTexInfo.format = gfxContext.convertInternalTextureFormat(ghqTexInfo.format);
Context::InitTextureParams params; Context::InitTextureParams params;
params.handle = _pTexture->name; params.handle = _pTexture->name;
params.mipMapLevel = 0; params.mipMapLevel = 0;
@ -1308,7 +1308,7 @@ 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,
(u16)u32(glInternalFormat), (uint64)_pTexture->crc, (u16)u32(glInternalFormat), (uint64)_pTexture->crc,
&ghqTexInfo) != 0 && ghqTexInfo.data != nullptr) { &ghqTexInfo) != 0 && ghqTexInfo.data != nullptr) {
ghqTexInfo.format = gfxContext.convertGHQTextureFormat(ghqTexInfo.format); ghqTexInfo.format = gfxContext.convertInternalTextureFormat(ghqTexInfo.format);
Context::InitTextureParams params; Context::InitTextureParams params;
params.handle = _pTexture->name; params.handle = _pTexture->name;
params.textureUnitIndex = textureIndices::Tex[_tile]; params.textureUnitIndex = textureIndices::Tex[_tile];
@ -1338,7 +1338,7 @@ void TextureCache::_load(u32 _tile, CachedTexture *_pTexture)
params.msaaLevel = 0; params.msaaLevel = 0;
params.width = tmptex.realWidth; params.width = tmptex.realWidth;
params.height = tmptex.realHeight; params.height = tmptex.realHeight;
params.internalFormat = glInternalFormat; params.internalFormat = gfxContext.convertInternalTextureFormat(u32(glInternalFormat));
params.format = colorFormat::RGBA; params.format = colorFormat::RGBA;
params.dataType = glType; params.dataType = glType;
params.data = pDest; params.data = pDest;