Texture delete cleanup

This commit is contained in:
luboslenco
2025-07-21 17:14:54 +02:00
parent acd77cfa08
commit c0ff6ad9e2
28 changed files with 85 additions and 154 deletions
+9 -9
View File
@@ -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) {
+1 -3
View File
@@ -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];
+1 -3
View File
@@ -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);
+1 -1
View File
@@ -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;
}
+4 -4
View File
@@ -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