mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +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);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
using namespace MobileGL::MG_Util::TextureFormatProcessor;
|
using namespace MobileGL::MG_Util::TextureFormatProcessor;
|
||||||
const Bool useNorm16Texture = g_GLESCapabilities.SupportsNorm16Texture &&
|
Flags<PixelFormatNormalizeOptionBit> options =
|
||||||
g_GLESCapabilities.GLESRendererString.find("ANGLE") == String::npos;
|
(g_GLESCapabilities.SupportsNorm16Texture) ? PixelFormatNormalizeOptionBit::None
|
||||||
auto options =
|
: PixelFormatNormalizeOptionBit::NoNorm16;
|
||||||
useNorm16Texture ? PixelFormatNormalizeOptionBit::None : PixelFormatNormalizeOptionBit::NoNorm16;
|
if (g_GLESCapabilities.GLESRendererString.find("ANGLE") != String::npos) {
|
||||||
|
options |= PixelFormatNormalizeOptionBit::NoRgb16;
|
||||||
|
options |= PixelFormatNormalizeOptionBit::NoSnorm16;
|
||||||
|
}
|
||||||
NormalizePixelFormat(MG_Util::ConvertTextureInternalFormatToGLEnum(internalFormat), options,
|
NormalizePixelFormat(MG_Util::ConvertTextureInternalFormatToGLEnum(internalFormat), options,
|
||||||
outInternalFormat, outFormat, outType);
|
outInternalFormat, outFormat, outType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,41 +26,62 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
|||||||
*outInternalFormat = GL_RGBA32F;
|
*outInternalFormat = GL_RGBA32F;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*outInternalFormat = internalFormat;
|
||||||
|
break;
|
||||||
case GL_RGB16:
|
case GL_RGB16:
|
||||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
if ((options & PixelFormatNormalizeOptionBit::NoNorm16) ||
|
||||||
|
(options & PixelFormatNormalizeOptionBit::NoRgb16)) {
|
||||||
*outInternalFormat = GL_RGB32F;
|
*outInternalFormat = GL_RGB32F;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*outInternalFormat = internalFormat;
|
||||||
|
break;
|
||||||
case GL_RG16:
|
case GL_RG16:
|
||||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
||||||
*outInternalFormat = GL_RG32F;
|
*outInternalFormat = GL_RG32F;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*outInternalFormat = internalFormat;
|
||||||
|
break;
|
||||||
case GL_R16:
|
case GL_R16:
|
||||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
||||||
*outInternalFormat = GL_R32F;
|
*outInternalFormat = GL_R32F;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*outInternalFormat = internalFormat;
|
||||||
|
break;
|
||||||
case GL_RGBA16_SNORM:
|
case GL_RGBA16_SNORM:
|
||||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
if ((options & PixelFormatNormalizeOptionBit::NoNorm16) ||
|
||||||
|
(options & PixelFormatNormalizeOptionBit::NoSnorm16)) {
|
||||||
*outInternalFormat = GL_RGBA16F;
|
*outInternalFormat = GL_RGBA16F;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*outInternalFormat = internalFormat;
|
||||||
|
break;
|
||||||
case GL_RGB16_SNORM:
|
case GL_RGB16_SNORM:
|
||||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
if ((options & PixelFormatNormalizeOptionBit::NoNorm16) ||
|
||||||
|
(options & PixelFormatNormalizeOptionBit::NoSnorm16)) {
|
||||||
*outInternalFormat = GL_RGB16F;
|
*outInternalFormat = GL_RGB16F;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*outInternalFormat = internalFormat;
|
||||||
|
break;
|
||||||
case GL_RG16_SNORM:
|
case GL_RG16_SNORM:
|
||||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
if ((options & PixelFormatNormalizeOptionBit::NoNorm16) ||
|
||||||
|
(options & PixelFormatNormalizeOptionBit::NoSnorm16)) {
|
||||||
*outInternalFormat = GL_RG16F;
|
*outInternalFormat = GL_RG16F;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*outInternalFormat = internalFormat;
|
||||||
|
break;
|
||||||
case GL_R16_SNORM:
|
case GL_R16_SNORM:
|
||||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
if ((options & PixelFormatNormalizeOptionBit::NoNorm16) ||
|
||||||
|
(options & PixelFormatNormalizeOptionBit::NoSnorm16)) {
|
||||||
*outInternalFormat = GL_R16F;
|
*outInternalFormat = GL_R16F;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*outInternalFormat = internalFormat;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
*outInternalFormat = internalFormat;
|
*outInternalFormat = internalFormat;
|
||||||
break;
|
break;
|
||||||
@@ -232,7 +253,6 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
|||||||
switch (internalFormat) {
|
switch (internalFormat) {
|
||||||
// Color Unsigned Normalized
|
// Color Unsigned Normalized
|
||||||
case GL_RGBA16:
|
case GL_RGBA16:
|
||||||
case GL_RGB16:
|
|
||||||
case GL_RG16:
|
case GL_RG16:
|
||||||
case GL_R16:
|
case GL_R16:
|
||||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
||||||
@@ -243,6 +263,15 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
|||||||
*outType = GL_UNSIGNED_SHORT;
|
*outType = GL_UNSIGNED_SHORT;
|
||||||
break;
|
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_RGBA8:
|
||||||
case GL_RGB8:
|
case GL_RGB8:
|
||||||
case GL_RG8:
|
case GL_RG8:
|
||||||
@@ -255,7 +284,8 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
|||||||
case GL_RGB16_SNORM:
|
case GL_RGB16_SNORM:
|
||||||
case GL_RG16_SNORM:
|
case GL_RG16_SNORM:
|
||||||
case GL_R16_SNORM:
|
case GL_R16_SNORM:
|
||||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
if ((options & PixelFormatNormalizeOptionBit::NoNorm16) ||
|
||||||
|
(options & PixelFormatNormalizeOptionBit::NoSnorm16)) {
|
||||||
*outType = GL_FLOAT;
|
*outType = GL_FLOAT;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -12,10 +12,12 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
enum class PixelFormatNormalizeOptionBit : Uint {
|
enum class PixelFormatNormalizeOptionBit : Uint {
|
||||||
NoNorm16 = 1 << 0,
|
NoNorm16 = 1 << 0,
|
||||||
|
NoSnorm16 = 1 << 1,
|
||||||
|
NoRgb16 = 1 << 2,
|
||||||
None = 0,
|
None = 0,
|
||||||
};
|
};
|
||||||
namespace MG_Util::TextureFormatProcessor {
|
namespace MG_Util::TextureFormatProcessor {
|
||||||
void NormalizePixelFormat(GLenum internalFormat, Flags<PixelFormatNormalizeOptionBit> options,
|
void NormalizePixelFormat(GLenum internalFormat, Flags<PixelFormatNormalizeOptionBit> options,
|
||||||
GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType);
|
GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType);
|
||||||
} // namespace MG_Util::TextureFormatProcessor
|
} // namespace MG_Util::TextureFormatProcessor
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
|
|||||||
Reference in New Issue
Block a user