summaryrefslogtreecommitdiffstats
path: root/drivers/gles3/storage/texture_storage.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2023-09-27 10:35:50 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2023-09-27 10:44:56 +0200
commita67559931b09cc19cef1cecc82e6f6dbf596bfec (patch)
tree71bf761e95478df1d86df2dcc52e21b9390e979a /drivers/gles3/storage/texture_storage.cpp
parent7e67b496ff7e35f66b88adcbdd5b252d01739cbb (diff)
downloadredot-engine-a67559931b09cc19cef1cecc82e6f6dbf596bfec.tar.gz
[GLES3] Avoid freeing proxy textures clearing onwer's data
Diffstat (limited to 'drivers/gles3/storage/texture_storage.cpp')
-rw-r--r--drivers/gles3/storage/texture_storage.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp
index 6ccd4246e6..bd2a2b4055 100644
--- a/drivers/gles3/storage/texture_storage.cpp
+++ b/drivers/gles3/storage/texture_storage.cpp
@@ -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);