From c0ff6ad9e23198403880ea689661e0e183ea7f3d Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 21 Jul 2025 17:14:54 +0200 Subject: [PATCH] Texture delete cleanup --- armorlab/sources/layers_ext.ts | 18 +++++----- armorlab/sources/nodes/photo_to_pbr_node.ts | 4 +-- armorlab/sources/nodes/rgb_node.ts | 4 +-- armorlab/sources/nodes/text_to_photo_node.ts | 2 +- armorlab/sources/nodes/upscale_node.ts | 8 ++--- armorpaint/sources/make_material.ts | 12 +++---- armorsculpt/sources/make_material.ts | 8 ++--- base/sources/iron.h | 21 +++-------- base/sources/ts/export_arm.ts | 15 ++++---- base/sources/ts/import_arm.ts | 20 +++-------- base/sources/ts/iron/data.ts | 4 +-- base/sources/ts/iron/input.ts | 4 +-- base/sources/ts/iron/iron.ts | 9 +++-- base/sources/ts/iron/mesh_data.ts | 4 +-- base/sources/ts/iron/render_path.ts | 4 +-- base/sources/ts/layers.ts | 28 ++++----------- base/sources/ts/nodes/color_node.ts | 2 +- base/sources/ts/nodes/float_node.ts | 2 +- base/sources/ts/nodes/vector_node.ts | 2 +- base/sources/ts/render_path_raytrace_bake.ts | 6 ++-- base/sources/ts/slot_layer.ts | 38 +++++--------------- base/sources/ts/slot_material.ts | 6 ++-- base/sources/ts/tab_textures.ts | 2 +- base/sources/ts/ui_nodes.ts | 2 +- base/sources/ts/ui_view2d.ts | 2 +- base/sources/ts/util_render.ts | 2 +- base/sources/ts/util_uv.ts | 8 ++--- base/tools/pad/sources/main.ts | 2 +- 28 files changed, 85 insertions(+), 154 deletions(-) diff --git a/armorlab/sources/layers_ext.ts b/armorlab/sources/layers_ext.ts index 8f6a398e..ffd00f66 100644 --- a/armorlab/sources/layers_ext.ts +++ b/armorlab/sources/layers_ext.ts @@ -23,22 +23,22 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t } function layers_ext_on_resized() { - iron_unload_image(context_raw.brush_output_node_inst.texpaint); + iron_delete_texture(context_raw.brush_output_node_inst.texpaint); let texpaint_rt: render_target_t = map_get(render_path_render_targets, "texpaint"); context_raw.brush_output_node_inst.texpaint = texpaint_rt._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); - iron_unload_image(context_raw.brush_output_node_inst.texpaint_nor); + iron_delete_texture(context_raw.brush_output_node_inst.texpaint_nor); let texpaint_nor_rt: render_target_t = map_get(render_path_render_targets, "texpaint_nor"); context_raw.brush_output_node_inst.texpaint_nor = texpaint_nor_rt._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); - iron_unload_image(context_raw.brush_output_node_inst.texpaint_pack); + iron_delete_texture(context_raw.brush_output_node_inst.texpaint_pack); let texpaint_pack_rt: render_target_t = map_get(render_path_render_targets, "texpaint_pack"); context_raw.brush_output_node_inst.texpaint_pack = texpaint_pack_rt._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); if (inpaint_node_image != null) { - iron_unload_image(inpaint_node_image); + iron_delete_texture(inpaint_node_image); inpaint_node_image = null; - iron_unload_image(inpaint_node_mask); + iron_delete_texture(inpaint_node_mask); inpaint_node_mask = null; inpaint_node_init(); } @@ -46,24 +46,24 @@ function layers_ext_on_resized() { if (photo_to_pbr_node_images != null) { for (let i: i32 = 0; i < photo_to_pbr_node_images.length; ++i) { let image: gpu_texture_t = photo_to_pbr_node_images[i]; - iron_unload_image(image); + iron_delete_texture(image); } photo_to_pbr_node_images = null; photo_to_pbr_node_init(); } if (tiling_node_image != null) { - iron_unload_image(tiling_node_image); + iron_delete_texture(tiling_node_image); tiling_node_image = null; tiling_node_init(); } let texpaint_blend0_rt: render_target_t = map_get(render_path_render_targets, "texpaint_blend0"); - iron_unload_image(texpaint_blend0_rt._image); + iron_delete_texture(texpaint_blend0_rt._image); texpaint_blend0_rt._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); let texpaint_blend1_rt: render_target_t = map_get(render_path_render_targets, "texpaint_blend1"); - iron_unload_image(texpaint_blend1_rt._image); + iron_delete_texture(texpaint_blend1_rt._image); texpaint_blend1_rt._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); if (map_get(render_path_render_targets, "texpaint_node") != null) { diff --git a/armorlab/sources/nodes/photo_to_pbr_node.ts b/armorlab/sources/nodes/photo_to_pbr_node.ts index be64cf25..27d03220 100644 --- a/armorlab/sources/nodes/photo_to_pbr_node.ts +++ b/armorlab/sources/nodes/photo_to_pbr_node.ts @@ -157,9 +157,7 @@ function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): g draw_begin(photo_to_pbr_node_images[from]); draw_image(temp2, x * photo_to_pbr_node_tile_w, y * photo_to_pbr_node_tile_w); draw_end(); - sys_notify_on_next_frame(function(temp2: gpu_texture_t) { - iron_unload_image(temp2); - }, temp2); + iron_delete_texture(temp2); } return photo_to_pbr_node_images[from]; diff --git a/armorlab/sources/nodes/rgb_node.ts b/armorlab/sources/nodes/rgb_node.ts index 87d363ec..14eafbb8 100644 --- a/armorlab/sources/nodes/rgb_node.ts +++ b/armorlab/sources/nodes/rgb_node.ts @@ -16,9 +16,7 @@ function rgb_node_create(raw: ui_node_t, args: f32_array_t): rgb_node_t { function rgb_node_get_as_image(self: rgb_node_t, from: i32): gpu_texture_t { if (self.image != null) { - sys_notify_on_next_frame(function (self: rgb_node_t) { - iron_unload_image(self.image); - }, self); + iron_delete_texture(self.image); } let f32a: f32_array_t = f32_array_create(4); diff --git a/armorlab/sources/nodes/text_to_photo_node.ts b/armorlab/sources/nodes/text_to_photo_node.ts index 4bf22414..5f9cab4a 100644 --- a/armorlab/sources/nodes/text_to_photo_node.ts +++ b/armorlab/sources/nodes/text_to_photo_node.ts @@ -280,7 +280,7 @@ function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): gp while (image.width < config_get_texture_res_x()) { let last_image: gpu_texture_t = image; image = upscale_node_esrgan(image); - iron_unload_image(last_image); + iron_delete_texture(last_image); } return image; } diff --git a/armorlab/sources/nodes/upscale_node.ts b/armorlab/sources/nodes/upscale_node.ts index 10e69c38..a0ac196d 100644 --- a/armorlab/sources/nodes/upscale_node.ts +++ b/armorlab/sources/nodes/upscale_node.ts @@ -26,7 +26,7 @@ function upscale_node_get_as_image(self: upscale_node_t, from: i32): gpu_texture while (upscale_node_image.width < config_get_texture_res_x()) { let last_image: gpu_texture_t = upscale_node_image; upscale_node_image = upscale_node_esrgan(upscale_node_image); - iron_unload_image(last_image); + iron_delete_texture(last_image); } } return upscale_node_image; @@ -47,7 +47,7 @@ function upscale_node_do_tile(source: gpu_texture_t): gpu_texture_t { let size2w: i32 = math_floor(size1w * 2); let size2h: i32 = math_floor(size1h * 2); if (upscale_node_temp != null) { - iron_unload_image(upscale_node_temp); + iron_delete_texture(upscale_node_temp); } upscale_node_temp = gpu_create_render_target(size1w, size1h); draw_begin(upscale_node_temp); @@ -118,10 +118,10 @@ function upscale_node_esrgan(source: gpu_texture_t): gpu_texture_t { draw_begin(result); draw_sub_image(tile_result, x * tile_size2x, y * tile_size2x, 64, 64, tile_size2x, tile_size2x); draw_end(); - iron_unload_image(tile_result); + iron_delete_texture(tile_result); } } - iron_unload_image(tile_source); + iron_delete_texture(tile_source); } else { result = upscale_node_do_tile(source); // Single tile diff --git a/armorpaint/sources/make_material.ts b/armorpaint/sources/make_material.ts index 870234ba..cefe9545 100644 --- a/armorpaint/sources/make_material.ts +++ b/armorpaint/sources/make_material.ts @@ -236,9 +236,7 @@ function make_material_bake_node_previews() { let key: string = keys[i]; if (array_index_of(context_raw.node_previews_used, key) == -1) { let image: gpu_texture_t = map_get(context_raw.node_previews, key); - sys_notify_on_next_frame(function (image: gpu_texture_t) { - iron_unload_image(image); - }, image); + iron_delete_texture(image); map_delete(context_raw.node_previews, key); } } @@ -272,7 +270,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ let res_y: i32 = math_floor(config_get_texture_res_y() / 4); if (image == null || image.width != res_x || image.height != res_y) { if (image != null) { - iron_unload_image(image); + iron_delete_texture(image); } image = gpu_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); @@ -289,7 +287,9 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ let res_x: i32 = math_floor(config_get_texture_res_x()); let res_y: i32 = math_floor(config_get_texture_res_y()); if (image == null || image.width != res_x || image.height != res_y) { - if (image != null) iron_unload_image(image); + if (image != null) { + iron_delete_texture(image); + } image = gpu_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); } @@ -306,7 +306,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ let res_y: i32 = math_floor(config_get_texture_res_y()); if (image == null || image.width != res_x || image.height != res_y) { if (image != null) { - iron_unload_image(image); + iron_delete_texture(image); } image = gpu_create_render_target(res_x, res_y, tex_format_t.R8); map_set(context_raw.node_previews, id, image); diff --git a/armorsculpt/sources/make_material.ts b/armorsculpt/sources/make_material.ts index 0d19ada3..d8927965 100644 --- a/armorsculpt/sources/make_material.ts +++ b/armorsculpt/sources/make_material.ts @@ -212,9 +212,7 @@ function make_material_bake_node_previews() { let key: string = keys[i]; if (array_index_of(context_raw.node_previews_used, key) == -1) { let image: gpu_texture_t = map_get(context_raw.node_previews, key); - sys_notify_on_next_frame(function (image: gpu_texture_t) { - iron_unload_image(image); - }, image); + iron_delete_texture(image); map_delete(context_raw.node_previews, key); } } @@ -248,7 +246,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ let res_y: i32 = math_floor(config_get_texture_res_y() / 4); if (image == null || image.width != res_x || image.height != res_y) { if (image != null) { - iron_unload_image(image); + iron_delete_texture(image); } image = gpu_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); @@ -266,7 +264,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ let res_y: i32 = math_floor(config_get_texture_res_y()); if (image == null || image.width != res_x || image.height != res_y) { if (image != null) { - iron_unload_image(image); + iron_delete_texture(image); } image = gpu_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); diff --git a/base/sources/iron.h b/base/sources/iron.h index 1d7e79b6..08291c04 100644 --- a/base/sources/iron.h +++ b/base/sources/iron.h @@ -928,12 +928,9 @@ void iron_set_gamepad_button_callback(void (*callback)(int, int, float)) { iron_gamepad_set_button_callback(_gamepad_button, NULL); } -void iron_show_mouse(bool show) { - show ? iron_mouse_show() : iron_mouse_hide(); -} - -void iron_show_keyboard(bool show) { - show ? iron_keyboard_show() : iron_keyboard_hide(); +void gpu_delete_buffer(gpu_buffer_t *buffer) { + buffers_to_destroy[buffers_to_destroy_count] = buffer; + buffers_to_destroy_count++; } any gpu_create_index_buffer(i32 count) { @@ -942,11 +939,6 @@ any gpu_create_index_buffer(i32 count) { return buffer; } -void gpu_delete_index_buffer(gpu_buffer_t *buffer) { - buffers_to_destroy[buffers_to_destroy_count] = buffer; - buffers_to_destroy_count++; -} - u32_array_t *gpu_lock_index_buffer(gpu_buffer_t *buffer) { u32_array_t *ar = (u32_array_t *)malloc(sizeof(u32_array_t)); ar->buffer = gpu_index_buffer_lock(buffer); @@ -960,11 +952,6 @@ any gpu_create_vertex_buffer(i32 count, gpu_vertex_structure_t *structure) { return buffer; } -void gpu_delete_vertex_buffer(gpu_buffer_t *buffer) { - buffers_to_destroy[buffers_to_destroy_count] = buffer; - buffers_to_destroy_count++; -} - buffer_t *gpu_lock_vertex_buffer(gpu_buffer_t *buffer) { buffer_t *b = (buffer_t *)malloc(sizeof(buffer_t)); b->buffer = gpu_vertex_buffer_lock(buffer); @@ -1206,7 +1193,7 @@ gpu_texture_t *iron_load_image(string_t *file) { return texture; } -void iron_unload_image(gpu_texture_t *texture) { +void iron_delete_texture(gpu_texture_t *texture) { textures_to_destroy[textures_to_destroy_count] = texture; textures_to_destroy_count++; } diff --git a/base/sources/ts/export_arm.ts b/base/sources/ts/export_arm.ts index d83b8d56..4fb07056 100644 --- a/base/sources/ts/export_arm.ts +++ b/base/sources/ts/export_arm.ts @@ -190,9 +190,7 @@ function export_arm_run_project() { export_arm_bgra_swap(mesh_icon_pixels); ///end - sys_notify_on_next_frame(function (mesh_icon: gpu_texture_t) { - iron_unload_image(mesh_icon); - }); + iron_delete_texture(mesh_icon); // raw.mesh_icons = // ///if (arm_metal || arm_vulkan) @@ -495,12 +493,11 @@ function export_arm_pack_assets(raw: project_format_t, assets: asset_t[]) { array_push(raw.packed_assets, pa); } } - sys_notify_on_next_frame(function (temp_images: gpu_texture_t[]) { - for (let i: i32 = 0; i < temp_images.length; ++i) { - let image: gpu_texture_t = temp_images[i]; - iron_unload_image(image); - } - }, temp_images); + + for (let i: i32 = 0; i < temp_images.length; ++i) { + let image: gpu_texture_t = temp_images[i]; + iron_delete_texture(image); + } } function export_arm_run_swatches(path: string) { diff --git a/base/sources/ts/import_arm.ts b/base/sources/ts/import_arm.ts index 63e92468..9599c7d0 100644 --- a/base/sources/ts/import_arm.ts +++ b/base/sources/ts/import_arm.ts @@ -197,17 +197,13 @@ function import_arm_run_project(path: string) { let rts: map_t = render_path_render_targets; let blend0: render_target_t = map_get(rts, "texpaint_blend0"); let _texpaint_blend0: gpu_texture_t = blend0._image; - sys_notify_on_next_frame(function (_texpaint_blend0: gpu_texture_t) { - iron_unload_image(_texpaint_blend0); - }, _texpaint_blend0); + iron_delete_texture(_texpaint_blend0); blend0.width = config_get_texture_res_x(); blend0.height = config_get_texture_res_y(); blend0._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); let blend1: render_target_t = map_get(rts, "texpaint_blend1"); let _texpaint_blend1: gpu_texture_t = blend1._image; - sys_notify_on_next_frame(function (_texpaint_blend1: gpu_texture_t) { - iron_unload_image(_texpaint_blend1); - }, _texpaint_blend1); + iron_delete_texture(_texpaint_blend1); blend1.width = config_get_texture_res_x(); blend1.height = config_get_texture_res_y(); blend1._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); @@ -301,20 +297,14 @@ function import_arm_run_project(path: string) { l.paint_subs = ld.paint_subs; ///end - sys_notify_on_next_frame(function (_texpaint: gpu_texture_t) { - iron_unload_image(_texpaint); - }, _texpaint); + iron_delete_texture(_texpaint); ///if is_paint if (_texpaint_nor != null) { - sys_notify_on_next_frame(function (_texpaint_nor: gpu_texture_t) { - iron_unload_image(_texpaint_nor); - }, _texpaint_nor); + iron_delete_texture(_texpaint_nor); } if (_texpaint_pack != null) { - sys_notify_on_next_frame(function (_texpaint_pack: gpu_texture_t) { - iron_unload_image(_texpaint_pack); - }, _texpaint_pack); + iron_delete_texture(_texpaint_pack); } ///end } diff --git a/base/sources/ts/iron/data.ts b/base/sources/ts/iron/data.ts index c9fe4964..deb74f2c 100644 --- a/base/sources/ts/iron/data.ts +++ b/base/sources/ts/iron/data.ts @@ -189,7 +189,7 @@ function data_delete_image(handle: string) { if (image == null) { return; } - iron_unload_image(image); + iron_delete_texture(image); map_delete(data_cached_images, handle); } @@ -247,7 +247,7 @@ function data_delete_all() { let cached_images_keys: string[] = map_keys(data_cached_images); for (let i: i32 = 0; i < cached_images_keys.length; ++i) { let c: gpu_texture_t = map_get(data_cached_images, cached_images_keys[i]); - iron_unload_image(c); + iron_delete_texture(c); } data_cached_images = map_create(); diff --git a/base/sources/ts/iron/input.ts b/base/sources/ts/iron/input.ts index 7d648f97..9be34ea3 100644 --- a/base/sources/ts/iron/input.ts +++ b/base/sources/ts/iron/input.ts @@ -110,12 +110,12 @@ function mouse_unlock() { } function mouse_hide() { - iron_show_mouse(false); + iron_mouse_hide(); mouse_hidden = true; } function mouse_show() { - iron_show_mouse(true); + iron_mouse_show(); mouse_hidden = false; } diff --git a/base/sources/ts/iron/iron.ts b/base/sources/ts/iron/iron.ts index db515ef4..f809b713 100644 --- a/base/sources/ts/iron/iron.ts +++ b/base/sources/ts/iron/iron.ts @@ -208,16 +208,15 @@ declare function iron_mouse_unlock(): void; declare function iron_mouse_can_lock(): bool; declare function iron_mouse_is_locked(): bool; declare function iron_mouse_set_position(x: i32, y: i32): void; -declare function iron_show_mouse(show: bool): void; -declare function iron_show_keyboard(show: bool): void; +declare function iron_mouse_show(): void; +declare function iron_mouse_hide(): void; +declare function gpu_delete_buffer(buffer: any): void; declare function gpu_create_index_buffer(count: i32): any; -declare function gpu_delete_index_buffer(buffer: any): void; declare function gpu_lock_index_buffer(buffer: any): u32_array_t; declare function gpu_index_buffer_unlock(buffer: any): void; declare function gpu_set_index_buffer(buffer: any): void; declare function gpu_create_vertex_buffer(count: i32, structure: gpu_vertex_structure_t): any; -declare function gpu_delete_vertex_buffer(buffer: any): void; declare function gpu_lock_vertex_buffer(buffer: any): buffer_t; declare function gpu_vertex_buffer_unlock(buffer: any): void; declare function gpu_set_vertex_buffer(buffer: any): void; @@ -230,7 +229,7 @@ declare function gpu_delete_pipeline(pipeline: any): void; declare function gpu_pipeline_compile(pipeline: any): void; declare function gpu_set_pipeline(pipeline: any): void; declare function iron_load_image(file: string): any; -declare function iron_unload_image(image: gpu_texture_t): void; +declare function iron_delete_texture(image: gpu_texture_t): void; declare function iron_load_sound(file: string): any; declare function iron_a1_sound_destroy(sound: any): void; declare function iron_a1_play_sound(sound: any, loop: bool, pitch: f32, unique: bool): audio_channel_t; diff --git a/base/sources/ts/iron/mesh_data.ts b/base/sources/ts/iron/mesh_data.ts index 97b905b9..fdf06a5e 100644 --- a/base/sources/ts/iron/mesh_data.ts +++ b/base/sources/ts/iron/mesh_data.ts @@ -342,11 +342,11 @@ function mesh_data_delete(raw: mesh_data_t) { for (let i: i32 = 0; i < vertex_buffer_keys.length; ++i) { let buf: gpu_buffer_t = map_get(raw._.vertex_buffer_map, vertex_buffer_keys[i]); if (buf != null) { - gpu_delete_vertex_buffer(buf); + gpu_delete_buffer(buf); } } for (let i: i32 = 0; i < raw._.index_buffers.length; ++i) { let buf: gpu_buffer_t = raw._.index_buffers[i]; - gpu_delete_index_buffer(buf); + gpu_delete_buffer(buf); } } diff --git a/base/sources/ts/iron/render_path.ts b/base/sources/ts/iron/render_path.ts index c15dcd57..2194af1e 100644 --- a/base/sources/ts/iron/render_path.ts +++ b/base/sources/ts/iron/render_path.ts @@ -246,7 +246,7 @@ function render_path_resize() { let rt: render_target_t = map_get(render_path_render_targets, render_targets_keys[i]); if (rt != null && rt.width == 0) { let _image: gpu_texture_t = rt._image; - sys_notify_on_init(iron_unload_image, _image); + iron_delete_texture(_image); rt._image = render_path_create_image(rt); } } @@ -306,6 +306,6 @@ function render_target_create(): render_target_t { function render_target_unload(raw: render_target_t) { if (raw._image != null) { - iron_unload_image(raw._image); + iron_delete_texture(raw._image); } } diff --git a/base/sources/ts/layers.ts b/base/sources/ts/layers.ts index 243fdcca..d6731569 100644 --- a/base/sources/ts/layers.ts +++ b/base/sources/ts/layers.ts @@ -76,18 +76,14 @@ function layers_resize() { let blend0: render_target_t = map_get(rts, "texpaint_blend0"); let _texpaint_blend0: gpu_texture_t = blend0._image; - sys_notify_on_next_frame(function (_texpaint_blend0: gpu_texture_t) { - iron_unload_image(_texpaint_blend0); - }, _texpaint_blend0); + iron_delete_texture(_texpaint_blend0); blend0.width = config_get_texture_res_x(); blend0.height = config_get_texture_res_y(); blend0._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); let blend1: render_target_t = map_get(rts, "texpaint_blend1"); let _texpaint_blend1: gpu_texture_t = blend1._image; - sys_notify_on_next_frame(function (_texpaint_blend1: gpu_texture_t) { - iron_unload_image(_texpaint_blend1); - }, _texpaint_blend1); + iron_delete_texture(_texpaint_blend1); blend1.width = config_get_texture_res_x(); blend1.height = config_get_texture_res_y(); blend1._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); @@ -97,9 +93,7 @@ function layers_resize() { let blur: render_target_t = map_get(rts, "texpaint_blur"); if (blur != null) { let _texpaint_blur: gpu_texture_t = blur._image; - sys_notify_on_next_frame(function (_texpaint_blur: gpu_texture_t) { - iron_unload_image(_texpaint_blur); - }, _texpaint_blur); + iron_delete_texture(_texpaint_blur); let size_x: f32 = math_floor(config_get_texture_res_x() * 0.95); let size_y: f32 = math_floor(config_get_texture_res_y() * 0.95); blur.width = size_x; @@ -161,9 +155,7 @@ function layers_make_temp_img() { function layers_make_temp_mask_img() { if (pipes_temp_mask_image != null && (pipes_temp_mask_image.width != config_get_texture_res_x() || pipes_temp_mask_image.height != config_get_texture_res_y())) { let _temp_mask_image: gpu_texture_t = pipes_temp_mask_image; - sys_notify_on_next_frame(function (_temp_mask_image: gpu_texture_t) { - iron_unload_image(_temp_mask_image); - }, _temp_mask_image); + iron_delete_texture(_temp_mask_image); pipes_temp_mask_image = null; } if (pipes_temp_mask_image == null) { @@ -183,15 +175,9 @@ function layers_make_export_img() { let _expa: gpu_texture_t = layers_expa; let _expb: gpu_texture_t = layers_expb; let _expc: gpu_texture_t = layers_expc; - sys_notify_on_next_frame(function (_expa: gpu_texture_t) { - iron_unload_image(_expa); - }, _expa); - sys_notify_on_next_frame(function (_expb: gpu_texture_t) { - iron_unload_image(_expb); - }, _expb); - sys_notify_on_next_frame(function (_expc: gpu_texture_t) { - iron_unload_image(_expc); - }, _expc); + iron_delete_texture(_expa); + iron_delete_texture(_expb); + iron_delete_texture(_expc); layers_expa = null; layers_expb = null; layers_expc = null; diff --git a/base/sources/ts/nodes/color_node.ts b/base/sources/ts/nodes/color_node.ts index ac6b554f..045254c4 100644 --- a/base/sources/ts/nodes/color_node.ts +++ b/base/sources/ts/nodes/color_node.ts @@ -34,7 +34,7 @@ function color_node_get_as_image(self: color_node_t, from: i32): gpu_texture_t { return logic_node_input_get_as_image(self.base.inputs[0]); } if (self.image != null) { - iron_unload_image(self.image); + iron_delete_texture(self.image); } let b: buffer_t = buffer_create(16); buffer_set_f32(b, 0, self.value.x); diff --git a/base/sources/ts/nodes/float_node.ts b/base/sources/ts/nodes/float_node.ts index 4556cd26..019d61a4 100644 --- a/base/sources/ts/nodes/float_node.ts +++ b/base/sources/ts/nodes/float_node.ts @@ -30,7 +30,7 @@ function float_node_get_as_image(self: float_node_t, from: i32): gpu_texture_t { return logic_node_input_get_as_image(self.base.inputs[0]); } if (self.image != null) { - iron_unload_image(self.image); + iron_delete_texture(self.image); } let b: buffer_t = buffer_create(16); buffer_set_f32(b, 0, self.value); diff --git a/base/sources/ts/nodes/vector_node.ts b/base/sources/ts/nodes/vector_node.ts index cc147e28..a97f6d2f 100644 --- a/base/sources/ts/nodes/vector_node.ts +++ b/base/sources/ts/nodes/vector_node.ts @@ -38,7 +38,7 @@ function vector_node_get_as_image(self: vector_node_t, from: i32): gpu_texture_t // let y: f32 = logic_node_input_get(self.base.inputs[1]); // let z: f32 = logic_node_input_get(self.base.inputs[2]); if (self.image != null) { - iron_unload_image(self.image); + iron_delete_texture(self.image); } let b: buffer_t = buffer_create(16); let n0: float_node_t = self.base.inputs[0].node; diff --git a/base/sources/ts/render_path_raytrace_bake.ts b/base/sources/ts/render_path_raytrace_bake.ts index d3e47fab..a8fba490 100644 --- a/base/sources/ts/render_path_raytrace_bake.ts +++ b/base/sources/ts/render_path_raytrace_bake.ts @@ -21,9 +21,9 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo let baketex0: render_target_t = map_get(render_path_render_targets, "baketex0"); let baketex1: render_target_t = map_get(render_path_render_targets, "baketex1"); let baketex2: render_target_t = map_get(render_path_render_targets, "baketex2"); - iron_unload_image(baketex0._image); - iron_unload_image(baketex1._image); - iron_unload_image(baketex2._image); + iron_delete_texture(baketex0._image); + iron_delete_texture(baketex1._image); + iron_delete_texture(baketex2._image); } { diff --git a/base/sources/ts/slot_layer.ts b/base/sources/ts/slot_layer.ts index 3c4a8b2a..59ca9fd8 100644 --- a/base/sources/ts/slot_layer.ts +++ b/base/sources/ts/slot_layer.ts @@ -184,23 +184,15 @@ function slot_layer_unload(raw: slot_layer_t) { let _texpaint_pack: gpu_texture_t = raw.texpaint_pack; let _texpaint_preview: gpu_texture_t = raw.texpaint_preview; - sys_notify_on_next_frame(function (_texpaint: gpu_texture_t) { - iron_unload_image(_texpaint); - }, _texpaint); - + iron_delete_texture(_texpaint); if (_texpaint_nor != null) { - sys_notify_on_next_frame(function (_texpaint_nor: gpu_texture_t) { - iron_unload_image(_texpaint_nor); - }, _texpaint_nor); + iron_delete_texture(_texpaint_nor); } if (_texpaint_pack != null) { - sys_notify_on_next_frame(function (_texpaint_pack: gpu_texture_t) { - iron_unload_image(_texpaint_pack); - }, _texpaint_pack); + iron_delete_texture(_texpaint_pack); } - if (_texpaint_preview != null) { - iron_unload_image(_texpaint_preview); + iron_delete_texture(_texpaint_preview); } map_delete(render_path_render_targets, "texpaint" + raw.ext); @@ -274,9 +266,7 @@ function slot_layer_invert_mask(raw: slot_layer_t) { draw_set_pipeline(null); draw_end(); let _texpaint: gpu_texture_t = raw.texpaint; - sys_notify_on_next_frame(function (_texpaint: gpu_texture_t) { - iron_unload_image(_texpaint); - }, _texpaint); + iron_delete_texture(_texpaint); let rt: render_target_t = map_get(render_path_render_targets, "texpaint" + raw.id); raw.texpaint = rt._image = inverted; context_raw.layer_preview_dirty = true; @@ -412,20 +402,12 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_end(); } - sys_notify_on_next_frame(function (_texpaint: gpu_texture_t) { - iron_unload_image(_texpaint); - }, _texpaint); - + iron_delete_texture(_texpaint); if (_texpaint_nor != null) { - sys_notify_on_next_frame(function (_texpaint_nor: gpu_texture_t) { - iron_unload_image(_texpaint_nor); - }, _texpaint_nor); + iron_delete_texture(_texpaint_nor); } - if (_texpaint_pack != null) { - sys_notify_on_next_frame(function (_texpaint_pack: gpu_texture_t) { - iron_unload_image(_texpaint_pack); - }, _texpaint_pack); + iron_delete_texture(_texpaint_pack); } let rt: render_target_t = map_get(rts, "texpaint" + raw.ext); @@ -451,9 +433,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_set_pipeline(null); draw_end(); - sys_notify_on_next_frame(function (_texpaint: gpu_texture_t) { - iron_unload_image(_texpaint); - }, _texpaint); + iron_delete_texture(_texpaint); let rt: render_target_t = map_get(rts, "texpaint" + raw.ext); rt._image = raw.texpaint; diff --git a/base/sources/ts/slot_material.ts b/base/sources/ts/slot_material.ts index 24d17e69..fc678aba 100644 --- a/base/sources/ts/slot_material.ts +++ b/base/sources/ts/slot_material.ts @@ -70,10 +70,8 @@ function slot_material_create(m: material_data_t = null, c: ui_node_canvas_t = n } function slot_material_unload(raw: slot_material_t) { - sys_notify_on_next_frame(function (raw: slot_material_t) { - iron_unload_image(raw.image); - iron_unload_image(raw.image_icon); - }, raw); + iron_delete_texture(raw.image); + iron_delete_texture(raw.image_icon); } function slot_material_delete(raw: slot_material_t) { diff --git a/base/sources/ts/tab_textures.ts b/base/sources/ts/tab_textures.ts index 2ba500f3..0dbe0a8d 100644 --- a/base/sources/ts/tab_textures.ts +++ b/base/sources/ts/tab_textures.ts @@ -157,7 +157,7 @@ function tab_textures_draw(htab: ui_handle_t) { f += ".png"; } iron_write_png(path + path_sep + f, gpu_get_texture_pixels(target), target.width, target.height, 0); - iron_unload_image(target); + iron_delete_texture(target); }, target); }); }); diff --git a/base/sources/ts/ui_nodes.ts b/base/sources/ts/ui_nodes.ts index 47fe56d8..1aa6ae0a 100644 --- a/base/sources/ts/ui_nodes.ts +++ b/base/sources/ts/ui_nodes.ts @@ -869,7 +869,7 @@ function ui_nodes_render() { if (ui_nodes_grid_redraw) { if (ui_nodes_grid != null) { - iron_unload_image(ui_nodes_grid); + iron_delete_texture(ui_nodes_grid); } let ui_nodes: ui_nodes_t = ui_nodes_get_nodes(); ui_nodes_grid = ui_nodes_draw_grid(ui_nodes.zoom); diff --git a/base/sources/ts/ui_view2d.ts b/base/sources/ts/ui_view2d.ts index 68613224..19bc7065 100644 --- a/base/sources/ts/ui_view2d.ts +++ b/base/sources/ts/ui_view2d.ts @@ -95,7 +95,7 @@ function ui_view2d_render() { // Cache grid if (ui_view2d_grid_redraw) { if (ui_view2d_grid != null) { - iron_unload_image(ui_view2d_grid); + iron_delete_texture(ui_view2d_grid); } ui_view2d_grid = ui_nodes_draw_grid(ui_view2d_pan_scale); ui_view2d_grid_redraw = false; diff --git a/base/sources/ts/util_render.ts b/base/sources/ts/util_render.ts index 3135f3aa..65969e08 100644 --- a/base/sources/ts/util_render.ts +++ b/base/sources/ts/util_render.ts @@ -157,7 +157,7 @@ function util_render_make_text_preview() { tex_w = 512; } if (context_raw.text_tool_image != null && context_raw.text_tool_image.width < tex_w) { - iron_unload_image(context_raw.text_tool_image); + iron_delete_texture(context_raw.text_tool_image); context_raw.text_tool_image = null; } if (context_raw.text_tool_image == null) { diff --git a/base/sources/ts/util_uv.ts b/base/sources/ts/util_uv.ts index e8e6faf8..0df48d3d 100644 --- a/base/sources/ts/util_uv.ts +++ b/base/sources/ts/util_uv.ts @@ -12,7 +12,7 @@ let util_uv_pipe_dilate: gpu_pipeline_t = null; function util_uv_cache_uv_map() { if (util_uv_uvmap != null && (util_uv_uvmap.width != config_get_texture_res_x() || util_uv_uvmap.height != config_get_texture_res_y())) { - iron_unload_image(util_uv_uvmap); + iron_delete_texture(util_uv_uvmap); util_uv_uvmap = null; util_uv_uvmap_cached = false; } @@ -54,7 +54,7 @@ function util_uv_cache_uv_map() { function util_uv_cache_triangle_map() { if (util_uv_trianglemap != null && (util_uv_trianglemap.width != config_get_texture_res_x() || util_uv_trianglemap.height != config_get_texture_res_y())) { - iron_unload_image(util_uv_trianglemap); + iron_delete_texture(util_uv_trianglemap); util_uv_trianglemap = null; util_uv_trianglemap_cached = false; } @@ -92,7 +92,7 @@ function util_uv_cache_triangle_map() { function util_uv_cache_dilate_map() { if (util_uv_dilatemap != null && (util_uv_dilatemap.width != config_get_texture_res_x() || util_uv_dilatemap.height != config_get_texture_res_y())) { - iron_unload_image(util_uv_dilatemap); + iron_delete_texture(util_uv_dilatemap); util_uv_dilatemap = null; util_uv_dilatemap_cached = false; } @@ -181,7 +181,7 @@ function util_uv_cache_uv_island_map() { } if (util_uv_uvislandmap != null) { - iron_unload_image(util_uv_uvislandmap); + iron_delete_texture(util_uv_uvislandmap); } util_uv_uvislandmap = gpu_create_texture_from_bytes(bytes, w, h, tex_format_t.R8); util_uv_uvislandmap_cached = true; diff --git a/base/tools/pad/sources/main.ts b/base/tools/pad/sources/main.ts index 5579c7ab..e1d6b835 100644 --- a/base/tools/pad/sources/main.ts +++ b/base/tools/pad/sources/main.ts @@ -315,7 +315,7 @@ function draw_minimap() { if (minimap_h != iron_window_height()) { minimap_h = iron_window_height(); if (minimap != null) { - iron_unload_image(minimap); + iron_delete_texture(minimap); } minimap = gpu_create_render_target(minimap_w, minimap_h); }