diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-07-29 18:19:31 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-02-11 11:58:16 +0100 |
commit | dc3b47f3abbeb271ca16ce54f2c965099d4ae492 (patch) | |
tree | d86db481912b42489b5d1ce37867c11e707a596f /servers | |
parent | b52a2f3dfa9bacb84ba40dadbb0ed3c32c5d3afd (diff) |
Vulkan/RD rasterizer now does clean exit.
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/rasterizer_rd/effects_rd.cpp | 3 | ||||
-rw-r--r-- | servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp | 29 | ||||
-rw-r--r-- | servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp | 13 |
3 files changed, 36 insertions, 9 deletions
diff --git a/servers/visual/rasterizer_rd/effects_rd.cpp b/servers/visual/rasterizer_rd/effects_rd.cpp index 1566fac5b0..90881ae7fd 100644 --- a/servers/visual/rasterizer_rd/effects_rd.cpp +++ b/servers/visual/rasterizer_rd/effects_rd.cpp @@ -139,4 +139,7 @@ EffectsRD::EffectsRD() { } EffectsRD::~EffectsRD() { + RD::get_singleton()->free(default_sampler); + blur.shader.version_free(blur.shader_version); + RD::get_singleton()->free(index_buffer); //array gets freed as dependency } diff --git a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp index 3687687dcc..f0d51f514a 100644 --- a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp @@ -2559,10 +2559,24 @@ RasterizerCanvasRD::~RasterizerCanvasRD() { //canvas state - if (state.canvas_state_buffer.is_valid()) { - RD::get_singleton()->free(state.canvas_state_buffer); + { + if (state.canvas_state_buffer.is_valid()) { + RD::get_singleton()->free(state.canvas_state_buffer); + } + + memdelete_arr(state.light_uniforms); + RD::get_singleton()->free(state.lights_uniform_buffer); + RD::get_singleton()->free(shader.default_skeleton_uniform_buffer); + RD::get_singleton()->free(shader.default_skeleton_texture_buffer); } + //shadow rendering + { + + shadow_render.shader.version_free(shadow_render.shader_version); + //this will also automatically clear all pipelines + RD::get_singleton()->free(state.shadow_sampler); + } //bindings { @@ -2589,8 +2603,15 @@ RasterizerCanvasRD::~RasterizerCanvasRD() { shader.canvas_shader.version_free(shader.default_version); //buffers - RD::get_singleton()->free(shader.quad_index_array); - RD::get_singleton()->free(shader.quad_index_buffer); + { + RD::get_singleton()->free(shader.quad_index_array); + RD::get_singleton()->free(shader.quad_index_buffer); + RD::get_singleton()->free(polygon_buffers.default_bone_buffer); + RD::get_singleton()->free(polygon_buffers.default_weight_buffer); + RD::get_singleton()->free(polygon_buffers.default_color_buffer); + RD::get_singleton()->free(polygon_buffers.default_uv_buffer); + //primitives are erase by dependency + } //pipelines don't need freeing, they are all gone after shaders are gone } diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp index 22d19073e4..15503ec38d 100644 --- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp @@ -573,9 +573,7 @@ RID RasterizerStorageRD::texture_2d_create(const Ref<Image> &p_image) { texture.is_render_target = false; texture.rd_view = rd_view; texture.is_proxy = false; -#ifndef _MSC_VER -#warning texture owner needs a spinlock to make this really callable from any thread -#endif + return texture_owner.make_rid(texture); } @@ -607,6 +605,7 @@ RID RasterizerStorageRD::texture_proxy_create(RID p_base) { RID rid = texture_owner.make_rid(proxy_tex); tex->proxies.push_back(rid); + return rid; } @@ -2045,11 +2044,13 @@ bool RasterizerStorageRD::free(RID p_rid) { ERR_FAIL_COND_V(t->is_render_target, false); - if (t->rd_texture_srgb.is_valid()) { + if (RD::get_singleton()->texture_is_valid(t->rd_texture_srgb)) { //erase this first, as it's a dependency of the one below RD::get_singleton()->free(t->rd_texture_srgb); } - RD::get_singleton()->free(t->rd_texture); + if (RD::get_singleton()->texture_is_valid(t->rd_texture)) { + RD::get_singleton()->free(t->rd_texture); + } for (int i = 0; i < t->proxies.size(); i++) { Texture *p = texture_owner.getornull(t->proxies[i]); @@ -2079,6 +2080,7 @@ bool RasterizerStorageRD::free(RID p_rid) { } material_set_shader(p_rid, RID()); //clean up shader material->instance_dependency.instance_notify_deleted(p_rid); + material_owner.free(p_rid); } else if (render_target_owner.owns(p_rid)) { RenderTarget *rt = render_target_owner.getornull(p_rid); @@ -2252,6 +2254,7 @@ RasterizerStorageRD::RasterizerStorageRD() { } RasterizerStorageRD::~RasterizerStorageRD() { + //def textures for (int i = 0; i < DEFAULT_RD_TEXTURE_MAX; i++) { RD::get_singleton()->free(default_rd_textures[i]); |