Skip to content

Commit

Permalink
fix compatibility gles3 driver loading GL_TEXTURE_2D_ARRAY and bptc r…
Browse files Browse the repository at this point in the history
…gba pixel size
  • Loading branch information
semensanyok committed May 3, 2024
1 parent e378083 commit 9e9b84e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 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 1; //btpc bc6h
return 4; //btpc bc6h
case FORMAT_BPTC_RGBF:
return 1; //float /
case FORMAT_BPTC_RGBFU:
Expand Down
13 changes: 9 additions & 4 deletions drivers/gles3/storage/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1497,12 +1497,17 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref<Image> &p_image,
img->get_mipmap_offset_and_size(i, ofs, size);

if (compressed) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

int bw = w;
int bh = h;
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]);
}
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, i, 0, 0, p_layer, w, h, 1, format, size, &read[ofs]);

glCompressedTexImage2D(blit_target, i, internal_format, bw, bh, 0, size, &read[ofs]);
} else {
glCompressedTexImage3D(blit_target, i, internal_format, w, h, texture->layers, 0, size, &read[ofs]);
}
} else {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (texture->target == GL_TEXTURE_2D_ARRAY) {
Expand Down

0 comments on commit 9e9b84e

Please sign in to comment.