Skip to content

Commit

Permalink
Merge pull request #91853 from semensanyok/fix-compatibility-gles3-lo…
Browse files Browse the repository at this point in the history
…ad-compressed-layered-tex-2dArray

Fix compatibility renderer load of compressed layered `GL_TEXTURE_2D_ARRAY`
  • Loading branch information
akien-mga committed May 18, 2024
2 parents bd2300d + 07c15ef commit 7cd9f61
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/gles3/storage/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,14 +1495,18 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref<Image> &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) {
Expand Down

0 comments on commit 7cd9f61

Please sign in to comment.