Skip to content

Commit

Permalink
fix compatibility gles3 driver load of compressed layered GL_TEXTURE_…
Browse files Browse the repository at this point in the history
…2D_ARRAY
  • Loading branch information
semensanyok committed May 11, 2024
1 parent 651a4d6 commit 23e12ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/io/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int Image::get_format_pixel_size(Format p_format) {
case FORMAT_RGTC_RG:
return 1; //bc5
case FORMAT_BPTC_RGBA:
return 4; //btpc bc6h
return 1; //btpc bc6h
case FORMAT_BPTC_RGBF:
return 1; //float /
case FORMAT_BPTC_RGBFU:
Expand Down
13 changes: 6 additions & 7 deletions drivers/gles3/storage/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,18 +1495,17 @@ 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, 1);

if (texture->target == GL_TEXTURE_2D_ARRAY) {
if (p_initialize) {
glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, i, internal_format, w, h, texture->layers, 0, size, &read[ofs]);
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]);
}
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, i, 0, 0, p_layer, w, h, 1, format, size, &read[ofs]);

} else {
glCompressedTexImage3D(blit_target, i, internal_format, w, h, texture->layers, 0, size, &read[ofs]);
glCompressedTexImage3D(blit_target, i, internal_format, w, h, texture->layers, 0,
size * texture->layers, &read[ofs]);
}
} else {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
Expand Down

0 comments on commit 23e12ab

Please sign in to comment.