diff --git a/src/Graphics/Context.cpp b/src/Graphics/Context.cpp index ca890bf2..f6ed7db4 100644 --- a/src/Graphics/Context.cpp +++ b/src/Graphics/Context.cpp @@ -135,9 +135,9 @@ void Context::bindImageTexture(const BindImageTextureParameters & _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-------------*/ diff --git a/src/Graphics/Context.h b/src/Graphics/Context.h index 1f66fb96..5ba6c93c 100644 --- a/src/Graphics/Context.h +++ b/src/Graphics/Context.h @@ -138,7 +138,7 @@ namespace graphics { void bindImageTexture(const BindImageTextureParameters & _params); - u32 convertGHQTextureFormat(u32 _format) const; + u32 convertInternalTextureFormat(u32 _format) const; /*---------------Framebuffer-------------*/ diff --git a/src/Graphics/ContextImpl.h b/src/Graphics/ContextImpl.h index 475b8ff7..c056c9f5 100644 --- a/src/Graphics/ContextImpl.h +++ b/src/Graphics/ContextImpl.h @@ -33,7 +33,7 @@ namespace graphics { virtual s32 getTextureUnpackAlignment() const = 0; virtual s32 getMaxTextureSize() const = 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 ObjectHandle createFramebuffer() = 0; virtual void deleteFramebuffer(ObjectHandle _name) = 0; diff --git a/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp b/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp index 6a0794eb..aebe4e0b 100644 --- a/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp +++ b/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp @@ -33,12 +33,6 @@ void ContextImpl::init() // Correct buffer target parameters, since GLES2 knows only GL_FRAMEBUFFER graphics::bufferTarget::DRAW_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) @@ -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)); } -u32 ContextImpl::convertGHQTextureFormat(u32 _format) const +u32 ContextImpl::convertInternalTextureFormat(u32 _format) const { if (!m_glInfo.isGLES2) return _format; - return GL_RGBA; + switch (_format) { + case GL_RGB8: + return GL_RGB; + case GL_RGBA8: + case GL_RGBA4: + case GL_RGB5_A1: + return GL_RGBA; + } + + return _format; } /*---------------Framebuffer-------------*/ diff --git a/src/Graphics/OpenGLContext/opengl_ContextImpl.h b/src/Graphics/OpenGLContext/opengl_ContextImpl.h index e42aa481..feb89af0 100644 --- a/src/Graphics/OpenGLContext/opengl_ContextImpl.h +++ b/src/Graphics/OpenGLContext/opengl_ContextImpl.h @@ -69,7 +69,7 @@ namespace opengl { void bindImageTexture(const graphics::Context::BindImageTextureParameters & _params) override; - u32 convertGHQTextureFormat(u32 _format) const override; + u32 convertInternalTextureFormat(u32 _format) const override; /*---------------Framebuffer-------------*/ diff --git a/src/Textures.cpp b/src/Textures.cpp index 6764882d..61661ff6 100644 --- a/src/Textures.cpp +++ b/src/Textures.cpp @@ -898,7 +898,7 @@ bool TextureCache::_loadHiresBackground(CachedTexture *_pTexture) bpl, paladdr); GHQTexInfo ghqTexInfo; if (txfilter_hirestex(_pTexture->crc, ricecrc, palette, &ghqTexInfo)) { - ghqTexInfo.format = gfxContext.convertGHQTextureFormat(ghqTexInfo.format); + ghqTexInfo.format = gfxContext.convertInternalTextureFormat(ghqTexInfo.format); Context::InitTextureParams params; params.handle = _pTexture->name; params.mipMapLevel = 0; @@ -989,7 +989,7 @@ void TextureCache::_loadBackground(CachedTexture *pTexture) m_curUnpackAlignment > 1) gfxContext.setTextureUnpackAlignment(2); - ghqTexInfo.format = gfxContext.convertGHQTextureFormat(ghqTexInfo.format); + ghqTexInfo.format = gfxContext.convertInternalTextureFormat(ghqTexInfo.format); Context::InitTextureParams params; params.handle = pTexture->name; params.mipMapLevel = 0; @@ -1015,7 +1015,7 @@ void TextureCache::_loadBackground(CachedTexture *pTexture) params.width = pTexture->realWidth; params.height = pTexture->realHeight; params.format = colorFormat::RGBA; - params.internalFormat = glInternalFormat; + params.internalFormat = gfxContext.convertInternalTextureFormat(u32(glInternalFormat)); params.dataType = glType; params.data = pDest; 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); GHQTexInfo ghqTexInfo; if (txfilter_hirestex(_pTexture->crc, _ricecrc, palette, &ghqTexInfo)) { - ghqTexInfo.format = gfxContext.convertGHQTextureFormat(ghqTexInfo.format); + ghqTexInfo.format = gfxContext.convertInternalTextureFormat(ghqTexInfo.format); Context::InitTextureParams params; params.handle = _pTexture->name; params.mipMapLevel = 0; @@ -1308,7 +1308,7 @@ void TextureCache::_load(u32 _tile, CachedTexture *_pTexture) if (txfilter_filter((u8*)pDest, tmptex.realWidth, tmptex.realHeight, (u16)u32(glInternalFormat), (uint64)_pTexture->crc, &ghqTexInfo) != 0 && ghqTexInfo.data != nullptr) { - ghqTexInfo.format = gfxContext.convertGHQTextureFormat(ghqTexInfo.format); + ghqTexInfo.format = gfxContext.convertInternalTextureFormat(ghqTexInfo.format); Context::InitTextureParams params; params.handle = _pTexture->name; params.textureUnitIndex = textureIndices::Tex[_tile]; @@ -1338,7 +1338,7 @@ void TextureCache::_load(u32 _tile, CachedTexture *_pTexture) params.msaaLevel = 0; params.width = tmptex.realWidth; params.height = tmptex.realHeight; - params.internalFormat = glInternalFormat; + params.internalFormat = gfxContext.convertInternalTextureFormat(u32(glInternalFormat)); params.format = colorFormat::RGBA; params.dataType = glType; params.data = pDest;