mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 20:28:32 +09:00
[Feat] (MG_Util/Texture): use fallback formats when GL_EXT_texture_norm16 is not supported
This commit is contained in:
@@ -72,8 +72,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
MG_Util::TextureFormatProcessor::NormalizePixelFormat(
|
||||
MG_Util::ConvertTextureInternalFormatToGLEnum(internalFormat), outInternalFormat,
|
||||
using namespace MobileGL::MG_Util::TextureFormatProcessor;
|
||||
auto options =
|
||||
(MG_External::GLES::g_glesCaps.hasNorm16Texture) ? PixelFormatNormalizeOptionBit::None : PixelFormatNormalizeOptionBit::NoNorm16;
|
||||
NormalizePixelFormat(
|
||||
MG_Util::ConvertTextureInternalFormatToGLEnum(internalFormat),
|
||||
options,
|
||||
outInternalFormat,
|
||||
outFormat, outType);
|
||||
}
|
||||
} // namespace TextureImpl
|
||||
|
||||
@@ -1220,7 +1220,7 @@ namespace MobileGL {
|
||||
void CopyTexImage2D_State(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
||||
GLsizei height, GLint border) {
|
||||
GLenum outInternalFormat, format, type;
|
||||
MG_Util::TextureFormatProcessor::NormalizePixelFormat(internalformat, &outInternalFormat, &format, &type);
|
||||
MG_Util::TextureFormatProcessor::NormalizePixelFormat(internalformat, 0, &outInternalFormat, &format, &type);
|
||||
const auto pixelUnpackBufferObject =
|
||||
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::PixelUnpack).GetBoundObject();
|
||||
TexImage2D_State(target, level, outInternalFormat, width, height, border, format, type, nullptr);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "MG_Util/Converters/GLToStr/GLEnumConverter.h"
|
||||
|
||||
namespace MobileGL::MG_Util::TextureFormatProcessor {
|
||||
void NormalizePixelFormat(GLenum internalFormat, GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType) {
|
||||
void NormalizePixelFormat(GLenum internalFormat, Flags<PixelFormatNormalizeOptionBit> options, GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType) {
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
@@ -19,6 +19,26 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
*outInternalFormat = GL_DEPTH_COMPONENT;
|
||||
break;
|
||||
case GL_RGBA16:
|
||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
||||
*outInternalFormat = GL_RGBA32F;
|
||||
break;
|
||||
}
|
||||
case GL_RGB16:
|
||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
||||
*outInternalFormat = GL_RGB32F;
|
||||
break;
|
||||
}
|
||||
case GL_RG16:
|
||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
||||
*outInternalFormat = GL_RG32F;
|
||||
break;
|
||||
}
|
||||
case GL_R16:
|
||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
||||
*outInternalFormat = GL_R32F;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
*outInternalFormat = internalFormat;
|
||||
break;
|
||||
@@ -188,9 +208,14 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
||||
case GL_RGB16:
|
||||
case GL_RG16:
|
||||
case GL_R16:
|
||||
*outType = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
|
||||
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
||||
// converted to GL_RGBA32F
|
||||
*outType = GL_FLOAT;
|
||||
break;
|
||||
} else {
|
||||
*outType = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
}
|
||||
case GL_RGBA8:
|
||||
case GL_RGB8:
|
||||
case GL_RG8:
|
||||
|
||||
@@ -9,5 +9,9 @@
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL::MG_Util::TextureFormatProcessor {
|
||||
void NormalizePixelFormat(GLenum internalFormat, GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType);
|
||||
enum class PixelFormatNormalizeOptionBit : Uint {
|
||||
NoNorm16 = 1 << 0,
|
||||
None = 0,
|
||||
};
|
||||
void NormalizePixelFormat(GLenum internalFormat, Flags<PixelFormatNormalizeOptionBit> options, GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType);
|
||||
} // namespace MobileGL::MG_Util::TextureFormatProcessor
|
||||
Reference in New Issue
Block a user