mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +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
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_Util::TextureFormatProcessor::NormalizePixelFormat(
|
using namespace MobileGL::MG_Util::TextureFormatProcessor;
|
||||||
MG_Util::ConvertTextureInternalFormatToGLEnum(internalFormat), outInternalFormat,
|
auto options =
|
||||||
|
(MG_External::GLES::g_glesCaps.hasNorm16Texture) ? PixelFormatNormalizeOptionBit::None : PixelFormatNormalizeOptionBit::NoNorm16;
|
||||||
|
NormalizePixelFormat(
|
||||||
|
MG_Util::ConvertTextureInternalFormatToGLEnum(internalFormat),
|
||||||
|
options,
|
||||||
|
outInternalFormat,
|
||||||
outFormat, outType);
|
outFormat, outType);
|
||||||
}
|
}
|
||||||
} // namespace TextureImpl
|
} // namespace TextureImpl
|
||||||
|
|||||||
@@ -1220,7 +1220,7 @@ namespace MobileGL {
|
|||||||
void CopyTexImage2D_State(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
void CopyTexImage2D_State(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
||||||
GLsizei height, GLint border) {
|
GLsizei height, GLint border) {
|
||||||
GLenum outInternalFormat, format, type;
|
GLenum outInternalFormat, format, type;
|
||||||
MG_Util::TextureFormatProcessor::NormalizePixelFormat(internalformat, &outInternalFormat, &format, &type);
|
MG_Util::TextureFormatProcessor::NormalizePixelFormat(internalformat, 0, &outInternalFormat, &format, &type);
|
||||||
const auto pixelUnpackBufferObject =
|
const auto pixelUnpackBufferObject =
|
||||||
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::PixelUnpack).GetBoundObject();
|
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::PixelUnpack).GetBoundObject();
|
||||||
TexImage2D_State(target, level, outInternalFormat, width, height, border, format, type, nullptr);
|
TexImage2D_State(target, level, outInternalFormat, width, height, border, format, type, nullptr);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "MG_Util/Converters/GLToStr/GLEnumConverter.h"
|
#include "MG_Util/Converters/GLToStr/GLEnumConverter.h"
|
||||||
|
|
||||||
namespace MobileGL::MG_Util::TextureFormatProcessor {
|
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
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
@@ -19,6 +19,26 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
|||||||
case GL_DEPTH_COMPONENT32:
|
case GL_DEPTH_COMPONENT32:
|
||||||
*outInternalFormat = GL_DEPTH_COMPONENT;
|
*outInternalFormat = GL_DEPTH_COMPONENT;
|
||||||
break;
|
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:
|
default:
|
||||||
*outInternalFormat = internalFormat;
|
*outInternalFormat = internalFormat;
|
||||||
break;
|
break;
|
||||||
@@ -188,9 +208,14 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
|||||||
case GL_RGB16:
|
case GL_RGB16:
|
||||||
case GL_RG16:
|
case GL_RG16:
|
||||||
case GL_R16:
|
case GL_R16:
|
||||||
*outType = GL_UNSIGNED_SHORT;
|
if (options & PixelFormatNormalizeOptionBit::NoNorm16) {
|
||||||
break;
|
// converted to GL_RGBA32F
|
||||||
|
*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:
|
||||||
|
|||||||
@@ -9,5 +9,9 @@
|
|||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
|
|
||||||
namespace MobileGL::MG_Util::TextureFormatProcessor {
|
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
|
} // namespace MobileGL::MG_Util::TextureFormatProcessor
|
||||||
Reference in New Issue
Block a user