diff options
author | Yuri Rubinsky <chaosus89@gmail.com> | 2023-01-13 21:14:00 +0300 |
---|---|---|
committer | Yuri Rubinsky <chaosus89@gmail.com> | 2023-01-13 23:25:09 +0300 |
commit | 01cddbb12a33c21f308568e0b93ff1bb49dc2e7f (patch) | |
tree | e6c52047723e477e532919dd10b866fa7e930181 | |
parent | 228db366bf7eee5cc1623f009d27e88ed80b5d7d (diff) |
Clear material arrays to prevent freeing of invalid texture RID
-rw-r--r-- | drivers/gles3/storage/material_storage.cpp | 8 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/storage_rd/material_storage.cpp | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp index e54fad1551..2d81771898 100644 --- a/drivers/gles3/storage/material_storage.cpp +++ b/drivers/gles3/storage/material_storage.cpp @@ -2765,6 +2765,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<StringName, Variant> &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); 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<StringName, Variant> &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); |