[Feat|Fix] (MG_Impl/Texture): Implement TexImage2D & related stuff.

This commit is contained in:
BZLZHH
2025-08-14 18:32:37 +08:00
parent f713a3785b
commit 675ee4915b
16 changed files with 744 additions and 263 deletions
@@ -68,132 +68,156 @@ namespace MobileGL {
}
}
TextureSizedInternalFormat ConvertGLEnumToTextureSizedInternalFormat(GLenum internalformat) {
TextureInternalFormat ConvertGLEnumToTextureInternalFormat(GLenum internalformat) {
switch (internalformat) {
case GL_R8:
return TextureSizedInternalFormat::R8;
return TextureInternalFormat::R8;
case GL_R8_SNORM:
return TextureSizedInternalFormat::R8Snorm;
return TextureInternalFormat::R8Snorm;
case GL_R16:
return TextureSizedInternalFormat::R16;
return TextureInternalFormat::R16;
case GL_R16_SNORM:
return TextureSizedInternalFormat::R16Snorm;
return TextureInternalFormat::R16Snorm;
case GL_RG8:
return TextureSizedInternalFormat::RG8;
return TextureInternalFormat::RG8;
case GL_RG8_SNORM:
return TextureSizedInternalFormat::RG8Snorm;
return TextureInternalFormat::RG8Snorm;
case GL_RG16:
return TextureSizedInternalFormat::RG16;
return TextureInternalFormat::RG16;
case GL_RG16_SNORM:
return TextureSizedInternalFormat::RG16Snorm;
return TextureInternalFormat::RG16Snorm;
case GL_R3_G3_B2:
return TextureSizedInternalFormat::R3G3B2;
return TextureInternalFormat::R3G3B2;
case GL_RGB4:
return TextureSizedInternalFormat::RGB4;
return TextureInternalFormat::RGB4;
case GL_RGB5:
return TextureSizedInternalFormat::RGB5;
return TextureInternalFormat::RGB5;
case GL_RGB8:
return TextureSizedInternalFormat::RGB8;
return TextureInternalFormat::RGB8;
case GL_RGB8_SNORM:
return TextureSizedInternalFormat::RGB8Snorm;
return TextureInternalFormat::RGB8Snorm;
case GL_RGB10:
return TextureSizedInternalFormat::RGB10;
return TextureInternalFormat::RGB10;
case GL_RGB12:
return TextureSizedInternalFormat::RGB12;
return TextureInternalFormat::RGB12;
case GL_RGB16_SNORM:
return TextureSizedInternalFormat::RGB16Snorm;
return TextureInternalFormat::RGB16Snorm;
case GL_RGBA2:
return TextureSizedInternalFormat::RGBA2;
return TextureInternalFormat::RGBA2;
case GL_RGBA4:
return TextureSizedInternalFormat::RGBA4;
return TextureInternalFormat::RGBA4;
case GL_RGB5_A1:
return TextureSizedInternalFormat::RGB5A1;
return TextureInternalFormat::RGB5A1;
case GL_RGBA8:
return TextureSizedInternalFormat::RGBA8;
return TextureInternalFormat::RGBA8;
case GL_RGBA8_SNORM:
return TextureSizedInternalFormat::RGBA8Snorm;
return TextureInternalFormat::RGBA8Snorm;
case GL_RGB10_A2:
return TextureSizedInternalFormat::RGB10A2;
return TextureInternalFormat::RGB10A2;
case GL_RGB10_A2UI:
return TextureSizedInternalFormat::RGB10A2UI;
return TextureInternalFormat::RGB10A2UI;
case GL_RGBA12:
return TextureSizedInternalFormat::RGBA12;
return TextureInternalFormat::RGBA12;
case GL_RGBA16:
return TextureSizedInternalFormat::RGBA16;
return TextureInternalFormat::RGBA16;
case GL_SRGB8:
return TextureSizedInternalFormat::SRGB8;
return TextureInternalFormat::SRGB8;
case GL_SRGB8_ALPHA8:
return TextureSizedInternalFormat::SRGB8Alpha8;
return TextureInternalFormat::SRGB8Alpha8;
case GL_R16F:
return TextureSizedInternalFormat::R16F;
return TextureInternalFormat::R16F;
case GL_RG16F:
return TextureSizedInternalFormat::RG16F;
return TextureInternalFormat::RG16F;
case GL_RGB16F:
return TextureSizedInternalFormat::RGB16F;
return TextureInternalFormat::RGB16F;
case GL_RGBA16F:
return TextureSizedInternalFormat::RGBA16F;
return TextureInternalFormat::RGBA16F;
case GL_R32F:
return TextureSizedInternalFormat::R32F;
return TextureInternalFormat::R32F;
case GL_RG32F:
return TextureSizedInternalFormat::RG32F;
return TextureInternalFormat::RG32F;
case GL_RGB32F:
return TextureSizedInternalFormat::RGB32F;
return TextureInternalFormat::RGB32F;
case GL_RGBA32F:
return TextureSizedInternalFormat::RGBA32F;
return TextureInternalFormat::RGBA32F;
case GL_R11F_G11F_B10F:
return TextureSizedInternalFormat::R11FG11FB10F;
return TextureInternalFormat::R11FG11FB10F;
case GL_RGB9_E5:
return TextureSizedInternalFormat::RGB9E5;
return TextureInternalFormat::RGB9E5;
case GL_R8I:
return TextureSizedInternalFormat::R8I;
return TextureInternalFormat::R8I;
case GL_R8UI:
return TextureSizedInternalFormat::R8UI;
return TextureInternalFormat::R8UI;
case GL_R16I:
return TextureSizedInternalFormat::R16I;
return TextureInternalFormat::R16I;
case GL_R16UI:
return TextureSizedInternalFormat::R16UI;
return TextureInternalFormat::R16UI;
case GL_R32I:
return TextureSizedInternalFormat::R32I;
return TextureInternalFormat::R32I;
case GL_R32UI:
return TextureSizedInternalFormat::R32UI;
return TextureInternalFormat::R32UI;
case GL_RG8I:
return TextureSizedInternalFormat::RG8I;
return TextureInternalFormat::RG8I;
case GL_RG8UI:
return TextureSizedInternalFormat::RG8UI;
return TextureInternalFormat::RG8UI;
case GL_RG16I:
return TextureSizedInternalFormat::RG16I;
return TextureInternalFormat::RG16I;
case GL_RG16UI:
return TextureSizedInternalFormat::RG16UI;
return TextureInternalFormat::RG16UI;
case GL_RG32I:
return TextureSizedInternalFormat::RG32I;
return TextureInternalFormat::RG32I;
case GL_RG32UI:
return TextureSizedInternalFormat::RG32UI;
return TextureInternalFormat::RG32UI;
case GL_RGB8I:
return TextureSizedInternalFormat::RGB8I;
return TextureInternalFormat::RGB8I;
case GL_RGB8UI:
return TextureSizedInternalFormat::RGB8UI;
return TextureInternalFormat::RGB8UI;
case GL_RGB16I:
return TextureSizedInternalFormat::RGB16I;
return TextureInternalFormat::RGB16I;
case GL_RGB16UI:
return TextureSizedInternalFormat::RGB16UI;
return TextureInternalFormat::RGB16UI;
case GL_RGB32I:
return TextureSizedInternalFormat::RGB32I;
return TextureInternalFormat::RGB32I;
case GL_RGB32UI:
return TextureSizedInternalFormat::RGB32UI;
return TextureInternalFormat::RGB32UI;
case GL_RGBA8I:
return TextureSizedInternalFormat::RGBA8I;
return TextureInternalFormat::RGBA8I;
case GL_RGBA8UI:
return TextureSizedInternalFormat::RGBA8UI;
return TextureInternalFormat::RGBA8UI;
case GL_RGBA16I:
return TextureSizedInternalFormat::RGBA16I;
return TextureInternalFormat::RGBA16I;
case GL_RGBA16UI:
return TextureSizedInternalFormat::RGBA16UI;
return TextureInternalFormat::RGBA16UI;
case GL_RGBA32I:
return TextureSizedInternalFormat::RGBA32I;
return TextureInternalFormat::RGBA32I;
case GL_RGBA32UI:
return TextureSizedInternalFormat::RGBA32UI;
return TextureInternalFormat::RGBA32UI;
case GL_DEPTH_COMPONENT16:
return TextureInternalFormat::DepthComponent16;
case GL_DEPTH_COMPONENT24:
return TextureInternalFormat::DepthComponent24;
case GL_DEPTH_COMPONENT32:
return TextureInternalFormat::DepthComponent32;
case GL_DEPTH_COMPONENT32F:
return TextureInternalFormat::DepthComponent32F;
case GL_DEPTH24_STENCIL8:
return TextureInternalFormat::Depth24Stencil8;
case GL_DEPTH32F_STENCIL8:
return TextureInternalFormat::Depth32FStencil8;
case GL_DEPTH_COMPONENT:
return TextureInternalFormat::DepthComponent;
case GL_DEPTH_STENCIL:
return TextureInternalFormat::DepthStencil;
case GL_RED:
return TextureInternalFormat::Red;
case GL_RG:
return TextureInternalFormat::RG;
case GL_RGB:
return TextureInternalFormat::RGB;
case GL_RGBA:
return TextureInternalFormat::RGBA;
default:
return TextureSizedInternalFormat::Unknown;
return TextureInternalFormat::Unknown;
}
}
@@ -234,9 +258,11 @@ namespace MobileGL {
case GL_UNSIGNED_INT_8_8_8_8_REV:
return TexturePixelDataType::UnsignedInt8888Rev;
case GL_UNSIGNED_INT_10F_11F_11F_REV:
return TexturePixelDataType::UnsignedInt1010102;
return TexturePixelDataType::UnsignedInt101111Rev;
case GL_UNSIGNED_INT_2_10_10_10_REV:
return TexturePixelDataType::UnsignedInt2101010Rev;
case GL_UNSIGNED_INT_5_9_9_9_REV:
return TexturePixelDataType::UnsignedInt5999Rev;
default:
return TexturePixelDataType::Unknown;
}
@@ -270,6 +296,10 @@ namespace MobileGL {
return TextureUploadTarget::CubeMapNegativeZ;
case GL_PROXY_TEXTURE_CUBE_MAP:
return TextureUploadTarget::ProxyCubeMap;
case GL_TEXTURE_2D_MULTISAMPLE:
return TextureUploadTarget::Texture2DMultisample;
case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
return TextureUploadTarget::ProxyTexture2DMultisample;
default:
return TextureUploadTarget::Unknown;
}
@@ -6,7 +6,7 @@ namespace MobileGL {
namespace MG_Util {
TextureTarget ConvertGLEnumToTextureTarget(GLenum target);
TextureInputFormat ConvertGLEnumToTextureInputFormat(GLenum format);
TextureSizedInternalFormat ConvertGLEnumToTextureSizedInternalFormat(GLenum internalformat);
TextureInternalFormat ConvertGLEnumToTextureInternalFormat(GLenum internalformat);
TexturePixelDataType ConvertGLEnumToTexturePixelDataType(GLenum type);
TextureUploadTarget ConvertGLEnumToTextureUploadTarget(GLenum target);
} // namespace MG_Util
@@ -68,130 +68,154 @@ namespace MobileGL {
}
}
GLenum ConvertTextureSizedInternalFormatToGLEnum(TextureSizedInternalFormat format) {
GLenum ConvertTextureInternalFormatToGLEnum(TextureInternalFormat format) {
switch (format) {
case TextureSizedInternalFormat::R8:
case TextureInternalFormat::R8:
return GL_R8;
case TextureSizedInternalFormat::R8Snorm:
case TextureInternalFormat::R8Snorm:
return GL_R8_SNORM;
case TextureSizedInternalFormat::R16:
case TextureInternalFormat::R16:
return GL_R16;
case TextureSizedInternalFormat::R16Snorm:
case TextureInternalFormat::R16Snorm:
return GL_R16_SNORM;
case TextureSizedInternalFormat::RG8:
case TextureInternalFormat::RG8:
return GL_RG8;
case TextureSizedInternalFormat::RG8Snorm:
case TextureInternalFormat::RG8Snorm:
return GL_RG8_SNORM;
case TextureSizedInternalFormat::RG16:
case TextureInternalFormat::RG16:
return GL_RG16;
case TextureSizedInternalFormat::RG16Snorm:
case TextureInternalFormat::RG16Snorm:
return GL_RG16_SNORM;
case TextureSizedInternalFormat::R3G3B2:
case TextureInternalFormat::R3G3B2:
return GL_R3_G3_B2;
case TextureSizedInternalFormat::RGB4:
case TextureInternalFormat::RGB4:
return GL_RGB4;
case TextureSizedInternalFormat::RGB5:
case TextureInternalFormat::RGB5:
return GL_RGB5;
case TextureSizedInternalFormat::RGB8:
case TextureInternalFormat::RGB8:
return GL_RGB8;
case TextureSizedInternalFormat::RGB8Snorm:
case TextureInternalFormat::RGB8Snorm:
return GL_RGB8_SNORM;
case TextureSizedInternalFormat::RGB10:
case TextureInternalFormat::RGB10:
return GL_RGB10;
case TextureSizedInternalFormat::RGB12:
case TextureInternalFormat::RGB12:
return GL_RGB12;
case TextureSizedInternalFormat::RGB16Snorm:
case TextureInternalFormat::RGB16Snorm:
return GL_RGB16_SNORM;
case TextureSizedInternalFormat::RGBA2:
case TextureInternalFormat::RGBA2:
return GL_RGBA2;
case TextureSizedInternalFormat::RGBA4:
case TextureInternalFormat::RGBA4:
return GL_RGBA4;
case TextureSizedInternalFormat::RGB5A1:
case TextureInternalFormat::RGB5A1:
return GL_RGB5_A1;
case TextureSizedInternalFormat::RGBA8:
case TextureInternalFormat::RGBA8:
return GL_RGBA8;
case TextureSizedInternalFormat::RGBA8Snorm:
case TextureInternalFormat::RGBA8Snorm:
return GL_RGBA8_SNORM;
case TextureSizedInternalFormat::RGB10A2:
case TextureInternalFormat::RGB10A2:
return GL_RGB10_A2;
case TextureSizedInternalFormat::RGB10A2UI:
case TextureInternalFormat::RGB10A2UI:
return GL_RGB10_A2UI;
case TextureSizedInternalFormat::RGBA12:
case TextureInternalFormat::RGBA12:
return GL_RGBA12;
case TextureSizedInternalFormat::RGBA16:
case TextureInternalFormat::RGBA16:
return GL_RGBA16;
case TextureSizedInternalFormat::SRGB8:
case TextureInternalFormat::SRGB8:
return GL_SRGB8;
case TextureSizedInternalFormat::SRGB8Alpha8:
case TextureInternalFormat::SRGB8Alpha8:
return GL_SRGB8_ALPHA8;
case TextureSizedInternalFormat::R16F:
case TextureInternalFormat::R16F:
return GL_R16F;
case TextureSizedInternalFormat::RG16F:
case TextureInternalFormat::RG16F:
return GL_RG16F;
case TextureSizedInternalFormat::RGB16F:
case TextureInternalFormat::RGB16F:
return GL_RGB16F;
case TextureSizedInternalFormat::RGBA16F:
case TextureInternalFormat::RGBA16F:
return GL_RGBA16F;
case TextureSizedInternalFormat::R32F:
case TextureInternalFormat::R32F:
return GL_R32F;
case TextureSizedInternalFormat::RG32F:
case TextureInternalFormat::RG32F:
return GL_RG32F;
case TextureSizedInternalFormat::RGB32F:
case TextureInternalFormat::RGB32F:
return GL_RGB32F;
case TextureSizedInternalFormat::RGBA32F:
case TextureInternalFormat::RGBA32F:
return GL_RGBA32F;
case TextureSizedInternalFormat::R11FG11FB10F:
case TextureInternalFormat::R11FG11FB10F:
return GL_R11F_G11F_B10F;
case TextureSizedInternalFormat::RGB9E5:
case TextureInternalFormat::RGB9E5:
return GL_RGB9_E5;
case TextureSizedInternalFormat::R8I:
case TextureInternalFormat::R8I:
return GL_R8I;
case TextureSizedInternalFormat::R8UI:
case TextureInternalFormat::R8UI:
return GL_R8UI;
case TextureSizedInternalFormat::R16I:
case TextureInternalFormat::R16I:
return GL_R16I;
case TextureSizedInternalFormat::R16UI:
case TextureInternalFormat::R16UI:
return GL_R16UI;
case TextureSizedInternalFormat::R32I:
case TextureInternalFormat::R32I:
return GL_R32I;
case TextureSizedInternalFormat::R32UI:
case TextureInternalFormat::R32UI:
return GL_R32UI;
case TextureSizedInternalFormat::RG8I:
case TextureInternalFormat::RG8I:
return GL_RG8I;
case TextureSizedInternalFormat::RG8UI:
case TextureInternalFormat::RG8UI:
return GL_RG8UI;
case TextureSizedInternalFormat::RG16I:
case TextureInternalFormat::RG16I:
return GL_RG16I;
case TextureSizedInternalFormat::RG16UI:
case TextureInternalFormat::RG16UI:
return GL_RG16UI;
case TextureSizedInternalFormat::RG32I:
case TextureInternalFormat::RG32I:
return GL_RG32I;
case TextureSizedInternalFormat::RG32UI:
case TextureInternalFormat::RG32UI:
return GL_RG32UI;
case TextureSizedInternalFormat::RGB8I:
case TextureInternalFormat::RGB8I:
return GL_RGB8I;
case TextureSizedInternalFormat::RGB8UI:
case TextureInternalFormat::RGB8UI:
return GL_RGB8UI;
case TextureSizedInternalFormat::RGB16I:
case TextureInternalFormat::RGB16I:
return GL_RGB16I;
case TextureSizedInternalFormat::RGB16UI:
case TextureInternalFormat::RGB16UI:
return GL_RGB16UI;
case TextureSizedInternalFormat::RGB32I:
case TextureInternalFormat::RGB32I:
return GL_RGB32I;
case TextureSizedInternalFormat::RGB32UI:
case TextureInternalFormat::RGB32UI:
return GL_RGB32UI;
case TextureSizedInternalFormat::RGBA8I:
case TextureInternalFormat::RGBA8I:
return GL_RGBA8I;
case TextureSizedInternalFormat::RGBA8UI:
case TextureInternalFormat::RGBA8UI:
return GL_RGBA8UI;
case TextureSizedInternalFormat::RGBA16I:
case TextureInternalFormat::RGBA16I:
return GL_RGBA16I;
case TextureSizedInternalFormat::RGBA16UI:
case TextureInternalFormat::RGBA16UI:
return GL_RGBA16UI;
case TextureSizedInternalFormat::RGBA32I:
case TextureInternalFormat::RGBA32I:
return GL_RGBA32I;
case TextureSizedInternalFormat::RGBA32UI:
case TextureInternalFormat::RGBA32UI:
return GL_RGBA32UI;
case TextureInternalFormat::DepthComponent:
return GL_DEPTH_COMPONENT;
case TextureInternalFormat::DepthComponent16:
return GL_DEPTH_COMPONENT16;
case TextureInternalFormat::DepthComponent24:
return GL_DEPTH_COMPONENT24;
case TextureInternalFormat::DepthComponent32F:
return GL_DEPTH_COMPONENT32F;
case TextureInternalFormat::Depth24Stencil8:
return GL_DEPTH24_STENCIL8;
case TextureInternalFormat::Depth32FStencil8:
return GL_DEPTH32F_STENCIL8;
case TextureInternalFormat::DepthComponent32:
return GL_DEPTH_COMPONENT32;
case TextureInternalFormat::DepthStencil:
return GL_DEPTH_STENCIL;
case TextureInternalFormat::Red:
return GL_RED;
case TextureInternalFormat::RG:
return GL_RG;
case TextureInternalFormat::RGB:
return GL_RGB;
case TextureInternalFormat::RGBA:
return GL_RGBA;
default:
return GL_UNKNOWN_MGL;
}
@@ -233,6 +257,12 @@ namespace MobileGL {
return GL_UNSIGNED_INT_8_8_8_8_REV;
case TexturePixelDataType::UnsignedInt1010102:
return GL_UNSIGNED_INT_10_10_10_2;
case TexturePixelDataType::UnsignedInt2101010Rev:
return GL_UNSIGNED_INT_2_10_10_10_REV;
case TexturePixelDataType::UnsignedInt101111Rev:
return GL_UNSIGNED_INT_10F_11F_11F_REV;
case TexturePixelDataType::UnsignedInt5999Rev:
return GL_UNSIGNED_INT_5_9_9_9_REV;
default:
return GL_UNKNOWN_MGL;
}
@@ -266,6 +296,10 @@ namespace MobileGL {
return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
case TextureUploadTarget::ProxyCubeMap:
return GL_PROXY_TEXTURE_CUBE_MAP;
case TextureUploadTarget::Texture2DMultisample:
return GL_TEXTURE_2D_MULTISAMPLE;
case TextureUploadTarget::ProxyTexture2DMultisample:
return GL_PROXY_TEXTURE_2D_MULTISAMPLE;
default:
return GL_UNKNOWN_MGL;
}
@@ -6,7 +6,7 @@ namespace MobileGL {
namespace MG_Util {
GLenum ConvertTextureTargetToGLEnum(TextureTarget target);
GLenum ConvertTextureInputFormatToGLEnum(TextureInputFormat format);
GLenum ConvertTextureSizedInternalFormatToGLEnum(TextureSizedInternalFormat internalformat);
GLenum ConvertTextureInternalFormatToGLEnum(TextureInternalFormat internalformat);
GLenum ConvertTexturePixelDataTypeToGLEnum(TexturePixelDataType type);
GLenum ConvertTextureUploadTargetToGLEnum(TextureUploadTarget target);
} // namespace MG_Util
@@ -0,0 +1,32 @@
#include "TextureEnumConverter.h"
namespace MobileGL {
namespace MG_Util {
TextureTarget ConvertTextureUploadTargetToTextureTarget(TextureUploadTarget target) {
switch (target) {
case TextureUploadTarget::Texture2D:
case TextureUploadTarget::ProxyTexture2D:
return TextureTarget::Texture2D;
case TextureUploadTarget::Texture1DArray:
case TextureUploadTarget::ProxyTexture1DArray:
return TextureTarget::Texture1DArray;
case TextureUploadTarget::TextureRectangle:
case TextureUploadTarget::ProxyTextureRectangle:
return TextureTarget::TextureRectangle;
case TextureUploadTarget::CubeMapPositiveX:
case TextureUploadTarget::CubeMapNegativeX:
case TextureUploadTarget::CubeMapPositiveY:
case TextureUploadTarget::CubeMapNegativeY:
case TextureUploadTarget::CubeMapPositiveZ:
case TextureUploadTarget::CubeMapNegativeZ:
case TextureUploadTarget::ProxyCubeMap:
return TextureTarget::TextureCubeMap;
case TextureUploadTarget::Texture2DMultisample:
case TextureUploadTarget::ProxyTexture2DMultisample:
return TextureTarget::Texture2DMultisample;
default:
return TextureTarget::Unknown;
}
}
} // namespace MG_Util
} // namespace MobileGL
@@ -0,0 +1,9 @@
#pragma once
#include <Includes.h>
#include <MG_State/GLState/TextureState/TextureObject.h>
namespace MobileGL {
namespace MG_Util {
TextureTarget ConvertTextureUploadTargetToTextureTarget(TextureUploadTarget target);
} // namespace MG_Util
} // namespace MobileGL
@@ -62,130 +62,154 @@ namespace MobileGL {
}
}
String ConvertTextureSizedInternalFormatToString(TextureSizedInternalFormat format) {
String ConvertTextureInternalFormatToString(TextureInternalFormat format) {
switch (format) {
case TextureSizedInternalFormat::R8:
case TextureInternalFormat::R8:
return "R8";
case TextureSizedInternalFormat::R8Snorm:
case TextureInternalFormat::R8Snorm:
return "R8Snorm";
case TextureSizedInternalFormat::R16:
case TextureInternalFormat::R16:
return "R16";
case TextureSizedInternalFormat::R16Snorm:
case TextureInternalFormat::R16Snorm:
return "R16Snorm";
case TextureSizedInternalFormat::RG8:
case TextureInternalFormat::RG8:
return "RG8";
case TextureSizedInternalFormat::RG8Snorm:
case TextureInternalFormat::RG8Snorm:
return "RG8Snorm";
case TextureSizedInternalFormat::RG16:
case TextureInternalFormat::RG16:
return "RG16";
case TextureSizedInternalFormat::RG16Snorm:
case TextureInternalFormat::RG16Snorm:
return "RG16Snorm";
case TextureSizedInternalFormat::R3G3B2:
case TextureInternalFormat::R3G3B2:
return "R3G3B2";
case TextureSizedInternalFormat::RGB4:
case TextureInternalFormat::RGB4:
return "RGB4";
case TextureSizedInternalFormat::RGB5:
case TextureInternalFormat::RGB5:
return "RGB5";
case TextureSizedInternalFormat::RGB8:
case TextureInternalFormat::RGB8:
return "RGB8";
case TextureSizedInternalFormat::RGB8Snorm:
case TextureInternalFormat::RGB8Snorm:
return "RGB8Snorm";
case TextureSizedInternalFormat::RGB10:
case TextureInternalFormat::RGB10:
return "RGB10";
case TextureSizedInternalFormat::RGB12:
case TextureInternalFormat::RGB12:
return "RGB12";
case TextureSizedInternalFormat::RGB16Snorm:
case TextureInternalFormat::RGB16Snorm:
return "RGB16Snorm";
case TextureSizedInternalFormat::RGBA2:
case TextureInternalFormat::RGBA2:
return "RGBA2";
case TextureSizedInternalFormat::RGBA4:
case TextureInternalFormat::RGBA4:
return "RGBA4";
case TextureSizedInternalFormat::RGB5A1:
case TextureInternalFormat::RGB5A1:
return "RGB5A1";
case TextureSizedInternalFormat::RGBA8:
case TextureInternalFormat::RGBA8:
return "RGBA8";
case TextureSizedInternalFormat::RGBA8Snorm:
case TextureInternalFormat::RGBA8Snorm:
return "RGBA8Snorm";
case TextureSizedInternalFormat::RGB10A2:
case TextureInternalFormat::RGB10A2:
return "RGB10A2";
case TextureSizedInternalFormat::RGB10A2UI:
case TextureInternalFormat::RGB10A2UI:
return "RGB10A2UI";
case TextureSizedInternalFormat::RGBA12:
case TextureInternalFormat::RGBA12:
return "RGBA12";
case TextureSizedInternalFormat::RGBA16:
case TextureInternalFormat::RGBA16:
return "RGBA16";
case TextureSizedInternalFormat::SRGB8:
case TextureInternalFormat::SRGB8:
return "SRGB8";
case TextureSizedInternalFormat::SRGB8Alpha8:
case TextureInternalFormat::SRGB8Alpha8:
return "SRGB8Alpha8";
case TextureSizedInternalFormat::R16F:
case TextureInternalFormat::R16F:
return "R16F";
case TextureSizedInternalFormat::RG16F:
case TextureInternalFormat::RG16F:
return "RG16F";
case TextureSizedInternalFormat::RGB16F:
case TextureInternalFormat::RGB16F:
return "RGB16F";
case TextureSizedInternalFormat::RGBA16F:
case TextureInternalFormat::RGBA16F:
return "RGBA16F";
case TextureSizedInternalFormat::R32F:
case TextureInternalFormat::R32F:
return "R32F";
case TextureSizedInternalFormat::RG32F:
case TextureInternalFormat::RG32F:
return "RG32F";
case TextureSizedInternalFormat::RGB32F:
case TextureInternalFormat::RGB32F:
return "RGB32F";
case TextureSizedInternalFormat::RGBA32F:
case TextureInternalFormat::RGBA32F:
return "RGBA32F";
case TextureSizedInternalFormat::R11FG11FB10F:
case TextureInternalFormat::R11FG11FB10F:
return "R11FG11FB10F";
case TextureSizedInternalFormat::RGB9E5:
case TextureInternalFormat::RGB9E5:
return "RGB9E5";
case TextureSizedInternalFormat::R8I:
case TextureInternalFormat::R8I:
return "R8I";
case TextureSizedInternalFormat::R8UI:
case TextureInternalFormat::R8UI:
return "R8UI";
case TextureSizedInternalFormat::R16I:
case TextureInternalFormat::R16I:
return "R16I";
case TextureSizedInternalFormat::R16UI:
case TextureInternalFormat::R16UI:
return "R16UI";
case TextureSizedInternalFormat::R32I:
case TextureInternalFormat::R32I:
return "R32I";
case TextureSizedInternalFormat::R32UI:
case TextureInternalFormat::R32UI:
return "R32UI";
case TextureSizedInternalFormat::RG8I:
case TextureInternalFormat::RG8I:
return "RG8I";
case TextureSizedInternalFormat::RG8UI:
case TextureInternalFormat::RG8UI:
return "RG8UI";
case TextureSizedInternalFormat::RG16I:
case TextureInternalFormat::RG16I:
return "RG16I";
case TextureSizedInternalFormat::RG16UI:
case TextureInternalFormat::RG16UI:
return "RG16UI";
case TextureSizedInternalFormat::RG32I:
case TextureInternalFormat::RG32I:
return "RG32I";
case TextureSizedInternalFormat::RG32UI:
case TextureInternalFormat::RG32UI:
return "RG32UI";
case TextureSizedInternalFormat::RGB8I:
case TextureInternalFormat::RGB8I:
return "RGB8I";
case TextureSizedInternalFormat::RGB8UI:
case TextureInternalFormat::RGB8UI:
return "RGB8UI";
case TextureSizedInternalFormat::RGB16I:
case TextureInternalFormat::RGB16I:
return "RGB16I";
case TextureSizedInternalFormat::RGB16UI:
case TextureInternalFormat::RGB16UI:
return "RGB16UI";
case TextureSizedInternalFormat::RGB32I:
case TextureInternalFormat::RGB32I:
return "RGB32I";
case TextureSizedInternalFormat::RGB32UI:
case TextureInternalFormat::RGB32UI:
return "RGB32UI";
case TextureSizedInternalFormat::RGBA8I:
case TextureInternalFormat::RGBA8I:
return "RGBA8I";
case TextureSizedInternalFormat::RGBA8UI:
case TextureInternalFormat::RGBA8UI:
return "RGBA8UI";
case TextureSizedInternalFormat::RGBA16I:
case TextureInternalFormat::RGBA16I:
return "RGBA16I";
case TextureSizedInternalFormat::RGBA16UI:
case TextureInternalFormat::RGBA16UI:
return "RGBA16UI";
case TextureSizedInternalFormat::RGBA32I:
case TextureInternalFormat::RGBA32I:
return "RGBA32I";
case TextureSizedInternalFormat::RGBA32UI:
case TextureInternalFormat::RGBA32UI:
return "RGBA32UI";
case TextureInternalFormat::DepthComponent:
return "DepthComponent";
case TextureInternalFormat::DepthComponent16:
return "DepthComponent16";
case TextureInternalFormat::DepthComponent24:
return "DepthComponent24";
case TextureInternalFormat::DepthComponent32:
return "DepthComponent32";
case TextureInternalFormat::DepthComponent32F:
return "DepthComponent32F";
case TextureInternalFormat::DepthStencil:
return "DepthStencil";
case TextureInternalFormat::Depth24Stencil8:
return "Depth24Stencil8";
case TextureInternalFormat::Depth32FStencil8:
return "Depth32FStencil8";
case TextureInternalFormat::Red:
return "Red";
case TextureInternalFormat::RG:
return "RG";
case TextureInternalFormat::RGB:
return "RGB";
case TextureInternalFormat::RGBA:
return "RGBA";
default:
return "Unknown";
}
@@ -223,6 +247,18 @@ namespace MobileGL {
return "UnsignedShort5551";
case TexturePixelDataType::UnsignedShort1555Rev:
return "UnsignedShort1555Rev";
case TexturePixelDataType::UnsignedInt8888:
return "UnsignedInt8888";
case TexturePixelDataType::UnsignedInt8888Rev:
return "UnsignedInt8888Rev";
case TexturePixelDataType::UnsignedInt1010102:
return "UnsignedInt1010102";
case TexturePixelDataType::UnsignedInt2101010Rev:
return "UnsignedInt2101010Rev";
case TexturePixelDataType::UnsignedInt101111Rev:
return "UnsignedInt101111Rev";
case TexturePixelDataType::UnsignedInt5999Rev:
return "UnsignedInt5999Rev";
default:
return "Unknown";
}
@@ -256,6 +292,10 @@ namespace MobileGL {
return "CubeMapNegativeZ";
case TextureUploadTarget::ProxyCubeMap:
return "ProxyCubeMap";
case TextureUploadTarget::Texture2DMultisample:
return "Texture2DMultisample";
case TextureUploadTarget::ProxyTexture2DMultisample:
return "ProxyTexture2DMultisample";
default:
return "Unknown";
}
@@ -6,7 +6,7 @@ namespace MobileGL {
namespace MG_Util {
String ConvertTextureTargetToString(TextureTarget target);
String ConvertTextureInputFormatToString(TextureInputFormat format);
String ConvertTextureSizedInternalFormatToString(TextureSizedInternalFormat internalformat);
String ConvertTextureInternalFormatToString(TextureInternalFormat internalformat);
String ConvertTexturePixelDataTypeToString(TexturePixelDataType type);
String ConvertTextureUploadTargetToString(TextureUploadTarget target);
} // namespace MG_Util
+101 -57
View File
@@ -1,85 +1,129 @@
#include "TextureMetrics.h"
#include "MG_Util/Math/VectorTypes.h"
namespace MobileGL {
namespace MG_Util {
SizeT GetTexturePixelSize(TextureSizedInternalFormat internal) {
SizeT GetTexturePixelSize(TextureInternalFormat internal) {
switch (internal) {
case TextureSizedInternalFormat::R8:
case TextureSizedInternalFormat::R8Snorm:
case TextureSizedInternalFormat::R8I:
case TextureSizedInternalFormat::R8UI:
case TextureInternalFormat::R8:
case TextureInternalFormat::R8Snorm:
case TextureInternalFormat::R8I:
case TextureInternalFormat::R8UI:
return 1;
case TextureSizedInternalFormat::R16:
case TextureSizedInternalFormat::R16Snorm:
case TextureSizedInternalFormat::R16I:
case TextureSizedInternalFormat::R16UI:
case TextureSizedInternalFormat::R16F:
case TextureSizedInternalFormat::RG8:
case TextureSizedInternalFormat::RG8Snorm:
case TextureSizedInternalFormat::RG8I:
case TextureSizedInternalFormat::RG8UI:
case TextureInternalFormat::R16:
case TextureInternalFormat::R16Snorm:
case TextureInternalFormat::R16I:
case TextureInternalFormat::R16UI:
case TextureInternalFormat::R16F:
case TextureInternalFormat::RG8:
case TextureInternalFormat::RG8Snorm:
case TextureInternalFormat::RG8I:
case TextureInternalFormat::RG8UI:
return 2;
case TextureSizedInternalFormat::R3G3B2:
case TextureSizedInternalFormat::RGB4:
case TextureSizedInternalFormat::RGB5:
case TextureSizedInternalFormat::RGB8:
case TextureSizedInternalFormat::RGB8Snorm:
case TextureSizedInternalFormat::SRGB8:
case TextureSizedInternalFormat::RGB8I:
case TextureSizedInternalFormat::RGB8UI:
case TextureInternalFormat::R3G3B2:
case TextureInternalFormat::RGB4:
case TextureInternalFormat::RGB5:
case TextureInternalFormat::RGB8:
case TextureInternalFormat::RGB8Snorm:
case TextureInternalFormat::SRGB8:
case TextureInternalFormat::RGB8I:
case TextureInternalFormat::RGB8UI:
return 3;
case TextureSizedInternalFormat::RGBA2:
case TextureSizedInternalFormat::RGBA4:
case TextureSizedInternalFormat::RGB5A1:
case TextureSizedInternalFormat::RGBA8:
case TextureSizedInternalFormat::RGBA8Snorm:
case TextureSizedInternalFormat::RGBA8I:
case TextureSizedInternalFormat::RGBA8UI:
case TextureSizedInternalFormat::SRGB8Alpha8:
case TextureSizedInternalFormat::RGB10A2:
case TextureSizedInternalFormat::RGB10A2UI:
case TextureSizedInternalFormat::R32F:
case TextureInternalFormat::RGBA2:
case TextureInternalFormat::RGBA4:
case TextureInternalFormat::RGB5A1:
case TextureInternalFormat::RGBA8:
case TextureInternalFormat::RGBA8Snorm:
case TextureInternalFormat::RGBA8I:
case TextureInternalFormat::RGBA8UI:
case TextureInternalFormat::SRGB8Alpha8:
case TextureInternalFormat::RGB10A2:
case TextureInternalFormat::RGB10A2UI:
case TextureInternalFormat::R32F:
case TextureSizedInternalFormat::RG16:
case TextureSizedInternalFormat::RG16Snorm:
case TextureSizedInternalFormat::RG16I:
case TextureSizedInternalFormat::RG16UI:
case TextureSizedInternalFormat::RG16F:
case TextureInternalFormat::RG16:
case TextureInternalFormat::RG16Snorm:
case TextureInternalFormat::RG16I:
case TextureInternalFormat::RG16UI:
case TextureInternalFormat::RG16F:
return 4;
case TextureSizedInternalFormat::RGBA12:
case TextureSizedInternalFormat::RGBA16:
case TextureSizedInternalFormat::RGBA16I:
case TextureSizedInternalFormat::RGBA16UI:
case TextureSizedInternalFormat::RGBA16F:
case TextureSizedInternalFormat::RG32F:
case TextureSizedInternalFormat::RG32I:
case TextureSizedInternalFormat::RG32UI:
case TextureInternalFormat::RGBA12:
case TextureInternalFormat::RGBA16:
case TextureInternalFormat::RGBA16I:
case TextureInternalFormat::RGBA16UI:
case TextureInternalFormat::RGBA16F:
case TextureInternalFormat::RG32F:
case TextureInternalFormat::RG32I:
case TextureInternalFormat::RG32UI:
return 8;
case TextureSizedInternalFormat::RGB16F:
case TextureSizedInternalFormat::RGB32F:
case TextureSizedInternalFormat::RGB16I:
case TextureSizedInternalFormat::RGB16UI:
case TextureSizedInternalFormat::RGB32I:
case TextureSizedInternalFormat::RGB32UI:
case TextureInternalFormat::RGB16F:
case TextureInternalFormat::RGB32F:
case TextureInternalFormat::RGB16I:
case TextureInternalFormat::RGB16UI:
case TextureInternalFormat::RGB32I:
case TextureInternalFormat::RGB32UI:
return 12;
case TextureSizedInternalFormat::RGBA32F:
case TextureSizedInternalFormat::RGBA32I:
case TextureSizedInternalFormat::RGBA32UI:
case TextureInternalFormat::RGBA32F:
case TextureInternalFormat::RGBA32I:
case TextureInternalFormat::RGBA32UI:
return 16;
case TextureSizedInternalFormat::R11FG11FB10F:
case TextureSizedInternalFormat::RGB9E5:
case TextureInternalFormat::R11FG11FB10F:
case TextureInternalFormat::RGB9E5:
return 4;
default:
return 0;
}
}
SizeT GetTexturePixelDataTypeSize(TexturePixelDataType type) {
switch (type) {
case TexturePixelDataType::UnsignedByte:
case TexturePixelDataType::Byte:
case TexturePixelDataType::UnsignedByte332:
case TexturePixelDataType::UnsignedByte233Rev:
return 1;
case TexturePixelDataType::UnsignedShort:
case TexturePixelDataType::Short:
case TexturePixelDataType::UnsignedShort565:
case TexturePixelDataType::UnsignedShort565Rev:
case TexturePixelDataType::UnsignedShort4444:
case TexturePixelDataType::UnsignedShort4444Rev:
case TexturePixelDataType::UnsignedShort5551:
case TexturePixelDataType::UnsignedShort1555Rev:
return 2;
case TexturePixelDataType::UnsignedInt:
case TexturePixelDataType::Int:
case TexturePixelDataType::Float:
case TexturePixelDataType::UnsignedInt8888:
case TexturePixelDataType::UnsignedInt8888Rev:
case TexturePixelDataType::UnsignedInt1010102:
case TexturePixelDataType::UnsignedInt2101010Rev:
case TexturePixelDataType::UnsignedInt101111Rev:
case TexturePixelDataType::UnsignedInt5999Rev:
return 4;
default:
return 0;
}
}
SizeT CalculateTextureImageSize(TextureInternalFormat internalFormat, TexturePixelDataType pixelDataType,
IntVec3 size) {
SizeT pixelSize = GetTexturePixelSize(internalFormat);
if (pixelSize == 0) return 0;
SizeT dataTypeSize = GetTexturePixelDataTypeSize(pixelDataType);
if (dataTypeSize == 0) return 0;
return pixelSize * dataTypeSize * size.x() * size.y() * size.z();
}
} // namespace MG_Util
} // namespace MobileGL
+5 -2
View File
@@ -4,6 +4,9 @@
namespace MobileGL {
namespace MG_Util {
SizeT GetTexturePixelSize(TextureSizedInternalFormat internal);
}
SizeT GetTexturePixelSize(TextureInternalFormat internal);
SizeT GetTexturePixelDataTypeSize(TexturePixelDataType type);
SizeT CalculateTextureImageSize(TextureInternalFormat internalFormat, TexturePixelDataType pixelDataType,
IntVec3 size);
} // namespace MG_Util
} // namespace MobileGL