diff --git a/MobileGL/MG_Backend/DirectGLES/Utils.cpp b/MobileGL/MG_Backend/DirectGLES/Utils.cpp index 8cdfcf73..88c0e0ce 100644 --- a/MobileGL/MG_Backend/DirectGLES/Utils.cpp +++ b/MobileGL/MG_Backend/DirectGLES/Utils.cpp @@ -26,10 +26,13 @@ namespace MobileGL::MG_Backend::DirectGLES { ZoneScopedC(TRACY_ZONECOLOR_BACKEND); #endif using namespace MobileGL::MG_Util::TextureFormatProcessor; - const Bool useNorm16Texture = g_GLESCapabilities.SupportsNorm16Texture && - g_GLESCapabilities.GLESRendererString.find("ANGLE") == String::npos; - auto options = - useNorm16Texture ? PixelFormatNormalizeOptionBit::None : PixelFormatNormalizeOptionBit::NoNorm16; + Flags options = + (g_GLESCapabilities.SupportsNorm16Texture) ? PixelFormatNormalizeOptionBit::None + : PixelFormatNormalizeOptionBit::NoNorm16; + if (g_GLESCapabilities.GLESRendererString.find("ANGLE") != String::npos) { + options |= PixelFormatNormalizeOptionBit::NoRgb16; + options |= PixelFormatNormalizeOptionBit::NoSnorm16; + } NormalizePixelFormat(MG_Util::ConvertTextureInternalFormatToGLEnum(internalFormat), options, outInternalFormat, outFormat, outType); } diff --git a/MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp b/MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp index dc7fd949..d1412004 100644 --- a/MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp +++ b/MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp @@ -26,41 +26,62 @@ namespace MobileGL::MG_Util::TextureFormatProcessor { *outInternalFormat = GL_RGBA32F; break; } + *outInternalFormat = internalFormat; + break; case GL_RGB16: - if (options & PixelFormatNormalizeOptionBit::NoNorm16) { + if ((options & PixelFormatNormalizeOptionBit::NoNorm16) || + (options & PixelFormatNormalizeOptionBit::NoRgb16)) { *outInternalFormat = GL_RGB32F; break; } + *outInternalFormat = internalFormat; + break; case GL_RG16: if (options & PixelFormatNormalizeOptionBit::NoNorm16) { *outInternalFormat = GL_RG32F; break; } + *outInternalFormat = internalFormat; + break; case GL_R16: if (options & PixelFormatNormalizeOptionBit::NoNorm16) { *outInternalFormat = GL_R32F; break; } + *outInternalFormat = internalFormat; + break; case GL_RGBA16_SNORM: - if (options & PixelFormatNormalizeOptionBit::NoNorm16) { + if ((options & PixelFormatNormalizeOptionBit::NoNorm16) || + (options & PixelFormatNormalizeOptionBit::NoSnorm16)) { *outInternalFormat = GL_RGBA16F; break; } + *outInternalFormat = internalFormat; + break; case GL_RGB16_SNORM: - if (options & PixelFormatNormalizeOptionBit::NoNorm16) { + if ((options & PixelFormatNormalizeOptionBit::NoNorm16) || + (options & PixelFormatNormalizeOptionBit::NoSnorm16)) { *outInternalFormat = GL_RGB16F; break; } + *outInternalFormat = internalFormat; + break; case GL_RG16_SNORM: - if (options & PixelFormatNormalizeOptionBit::NoNorm16) { + if ((options & PixelFormatNormalizeOptionBit::NoNorm16) || + (options & PixelFormatNormalizeOptionBit::NoSnorm16)) { *outInternalFormat = GL_RG16F; break; } + *outInternalFormat = internalFormat; + break; case GL_R16_SNORM: - if (options & PixelFormatNormalizeOptionBit::NoNorm16) { + if ((options & PixelFormatNormalizeOptionBit::NoNorm16) || + (options & PixelFormatNormalizeOptionBit::NoSnorm16)) { *outInternalFormat = GL_R16F; break; } + *outInternalFormat = internalFormat; + break; default: *outInternalFormat = internalFormat; break; @@ -232,7 +253,6 @@ namespace MobileGL::MG_Util::TextureFormatProcessor { switch (internalFormat) { // Color Unsigned Normalized case GL_RGBA16: - case GL_RGB16: case GL_RG16: case GL_R16: if (options & PixelFormatNormalizeOptionBit::NoNorm16) { @@ -243,6 +263,15 @@ namespace MobileGL::MG_Util::TextureFormatProcessor { *outType = GL_UNSIGNED_SHORT; break; } + case GL_RGB16: + if ((options & PixelFormatNormalizeOptionBit::NoNorm16) || + (options & PixelFormatNormalizeOptionBit::NoRgb16)) { + *outType = GL_FLOAT; + break; + } else { + *outType = GL_UNSIGNED_SHORT; + break; + } case GL_RGBA8: case GL_RGB8: case GL_RG8: @@ -255,7 +284,8 @@ namespace MobileGL::MG_Util::TextureFormatProcessor { case GL_RGB16_SNORM: case GL_RG16_SNORM: case GL_R16_SNORM: - if (options & PixelFormatNormalizeOptionBit::NoNorm16) { + if ((options & PixelFormatNormalizeOptionBit::NoNorm16) || + (options & PixelFormatNormalizeOptionBit::NoSnorm16)) { *outType = GL_FLOAT; break; } else { diff --git a/MobileGL/MG_Util/Texture/TextureFormatProcessor.h b/MobileGL/MG_Util/Texture/TextureFormatProcessor.h index 42420c5e..3ab5dbf4 100644 --- a/MobileGL/MG_Util/Texture/TextureFormatProcessor.h +++ b/MobileGL/MG_Util/Texture/TextureFormatProcessor.h @@ -12,10 +12,12 @@ namespace MobileGL { enum class PixelFormatNormalizeOptionBit : Uint { NoNorm16 = 1 << 0, + NoSnorm16 = 1 << 1, + NoRgb16 = 1 << 2, None = 0, }; namespace MG_Util::TextureFormatProcessor { void NormalizePixelFormat(GLenum internalFormat, Flags options, GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType); } // namespace MG_Util::TextureFormatProcessor -} // namespace MobileGL \ No newline at end of file +} // namespace MobileGL