mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 04:08:32 +09:00
[Fix]: fix BSL
- keep ANGLE RGBA16 textures on the native norm16 path - add separate RGB16 and SNORM16 fallback controls for DirectGLES format normalization - convert RGB16 fallback uploads to float when using RGB32F storage
This commit is contained in:
@@ -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<PixelFormatNormalizeOptionBit> 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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<PixelFormatNormalizeOptionBit> options,
|
||||
GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType);
|
||||
} // namespace MG_Util::TextureFormatProcessor
|
||||
} // namespace MobileGL
|
||||
} // namespace MobileGL
|
||||
|
||||
Reference in New Issue
Block a user