mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 04:08:32 +09:00
[Fix] (MG_Impl): give a cube map the storage and the layered attachment it asks for
direct_state_access.framebuffers_texture_attachment threw on both backends, and three separate things were wrong on the way to a cube map framebuffer. glTexStorage1D/2D/3D validated their target by converting it to a single TextureUploadTarget. GL_TEXTURE_CUBE_MAP has no single upload target - it allocates all six faces - so the conversion produced Unknown and a legal glTexStorage2D(GL_TEXTURE_CUBE_MAP, ...) was rejected with INVALID_ENUM, which is where the case threw. The accepted set for these entry points is the dimension's storage targets, which IsTextureStorageTargetForDimension already spells out, so that is what they check now. TextureStorage2D then allocated only the primary upload target, leaving a cube map with one face out of six - cube-incomplete, so every framebuffer it was attached to answered GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT. It allocates every upload target the object has; for every other 2D target that is the same single target as before. ResolveRepresentableFramebufferTextureUploadTarget declined every layered target but 2D array, so glNamedFramebufferTexture on a cube map reported "not represented by the current framebuffer attachment model". Cube maps, cube map arrays, 1D arrays, 2D multisample arrays and 3D textures are all the same shape as the 2D array that already worked - glFramebufferTexture binds the whole texture and the attachment records a representative upload target - so they are all handled now. DirectGLES routes a layered attachment to glFramebufferTexture, which is exactly this. Takes framebuffers_texture_attachment from failing to passing on both backends.
This commit is contained in:
@@ -435,12 +435,36 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
case TextureTarget::Texture2DMultisample:
|
||||
outUploadTarget = TextureUploadTarget::Texture2DMultisample;
|
||||
return true;
|
||||
// Everything below attaches as a LAYERED attachment (GL 4.6 core 9.2.8): glFramebufferTexture
|
||||
// on one of these binds the whole texture, not one image, and the upload target named here is
|
||||
// only the representative the attachment model records - the first face for a cube map, the
|
||||
// whole array otherwise. DirectGLES routes a layered attachment to glFramebufferTexture, which
|
||||
// is exactly this.
|
||||
case TextureTarget::Texture2DArray:
|
||||
outUploadTarget = TextureUploadTarget::Texture2DArray;
|
||||
outLayered = true;
|
||||
return true;
|
||||
case TextureTarget::Texture1DArray:
|
||||
outUploadTarget = TextureUploadTarget::Texture1DArray;
|
||||
outLayered = true;
|
||||
return true;
|
||||
case TextureTarget::Texture2DMultisampleArray:
|
||||
outUploadTarget = TextureUploadTarget::Texture2DMultisampleArray;
|
||||
outLayered = true;
|
||||
return true;
|
||||
case TextureTarget::Texture3D:
|
||||
outUploadTarget = TextureUploadTarget::Texture3D;
|
||||
outLayered = true;
|
||||
return true;
|
||||
case TextureTarget::TextureCubeMap:
|
||||
outUploadTarget = TextureUploadTarget::CubeMapPositiveX;
|
||||
outLayered = true;
|
||||
return true;
|
||||
case TextureTarget::TextureCubeMapArray:
|
||||
outUploadTarget = TextureUploadTarget::CubeMapArray;
|
||||
outLayered = true;
|
||||
return true;
|
||||
default:
|
||||
// TODO: Extend layered framebuffer attachment support to 3D, cube, 1D array, and multisample array textures.
|
||||
outUploadTarget = TextureUploadTarget::Unknown;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user