From 01cddbb12a33c21f308568e0b93ff1bb49dc2e7f Mon Sep 17 00:00:00 2001 From: Yuri Rubinsky Date: Fri, 13 Jan 2023 21:14:00 +0300 Subject: Clear material arrays to prevent freeing of invalid texture RID --- servers/rendering/renderer_rd/storage_rd/material_storage.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'servers/rendering') diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp index 66ae1e8d1a..d631a89dd2 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp @@ -2685,6 +2685,14 @@ void MaterialStorage::material_free(RID p_rid) { Material *material = material_owner.get_or_null(p_rid); ERR_FAIL_COND(!material); + // Need to clear texture arrays to prevent spin locking of their RID's. + // This happens when the app is being closed. + for (KeyValue &E : material->params) { + if (E.value.get_type() == Variant::ARRAY) { + Array(E.value).clear(); + } + } + material_set_shader(p_rid, RID()); //clean up shader material->dependency.deleted_notify(p_rid); -- cgit v1.2.3