[Feat] (MG_Impl, MG_Util): copy into 1D and 3D textures, and accept the BPTC and ETC2 enums

Two unrelated texture gaps.

glCopyTextureSubImage1D and 3D validated their arguments and then did nothing:
CopyTexSubImage1D_State and CopyTexSubImage3D_State were empty TODOs and no
backend exposes anything but a 2D blit. But a texture's contents live in its CPU
storage - the backends sync from it - so the copy does not need a blit at all.
CopyReadFramebufferIntoMipmapRegion reads the region out of the read framebuffer
through the existing ReadPixels path, in the destination's own canonical client
layout so the bytes need no second conversion, and writes them straight into the
level. GL 4.6 core 8.6 says the copy ignores pixel-store state and any bound pack
buffer, which the borrowed readback does not, so both are neutralised for the
duration and restored after. A cube map destination addresses its faces as
separate upload targets, so its zoffset picks the target rather than a slice.

ConvertGLEnumToTextureInternalFormat had arms for the six generic compressed
formats and the four RGTC ones, all resolving to uncompressed storage, but none
for BPTC or ETC2/EAC - so glTexImage2D with one of those fourteen enums answered
INVALID_ENUM, which was never a legal reply for formats core GL has required
since 4.2 and 4.3. They follow the same deviation for the same reason: nothing in
this stack can compress them, and uncompressed storage is the trade the RGTC
formats already take.

Takes textures_compressed_subimage from failing to passing on both backends and
textures_copy on Espryt. textures_copy still fails on Magma, where the readback
of a layered attachment does not yet resolve the attached layer.
This commit is contained in:
BZLZHH
2026-08-05 05:50:32 -04:00
parent 300b458132
commit 394d1ce748
2 changed files with 132 additions and 8 deletions
@@ -288,6 +288,35 @@ namespace MobileGL {
return TextureInternalFormat::SRGB8;
case GL_COMPRESSED_SRGB_ALPHA:
return TextureInternalFormat::SRGB8Alpha8;
// BPTC and ETC2/EAC follow the same deviation as RGTC above, for the same reason: they
// are specific formats core GL requires (BPTC from 4.2, ETC2/EAC from 4.3) that this
// stack has no compressor for. INVALID_ENUM was never a legal answer for them, and
// uncompressed storage is the same trade the RGTC formats already take.
case GL_COMPRESSED_RGBA_BPTC_UNORM:
return TextureInternalFormat::RGBA8;
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
return TextureInternalFormat::SRGB8Alpha8;
case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
return TextureInternalFormat::RGB16F;
case GL_COMPRESSED_RGB8_ETC2:
return TextureInternalFormat::RGB8;
case GL_COMPRESSED_SRGB8_ETC2:
return TextureInternalFormat::SRGB8;
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
case GL_COMPRESSED_RGBA8_ETC2_EAC:
return TextureInternalFormat::RGBA8;
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
return TextureInternalFormat::SRGB8Alpha8;
case GL_COMPRESSED_R11_EAC:
return TextureInternalFormat::R8;
case GL_COMPRESSED_SIGNED_R11_EAC:
return TextureInternalFormat::R8Snorm;
case GL_COMPRESSED_RG11_EAC:
return TextureInternalFormat::RG8;
case GL_COMPRESSED_SIGNED_RG11_EAC:
return TextureInternalFormat::RG8Snorm;
case GL_ALPHA:
case GL_RED:
return TextureInternalFormat::Red;