Merge branch 'dev' into Feat/Backend-Direct-Vulkan

This commit is contained in:
BZLZHH
2026-02-07 11:41:11 +08:00
50 changed files with 2525 additions and 1136 deletions
@@ -30,13 +30,22 @@ namespace MobileGL {
}
switch (attachment) {
case GL_DEPTH_ATTACHMENT:
return FramebufferAttachmentType::Depth;
case GL_STENCIL_ATTACHMENT:
return FramebufferAttachmentType::Stencil;
case GL_UNKNOWN_MGL:
default:
return FramebufferAttachmentType::Unknown;
case GL_NONE:
return FramebufferAttachmentType::None;
case GL_DEPTH_ATTACHMENT:
return FramebufferAttachmentType::Depth;
case GL_STENCIL_ATTACHMENT:
return FramebufferAttachmentType::Stencil;
case GL_FRONT_LEFT:
return FramebufferAttachmentType::FrontLeft;
case GL_FRONT_RIGHT:
return FramebufferAttachmentType::FrontRight;
case GL_BACK_LEFT:
return FramebufferAttachmentType::BackLeft;
case GL_BACK_RIGHT:
return FramebufferAttachmentType::BackRight;
default:
return FramebufferAttachmentType::Unknown;
}
}
@@ -85,7 +85,7 @@ namespace MobileGL {
case GL_PACK_SWAP_BYTES:
return PixelStoreParam::PackSwapBytes;
case GL_PACK_LSB_FIRST:
return PixelStoreParam::PackLsbFirst;
return PixelStoreParam::PackLSBFirst;
case GL_UNPACK_ALIGNMENT:
return PixelStoreParam::UnpackAlignment;
case GL_UNPACK_ROW_LENGTH:
@@ -101,7 +101,7 @@ namespace MobileGL {
case GL_UNPACK_SWAP_BYTES:
return PixelStoreParam::UnpackSwapBytes;
case GL_UNPACK_LSB_FIRST:
return PixelStoreParam::UnpackLsbFirst;
return PixelStoreParam::UnpackLSBFirst;
default:
return PixelStoreParam::Unknown;
}
@@ -29,12 +29,20 @@ namespace MobileGL {
}
switch (type) {
case FramebufferAttachmentType::Depth:
return GL_DEPTH_ATTACHMENT;
case FramebufferAttachmentType::Stencil:
return GL_STENCIL_ATTACHMENT;
default:
return GL_NONE;
case FramebufferAttachmentType::Depth:
return GL_DEPTH_ATTACHMENT;
case FramebufferAttachmentType::Stencil:
return GL_STENCIL_ATTACHMENT;
case FramebufferAttachmentType::FrontLeft:
return GL_FRONT_LEFT;
case FramebufferAttachmentType::FrontRight:
return GL_FRONT_RIGHT;
case FramebufferAttachmentType::BackLeft:
return GL_BACK_LEFT;
case FramebufferAttachmentType::BackRight:
return GL_BACK_RIGHT;
default:
return GL_NONE;
}
}
@@ -85,7 +85,7 @@ namespace MobileGL {
return GL_PACK_SKIP_IMAGES;
case PixelStoreParam::PackSwapBytes:
return GL_PACK_SWAP_BYTES;
case PixelStoreParam::PackLsbFirst:
case PixelStoreParam::PackLSBFirst:
return GL_PACK_LSB_FIRST;
case PixelStoreParam::UnpackAlignment:
return GL_UNPACK_ALIGNMENT;
@@ -101,7 +101,7 @@ namespace MobileGL {
return GL_UNPACK_SKIP_IMAGES;
case PixelStoreParam::UnpackSwapBytes:
return GL_UNPACK_SWAP_BYTES;
case PixelStoreParam::UnpackLsbFirst:
case PixelStoreParam::UnpackLSBFirst:
return GL_UNPACK_LSB_FIRST;
default:
return GL_UNKNOWN_MGL;
@@ -183,6 +183,36 @@ namespace MobileGL {
return internalformat;
}
}
case TextureInternalFormat::DepthComponent: {
switch (type) {
case TexturePixelDataType::UnsignedShort:
return TextureInternalFormat::DepthComponent16;
case TexturePixelDataType::UnsignedInt:
return TextureInternalFormat::DepthComponent32;
case TexturePixelDataType::Float:
return TextureInternalFormat::DepthComponent32F;
default:
MGLOG_W("%s: Can't infer sized internal format from internalformat=%s, format=%s, type=%s, "
"returning original.",
__func__, MG_Util::ConvertTextureInternalFormatToString(internalformat).c_str(),
MG_Util::ConvertTextureInputFormatToString(format).c_str(),
MG_Util::ConvertTexturePixelDataTypeToString(type).c_str());
return internalformat;
}
}
case TextureInternalFormat::DepthStencil: {
switch (type) {
case TexturePixelDataType::UnsignedInt248:
return TextureInternalFormat::Depth24Stencil8;
default:
MGLOG_W("%s: Can't infer sized internal format from internalformat=%s, format=%s, type=%s, "
"returning original.",
__func__, MG_Util::ConvertTextureInternalFormatToString(internalformat).c_str(),
MG_Util::ConvertTextureInputFormatToString(format).c_str(),
MG_Util::ConvertTexturePixelDataTypeToString(type).c_str());
return internalformat;
}
}
default: {
MGLOG_W("%s: Can't infer sized internal format from internalformat=%s, format=%s, type=%s, returning "
"original.",
@@ -193,5 +223,93 @@ namespace MobileGL {
}
}
}
TextureInternalFormat ConvertInternalFormatToUnsized(TextureInternalFormat internalformat) {
switch (internalformat) {
case TextureInternalFormat::R8:
case TextureInternalFormat::R8Snorm:
case TextureInternalFormat::R16:
case TextureInternalFormat::R16Snorm:
case TextureInternalFormat::R16F:
case TextureInternalFormat::R32F:
case TextureInternalFormat::R8I:
case TextureInternalFormat::R8UI:
case TextureInternalFormat::R16I:
case TextureInternalFormat::R16UI:
case TextureInternalFormat::R32I:
case TextureInternalFormat::R32UI:
case TextureInternalFormat::Red:
return TextureInternalFormat::Red;
case TextureInternalFormat::RG8:
case TextureInternalFormat::RG8Snorm:
case TextureInternalFormat::RG16:
case TextureInternalFormat::RG16Snorm:
case TextureInternalFormat::RG16F:
case TextureInternalFormat::RG32F:
case TextureInternalFormat::RG8I:
case TextureInternalFormat::RG8UI:
case TextureInternalFormat::RG16I:
case TextureInternalFormat::RG16UI:
case TextureInternalFormat::RG32I:
case TextureInternalFormat::RG32UI:
case TextureInternalFormat::RG:
return TextureInternalFormat::RG;
case TextureInternalFormat::R3G3B2:
case TextureInternalFormat::RGB4:
case TextureInternalFormat::RGB5:
case TextureInternalFormat::RGB8:
case TextureInternalFormat::RGB8Snorm:
case TextureInternalFormat::RGB10:
case TextureInternalFormat::RGB12:
case TextureInternalFormat::RGB16Snorm:
case TextureInternalFormat::RGB16F:
case TextureInternalFormat::RGB32F:
case TextureInternalFormat::R11FG11FB10F:
case TextureInternalFormat::RGB9E5:
case TextureInternalFormat::SRGB8:
case TextureInternalFormat::RGB8I:
case TextureInternalFormat::RGB8UI:
case TextureInternalFormat::RGB16I:
case TextureInternalFormat::RGB16UI:
case TextureInternalFormat::RGB32I:
case TextureInternalFormat::RGB32UI:
case TextureInternalFormat::RGB:
return TextureInternalFormat::RGB;
case TextureInternalFormat::RGBA2:
case TextureInternalFormat::RGBA4:
case TextureInternalFormat::RGB5A1:
case TextureInternalFormat::RGBA8:
case TextureInternalFormat::RGBA8Snorm:
case TextureInternalFormat::RGB10A2:
case TextureInternalFormat::RGB10A2UI:
case TextureInternalFormat::RGBA12:
case TextureInternalFormat::RGBA16:
case TextureInternalFormat::SRGB8Alpha8:
case TextureInternalFormat::RGBA16F:
case TextureInternalFormat::RGBA32F:
case TextureInternalFormat::RGBA8I:
case TextureInternalFormat::RGBA8UI:
case TextureInternalFormat::RGBA16I:
case TextureInternalFormat::RGBA16UI:
case TextureInternalFormat::RGBA32I:
case TextureInternalFormat::RGBA32UI:
case TextureInternalFormat::RGBA:
return TextureInternalFormat::RGBA;
case TextureInternalFormat::DepthComponent16:
case TextureInternalFormat::DepthComponent24:
case TextureInternalFormat::DepthComponent32:
case TextureInternalFormat::DepthComponent32F:
case TextureInternalFormat::DepthComponent:
return TextureInternalFormat::DepthComponent;
case TextureInternalFormat::Depth24Stencil8:
case TextureInternalFormat::Depth32FStencil8:
case TextureInternalFormat::DepthStencil:
return TextureInternalFormat::DepthStencil;
default:
MGLOG_W("%s: Unknown or unhandled internal format %s, returning original.", __func__,
MG_Util::ConvertTextureInternalFormatToString(internalformat).c_str());
return internalformat;
}
}
} // namespace MG_Util
} // namespace MobileGL
@@ -15,5 +15,7 @@ namespace MobileGL {
TextureTarget ConvertTextureUploadTargetToTextureTarget(TextureUploadTarget target);
TextureInternalFormat ConvertInternalFormatToSized(TextureInternalFormat internalformat,
TextureInputFormat format, TexturePixelDataType type);
TextureInternalFormat ConvertInternalFormatToUnsized(TextureInternalFormat internalformat);
} // namespace MG_Util
} // namespace MobileGL
@@ -84,8 +84,8 @@ namespace MobileGL {
return "PackSkipImages";
case PixelStoreParam::PackSwapBytes:
return "PackSwapBytes";
case PixelStoreParam::PackLsbFirst:
return "PackLsbFirst";
case PixelStoreParam::PackLSBFirst:
return "PackLSBFirst";
case PixelStoreParam::UnpackAlignment:
return "UnpackAlignment";
case PixelStoreParam::UnpackRowLength:
@@ -100,8 +100,8 @@ namespace MobileGL {
return "UnpackSkipImages";
case PixelStoreParam::UnpackSwapBytes:
return "UnpackSwapBytes";
case PixelStoreParam::UnpackLsbFirst:
return "UnpackLsbFirst";
case PixelStoreParam::UnpackLSBFirst:
return "UnpackLSBFirst";
default:
return "Unknown";
}