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

Convert texture format returned by GLideNHQ for GLES2.

This commit is contained in:
Sergey Lipskiy 2017-02-05 20:26:40 +07:00
parent bca968fdd3
commit 403c60cfea
6 changed files with 24 additions and 0 deletions

View File

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

View File

@ -138,6 +138,8 @@ namespace graphics {
void bindImageTexture(const BindImageTextureParameters & _params);
u32 convertGHQTextureFormat(u32 _format) const;
/*---------------Framebuffer-------------*/
const FramebufferTextureFormats & getFramebufferTextureFormats();

View File

@ -33,6 +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 FramebufferTextureFormats * getFramebufferTextureFormats() = 0;
virtual ObjectHandle createFramebuffer() = 0;
virtual void deleteFramebuffer(ObjectHandle _name) = 0;

View File

@ -222,6 +222,14 @@ 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
{
if (!m_glInfo.isGLES2)
return _format;
return GL_RGBA;
}
/*---------------Framebuffer-------------*/
graphics::FramebufferTextureFormats * ContextImpl::getFramebufferTextureFormats()

View File

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

View File

@ -898,6 +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);
Context::InitTextureParams params;
params.handle = _pTexture->name;
params.mipMapLevel = 0;
@ -982,10 +983,13 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
if (txfilter_filter((u8*)pDest, pTexture->realWidth, pTexture->realHeight,
(u16)u32(glInternalFormat), (uint64)pTexture->crc, &ghqTexInfo) != 0 &&
ghqTexInfo.data != nullptr) {
if (ghqTexInfo.width % 2 != 0 &&
ghqTexInfo.format != u32(internalcolorFormat::RGBA8) &&
m_curUnpackAlignment > 1)
gfxContext.setTextureUnpackAlignment(2);
ghqTexInfo.format = gfxContext.convertGHQTextureFormat(ghqTexInfo.format);
Context::InitTextureParams params;
params.handle = pTexture->name;
params.mipMapLevel = 0;
@ -1066,6 +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);
Context::InitTextureParams params;
params.handle = _pTexture->name;
params.mipMapLevel = 0;
@ -1303,6 +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);
Context::InitTextureParams params;
params.handle = _pTexture->name;
params.textureUnitIndex = textureIndices::Tex[_tile];