Skip to content

Commit

Permalink
Merge pull request #82430 from RandomShaper/fix_gles3_tex_free
Browse files Browse the repository at this point in the history
[GLES3] Avoid freeing proxy textures clearing onwer's data
  • Loading branch information
akien-mga committed Oct 26, 2023
2 parents 23b1f21 + a675599 commit 253711e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions drivers/gles3/storage/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,18 +713,20 @@ void TextureStorage::texture_free(RID p_texture) {
memdelete(t->canvas_texture);
}

if (t->tex_id != 0) {
if (!t->is_external) {
GLES3::Utilities::get_singleton()->texture_free_data(t->tex_id);
bool must_free_data = false;
if (t->is_proxy) {
if (t->proxy_to.is_valid()) {
Texture *proxy_to = texture_owner.get_or_null(t->proxy_to);
if (proxy_to) {
proxy_to->proxies.erase(p_texture);
}
}
t->tex_id = 0;
} else {
must_free_data = t->tex_id != 0 && !t->is_external;
}

if (t->is_proxy && t->proxy_to.is_valid()) {
Texture *proxy_to = texture_owner.get_or_null(t->proxy_to);
if (proxy_to) {
proxy_to->proxies.erase(p_texture);
}
if (must_free_data) {
GLES3::Utilities::get_singleton()->texture_free_data(t->tex_id);
t->tex_id = 0;
}

texture_atlas_remove_texture(p_texture);
Expand Down

0 comments on commit 253711e

Please sign in to comment.