From 118443ce2ef9abce7e5dc0e05f81b37043f5da36 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Thu, 6 Mar 2025 20:42:54 +0100 Subject: [PATCH] Cleanup --- armorforge/sources/sim.ts | 2 +- armorforge/sources/ui_toolbar_ext.ts | 2 +- armorlab/sources/layers_ext.ts | 36 +++---- .../sources/nodes/brush_output_node_ext.ts | 12 +-- armorlab/sources/nodes/image_texture_node.ts | 6 +- armorlab/sources/nodes/inpaint_node.ts | 42 ++++---- armorlab/sources/nodes/photo_to_pbr_node.ts | 22 ++-- armorlab/sources/nodes/rgb_node.ts | 8 +- armorlab/sources/nodes/text_to_photo_node.ts | 16 +-- armorlab/sources/nodes/tiling_node.ts | 18 ++-- armorlab/sources/nodes/upscale_node.ts | 36 +++---- armorlab/sources/nodes/variance_node.ts | 14 +-- armorlab/sources/render_path_paint.ts | 12 +-- armorlab/sources/ui_nodes_ext.ts | 12 +-- armorlab/sources/ui_toolbar_ext.ts | 2 +- armorpaint/sources/layers_ext.ts | 28 ++--- armorpaint/sources/make_material.ts | 26 ++--- .../sources/nodes/brush_output_node_ext.ts | 4 +- armorpaint/sources/render_path_paint.ts | 20 ++-- armorpaint/sources/ui_header_ext.ts | 10 +- armorpaint/sources/ui_toolbar_ext.ts | 2 +- armorsculpt/sources/export_obj.ts | 4 +- armorsculpt/sources/import_mesh.ts | 4 +- armorsculpt/sources/make_material.ts | 20 ++-- .../sources/nodes/brush_output_node_ext.ts | 4 +- armorsculpt/sources/tab_layers.ts | 2 +- armorsculpt/sources/ui_toolbar_ext.ts | 2 +- base/sources/backends/direct3d12_gpu.c | 11 -- base/sources/backends/metal_gpu.m | 15 --- base/sources/backends/vulkan_gpu.c | 14 --- base/sources/backends/webgpu_gpu.c | 6 -- base/sources/iron.h | 50 ++++----- base/sources/iron_draw.c | 11 +- base/sources/iron_draw.h | 15 +-- base/sources/iron_gpu.h | 2 - base/sources/ts/base.ts | 26 ++--- base/sources/ts/box_preferences.ts | 2 +- base/sources/ts/box_projects.ts | 10 +- base/sources/ts/config.ts | 2 +- base/sources/ts/context.ts | 26 ++--- base/sources/ts/export_arm.ts | 46 ++++---- base/sources/ts/export_obj.ts | 2 +- base/sources/ts/export_texture.ts | 36 +++---- base/sources/ts/import_arm.ts | 40 +++---- base/sources/ts/import_blend_material.ts | 2 +- base/sources/ts/import_envmap.ts | 36 +++---- base/sources/ts/import_texture.ts | 10 +- base/sources/ts/iron/data.ts | 16 +-- base/sources/ts/iron/g2.ts | 6 +- base/sources/ts/iron/g4.ts | 98 ++--------------- base/sources/ts/iron/iron.ts | 20 ++-- base/sources/ts/iron/material_data.ts | 10 +- base/sources/ts/iron/render_path.ts | 30 +++--- base/sources/ts/iron/scene.ts | 12 +-- base/sources/ts/iron/shader_data.ts | 2 +- base/sources/ts/iron/ui.ts | 15 +-- base/sources/ts/iron/uniforms.ts | 36 +++---- base/sources/ts/iron/world_data.ts | 8 +- base/sources/ts/layers.ts | 100 +++++++++--------- base/sources/ts/logic_node.ts | 10 +- base/sources/ts/nodes/color_node.ts | 6 +- base/sources/ts/nodes/float_node.ts | 6 +- base/sources/ts/nodes/vector_node.ts | 6 +- base/sources/ts/parser_material.ts | 2 +- base/sources/ts/path.ts | 2 +- base/sources/ts/pipes.ts | 2 +- base/sources/ts/project.ts | 8 +- base/sources/ts/render_path_raytrace.ts | 24 ++--- base/sources/ts/render_path_raytrace_bake.ts | 20 ++-- base/sources/ts/resource.ts | 12 +-- base/sources/ts/slot_brush.ts | 4 +- base/sources/ts/slot_font.ts | 2 +- base/sources/ts/slot_layer.ts | 84 +++++++-------- base/sources/ts/slot_material.ts | 12 +-- base/sources/ts/tab_brushes.ts | 4 +- base/sources/ts/tab_fonts.ts | 2 +- base/sources/ts/tab_layers.ts | 14 +-- base/sources/ts/tab_materials.ts | 4 +- base/sources/ts/tab_swatches.ts | 6 +- base/sources/ts/tab_textures.ts | 16 +-- base/sources/ts/ui_base.ts | 18 ++-- base/sources/ts/ui_files.ts | 26 ++--- base/sources/ts/ui_menu.ts | 4 +- base/sources/ts/ui_menubar.ts | 2 +- base/sources/ts/ui_nodes.ts | 16 +-- base/sources/ts/ui_toolbar.ts | 4 +- base/sources/ts/ui_view2d.ts | 22 ++-- base/sources/ts/uniforms_ext.ts | 2 +- base/sources/ts/util_mesh.ts | 4 +- base/sources/ts/util_render.ts | 26 ++--- base/sources/ts/util_uv.ts | 24 ++--- base/tools/amake/aimage.c | 18 ++-- base/tools/pad/sources/main.ts | 6 +- 93 files changed, 674 insertions(+), 825 deletions(-) diff --git a/armorforge/sources/sim.ts b/armorforge/sources/sim.ts index b70a7081..dadf9426 100644 --- a/armorforge/sources/sim.ts +++ b/armorforge/sources/sim.ts @@ -33,7 +33,7 @@ function sim_update() { if (sim_record) { let rt: render_target_t = map_get(render_path_render_targets, "taa"); - let pixels: buffer_t = image_get_pixels(rt._image); + let pixels: buffer_t = iron_g4_get_texture_pixels(rt._image); ///if (arm_metal || arm_vulkan) export_arm_bgra_swap(pixels); ///end diff --git a/armorforge/sources/ui_toolbar_ext.ts b/armorforge/sources/ui_toolbar_ext.ts index 4f53c3f3..b02cc013 100644 --- a/armorforge/sources/ui_toolbar_ext.ts +++ b/armorforge/sources/ui_toolbar_ext.ts @@ -1,5 +1,5 @@ -function ui_toolbar_ext_draw_tools(ui: ui_t, img: image_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { ui_toolbar_draw_tool(workspace_tool_t.GIZMO, ui, img, icon_accent, keys); ui_toolbar_draw_tool(workspace_tool_t.BRUSH, ui, img, icon_accent, keys); diff --git a/armorlab/sources/layers_ext.ts b/armorlab/sources/layers_ext.ts index 29c396a6..fd08cb7e 100644 --- a/armorlab/sources/layers_ext.ts +++ b/armorlab/sources/layers_ext.ts @@ -1,8 +1,8 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t[] = null): slot_layer_t { - let texpaint: image_t = context_raw.brush_output_node_inst.texpaint; - let texpaint_nor: image_t = context_raw.brush_output_node_inst.texpaint_nor; - let texpaint_pack: image_t = context_raw.brush_output_node_inst.texpaint_pack; + let texpaint: kinc_g5_texture_t = context_raw.brush_output_node_inst.texpaint; + let texpaint_nor: kinc_g5_texture_t = context_raw.brush_output_node_inst.texpaint_nor; + let texpaint_pack: kinc_g5_texture_t = context_raw.brush_output_node_inst.texpaint_pack; let nodes: ui_nodes_t = ui_nodes_get_nodes(); let canvas: ui_node_canvas_t = ui_nodes_get_canvas(true); @@ -23,48 +23,48 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t } function layers_ext_on_resized() { - image_unload(context_raw.brush_output_node_inst.texpaint); + iron_unload_image(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 = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + context_raw.brush_output_node_inst.texpaint = texpaint_rt._image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); - image_unload(context_raw.brush_output_node_inst.texpaint_nor); + iron_unload_image(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 = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + context_raw.brush_output_node_inst.texpaint_nor = texpaint_nor_rt._image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); - image_unload(context_raw.brush_output_node_inst.texpaint_pack); + iron_unload_image(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 = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + context_raw.brush_output_node_inst.texpaint_pack = texpaint_pack_rt._image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); if (inpaint_node_image != null) { - image_unload(inpaint_node_image); + iron_unload_image(inpaint_node_image); inpaint_node_image = null; - image_unload(inpaint_node_mask); + iron_unload_image(inpaint_node_mask); inpaint_node_mask = null; inpaint_node_init(); } if (photo_to_pbr_node_images != null) { for (let i: i32 = 0; i < photo_to_pbr_node_images.length; ++i) { - let image: image_t = photo_to_pbr_node_images[i]; - image_unload(image); + let image: kinc_g5_texture_t = photo_to_pbr_node_images[i]; + iron_unload_image(image); } photo_to_pbr_node_images = null; photo_to_pbr_node_init(); } if (tiling_node_image != null) { - image_unload(tiling_node_image); + iron_unload_image(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"); - image_unload(texpaint_blend0_rt._image); - texpaint_blend0_rt._image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + iron_unload_image(texpaint_blend0_rt._image); + texpaint_blend0_rt._image = iron_g4_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"); - image_unload(texpaint_blend1_rt._image); - texpaint_blend1_rt._image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + iron_unload_image(texpaint_blend1_rt._image); + texpaint_blend1_rt._image = iron_g4_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) { map_delete(render_path_render_targets, "texpaint_node"); diff --git a/armorlab/sources/nodes/brush_output_node_ext.ts b/armorlab/sources/nodes/brush_output_node_ext.ts index e2499cec..bbf58fcb 100644 --- a/armorlab/sources/nodes/brush_output_node_ext.ts +++ b/armorlab/sources/nodes/brush_output_node_ext.ts @@ -4,11 +4,11 @@ type brush_output_node_t = { raw?: ui_node_t; id?: i32; - texpaint?: image_t; - texpaint_nor?: image_t; - texpaint_pack?: image_t; - texpaint_nor_empty?: image_t; - texpaint_pack_empty?: image_t; + texpaint?: kinc_g5_texture_t; + texpaint_nor?: kinc_g5_texture_t; + texpaint_pack?: kinc_g5_texture_t; + texpaint_nor_empty?: kinc_g5_texture_t; + texpaint_pack_empty?: kinc_g5_texture_t; }; function brush_output_node_create_ext(n: brush_output_node_t) { @@ -66,7 +66,7 @@ function brush_output_node_create_ext(n: brush_output_node_t) { context_raw.brush_output_node_inst = n; } -function brush_output_node_get_as_image(self: brush_output_node_t, from: i32): image_t { +function brush_output_node_get_as_image(self: brush_output_node_t, from: i32): kinc_g5_texture_t { return logic_node_input_get_as_image(self.base.inputs[from]); } diff --git a/armorlab/sources/nodes/image_texture_node.ts b/armorlab/sources/nodes/image_texture_node.ts index 1742e2d1..753bc422 100644 --- a/armorlab/sources/nodes/image_texture_node.ts +++ b/armorlab/sources/nodes/image_texture_node.ts @@ -13,7 +13,7 @@ function image_texture_node_create(raw: ui_node_t, args: f32_array_t): image_tex return n; } -function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): image_t { +function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): kinc_g5_texture_t { if (project_assets.length == 0) { return null; } @@ -22,8 +22,8 @@ function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): return project_get_image(asset); } -function image_texture_node_get_cached_image(self: image_texture_node_t): image_t { - let image: image_t = self.base.get_as_image(self, 0); +function image_texture_node_get_cached_image(self: image_texture_node_t): kinc_g5_texture_t { + let image: kinc_g5_texture_t = self.base.get_as_image(self, 0); return image; } diff --git a/armorlab/sources/nodes/inpaint_node.ts b/armorlab/sources/nodes/inpaint_node.ts index f9270973..3362d409 100644 --- a/armorlab/sources/nodes/inpaint_node.ts +++ b/armorlab/sources/nodes/inpaint_node.ts @@ -5,11 +5,11 @@ type inpaint_node_t = { base?: logic_node_t; }; -let inpaint_node_image: image_t = null; -let inpaint_node_mask: image_t = null; -let inpaint_node_result: image_t = null; +let inpaint_node_image: kinc_g5_texture_t = null; +let inpaint_node_mask: kinc_g5_texture_t = null; +let inpaint_node_result: kinc_g5_texture_t = null; -let inpaint_node_temp: image_t = null; +let inpaint_node_temp: kinc_g5_texture_t = null; let inpaint_node_prompt: string = ""; let inpaint_node_strength: f32 = 0.5; let inpaint_node_auto: bool = true; @@ -27,11 +27,11 @@ function inpaint_node_create(raw: ui_node_t, args: f32_array_t): inpaint_node_t function inpaint_node_init() { if (inpaint_node_image == null) { - inpaint_node_image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + inpaint_node_image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); } if (inpaint_node_mask == null) { - inpaint_node_mask = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + inpaint_node_mask = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); app_notify_on_next_frame(function () { iron_g4_begin(inpaint_node_mask); kinc_g5_clear(color_from_floats(1.0, 1.0, 1.0, 1.0)); @@ -40,11 +40,11 @@ function inpaint_node_init() { } if (inpaint_node_temp == null) { - inpaint_node_temp = image_create_render_target(512, 512); + inpaint_node_temp = iron_g4_create_render_target(512, 512); } if (inpaint_node_result == null) { - inpaint_node_result = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + inpaint_node_result = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); } } @@ -68,8 +68,8 @@ function inpaint_node_button(node_id: i32) { } } -function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): image_t { - let source: image_t = logic_node_input_get_as_image(self.base.inputs[0]); +function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): kinc_g5_texture_t { + let source: kinc_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); console_progress(tr("Processing") + " - " + tr("Inpaint")); g2_begin(inpaint_node_image); @@ -84,13 +84,13 @@ function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): image_t { } } -function inpaint_node_get_cached_image(self: inpaint_node_t): image_t { +function inpaint_node_get_cached_image(self: inpaint_node_t): kinc_g5_texture_t { app_notify_on_next_frame(function (self: inpaint_node_t) { - let source: image_t = logic_node_input_get_as_image(self.base.inputs[0]); + let source: kinc_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); iron_g4_begin(inpaint_node_image); kinc_g5_set_pipeline(pipes_inpaint_preview); - g4_set_tex(pipes_tex0_inpaint_preview, source); - g4_set_tex(pipes_texa_inpaint_preview, inpaint_node_mask); + iron_g4_set_texture(pipes_tex0_inpaint_preview, source); + iron_g4_set_texture(pipes_texa_inpaint_preview, inpaint_node_mask); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); kinc_g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -99,16 +99,16 @@ function inpaint_node_get_cached_image(self: inpaint_node_t): image_t { return inpaint_node_image; } -function inpaint_node_get_target(): image_t { +function inpaint_node_get_target(): kinc_g5_texture_t { return inpaint_node_mask; } -function inpaint_node_texsynth_inpaint(image: image_t, tiling: bool, mask: image_t): image_t { +function inpaint_node_texsynth_inpaint(image: kinc_g5_texture_t, tiling: bool, mask: kinc_g5_texture_t): kinc_g5_texture_t { let w: i32 = config_get_texture_res_x(); let h: i32 = config_get_texture_res_y(); - let bytes_img: buffer_t = image_get_pixels(image); - let bytes_mask: buffer_t = mask != null ? image_get_pixels(mask) : buffer_create(w * h); + let bytes_img: buffer_t = iron_g4_get_texture_pixels(image); + let bytes_mask: buffer_t = mask != null ? iron_g4_get_texture_pixels(mask) : buffer_create(w * h); let bytes_out: buffer_t = buffer_create(w * h * 4); texsynth_inpaint(w, h, bytes_out.buffer, bytes_img.buffer, bytes_mask.buffer, tiling); @@ -116,10 +116,10 @@ function inpaint_node_texsynth_inpaint(image: image_t, tiling: bool, mask: image return inpaint_node_result; } -function inpaint_node_sd_inpaint(image: image_t, mask: image_t): image_t { +function inpaint_node_sd_inpaint(image: kinc_g5_texture_t, mask: kinc_g5_texture_t): kinc_g5_texture_t { inpaint_node_init(); - let bytes_img: buffer_t = image_get_pixels(mask); + let bytes_img: buffer_t = iron_g4_get_texture_pixels(mask); let u8_img: buffer_t = bytes_img; let f32mask: f32_array_t = f32_array_create(4 * 64 * 64); @@ -149,7 +149,7 @@ function inpaint_node_sd_inpaint(image: image_t, mask: image_t): image_t { draw_scaled_image(image, 0, 0, 512, 512); g2_end(); - bytes_img = image_get_pixels(inpaint_node_temp); + bytes_img = iron_g4_get_texture_pixels(inpaint_node_temp); let u8a: buffer_t = bytes_img; let f32a: f32_array_t = f32_array_create(3 * 512 * 512); for (let i: i32 = 0; i < (512 * 512); ++i) { diff --git a/armorlab/sources/nodes/photo_to_pbr_node.ts b/armorlab/sources/nodes/photo_to_pbr_node.ts index c7ee32d0..5472ebb0 100644 --- a/armorlab/sources/nodes/photo_to_pbr_node.ts +++ b/armorlab/sources/nodes/photo_to_pbr_node.ts @@ -3,11 +3,11 @@ type photo_to_pbr_node_t = { base?: logic_node_t; }; -let photo_to_pbr_node_temp: image_t = null; -let photo_to_pbr_node_images: image_t[] = null; +let photo_to_pbr_node_temp: kinc_g5_texture_t = null; +let photo_to_pbr_node_images: kinc_g5_texture_t[] = null; let photo_to_pbr_node_model_names: string[] = ["base", "occlusion", "roughness", "metallic", "normal", "height"]; -let photo_to_pbr_node_cached_source: image_t = null; +let photo_to_pbr_node_cached_source: kinc_g5_texture_t = null; let photo_to_pbr_node_border_w: i32 = 64; let photo_to_pbr_node_tile_w: i32 = 2048; let photo_to_pbr_node_tile_with_border_w: i32 = photo_to_pbr_node_tile_w + photo_to_pbr_node_border_w * 2; @@ -18,7 +18,7 @@ function photo_to_pbr_node_create(raw: ui_node_t, args: f32_array_t): photo_to_p n.base.get_as_image = photo_to_pbr_node_get_as_image; if (photo_to_pbr_node_temp == null) { - photo_to_pbr_node_temp = image_create_render_target(photo_to_pbr_node_tile_with_border_w, photo_to_pbr_node_tile_with_border_w); + photo_to_pbr_node_temp = iron_g4_create_render_target(photo_to_pbr_node_tile_with_border_w, photo_to_pbr_node_tile_with_border_w); } photo_to_pbr_node_init(); @@ -30,14 +30,14 @@ function photo_to_pbr_node_init() { if (photo_to_pbr_node_images == null) { photo_to_pbr_node_images = []; for (let i: i32 = 0; i < photo_to_pbr_node_model_names.length; ++i) { - array_push(photo_to_pbr_node_images, image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y())); + array_push(photo_to_pbr_node_images, iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y())); } } } -function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): image_t { +function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): kinc_g5_texture_t { - let source: image_t; + let source: kinc_g5_texture_t; if (photo_to_pbr_node_cached_source != null) { source = photo_to_pbr_node_cached_source; } @@ -67,7 +67,7 @@ function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): i draw_scaled_image(source, photo_to_pbr_node_border_w - x * photo_to_pbr_node_tile_w, photo_to_pbr_node_border_w - y * photo_to_pbr_node_tile_w, config_get_texture_res_x(), config_get_texture_res_y()); g2_end(); - let bytes_img: buffer_t = image_get_pixels(photo_to_pbr_node_temp); + let bytes_img: buffer_t = iron_g4_get_texture_pixels(photo_to_pbr_node_temp); let u8a: buffer_t = bytes_img; let f32a: f32_array_t = f32_array_create(3 * photo_to_pbr_node_tile_with_border_w * photo_to_pbr_node_tile_with_border_w); for (let i: i32 = 0; i < (photo_to_pbr_node_tile_with_border_w * photo_to_pbr_node_tile_with_border_w); ++i) { @@ -153,12 +153,12 @@ function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): i } ///end - let temp2: image_t = image_from_bytes(u8a, photo_to_pbr_node_tile_w, photo_to_pbr_node_tile_w); + let temp2: kinc_g5_texture_t = image_from_bytes(u8a, photo_to_pbr_node_tile_w, photo_to_pbr_node_tile_w); g2_begin(photo_to_pbr_node_images[from]); draw_image(temp2, x * photo_to_pbr_node_tile_w, y * photo_to_pbr_node_tile_w); g2_end(); - app_notify_on_next_frame(function(temp2: image_t) { - image_unload(temp2); + app_notify_on_next_frame(function(temp2: kinc_g5_texture_t) { + iron_unload_image(temp2); }, temp2); } diff --git a/armorlab/sources/nodes/rgb_node.ts b/armorlab/sources/nodes/rgb_node.ts index ae26182a..b0bdf3ab 100644 --- a/armorlab/sources/nodes/rgb_node.ts +++ b/armorlab/sources/nodes/rgb_node.ts @@ -1,7 +1,7 @@ type rgb_node_t = { base?: logic_node_t; - image?: image_t; + image?: kinc_g5_texture_t; raw?: ui_node_t; }; @@ -14,10 +14,10 @@ function rgb_node_create(raw: ui_node_t, args: f32_array_t): rgb_node_t { return n; } -function rgb_node_get_as_image(self: rgb_node_t, from: i32): image_t { +function rgb_node_get_as_image(self: rgb_node_t, from: i32): kinc_g5_texture_t { if (self.image != null) { app_notify_on_next_frame(function (self: rgb_node_t) { - image_unload(self.image); + iron_unload_image(self.image); }, self); } @@ -33,7 +33,7 @@ function rgb_node_get_as_image(self: rgb_node_t, from: i32): image_t { return self.image; } -function rgb_node_get_cached_image(self: rgb_node_t): image_t { +function rgb_node_get_cached_image(self: rgb_node_t): kinc_g5_texture_t { self.base.get_as_image(self, 0); return self.image; } diff --git a/armorlab/sources/nodes/text_to_photo_node.ts b/armorlab/sources/nodes/text_to_photo_node.ts index 57e22879..6b8f1388 100644 --- a/armorlab/sources/nodes/text_to_photo_node.ts +++ b/armorlab/sources/nodes/text_to_photo_node.ts @@ -4,7 +4,7 @@ type text_to_photo_node_t = { }; let text_to_photo_node_prompt: string = ""; -let text_to_photo_node_image: image_t = null; +let text_to_photo_node_image: kinc_g5_texture_t = null; let text_to_photo_node_tiling: bool = false; let text_to_photo_node_text_encoder_blob: buffer_t; let text_to_photo_node_unet_blob: buffer_t; @@ -18,12 +18,12 @@ function text_to_photo_node_create(raw: ui_node_t, args: f32_array_t): text_to_p return n; } -function text_to_photo_node_get_as_image(self: text_to_photo_node_t, from: i32): image_t { +function text_to_photo_node_get_as_image(self: text_to_photo_node_t, from: i32): kinc_g5_texture_t { text_to_photo_node_image = text_to_photo_node_stable_diffusion(text_to_photo_node_prompt); return text_to_photo_node_image; } -function text_to_photo_node_get_cached_image(self: text_to_photo_node_t): image_t { +function text_to_photo_node_get_cached_image(self: text_to_photo_node_t): kinc_g5_texture_t { return text_to_photo_node_image; } @@ -35,7 +35,7 @@ function text_to_photo_node_button(node_id: i32) { node.buttons[1].height = string_split(text_to_photo_node_prompt, "\n").length; } -function text_to_photo_node_stable_diffusion(prompt: string, inpaint_latents: f32_array_t = null, offset: i32 = 0, upscale: bool = true, mask: f32_array_t = null, latents_orig: f32_array_t = null): image_t { +function text_to_photo_node_stable_diffusion(prompt: string, inpaint_latents: f32_array_t = null, offset: i32 = 0, upscale: bool = true, mask: f32_array_t = null, latents_orig: f32_array_t = null): kinc_g5_texture_t { let _text_encoder_blob: buffer_t = data_get_blob("models/sd_text_encoder.quant.onnx"); let _unet_blob: buffer_t = data_get_blob("models/sd_unet.quant.onnx"); let _vae_decoder_blob: buffer_t = data_get_blob("models/sd_vae_decoder.quant.onnx"); @@ -239,7 +239,7 @@ function text_to_photo_node_unet(latents: f32_array_t, text_embeddings: f32_arra return latents; } -function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): image_t { +function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): kinc_g5_texture_t { console_progress(tr("Processing") + " - " + tr("Text to Photo")); for (let i: i32 = 0; i < latents.length; ++i) { @@ -267,7 +267,7 @@ function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): im u8a[i * 4 + 2] = math_floor(pyimage[i + 512 * 512 * 2] * 255); u8a[i * 4 + 3] = 255; } - let image: image_t = image_from_bytes(u8a, 512, 512); + let image: kinc_g5_texture_t = image_from_bytes(u8a, 512, 512); if (text_to_photo_node_tiling) { tiling_node_prompt = text_to_photo_node_prompt; @@ -278,9 +278,9 @@ function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): im if (upscale) { upscale_node_load_blob(); while (image.width < config_get_texture_res_x()) { - let last_image: image_t = image; + let last_image: kinc_g5_texture_t = image; image = upscale_node_esrgan(image); - image_unload(last_image); + iron_unload_image(last_image); } return image; } diff --git a/armorlab/sources/nodes/tiling_node.ts b/armorlab/sources/nodes/tiling_node.ts index 9ab898f9..760c99be 100644 --- a/armorlab/sources/nodes/tiling_node.ts +++ b/armorlab/sources/nodes/tiling_node.ts @@ -1,10 +1,10 @@ type tiling_node_t = { base?: logic_node_t; - result?: image_t; + result?: kinc_g5_texture_t; }; -let tiling_node_image: image_t = null; +let tiling_node_image: kinc_g5_texture_t = null; let tiling_node_prompt: string = ""; let tiling_node_strength: f32 = 0.5; let tiling_node_auto: bool = true; @@ -20,7 +20,7 @@ function tiling_node_create(raw: ui_node_t, args: f32_array_t): tiling_node_t { function tiling_node_init() { if (tiling_node_image == null) { - tiling_node_image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + tiling_node_image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); } } @@ -43,8 +43,8 @@ function tiling_node_button(node_id: i32) { } } -function tiling_node_get_as_image(self: tiling_node_t, from: i32): image_t { - let source: image_t = logic_node_input_get_as_image(self.base.inputs[0]); +function tiling_node_get_as_image(self: tiling_node_t, from: i32): kinc_g5_texture_t { + let source: kinc_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); g2_begin(tiling_node_image); draw_scaled_image(source, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); g2_end(); @@ -60,13 +60,13 @@ function tiling_node_get_as_image(self: tiling_node_t, from: i32): image_t { return self.result; } -function tiling_node_get_cached_image(self: tiling_node_t): image_t { +function tiling_node_get_cached_image(self: tiling_node_t): kinc_g5_texture_t { return self.result; } -function tiling_node_sd_tiling(image: image_t, seed: i32): image_t { +function tiling_node_sd_tiling(image: kinc_g5_texture_t, seed: i32): kinc_g5_texture_t { text_to_photo_node_tiling = false; - let tile: image_t = image_create_render_target(512, 512); + let tile: kinc_g5_texture_t = iron_g4_create_render_target(512, 512); g2_begin(tile); draw_scaled_image(image, -256, -256, 512, 512); draw_scaled_image(image, 256, -256, 512, 512); @@ -92,7 +92,7 @@ function tiling_node_sd_tiling(image: image_t, seed: i32): image_t { // u8a[y * 512 + x] = 0; // } // } - let mask: image_t = image_from_bytes(u8a, 512, 512, tex_format_t.R8); + let mask: kinc_g5_texture_t = image_from_bytes(u8a, 512, 512, tex_format_t.R8); inpaint_node_prompt = tiling_node_prompt; inpaint_node_strength = tiling_node_strength; diff --git a/armorlab/sources/nodes/upscale_node.ts b/armorlab/sources/nodes/upscale_node.ts index e19e206c..b3ba5423 100644 --- a/armorlab/sources/nodes/upscale_node.ts +++ b/armorlab/sources/nodes/upscale_node.ts @@ -3,8 +3,8 @@ type upscale_node_t = { base?: logic_node_t; }; -let upscale_node_temp: image_t = null; -let upscale_node_image: image_t = null; +let upscale_node_temp: kinc_g5_texture_t = null; +let upscale_node_image: kinc_g5_texture_t = null; let upscale_node_esrgan_blob: buffer_t; function upscale_node_create(raw: ui_node_t, args: f32_array_t): upscale_node_t { @@ -15,7 +15,7 @@ function upscale_node_create(raw: ui_node_t, args: f32_array_t): upscale_node_t return n; } -function upscale_node_get_as_image(self: upscale_node_t, from: i32): image_t { +function upscale_node_get_as_image(self: upscale_node_t, from: i32): kinc_g5_texture_t { upscale_node_image = logic_node_input_get_as_image(self.base.inputs[0]); console_progress(tr("Processing") + " - " + tr("Upscale")); @@ -24,9 +24,9 @@ function upscale_node_get_as_image(self: upscale_node_t, from: i32): image_t { if (upscale_node_image.width < config_get_texture_res_x()) { upscale_node_image = upscale_node_esrgan(upscale_node_image); while (upscale_node_image.width < config_get_texture_res_x()) { - let last_image: image_t = upscale_node_image; + let last_image: kinc_g5_texture_t = upscale_node_image; upscale_node_image = upscale_node_esrgan(upscale_node_image); - image_unload(last_image); + iron_unload_image(last_image); } } return upscale_node_image; @@ -36,25 +36,25 @@ function upscale_node_load_blob() { upscale_node_esrgan_blob = data_get_blob("models/esrgan.quant.onnx"); } -function upscale_node_get_cached_image(self: upscale_node_t): image_t { +function upscale_node_get_cached_image(self: upscale_node_t): kinc_g5_texture_t { return upscale_node_image; } -function upscale_node_do_tile(source: image_t): image_t { - let result: image_t = null; +function upscale_node_do_tile(source: kinc_g5_texture_t): kinc_g5_texture_t { + let result: kinc_g5_texture_t = null; let size1w: i32 = source.width; let size1h: i32 = source.height; let size2w: i32 = math_floor(size1w * 2); let size2h: i32 = math_floor(size1h * 2); if (upscale_node_temp != null) { - image_unload(upscale_node_temp); + iron_unload_image(upscale_node_temp); } - upscale_node_temp = image_create_render_target(size1w, size1h); + upscale_node_temp = iron_g4_create_render_target(size1w, size1h); g2_begin(upscale_node_temp); draw_scaled_image(source, 0, 0, size1w, size1h); g2_end(); - let bytes_img: buffer_t = image_get_pixels(upscale_node_temp); + let bytes_img: buffer_t = iron_g4_get_texture_pixels(upscale_node_temp); let u8a: u8_array_t = bytes_img; let f32a: f32_array_t = f32_array_create(3 * size1w * size1h); for (let i: i32 = 0; i < (size1w * size1h); ++i) { @@ -91,8 +91,8 @@ function upscale_node_do_tile(source: image_t): image_t { return result; } -function upscale_node_esrgan(source: image_t): image_t { - let result: image_t = null; +function upscale_node_esrgan(source: kinc_g5_texture_t): kinc_g5_texture_t { + let result: kinc_g5_texture_t = null; let size1w: i32 = source.width; let size1h: i32 = source.height; let tile_size: i32 = 512; @@ -101,8 +101,8 @@ function upscale_node_esrgan(source: image_t): image_t { if (size1w >= tile_size2x || size1h >= tile_size2x) { // Split into tiles let size2w: i32 = math_floor(size1w * 2); let size2h: i32 = math_floor(size1h * 2); - result = image_create_render_target(size2w, size2h); - let tile_source: image_t = image_create_render_target(tile_size + 32 * 2, tile_size + 32 * 2); + result = iron_g4_create_render_target(size2w, size2h); + let tile_source: kinc_g5_texture_t = iron_g4_create_render_target(tile_size + 32 * 2, tile_size + 32 * 2); for (let x: i32 = 0; x < math_floor(size1w / tile_size); ++x) { for (let y: i32 = 0; y < math_floor(size1h / tile_size); ++y) { g2_begin(tile_source); @@ -114,14 +114,14 @@ function upscale_node_esrgan(source: image_t): image_t { draw_scaled_image(source, 32 - x * tile_size + tile_size, 32 - y * tile_size + tile_size, source.width, -source.height); draw_scaled_image(source, 32 - x * tile_size, 32 - y * tile_size, source.width, source.height); g2_end(); - let tile_result: image_t = upscale_node_do_tile(tile_source); + let tile_result: kinc_g5_texture_t = upscale_node_do_tile(tile_source); g2_begin(result); draw_sub_image(tile_result, x * tile_size2x, y * tile_size2x, 64, 64, tile_size2x, tile_size2x); g2_end(); - image_unload(tile_result); + iron_unload_image(tile_result); } } - image_unload(tile_source); + iron_unload_image(tile_source); } else { result = upscale_node_do_tile(source); // Single tile diff --git a/armorlab/sources/nodes/variance_node.ts b/armorlab/sources/nodes/variance_node.ts index 169e7396..0429ca68 100644 --- a/armorlab/sources/nodes/variance_node.ts +++ b/armorlab/sources/nodes/variance_node.ts @@ -3,8 +3,8 @@ type variance_node_t = { base?: logic_node_t; }; -let variance_node_temp: image_t = null; -let variance_node_image: image_t = null; +let variance_node_temp: kinc_g5_texture_t = null; +let variance_node_image: kinc_g5_texture_t = null; let variance_node_inst: variance_node_t = null; let variance_node_prompt: string = ""; @@ -22,7 +22,7 @@ function variance_node_create(raw: ui_node_t, args: f32_array_t): variance_node_ function variance_node_init() { if (variance_node_temp == null) { - variance_node_temp = image_create_render_target(512, 512); + variance_node_temp = iron_g4_create_render_target(512, 512); } } @@ -33,16 +33,16 @@ function variance_node_button(node_id: i32) { node.buttons[0].height = string_split(variance_node_prompt, "\n").length; } -function variance_node_get_as_image(self: variance_node_t, from: i32): image_t { +function variance_node_get_as_image(self: variance_node_t, from: i32): kinc_g5_texture_t { let node: float_node_t = variance_node_inst.base.inputs[1].node; let strength: f32 = node.value; - let source: image_t = logic_node_input_get_as_image(variance_node_inst.base.inputs[0]); + let source: kinc_g5_texture_t = logic_node_input_get_as_image(variance_node_inst.base.inputs[0]); g2_begin(variance_node_temp); draw_scaled_image(source, 0, 0, 512, 512); g2_end(); - let bytes_img: buffer_t = image_get_pixels(variance_node_temp); + let bytes_img: buffer_t = iron_g4_get_texture_pixels(variance_node_temp); let u8a: u8_array_t = bytes_img; let f32a: f32_array_t = f32_array_create(3 * 512 * 512); for (let i: i32 = 0; i < (512 * 512); ++i) { @@ -83,7 +83,7 @@ function variance_node_get_as_image(self: variance_node_t, from: i32): image_t { return variance_node_image; } -function variance_node_get_cached_image(self: variance_node_t): image_t { +function variance_node_get_cached_image(self: variance_node_t): kinc_g5_texture_t { return variance_node_image; } diff --git a/armorlab/sources/render_path_paint.ts b/armorlab/sources/render_path_paint.ts index c4509704..7b7098a1 100644 --- a/armorlab/sources/render_path_paint.ts +++ b/armorlab/sources/render_path_paint.ts @@ -89,10 +89,10 @@ function render_path_paint_commands_paint(dilation: bool = true) { let texpaint_nor_picker: render_target_t = map_get(render_path_render_targets, "texpaint_nor_picker"); let texpaint_pack_picker: render_target_t = map_get(render_path_render_targets, "texpaint_pack_picker"); let texpaint_uv_picker: render_target_t = map_get(render_path_render_targets, "texpaint_uv_picker"); - let a: buffer_t = image_get_pixels(texpaint_picker._image); - let b: buffer_t = image_get_pixels(texpaint_nor_picker._image); - let c: buffer_t = image_get_pixels(texpaint_pack_picker._image); - let d: buffer_t = image_get_pixels(texpaint_uv_picker._image); + let a: buffer_t = iron_g4_get_texture_pixels(texpaint_picker._image); + let b: buffer_t = iron_g4_get_texture_pixels(texpaint_nor_picker._image); + let c: buffer_t = iron_g4_get_texture_pixels(texpaint_pack_picker._image); + let d: buffer_t = iron_g4_get_texture_pixels(texpaint_uv_picker._image); if (context_raw.color_picker_callback != null) { context_raw.color_picker_callback(context_raw.picked_color); @@ -190,7 +190,7 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 render_path_set_target(""); kinc_g5_set_pipeline(pipes_cursor); let gbuffer0: render_target_t = map_get(render_path_render_targets, "gbuffer0"); - g4_set_tex_depth(pipes_cursor_gbufferd, gbuffer0._image); + iron_g4_set_texture_depth(pipes_cursor_gbufferd, gbuffer0._image); iron_g4_set_float2(pipes_cursor_mouse, mx, my); iron_g4_set_float2(pipes_cursor_tex_step, 1 / gbuffer0._image.width, 1 / gbuffer0._image.height); iron_g4_set_float(pipes_cursor_radius, radius); @@ -263,7 +263,7 @@ function render_path_paint_draw() { } function render_path_paint_bind_layers() { - let image: image_t = null; + let image: kinc_g5_texture_t = null; let nodes: ui_nodes_t = ui_nodes_get_nodes(); let canvas: ui_node_canvas_t = ui_nodes_get_canvas(true); if (nodes.nodes_selected_id.length > 0) { diff --git a/armorlab/sources/ui_nodes_ext.ts b/armorlab/sources/ui_nodes_ext.ts index d6eb6a6b..cffe466a 100644 --- a/armorlab/sources/ui_nodes_ext.ts +++ b/armorlab/sources/ui_nodes_ext.ts @@ -39,11 +39,11 @@ function ui_nodes_ext_run() { parser_logic_parse(project_canvas); photo_to_pbr_node_cached_source = null; - let texbase: image_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.BASE_COLOR); - let texocc: image_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.OCCLUSION); - let texrough: image_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.ROUGHNESS); - let texnor: image_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.NORMAL_MAP); - let texheight: image_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.HEIGHT); + let texbase: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.BASE_COLOR); + let texocc: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.OCCLUSION); + let texrough: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.ROUGHNESS); + let texnor: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.NORMAL_MAP); + let texheight: kinc_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.HEIGHT); if (texbase != null) { let texpaint: render_target_t = map_get(render_path_render_targets, "texpaint"); @@ -80,7 +80,7 @@ function ui_nodes_ext_run() { if (texheight != null) { iron_g4_begin(texpaint_pack._image); kinc_g5_set_pipeline(pipes_copy_a); - g4_set_tex(pipes_copy_a_tex, texheight); + iron_g4_set_texture(pipes_copy_a_tex, texheight); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); kinc_g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); diff --git a/armorlab/sources/ui_toolbar_ext.ts b/armorlab/sources/ui_toolbar_ext.ts index 3f560f9d..ebcf1b43 100644 --- a/armorlab/sources/ui_toolbar_ext.ts +++ b/armorlab/sources/ui_toolbar_ext.ts @@ -1,4 +1,4 @@ -function ui_toolbar_ext_draw_tools(ui: ui_t, img: image_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { } diff --git a/armorpaint/sources/layers_ext.ts b/armorpaint/sources/layers_ext.ts index be66a678..e8c21e58 100644 --- a/armorpaint/sources/layers_ext.ts +++ b/armorpaint/sources/layers_ext.ts @@ -7,7 +7,7 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t layers_make_export_img(); let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); - let empty: image_t = empty_rt._image; + let empty: kinc_g5_texture_t = empty_rt._image; // Clear export layer iron_g4_begin(layers_expa); @@ -30,7 +30,7 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t continue; } - let mask: image_t = empty; + let mask: kinc_g5_texture_t = empty; let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); if (l1masks != null) { if (l1masks.length > 1) { @@ -66,10 +66,10 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t ///else iron_g4_begin(layers_expa); kinc_g5_set_pipeline(pipes_merge); - g4_set_tex(pipes_tex0, l1.texpaint); - g4_set_tex(pipes_tex1, empty); - g4_set_tex(pipes_texmask, mask); - g4_set_tex(pipes_texa, layers_temp_image); + iron_g4_set_texture(pipes_tex0, l1.texpaint); + iron_g4_set_texture(pipes_tex1, empty); + iron_g4_set_texture(pipes_texmask, mask); + iron_g4_set_texture(pipes_texa, layers_temp_image); iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); iron_g4_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); @@ -88,10 +88,10 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t iron_g4_begin(layers_expb); kinc_g5_set_pipeline(pipes_merge); - g4_set_tex(pipes_tex0, l1.texpaint); - g4_set_tex(pipes_tex1, l1.texpaint_nor); - g4_set_tex(pipes_texmask, mask); - g4_set_tex(pipes_texa, layers_temp_image); + iron_g4_set_texture(pipes_tex0, l1.texpaint); + iron_g4_set_texture(pipes_tex1, l1.texpaint_nor); + iron_g4_set_texture(pipes_texmask, mask); + iron_g4_set_texture(pipes_texa, layers_temp_image); iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); iron_g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); @@ -151,10 +151,10 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t iron_g4_begin(l0.texpaint_nor); kinc_g5_set_pipeline(pipes_merge); - g4_set_tex(pipes_tex0, layers_temp_image); - g4_set_tex(pipes_tex1, l0.texpaint_pack); - g4_set_tex(pipes_texmask, empty); - g4_set_tex(pipes_texa, empty); + iron_g4_set_texture(pipes_tex0, layers_temp_image); + iron_g4_set_texture(pipes_tex1, l0.texpaint_pack); + iron_g4_set_texture(pipes_texmask, empty); + iron_g4_set_texture(pipes_texa, empty); iron_g4_set_float(pipes_opac, 1.0); iron_g4_set_int(pipes_blending, -4); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); diff --git a/armorpaint/sources/make_material.ts b/armorpaint/sources/make_material.ts index f36cbe4d..d44386a1 100644 --- a/armorpaint/sources/make_material.ts +++ b/armorpaint/sources/make_material.ts @@ -175,7 +175,7 @@ function make_material_parse_paint_material(bake_previews: bool = true) { } if (bake_previews) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); make_material_bake_node_previews(); @@ -255,9 +255,9 @@ function make_material_bake_node_previews() { for (let i: i32 = 0; i < keys.length; ++i) { let key: string = keys[i]; if (array_index_of(context_raw.node_previews_used, key) == -1) { - let image: image_t = map_get(context_raw.node_previews, key); - app_notify_on_next_frame(function (image: image_t) { - image_unload(image); + let image: kinc_g5_texture_t = map_get(context_raw.node_previews, key); + app_notify_on_next_frame(function (image: kinc_g5_texture_t) { + iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); } @@ -286,15 +286,15 @@ function make_material_traverse_nodes(nodes: ui_node_t[], group: ui_node_canvas_ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_t, parents: ui_node_t[]) { if (node.type == "BLUR") { let id: string = parser_material_node_name(node, parents); - let image: image_t = map_get(context_raw.node_previews, id); + let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); let res_x: i32 = math_floor(config_get_texture_res_x() / 4); 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) { - image_unload(image); + iron_unload_image(image); } - image = image_create_render_target(res_x, res_y); + image = iron_g4_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); } @@ -304,13 +304,13 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ } else if (node.type == "DIRECT_WARP") { let id: string = parser_material_node_name(node, parents); - let image: image_t = map_get(context_raw.node_previews, id); + let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); 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) image_unload(image); - image = image_create_render_target(res_x, res_y); + if (image != null) iron_unload_image(image); + image = iron_g4_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); } @@ -320,15 +320,15 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ } else if (node.type == "BAKE_CURVATURE") { let id: string = parser_material_node_name(node, parents); - let image: image_t = map_get(context_raw.node_previews, id); + let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); 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) { - image_unload(image); + iron_unload_image(image); } - image = image_create_render_target(res_x, res_y, tex_format_t.R8); + image = iron_g4_create_render_target(res_x, res_y, tex_format_t.R8); map_set(context_raw.node_previews, id, image); } diff --git a/armorpaint/sources/nodes/brush_output_node_ext.ts b/armorpaint/sources/nodes/brush_output_node_ext.ts index eef4e7cc..f4799207 100644 --- a/armorpaint/sources/nodes/brush_output_node_ext.ts +++ b/armorpaint/sources/nodes/brush_output_node_ext.ts @@ -10,8 +10,8 @@ function brush_output_node_create_ext(n: brush_output_node_t) { function brush_output_node_parse_inputs(self: brush_output_node_t) { - let last_mask: image_t = context_raw.brush_mask_image; - let last_stencil: image_t = context_raw.brush_stencil_image; + let last_mask: kinc_g5_texture_t = context_raw.brush_mask_image; + let last_stencil: kinc_g5_texture_t = context_raw.brush_stencil_image; let input0: logic_node_value_t = logic_node_input_get(self.base.inputs[0]); let input1: logic_node_value_t = logic_node_input_get(self.base.inputs[1]); diff --git a/armorpaint/sources/render_path_paint.ts b/armorpaint/sources/render_path_paint.ts index 8f0d2ef3..0474ebdd 100644 --- a/armorpaint/sources/render_path_paint.ts +++ b/armorpaint/sources/render_path_paint.ts @@ -140,10 +140,10 @@ function render_path_paint_commands_paint(dilation: bool = true) { render_path_draw_meshes("paint"); let picker0: render_target_t = map_get(render_path_render_targets, "texpaint_posnortex_picker0"); let picker1: render_target_t = map_get(render_path_render_targets, "texpaint_posnortex_picker1"); - let texpaint_posnortex_picker0: image_t = picker0._image; - let texpaint_posnortex_picker1: image_t = picker1._image; - let a: buffer_t = image_get_pixels(texpaint_posnortex_picker0); - let b: buffer_t = image_get_pixels(texpaint_posnortex_picker1); + let texpaint_posnortex_picker0: kinc_g5_texture_t = picker0._image; + let texpaint_posnortex_picker1: kinc_g5_texture_t = picker1._image; + let a: buffer_t = iron_g4_get_texture_pixels(texpaint_posnortex_picker0); + let b: buffer_t = iron_g4_get_texture_pixels(texpaint_posnortex_picker1); context_raw.posx_picked = buffer_get_f32(a, 0); context_raw.posy_picked = buffer_get_f32(a, 4); context_raw.posz_picked = buffer_get_f32(a, 8); @@ -177,10 +177,10 @@ function render_path_paint_commands_paint(dilation: bool = true) { let texpaint_nor_picker: render_target_t = map_get(render_path_render_targets, "texpaint_nor_picker"); let texpaint_pack_picker: render_target_t = map_get(render_path_render_targets, "texpaint_pack_picker"); let texpaint_uv_picker: render_target_t = map_get(render_path_render_targets, "texpaint_uv_picker"); - let a: buffer_t = image_get_pixels(texpaint_picker._image); - let b: buffer_t = image_get_pixels(texpaint_nor_picker._image); - let c: buffer_t = image_get_pixels(texpaint_pack_picker._image); - let d: buffer_t = image_get_pixels(texpaint_uv_picker._image); + let a: buffer_t = iron_g4_get_texture_pixels(texpaint_picker._image); + let b: buffer_t = iron_g4_get_texture_pixels(texpaint_nor_picker._image); + let c: buffer_t = iron_g4_get_texture_pixels(texpaint_pack_picker._image); + let d: buffer_t = iron_g4_get_texture_pixels(texpaint_uv_picker._image); if (context_raw.color_picker_callback != null) { context_raw.color_picker_callback(context_raw.picked_color); @@ -441,8 +441,8 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 render_path_set_target(""); kinc_g5_set_pipeline(pipes_cursor); let rt: render_target_t = map_get(render_path_render_targets, "gbuffer0"); - let gbuffer0: image_t = rt._image; - g4_set_tex_depth(pipes_cursor_gbufferd, gbuffer0); + let gbuffer0: kinc_g5_texture_t = rt._image; + iron_g4_set_texture_depth(pipes_cursor_gbufferd, gbuffer0); iron_g4_set_float2(pipes_cursor_mouse, mx, my); iron_g4_set_float2(pipes_cursor_tex_step, 1 / gbuffer0.width, 1 / gbuffer0.height); iron_g4_set_float(pipes_cursor_radius, radius); diff --git a/armorpaint/sources/ui_header_ext.ts b/armorpaint/sources/ui_header_ext.ts index 9ed1e137..8041f732 100644 --- a/armorpaint/sources/ui_header_ext.ts +++ b/armorpaint/sources/ui_header_ext.ts @@ -55,8 +55,8 @@ function ui_header_draw_tool_properties(ui: ui_t) { iron_g4_begin(m.texpaint); kinc_g5_set_pipeline(pipes_colorid_to_mask); let rt: render_target_t = map_get(render_path_render_targets, "texpaint_colorid"); - g4_set_tex(pipes_texpaint_colorid, rt._image); - g4_set_tex(pipes_tex_colorid, project_get_image(project_assets[context_raw.colorid_handle.position])); + iron_g4_set_texture(pipes_texpaint_colorid, rt._image); + iron_g4_set_texture(pipes_tex_colorid, project_get_image(project_assets[context_raw.colorid_handle.position])); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); kinc_g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); @@ -338,7 +338,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { context_raw.brush_scale = ui_slider(brush_scale_handle, tr("UV Scale"), 0.01, 5.0, true); if (brush_scale_handle.changed) { if (context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; g2_end(); util_render_make_decal_preview(); g2_begin(current); @@ -423,7 +423,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { ui._w = w; if (h.changed) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; g2_end(); util_render_make_text_preview(); util_render_make_decal_preview(); @@ -436,7 +436,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { ui_combo(context_raw.fill_type_handle, fill_mode_combo, tr("Fill Mode")); if (context_raw.fill_type_handle.changed) { if (context_raw.fill_type_handle.position == fill_type_t.FACE) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; g2_end(); // cache_uv_map(); util_uv_cache_triangle_map(); diff --git a/armorpaint/sources/ui_toolbar_ext.ts b/armorpaint/sources/ui_toolbar_ext.ts index 75c91b84..da5b5554 100644 --- a/armorpaint/sources/ui_toolbar_ext.ts +++ b/armorpaint/sources/ui_toolbar_ext.ts @@ -1,5 +1,5 @@ -function ui_toolbar_ext_draw_tools(ui: ui_t, img: image_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { ui_toolbar_draw_tool(workspace_tool_t.BRUSH, ui, img, icon_accent, keys); ui_toolbar_draw_tool(workspace_tool_t.ERASER, ui, img, icon_accent, keys); diff --git a/armorsculpt/sources/export_obj.ts b/armorsculpt/sources/export_obj.ts index 72205a4b..fcbc366d 100644 --- a/armorsculpt/sources/export_obj.ts +++ b/armorsculpt/sources/export_obj.ts @@ -9,8 +9,8 @@ function export_obj_run(path: string, paint_objects: mesh_object_t[], apply_disp let o: u8[] = []; export_obj_write_string(o, "# armorsculpt.org\n"); - let texpaint: image_t = project_layers[0].texpaint; - let pixels: buffer_t = image_get_pixels(texpaint); + let texpaint: kinc_g5_texture_t = project_layers[0].texpaint; + let pixels: buffer_t = iron_g4_get_texture_pixels(texpaint); let mesh: mesh_data_t = paint_objects[0].data; let inda: u32_array_t = mesh.index_arrays[0].values; diff --git a/armorsculpt/sources/import_mesh.ts b/armorsculpt/sources/import_mesh.ts index 215cd469..6720ddcc 100644 --- a/armorsculpt/sources/import_mesh.ts +++ b/armorsculpt/sources/import_mesh.ts @@ -230,8 +230,8 @@ function import_mesh_pack_to_texture(mesh: raw_mesh_t) { buffer_set_f32(b, 4 * i * 4 + 3 * 4, 1.0); } - let imgmesh: image_t = image_from_bytes(b, config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.RGBA128); - let texpaint: image_t = project_layers[0].texpaint; + let imgmesh: kinc_g5_texture_t = image_from_bytes(b, config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.RGBA128); + let texpaint: kinc_g5_texture_t = project_layers[0].texpaint; g2_begin(texpaint); draw_set_pipeline(pipes_copy128); draw_scaled_image(imgmesh, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); diff --git a/armorsculpt/sources/make_material.ts b/armorsculpt/sources/make_material.ts index 5676bbcb..d55d7846 100644 --- a/armorsculpt/sources/make_material.ts +++ b/armorsculpt/sources/make_material.ts @@ -156,7 +156,7 @@ function make_material_parse_paint_material(bake_previews: bool = true) { } if (bake_previews) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); make_material_bake_node_previews(); @@ -232,9 +232,9 @@ function make_material_bake_node_previews() { for (let i: i32 = 0; i < keys.length; ++i) { let key: string = keys[i]; if (array_index_of(context_raw.node_previews_used, key) == -1) { - let image: image_t = map_get(context_raw.node_previews, key); - app_notify_on_next_frame(function (image: image_t) { - image_unload(image); + let image: kinc_g5_texture_t = map_get(context_raw.node_previews, key); + app_notify_on_next_frame(function (image: kinc_g5_texture_t) { + iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); } @@ -263,15 +263,15 @@ function make_material_traverse_nodes(nodes: ui_node_t[], group: ui_node_canvas_ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_t, parents: ui_node_t[]) { if (node.type == "BLUR") { let id: string = parser_material_node_name(node, parents); - let image: image_t = map_get(context_raw.node_previews, id); + let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); let res_x: i32 = math_floor(config_get_texture_res_x() / 4); 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) { - image_unload(image); + iron_unload_image(image); } - image = image_create_render_target(res_x, res_y); + image = iron_g4_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); } @@ -281,15 +281,15 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ } else if (node.type == "DIRECT_WARP") { let id: string = parser_material_node_name(node, parents); - let image: image_t = map_get(context_raw.node_previews, id); + let image: kinc_g5_texture_t = map_get(context_raw.node_previews, id); array_push(context_raw.node_previews_used, id); 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) { - image_unload(image); + iron_unload_image(image); } - image = image_create_render_target(res_x, res_y); + image = iron_g4_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); } diff --git a/armorsculpt/sources/nodes/brush_output_node_ext.ts b/armorsculpt/sources/nodes/brush_output_node_ext.ts index 15711678..20949cc1 100644 --- a/armorsculpt/sources/nodes/brush_output_node_ext.ts +++ b/armorsculpt/sources/nodes/brush_output_node_ext.ts @@ -10,8 +10,8 @@ function brush_output_node_create_ext(n: brush_output_node_t) { function brush_output_node_parse_inputs(self: brush_output_node_t) { - let last_mask: image_t = context_raw.brush_mask_image; - let last_stencil: image_t = context_raw.brush_stencil_image; + let last_mask: kinc_g5_texture_t = context_raw.brush_mask_image; + let last_stencil: kinc_g5_texture_t = context_raw.brush_stencil_image; let input0: logic_node_value_t = logic_node_input_get(self.base.inputs[0]); let input1: logic_node_value_t = logic_node_input_get(self.base.inputs[1]); diff --git a/armorsculpt/sources/tab_layers.ts b/armorsculpt/sources/tab_layers.ts index d9f4ffdd..972af346 100644 --- a/armorsculpt/sources/tab_layers.ts +++ b/armorsculpt/sources/tab_layers.ts @@ -223,7 +223,7 @@ function tab_layers_draw_layer_slot_full(l: slot_layer_t, i: i32) { } // Draw eye icon - let icons: image_t = resource_get("icons.k"); + let icons: kinc_g5_texture_t = resource_get("icons.k"); let r: rect_t = resource_tile18(icons, l.visible ? 0 : 1, 0); let center: i32 = (step / 2) * ui_SCALE(ui); ui._x += 2; diff --git a/armorsculpt/sources/ui_toolbar_ext.ts b/armorsculpt/sources/ui_toolbar_ext.ts index 72f267d7..d6677e44 100644 --- a/armorsculpt/sources/ui_toolbar_ext.ts +++ b/armorsculpt/sources/ui_toolbar_ext.ts @@ -1,5 +1,5 @@ -function ui_toolbar_ext_draw_tools(ui: ui_t, img: image_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { ui_toolbar_draw_tool(workspace_tool_t.BRUSH, ui, img, icon_accent, keys); } diff --git a/base/sources/backends/direct3d12_gpu.c b/base/sources/backends/direct3d12_gpu.c index 397abc9b..b6a2e3ec 100644 --- a/base/sources/backends/direct3d12_gpu.c +++ b/base/sources/backends/direct3d12_gpu.c @@ -2201,17 +2201,6 @@ void kinc_g5_internal_sampler_set(kinc_g5_command_list_t *list, kinc_g5_sampler_ list->impl.current_samplers[unit] = sampler; } -uint8_t *kinc_g5_texture_lock(struct kinc_g5_texture *texture) { - BYTE *pixel; - texture->impl.uploadImage->lpVtbl->Map(texture->impl.uploadImage, 0, NULL, (void **)&pixel); - return pixel; -} - -void kinc_g5_texture_unlock(struct kinc_g5_texture *texture) { - texture->impl.uploadImage->lpVtbl->Unmap(texture->impl.uploadImage, 0, NULL); - texture->_uploaded = false; -} - int kinc_g5_texture_stride(struct kinc_g5_texture *texture) { return texture->impl.stride; } diff --git a/base/sources/backends/metal_gpu.m b/base/sources/backends/metal_gpu.m index ca7f051c..8c10fe89 100644 --- a/base/sources/backends/metal_gpu.m +++ b/base/sources/backends/metal_gpu.m @@ -1592,21 +1592,6 @@ int kinc_g5_texture_stride(kinc_g5_texture_t *texture) { } } -uint8_t *kinc_g5_texture_lock(kinc_g5_texture_t *texture) { - return (uint8_t *)texture->impl.data; -} - -void kinc_g5_texture_unlock(kinc_g5_texture_t *tex) { - id texture = (__bridge id)tex->impl._tex; - [texture replaceRegion:MTLRegionMake2D(0, 0, tex->width, tex->height) - mipmapLevel:0 - slice:0 - withBytes:tex->impl.data - bytesPerRow:kinc_g5_texture_stride(tex) - bytesPerImage:kinc_g5_texture_stride(tex) * tex->height]; - tex->_uploaded = false; -} - void kinc_g5_texture_generate_mipmaps(kinc_g5_texture_t *texture, int levels) {} void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_g5_texture_t *mipmap, int level) { diff --git a/base/sources/backends/vulkan_gpu.c b/base/sources/backends/vulkan_gpu.c index 10930735..e8a8838d 100644 --- a/base/sources/backends/vulkan_gpu.c +++ b/base/sources/backends/vulkan_gpu.c @@ -3872,20 +3872,6 @@ int kinc_g5_texture_stride(kinc_g5_texture_t *texture) { return texture->impl.stride; } -uint8_t *kinc_g5_texture_lock(kinc_g5_texture_t *texture) { - void *data; - - VkResult err = vkMapMemory(vk_ctx.device, texture->impl.mem, 0, texture->impl.deviceSize, 0, &data); - assert(!err); - - return (uint8_t *)data; -} - -void kinc_g5_texture_unlock(kinc_g5_texture_t *texture) { - vkUnmapMemory(vk_ctx.device, texture->impl.mem); - texture->_uploaded = false; -} - void kinc_g5_texture_generate_mipmaps(kinc_g5_texture_t *texture, int levels) {} extern kinc_g5_command_list_t commandList; diff --git a/base/sources/backends/webgpu_gpu.c b/base/sources/backends/webgpu_gpu.c index 06c3afc6..88cf24ec 100644 --- a/base/sources/backends/webgpu_gpu.c +++ b/base/sources/backends/webgpu_gpu.c @@ -233,12 +233,6 @@ void kinc_g5_texture_init_from_data(kinc_g5_texture_t *texture, void *data, int void kinc_g5_texture_init_non_sampled_access(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format) {} void kinc_g5_texture_destroy(kinc_g5_texture_t *texture) {} -uint8_t *kinc_g5_texture_lock(kinc_g5_texture_t *texture) { - return NULL; -} - -void kinc_g5_texture_unlock(kinc_g5_texture_t *texture) {} - int kinc_g5_texture_stride(kinc_g5_texture_t *texture) { return 32; } diff --git a/base/sources/iron.h b/base/sources/iron.h index c361d276..ab314b26 100644 --- a/base/sources/iron.h +++ b/base/sources/iron.h @@ -1244,10 +1244,10 @@ kinc_g5_texture_t *iron_load_image(string_t *file, bool readable) { return texture; } -void iron_unload_image(image_t *image) { - if (image != NULL && image->texture_ != NULL) { - kinc_g5_texture_destroy(image->texture_); - free(image->texture_); +void iron_unload_image(kinc_g5_texture_t *image) { + if (image != NULL) { + kinc_g5_texture_destroy(image); + // free(image); } } @@ -1515,30 +1515,20 @@ buffer_t *iron_g4_get_texture_pixels(kinc_g5_texture_t *image) { return image->buffer; } -buffer_t *iron_g4_lock_texture(kinc_g5_texture_t *texture, i32 level) { - uint8_t *tex = kinc_g5_texture_lock(texture); - int stride = kinc_g5_texture_stride(texture); - int byte_length = stride * texture->height; - buffer_t *buffer = malloc(sizeof(buffer_t)); - buffer->buffer = tex; - buffer->length = byte_length; - return buffer; -} - void iron_g4_set_mipmaps(kinc_g5_texture_t *texture, any_array_t *mipmaps) { for (int32_t i = 0; i < mipmaps->length; ++i) { - image_t *img = mipmaps->buffer[i]; - kinc_g5_texture_t *img_tex = img->texture_; + kinc_g5_texture_t *img = mipmaps->buffer[i]; + kinc_g5_texture_t *img_tex = img; kinc_g5_texture_set_mipmap(texture, img_tex, i + 1); } } -void iron_g4_begin(image_t *render_target, any_array_t *additional) { +void iron_g4_begin(kinc_g5_texture_t *render_target, any_array_t *additional) { if (render_target == NULL) { kinc_g4_restore_render_target(); } else { - kinc_g5_texture_t *rt = (kinc_g5_texture_t *)render_target->texture_; + kinc_g5_texture_t *rt = (kinc_g5_texture_t *)render_target; int32_t length = 1; kinc_g5_texture_t *render_targets[8] = { rt, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; if (additional != NULL) { @@ -1547,8 +1537,8 @@ void iron_g4_begin(image_t *render_target, any_array_t *additional) { length = 8; } for (int32_t i = 1; i < length; ++i) { - image_t *img = additional->buffer[i - 1]; - kinc_g5_texture_t *art = (kinc_g5_texture_t *)img->texture_; + kinc_g5_texture_t *img = additional->buffer[i - 1]; + kinc_g5_texture_t *art = (kinc_g5_texture_t *)img; render_targets[i] = art; } } @@ -2277,13 +2267,13 @@ void iron_raytrace_as_build(kinc_g4_vertex_buffer_t *vb_full, kinc_g5_index_buff kinc_g5_raytrace_acceleration_structure_build(&accel, &commandList, &vb_full->impl._buffer, ib_full); } -void iron_raytrace_set_textures(image_t *tex0, image_t *tex1, image_t *tex2, kinc_g5_texture_t *texenv, kinc_g5_texture_t *texsobol, kinc_g5_texture_t *texscramble, kinc_g5_texture_t *texrank) { +void iron_raytrace_set_textures(kinc_g5_texture_t *tex0, kinc_g5_texture_t *tex1, kinc_g5_texture_t *tex2, kinc_g5_texture_t *texenv, kinc_g5_texture_t *texsobol, kinc_g5_texture_t *texscramble, kinc_g5_texture_t *texrank) { kinc_g5_texture_t *texpaint0; kinc_g5_texture_t *texpaint1; kinc_g5_texture_t *texpaint2; - // image_t *texpaint0_image = tex0; - // kinc_g5_texture_t *texpaint0_tex = texpaint0_image->texture_; + // kinc_g5_texture_t *texpaint0_image = tex0; + // kinc_g5_texture_t *texpaint0_tex = texpaint0_image; // kinc_g5_texture_t *texpaint0_rt = texpaint0_image->render_target_; // if (texpaint0_tex != NULL) { @@ -2304,8 +2294,8 @@ void iron_raytrace_set_textures(image_t *tex0, image_t *tex1, image_t *tex2, kin // texpaint0 = texpaint0_rt; // } - // image_t *texpaint1_image = tex1; - // kinc_g5_texture_t *texpaint1_tex = texpaint1_image->texture_; + // kinc_g5_texture_t *texpaint1_image = tex1; + // kinc_g5_texture_t *texpaint1_tex = texpaint1_image; // kinc_g5_texture_t *texpaint1_rt = texpaint1_image->render_target_; // if (texpaint1_tex != NULL) { @@ -2326,8 +2316,8 @@ void iron_raytrace_set_textures(image_t *tex0, image_t *tex1, image_t *tex2, kin // texpaint1 = texpaint1_rt; // } - // image_t *texpaint2_image = tex2; - // kinc_g5_texture_t *texpaint2_tex = texpaint2_image->texture_; + // kinc_g5_texture_t *texpaint2_image = tex2; + // kinc_g5_texture_t *texpaint2_tex = texpaint2_image; // kinc_g5_texture_t *texpaint2_rt = texpaint2_image->render_target_; // if (texpaint2_tex != NULL) { @@ -2348,9 +2338,9 @@ void iron_raytrace_set_textures(image_t *tex0, image_t *tex1, image_t *tex2, kin // texpaint2 = texpaint2_rt; // } - texpaint0 = tex0->texture_; - texpaint1 = tex1->texture_; - texpaint2 = tex2->texture_; + texpaint0 = tex0; + texpaint1 = tex1; + texpaint2 = tex2; if (!texenv->_uploaded) { kinc_g5_command_list_upload_texture(&commandList, texenv); diff --git a/base/sources/iron_draw.c b/base/sources/iron_draw.c index 5f66e2fd..e59c8747 100644 --- a/base/sources/iron_draw.c +++ b/base/sources/iron_draw.c @@ -377,23 +377,22 @@ void draw_texture(kinc_g5_texture_t *tex, float x, float y) { draw_scaled_sub_texture(tex, 0, 0, (float)tex->width, (float)tex->height, x, y, (float)tex->width, (float)tex->height); } -void draw_scaled_sub_image(image_t *image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { +void draw_scaled_sub_image(kinc_g5_texture_t *image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { #ifdef KINC_DIRECT3D12 waitAfterNextDraw = true; #endif - kinc_g5_texture_t *texture = (kinc_g5_texture_t *)image->texture_; - draw_scaled_sub_texture(texture, sx, sy, sw, sh, dx, dy, dw, dh); + draw_scaled_sub_texture(image, sx, sy, sw, sh, dx, dy, dw, dh); } -void draw_scaled_image(image_t *tex, float dx, float dy, float dw, float dh) { +void draw_scaled_image(kinc_g5_texture_t *tex, float dx, float dy, float dw, float dh) { draw_scaled_sub_image(tex, 0, 0, (float)tex->width, (float)tex->height, dx, dy, dw, dh); } -void draw_sub_image(image_t *tex, float sx, float sy, float sw, float sh, float x, float y) { +void draw_sub_image(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y) { draw_scaled_sub_image(tex, sx, sy, sw, sh, x, y, sw, sh); } -void draw_image(image_t *tex, float x, float y) { +void draw_image(kinc_g5_texture_t *tex, float x, float y) { draw_scaled_sub_image(tex, 0, 0, (float)tex->width, (float)tex->height, x, y, (float)tex->width, (float)tex->height); } diff --git a/base/sources/iron_draw.h b/base/sources/iron_draw.h index 161068a7..60f207cd 100644 --- a/base/sources/iron_draw.h +++ b/base/sources/iron_draw.h @@ -11,13 +11,6 @@ #include #include "iron_array.h" -typedef struct image { - void *texture_; - int format; // tex_format_t; - int width; - int height; -} image_t; - typedef struct draw_font_image draw_font_image_t; typedef struct draw_font { @@ -34,11 +27,11 @@ typedef struct draw_font { void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_vert, buffer_t *colored_frag, buffer_t *text_vert, buffer_t *text_frag); void draw_begin(void); -void draw_scaled_sub_image(image_t *img, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); +void draw_scaled_sub_image(kinc_g5_texture_t *img, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); void draw_scaled_sub_texture(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); -void draw_scaled_image(image_t *tex, float dx, float dy, float dw, float dh); -void draw_sub_image(image_t *tex, float sx, float sy, float sw, float sh, float x, float y); -void draw_image(image_t *tex, float x, float y); +void draw_scaled_image(kinc_g5_texture_t *tex, float dx, float dy, float dw, float dh); +void draw_sub_image(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); +void draw_image(kinc_g5_texture_t *tex, float x, float y); void draw_scaled_texture(kinc_g5_texture_t *tex, float dx, float dy, float dw, float dh); void draw_sub_texture(kinc_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); void draw_texture(kinc_g5_texture_t *tex, float x, float y); diff --git a/base/sources/iron_gpu.h b/base/sources/iron_gpu.h index 3f8512d3..27a0be91 100644 --- a/base/sources/iron_gpu.h +++ b/base/sources/iron_gpu.h @@ -186,8 +186,6 @@ void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kin void kinc_g5_texture_init_from_bytes(kinc_g5_texture_t *texture, void *data, int width, int height, kinc_image_format_t format); void kinc_g5_texture_init_non_sampled_access(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format); void kinc_g5_texture_destroy(kinc_g5_texture_t *texture); -uint8_t *kinc_g5_texture_lock(kinc_g5_texture_t *texture); -void kinc_g5_texture_unlock(kinc_g5_texture_t *texture); void kinc_g5_texture_generate_mipmaps(kinc_g5_texture_t *texture, int levels); void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_g5_texture_t *mipmap, int level); int kinc_g5_texture_stride(kinc_g5_texture_t *texture); diff --git a/base/sources/ts/base.ts b/base/sources/ts/base.ts index 0e1a38a4..c296fa33 100644 --- a/base/sources/ts/base.ts +++ b/base/sources/ts/base.ts @@ -5,7 +5,7 @@ let base_is_resizing: bool = false; let base_drag_asset: asset_t = null; let base_drag_swatch: swatch_color_t = null; let base_drag_file: string = null; -let base_drag_file_icon: image_t = null; +let base_drag_file_icon: kinc_g5_texture_t = null; let base_drag_tint: i32 = 0xffffffff; let base_drag_size: i32 = -1; let base_drag_rect: rect_t = null; @@ -16,8 +16,8 @@ let base_drop_x: f32 = 0.0; let base_drop_y: f32 = 0.0; let base_font: draw_font_t = null; let base_theme: ui_theme_t; -let base_color_wheel: image_t; -let base_color_wheel_gradient: image_t; +let base_color_wheel: kinc_g5_texture_t; +let base_color_wheel_gradient: kinc_g5_texture_t; let base_ui_box: ui_t; let base_ui_menu: ui_t; let base_default_element_w: i32 = 100; @@ -70,8 +70,8 @@ function base_init() { iron_set_save_and_quit_callback(base_save_and_quit_callback); let font: draw_font_t = data_get_font("font.ttf"); - let image_color_wheel: image_t = data_get_image("color_wheel.k"); - let image_color_wheel_gradient: image_t = data_get_image("color_wheel_gradient.k"); + let image_color_wheel: kinc_g5_texture_t = data_get_image("color_wheel.k"); + let image_color_wheel_gradient: kinc_g5_texture_t = data_get_image("color_wheel_gradient.k"); base_font = font; config_load_theme(config_raw.theme, false); @@ -100,8 +100,8 @@ function base_init() { theme: base_theme, font: font, scale_factor: config_raw.window_scale, - color_wheel: base_color_wheel.texture_, - black_white_gradient: base_color_wheel_gradient.texture_ + color_wheel: base_color_wheel, + black_white_gradient: base_color_wheel_gradient }; base_ui_box = ui_create(ops); base_ui_menu = ui_create(ops); @@ -367,7 +367,7 @@ function base_update() { } else if (context_in_viewport()) { if (ends_with(to_lower_case(base_drag_asset.file), ".hdr")) { - let image: image_t = project_get_image(base_drag_asset); + let image: kinc_g5_texture_t = project_get_image(base_drag_asset); import_envmap_run(base_drag_asset.file, image); } } @@ -504,14 +504,14 @@ function base_handle_drop_paths() { } function base_get_drag_background(): rect_t { - let icons: image_t = resource_get("icons.k"); + let icons: kinc_g5_texture_t = resource_get("icons.k"); if (base_drag_layer != null && !slot_layer_is_group(base_drag_layer) && base_drag_layer.fill_layer == null) { return resource_tile50(icons, 4, 1); } return null; } -function base_get_drag_image(): image_t { +function base_get_drag_image(): kinc_g5_texture_t { base_drag_tint = 0xffffffff; base_drag_size = -1; base_drag_rect = null; @@ -527,7 +527,7 @@ function base_get_drag_image(): image_t { if (base_drag_file_icon != null) { return base_drag_file_icon; } - let icons: image_t = resource_get("icons.k"); + let icons: kinc_g5_texture_t = resource_get("icons.k"); base_drag_rect = string_index_of(base_drag_file, ".") > 0 ? resource_tile50(icons, 3, 1) : resource_tile50(icons, 2, 1); base_drag_tint = ui_base_ui.ops.theme.HIGHLIGHT_COL; return icons; @@ -537,7 +537,7 @@ function base_get_drag_image(): image_t { return base_drag_material.image_icon; } if (base_drag_layer != null && slot_layer_is_group(base_drag_layer)) { - let icons: image_t = resource_get("icons.k"); + let icons: kinc_g5_texture_t = resource_get("icons.k"); let folder_closed: rect_t = resource_tile50(icons, 2, 1); let folder_open: rect_t = resource_tile50(icons, 8, 1); base_drag_rect = base_drag_layer.show_panel ? folder_open : folder_closed; @@ -585,7 +585,7 @@ function base_render() { if (base_is_dragging) { iron_set_mouse_cursor(1); // Hand - let img: image_t = base_get_drag_image(); + let img: kinc_g5_texture_t = base_get_drag_image(); let scale_factor: f32 = ui_SCALE(ui_base_ui); let size: f32 = (base_drag_size == -1 ? 50 : base_drag_size) * scale_factor; let ratio: f32 = size / img.width; diff --git a/base/sources/ts/box_preferences.ts b/base/sources/ts/box_preferences.ts index 47845296..0a0ff648 100644 --- a/base/sources/ts/box_preferences.ts +++ b/base/sources/ts/box_preferences.ts @@ -325,7 +325,7 @@ function box_preferences_show() { config_raw.undo_steps = math_floor(context_raw.undo_handle.value = 1); } if (context_raw.undo_handle.changed) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; g2_end(); if (history_undo_layers != null) { diff --git a/base/sources/ts/box_projects.ts b/base/sources/ts/box_projects.ts index 7e1419c0..9583c296 100644 --- a/base/sources/ts/box_projects.ts +++ b/base/sources/ts/box_projects.ts @@ -1,7 +1,7 @@ let box_projects_htab: ui_handle_t = ui_handle_create(); let box_projects_hsearch: ui_handle_t = ui_handle_create(); -let box_projects_icon_map: map_t = null; +let box_projects_icon_map: map_t = null; let _box_projects_path: string; let _box_projects_icon_path: string; @@ -113,9 +113,9 @@ function box_projects_tab(ui: ui_t) { if (box_projects_icon_map == null) { box_projects_icon_map = map_create(); } - let icon: image_t = map_get(box_projects_icon_map, icon_path); + let icon: kinc_g5_texture_t = map_get(box_projects_icon_map, icon_path); if (icon == null) { - let image: image_t = data_get_image(icon_path); + let image: kinc_g5_texture_t = data_get_image(icon_path); icon = image; map_set(box_projects_icon_map, icon_path, icon); } @@ -209,7 +209,7 @@ function box_projects_recent_tab(ui: ui_t) { } if (ui_button(file, ui_align_t.LEFT) && file_exists(path)) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -241,7 +241,7 @@ function box_projects_recent_tab(ui: ui_t) { } function box_projects_draw_badge(ui: ui_t) { - let img: image_t = data_get_image("badge.k"); + let img: kinc_g5_texture_t = data_get_image("badge.k"); _ui_image(img); _ui_end_element(); } diff --git a/base/sources/ts/config.ts b/base/sources/ts/config.ts index a3f2c5e8..054c2daa 100644 --- a/base/sources/ts/config.ts +++ b/base/sources/ts/config.ts @@ -253,7 +253,7 @@ function config_apply() { config_save(); context_raw.ddirty = 2; - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); render_path_base_apply_config(); diff --git a/base/sources/ts/context.ts b/base/sources/ts/context.ts index 79f9d77c..bb33e740 100644 --- a/base/sources/ts/context.ts +++ b/base/sources/ts/context.ts @@ -20,11 +20,11 @@ type context_t = { color_picker_callback?: (sc: swatch_color_t)=>void; default_irradiance?: f32_array_t; - default_radiance?: image_t; - default_radiance_mipmaps?: image_t[]; - saved_envmap?: image_t; - empty_envmap?: image_t; - preview_envmap?: image_t; + default_radiance?: kinc_g5_texture_t; + default_radiance_mipmaps?: kinc_g5_texture_t[]; + saved_envmap?: kinc_g5_texture_t; + empty_envmap?: kinc_g5_texture_t; + preview_envmap?: kinc_g5_texture_t; envmap_loaded?: bool; show_envmap?: bool; show_envmap_handle?: ui_handle_t; @@ -105,11 +105,11 @@ type context_t = { layer_preview_dirty?: bool; layers_preview_dirty?: bool; node_preview_dirty?: bool; - node_preview?: image_t; - node_previews?: map_t; + node_preview?: kinc_g5_texture_t; + node_previews?: map_t; node_previews_used?: string[]; node_preview_name?: string; - mask_preview_rgba32?: image_t; + mask_preview_rgba32?: kinc_g5_texture_t; mask_preview_last?: slot_layer_t; colorid_picked?: bool; @@ -138,7 +138,7 @@ type context_t = { colorid_handle?: ui_handle_t; layers_export?: export_mode_t; - decal_image?: image_t; + decal_image?: kinc_g5_texture_t; decal_preview?: bool; decal_x?: f32; decal_y?: f32; @@ -146,7 +146,7 @@ type context_t = { cache_draws?: bool; write_icon_on_export?: bool; - text_tool_image?: image_t; + text_tool_image?: kinc_g5_texture_t; text_tool_text?: string; particle_material?: material_data_t; @@ -181,9 +181,9 @@ type context_t = { brush_nodes_radius?: f32; brush_nodes_opacity?: f32; - brush_mask_image?: image_t; + brush_mask_image?: kinc_g5_texture_t; brush_mask_image_is_alpha?: bool; - brush_stencil_image?: image_t; + brush_stencil_image?: kinc_g5_texture_t; brush_stencil_image_is_alpha?: bool; brush_stencil_x?: f32; brush_stencil_y?: f32; @@ -543,7 +543,7 @@ function context_set_layer(l: slot_layer_t) { context_raw.layer = l; ui_header_handle.redraws = 2; - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); diff --git a/base/sources/ts/export_arm.ts b/base/sources/ts/export_arm.ts index cf1b5cb3..f23eb2cd 100644 --- a/base/sources/ts/export_arm.ts +++ b/base/sources/ts/export_arm.ts @@ -87,7 +87,7 @@ function export_arm_run_project() { name: l.name, res: l.texpaint != null ? l.texpaint.width : project_layers[0].texpaint.width, bpp: bpp, - texpaint: l.texpaint != null ? lz4_encode(image_get_pixels(l.texpaint)) : null, + texpaint: l.texpaint != null ? lz4_encode(iron_g4_get_texture_pixels(l.texpaint)) : null, uv_scale: l.scale, uv_rot: l.angle, uv_type: l.uv_type, @@ -99,8 +99,8 @@ function export_arm_run_project() { parent: l.parent != null ? array_index_of(project_layers, l.parent) : -1, visible: l.visible, ///if is_paint - texpaint_nor: l.texpaint_nor != null ? lz4_encode(image_get_pixels(l.texpaint_nor)) : null, - texpaint_pack: l.texpaint_pack != null ? lz4_encode(image_get_pixels(l.texpaint_pack)) : null, + texpaint_nor: l.texpaint_nor != null ? lz4_encode(iron_g4_get_texture_pixels(l.texpaint_nor)) : null, + texpaint_pack: l.texpaint_pack != null ? lz4_encode(iron_g4_get_texture_pixels(l.texpaint_pack)) : null, paint_base: l.paint_base, paint_opac: l.paint_opac, paint_occ: l.paint_occ, @@ -174,8 +174,8 @@ function export_arm_run_project() { ///if (arm_android || arm_ios) let rt: render_target_t = map_get(render_path_render_targets, context_raw.render_mode == render_mode_t.FORWARD ? "buf" : "tex"); - let tex: image_t = rt._image; - let mesh_icon: image_t = image_create_render_target(256, 256); + let tex: kinc_g5_texture_t = rt._image; + let mesh_icon: kinc_g5_texture_t = iron_g4_create_render_target(256, 256); let r: f32 = app_w() / app_h(); g2_begin(mesh_icon); draw_scaled_image(tex, -(256 * r - 256) / 2, 0, 256 * r, 256); @@ -187,7 +187,7 @@ function export_arm_run_project() { g2_end(); ///end - let mesh_icon_pixels: buffer_t = image_get_pixels(mesh_icon); + let mesh_icon_pixels: buffer_t = iron_g4_get_texture_pixels(mesh_icon); let u8a: u8_array_t = mesh_icon_pixels; for (let i: i32 = 0; i < 256 * 256 * 4; ++i) { u8a[i] = math_floor(math_pow(u8a[i] / 255, 1.0 / 2.2) * 255); @@ -196,8 +196,8 @@ function export_arm_run_project() { export_arm_bgra_swap(mesh_icon_pixels); ///end - app_notify_on_next_frame(function (mesh_icon: image_t) { - image_unload(mesh_icon); + app_notify_on_next_frame(function (mesh_icon: kinc_g5_texture_t) { + iron_unload_image(mesh_icon); }); // raw.mesh_icons = @@ -298,9 +298,9 @@ function export_arm_run_material(path: string) { let micons: buffer_t[] = null; if (!is_cloud) { ///if (arm_metal || arm_vulkan) - let buf: buffer_t = lz4_encode(export_arm_bgra_swap(image_get_pixels(m.image))); + let buf: buffer_t = lz4_encode(export_arm_bgra_swap(iron_g4_get_texture_pixels(m.image))); ///else - let buf: buffer_t = lz4_encode(image_get_pixels(m.image)); + let buf: buffer_t = lz4_encode(iron_g4_get_texture_pixels(m.image)); ///end micons = [buf]; } @@ -315,9 +315,9 @@ function export_arm_run_material(path: string) { }; if (context_raw.write_icon_on_export) { // Separate icon files - iron_write_png(substring(path, 0, path.length - 4) + "_icon.png", image_get_pixels(m.image), m.image.width, m.image.height, 0); + iron_write_png(substring(path, 0, path.length - 4) + "_icon.png", iron_g4_get_texture_pixels(m.image), m.image.width, m.image.height, 0); if (is_cloud) { - iron_write_jpg(substring(path, 0, path.length - 4) + "_icon.jpg", image_get_pixels(m.image), m.image.width, m.image.height, 0, 50); + iron_write_jpg(substring(path, 0, path.length - 4) + "_icon.jpg", iron_g4_get_texture_pixels(m.image), m.image.width, m.image.height, 0, 50); } } @@ -365,9 +365,9 @@ function export_arm_run_brush(path: string) { let bicons: buffer_t[] = null; if (!is_cloud) { ///if (arm_metal || arm_vulkan) - let buf: buffer_t = lz4_encode(export_arm_bgra_swap(image_get_pixels(b.image))); + let buf: buffer_t = lz4_encode(export_arm_bgra_swap(iron_g4_get_texture_pixels(b.image))); ///else - let buf: buffer_t = lz4_encode(image_get_pixels(b.image)); + let buf: buffer_t = lz4_encode(iron_g4_get_texture_pixels(b.image)); ///end bicons = [buf]; } @@ -381,7 +381,7 @@ function export_arm_run_brush(path: string) { }; if (context_raw.write_icon_on_export) { // Separate icon file - iron_write_png(substring(path, 0, path.length - 4) + "_icon.png", image_get_pixels(b.image), b.image.width, b.image.height, 0); + iron_write_png(substring(path, 0, path.length - 4) + "_icon.png", iron_g4_get_texture_pixels(b.image), b.image.width, b.image.height, 0); } if (context_raw.pack_assets_on_export) { // Pack textures @@ -483,11 +483,11 @@ function export_arm_pack_assets(raw: project_format_t, assets: asset_t[]) { if (raw.packed_assets == null) { raw.packed_assets = []; } - let temp_images: image_t[] = []; + let temp_images: kinc_g5_texture_t[] = []; for (let i: i32 = 0; i < assets.length; ++i) { if (!project_packed_asset_exists(raw.packed_assets, assets[i].file)) { - let image: image_t = project_get_image(assets[i]); - let temp: image_t = image_create_render_target(image.width, image.height); + let image: kinc_g5_texture_t = project_get_image(assets[i]); + let temp: kinc_g5_texture_t = iron_g4_create_render_target(image.width, image.height); g2_begin(temp); draw_image(image, 0, 0); g2_end(); @@ -495,16 +495,16 @@ function export_arm_pack_assets(raw: project_format_t, assets: asset_t[]) { let pa: packed_asset_t = { name: assets[i].file, bytes: ends_with(assets[i].file, ".jpg") ? - iron_encode_jpg(image_get_pixels(temp), temp.width, temp.height, 0, 80) : - iron_encode_png(image_get_pixels(temp), temp.width, temp.height, 0) + iron_encode_jpg(iron_g4_get_texture_pixels(temp), temp.width, temp.height, 0, 80) : + iron_encode_png(iron_g4_get_texture_pixels(temp), temp.width, temp.height, 0) }; array_push(raw.packed_assets, pa); } } - app_notify_on_next_frame(function (temp_images: image_t[]) { + app_notify_on_next_frame(function (temp_images: kinc_g5_texture_t[]) { for (let i: i32 = 0; i < temp_images.length; ++i) { - let image: image_t = temp_images[i]; - image_unload(image); + let image: kinc_g5_texture_t = temp_images[i]; + iron_unload_image(image); } }, temp_images); } diff --git a/base/sources/ts/export_obj.ts b/base/sources/ts/export_obj.ts index 59d39e56..aaef0758 100644 --- a/base/sources/ts/export_obj.ts +++ b/base/sources/ts/export_obj.ts @@ -88,7 +88,7 @@ function export_obj_run(path: string, paint_objects: mesh_object_t[], apply_disp } if (apply_disp) { - // let height: buffer_t = image_get_pixels(layers[0].texpaint_pack); + // let height: buffer_t = iron_g4_get_texture_pixels(layers[0].texpaint_pack); // let res: i32 = layers[0].texpaint_pack.width; // let strength: f32 = 0.1; // for (let i: i32 = 0; i < len; ++i) { diff --git a/base/sources/ts/export_texture.ts b/base/sources/ts/export_texture.ts index 68daf039..745953c6 100644 --- a/base/sources/ts/export_texture.ts +++ b/base/sources/ts/export_texture.ts @@ -178,7 +178,7 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ layers_make_temp_img(); layers_make_export_img(); let rt: render_target_t = map_get(render_path_render_targets, "empty_white"); - let empty: image_t = rt._image; + let empty: kinc_g5_texture_t = rt._image; // Append object mask name let export_selected: bool = context_raw.layers_export == export_mode_t.SELECTED; @@ -220,7 +220,7 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ } } - let mask: image_t = empty; + let mask: kinc_g5_texture_t = empty; let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); if (l1masks != null && !bake_material) { if (l1masks.length > 1) { @@ -250,10 +250,10 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ iron_g4_begin(layers_expa); kinc_g5_set_pipeline(pipes_merge); - g4_set_tex(pipes_tex0, l1.texpaint); - g4_set_tex(pipes_tex1, empty); - g4_set_tex(pipes_texmask, mask); - g4_set_tex(pipes_texa, layers_temp_image); + iron_g4_set_texture(pipes_tex0, l1.texpaint); + iron_g4_set_texture(pipes_tex1, empty); + iron_g4_set_texture(pipes_texmask, mask); + iron_g4_set_texture(pipes_texa, layers_temp_image); iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); iron_g4_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); @@ -271,10 +271,10 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ iron_g4_begin(layers_expb); kinc_g5_set_pipeline(pipes_merge); - g4_set_tex(pipes_tex0, l1.texpaint); - g4_set_tex(pipes_tex1, l1.texpaint_nor); - g4_set_tex(pipes_texmask, mask); - g4_set_tex(pipes_texa, layers_temp_image); + iron_g4_set_texture(pipes_tex0, l1.texpaint); + iron_g4_set_texture(pipes_tex1, l1.texpaint_nor); + iron_g4_set_texture(pipes_texmask, mask); + iron_g4_set_texture(pipes_texa, layers_temp_image); iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); iron_g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); @@ -312,9 +312,9 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ ///end ///end - let texpaint: image_t = layers_expa; - let texpaint_nor: image_t = layers_expb; - let texpaint_pack: image_t = layers_expc; + let texpaint: kinc_g5_texture_t = layers_expa; + let texpaint_nor: kinc_g5_texture_t = layers_expb; + let texpaint_pack: kinc_g5_texture_t = layers_expc; ///if is_lab texpaint = context_raw.brush_output_node_inst.texpaint; @@ -333,13 +333,13 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ for (let i: i32 = 0; i < t.channels.length; ++i) { let c: string = t.channels[i]; if ((c == "base_r" || c == "base_g" || c == "base_b" || c == "opac") && pixpaint == null) { - pixpaint = image_get_pixels(texpaint); + pixpaint = iron_g4_get_texture_pixels(texpaint); } else if ((c == "nor_r" || c == "nor_g" || c == "nor_g_directx" || c == "nor_b" || c == "emis" || c == "subs") && pixpaint_nor == null) { - pixpaint_nor = image_get_pixels(texpaint_nor); + pixpaint_nor = iron_g4_get_texture_pixels(texpaint_nor); } else if ((c == "occ" || c == "rough" || c == "metal" || c == "height" || c == "smooth") && pixpaint_pack == null) { - pixpaint_pack = image_get_pixels(texpaint_pack); + pixpaint_pack = iron_g4_get_texture_pixels(texpaint_pack); } } } @@ -435,7 +435,7 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ } } - // Release staging memory allocated in image_get_pixels() + // Release staging memory allocated in iron_g4_get_texture_pixels() // texpaint.pixels = null; // texpaint_nor.pixels = null; // texpaint_pack.pixels = null; @@ -464,7 +464,7 @@ function export_texture_write_texture(file: string, pixels: buffer_t, type: i32 } if (context_raw.layers_destination == export_destination_t.PACKED) { - let image: image_t = image_from_bytes(pixels, res_x, res_y); + let image: kinc_g5_texture_t = image_from_bytes(pixels, res_x, res_y); map_set(data_cached_images, file, image); let ar: string[] = string_split(file, path_sep); let name: string = ar[ar.length - 1]; diff --git a/base/sources/ts/import_arm.ts b/base/sources/ts/import_arm.ts index 4d837fa0..39cef31a 100644 --- a/base/sources/ts/import_arm.ts +++ b/base/sources/ts/import_arm.ts @@ -186,7 +186,7 @@ function import_arm_run_project(path: string) { context_raw.merged_object.base.visible = true; ///if (is_paint || is_sculpt) - let tex: image_t = project_layers[0].texpaint; + let tex: kinc_g5_texture_t = project_layers[0].texpaint; if (tex.width != config_get_texture_res_x() || tex.height != config_get_texture_res_y()) { if (history_undo_layers != null) { for (let i: i32 = 0; i < history_undo_layers.length; ++i) { @@ -196,21 +196,21 @@ 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: image_t = blend0._image; - app_notify_on_next_frame(function (_texpaint_blend0: image_t) { - image_unload(_texpaint_blend0); + let _texpaint_blend0: kinc_g5_texture_t = blend0._image; + app_notify_on_next_frame(function (_texpaint_blend0: kinc_g5_texture_t) { + iron_unload_image(_texpaint_blend0); }, _texpaint_blend0); blend0.width = config_get_texture_res_x(); blend0.height = config_get_texture_res_y(); - blend0._image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8, 0); + blend0._image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8, 0); let blend1: render_target_t = map_get(rts, "texpaint_blend1"); - let _texpaint_blend1: image_t = blend1._image; - app_notify_on_next_frame(function (_texpaint_blend1: image_t) { - image_unload(_texpaint_blend1); + let _texpaint_blend1: kinc_g5_texture_t = blend1._image; + app_notify_on_next_frame(function (_texpaint_blend1: kinc_g5_texture_t) { + iron_unload_image(_texpaint_blend1); }, _texpaint_blend1); blend1.width = config_get_texture_res_x(); blend1.height = config_get_texture_res_y(); - blend1._image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8, 0); + blend1._image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8, 0); context_raw.brush_blend_dirty = true; } @@ -238,9 +238,9 @@ function import_arm_run_project(path: string) { array_push(project_layers, l); if (!is_group) { - let _texpaint: image_t = null; - let _texpaint_nor: image_t = null; - let _texpaint_pack: image_t = null; + let _texpaint: kinc_g5_texture_t = null; + let _texpaint_nor: kinc_g5_texture_t = null; + let _texpaint_pack: kinc_g5_texture_t = null; if (is_mask) { _texpaint = image_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4), ld.res, ld.res, tex_format_t.RGBA32); @@ -301,19 +301,19 @@ function import_arm_run_project(path: string) { l.paint_subs = ld.paint_subs; ///end - app_notify_on_next_frame(function (_texpaint: image_t) { - image_unload(_texpaint); + app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + iron_unload_image(_texpaint); }, _texpaint); ///if is_paint if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: image_t) { - image_unload(_texpaint_nor); + app_notify_on_next_frame(function (_texpaint_nor: kinc_g5_texture_t) { + iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: image_t) { - image_unload(_texpaint_pack); + app_notify_on_next_frame(function (_texpaint_pack: kinc_g5_texture_t) { + iron_unload_image(_texpaint_pack); }, _texpaint_pack); } ///end @@ -633,7 +633,7 @@ function import_arm_make_pink(abs: string) { b[1] = 0; b[2] = 255; b[3] = 255; - let pink: image_t = image_from_bytes(b, 1, 1); + let pink: kinc_g5_texture_t = image_from_bytes(b, 1, 1); map_set(data_cached_images, abs, pink); } @@ -674,7 +674,7 @@ function import_arm_unpack_asset(project: project_format_t, abs: string, file: s if (!project_packed_asset_exists(project_raw.packed_assets, pa.name)) { array_push(project_raw.packed_assets, pa); } - let image: image_t = image_from_encoded_bytes(pa.bytes, ends_with(pa.name, ".jpg") ? ".jpg" : ".png"); + let image: kinc_g5_texture_t = image_from_encoded_bytes(pa.bytes, ends_with(pa.name, ".jpg") ? ".jpg" : ".png"); map_set(data_cached_images, abs, image); break; } diff --git a/base/sources/ts/import_blend_material.ts b/base/sources/ts/import_blend_material.ts index e1f9a174..0e81c346 100644 --- a/base/sources/ts/import_blend_material.ts +++ b/base/sources/ts/import_blend_material.ts @@ -30,7 +30,7 @@ function import_blend_material_run(path: string) { function _import_blend_material() { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); diff --git a/base/sources/ts/import_envmap.ts b/base/sources/ts/import_envmap.ts index 929dd636..6bcc03b7 100644 --- a/base/sources/ts/import_envmap.ts +++ b/base/sources/ts/import_envmap.ts @@ -4,12 +4,12 @@ let import_envmap_params_loc: kinc_const_loc_t; let import_envmap_params: vec4_t = vec4_create(); let import_envmap_n: vec4_t = vec4_create(); let import_envmap_radiance_loc: kinc_tex_unit_t; -let import_envmap_radiance: image_t = null; -let import_envmap_radiance_cpu: image_t = null; -let import_envmap_mips: image_t[] = null; -let import_envmap_mips_cpu: image_t[] = null; +let import_envmap_radiance: kinc_g5_texture_t = null; +let import_envmap_radiance_cpu: kinc_g5_texture_t = null; +let import_envmap_mips: kinc_g5_texture_t[] = null; +let import_envmap_mips_cpu: kinc_g5_texture_t[] = null; -function import_envmap_run(path: string, image: image_t) { +function import_envmap_run(path: string, image: kinc_g5_texture_t) { // Init if (import_envmap_pipeline == null) { import_envmap_pipeline = iron_g4_create_pipeline(); @@ -24,12 +24,12 @@ function import_envmap_run(path: string, image: image_t) { import_envmap_params_loc = iron_g4_get_constant_location(import_envmap_pipeline, "params"); import_envmap_radiance_loc = iron_g4_get_texture_unit(import_envmap_pipeline, "radiance"); - import_envmap_radiance = image_create_render_target(1024, 512, tex_format_t.RGBA128); + import_envmap_radiance = iron_g4_create_render_target(1024, 512, tex_format_t.RGBA128); import_envmap_mips = []; let w: i32 = 512; for (let i: i32 = 0; i < 10; ++i) { - array_push(import_envmap_mips, image_create_render_target(w, w > 1 ? math_floor(w / 2) : 1, tex_format_t.RGBA128)); + array_push(import_envmap_mips, iron_g4_create_render_target(w, w > 1 ? math_floor(w / 2) : 1, tex_format_t.RGBA128)); w = math_floor(w / 2); } } @@ -41,11 +41,11 @@ function import_envmap_run(path: string, image: image_t) { draw_set_pipeline(null); g2_end(); - let radiance_pixels: buffer_t = image_get_pixels(import_envmap_radiance); + let radiance_pixels: buffer_t = iron_g4_get_texture_pixels(import_envmap_radiance); if (import_envmap_radiance_cpu != null) { - let _radiance_cpu: image_t = import_envmap_radiance_cpu; - app_notify_on_next_frame(function (_radiance_cpu: image_t) { - image_unload(_radiance_cpu); + let _radiance_cpu: kinc_g5_texture_t = import_envmap_radiance_cpu; + app_notify_on_next_frame(function (_radiance_cpu: kinc_g5_texture_t) { + iron_unload_image(_radiance_cpu); }, _radiance_cpu); } import_envmap_radiance_cpu = image_from_bytes(radiance_pixels, import_envmap_radiance.width, import_envmap_radiance.height, tex_format_t.RGBA128); @@ -53,10 +53,10 @@ function import_envmap_run(path: string, image: image_t) { // Radiance if (import_envmap_mips_cpu != null) { for (let i: i32 = 0; i < import_envmap_mips_cpu.length; ++i) { - let mip: image_t = import_envmap_mips_cpu[i]; - app_notify_on_next_frame(function (mip: image_t) { + let mip: kinc_g5_texture_t = import_envmap_mips_cpu[i]; + app_notify_on_next_frame(function (mip: kinc_g5_texture_t) { ///if (!arm_direct3d12) // TODO: crashes after 50+ imports - image_unload(mip); + iron_unload_image(mip); ///end }, mip); } @@ -64,9 +64,9 @@ function import_envmap_run(path: string, image: image_t) { import_envmap_mips_cpu = []; for (let i: i32 = 0; i < import_envmap_mips.length; ++i) { import_envmap_get_radiance_mip(import_envmap_mips[i], i, import_envmap_radiance); - array_push(import_envmap_mips_cpu, image_from_bytes(image_get_pixels(import_envmap_mips[i]), import_envmap_mips[i].width, import_envmap_mips[i].height, tex_format_t.RGBA128)); + array_push(import_envmap_mips_cpu, image_from_bytes(iron_g4_get_texture_pixels(import_envmap_mips[i]), import_envmap_mips[i].width, import_envmap_mips[i].height, tex_format_t.RGBA128)); } - image_set_mipmaps(import_envmap_radiance_cpu, import_envmap_mips_cpu); + iron_g4_set_mipmaps(import_envmap_radiance_cpu, import_envmap_mips_cpu); // Irradiance scene_world._.irradiance = import_envmap_get_spherical_harmonics(radiance_pixels, import_envmap_radiance.width, import_envmap_radiance.height); @@ -86,14 +86,14 @@ function import_envmap_run(path: string, image: image_t) { project_raw.envmap = path; } -function import_envmap_get_radiance_mip(mip: image_t, level: i32, radiance: image_t) { +function import_envmap_get_radiance_mip(mip: kinc_g5_texture_t, level: i32, radiance: kinc_g5_texture_t) { iron_g4_begin(mip); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); kinc_g4_set_index_buffer(const_data_screen_aligned_ib); kinc_g5_set_pipeline(import_envmap_pipeline); import_envmap_params.x = 0.1 + level / 8; iron_g4_set_float4(import_envmap_params_loc, import_envmap_params.x, import_envmap_params.y, import_envmap_params.z, import_envmap_params.w); - g4_set_tex(import_envmap_radiance_loc, radiance); + iron_g4_set_texture(import_envmap_radiance_loc, radiance); g4_draw(); iron_g4_end(); } diff --git a/base/sources/ts/import_texture.ts b/base/sources/ts/import_texture.ts index 5dbfdf4c..76da6f69 100644 --- a/base/sources/ts/import_texture.ts +++ b/base/sources/ts/import_texture.ts @@ -1,7 +1,7 @@ type import_texture_data_t = { path: string; - image: image_t; + image: kinc_g5_texture_t; }; function import_texture_run(path: string, hdr_as_envmap: bool = true) { @@ -18,7 +18,7 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { if (a.file == path) { // Set as envmap if (hdr_as_envmap && ends_with(to_lower_case(path), ".hdr")) { - let image: image_t = data_get_image(path); + let image: kinc_g5_texture_t = data_get_image(path); let itd: import_texture_data_t = { path: path, image: image }; app_notify_on_next_frame(function (itd: import_texture_data_t) { // Make sure file browser process did finish import_envmap_run(itd.path, itd.image); @@ -30,9 +30,9 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { } let ext: string = substring(path, string_last_index_of(path, ".") + 1, path.length); - let importer: any = map_get(path_texture_importers, ext); // JSValue -> (s: string)=>image_t + let importer: any = map_get(path_texture_importers, ext); // JSValue -> (s: string)=>kinc_g5_texture_t let cached: bool = map_get(data_cached_images, path) != null; // Already loaded or pink texture for missing file - let image: image_t; + let image: kinc_g5_texture_t; if (importer == null || cached) { image = import_texture_default_importer(path); } @@ -62,6 +62,6 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { } } -function import_texture_default_importer(path: string): image_t { +function import_texture_default_importer(path: string): kinc_g5_texture_t { return data_get_image(path); } diff --git a/base/sources/ts/iron/data.ts b/base/sources/ts/iron/data.ts index 84b88bce..12ec052d 100644 --- a/base/sources/ts/iron/data.ts +++ b/base/sources/ts/iron/data.ts @@ -8,7 +8,7 @@ let data_cached_worlds: map_t = map_create(); let data_cached_shaders: map_t = map_create(); let data_cached_blobs: map_t = map_create(); -let data_cached_images: map_t = map_create(); +let data_cached_images: map_t = map_create(); let data_cached_videos: map_t = map_create(); let data_cached_fonts: map_t = map_create(); ///if arm_audio @@ -109,8 +109,8 @@ function data_get_blob(file: string): buffer_t { return b; } -function data_get_image(file: string, readable: bool = false): image_t { - let cached: image_t = map_get(data_cached_images, file); +function data_get_image(file: string, readable: bool = false): kinc_g5_texture_t { + let cached: kinc_g5_texture_t = map_get(data_cached_images, file); if (cached != null) { return cached; } @@ -120,7 +120,7 @@ function data_get_image(file: string, readable: bool = false): image_t { return null; } - let b: image_t = image_from_texture(image_); + let b: kinc_g5_texture_t = image_; map_set(data_cached_images, file, b); data_assets_loaded++; return b; @@ -185,11 +185,11 @@ function data_delete_blob(handle: string) { } function data_delete_image(handle: string) { - let image: image_t = map_get(data_cached_images, handle); + let image: kinc_g5_texture_t = map_get(data_cached_images, handle); if (image == null) { return; } - image_unload(image); + iron_unload_image(image); map_delete(data_cached_images, handle); } @@ -246,8 +246,8 @@ 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: image_t = map_get(data_cached_images, cached_images_keys[i]); - image_unload(c); + let c: kinc_g5_texture_t = map_get(data_cached_images, cached_images_keys[i]); + iron_unload_image(c); } data_cached_images = map_create(); diff --git a/base/sources/ts/iron/g2.ts b/base/sources/ts/iron/g2.ts index 6dded8c8..4a005702 100644 --- a/base/sources/ts/iron/g2.ts +++ b/base/sources/ts/iron/g2.ts @@ -11,7 +11,7 @@ declare type draw_font_t = { index?: i32; }; -let _g2_current: image_t = null; +let _g2_current: kinc_g5_texture_t = null; let _g2_in_use: bool = false; let _g2_font_glyphs: i32[] = _g2_make_glyphs(32, 127); let _g2_font_glyphs_last: i32[] = _g2_font_glyphs; @@ -50,7 +50,7 @@ function _g2_make_glyphs(start: i32, end: i32): i32[] { return ar; } -function g2_begin(render_target: image_t = null) { +function g2_begin(render_target: kinc_g5_texture_t = null) { if (_g2_in_use && !_g2_thrown) { _g2_thrown = true; kinc_log("End before you begin"); @@ -61,7 +61,7 @@ function g2_begin(render_target: image_t = null) { draw_begin(); if (render_target != null) { - draw_set_render_target(render_target.texture_); + draw_set_render_target(render_target); } else { draw_restore_render_target(); diff --git a/base/sources/ts/iron/g4.ts b/base/sources/ts/iron/g4.ts index fcf287bc..996302bd 100644 --- a/base/sources/ts/iron/g4.ts +++ b/base/sources/ts/iron/g4.ts @@ -45,18 +45,6 @@ function g4_vertex_struct_data_byte_size(data: vertex_data_t): i32 { return 0; } -function g4_set_tex(unit: kinc_tex_unit_t, tex: image_t) { - iron_g4_set_texture(unit, tex.texture_); -} - -function g4_set_tex_depth(unit: kinc_tex_unit_t, tex: image_t) { - iron_g4_set_texture_depth(unit, tex.texture_); -} - -function g4_set_tex_params(tex_unit: kinc_tex_unit_t, u_addressing: tex_addressing_t, v_addressing: tex_addressing_t, minification_filter: tex_filter_t, magnification_filter: tex_filter_t, mipmap_filter: mip_map_filter_t) { - iron_g4_set_texture_parameters(tex_unit, u_addressing, v_addressing, minification_filter, magnification_filter, mipmap_filter); -} - function g4_set_floats(loc: kinc_const_loc_t, values: f32_array_t) { let b: buffer_t = { buffer: values.buffer, @@ -73,92 +61,18 @@ function g4_draw(start: i32 = 0, count: i32 = -1) { iron_g4_draw_indexed_vertices(start, count); } -function _image_create(tex: any): image_t { - let raw: image_t = {}; - raw.texture_ = tex; - return raw; +function image_from_bytes(buffer: buffer_t, width: i32, height: i32, format: tex_format_t = tex_format_t.RGBA32): kinc_g5_texture_t { + return iron_g4_create_texture_from_bytes(buffer, width, height, format, true); } -function _image_set_size_from_texture(image: image_t, _tex: any) { - let tex: kinc_g5_texture_t = _tex; - image.width = tex.width; - image.height = tex.height; +function image_from_encoded_bytes(buffer: buffer_t, format: string, readable: bool = false): kinc_g5_texture_t { + return iron_g4_create_texture_from_encoded_bytes(buffer, format, readable); } -function image_from_texture(tex: any): image_t { - let image: image_t = _image_create(tex); - _image_set_size_from_texture(image, tex); - return image; +function image_create(width: i32, height: i32, format: tex_format_t = tex_format_t.RGBA32): kinc_g5_texture_t { + return iron_g4_create_texture(width, height, format); } -function image_from_bytes(buffer: buffer_t, width: i32, height: i32, format: tex_format_t = tex_format_t.RGBA32): image_t { - let readable: bool = true; - let image: image_t = _image_create(null); - image.format = format; - image.texture_ = iron_g4_create_texture_from_bytes(buffer, width, height, format, readable); - _image_set_size_from_texture(image, image.texture_); - return image; -} - -function image_from_encoded_bytes(buffer: buffer_t, format: string, readable: bool = false): image_t { - let image: image_t = _image_create(null); - image.texture_ = iron_g4_create_texture_from_encoded_bytes(buffer, format, readable); - _image_set_size_from_texture(image, image.texture_); - return image; -} - -function image_create(width: i32, height: i32, format: tex_format_t = tex_format_t.RGBA32): image_t { - let image: image_t = _image_create(null); - image.format = format; - image.texture_ = iron_g4_create_texture(width, height, format); - _image_set_size_from_texture(image, image.texture_); - return image; -} - -function image_create_render_target(width: i32, height: i32, format: tex_format_t = tex_format_t.RGBA32, depth_buffer_bits: i32 = 0): image_t { - let image: image_t = _image_create(null); - image.format = format; - image.texture_ = iron_g4_create_render_target(width, height, format, depth_buffer_bits); - _image_set_size_from_texture(image, image.texture_); - return image; -} - -function image_unload(raw: image_t) { - iron_unload_image(raw); - raw.texture_ = null; -} - -function image_lock(raw: image_t, level: i32 = 0): buffer_t { - return iron_g4_lock_texture(raw.texture_, level); -} - -function image_unlock(raw: image_t) { - kinc_g5_texture_unlock(raw.texture_); -} - -function image_get_pixels(raw: image_t): buffer_t { - return iron_g4_get_texture_pixels(raw.texture_); -} - -function image_gen_mipmaps(raw: image_t, levels: i32) { - kinc_g5_texture_generate_mipmaps(raw.texture_, levels); -} - -function image_set_mipmaps(raw: image_t, mipmaps: image_t[]) { - iron_g4_set_mipmaps(raw.texture_, mipmaps); -} - -function image_set_depth_from(raw: image_t, image: image_t) { - kinc_g5_render_target_set_depth_from(raw.texture_, image.texture_); -} - -declare type image_t = { - texture_?: any; - format?: tex_format_t; - width?: i32; - height?: i32; -}; - declare type kinc_g5_pipeline_t = { input_layout?: any; vertex_shader?: any; diff --git a/base/sources/ts/iron/iron.ts b/base/sources/ts/iron/iron.ts index d8a0c2c5..ecb5be88 100644 --- a/base/sources/ts/iron/iron.ts +++ b/base/sources/ts/iron/iron.ts @@ -230,7 +230,7 @@ declare function iron_g4_delete_pipeline(pipeline: any): void; declare function iron_g4_compile_pipeline(pipeline: any): void; declare function kinc_g5_set_pipeline(pipeline: any): void; declare function iron_load_image(file: string, readable: bool): any; -declare function iron_unload_image(image: image_t): void; +declare function iron_unload_image(image: kinc_g5_texture_t): void; declare function iron_load_sound(file: string): any; declare function kinc_a1_sound_destroy(sound: any): void; declare function kinc_a1_play_sound(sound: any, loop: bool, pitch: f32, unique: bool): audio_channel_t; @@ -274,20 +274,18 @@ declare function iron_display_y(index: i32): i32; declare function iron_display_frequency(index: i32): i32; declare function iron_display_is_primary(index: i32): bool; -declare function iron_g4_create_render_target(width: i32, height: i32, format: i32, depth_buffer_bits: i32): any; +declare function iron_g4_create_render_target(width: i32, height: i32, format: i32 = tex_format_t.RGBA32, depth_buffer_bits: i32 = 0): any; declare function iron_g4_create_texture(width: i32, height: i32, format: i32): any; declare function iron_g4_create_texture_from_bytes(data: buffer_t, width: i32, height: i32, format: i32, readable: bool): any; declare function iron_g4_create_texture_from_encoded_bytes(data: buffer_t, format: string, readable: bool): any; declare function iron_g4_get_texture_pixels(texture: any): buffer_t; -declare function iron_g4_lock_texture(texture: any, level: i32): buffer_t; -declare function kinc_g5_texture_unlock(texture: any): void; declare function kinc_g5_texture_generate_mipmaps(texture: any, levels: i32): void; -declare function iron_g4_set_mipmaps(texture: any, mipmaps: image_t[]): void; +declare function iron_g4_set_mipmaps(texture: any, mipmaps: kinc_g5_texture_t[]): void; declare function kinc_g5_render_target_set_depth_from(target: any, source: any): void; declare function kinc_g4_viewport(x: i32, y: i32, width: i32, height: i32): void; declare function kinc_g4_scissor(x: i32, y: i32, width: i32, height: i32): void; declare function kinc_g4_disable_scissor(): void; -declare function iron_g4_begin(render_target: image_t, additional: image_t[] = null): void; +declare function iron_g4_begin(render_target: kinc_g5_texture_t, additional: kinc_g5_texture_t[] = null): void; declare function iron_g4_end(): void; declare function iron_g4_swap_buffers(): void; declare function iron_file_save_bytes(path: string, bytes: buffer_t, length?: i32): void; @@ -301,10 +299,10 @@ declare function iron_http_request(url: string, size: i32, callback: (url: strin declare function draw_init(image_vert: buffer_t, image_frag: buffer_t, colored_vert: buffer_t, colored_frag: buffer_t, text_vert: buffer_t, text_frag: buffer_t): void; declare function draw_begin(): void; declare function draw_end(): void; -declare function draw_scaled_sub_image(image: image_t, sx: f32, sy: f32, sw: f32, sh: f32, dx: f32, dy: f32, dw: f32, dh: f32): void; -declare function draw_sub_image(image: image_t, x: f32, y: f32, sx: f32, sy: f32, sw: f32, sh: f32): void; -declare function draw_scaled_image(image: image_t, dx: f32, dy: f32, dw: f32, dh: f32): void; -declare function draw_image(image: image_t, x: f32, y: f32): void; +declare function draw_scaled_sub_image(image: kinc_g5_texture_t, sx: f32, sy: f32, sw: f32, sh: f32, dx: f32, dy: f32, dw: f32, dh: f32): void; +declare function draw_sub_image(image: kinc_g5_texture_t, x: f32, y: f32, sx: f32, sy: f32, sw: f32, sh: f32): void; +declare function draw_scaled_image(image: kinc_g5_texture_t, dx: f32, dy: f32, dw: f32, dh: f32): void; +declare function draw_image(image: kinc_g5_texture_t, x: f32, y: f32): void; declare function draw_filled_triangle(x0: f32, y0: f32, x1: f32, y1: f32, x2: f32, y2: f32): void; declare function draw_filled_rect(x: f32, y: f32, width: f32, height: f32): void; declare function draw_rect(x: f32, y: f32, width: f32, height: f32, strength: f32 = 1.0): void; @@ -356,7 +354,7 @@ declare function iron_raytrace_as_init(): void; declare function iron_raytrace_as_add(vb: any, ib: any, transform: mat4_t): void; declare function iron_raytrace_as_build(vb_full: any, ib_full: any): void; -declare function iron_raytrace_set_textures(tex0: image_t, tex1: image_t, tex2: image_t, texenv: any, tex_sobol: any, tex_scramble: any, tex_rank: any): void; +declare function iron_raytrace_set_textures(tex0: kinc_g5_texture_t, tex1: kinc_g5_texture_t, tex2: kinc_g5_texture_t, texenv: any, tex_sobol: any, tex_scramble: any, tex_rank: any): void; declare function iron_raytrace_dispatch_rays(target: any, cb: buffer_t): void; declare function kinc_window_x(): i32; diff --git a/base/sources/ts/iron/material_data.ts b/base/sources/ts/iron/material_data.ts index 19cbd083..76cc8dcf 100644 --- a/base/sources/ts/iron/material_data.ts +++ b/base/sources/ts/iron/material_data.ts @@ -79,28 +79,28 @@ function material_context_create(raw: material_context_t): material_context_t { continue; } - let image: image_t = data_get_image(tex.file, false); + let image: kinc_g5_texture_t = data_get_image(tex.file, false); array_push(raw._.textures, image); // Set mipmaps if (tex.mipmaps != null) { - let mipmaps: image_t[] = []; + let mipmaps: kinc_g5_texture_t[] = []; while (mipmaps.length < tex.mipmaps.length) { array_push(mipmaps, null); } for (let j: i32 = 0; j < tex.mipmaps.length; ++j) { let name: string = tex.mipmaps[j]; - let mipimg: image_t = data_get_image(name); + let mipimg: kinc_g5_texture_t = data_get_image(name); mipmaps[j] = mipimg; } - image_set_mipmaps(image, mipmaps); + iron_g4_set_mipmaps(image, mipmaps); tex.mipmaps = null; tex.generate_mipmaps = false; } else if (tex.generate_mipmaps == true && image != null) { - image_gen_mipmaps(image, 1000); + kinc_g5_texture_generate_mipmaps(image, 1000); tex.mipmaps = null; tex.generate_mipmaps = false; } diff --git a/base/sources/ts/iron/render_path.ts b/base/sources/ts/iron/render_path.ts index 1ea2acc9..871f3828 100644 --- a/base/sources/ts/iron/render_path.ts +++ b/base/sources/ts/iron/render_path.ts @@ -11,7 +11,7 @@ type render_target_t = { // Runtime _depth_buffer_bits?: i32; _depth_from?: string; - _image?: image_t; // RT or image + _image?: kinc_g5_texture_t; // RT or image _has_depth?: bool; }; @@ -36,7 +36,7 @@ let render_path_current_h: i32; let _render_path_frame_time: f32 = 0.0; let _render_path_frame: i32 = 0; let _render_path_current_target: render_target_t = null; -let _render_path_current_image: image_t = null; +let _render_path_current_image: kinc_g5_texture_t = null; let _render_path_draw_order: draw_order_t = draw_order_t.DIST; let _render_path_paused: bool = false; let _render_path_depth_to_render_target: map_t = map_create(); @@ -89,7 +89,7 @@ function render_path_set_target(target: string, additional: string[] = null) { else { // Render target let rt: render_target_t = map_get(render_path_render_targets, target); _render_path_current_target = rt; - let additional_images: image_t[] = null; + let additional_images: kinc_g5_texture_t[] = null; if (additional != null) { additional_images = []; for (let i: i32 = 0; i < additional.length; ++i) { @@ -108,10 +108,10 @@ function render_path_set_target(target: string, additional: string[] = null) { function render_path_set_depth_from(target: string, from: string) { let rt: render_target_t = map_get(render_path_render_targets, target); let rt_from: render_target_t = map_get(render_path_render_targets, from); - image_set_depth_from(rt._image, rt_from._image); + kinc_g5_render_target_set_depth_from(rt._image, rt_from._image); } -function render_path_begin(render_target: image_t = null, additional_targets: image_t[] = null) { +function render_path_begin(render_target: kinc_g5_texture_t = null, additional_targets: kinc_g5_texture_t[] = null) { if (_render_path_current_image != null) { render_path_end(); } @@ -149,7 +149,7 @@ function render_path_clear_target(color: color_t = 0x00000000, depth: f32 = 0.0, function render_path_gen_mipmaps(target: string) { let rt: render_target_t = map_get(render_path_render_targets, target); - image_gen_mipmaps(rt._image, 1000); + kinc_g5_texture_generate_mipmaps(rt._image, 1000); } function _render_path_sort_dist(a: any_ptr, b: any_ptr): i32 { @@ -285,8 +285,8 @@ function render_path_unload() { } } -function _render_path_resize_on_init(_image: image_t) { - image_unload(_image); +function _render_path_resize_on_init(_image: kinc_g5_texture_t) { + iron_unload_image(_image); } function render_path_resize() { @@ -314,7 +314,7 @@ function render_path_resize() { } if (nodepth != null) { - image_set_depth_from(rt._image, nodepth._image); + kinc_g5_render_target_set_depth_from(rt._image, nodepth._image); } } @@ -322,7 +322,7 @@ function render_path_resize() { for (let i: i32 = 0; i < render_targets_keys.length; ++i) { let rt: render_target_t = map_get(render_path_render_targets, render_targets_keys[i]); if (rt != null && rt.width == 0) { - let _image: image_t = rt._image; + let _image: kinc_g5_texture_t = rt._image; app_notify_on_init(_render_path_resize_on_init, _image); rt._image = render_path_create_image(rt, rt._depth_buffer_bits); } @@ -333,7 +333,7 @@ function render_path_resize() { let rt: render_target_t = map_get(render_path_render_targets, render_targets_keys[i]); if (rt != null && rt._depth_from != "") { let depth_from: render_target_t = map_get(_render_path_depth_to_render_target, rt._depth_from); - image_set_depth_from(rt._image, depth_from._image); + kinc_g5_render_target_set_depth_from(rt._image, depth_from._image); } } } @@ -372,7 +372,7 @@ function render_path_create_target(t: render_target_t): render_target_t { t._depth_buffer_bits = 0; t._depth_from = t.depth_buffer; t._image = render_path_create_image(t, t._depth_buffer_bits); - image_set_depth_from(t._image, depth_target._image); + kinc_g5_render_target_set_depth_from(t._image, depth_target._image); } } else { // No depth buffer @@ -383,7 +383,7 @@ function render_path_create_target(t: render_target_t): render_target_t { return t; } -function render_path_create_image(t: render_target_t, depth_buffer_bits: i32): image_t { +function render_path_create_image(t: render_target_t, depth_buffer_bits: i32): kinc_g5_texture_t { let width: i32 = t.width == 0 ? app_w() : t.width; let height: i32 = t.height == 0 ? app_h() : t.height; width = math_floor(width * t.scale); @@ -394,7 +394,7 @@ function render_path_create_image(t: render_target_t, depth_buffer_bits: i32): i if (height < 1) { height = 1; } - return image_create_render_target(width, height, + return iron_g4_create_render_target(width, height, t.format != null ? render_path_get_tex_format(t.format) : tex_format_t.RGBA32, depth_buffer_bits); } @@ -432,6 +432,6 @@ function render_target_create(): render_target_t { function render_target_unload(raw: render_target_t) { if (raw._image != null) { - image_unload(raw._image); + iron_unload_image(raw._image); } } diff --git a/base/sources/ts/iron/scene.ts b/base/sources/ts/iron/scene.ts index a2e9aa3a..c9d3daf8 100644 --- a/base/sources/ts/iron/scene.ts +++ b/base/sources/ts/iron/scene.ts @@ -13,7 +13,7 @@ let scene_animations: anim_raw_t[]; ///if arm_skin let scene_armatures: armature_t[]; ///end -let scene_embedded: map_t; +let scene_embedded: map_t; let _scene_ready: bool; let _scene_uid_counter: i32 = 0; @@ -444,7 +444,7 @@ function scene_load_embedded_data(datas: string[]) { } function scene_embed_data(file: string) { - let image: image_t = data_get_image(file); + let image: kinc_g5_texture_t = data_get_image(file); map_set(scene_embedded, file, image); } @@ -542,7 +542,7 @@ type material_context_t = { }; type material_context_runtime_t = { - textures?: image_t[]; + textures?: kinc_g5_texture_t[]; }; type bind_const_t = { @@ -651,9 +651,9 @@ type world_data_t = { }; type world_data_runtime_t = { - envmap?: image_t; - radiance?: image_t; - radiance_mipmaps?: image_t[]; + envmap?: kinc_g5_texture_t; + radiance?: kinc_g5_texture_t; + radiance_mipmaps?: kinc_g5_texture_t[]; irradiance?: f32_array_t; }; diff --git a/base/sources/ts/iron/shader_data.ts b/base/sources/ts/iron/shader_data.ts index 5f96a19b..1a903adb 100644 --- a/base/sources/ts/iron/shader_data.ts +++ b/base/sources/ts/iron/shader_data.ts @@ -355,7 +355,7 @@ function shader_context_add_tex(raw: shader_context_t, tu: tex_unit_t) { function shader_context_set_tex_params(raw: shader_context_t, unit_index: i32, tex: bind_tex_t) { // This function is called for samplers set using material context let unit: any = raw._.tex_units[unit_index]; - g4_set_tex_params(unit, + iron_g4_set_texture_parameters(unit, tex.u_addressing == null ? tex_addressing_t.REPEAT : shader_context_get_tex_addresing(tex.u_addressing), tex.v_addressing == null ? tex_addressing_t.REPEAT : shader_context_get_tex_addresing(tex.v_addressing), tex.min_filter == null ? tex_filter_t.LINEAR : shader_context_get_tex_filter(tex.min_filter), diff --git a/base/sources/ts/iron/ui.ts b/base/sources/ts/iron/ui.ts index 4ff02fbd..ccf9b6c3 100644 --- a/base/sources/ts/iron/ui.ts +++ b/base/sources/ts/iron/ui.ts @@ -122,16 +122,16 @@ function ui_nodes_PAN_Y(): f32 { return UI_NODES_PAN_Y(); } -function _ui_image(image: image_t, tint: i32 = 0xffffffff, h: f32 = -1.0, sx: i32 = 0, sy: i32 = 0, sw: i32 = 0, sh: i32 = 0): ui_state_t { - return ui_sub_image(image.texture_, tint, h, sx, sy, sw, sh); +function _ui_image(image: kinc_g5_texture_t, tint: i32 = 0xffffffff, h: f32 = -1.0, sx: i32 = 0, sy: i32 = 0, sw: i32 = 0, sh: i32 = 0): ui_state_t { + return ui_sub_image(image, tint, h, sx, sy, sw, sh); } -function _ui_tooltip_image(image: image_t, max_width: i32 = 0) { - return ui_tooltip_image(image.texture_, max_width); +function _ui_tooltip_image(image: kinc_g5_texture_t, max_width: i32 = 0) { + return ui_tooltip_image(image, max_width); } function ui_window(handle: ui_handle_t, x: i32, y: i32, w: i32, h: i32, drag: bool = false): bool { - _g2_current = { texture_: ADDRESS(handle.texture) }; + _g2_current = ADDRESS(handle.texture); _g2_in_use = true; return _ui_window(handle, x, y, w, h, drag); } @@ -309,7 +309,10 @@ declare function ui_draw_string(text: string, x_offset: f32, y_offset: f32, alig declare function ui_next_node_id(nodes: ui_node_t[]): i32; declare function ui_node_canvas(nodes: ui_nodes_t, canvas: ui_node_canvas_t): void; -declare type kinc_g5_texture_t = any; +declare type kinc_g5_texture_t = { + width: i32; + height: i32; +}; declare type ui_theme_t = any; declare type ui_t = { diff --git a/base/sources/ts/iron/uniforms.ts b/base/sources/ts/iron/uniforms.ts index 760a8821..0c9c71e4 100644 --- a/base/sources/ts/iron/uniforms.ts +++ b/base/sources/ts/iron/uniforms.ts @@ -6,7 +6,7 @@ let _uniforms_vec: vec4_t = vec4_create(); let _uniforms_vec2: vec4_t = vec4_create(); let _uniforms_quat: quat_t = quat_create(); -let uniforms_tex_links: (o: object_t, md: material_data_t, s: string)=>image_t = null; +let uniforms_tex_links: (o: object_t, md: material_data_t, s: string)=>kinc_g5_texture_t = null; let uniforms_mat4_links: (o: object_t, md: material_data_t, s: string)=>mat4_t = null; let uniforms_vec4_links: (o: object_t, md: material_data_t, s: string)=>vec4_t = null; let uniforms_vec3_links: (o: object_t, md: material_data_t, s: string)=>vec4_t = null; @@ -57,21 +57,21 @@ function uniforms_set_context_consts(context: shader_context_t, bind_params: str } if (char_at(tulink, 0) == "$") { // Link to embedded data - g4_set_tex(context._.tex_units[j], map_get(scene_embedded, substring(tulink, 1, tulink.length))); - g4_set_tex_params(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); + iron_g4_set_texture(context._.tex_units[j], map_get(scene_embedded, substring(tulink, 1, tulink.length))); + iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); } else if (tulink == "_envmap_radiance") { let w: world_data_t = scene_world; if (w != null) { - g4_set_tex(context._.tex_units[j], w._.radiance); - g4_set_tex_params(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.LINEAR); + iron_g4_set_texture(context._.tex_units[j], w._.radiance); + iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.LINEAR); } } else if (tulink == "_envmap") { let w: world_data_t = scene_world; if (w != null) { - g4_set_tex(context._.tex_units[j], w._.envmap); - g4_set_tex_params(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); + iron_g4_set_texture(context._.tex_units[j], w._.envmap); + iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); } } } @@ -96,12 +96,12 @@ function uniforms_set_obj_consts(context: shader_context_t, object: object_t) { continue; } - let image: image_t = uniforms_tex_links(object, current_material(object), tu.link); + let image: kinc_g5_texture_t = uniforms_tex_links(object, current_material(object), tu.link); if (image != null) { ends_with(tu.link, "_depth") ? - g4_set_tex_depth(context._.tex_units[j], image) : - g4_set_tex(context._.tex_units[j], image); - g4_set_tex_params(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); + iron_g4_set_texture_depth(context._.tex_units[j], image) : + iron_g4_set_texture(context._.tex_units[j], image); + iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.REPEAT, tex_addressing_t.REPEAT, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); } } } @@ -119,25 +119,25 @@ function uniforms_bind_render_target(rt: render_target_t, context: shader_contex if (sampler_id == tus[j].name) { if (attach_depth) { - g4_set_tex_depth(context._.tex_units[j], rt._image); // sampler2D + iron_g4_set_texture_depth(context._.tex_units[j], rt._image); // sampler2D } else { - g4_set_tex(context._.tex_units[j], rt._image); // sampler2D + iron_g4_set_texture(context._.tex_units[j], rt._image); // sampler2D } if (rt.mipmaps) { - g4_set_tex_params(context._.tex_units[j], tex_addressing_t.CLAMP, tex_addressing_t.CLAMP, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.LINEAR); + iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.CLAMP, tex_addressing_t.CLAMP, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.LINEAR); continue; } if (starts_with(rt.name, "bloom")) { // Use bilinear filter for bloom mips to get correct blur - g4_set_tex_params(context._.tex_units[j], tex_addressing_t.CLAMP, tex_addressing_t.CLAMP, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); + iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.CLAMP, tex_addressing_t.CLAMP, tex_filter_t.LINEAR, tex_filter_t.LINEAR, mip_map_filter_t.NONE); continue; } if (attach_depth) { - g4_set_tex_params(context._.tex_units[j], tex_addressing_t.CLAMP, tex_addressing_t.CLAMP, tex_filter_t.POINT, tex_filter_t.POINT, mip_map_filter_t.NONE); + iron_g4_set_texture_parameters(context._.tex_units[j], tex_addressing_t.CLAMP, tex_addressing_t.CLAMP, tex_filter_t.POINT, tex_filter_t.POINT, mip_map_filter_t.NONE); continue; } @@ -147,7 +147,7 @@ function uniforms_bind_render_target(rt: render_target_t, context: shader_contex if (allow_params) { let addressing: tex_addressing_t = (oc != null && oc.addressing == "repeat") ? tex_addressing_t.REPEAT : tex_addressing_t.CLAMP; let filter: tex_filter_t = (oc != null && oc.filter == "point") ? tex_filter_t.POINT : tex_filter_t.LINEAR; - g4_set_tex_params(context._.tex_units[j], addressing, addressing, filter, filter, mip_map_filter_t.NONE); + iron_g4_set_texture_parameters(context._.tex_units[j], addressing, addressing, filter, filter, mip_map_filter_t.NONE); } } } @@ -536,7 +536,7 @@ function uniforms_set_material_consts(context: shader_context_t, material_contex for (let j: i32 = 0; j < context._.tex_units.length; ++j) { let sname: string = context.texture_units[j].name; if (mname == sname) { - g4_set_tex(context._.tex_units[j], material_context._.textures[i]); + iron_g4_set_texture(context._.tex_units[j], material_context._.textures[i]); // After texture sampler have been assigned, set texture parameters material_context_set_tex_params(material_context, i, context, j); break; diff --git a/base/sources/ts/iron/world_data.ts b/base/sources/ts/iron/world_data.ts index 8f486bc4..e4b96b05 100644 --- a/base/sources/ts/iron/world_data.ts +++ b/base/sources/ts/iron/world_data.ts @@ -15,7 +15,7 @@ function world_data_parse(name: string, id: string): world_data_t { let irr: f32_array_t = world_data_set_irradiance(raw); raw._.irradiance = irr; if (raw.radiance != null) { - let rad: image_t = data_get_image(raw.radiance); + let rad: kinc_g5_texture_t = data_get_image(raw.radiance); raw._.radiance = rad; while (raw._.radiance_mipmaps.length < raw.radiance_mipmaps) { array_push(raw._.radiance_mipmaps, null); @@ -25,10 +25,10 @@ function world_data_parse(name: string, id: string): world_data_t { let base: string = substring(raw.radiance, 0, dot); for (let i: i32 = 0; i < raw.radiance_mipmaps; ++i) { - let mipimg: image_t = data_get_image(base + "_" + i + ext, true); + let mipimg: kinc_g5_texture_t = data_get_image(base + "_" + i + ext, true); raw._.radiance_mipmaps[i] = mipimg; } - image_set_mipmaps(raw._.radiance, raw._.radiance_mipmaps); + iron_g4_set_mipmaps(raw._.radiance, raw._.radiance_mipmaps); } return raw; @@ -73,7 +73,7 @@ function world_data_set_irradiance(raw: world_data_t): f32_array_t { function world_data_load_envmap(raw: world_data_t) { if (raw.envmap != null) { - let image: image_t = data_get_image(raw.envmap); + let image: kinc_g5_texture_t = data_get_image(raw.envmap); raw._.envmap = image; } } diff --git a/base/sources/ts/layers.ts b/base/sources/ts/layers.ts index 12c764c2..71dd3446 100644 --- a/base/sources/ts/layers.ts +++ b/base/sources/ts/layers.ts @@ -1,8 +1,8 @@ -let layers_temp_image: image_t = null; -let layers_expa: image_t = null; -let layers_expb: image_t = null; -let layers_expc: image_t = null; +let layers_temp_image: kinc_g5_texture_t = null; +let layers_expa: kinc_g5_texture_t = null; +let layers_expb: kinc_g5_texture_t = null; +let layers_expc: kinc_g5_texture_t = null; let layers_default_base: f32 = 0.5; let layers_default_rough: f32 = 0.4; let layers_max_layers: i32 = @@ -75,36 +75,36 @@ function layers_resize() { let rts: map_t = render_path_render_targets; let blend0: render_target_t = map_get(rts, "texpaint_blend0"); - let _texpaint_blend0: image_t = blend0._image; - app_notify_on_next_frame(function (_texpaint_blend0: image_t) { - image_unload(_texpaint_blend0); + let _texpaint_blend0: kinc_g5_texture_t = blend0._image; + app_notify_on_next_frame(function (_texpaint_blend0: kinc_g5_texture_t) { + iron_unload_image(_texpaint_blend0); }, _texpaint_blend0); blend0.width = config_get_texture_res_x(); blend0.height = config_get_texture_res_y(); - blend0._image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + blend0._image = iron_g4_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: image_t = blend1._image; - app_notify_on_next_frame(function (_texpaint_blend1: image_t) { - image_unload(_texpaint_blend1); + let _texpaint_blend1: kinc_g5_texture_t = blend1._image; + app_notify_on_next_frame(function (_texpaint_blend1: kinc_g5_texture_t) { + iron_unload_image(_texpaint_blend1); }, _texpaint_blend1); blend1.width = config_get_texture_res_x(); blend1.height = config_get_texture_res_y(); - blend1._image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + blend1._image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); context_raw.brush_blend_dirty = true; let blur: render_target_t = map_get(rts, "texpaint_blur"); if (blur != null) { - let _texpaint_blur: image_t = blur._image; - app_notify_on_next_frame(function (_texpaint_blur: image_t) { - image_unload(_texpaint_blur); + let _texpaint_blur: kinc_g5_texture_t = blur._image; + app_notify_on_next_frame(function (_texpaint_blur: kinc_g5_texture_t) { + iron_unload_image(_texpaint_blur); }, _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; blur.height = size_y; - blur._image = image_create_render_target(size_x, size_y); + blur._image = iron_g4_create_render_target(size_x, size_y); } if (render_path_paint_live_layer != null) { slot_layer_resize_and_set_bits(render_path_paint_live_layer); @@ -160,14 +160,14 @@ 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: image_t = pipes_temp_mask_image; - app_notify_on_next_frame(function (_temp_mask_image: image_t) { - image_unload(_temp_mask_image); + let _temp_mask_image: kinc_g5_texture_t = pipes_temp_mask_image; + app_notify_on_next_frame(function (_temp_mask_image: kinc_g5_texture_t) { + iron_unload_image(_temp_mask_image); }, _temp_mask_image); pipes_temp_mask_image = null; } if (pipes_temp_mask_image == null) { - pipes_temp_mask_image = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + pipes_temp_mask_image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); } } @@ -180,17 +180,17 @@ function layers_make_export_img() { ///end if (layers_expa != null && (layers_expa.width != l.texpaint.width || layers_expa.height != l.texpaint.height || layers_expa.format != l.texpaint.format)) { - let _expa: image_t = layers_expa; - let _expb: image_t = layers_expb; - let _expc: image_t = layers_expc; - app_notify_on_next_frame(function (_expa: image_t) { - image_unload(_expa); + let _expa: kinc_g5_texture_t = layers_expa; + let _expb: kinc_g5_texture_t = layers_expb; + let _expc: kinc_g5_texture_t = layers_expc; + app_notify_on_next_frame(function (_expa: kinc_g5_texture_t) { + iron_unload_image(_expa); }, _expa); - app_notify_on_next_frame(function (_expb: image_t) { - image_unload(_expb); + app_notify_on_next_frame(function (_expb: kinc_g5_texture_t) { + iron_unload_image(_expb); }, _expb); - app_notify_on_next_frame(function (_expc: image_t) { - image_unload(_expc); + app_notify_on_next_frame(function (_expc: kinc_g5_texture_t) { + iron_unload_image(_expc); }, _expc); layers_expa = null; layers_expb = null; @@ -257,21 +257,21 @@ function layers_apply_mask(l: slot_layer_t, m: slot_layer_t) { // Apply mask iron_g4_begin(l.texpaint); kinc_g5_set_pipeline(pipes_apply_mask); - g4_set_tex(pipes_tex0_mask, layers_temp_image); - g4_set_tex(pipes_texa_mask, m.texpaint); + iron_g4_set_texture(pipes_tex0_mask, layers_temp_image); + iron_g4_set_texture(pipes_texa_mask, m.texpaint); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); kinc_g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); iron_g4_end(); } -function layers_commands_merge_pack(pipe: kinc_g5_pipeline_t, i0: image_t, i1: image_t, i1pack: image_t, i1mask_opacity: f32, i1texmask: image_t, i1blending: i32 = -1) { +function layers_commands_merge_pack(pipe: kinc_g5_pipeline_t, i0: kinc_g5_texture_t, i1: kinc_g5_texture_t, i1pack: kinc_g5_texture_t, i1mask_opacity: f32, i1texmask: kinc_g5_texture_t, i1blending: i32 = -1) { iron_g4_begin(i0); kinc_g5_set_pipeline(pipe); - g4_set_tex(pipes_tex0, i1); - g4_set_tex(pipes_tex1, i1pack); - g4_set_tex(pipes_texmask, i1texmask); - g4_set_tex(pipes_texa, layers_temp_image); + iron_g4_set_texture(pipes_tex0, i1); + iron_g4_set_texture(pipes_tex1, i1pack); + iron_g4_set_texture(pipes_texmask, i1texmask); + iron_g4_set_texture(pipes_texa, layers_temp_image); iron_g4_set_float(pipes_opac, i1mask_opacity); iron_g4_set_int(pipes_blending, i1blending); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); @@ -299,7 +299,7 @@ function layers_update_fill_layers() { let _layer: slot_layer_t = context_raw.layer; let _tool: workspace_tool_t = context_raw.tool; let _fill_type: i32 = context_raw.fill_type_handle.position; - let current: image_t = null; + let current: kinc_g5_texture_t = null; if (context_raw.tool == workspace_tool_t.MATERIAL) { if (render_path_paint_live_layer == null) { @@ -399,7 +399,7 @@ function layers_update_fill_layers() { } function layers_update_fill_layer(parse_paint: bool = true) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -718,8 +718,8 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool g2_end(); let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); - let empty: image_t = empty_rt._image; - let mask: image_t = empty; + let empty: kinc_g5_texture_t = empty_rt._image; + let mask: kinc_g5_texture_t = empty; let l1masks: slot_layer_t[] = use_mask ? slot_layer_get_masks(l1) : null; if (l1masks != null) { // for (let i: i32 = 1; i < l1masks.length - 1; ++i) { @@ -731,8 +731,8 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool if (slot_layer_is_mask(l1)) { iron_g4_begin(l0.texpaint); kinc_g5_set_pipeline(pipes_merge_mask); - g4_set_tex(pipes_tex0_merge_mask, l1.texpaint); - g4_set_tex(pipes_texa_merge_mask, layers_temp_image); + iron_g4_set_texture(pipes_tex0_merge_mask, l1.texpaint); + iron_g4_set_texture(pipes_texa_merge_mask, layers_temp_image); iron_g4_set_float(pipes_opac_merge_mask, slot_layer_get_opacity(l1)); iron_g4_set_int(pipes_blending_merge_mask, l1.blending); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); @@ -745,10 +745,10 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool if (l1.paint_base) { iron_g4_begin(l0.texpaint); kinc_g5_set_pipeline(pipes_merge); - g4_set_tex(pipes_tex0, l1.texpaint); - g4_set_tex(pipes_tex1, empty); - g4_set_tex(pipes_texmask, mask); - g4_set_tex(pipes_texa, layers_temp_image); + iron_g4_set_texture(pipes_tex0, l1.texpaint); + iron_g4_set_texture(pipes_tex1, empty); + iron_g4_set_texture(pipes_texmask, mask); + iron_g4_set_texture(pipes_texa, layers_temp_image); iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); iron_g4_set_int(pipes_blending, l1.blending); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); @@ -767,10 +767,10 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool if (l1.paint_nor) { iron_g4_begin(l0.texpaint_nor); kinc_g5_set_pipeline(pipes_merge); - g4_set_tex(pipes_tex0, l1.texpaint); - g4_set_tex(pipes_tex1, l1.texpaint_nor); - g4_set_tex(pipes_texmask, mask); - g4_set_tex(pipes_texa, layers_temp_image); + iron_g4_set_texture(pipes_tex0, l1.texpaint); + iron_g4_set_texture(pipes_tex1, l1.texpaint_nor); + iron_g4_set_texture(pipes_texmask, mask); + iron_g4_set_texture(pipes_texa, layers_temp_image); iron_g4_set_float(pipes_opac, slot_layer_get_opacity(l1)); iron_g4_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); kinc_g4_set_vertex_buffer(const_data_screen_aligned_vb); diff --git a/base/sources/ts/logic_node.ts b/base/sources/ts/logic_node.ts index d6575dc3..c027058c 100644 --- a/base/sources/ts/logic_node.ts +++ b/base/sources/ts/logic_node.ts @@ -3,8 +3,8 @@ type logic_node_t = { inputs?: logic_node_input_t[]; outputs?: logic_node_t[][]; get?: (self: any, from: i32)=>logic_node_value_t; - get_as_image?: (self: any, from: i32)=>image_t; - get_cached_image?: (self: any)=>image_t; + get_as_image?: (self: any, from: i32)=>kinc_g5_texture_t; + get_cached_image?: (self: any)=>kinc_g5_texture_t; set?: (self: any, value: f32_array_t)=>void; ext?: logic_node_ext_t; }; @@ -47,14 +47,14 @@ function logic_node_get(self: logic_node_t, from: i32): any { return null; } -function logic_node_get_as_image(self: logic_node_t, from: i32): image_t { +function logic_node_get_as_image(self: logic_node_t, from: i32): kinc_g5_texture_t { if (self.get_as_image != null) { return self.get_as_image(self.ext, from); } return null; } -function logic_node_get_cached_image(self: logic_node_t): image_t { +function logic_node_get_cached_image(self: logic_node_t): kinc_g5_texture_t { if (self.get_cached_image != null) { return self.get_cached_image(self.ext); } @@ -78,7 +78,7 @@ function logic_node_input_get(self: logic_node_input_t): logic_node_value_t { return logic_node_get(self.node.base, self.from); } -function logic_node_input_get_as_image(self: logic_node_input_t): image_t { +function logic_node_input_get_as_image(self: logic_node_input_t): kinc_g5_texture_t { return logic_node_get_as_image(self.node.base, self.from); } diff --git a/base/sources/ts/nodes/color_node.ts b/base/sources/ts/nodes/color_node.ts index 41b5e383..a39ace2a 100644 --- a/base/sources/ts/nodes/color_node.ts +++ b/base/sources/ts/nodes/color_node.ts @@ -2,7 +2,7 @@ type color_node_t = { base?: logic_node_t; value?: vec4_t; - image?: image_t; + image?: kinc_g5_texture_t; }; function color_node_create(raw: ui_node_t, args: f32_array_t): color_node_t { @@ -29,12 +29,12 @@ function color_node_get(self: color_node_t, from: i32): logic_node_value_t { } } -function color_node_get_as_image(self: color_node_t, from: i32): image_t { +function color_node_get_as_image(self: color_node_t, from: i32): kinc_g5_texture_t { if (self.base.inputs.length > 0) { return logic_node_input_get_as_image(self.base.inputs[0]); } if (self.image != null) { - image_unload(self.image); + iron_unload_image(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 1400c317..7e44df0e 100644 --- a/base/sources/ts/nodes/float_node.ts +++ b/base/sources/ts/nodes/float_node.ts @@ -2,7 +2,7 @@ type float_node_t = { base?: logic_node_t; value?: f32; - image?: image_t; + image?: kinc_g5_texture_t; }; function float_node_create(raw: ui_node_t, args: f32_array_t): float_node_t { @@ -25,12 +25,12 @@ function float_node_get(self: float_node_t, from: i32): logic_node_value_t { } } -function float_node_get_as_image(self: float_node_t, from: i32): image_t { +function float_node_get_as_image(self: float_node_t, from: i32): kinc_g5_texture_t { if (self.base.inputs.length > 0) { return logic_node_input_get_as_image(self.base.inputs[0]); } if (self.image != null) { - image_unload(self.image); + iron_unload_image(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 511e6356..ca3d7cf4 100644 --- a/base/sources/ts/nodes/vector_node.ts +++ b/base/sources/ts/nodes/vector_node.ts @@ -2,7 +2,7 @@ type vector_node_t = { base?: logic_node_t; value?: vec4_t; - image?: image_t; + image?: kinc_g5_texture_t; }; function vector_node_create(raw: ui_node_t, args: f32_array_t): vector_node_t { @@ -33,12 +33,12 @@ function vector_node_get(self: vector_node_t, from: i32): logic_node_value_t { return v; } -function vector_node_get_as_image(self: vector_node_t, from: i32): image_t { +function vector_node_get_as_image(self: vector_node_t, from: i32): kinc_g5_texture_t { // let x: f32 = logic_node_input_get(self.base.inputs[0]); // 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) { - image_unload(self.image); + iron_unload_image(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/parser_material.ts b/base/sources/ts/parser_material.ts index 5c9cc1df..8d77a167 100644 --- a/base/sources/ts/parser_material.ts +++ b/base/sources/ts/parser_material.ts @@ -466,7 +466,7 @@ function _parser_material_cache_tex_text_node(file: string, text: string) { if (map_get(data_cached_images, file) == null) { app_notify_on_init(function(text: string) { let _text_tool_text: string = context_raw.text_tool_text; - let _text_tool_image: image_t = context_raw.text_tool_image; + let _text_tool_image: kinc_g5_texture_t = context_raw.text_tool_image; context_raw.text_tool_text = text; context_raw.text_tool_image = null; diff --git a/base/sources/ts/path.ts b/base/sources/ts/path.ts index 7df9bf58..1ad9a0f3 100644 --- a/base/sources/ts/path.ts +++ b/base/sources/ts/path.ts @@ -15,7 +15,7 @@ let path_mesh_formats: string[] = ["obj", "blend"]; let path_texture_formats: string[] = ["jpg", "jpeg", "png", "tga", "bmp", "psd", "gif", "hdr", "k"]; let path_mesh_importers: map_t = map_create(); // JSValue -> (s: string)=>raw_mesh_t -let path_texture_importers: map_t = map_create(); // JSValue -> (s: string)=>image_t +let path_texture_importers: map_t = map_create(); // JSValue -> (s: string)=>kinc_g5_texture_t let path_base_color_ext: string[] = ["albedo", "alb", "basecol", "basecolor", "diffuse", "diff", "base", "bc", "d", "color", "col"]; let path_opacity_ext: string[] = ["opac", "opacity", "alpha"]; diff --git a/base/sources/ts/pipes.ts b/base/sources/ts/pipes.ts index 0b981c21..87cce9ec 100644 --- a/base/sources/ts/pipes.ts +++ b/base/sources/ts/pipes.ts @@ -33,7 +33,7 @@ let pipes_tex_colorid: kinc_tex_unit_t; let pipes_texpaint_colorid: kinc_tex_unit_t; let pipes_opac_merge_mask: kinc_const_loc_t; let pipes_blending_merge_mask: kinc_const_loc_t; -let pipes_temp_mask_image: image_t = null; +let pipes_temp_mask_image: kinc_g5_texture_t = null; let pipes_inpaint_preview: kinc_g5_pipeline_t; let pipes_tex0_inpaint_preview: kinc_tex_unit_t; diff --git a/base/sources/ts/project.ts b/base/sources/ts/project.ts index 44da3163..5f7e48a1 100644 --- a/base/sources/ts/project.ts +++ b/base/sources/ts/project.ts @@ -7,7 +7,7 @@ let project_asset_id: i32 = 0; let project_mesh_assets: string[] = []; let project_material_groups: node_group_t[] = []; let project_paint_objects: mesh_object_t[] = null; -let project_asset_map: map_t = map_create(); // image_t | font_t +let project_asset_map: map_t = map_create(); // kinc_g5_texture_t | font_t let project_mesh_list: string[] = null; let project_materials: slot_material_t[] = null; @@ -45,7 +45,7 @@ function project_open() { return; } - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -226,7 +226,7 @@ function project_new(reset_layers: bool = true) { let n: string = context_raw.project_type == project_model_t.ROUNDED_CUBE ? ".Cube" : "Tessellated"; let md: mesh_data_t = data_get_mesh("Scene", n); - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -640,7 +640,7 @@ function project_reimport_texture(asset: asset_t) { } } -function project_get_image(asset: asset_t): image_t { +function project_get_image(asset: asset_t): kinc_g5_texture_t { return asset != null ? map_get(project_asset_map, asset.id) : null; } diff --git a/base/sources/ts/render_path_raytrace.ts b/base/sources/ts/render_path_raytrace.ts index b832c059..a0bf1714 100644 --- a/base/sources/ts/render_path_raytrace.ts +++ b/base/sources/ts/render_path_raytrace.ts @@ -10,7 +10,7 @@ let render_path_raytrace_transform: mat4_t; let render_path_raytrace_vb: kinc_g5_vertex_buffer_t; let render_path_raytrace_ib: kinc_g5_index_buffer_t; -let render_path_raytrace_last_envmap: image_t = null; +let render_path_raytrace_last_envmap: kinc_g5_texture_t = null; let render_path_raytrace_is_bake: bool = false; ///if arm_direct3d12 @@ -21,7 +21,7 @@ let render_path_raytrace_ext: string = ".metal"; let render_path_raytrace_ext: string = ".spirv"; ///end -let render_path_raytrace_last_texpaint: image_t = null; +let render_path_raytrace_last_texpaint: kinc_g5_texture_t = null; function render_path_raytrace_init() { } @@ -45,17 +45,17 @@ function render_path_raytrace_commands(use_live_layer: bool) { } let probe: world_data_t = scene_world; - let saved_envmap: image_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; + let saved_envmap: kinc_g5_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; if (render_path_raytrace_last_envmap != saved_envmap) { render_path_raytrace_last_envmap = saved_envmap; - let bnoise_sobol: image_t = map_get(scene_embedded, "bnoise_sobol.k"); - let bnoise_scramble: image_t = map_get(scene_embedded, "bnoise_scramble.k"); - let bnoise_rank: image_t = map_get(scene_embedded, "bnoise_rank.k"); + let bnoise_sobol: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); let l: slot_layer_t = layers_flatten(true); - iron_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, saved_envmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_); + iron_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, saved_envmap, bnoise_sobol, bnoise_scramble, bnoise_rank); } ///if is_lab @@ -63,11 +63,11 @@ function render_path_raytrace_commands(use_live_layer: bool) { if (l.texpaint != render_path_raytrace_last_texpaint) { render_path_raytrace_last_texpaint = l.texpaint; - let bnoise_sobol: image_t = map_get(scene_embedded, "bnoise_sobol.k"); - let bnoise_scramble: image_t = map_get(scene_embedded, "bnoise_scramble.k"); - let bnoise_rank: image_t = map_get(scene_embedded, "bnoise_rank.k"); + let bnoise_sobol: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); - iron_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, saved_envmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_); + iron_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, saved_envmap, bnoise_sobol, bnoise_scramble, bnoise_rank); } ///end @@ -118,7 +118,7 @@ function render_path_raytrace_commands(use_live_layer: bool) { ///end let framebuffer: render_target_t = map_get(render_path_render_targets, "buf"); - iron_raytrace_dispatch_rays(framebuffer._image.texture_, render_path_raytrace_f32a); + iron_raytrace_dispatch_rays(framebuffer._image, render_path_raytrace_f32a); if (context_raw.ddirty == 1 || context_raw.pdirty == 1) { ///if arm_metal diff --git a/base/sources/ts/render_path_raytrace_bake.ts b/base/sources/ts/render_path_raytrace_bake.ts index 2705219a..caac69f4 100644 --- a/base/sources/ts/render_path_raytrace_bake.ts +++ b/base/sources/ts/render_path_raytrace_bake.ts @@ -4,7 +4,7 @@ let render_path_raytrace_bake_rays_sec: i32 = 0; let render_path_raytrace_bake_current_sample: i32 = 0; let render_path_raytrace_bake_rays_timer: f32 = 0.0; let render_path_raytrace_bake_rays_counter: i32 = 0; -let render_path_raytrace_bake_last_layer: image_t = null; +let render_path_raytrace_bake_last_layer: kinc_g5_texture_t = null; let render_path_raytrace_bake_last_bake: i32 = 0; function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>void): bool { @@ -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"); - image_unload(baketex0._image); - image_unload(baketex1._image); - image_unload(baketex2._image); + iron_unload_image(baketex0._image); + iron_unload_image(baketex1._image); + iron_unload_image(baketex2._image); } { @@ -74,21 +74,21 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo } let probe: world_data_t = scene_world; - let saved_envmap: image_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; + let saved_envmap: kinc_g5_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; if (render_path_raytrace_last_envmap != saved_envmap || render_path_raytrace_bake_last_layer != context_raw.layer.texpaint) { render_path_raytrace_last_envmap = saved_envmap; render_path_raytrace_bake_last_layer = context_raw.layer.texpaint; - let bnoise_sobol: image_t = map_get(scene_embedded, "bnoise_sobol.k"); - let bnoise_scramble: image_t = map_get(scene_embedded, "bnoise_scramble.k"); - let bnoise_rank: image_t = map_get(scene_embedded, "bnoise_rank.k"); + let bnoise_sobol: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: kinc_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); 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 texpaint_undo: render_target_t = map_get(render_path_render_targets, "texpaint_undo" + history_undo_i); - iron_raytrace_set_textures(baketex0._image, baketex1._image, texpaint_undo._image, saved_envmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_); + iron_raytrace_set_textures(baketex0._image, baketex1._image, texpaint_undo._image, saved_envmap, bnoise_sobol, bnoise_scramble, bnoise_rank); } if (context_raw.brush_time > 0) { @@ -107,7 +107,7 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo f32a[6] = context_raw.envmap_angle; let framebuffer: render_target_t = map_get(render_path_render_targets, "baketex2"); - iron_raytrace_dispatch_rays(framebuffer._image.texture_, f32a); + iron_raytrace_dispatch_rays(framebuffer._image, f32a); let id: i32 = context_raw.layer.id; let texpaint_id: string = "texpaint" + id; diff --git a/base/sources/ts/resource.ts b/base/sources/ts/resource.ts index 3790ba64..fc5e4750 100644 --- a/base/sources/ts/resource.ts +++ b/base/sources/ts/resource.ts @@ -1,31 +1,31 @@ -let resource_bundled: map_t = map_create(); +let resource_bundled: map_t = map_create(); function resource_load(names: string[]) { for (let i: i32 = 0; i < names.length; ++i) { let s: string = names[i]; - let image: image_t = data_get_image(s); + let image: kinc_g5_texture_t = data_get_image(s); map_set(resource_bundled, s, image); } } -function resource_get(name: string): image_t { +function resource_get(name: string): kinc_g5_texture_t { return map_get(resource_bundled, name); } -function resource_tile50(img: image_t, x: i32, y: i32): rect_t { +function resource_tile50(img: kinc_g5_texture_t, x: i32, y: i32): rect_t { let size: i32 = config_raw.window_scale > 1 ? 100 : 50; let r: rect_t = { x: x * size, y: y * size, w: size, h: size }; return r; } -function resource_tile25(img: image_t, x: i32, y: i32): rect_t { +function resource_tile25(img: kinc_g5_texture_t, x: i32, y: i32): rect_t { let size: i32 = config_raw.window_scale > 1 ? 50 : 25; let r: rect_t = { x: x * size, y: y * size, w: size, h: size }; return r; } -function resource_tile18(img: image_t, x: i32, y: i32): rect_t { +function resource_tile18(img: kinc_g5_texture_t, x: i32, y: i32): rect_t { let size: i32 = config_raw.window_scale > 1 ? 36 : 18; let r: rect_t = { x: x * size, y: img.height - (y + 1) * size, w: size, h: size }; return r; diff --git a/base/sources/ts/slot_brush.ts b/base/sources/ts/slot_brush.ts index 0415dfa5..75296691 100644 --- a/base/sources/ts/slot_brush.ts +++ b/base/sources/ts/slot_brush.ts @@ -2,8 +2,8 @@ type slot_brush_t = { nodes?: ui_nodes_t; canvas?: ui_node_canvas_t; - image?: image_t; // 200px - image_icon?: image_t; // 50px + image?: kinc_g5_texture_t; // 200px + image_icon?: kinc_g5_texture_t; // 50px preview_ready?: bool; id?: i32; }; diff --git a/base/sources/ts/slot_font.ts b/base/sources/ts/slot_font.ts index 706a0830..209d452e 100644 --- a/base/sources/ts/slot_font.ts +++ b/base/sources/ts/slot_font.ts @@ -1,6 +1,6 @@ type slot_font_t = { - image?: image_t; // 200px + image?: kinc_g5_texture_t; // 200px preview_ready?: bool; id?: i32; font?: draw_font_t; diff --git a/base/sources/ts/slot_layer.ts b/base/sources/ts/slot_layer.ts index 1f574d82..1e482065 100644 --- a/base/sources/ts/slot_layer.ts +++ b/base/sources/ts/slot_layer.ts @@ -5,10 +5,10 @@ type slot_layer_t = { ext?: string; visible?: bool; parent?: slot_layer_t; // Group (for layers) or layer (for masks) - texpaint?: image_t; // Base or mask - texpaint_nor?: image_t; - texpaint_pack?: image_t; - texpaint_preview?: image_t; // Layer preview + texpaint?: kinc_g5_texture_t; // Base or mask + texpaint_nor?: kinc_g5_texture_t; + texpaint_pack?: kinc_g5_texture_t; + texpaint_preview?: kinc_g5_texture_t; // Layer preview mask_opacity?: f32; // Opacity mask fill_layer?: slot_material_t; show_panel?: bool; @@ -110,7 +110,7 @@ function slot_layer_create(ext: string = "", type: layer_slot_type_t = layer_slo raw.texpaint_pack = render_path_create_render_target(t)._image; } - raw.texpaint_preview = image_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size, tex_format_t.RGBA32); + raw.texpaint_preview = iron_g4_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size, tex_format_t.RGBA32); ///end } @@ -129,7 +129,7 @@ function slot_layer_create(ext: string = "", type: layer_slot_type_t = layer_slo raw.texpaint = render_path_create_render_target(t)._image; } - raw.texpaint_preview = image_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size, tex_format_t.RGBA32); + raw.texpaint_preview = iron_g4_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size, tex_format_t.RGBA32); } return raw; @@ -179,28 +179,28 @@ function slot_layer_unload(raw: slot_layer_t) { return; } - let _texpaint: image_t = raw.texpaint; - let _texpaint_nor: image_t = raw.texpaint_nor; - let _texpaint_pack: image_t = raw.texpaint_pack; - let _texpaint_preview: image_t = raw.texpaint_preview; + let _texpaint: kinc_g5_texture_t = raw.texpaint; + let _texpaint_nor: kinc_g5_texture_t = raw.texpaint_nor; + let _texpaint_pack: kinc_g5_texture_t = raw.texpaint_pack; + let _texpaint_preview: kinc_g5_texture_t = raw.texpaint_preview; - app_notify_on_next_frame(function (_texpaint: image_t) { - image_unload(_texpaint); + app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: image_t) { - image_unload(_texpaint_nor); + app_notify_on_next_frame(function (_texpaint_nor: kinc_g5_texture_t) { + iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: image_t) { - image_unload(_texpaint_pack); + app_notify_on_next_frame(function (_texpaint_pack: kinc_g5_texture_t) { + iron_unload_image(_texpaint_pack); }, _texpaint_pack); } if (_texpaint_preview != null) { - image_unload(_texpaint_preview); + iron_unload_image(_texpaint_preview); } map_delete(render_path_render_targets, "texpaint" + raw.ext); @@ -216,11 +216,11 @@ function slot_layer_swap(raw: slot_layer_t, other: slot_layer_t) { let rt1: render_target_t = map_get(render_path_render_targets, "texpaint" + other.ext); rt0._image = other.texpaint; rt1._image = raw.texpaint; - let _texpaint: image_t = raw.texpaint; + let _texpaint: kinc_g5_texture_t = raw.texpaint; raw.texpaint = other.texpaint; other.texpaint = _texpaint; - let _texpaint_preview: image_t = raw.texpaint_preview; + let _texpaint_preview: kinc_g5_texture_t = raw.texpaint_preview; raw.texpaint_preview = other.texpaint_preview; other.texpaint_preview = _texpaint_preview; } @@ -234,8 +234,8 @@ function slot_layer_swap(raw: slot_layer_t, other: slot_layer_t) { nor1._image = raw.texpaint_nor; let pack1: render_target_t = map_get(render_path_render_targets, "texpaint_pack" + other.ext); pack1._image = raw.texpaint_pack; - let _texpaint_nor: image_t = raw.texpaint_nor; - let _texpaint_pack: image_t = raw.texpaint_pack; + let _texpaint_nor: kinc_g5_texture_t = raw.texpaint_nor; + let _texpaint_pack: kinc_g5_texture_t = raw.texpaint_pack; raw.texpaint_nor = other.texpaint_nor; raw.texpaint_pack = other.texpaint_pack; other.texpaint_nor = _texpaint_nor; @@ -243,7 +243,7 @@ function slot_layer_swap(raw: slot_layer_t, other: slot_layer_t) { } } -function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_image: image_t = null, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0) { +function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_image: kinc_g5_texture_t = null, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0) { iron_g4_begin(raw.texpaint); kinc_g5_clear(base_color); // Base iron_g4_end(); @@ -267,15 +267,15 @@ function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_ } function slot_layer_invert_mask(raw: slot_layer_t) { - let inverted: image_t = image_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32); + let inverted: kinc_g5_texture_t = iron_g4_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32); g2_begin(inverted); draw_set_pipeline(pipes_invert8); draw_image(raw.texpaint, 0, 0); draw_set_pipeline(null); g2_end(); - let _texpaint: image_t = raw.texpaint; - app_notify_on_next_frame(function (_texpaint: image_t) { - image_unload(_texpaint); + let _texpaint: kinc_g5_texture_t = raw.texpaint; + app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + iron_unload_image(_texpaint); }, _texpaint); let rt: render_target_t = map_get(render_path_render_targets, "texpaint" + raw.id); raw.texpaint = rt._image = inverted; @@ -383,17 +383,17 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { format = tex_format_t.RGBA128; ///end - let _texpaint: image_t = raw.texpaint; - raw.texpaint = image_create_render_target(res_x, res_y, format); + let _texpaint: kinc_g5_texture_t = raw.texpaint; + raw.texpaint = iron_g4_create_render_target(res_x, res_y, format); g2_begin(raw.texpaint); draw_set_pipeline(pipes_copy); draw_scaled_image(_texpaint, 0, 0, res_x, res_y); draw_set_pipeline(null); g2_end(); - let _texpaint_nor: image_t = raw.texpaint_nor; + let _texpaint_nor: kinc_g5_texture_t = raw.texpaint_nor; if (raw.texpaint_nor != null) { - raw.texpaint_nor = image_create_render_target(res_x, res_y, format); + raw.texpaint_nor = iron_g4_create_render_target(res_x, res_y, format); g2_begin(raw.texpaint_nor); draw_set_pipeline(pipes_copy); @@ -402,9 +402,9 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { g2_end(); } - let _texpaint_pack: image_t = raw.texpaint_pack; + let _texpaint_pack: kinc_g5_texture_t = raw.texpaint_pack; if (raw.texpaint_pack != null) { - raw.texpaint_pack = image_create_render_target(res_x, res_y, format); + raw.texpaint_pack = iron_g4_create_render_target(res_x, res_y, format); g2_begin(raw.texpaint_pack); draw_set_pipeline(pipes_copy); @@ -413,19 +413,19 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { g2_end(); } - app_notify_on_next_frame(function (_texpaint: image_t) { - image_unload(_texpaint); + app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: image_t) { - image_unload(_texpaint_nor); + app_notify_on_next_frame(function (_texpaint_nor: kinc_g5_texture_t) { + iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: image_t) { - image_unload(_texpaint_pack); + app_notify_on_next_frame(function (_texpaint_pack: kinc_g5_texture_t) { + iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -443,8 +443,8 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { } } else if (slot_layer_is_mask(raw)) { - let _texpaint: image_t = raw.texpaint; - raw.texpaint = image_create_render_target(res_x, res_y, tex_format_t.RGBA32); + let _texpaint: kinc_g5_texture_t = raw.texpaint; + raw.texpaint = iron_g4_create_render_target(res_x, res_y, tex_format_t.RGBA32); g2_begin(raw.texpaint); draw_set_pipeline(pipes_copy8); @@ -452,8 +452,8 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_set_pipeline(null); g2_end(); - app_notify_on_next_frame(function (_texpaint: image_t) { - image_unload(_texpaint); + app_notify_on_next_frame(function (_texpaint: kinc_g5_texture_t) { + iron_unload_image(_texpaint); }, _texpaint); let rt: render_target_t = map_get(rts, "texpaint" + raw.ext); diff --git a/base/sources/ts/slot_material.ts b/base/sources/ts/slot_material.ts index 663b3401..cb81347c 100644 --- a/base/sources/ts/slot_material.ts +++ b/base/sources/ts/slot_material.ts @@ -2,8 +2,8 @@ type slot_material_t = { nodes?: ui_nodes_t; canvas?: ui_node_canvas_t; - image?: image_t; - image_icon?: image_t; + image?: kinc_g5_texture_t; + image_icon?: kinc_g5_texture_t; preview_ready?: bool; data?: material_data_t; id?: i32; @@ -45,8 +45,8 @@ function slot_material_create(m: material_data_t = null, c: ui_node_canvas_t = n let w: i32 = util_render_material_preview_size; let w_icon: i32 = 50; - raw.image = image_create_render_target(w, w); - raw.image_icon = image_create_render_target(w_icon, w_icon); + raw.image = iron_g4_create_render_target(w, w); + raw.image_icon = iron_g4_create_render_target(w_icon, w_icon); if (c == null) { if (slot_material_default_canvas == null) { // Synchronous @@ -71,8 +71,8 @@ function slot_material_create(m: material_data_t = null, c: ui_node_canvas_t = n function slot_material_unload(raw: slot_material_t) { app_notify_on_next_frame(function (raw: slot_material_t) { - image_unload(raw.image); - image_unload(raw.image_icon); + iron_unload_image(raw.image); + iron_unload_image(raw.image_icon); }, raw); } diff --git a/base/sources/ts/tab_brushes.ts b/base/sources/ts/tab_brushes.ts index 1b23cda5..9bfe7a12 100644 --- a/base/sources/ts/tab_brushes.ts +++ b/base/sources/ts/tab_brushes.ts @@ -52,8 +52,8 @@ function tab_brushes_draw(htab: ui_handle_t) { } continue; } - let img: image_t = ui_SCALE(ui) > 1 ? project_brushes[i].image : project_brushes[i].image_icon; - let img_full: image_t = project_brushes[i].image; + let img: kinc_g5_texture_t = ui_SCALE(ui) > 1 ? project_brushes[i].image : project_brushes[i].image_icon; + let img_full: kinc_g5_texture_t = project_brushes[i].image; if (context_raw.brush == project_brushes[i]) { // ui_fill(1, -2, img.width + 3, img.height + 3, ui.ops.theme.HIGHLIGHT_COL); // TODO diff --git a/base/sources/ts/tab_fonts.ts b/base/sources/ts/tab_fonts.ts index b94bcf4f..c6255138 100644 --- a/base/sources/ts/tab_fonts.ts +++ b/base/sources/ts/tab_fonts.ts @@ -60,7 +60,7 @@ function tab_fonts_draw(htab: ui_handle_t) { } continue; } - let img: image_t = project_fonts[i].image; + let img: kinc_g5_texture_t = project_fonts[i].image; if (context_raw.font == project_fonts[i]) { // ui_fill(1, -2, img.width + 3, img.height + 3, ui.ops.theme.HIGHLIGHT_COL); // TODO diff --git a/base/sources/ts/tab_layers.ts b/base/sources/ts/tab_layers.ts index 7efc0600..441c3442 100644 --- a/base/sources/ts/tab_layers.ts +++ b/base/sources/ts/tab_layers.ts @@ -345,7 +345,7 @@ function tab_layers_draw_layer_slot_full(l: slot_layer_t, i: i32) { } // Draw eye icon - let icons: image_t = resource_get("icons.k"); + let icons: kinc_g5_texture_t = resource_get("icons.k"); let r: rect_t = resource_tile18(icons, l.visible ? 0 : 1, 0); let center: f32 = (step / 2) * ui_SCALE(ui); ui._x += 2; @@ -573,7 +573,7 @@ function tab_layers_draw_layer_highlight(l: slot_layer_t, mini: bool) { function tab_layers_handle_layer_icon_state(l: slot_layer_t, i: i32, state: ui_state_t, uix: f32, uiy: f32) { let ui: ui_t = ui_base_ui; - let texpaint_preview: image_t = l.texpaint_preview; + let texpaint_preview: kinc_g5_texture_t = l.texpaint_preview; tab_layers_show_context_menu = false; @@ -620,7 +620,7 @@ function tab_layers_handle_layer_icon_state(l: slot_layer_t, i: i32, state: ui_s function tab_layers_draw_layer_icon(l: slot_layer_t, i: i32, uix: f32, uiy: f32, mini: bool): ui_state_t { let ui: ui_t = ui_base_ui; - let icons: image_t = resource_get("icons.k"); + let icons: kinc_g5_texture_t = resource_get("icons.k"); let icon_h: i32 = (ui_ELEMENT_H(ui) - (mini ? 2 : 3)) * 2; if (mini && ui_SCALE(ui) > 1) { @@ -637,9 +637,9 @@ function tab_layers_draw_layer_icon(l: slot_layer_t, i: i32, uix: f32, uiy: f32, } if (!slot_layer_is_group(l)) { - let texpaint_preview: image_t = l.texpaint_preview; + let texpaint_preview: kinc_g5_texture_t = l.texpaint_preview; - let icon: image_t = l.fill_layer == null ? texpaint_preview : l.fill_layer.image_icon; + let icon: kinc_g5_texture_t = l.fill_layer == null ? texpaint_preview : l.fill_layer.image_icon; if (l.fill_layer == null) { // Checker let r: rect_t = resource_tile50(icons, 4, 1); @@ -750,7 +750,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { if (!ends_with(f, ".png")) { f += ".png"; } - iron_write_png(path + path_sep + f, image_get_pixels(l.texpaint), l.texpaint.width, l.texpaint.height, 3); // RRR1 + iron_write_png(path + path_sep + f, iron_g4_get_texture_pixels(l.texpaint), l.texpaint.width, l.texpaint.height, 3); // RRR1 }); } else { @@ -998,7 +998,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { function tab_layers_make_mask_preview_rgba32(l: slot_layer_t) { if (context_raw.mask_preview_rgba32 == null) { - context_raw.mask_preview_rgba32 = image_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size); + context_raw.mask_preview_rgba32 = iron_g4_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size); } // Convert from R8 to RGBA32 for tooltip display if (context_raw.mask_preview_last != l) { diff --git a/base/sources/ts/tab_materials.ts b/base/sources/ts/tab_materials.ts index e7e7b1b1..c600ac2c 100644 --- a/base/sources/ts/tab_materials.ts +++ b/base/sources/ts/tab_materials.ts @@ -80,8 +80,8 @@ function tab_materials_draw_slots(mini: bool) { } continue; } - let img: image_t = ui_SCALE(ui) > 1 ? project_materials[i].image : project_materials[i].image_icon; - let img_full: image_t = project_materials[i].image; + let img: kinc_g5_texture_t = ui_SCALE(ui) > 1 ? project_materials[i].image : project_materials[i].image_icon; + let img_full: kinc_g5_texture_t = project_materials[i].image; // Highligh selected if (context_raw.material == project_materials[i]) { diff --git a/base/sources/ts/tab_swatches.ts b/base/sources/ts/tab_swatches.ts index 2e2b5186..7eab7b7c 100644 --- a/base/sources/ts/tab_swatches.ts +++ b/base/sources/ts/tab_swatches.ts @@ -1,13 +1,13 @@ -let _tab_swatches_empty: image_t; +let _tab_swatches_empty: kinc_g5_texture_t; let tab_swatches_drag_pos: i32 = -1; let _tab_swatches_draw_i: i32; -function tab_swatches_empty_set(image: image_t) { +function tab_swatches_empty_set(image: kinc_g5_texture_t) { _tab_swatches_empty = image; } -function tab_swatches_empty_get(): image_t { +function tab_swatches_empty_get(): kinc_g5_texture_t { if (_tab_swatches_empty == null) { let b: u8_array_t = u8_array_create(4); b[0] = 255; diff --git a/base/sources/ts/tab_textures.ts b/base/sources/ts/tab_textures.ts index b45732f2..309f6f42 100644 --- a/base/sources/ts/tab_textures.ts +++ b/base/sources/ts/tab_textures.ts @@ -1,5 +1,5 @@ -let _tab_textures_draw_img: image_t; +let _tab_textures_draw_img: kinc_g5_texture_t; let _tab_textures_draw_path: string; let _tab_textures_draw_asset: asset_t; let _tab_textures_draw_i: i32; @@ -78,7 +78,7 @@ function tab_textures_draw(htab: ui_handle_t) { } let asset: asset_t = project_assets[i]; - let img: image_t = project_get_image(asset); + let img: kinc_g5_texture_t = project_get_image(asset); if (img == null) { let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_black"); img = empty_rt._image; @@ -140,14 +140,14 @@ function tab_textures_draw(htab: ui_handle_t) { _tab_textures_draw_path = path; app_notify_on_next_frame(function () { - let img: image_t = _tab_textures_draw_img; - let target: image_t = image_create_render_target(tab_textures_to_pow2(img.width), tab_textures_to_pow2(img.height)); + let img: kinc_g5_texture_t = _tab_textures_draw_img; + let target: kinc_g5_texture_t = iron_g4_create_render_target(tab_textures_to_pow2(img.width), tab_textures_to_pow2(img.height)); g2_begin(target); draw_set_pipeline(pipes_copy); draw_scaled_image(img, 0, 0, target.width, target.height); draw_set_pipeline(null); g2_end(); - app_notify_on_next_frame(function (target: image_t) { + app_notify_on_next_frame(function (target: kinc_g5_texture_t) { let path: string = _tab_textures_draw_path; let f: string = ui_files_filename; if (f == "") { @@ -156,8 +156,8 @@ function tab_textures_draw(htab: ui_handle_t) { if (!ends_with(f, ".png")) { f += ".png"; } - iron_write_png(path + path_sep + f, image_get_pixels(target), target.width, target.height, 0); - image_unload(target); + iron_write_png(path + path_sep + f, iron_g4_get_texture_pixels(target), target.width, target.height, 0); + iron_unload_image(target); }, target); }); }); @@ -220,7 +220,7 @@ function tab_textures_draw(htab: ui_handle_t) { } } else { - let img: image_t = resource_get("icons.k"); + let img: kinc_g5_texture_t = resource_get("icons.k"); let r: rect_t = resource_tile50(img, 0, 1); _ui_image(img, ui.ops.theme.BUTTON_COL, r.h, r.x, r.y, r.w, r.h); if (ui.is_hovered) { diff --git a/base/sources/ts/ui_base.ts b/base/sources/ts/ui_base.ts index 4002781d..480e9944 100644 --- a/base/sources/ts/ui_base.ts +++ b/base/sources/ts/ui_base.ts @@ -151,8 +151,8 @@ function ui_base_init() { theme: base_theme, font: base_font, scale_factor: scale, - color_wheel: base_color_wheel.texture_, - black_white_gradient: base_color_wheel_gradient.texture_ + color_wheel: base_color_wheel, + black_white_gradient: base_color_wheel_gradient }; ui_base_ui = ui_create(ops); ui_on_border_hover = ui_base_on_border_hover; @@ -1082,12 +1082,12 @@ function ui_base_update_ui() { continue; } - let target: image_t = l.texpaint_preview; + let target: kinc_g5_texture_t = l.texpaint_preview; if (target == null) { continue; } - let source: image_t = l.texpaint; + let source: kinc_g5_texture_t = l.texpaint; g2_begin(target); kinc_g5_clear(0x00000000); // draw_set_pipeline(l.is_mask() ? pipes_copy8 : pipes_copy); @@ -1104,10 +1104,10 @@ function ui_base_update_ui() { // Update layer preview let l: slot_layer_t = context_raw.layer; - let target: image_t = l.texpaint_preview; + let target: kinc_g5_texture_t = l.texpaint_preview; if (target != null) { - let source: image_t = l.texpaint; + let source: kinc_g5_texture_t = l.texpaint; g2_begin(target); kinc_g5_clear(0x00000000); // draw_set_pipeline(raw.layer.is_mask() ? pipes_copy8 : pipes_copy); @@ -1338,16 +1338,16 @@ function ui_base_render_cursor() { // Show picked material next to cursor if (context_raw.tool == workspace_tool_t.PICKER && context_raw.picker_select_material && context_raw.color_picker_callback == null) { - let img: image_t = context_raw.material.image_icon; + let img: kinc_g5_texture_t = context_raw.material.image_icon; draw_image(img, mx + 10, my + 10); } if (context_raw.tool == workspace_tool_t.PICKER && context_raw.color_picker_callback != null) { - let img: image_t = resource_get("icons.k"); + let img: kinc_g5_texture_t = resource_get("icons.k"); let rect: rect_t = resource_tile50(img, workspace_tool_t.PICKER, 0); draw_sub_image(img, mx + 10, my + 10, rect.x, rect.y, rect.w, rect.h); } - let cursor_img: image_t = resource_get("cursor.k"); + let cursor_img: kinc_g5_texture_t = resource_get("cursor.k"); let psize: i32 = math_floor(182 * (context_raw.brush_radius * context_raw.brush_nodes_radius) * ui_SCALE(ui_base_ui)); // Clone source cursor diff --git a/base/sources/ts/ui_files.ts b/base/sources/ts/ui_files.ts index 8f71a3b1..b7950892 100644 --- a/base/sources/ts/ui_files.ts +++ b/base/sources/ts/ui_files.ts @@ -1,7 +1,7 @@ type draw_cloud_icon_data_t = { f: string; - image: image_t; + image: kinc_g5_texture_t; }; let ui_files_default_path: string = @@ -21,7 +21,7 @@ let ui_files_path: string = ui_files_default_path; let ui_files_last_path: string = ""; let ui_files_last_search: string = ""; let ui_files_files: string[] = null; -let ui_files_icon_map: map_t = null; +let ui_files_icon_map: map_t = null; let ui_files_icon_file_map: map_t = null; let ui_files_selected: i32 = -1; let ui_files_show_extensions: bool = false; @@ -71,14 +71,14 @@ function ui_files_release_keys() { ///end } -function make_draw_cloud_icon_data(f: string, image: image_t): draw_cloud_icon_data_t { +function make_draw_cloud_icon_data(f: string, image: kinc_g5_texture_t): draw_cloud_icon_data_t { let data: draw_cloud_icon_data_t = { f: f, image: image }; return data; } function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = false, search: string = "", refresh: bool = false, context_menu: (s: string)=>void = null): string { - let icons: image_t = resource_get("icons.k"); + let icons: kinc_g5_texture_t = resource_get("icons.k"); let folder: rect_t = resource_tile50(icons, 2, 1); let file: rect_t = resource_tile50(icons, 3, 1); let is_cloud: bool = starts_with(handle.text, "cloud"); @@ -173,7 +173,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let uiy: f32 = ui._y; let state: ui_state_t = ui_state_t.IDLE; let generic: bool = true; - let icon: image_t = null; + let icon: kinc_g5_texture_t = null; if (is_cloud && f != ".." && !ui_files_offline) { if (ui_files_icon_map == null) { @@ -188,7 +188,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let icon_file: string = substring(f, 0, dot) + "_icon.jpg"; if (array_index_of(files_all, icon_file) >= 0) { let rt: render_target_t = map_get(render_path_render_targets, "empty_black"); - let empty: image_t = rt._image; + let empty: kinc_g5_texture_t = rt._image; map_set(ui_files_icon_map, handle.text + path_sep + f, empty); _ui_files_file_browser_handle = handle; @@ -196,7 +196,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = file_cache_cloud(handle.text + path_sep + icon_file, function (abs: string) { if (abs != null) { - let image: image_t = data_get_image(abs); + let image: kinc_g5_texture_t = data_get_image(abs); ///if arm_windows abs = string_replace_all(abs, "\\", "/"); ///end @@ -205,7 +205,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let data: draw_cloud_icon_data_t = make_draw_cloud_icon_data(f, image); app_notify_on_init(function (data: draw_cloud_icon_data_t) { - let icon: image_t = image_create_render_target(data.image.width, data.image.height); + let icon: kinc_g5_texture_t = iron_g4_create_render_target(data.image.width, data.image.height); if (ends_with(data.f, ".arm")) { // Used for material sphere alpha cutout g2_begin(icon); @@ -312,9 +312,9 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = icon = map_get(ui_files_icon_map, shandle); if (icon == null) { let rt: render_target_t = map_get(render_path_render_targets, "empty_black"); - let empty: image_t = rt._image; + let empty: kinc_g5_texture_t = rt._image; map_set(ui_files_icon_map, shandle, empty); - let image: image_t = data_get_image(shandle); + let image: kinc_g5_texture_t = data_get_image(shandle); let args: ui_files_make_icon_t = { image: image, @@ -428,10 +428,10 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = function ui_files_make_icon (args: ui_files_make_icon_t) { let w: i32 = args.w; - let image: image_t = args.image; + let image: kinc_g5_texture_t = args.image; let sw: i32 = image.width > image.height ? w : math_floor(1.0 * image.width / image.height * w); let sh: i32 = image.width > image.height ? math_floor(1.0 * image.height / image.width * w) : w; - let icon: image_t = image_create_render_target(sw, sh); + let icon: kinc_g5_texture_t = iron_g4_create_render_target(sw, sh); g2_begin(icon); kinc_g5_clear(0xffffffff); draw_set_pipeline(pipes_copy_rgb); @@ -452,7 +452,7 @@ function ui_files_go_up(handle: ui_handle_t) { } type ui_files_make_icon_t = { - image: image_t; + image: kinc_g5_texture_t; shandle: string; w: i32; }; diff --git a/base/sources/ts/ui_menu.ts b/base/sources/ts/ui_menu.ts index bf5ccc5f..dfa5f205 100644 --- a/base/sources/ts/ui_menu.ts +++ b/base/sources/ts/ui_menu.ts @@ -243,7 +243,7 @@ function ui_menu_render() { ///if (is_paint || is_sculpt) context_raw.draw_wireframe = ui_check(context_raw.wireframe_handle, " " + tr("Wireframe")); if (context_raw.wireframe_handle.changed) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; g2_end(); util_uv_cache_uv_map(); g2_begin(current); @@ -528,7 +528,7 @@ function ui_menu_render() { let tab_vertical: bool = config_raw.touch_ui; if (ui_tab(ui_handle(__ID__), tr("About"), tab_vertical)) { - let img: image_t = data_get_image("badge.k"); + let img: kinc_g5_texture_t = data_get_image("badge.k"); _ui_image(img); _ui_end_element(); diff --git a/base/sources/ts/ui_menubar.ts b/base/sources/ts/ui_menubar.ts index 501a9391..b0b5ccb0 100644 --- a/base/sources/ts/ui_menubar.ts +++ b/base/sources/ts/ui_menubar.ts @@ -231,7 +231,7 @@ function ui_menubar_icon_button(ui: ui_t, i: i32, j: i32): bool { let col: u32 = ui.ops.theme.WINDOW_BG_COL; let light: bool = col > 0xff666666 ; let icon_accent: i32 = light ? 0xff666666 : 0xffaaaaaa; - let img: image_t = resource_get("icons.k"); + let img: kinc_g5_texture_t = resource_get("icons.k"); let rect: rect_t = resource_tile50(img, i, j); return _ui_image(img, icon_accent, -1.0, rect.x, rect.y, rect.w, rect.h) == ui_state_t.RELEASED; } diff --git a/base/sources/ts/ui_nodes.ts b/base/sources/ts/ui_nodes.ts index 1708f55c..c0009613 100644 --- a/base/sources/ts/ui_nodes.ts +++ b/base/sources/ts/ui_nodes.ts @@ -32,7 +32,7 @@ let ui_nodes_last_node_selected_id: i32 = -1; let ui_nodes_release_link: bool = false; let ui_nodes_is_node_menu_op: bool = false; -let ui_nodes_grid: image_t = null; +let ui_nodes_grid: kinc_g5_texture_t = null; let ui_nodes_grid_redraw: bool = true; let ui_nodes_grid_cell_w: i32 = 200; let ui_nodes_grid_small_cell_w: i32 = 40; @@ -70,8 +70,8 @@ function ui_viewnodes_init() { let ops: ui_options_t = { theme: base_theme, font: base_font, - color_wheel: base_color_wheel.texture_, - black_white_gradient: base_color_wheel_gradient.texture_, + color_wheel: base_color_wheel, + black_white_gradient: base_color_wheel_gradient, scale_factor: scale }; ui_nodes_ui = ui_create(ops); @@ -715,7 +715,7 @@ function ui_nodes_get_node_y(): i32 { return math_floor((mouse_y - ui_nodes_wy - ui_nodes_PAN_Y()) / ui_nodes_SCALE()); } -function ui_nodes_draw_grid(zoom: f32): image_t { +function ui_nodes_draw_grid(zoom: f32): kinc_g5_texture_t { let ww: i32 = config_raw.layout[layout_size_t.NODES_W]; ///if (is_paint || is_sculpt) @@ -736,7 +736,7 @@ function ui_nodes_draw_grid(zoom: f32): image_t { h = 1; } - let grid: image_t = image_create_render_target(w, h); + let grid: kinc_g5_texture_t = iron_g4_create_render_target(w, h); g2_begin(grid); kinc_g5_clear(ui_nodes_ui.ops.theme.SEPARATOR_COL); @@ -868,7 +868,7 @@ function ui_nodes_render() { if (ui_nodes_grid_redraw) { if (ui_nodes_grid != null) { - image_unload(ui_nodes_grid); + iron_unload_image(ui_nodes_grid); } let ui_nodes: ui_nodes_t = ui_nodes_get_nodes(); ui_nodes_grid = ui_nodes_draw_grid(ui_nodes.zoom); @@ -1056,7 +1056,7 @@ function ui_nodes_render() { // Node previews if (config_raw.node_preview && nodes.nodes_selected_id.length > 0) { - let img: image_t = null; + let img: kinc_g5_texture_t = null; let sel: ui_node_t = ui_get_node(c.nodes, nodes.nodes_selected_id[0]); ///if (is_paint || is_sculpt) @@ -1587,7 +1587,7 @@ function ui_nodes_make_node_preview() { } if (context_raw.node_preview == null) { - context_raw.node_preview = image_create_render_target(util_render_material_preview_size, util_render_material_preview_size); + context_raw.node_preview = iron_g4_create_render_target(util_render_material_preview_size, util_render_material_preview_size); } context_raw.node_preview_dirty = false; diff --git a/base/sources/ts/ui_toolbar.ts b/base/sources/ts/ui_toolbar.ts index 9b878624..1d6dedfc 100644 --- a/base/sources/ts/ui_toolbar.ts +++ b/base/sources/ts/ui_toolbar.ts @@ -30,7 +30,7 @@ let _ui_toolbar_i: i32; function ui_toolbar_init() { } -function ui_toolbar_draw_tool(i: i32, ui: ui_t, img: image_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_draw_tool(i: i32, ui: ui_t, img: kinc_g5_texture_t, icon_accent: i32, keys: string[]) { ui._x += 2; if (context_raw.tool == i) { ui_toolbar_draw_highlight(); @@ -108,7 +108,7 @@ function ui_toolbar_render_ui() { ui._y -= 4 * ui_SCALE(ui); ui.image_scroll_align = false; - let img: image_t = resource_get("icons.k"); + let img: kinc_g5_texture_t = resource_get("icons.k"); let col: u32 = ui.ops.theme.WINDOW_BG_COL; let light: bool = col > 0xff666666; diff --git a/base/sources/ts/ui_view2d.ts b/base/sources/ts/ui_view2d.ts index e1d9dab6..605d28c7 100644 --- a/base/sources/ts/ui_view2d.ts +++ b/base/sources/ts/ui_view2d.ts @@ -22,12 +22,12 @@ let ui_view2d_pan_y: f32 = 0.0; let ui_view2d_pan_scale: f32 = 1.0; let ui_view2d_tiled_show: bool = false; let ui_view2d_controls_down: bool = false; -let _ui_view2d_render_tex: image_t; +let _ui_view2d_render_tex: kinc_g5_texture_t; let _ui_view2d_render_x: f32; let _ui_view2d_render_y: f32; let _ui_view2d_render_tw: f32; let _ui_view2d_render_th: f32; -let ui_view2d_grid: image_t = null; +let ui_view2d_grid: kinc_g5_texture_t = null; let ui_view2d_grid_redraw: bool = true; function ui_view2d_init() { @@ -51,8 +51,8 @@ function ui_view2d_init() { let ops: ui_options_t = { theme: base_theme, font: base_font, - color_wheel: base_color_wheel.texture_, - black_white_gradient: base_color_wheel_gradient.texture_, + color_wheel: base_color_wheel, + black_white_gradient: base_color_wheel_gradient, scale_factor: scale }; ui_view2d_ui = ui_create(ops); @@ -94,7 +94,7 @@ function ui_view2d_render() { // Cache grid if (ui_view2d_grid_redraw) { if (ui_view2d_grid != null) { - image_unload(ui_view2d_grid); + iron_unload_image(ui_view2d_grid); } ui_view2d_grid = ui_nodes_draw_grid(ui_view2d_pan_scale); ui_view2d_grid_redraw = false; @@ -139,7 +139,7 @@ function ui_view2d_render() { draw_image(ui_view2d_grid, x, y); // Texture - let tex: image_t = null; + let tex: kinc_g5_texture_t = null; let l: slot_layer_t = context_raw.layer; let channel: i32 = 0; @@ -177,14 +177,14 @@ function ui_view2d_render() { } if (ui_view2d_layer_mode == view_2d_layer_mode_t.VISIBLE) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); layer = layers_flatten(); if (g2_in_use) g2_begin(current); } else if (slot_layer_is_group(layer)) { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); layer = layers_flatten(false, slot_layer_get_children(layer)); @@ -258,11 +258,11 @@ function ui_view2d_render() { app_notify_on_next_frame(function () { let rt: render_target_t = map_get(render_path_render_targets, "texpaint_picker"); - let texpaint_picker: image_t = rt._image; + let texpaint_picker: kinc_g5_texture_t = rt._image; g2_begin(texpaint_picker); draw_scaled_image(_ui_view2d_render_tex, -_ui_view2d_render_x, -_ui_view2d_render_y, _ui_view2d_render_tw, _ui_view2d_render_th); g2_end(); - let a: buffer_t = image_get_pixels(texpaint_picker); + let a: buffer_t = iron_g4_get_texture_pixels(texpaint_picker); ///if (arm_metal || arm_vulkan) let i0: i32 = 2; let i1: i32 = 1; @@ -410,7 +410,7 @@ function ui_view2d_render() { // Picked position ///if (is_paint || is_sculpt) if (context_raw.tool == workspace_tool_t.PICKER && (ui_view2d_type == view_2d_type_t.LAYER || ui_view2d_type == view_2d_type_t.ASSET)) { - let cursor_img: image_t = resource_get("cursor.k"); + let cursor_img: kinc_g5_texture_t = resource_get("cursor.k"); let hsize: f32 = 16 * ui_SCALE(ui_view2d_ui); let size: f32 = hsize * 2; draw_scaled_image(cursor_img, tx + tw * context_raw.uvx_picked - hsize, ty + th * context_raw.uvy_picked - hsize, size, size); diff --git a/base/sources/ts/uniforms_ext.ts b/base/sources/ts/uniforms_ext.ts index db2dace9..d3842864 100644 --- a/base/sources/ts/uniforms_ext.ts +++ b/base/sources/ts/uniforms_ext.ts @@ -301,7 +301,7 @@ function uniforms_ext_mat4_link(object: object_t, mat: material_data_t, link: st return mat4_nan(); } -function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: string): image_t { +function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: string): kinc_g5_texture_t { if (link == "_texpaint_undo") { ///if is_lab return null; diff --git a/base/sources/ts/util_mesh.ts b/base/sources/ts/util_mesh.ts index 78b72e42..64d81cba 100644 --- a/base/sources/ts/util_mesh.ts +++ b/base/sources/ts/util_mesh.ts @@ -383,8 +383,8 @@ function util_mesh_to_origin() { util_mesh_merge(); } -function util_mesh_apply_displacement(texpaint_pack: image_t, strength: f32 = 0.1, uv_scale: f32 = 1.0) { - let height: buffer_t = image_get_pixels(texpaint_pack); +function util_mesh_apply_displacement(texpaint_pack: kinc_g5_texture_t, strength: f32 = 0.1, uv_scale: f32 = 1.0) { + let height: buffer_t = iron_g4_get_texture_pixels(texpaint_pack); let res: i32 = texpaint_pack.width; let o: mesh_object_t = project_paint_objects[0]; let g: mesh_data_t = o.data; diff --git a/base/sources/ts/util_render.ts b/base/sources/ts/util_render.ts index b5ca9e4e..f29fa310 100644 --- a/base/sources/ts/util_render.ts +++ b/base/sources/ts/util_render.ts @@ -79,12 +79,12 @@ function util_render_make_material_preview() { } function util_render_make_decal_preview() { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); if (context_raw.decal_image == null) { - context_raw.decal_image = image_create_render_target(util_render_decal_preview_size, util_render_decal_preview_size); + context_raw.decal_image = iron_g4_create_render_target(util_render_decal_preview_size, util_render_decal_preview_size); } context_raw.decal_preview = true; @@ -143,7 +143,7 @@ function util_render_make_decal_preview() { } function util_render_make_text_preview() { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -157,14 +157,14 @@ function util_render_make_text_preview() { tex_w = 512; } if (context_raw.text_tool_image != null && context_raw.text_tool_image.width < tex_w) { - image_unload(context_raw.text_tool_image); + iron_unload_image(context_raw.text_tool_image); context_raw.text_tool_image = null; } if (context_raw.text_tool_image == null) { ///if arm_metal - context_raw.text_tool_image = image_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); + context_raw.text_tool_image = iron_g4_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); ///else - context_raw.text_tool_image = image_create_render_target(tex_w, tex_w, tex_format_t.R8); + context_raw.text_tool_image = iron_g4_create_render_target(tex_w, tex_w, tex_format_t.R8); ///end } g2_begin(context_raw.text_tool_image); @@ -178,7 +178,7 @@ function util_render_make_text_preview() { } function util_render_make_font_preview() { - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -189,7 +189,7 @@ function util_render_make_font_preview() { let text_h: i32 = math_floor(g2_font_height(font, font_size)) + 8; let tex_w: i32 = text_w + 32; if (context_raw.font.image == null) { - context_raw.font.image = image_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); + context_raw.font.image = iron_g4_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); } g2_begin(context_raw.font.image); kinc_g5_clear(0x00000000); @@ -207,7 +207,7 @@ function util_render_make_brush_preview() { return; } - let current: image_t = _g2_current; + let current: kinc_g5_texture_t = _g2_current; let g2_in_use: bool = _g2_in_use; if (g2_in_use) g2_end(); @@ -222,8 +222,8 @@ function util_render_make_brush_preview() { slot_layer_clear(l); if (context_raw.brush.image == null) { - context_raw.brush.image = image_create_render_target(util_render_material_preview_size, util_render_material_preview_size); - context_raw.brush.image_icon = image_create_render_target(50, 50); + context_raw.brush.image = iron_g4_create_render_target(util_render_material_preview_size, util_render_material_preview_size); + context_raw.brush.image_icon = iron_g4_create_render_target(50, 50); } let _material: slot_material_t = context_raw.material; @@ -365,7 +365,7 @@ function util_render_make_brush_preview() { // Scale layer down to to image preview l = render_path_paint_live_layer; - let target: image_t = context_raw.brush.image; + let target: kinc_g5_texture_t = context_raw.brush.image; g2_begin(target); kinc_g5_clear(0x00000000); draw_set_pipeline(pipes_copy); @@ -388,7 +388,7 @@ function util_render_make_brush_preview() { if (g2_in_use) g2_begin(current); } -function util_render_make_node_preview(canvas: ui_node_canvas_t, node: ui_node_t, image: image_t, group: ui_node_canvas_t = null, parents: ui_node_t[] = null) { +function util_render_make_node_preview(canvas: ui_node_canvas_t, node: ui_node_t, image: kinc_g5_texture_t, group: ui_node_canvas_t = null, parents: ui_node_t[] = null) { let res: parse_node_preview_result_t = make_material_parse_node_preview_material(node, group, parents); if (res == null || res.scon == null) { return; diff --git a/base/sources/ts/util_uv.ts b/base/sources/ts/util_uv.ts index c915ea90..98a0f874 100644 --- a/base/sources/ts/util_uv.ts +++ b/base/sources/ts/util_uv.ts @@ -1,18 +1,18 @@ -let util_uv_uvmap: image_t = null; +let util_uv_uvmap: kinc_g5_texture_t = null; let util_uv_uvmap_cached: bool = false; -let util_uv_trianglemap: image_t = null; +let util_uv_trianglemap: kinc_g5_texture_t = null; let util_uv_trianglemap_cached: bool = false; -let util_uv_dilatemap: image_t = null; +let util_uv_dilatemap: kinc_g5_texture_t = null; let util_uv_dilatemap_cached: bool = false; -let util_uv_uvislandmap: image_t = null; +let util_uv_uvislandmap: kinc_g5_texture_t = null; let util_uv_uvislandmap_cached: bool = false; let util_uv_dilate_bytes: buffer_t = null; let util_uv_pipe_dilate: kinc_g5_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())) { - image_unload(util_uv_uvmap); + iron_unload_image(util_uv_uvmap); util_uv_uvmap = null; util_uv_uvmap_cached = false; } @@ -24,7 +24,7 @@ function util_uv_cache_uv_map() { let res_x: i32 = config_get_texture_res_x(); let res_y: i32 = config_get_texture_res_y(); if (util_uv_uvmap == null) { - util_uv_uvmap = image_create_render_target(res_x, res_y); + util_uv_uvmap = iron_g4_create_render_target(res_x, res_y); } util_uv_uvmap_cached = true; @@ -55,7 +55,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())) { - image_unload(util_uv_trianglemap); + iron_unload_image(util_uv_trianglemap); util_uv_trianglemap = null; util_uv_trianglemap_cached = false; } @@ -65,7 +65,7 @@ function util_uv_cache_triangle_map() { } if (util_uv_trianglemap == null) { - util_uv_trianglemap = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + util_uv_trianglemap = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); } util_uv_trianglemap_cached = true; @@ -94,7 +94,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())) { - image_unload(util_uv_dilatemap); + iron_unload_image(util_uv_dilatemap); util_uv_dilatemap = null; util_uv_dilatemap_cached = false; } @@ -102,7 +102,7 @@ function util_uv_cache_dilate_map() { if (util_uv_dilatemap_cached) return; if (util_uv_dilatemap == null) { - util_uv_dilatemap = image_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + util_uv_dilatemap = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); } if (util_uv_pipe_dilate == null) { @@ -179,7 +179,7 @@ function _util_uv_check(cx: i32, cy: i32, w: i32, h: i32, r: i32, view: buffer_t function util_uv_cache_uv_island_map() { util_uv_cache_dilate_map(); if (util_uv_dilate_bytes == null) { - util_uv_dilate_bytes = image_get_pixels(util_uv_dilatemap); + util_uv_dilate_bytes = iron_g4_get_texture_pixels(util_uv_dilatemap); } util_render_pick_pos_nor_tex(); let w: i32 = 2048; // config_get_texture_res_x() @@ -198,7 +198,7 @@ function util_uv_cache_uv_island_map() { } if (util_uv_uvislandmap != null) { - image_unload(util_uv_uvislandmap); + iron_unload_image(util_uv_uvislandmap); } util_uv_uvislandmap = image_from_bytes(bytes, w, h, tex_format_t.R8); util_uv_uvislandmap_cached = true; diff --git a/base/tools/amake/aimage.c b/base/tools/amake/aimage.c index 39091cf1..24e0ac34 100644 --- a/base/tools/amake/aimage.c +++ b/base/tools/amake/aimage.c @@ -18,7 +18,7 @@ typedef struct image { int width; int height; bool is_hdr; -} image_t; +} kinc_g5_texture_t; static bool ends_with(const char *s, const char *end) { size_t len_s = strlen(s); @@ -26,21 +26,21 @@ static bool ends_with(const char *s, const char *end) { return strncmp(s + len_s - len_end, end, len_end) == 0; } -static image_t read_png_jpg(const char *filename) { +static kinc_g5_texture_t read_png_jpg(const char *filename) { int width, height, n; char *data = stbi_load(filename, &width, &height, &n, 4); - image_t img = { .data = data, .width = width, .height = height, .is_hdr = false }; + kinc_g5_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = false }; return img; } -static image_t read_hdr(const char *filename) { +static kinc_g5_texture_t read_hdr(const char *filename) { int width, height, n; float *data = stbi_loadf(filename, &width, &height, &n, 4); - image_t img = { .data = data, .width = width, .height = height, .is_hdr = true }; + kinc_g5_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = true }; return img; } -static void *scale_image(image_t img, int width, int height) { +static void *scale_image(kinc_g5_texture_t img, int width, int height) { unsigned char *scaled = malloc(width * height * 4); stbir_resize_uint8_generic(img.data, img.width, img.height, img.width * 4, scaled, width, height, width * 4, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_COLORSPACE_SRGB, 0); @@ -72,7 +72,7 @@ static void write_ico_entry(FILE *file, int width, int height, int size, int off } void export_ico(const char *from, const char *to) { - image_t img = read_png_jpg(from); + kinc_g5_texture_t img = read_png_jpg(from); FILE *file = fopen(to, "wb"); unsigned char *data256 = scale_image(img, 256, 256); @@ -115,7 +115,7 @@ void export_ico(const char *from, const char *to) { } void export_png(const char *from, const char *to, int width, int height) { - image_t img = read_png_jpg(from); + kinc_g5_texture_t img = read_png_jpg(from); if (width > 0 && height > 0) { unsigned char *scaled = scale_image(img, width, height); @@ -151,7 +151,7 @@ static void write_k(int width, int height, const char *format, char *data, int s } void export_k(const char *from, const char *to) { - image_t img; + kinc_g5_texture_t img; if (ends_with(from, ".hdr")) { img = read_hdr(from); } diff --git a/base/tools/pad/sources/main.ts b/base/tools/pad/sources/main.ts index 040815e4..5ef293d7 100644 --- a/base/tools/pad/sources/main.ts +++ b/base/tools/pad/sources/main.ts @@ -23,7 +23,7 @@ let minimap_w: i32 = 150; let minimap_h: i32 = 0; let minimap_box_h: i32 = 0; let minimap_scrolling: bool = false; -let minimap: image_t = null; +let minimap: kinc_g5_texture_t = null; let window_header_h: i32 = 0; function drop_files(path: string) { @@ -315,9 +315,9 @@ function draw_minimap() { if (minimap_h != kinc_window_height()) { minimap_h = kinc_window_height(); if (minimap != null) { - image_unload(minimap); + iron_unload_image(minimap); } - minimap = image_create_render_target(minimap_w, minimap_h); + minimap = iron_g4_create_render_target(minimap_w, minimap_h); } g2_begin(minimap);