From 07c15ef3c8845f6772802b7ea5b728f50533d80f Mon Sep 17 00:00:00 2001 From: semensanyok Date: Sun, 12 May 2024 01:14:13 +0200 Subject: [PATCH] fix compatibility gles3 driver load of compressed layered GL_TEXTURE_2D_ARRAY --- drivers/gles3/storage/texture_storage.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index a65347a5b1b5..68d10b0c3965 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1495,14 +1495,18 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref &p_image, for (int i = 0; i < mipmaps; i++) { int size, ofs; img->get_mipmap_offset_and_size(i, ofs, size); - if (compressed) { glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - - int bw = w; - int bh = h; - - glCompressedTexImage2D(blit_target, i, internal_format, bw, bh, 0, size, &read[ofs]); + if (texture->target == GL_TEXTURE_2D_ARRAY) { + if (p_initialize) { + glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, i, internal_format, w, h, texture->layers, 0, + size * texture->layers, &read[ofs]); + } else { + glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, i, 0, 0, p_layer, w, h, 1, internal_format, size, &read[ofs]); + } + } else { + glCompressedTexImage2D(blit_target, i, internal_format, w, h, 0, size, &read[ofs]); + } } else { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); if (texture->target == GL_TEXTURE_2D_ARRAY) {