浏览代码

[GLES3] Avoid freeing proxy textures clearing onwer's data

(cherry picked from commit a67559931b09cc19cef1cecc82e6f6dbf596bfec)
Pedro J. Estébanez 1 年之前
父节点
当前提交
1aeff1a7a5
共有 1 个文件被更改,包括 12 次插入10 次删除
  1. 12 10
      drivers/gles3/storage/texture_storage.cpp

+ 12 - 10
drivers/gles3/storage/texture_storage.cpp

@@ -709,18 +709,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);