From 9bb68734e9256ef0b36a1270674dadb8c4387f01 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 10 Mar 2025 20:38:53 +0100 Subject: [PATCH] Cleanup --- armorforge/sources/sim.ts | 2 +- armorforge/sources/ui_toolbar_ext.ts | 2 +- armorlab/sources/layers_ext.ts | 18 +- .../sources/nodes/brush_output_node_ext.ts | 12 +- armorlab/sources/nodes/image_texture_node.ts | 6 +- armorlab/sources/nodes/inpaint_node.ts | 62 +- armorlab/sources/nodes/photo_to_pbr_node.ts | 20 +- armorlab/sources/nodes/rgb_node.ts | 8 +- armorlab/sources/nodes/text_to_photo_node.ts | 14 +- armorlab/sources/nodes/tiling_node.ts | 18 +- armorlab/sources/nodes/upscale_node.ts | 30 +- armorlab/sources/nodes/variance_node.ts | 14 +- armorlab/sources/render_path_paint.ts | 38 +- armorlab/sources/ui_nodes_ext.ts | 28 +- armorlab/sources/ui_toolbar_ext.ts | 2 +- armorpaint/plugins/io_svg/nanosvg.c | 4 +- armorpaint/sources/layers_ext.ts | 96 +-- armorpaint/sources/make_material.ts | 18 +- .../sources/nodes/brush_output_node_ext.ts | 4 +- armorpaint/sources/render_path_paint.ts | 46 +- armorpaint/sources/ui_header_ext.ts | 26 +- armorpaint/sources/ui_toolbar_ext.ts | 2 +- armorsculpt/sources/export_obj.ts | 4 +- armorsculpt/sources/import_mesh.ts | 4 +- armorsculpt/sources/make_material.ts | 14 +- .../sources/nodes/brush_output_node_ext.ts | 4 +- armorsculpt/sources/render_path_sculpt.ts | 8 +- armorsculpt/sources/tab_layers.ts | 2 +- armorsculpt/sources/ui_toolbar_ext.ts | 2 +- base/assets/plugins/import_tiff.js | 2 +- base/plugins/plugin_api.c | 8 +- base/sources/backends/android_system.c | 6 +- base/sources/backends/android_video.c | 2 +- base/sources/backends/android_video.h | 2 +- base/sources/backends/apple_video.h | 2 +- base/sources/backends/apple_video.m | 6 +- base/sources/backends/direct3d12_gpu.c | 536 +++++++------- base/sources/backends/direct3d12_gpu.h | 44 +- base/sources/backends/ios_system.h | 2 +- base/sources/backends/ios_system.m | 4 +- base/sources/backends/linux_system.c | 8 +- base/sources/backends/linux_video.c | 2 +- base/sources/backends/macos_system.h | 2 +- base/sources/backends/macos_system.m | 4 +- base/sources/backends/metal_gpu.h | 22 +- base/sources/backends/metal_gpu.m | 468 ++++++------ base/sources/backends/vulkan_gpu.c | 496 ++++++------- base/sources/backends/vulkan_gpu.h | 12 +- base/sources/backends/wasm_system.c | 4 +- base/sources/backends/wasm_video.c | 2 +- base/sources/backends/webgpu_gpu.c | 232 +++--- base/sources/backends/webgpu_gpu.h | 8 +- base/sources/backends/windows_system.c | 8 +- base/sources/backends/windows_video.c | 2 +- base/sources/iron.h | 332 ++++----- base/sources/iron_draw.c | 330 ++++----- base/sources/iron_draw.h | 24 +- base/sources/iron_gpu.c | 544 +++++++------- base/sources/iron_gpu.h | 688 +++++++++--------- base/sources/iron_ui.c | 58 +- base/sources/iron_ui.h | 24 +- base/sources/iron_ui_nodes.c | 8 +- base/sources/iron_video.h | 2 +- base/sources/ts/base.ts | 22 +- base/sources/ts/box_preferences.ts | 2 +- base/sources/ts/box_projects.ts | 10 +- base/sources/ts/config.ts | 2 +- base/sources/ts/console.ts | 6 +- base/sources/ts/context.ts | 26 +- base/sources/ts/export_arm.ts | 42 +- base/sources/ts/export_obj.ts | 2 +- base/sources/ts/export_texture.ts | 88 +-- base/sources/ts/import_arm.ts | 38 +- base/sources/ts/import_blend_material.ts | 2 +- base/sources/ts/import_envmap.ts | 66 +- base/sources/ts/import_texture.ts | 10 +- base/sources/ts/iron/const_data.ts | 44 +- base/sources/ts/iron/data.ts | 12 +- base/sources/ts/iron/iron.ts | 138 ++-- base/sources/ts/iron/material_data.ts | 10 +- base/sources/ts/iron/mesh_data.ts | 40 +- base/sources/ts/iron/mesh_object.ts | 10 +- base/sources/ts/iron/render_path.ts | 54 +- base/sources/ts/iron/scene.ts | 28 +- base/sources/ts/iron/shader_data.ts | 30 +- base/sources/ts/iron/sys.ts | 8 +- base/sources/ts/iron/ui.ts | 12 +- base/sources/ts/iron/uniforms.ts | 90 +-- base/sources/ts/iron/world_data.ts | 8 +- base/sources/ts/layers.ts | 186 ++--- base/sources/ts/line_draw.ts | 82 +-- 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 | 298 ++++---- base/sources/ts/project.ts | 8 +- base/sources/ts/render_path_deferred.ts | 4 +- base/sources/ts/render_path_raytrace.ts | 26 +- base/sources/ts/render_path_raytrace_bake.ts | 10 +- 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 | 86 +-- base/sources/ts/slot_material.ts | 8 +- base/sources/ts/tab_brushes.ts | 4 +- base/sources/ts/tab_fonts.ts | 4 +- base/sources/ts/tab_layers.ts | 18 +- base/sources/ts/tab_materials.ts | 4 +- base/sources/ts/tab_swatches.ts | 8 +- base/sources/ts/tab_textures.ts | 14 +- base/sources/ts/ui_base.ts | 24 +- base/sources/ts/ui_box.ts | 2 +- base/sources/ts/ui_files.ts | 38 +- base/sources/ts/ui_menu.ts | 6 +- base/sources/ts/ui_menubar.ts | 2 +- base/sources/ts/ui_nodes.ts | 14 +- base/sources/ts/ui_toolbar.ts | 4 +- base/sources/ts/ui_view2d.ts | 36 +- base/sources/ts/uniforms_ext.ts | 2 +- base/sources/ts/util_mesh.ts | 34 +- base/sources/ts/util_render.ts | 68 +- base/sources/ts/util_uv.ts | 54 +- base/tests/triangle/main.ts | 42 +- base/tools/amake/aimage.c | 18 +- base/tools/pad/sources/main.ts | 6 +- 128 files changed, 3181 insertions(+), 3181 deletions(-) diff --git a/armorforge/sources/sim.ts b/armorforge/sources/sim.ts index dadf9426..df05dbe1 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 = iron_g4_get_texture_pixels(rt._image); + let pixels: buffer_t = gpu_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 36001042..57f7ade2 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: iron_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: iron_gpu_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 fd790b53..13386386 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: iron_g5_texture_t = context_raw.brush_output_node_inst.texpaint; - let texpaint_nor: iron_g5_texture_t = context_raw.brush_output_node_inst.texpaint_nor; - let texpaint_pack: iron_g5_texture_t = context_raw.brush_output_node_inst.texpaint_pack; + let texpaint: iron_gpu_texture_t = context_raw.brush_output_node_inst.texpaint; + let texpaint_nor: iron_gpu_texture_t = context_raw.brush_output_node_inst.texpaint_nor; + let texpaint_pack: iron_gpu_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); @@ -25,15 +25,15 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t function layers_ext_on_resized() { iron_unload_image(context_raw.brush_output_node_inst.texpaint); let texpaint_rt: render_target_t = map_get(render_path_render_targets, "texpaint"); - 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()); + context_raw.brush_output_node_inst.texpaint = texpaint_rt._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); iron_unload_image(context_raw.brush_output_node_inst.texpaint_nor); 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 = iron_g4_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 = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); iron_unload_image(context_raw.brush_output_node_inst.texpaint_pack); 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 = iron_g4_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 = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); if (inpaint_node_image != null) { iron_unload_image(inpaint_node_image); @@ -45,7 +45,7 @@ function layers_ext_on_resized() { if (photo_to_pbr_node_images != null) { for (let i: i32 = 0; i < photo_to_pbr_node_images.length; ++i) { - let image: iron_g5_texture_t = photo_to_pbr_node_images[i]; + let image: iron_gpu_texture_t = photo_to_pbr_node_images[i]; iron_unload_image(image); } photo_to_pbr_node_images = null; @@ -60,11 +60,11 @@ function layers_ext_on_resized() { let texpaint_blend0_rt: render_target_t = map_get(render_path_render_targets, "texpaint_blend0"); 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); + texpaint_blend0_rt._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); let texpaint_blend1_rt: render_target_t = map_get(render_path_render_targets, "texpaint_blend1"); iron_unload_image(texpaint_blend1_rt._image); - texpaint_blend1_rt._image = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + texpaint_blend1_rt._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); if (map_get(render_path_render_targets, "texpaint_node") != null) { 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 3cc0e170..b78a0e4c 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?: iron_g5_texture_t; - texpaint_nor?: iron_g5_texture_t; - texpaint_pack?: iron_g5_texture_t; - texpaint_nor_empty?: iron_g5_texture_t; - texpaint_pack_empty?: iron_g5_texture_t; + texpaint?: iron_gpu_texture_t; + texpaint_nor?: iron_gpu_texture_t; + texpaint_pack?: iron_gpu_texture_t; + texpaint_nor_empty?: iron_gpu_texture_t; + texpaint_pack_empty?: iron_gpu_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): iron_g5_texture_t { +function brush_output_node_get_as_image(self: brush_output_node_t, from: i32): iron_gpu_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 4f461055..6c1004d5 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): iron_g5_texture_t { +function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): iron_gpu_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): iron_g5_texture_t { - let image: iron_g5_texture_t = self.base.get_as_image(self, 0); +function image_texture_node_get_cached_image(self: image_texture_node_t): iron_gpu_texture_t { + let image: iron_gpu_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 09cbeb15..edfaa5d8 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: iron_g5_texture_t = null; -let inpaint_node_mask: iron_g5_texture_t = null; -let inpaint_node_result: iron_g5_texture_t = null; +let inpaint_node_image: iron_gpu_texture_t = null; +let inpaint_node_mask: iron_gpu_texture_t = null; +let inpaint_node_result: iron_gpu_texture_t = null; -let inpaint_node_temp: iron_g5_texture_t = null; +let inpaint_node_temp: iron_gpu_texture_t = null; let inpaint_node_prompt: string = ""; let inpaint_node_strength: f32 = 0.5; let inpaint_node_auto: bool = true; @@ -27,24 +27,24 @@ 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 = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + inpaint_node_image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); } if (inpaint_node_mask == null) { - inpaint_node_mask = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + inpaint_node_mask = gpu_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); - iron_g5_clear(color_from_floats(1.0, 1.0, 1.0, 1.0)); - _iron_g4_end(); + _gpu_begin(inpaint_node_mask); + iron_gpu_clear(color_from_floats(1.0, 1.0, 1.0, 1.0)); + _gpu_end(); }); } if (inpaint_node_temp == null) { - inpaint_node_temp = iron_g4_create_render_target(512, 512); + inpaint_node_temp = gpu_create_render_target(512, 512); } if (inpaint_node_result == null) { - inpaint_node_result = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + inpaint_node_result = gpu_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): iron_g5_texture_t { - let source: iron_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); +function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): iron_gpu_texture_t { + let source: iron_gpu_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); console_progress(tr("Processing") + " - " + tr("Inpaint")); draw_begin(inpaint_node_image); @@ -84,42 +84,42 @@ function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): iron_g5_tex } } -function inpaint_node_get_cached_image(self: inpaint_node_t): iron_g5_texture_t { +function inpaint_node_get_cached_image(self: inpaint_node_t): iron_gpu_texture_t { app_notify_on_next_frame(function (self: inpaint_node_t) { - let source: iron_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); - _iron_g4_begin(inpaint_node_image); - iron_g5_set_pipeline(pipes_inpaint_preview); - _iron_g4_set_texture(pipes_tex0_inpaint_preview, source); - _iron_g4_set_texture(pipes_texa_inpaint_preview, inpaint_node_mask); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + let source: iron_gpu_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); + _gpu_begin(inpaint_node_image); + iron_gpu_set_pipeline(pipes_inpaint_preview); + _gpu_set_texture(pipes_tex0_inpaint_preview, source); + _gpu_set_texture(pipes_texa_inpaint_preview, inpaint_node_mask); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); }, self); return inpaint_node_image; } -function inpaint_node_get_target(): iron_g5_texture_t { +function inpaint_node_get_target(): iron_gpu_texture_t { return inpaint_node_mask; } -function inpaint_node_texsynth_inpaint(image: iron_g5_texture_t, tiling: bool, mask: iron_g5_texture_t): iron_g5_texture_t { +function inpaint_node_texsynth_inpaint(image: iron_gpu_texture_t, tiling: bool, mask: iron_gpu_texture_t): iron_gpu_texture_t { let w: i32 = config_get_texture_res_x(); let h: i32 = config_get_texture_res_y(); - 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_img: buffer_t = gpu_get_texture_pixels(image); + let bytes_mask: buffer_t = mask != null ? gpu_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); - inpaint_node_result = iron_g4_create_texture_from_bytes(bytes_out, w, h); + inpaint_node_result = gpu_create_texture_from_bytes(bytes_out, w, h); return inpaint_node_result; } -function inpaint_node_sd_inpaint(image: iron_g5_texture_t, mask: iron_g5_texture_t): iron_g5_texture_t { +function inpaint_node_sd_inpaint(image: iron_gpu_texture_t, mask: iron_gpu_texture_t): iron_gpu_texture_t { inpaint_node_init(); - let bytes_img: buffer_t = iron_g4_get_texture_pixels(mask); + let bytes_img: buffer_t = gpu_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: iron_g5_texture_t, mask: iron_g5_texture draw_scaled_image(image, 0, 0, 512, 512); draw_end(); - bytes_img = iron_g4_get_texture_pixels(inpaint_node_temp); + bytes_img = gpu_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 53bf216a..76228f0f 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: iron_g5_texture_t = null; -let photo_to_pbr_node_images: iron_g5_texture_t[] = null; +let photo_to_pbr_node_temp: iron_gpu_texture_t = null; +let photo_to_pbr_node_images: iron_gpu_texture_t[] = null; let photo_to_pbr_node_model_names: string[] = ["base", "occlusion", "roughness", "metallic", "normal", "height"]; -let photo_to_pbr_node_cached_source: iron_g5_texture_t = null; +let photo_to_pbr_node_cached_source: iron_gpu_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 = 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_temp = gpu_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, iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y())); + array_push(photo_to_pbr_node_images, gpu_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): iron_g5_texture_t { +function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): iron_gpu_texture_t { - let source: iron_g5_texture_t; + let source: iron_gpu_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()); draw_end(); - let bytes_img: buffer_t = iron_g4_get_texture_pixels(photo_to_pbr_node_temp); + let bytes_img: buffer_t = gpu_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,11 +153,11 @@ function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): i } ///end - let temp2: iron_g5_texture_t = iron_g4_create_texture_from_bytes(u8a, photo_to_pbr_node_tile_w, photo_to_pbr_node_tile_w); + let temp2: iron_gpu_texture_t = gpu_create_texture_from_bytes(u8a, photo_to_pbr_node_tile_w, photo_to_pbr_node_tile_w); draw_begin(photo_to_pbr_node_images[from]); draw_image(temp2, x * photo_to_pbr_node_tile_w, y * photo_to_pbr_node_tile_w); draw_end(); - app_notify_on_next_frame(function(temp2: iron_g5_texture_t) { + app_notify_on_next_frame(function(temp2: iron_gpu_texture_t) { iron_unload_image(temp2); }, temp2); } diff --git a/armorlab/sources/nodes/rgb_node.ts b/armorlab/sources/nodes/rgb_node.ts index ba4ddb12..6282940d 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?: iron_g5_texture_t; + image?: iron_gpu_texture_t; raw?: ui_node_t; }; @@ -14,7 +14,7 @@ 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): iron_g5_texture_t { +function rgb_node_get_as_image(self: rgb_node_t, from: i32): iron_gpu_texture_t { if (self.image != null) { app_notify_on_next_frame(function (self: rgb_node_t) { iron_unload_image(self.image); @@ -29,11 +29,11 @@ function rgb_node_get_as_image(self: rgb_node_t, from: i32): iron_g5_texture_t { f32a[2] = default_value[2]; f32a[3] = default_value[3]; let buf: buffer_t = buffer_create_from_raw(f32a.buffer, f32a.length * 4); - self.image = iron_g4_create_texture_from_bytes(buf, 1, 1, tex_format_t.RGBA128); + self.image = gpu_create_texture_from_bytes(buf, 1, 1, tex_format_t.RGBA128); return self.image; } -function rgb_node_get_cached_image(self: rgb_node_t): iron_g5_texture_t { +function rgb_node_get_cached_image(self: rgb_node_t): iron_gpu_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 9a9f9d33..619df60b 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: iron_g5_texture_t = null; +let text_to_photo_node_image: iron_gpu_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): iron_g5_texture_t { +function text_to_photo_node_get_as_image(self: text_to_photo_node_t, from: i32): iron_gpu_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): iron_g5_texture_t { +function text_to_photo_node_get_cached_image(self: text_to_photo_node_t): iron_gpu_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): iron_g5_texture_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): iron_gpu_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): iron_g5_texture_t { +function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): iron_gpu_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): ir u8a[i * 4 + 2] = math_floor(pyimage[i + 512 * 512 * 2] * 255); u8a[i * 4 + 3] = 255; } - let image: iron_g5_texture_t = iron_g4_create_texture_from_bytes(u8a, 512, 512); + let image: iron_gpu_texture_t = gpu_create_texture_from_bytes(u8a, 512, 512); if (text_to_photo_node_tiling) { tiling_node_prompt = text_to_photo_node_prompt; @@ -278,7 +278,7 @@ function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): ir if (upscale) { upscale_node_load_blob(); while (image.width < config_get_texture_res_x()) { - let last_image: iron_g5_texture_t = image; + let last_image: iron_gpu_texture_t = image; image = upscale_node_esrgan(image); iron_unload_image(last_image); } diff --git a/armorlab/sources/nodes/tiling_node.ts b/armorlab/sources/nodes/tiling_node.ts index 5c6be13b..482bc84c 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?: iron_g5_texture_t; + result?: iron_gpu_texture_t; }; -let tiling_node_image: iron_g5_texture_t = null; +let tiling_node_image: iron_gpu_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 = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + tiling_node_image = gpu_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): iron_g5_texture_t { - let source: iron_g5_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); +function tiling_node_get_as_image(self: tiling_node_t, from: i32): iron_gpu_texture_t { + let source: iron_gpu_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); draw_begin(tiling_node_image); draw_scaled_image(source, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); draw_end(); @@ -60,13 +60,13 @@ function tiling_node_get_as_image(self: tiling_node_t, from: i32): iron_g5_textu return self.result; } -function tiling_node_get_cached_image(self: tiling_node_t): iron_g5_texture_t { +function tiling_node_get_cached_image(self: tiling_node_t): iron_gpu_texture_t { return self.result; } -function tiling_node_sd_tiling(image: iron_g5_texture_t, seed: i32): iron_g5_texture_t { +function tiling_node_sd_tiling(image: iron_gpu_texture_t, seed: i32): iron_gpu_texture_t { text_to_photo_node_tiling = false; - let tile: iron_g5_texture_t = iron_g4_create_render_target(512, 512); + let tile: iron_gpu_texture_t = gpu_create_render_target(512, 512); draw_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: iron_g5_texture_t, seed: i32): iron_g5_tex // u8a[y * 512 + x] = 0; // } // } - let mask: iron_g5_texture_t = iron_g4_create_texture_from_bytes(u8a, 512, 512, tex_format_t.R8); + let mask: iron_gpu_texture_t = gpu_create_texture_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 80a1ed82..5ce469ae 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: iron_g5_texture_t = null; -let upscale_node_image: iron_g5_texture_t = null; +let upscale_node_temp: iron_gpu_texture_t = null; +let upscale_node_image: iron_gpu_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): iron_g5_texture_t { +function upscale_node_get_as_image(self: upscale_node_t, from: i32): iron_gpu_texture_t { upscale_node_image = logic_node_input_get_as_image(self.base.inputs[0]); console_progress(tr("Processing") + " - " + tr("Upscale")); @@ -24,7 +24,7 @@ function upscale_node_get_as_image(self: upscale_node_t, from: i32): iron_g5_tex 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: iron_g5_texture_t = upscale_node_image; + let last_image: iron_gpu_texture_t = upscale_node_image; upscale_node_image = upscale_node_esrgan(upscale_node_image); iron_unload_image(last_image); } @@ -36,12 +36,12 @@ 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): iron_g5_texture_t { +function upscale_node_get_cached_image(self: upscale_node_t): iron_gpu_texture_t { return upscale_node_image; } -function upscale_node_do_tile(source: iron_g5_texture_t): iron_g5_texture_t { - let result: iron_g5_texture_t = null; +function upscale_node_do_tile(source: iron_gpu_texture_t): iron_gpu_texture_t { + let result: iron_gpu_texture_t = null; let size1w: i32 = source.width; let size1h: i32 = source.height; let size2w: i32 = math_floor(size1w * 2); @@ -49,12 +49,12 @@ function upscale_node_do_tile(source: iron_g5_texture_t): iron_g5_texture_t { if (upscale_node_temp != null) { iron_unload_image(upscale_node_temp); } - upscale_node_temp = iron_g4_create_render_target(size1w, size1h); + upscale_node_temp = gpu_create_render_target(size1w, size1h); draw_begin(upscale_node_temp); draw_scaled_image(source, 0, 0, size1w, size1h); draw_end(); - let bytes_img: buffer_t = iron_g4_get_texture_pixels(upscale_node_temp); + let bytes_img: buffer_t = gpu_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) { @@ -87,12 +87,12 @@ function upscale_node_do_tile(source: iron_g5_texture_t): iron_g5_texture_t { u8a[i * 4 + 3] = 255; } - result = iron_g4_create_texture_from_bytes(u8a, size2w, size2h); + result = gpu_create_texture_from_bytes(u8a, size2w, size2h); return result; } -function upscale_node_esrgan(source: iron_g5_texture_t): iron_g5_texture_t { - let result: iron_g5_texture_t = null; +function upscale_node_esrgan(source: iron_gpu_texture_t): iron_gpu_texture_t { + let result: iron_gpu_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: iron_g5_texture_t): iron_g5_texture_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 = iron_g4_create_render_target(size2w, size2h); - let tile_source: iron_g5_texture_t = iron_g4_create_render_target(tile_size + 32 * 2, tile_size + 32 * 2); + result = gpu_create_render_target(size2w, size2h); + let tile_source: iron_gpu_texture_t = gpu_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) { draw_begin(tile_source); @@ -114,7 +114,7 @@ function upscale_node_esrgan(source: iron_g5_texture_t): iron_g5_texture_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); draw_end(); - let tile_result: iron_g5_texture_t = upscale_node_do_tile(tile_source); + let tile_result: iron_gpu_texture_t = upscale_node_do_tile(tile_source); draw_begin(result); draw_sub_image(tile_result, x * tile_size2x, y * tile_size2x, 64, 64, tile_size2x, tile_size2x); draw_end(); diff --git a/armorlab/sources/nodes/variance_node.ts b/armorlab/sources/nodes/variance_node.ts index d165f4bd..bcbdefac 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: iron_g5_texture_t = null; -let variance_node_image: iron_g5_texture_t = null; +let variance_node_temp: iron_gpu_texture_t = null; +let variance_node_image: iron_gpu_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 = iron_g4_create_render_target(512, 512); + variance_node_temp = gpu_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): iron_g5_texture_t { +function variance_node_get_as_image(self: variance_node_t, from: i32): iron_gpu_texture_t { let node: float_node_t = variance_node_inst.base.inputs[1].node; let strength: f32 = node.value; - let source: iron_g5_texture_t = logic_node_input_get_as_image(variance_node_inst.base.inputs[0]); + let source: iron_gpu_texture_t = logic_node_input_get_as_image(variance_node_inst.base.inputs[0]); draw_begin(variance_node_temp); draw_scaled_image(source, 0, 0, 512, 512); draw_end(); - let bytes_img: buffer_t = iron_g4_get_texture_pixels(variance_node_temp); + let bytes_img: buffer_t = gpu_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): iron_g5_t return variance_node_image; } -function variance_node_get_cached_image(self: variance_node_t): iron_g5_texture_t { +function variance_node_get_cached_image(self: variance_node_t): iron_gpu_texture_t { return variance_node_image; } diff --git a/armorlab/sources/render_path_paint.ts b/armorlab/sources/render_path_paint.ts index 854e0b5a..41b95b65 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 = 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); + let a: buffer_t = gpu_get_texture_pixels(texpaint_picker._image); + let b: buffer_t = gpu_get_texture_pixels(texpaint_nor_picker._image); + let c: buffer_t = gpu_get_texture_pixels(texpaint_pack_picker._image); + let d: buffer_t = gpu_get_texture_pixels(texpaint_uv_picker._image); if (context_raw.color_picker_callback != null) { context_raw.color_picker_callback(context_raw.picked_color); @@ -188,19 +188,19 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 let geom: mesh_data_t = plane.data; render_path_set_target(""); - iron_g5_set_pipeline(pipes_cursor); + iron_gpu_set_pipeline(pipes_cursor); let gbuffer0: render_target_t = map_get(render_path_render_targets, "gbuffer0"); - 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); + gpu_set_texture_depth(pipes_cursor_gbufferd, gbuffer0._image); + _gpu_set_float2(pipes_cursor_mouse, mx, my); + _gpu_set_float2(pipes_cursor_tex_step, 1 / gbuffer0._image.width, 1 / gbuffer0._image.height); + _gpu_set_float(pipes_cursor_radius, radius); let right: vec4_t = vec4_norm(camera_object_right_world(scene_camera)); - _iron_g4_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); - _iron_g4_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); - _iron_g4_set_matrix4(pipes_cursor_vp, scene_camera.vp); + _gpu_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); + _gpu_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); + _gpu_set_matrix4(pipes_cursor_vp, scene_camera.vp); let help_mat: mat4_t = mat4_identity(); help_mat = mat4_inv(scene_camera.vp); - _iron_g4_set_matrix4(pipes_cursor_inv_vp, help_mat); + _gpu_set_matrix4(pipes_cursor_inv_vp, help_mat); ///if (arm_metal || arm_vulkan) let vs: vertex_element_t[] = [ { @@ -208,14 +208,14 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 data: "short2norm" } ]; - iron_g4_set_vertex_buffer(mesh_data_get(geom, vs)); + gpu_set_vertex_buffer(mesh_data_get(geom, vs)); ///else - iron_g4_set_vertex_buffer(geom._.vertex_buffer); + gpu_set_vertex_buffer(geom._.vertex_buffer); ///end - iron_g4_set_index_buffer(geom._.index_buffers[0]); - iron_g4_draw_indexed_vertices(); + gpu_set_index_buffer(geom._.index_buffers[0]); + gpu_draw_indexed_vertices(); - iron_g4_disable_scissor(); + gpu_disable_scissor(); render_path_end(); } @@ -263,7 +263,7 @@ function render_path_paint_draw() { } function render_path_paint_bind_layers() { - let image: iron_g5_texture_t = null; + let image: iron_gpu_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 9268d1d2..37955b04 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: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.BASE_COLOR); - let texocc: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.OCCLUSION); - let texrough: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.ROUGHNESS); - let texnor: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.NORMAL_MAP); - let texheight: iron_g5_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.HEIGHT); + let texbase: iron_gpu_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.BASE_COLOR); + let texocc: iron_gpu_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.OCCLUSION); + let texrough: iron_gpu_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.ROUGHNESS); + let texnor: iron_gpu_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.NORMAL_MAP); + let texheight: iron_gpu_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"); @@ -78,13 +78,13 @@ function ui_nodes_ext_run() { } if (texheight != null) { - _iron_g4_begin(texpaint_pack._image); - iron_g5_set_pipeline(pipes_copy_a); - _iron_g4_set_texture(pipes_copy_a_tex, texheight); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(texpaint_pack._image); + iron_gpu_set_pipeline(pipes_copy_a); + _gpu_set_texture(pipes_copy_a_tex, texheight); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); let is_float_node: bool = context_raw.brush_output_node_inst.base.inputs[channel_type_t.HEIGHT].node.base.get == float_node_get; @@ -93,7 +93,7 @@ function ui_nodes_ext_run() { // Make copy of vertices before displacement let o: mesh_object_t = project_paint_objects[0]; let g: mesh_data_t = o.data; - let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); + let vertices: buffer_t = gpu_lock_vertex_buffer(g._.vertex_buffer); if (ui_nodes_ext_last_vertices == null || ui_nodes_ext_last_vertices.length != vertices.length) { ui_nodes_ext_last_vertices = buffer_create(vertices.length); for (let i: i32 = 0; i < math_floor((vertices.length) / 2); ++i) { @@ -105,7 +105,7 @@ function ui_nodes_ext_run() { buffer_set_i16(vertices, i * 2, buffer_get_i16(ui_nodes_ext_last_vertices, i * 2)); } } - iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + gpu_vertex_buffer_unlock_all(g._.vertex_buffer); // Apply displacement if (config_raw.displace_strength > 0) { diff --git a/armorlab/sources/ui_toolbar_ext.ts b/armorlab/sources/ui_toolbar_ext.ts index 545c9c36..a248ef64 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: iron_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: iron_gpu_texture_t, icon_accent: i32, keys: string[]) { } diff --git a/armorpaint/plugins/io_svg/nanosvg.c b/armorpaint/plugins/io_svg/nanosvg.c index eb3afa21..4d4a7d7f 100644 --- a/armorpaint/plugins/io_svg/nanosvg.c +++ b/armorpaint/plugins/io_svg/nanosvg.c @@ -9,7 +9,7 @@ #include "nanosvgrast.h" #include "iron_array.h" -void *iron_g4_create_texture_from_bytes(void *buffer, int width, int height, int format); +void *gpu_create_texture_from_bytes(void *buffer, int width, int height, int format); void *io_svg_parse(char *buf) { NSVGimage *image = nsvgParse(buf, "px", 96.0f); @@ -24,5 +24,5 @@ void *io_svg_parse(char *buf) { buffer_t *b = malloc(sizeof(buffer_t)); b->buffer = pixels; b->length = b->capacity = w * h * 4; - return iron_g4_create_texture_from_bytes(b, w, h, 0); + return gpu_create_texture_from_bytes(b, w, h, 0); } diff --git a/armorpaint/sources/layers_ext.ts b/armorpaint/sources/layers_ext.ts index c4cc792e..a9bb6a69 100644 --- a/armorpaint/sources/layers_ext.ts +++ b/armorpaint/sources/layers_ext.ts @@ -7,18 +7,18 @@ 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: iron_g5_texture_t = empty_rt._image; + let empty: iron_gpu_texture_t = empty_rt._image; // Clear export layer - _iron_g4_begin(layers_expa); - iron_g5_clear(color_from_floats(0.0, 0.0, 0.0, 0.0)); - _iron_g4_end(); - _iron_g4_begin(layers_expb); - iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); - _iron_g4_end(); - _iron_g4_begin(layers_expc); - iron_g5_clear(color_from_floats(1.0, 0.0, 0.0, 0.0)); - _iron_g4_end(); + _gpu_begin(layers_expa); + iron_gpu_clear(color_from_floats(0.0, 0.0, 0.0, 0.0)); + _gpu_end(); + _gpu_begin(layers_expb); + iron_gpu_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); + _gpu_end(); + _gpu_begin(layers_expc); + iron_gpu_clear(color_from_floats(1.0, 0.0, 0.0, 0.0)); + _gpu_end(); // Flatten layers for (let i: i32 = 0; i < layers.length; ++i) { @@ -30,13 +30,13 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t continue; } - let mask: iron_g5_texture_t = empty; + let mask: iron_gpu_texture_t = empty; let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); if (l1masks != null) { if (l1masks.length > 1) { layers_make_temp_mask_img(); draw_begin(pipes_temp_mask_image); - iron_g5_clear(0x00000000); + iron_gpu_clear(0x00000000); draw_end(); let l1: slot_layer_t = { texpaint: pipes_temp_mask_image }; for (let i: i32 = 0; i < l1masks.length; ++i) { @@ -64,18 +64,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t draw_set_pipeline(null); draw_end(); ///else - _iron_g4_begin(layers_expa); - iron_g5_set_pipeline(pipes_merge); - _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); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(layers_expa); + iron_gpu_set_pipeline(pipes_merge); + _gpu_set_texture(pipes_tex0, l1.texpaint); + _gpu_set_texture(pipes_tex1, empty); + _gpu_set_texture(pipes_texmask, mask); + _gpu_set_texture(pipes_texa, layers_temp_image); + _gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _gpu_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); ///end } @@ -86,18 +86,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t draw_set_pipeline(null); draw_end(); - _iron_g4_begin(layers_expb); - iron_g5_set_pipeline(pipes_merge); - _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); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(layers_expb); + iron_gpu_set_pipeline(pipes_merge); + _gpu_set_texture(pipes_tex0, l1.texpaint); + _gpu_set_texture(pipes_tex1, l1.texpaint_nor); + _gpu_set_texture(pipes_texmask, mask); + _gpu_set_texture(pipes_texa, layers_temp_image); + _gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _gpu_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); } if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { @@ -149,18 +149,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t draw_set_pipeline(null); draw_end(); - _iron_g4_begin(l0.texpaint_nor); - iron_g5_set_pipeline(pipes_merge); - _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); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(l0.texpaint_nor); + iron_gpu_set_pipeline(pipes_merge); + _gpu_set_texture(pipes_tex0, layers_temp_image); + _gpu_set_texture(pipes_tex1, l0.texpaint_pack); + _gpu_set_texture(pipes_texmask, empty); + _gpu_set_texture(pipes_texa, empty); + _gpu_set_float(pipes_opac, 1.0); + _gpu_set_int(pipes_blending, -4); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); } return l0; diff --git a/armorpaint/sources/make_material.ts b/armorpaint/sources/make_material.ts index 2d9c1a47..81560ba6 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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); make_material_bake_node_previews(); @@ -255,8 +255,8 @@ 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: iron_g5_texture_t = map_get(context_raw.node_previews, key); - app_notify_on_next_frame(function (image: iron_g5_texture_t) { + let image: iron_gpu_texture_t = map_get(context_raw.node_previews, key); + app_notify_on_next_frame(function (image: iron_gpu_texture_t) { iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); @@ -286,7 +286,7 @@ 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: iron_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_gpu_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); @@ -294,7 +294,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ if (image != null) { iron_unload_image(image); } - image = iron_g4_create_render_target(res_x, res_y); + image = gpu_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: iron_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_gpu_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) iron_unload_image(image); - image = iron_g4_create_render_target(res_x, res_y); + image = gpu_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); } @@ -320,7 +320,7 @@ 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: iron_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_gpu_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()); @@ -328,7 +328,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ if (image != null) { iron_unload_image(image); } - image = iron_g4_create_render_target(res_x, res_y, tex_format_t.R8); + image = gpu_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 05406a7c..c5ecdfe4 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: iron_g5_texture_t = context_raw.brush_mask_image; - let last_stencil: iron_g5_texture_t = context_raw.brush_stencil_image; + let last_mask: iron_gpu_texture_t = context_raw.brush_mask_image; + let last_stencil: iron_gpu_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 161c4ce3..f6fb5f11 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: iron_g5_texture_t = picker0._image; - let texpaint_posnortex_picker1: iron_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); + let texpaint_posnortex_picker0: iron_gpu_texture_t = picker0._image; + let texpaint_posnortex_picker1: iron_gpu_texture_t = picker1._image; + let a: buffer_t = gpu_get_texture_pixels(texpaint_posnortex_picker0); + let b: buffer_t = gpu_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 = 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); + let a: buffer_t = gpu_get_texture_pixels(texpaint_picker._image); + let b: buffer_t = gpu_get_texture_pixels(texpaint_nor_picker._image); + let c: buffer_t = gpu_get_texture_pixels(texpaint_pack_picker._image); + let d: buffer_t = gpu_get_texture_pixels(texpaint_uv_picker._image); if (context_raw.color_picker_callback != null) { context_raw.color_picker_callback(context_raw.picked_color); @@ -439,20 +439,20 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 let geom: mesh_data_t = plane.data; render_path_set_target(""); - iron_g5_set_pipeline(pipes_cursor); + iron_gpu_set_pipeline(pipes_cursor); let rt: render_target_t = map_get(render_path_render_targets, "gbuffer0"); - let gbuffer0: iron_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); + let gbuffer0: iron_gpu_texture_t = rt._image; + gpu_set_texture_depth(pipes_cursor_gbufferd, gbuffer0); + _gpu_set_float2(pipes_cursor_mouse, mx, my); + _gpu_set_float2(pipes_cursor_tex_step, 1 / gbuffer0.width, 1 / gbuffer0.height); + _gpu_set_float(pipes_cursor_radius, radius); let right: vec4_t = vec4_norm(camera_object_right_world(scene_camera)); - _iron_g4_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); - _iron_g4_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); - _iron_g4_set_matrix4(pipes_cursor_vp, scene_camera.vp); + _gpu_set_float3(pipes_cursor_camera_right, right.x, right.y, right.z); + _gpu_set_float3(pipes_cursor_tint, tint_r, tint_g, tint_b); + _gpu_set_matrix4(pipes_cursor_vp, scene_camera.vp); let help_mat: mat4_t = mat4_identity(); help_mat = mat4_inv(scene_camera.vp); - _iron_g4_set_matrix4(pipes_cursor_inv_vp, help_mat); + _gpu_set_matrix4(pipes_cursor_inv_vp, help_mat); ///if (arm_metal || arm_vulkan) let vs: vertex_element_t[] = [ { @@ -460,14 +460,14 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 data: "short2norm" } ]; - iron_g4_set_vertex_buffer(mesh_data_get(geom, vs)); + gpu_set_vertex_buffer(mesh_data_get(geom, vs)); ///else - iron_g4_set_vertex_buffer(geom._.vertex_buffer); + gpu_set_vertex_buffer(geom._.vertex_buffer); ///end - iron_g4_set_index_buffer(geom._.index_buffers[0]); - iron_g4_draw_indexed_vertices(); + gpu_set_index_buffer(geom._.index_buffers[0]); + gpu_draw_indexed_vertices(); - iron_g4_disable_scissor(); + gpu_disable_scissor(); render_path_end(); } diff --git a/armorpaint/sources/ui_header_ext.ts b/armorpaint/sources/ui_header_ext.ts index 4add4969..31b60a10 100644 --- a/armorpaint/sources/ui_header_ext.ts +++ b/armorpaint/sources/ui_header_ext.ts @@ -52,15 +52,15 @@ function ui_header_draw_tool_properties(ui: ui_t) { } let m: slot_layer_t = layers_new_mask(false, context_raw.layer); app_notify_on_next_frame(function (m: slot_layer_t) { - _iron_g4_begin(m.texpaint); - iron_g5_set_pipeline(pipes_colorid_to_mask); + _gpu_begin(m.texpaint); + iron_gpu_set_pipeline(pipes_colorid_to_mask); let rt: render_target_t = map_get(render_path_render_targets, "texpaint_colorid"); - _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])); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_set_texture(pipes_texpaint_colorid, rt._image); + _gpu_set_texture(pipes_tex_colorid, project_get_image(project_assets[context_raw.colorid_handle.position])); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); context_raw.colorid_picked = false; ui_toolbar_handle.redraws = 1; ui_header_handle.redraws = 1; @@ -178,7 +178,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { tr("Object ID"), tr("Vertex Color"), ]; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { array_push(bakes, tr("Lightmap")); array_push(bakes, tr("Bent Normal")); array_push(bakes, tr("Thickness")); @@ -189,7 +189,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { context_raw.bake_type = ui_combo(bake_handle, bakes, tr("Bake")); - if (!iron_g5_raytrace_supported()) { + if (!iron_gpu_raytrace_supported()) { context_raw.bake_type += 1; // Offset for removed AO } @@ -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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; draw_end(); util_render_make_decal_preview(); draw_begin(current); @@ -423,7 +423,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { ui._w = w; if (h.changed) { - let current: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; draw_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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; draw_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 2dac0279..5501e645 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: iron_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: iron_gpu_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 96befa01..1becbdaf 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: iron_g5_texture_t = project_layers[0].texpaint; - let pixels: buffer_t = iron_g4_get_texture_pixels(texpaint); + let texpaint: iron_gpu_texture_t = project_layers[0].texpaint; + let pixels: buffer_t = gpu_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 d3a6e5c4..e2141092 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: iron_g5_texture_t = iron_g4_create_texture_from_bytes(b, config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.RGBA128); - let texpaint: iron_g5_texture_t = project_layers[0].texpaint; + let imgmesh: iron_gpu_texture_t = gpu_create_texture_from_bytes(b, config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.RGBA128); + let texpaint: iron_gpu_texture_t = project_layers[0].texpaint; draw_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 328729d9..aaa9a0ec 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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); make_material_bake_node_previews(); @@ -232,8 +232,8 @@ 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: iron_g5_texture_t = map_get(context_raw.node_previews, key); - app_notify_on_next_frame(function (image: iron_g5_texture_t) { + let image: iron_gpu_texture_t = map_get(context_raw.node_previews, key); + app_notify_on_next_frame(function (image: iron_gpu_texture_t) { iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); @@ -263,7 +263,7 @@ 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: iron_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_gpu_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); @@ -271,7 +271,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ if (image != null) { iron_unload_image(image); } - image = iron_g4_create_render_target(res_x, res_y); + image = gpu_create_render_target(res_x, res_y); map_set(context_raw.node_previews, id, image); } @@ -281,7 +281,7 @@ 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: iron_g5_texture_t = map_get(context_raw.node_previews, id); + let image: iron_gpu_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()); @@ -289,7 +289,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_ if (image != null) { iron_unload_image(image); } - image = iron_g4_create_render_target(res_x, res_y); + image = gpu_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 8b6128c2..6c140c7e 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: iron_g5_texture_t = context_raw.brush_mask_image; - let last_stencil: iron_g5_texture_t = context_raw.brush_stencil_image; + let last_mask: iron_gpu_texture_t = context_raw.brush_mask_image; + let last_stencil: iron_gpu_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/render_path_sculpt.ts b/armorsculpt/sources/render_path_sculpt.ts index 3ebd46a0..ebff2a80 100644 --- a/armorsculpt/sources/render_path_sculpt.ts +++ b/armorsculpt/sources/render_path_sculpt.ts @@ -29,13 +29,13 @@ function render_path_sculpt_commands() { mesh_object_get_contexts(project_paint_objects[0], "paint", mats, material_contexts, shader_contexts); let cc_context: shader_context_t = shader_contexts[0]; - iron_g5_set_pipeline(cc_context._.pipe_state); + iron_gpu_set_pipeline(cc_context._.pipe_state); uniforms_set_context_consts(cc_context,_render_path_bind_params); uniforms_set_obj_consts(cc_context, project_paint_objects[0].base); uniforms_set_material_consts(cc_context, material_contexts[0]); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); render_path_end(); } diff --git a/armorsculpt/sources/tab_layers.ts b/armorsculpt/sources/tab_layers.ts index 67638637..3df8b229 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: iron_g5_texture_t = resource_get("icons.k"); + let icons: iron_gpu_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 7592d93a..c588eed6 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: iron_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: iron_gpu_texture_t, icon_accent: i32, keys: string[]) { ui_toolbar_draw_tool(workspace_tool_t.BRUSH, ui, img, icon_accent, keys); } diff --git a/base/assets/plugins/import_tiff.js b/base/assets/plugins/import_tiff.js index e905ed56..ce8a289e 100644 --- a/base/assets/plugins/import_tiff.js +++ b/base/assets/plugins/import_tiff.js @@ -8,7 +8,7 @@ function import_tiff(path) { let ifds = UTIF.decode(b); UTIF.decodeImage(b, ifds[0]); let rgba = UTIF.toRGBA8(ifds[0]); - let image = iron_g4_create_texture_from_bytes(rgba.buffer, ifds[0].width, ifds[0].height); + let image = gpu_create_texture_from_bytes(rgba.buffer, ifds[0].width, ifds[0].height); return image; } diff --git a/base/plugins/plugin_api.c b/base/plugins/plugin_api.c index e3252a78..b323eedb 100644 --- a/base/plugins/plugin_api.c +++ b/base/plugins/plugin_api.c @@ -449,8 +449,8 @@ FN(node_shader_add_uniform) { VOID_FN_PTR_STR(node_shader_write) -void *iron_g4_create_texture_from_bytes(void *p, int w, int h, int format); -FN(iron_g4_create_texture_from_bytes) { +void *gpu_create_texture_from_bytes(void *p, int w, int h, int format); +FN(gpu_create_texture_from_bytes) { size_t len; void *ab = JS_GetArrayBuffer(ctx, &len, argv[0]); buffer_t b = { .buffer = ab, .length = len, .capacity = len }; @@ -458,7 +458,7 @@ FN(iron_g4_create_texture_from_bytes) { JS_ToInt64(ctx, &w, argv[1]); int64_t h; JS_ToInt64(ctx, &h, argv[2]); - int64_t result = (int64_t)iron_g4_create_texture_from_bytes(&b, w, h, 0); + int64_t result = (int64_t)gpu_create_texture_from_bytes(&b, w, h, 0); return JS_NewInt64(ctx, result); } @@ -810,7 +810,7 @@ void plugin_api_init() { BIND(context_set_viewport_shader, 1); BIND(node_shader_add_uniform, 3); BIND(node_shader_write, 2); - BIND(iron_g4_create_texture_from_bytes, 3); + BIND(gpu_create_texture_from_bytes, 3); BIND(project_filepath_get, 0); BIND(project_save, 0); diff --git a/base/sources/backends/android_system.c b/base/sources/backends/android_system.c index 7cd4ad6f..14dcd2d7 100644 --- a/base/sources/backends/android_system.c +++ b/base/sources/backends/android_system.c @@ -846,7 +846,7 @@ static void cmd(struct android_app *app, int32_t cmd) { } else { initDisplay(); - iron_g5_swap_buffers(); + iron_gpu_swap_buffers(); } updateAppForegroundStatus(true, appIsForeground); @@ -1213,8 +1213,8 @@ void iron_init(const char *name, int width, int height, struct iron_window_optio win->width = width; win->height = height; - iron_g5_internal_init(); - iron_g4_internal_init_window(win->depth_bits, true); + iron_gpu_internal_init(); + gpu_internal_init_window(win->depth_bits, true); iron_internal_gamepad_trigger_connect(0); } diff --git a/base/sources/backends/android_video.c b/base/sources/backends/android_video.c index a5296084..9402e495 100644 --- a/base/sources/backends/android_video.c +++ b/base/sources/backends/android_video.c @@ -85,7 +85,7 @@ // return 512; // } -// iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { +// iron_gpu_texture_t *iron_video_current_image(iron_video_t *video) { // return NULL; // } diff --git a/base/sources/backends/android_video.h b/base/sources/backends/android_video.h index b6bc25bc..75144894 100644 --- a/base/sources/backends/android_video.h +++ b/base/sources/backends/android_video.h @@ -13,7 +13,7 @@ // void *sound; // void *androidVideo; // int id; -// iron_g5_texture_t image; +// iron_gpu_texture_t image; // double lastTime; // int myWidth; // int myHeight; diff --git a/base/sources/backends/apple_video.h b/base/sources/backends/apple_video.h index 59448777..9498532f 100644 --- a/base/sources/backends/apple_video.h +++ b/base/sources/backends/apple_video.h @@ -12,7 +12,7 @@ // bool loop; // void *sound; // bool image_initialized; -// iron_g5_texture_t image; +// iron_gpu_texture_t image; // double lastTime; // float duration; // bool finished; diff --git a/base/sources/backends/apple_video.m b/base/sources/backends/apple_video.m index 102ab7f0..a5f55c5c 100644 --- a/base/sources/backends/apple_video.m +++ b/base/sources/backends/apple_video.m @@ -228,13 +228,13 @@ // CGSize size = CVImageBufferGetDisplaySize(pixelBuffer); // video->impl.myWidth = size.width; // video->impl.myHeight = size.height; -// iron_g5_texture_init(&video->impl.image, iron_video_width(video), iron_video_height(video), IRON_IMAGE_FORMAT_BGRA32); +// iron_gpu_texture_init(&video->impl.image, iron_video_width(video), iron_video_height(video), IRON_IMAGE_FORMAT_BGRA32); // video->impl.image_initialized = true; // } // if (pixelBuffer != NULL) { // CVPixelBufferLockBaseAddress(pixelBuffer, 0); -// // iron_g4_texture_upload(&video->impl.image, (uint8_t *)CVPixelBufferGetBaseAddress(pixelBuffer), (int)(CVPixelBufferGetBytesPerRow(pixelBuffer))); +// // gpu_texture_upload(&video->impl.image, (uint8_t *)CVPixelBufferGetBaseAddress(pixelBuffer), (int)(CVPixelBufferGetBytesPerRow(pixelBuffer))); // CVPixelBufferUnlockBaseAddress(pixelBuffer, 0); // } // CFRelease(buffer); @@ -283,7 +283,7 @@ // return video->impl.myHeight; // } -// iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { +// iron_gpu_texture_t *iron_video_current_image(iron_video_t *video) { // iron_video_update(video, iron_time()); // return &video->impl.image; // } diff --git a/base/sources/backends/direct3d12_gpu.c b/base/sources/backends/direct3d12_gpu.c index 23ca6c10..f02b64ec 100644 --- a/base/sources/backends/direct3d12_gpu.c +++ b/base/sources/backends/direct3d12_gpu.c @@ -416,16 +416,16 @@ static void initWindow(struct dx_window *window) { setupSwapChain(window); } -void iron_g5_internal_destroy_window() {} +void iron_gpu_internal_destroy_window() {} -void iron_g5_internal_destroy() { +void iron_gpu_internal_destroy() { if (device) { device->lpVtbl->Release(device); device = NULL; } } -void iron_g5_internal_init() { +void iron_gpu_internal_init() { #ifdef _DEBUG ID3D12Debug *debugController = NULL; if (D3D12GetDebugInterface(&IID_ID3D12Debug, &debugController) == S_OK) { @@ -464,7 +464,7 @@ void iron_g5_internal_init() { CloseHandle(waitEvent); } -void iron_g5_internal_init_window(int depthBufferBits, bool verticalSync) { +void iron_gpu_internal_init_window(int depthBufferBits, bool verticalSync) { struct dx_window *window = &dx_ctx.windows[0]; window->vsync = verticalSync; window->width = window->new_width = iron_window_width(); @@ -472,13 +472,13 @@ void iron_g5_internal_init_window(int depthBufferBits, bool verticalSync) { initWindow(window); } -int iron_g5_max_bound_textures(void) { +int iron_gpu_max_bound_textures(void) { return D3D12_COMMONSHADER_SAMPLER_SLOT_COUNT; } static bool began = false; -void iron_g5_begin(iron_g5_texture_t *renderTarget) { +void iron_gpu_begin(iron_gpu_texture_t *renderTarget) { if (began) return; began = true; @@ -512,11 +512,11 @@ void iron_g5_begin(iron_g5_texture_t *renderTarget) { // commandList->ClearDepthStencilView(GetCPUDescriptorHandle(depthStencilDescriptorHeap), D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr); } -void iron_g5_end() { +void iron_gpu_end() { began = false; } -void iron_g5_internal_resize(int, int); +void iron_gpu_internal_resize(int, int); void iron_internal_resize(int width, int height) { if (width == 0 || height == 0) @@ -524,10 +524,10 @@ void iron_internal_resize(int width, int height) { struct dx_window *window = &dx_ctx.windows[0]; window->new_width = width; window->new_height = height; - iron_g5_internal_resize(width, height); + iron_gpu_internal_resize(width, height); } -bool iron_g5_swap_buffers() { +bool iron_gpu_swap_buffers() { for (int i = 0; i < MAXIMUM_WINDOWS; i++) { struct dx_window *window = &dx_ctx.windows[i]; if (window->swapChain) { @@ -537,9 +537,9 @@ bool iron_g5_swap_buffers() { return true; } -void iron_g5_flush() {} +void iron_gpu_flush() {} -bool iron_g5_raytrace_supported() { +bool iron_gpu_raytrace_supported() { D3D12_FEATURE_DATA_D3D12_OPTIONS5 options; if (device->lpVtbl->CheckFeatureSupport(device, D3D12_FEATURE_D3D12_OPTIONS5, &options, sizeof(options)) == S_OK) { return options.RaytracingTier >= D3D12_RAYTRACING_TIER_1_0; @@ -547,7 +547,7 @@ bool iron_g5_raytrace_supported() { return false; } -void createHeaps(iron_g5_command_list_t *list); +void createHeaps(iron_gpu_command_list_t *list); static int formatSize(DXGI_FORMAT format) { switch (format) { @@ -564,7 +564,7 @@ static int formatSize(DXGI_FORMAT format) { } } -void iron_g5_command_list_init(struct iron_g5_command_list *list) { +void iron_gpu_command_list_init(struct iron_gpu_command_list *list) { #ifndef NDEBUG list->impl.open = false; #endif @@ -588,11 +588,11 @@ void iron_g5_command_list_init(struct iron_g5_command_list *list) { createHeaps(list); } -void iron_g5_command_list_destroy(struct iron_g5_command_list *list) {} +void iron_gpu_command_list_destroy(struct iron_gpu_command_list *list) {} -void iron_g5_internal_reset_textures(struct iron_g5_command_list *list); +void iron_gpu_internal_reset_textures(struct iron_gpu_command_list *list); -void iron_g5_command_list_begin(struct iron_g5_command_list *list) { +void iron_gpu_command_list_begin(struct iron_gpu_command_list *list) { assert(!list->impl.open); compute_pipeline_set = false; @@ -603,14 +603,14 @@ void iron_g5_command_list_begin(struct iron_g5_command_list *list) { list->impl._commandList->lpVtbl->Reset(list->impl._commandList, list->impl._commandAllocator, NULL); } - iron_g5_internal_reset_textures(list); + iron_gpu_internal_reset_textures(list); #ifndef NDEBUG list->impl.open = true; #endif } -void iron_g5_command_list_end(struct iron_g5_command_list *list) { +void iron_gpu_command_list_end(struct iron_gpu_command_list *list) { assert(list->impl.open); list->impl._commandList->lpVtbl->Close(list->impl._commandList); @@ -620,10 +620,10 @@ void iron_g5_command_list_end(struct iron_g5_command_list *list) { #endif } -void iron_g5_command_list_clear(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget, unsigned flags, unsigned color, float depth) { +void iron_gpu_command_list_clear(struct iron_gpu_command_list *list, iron_gpu_texture_t *renderTarget, unsigned flags, unsigned color, float depth) { assert(list->impl.open); - if (flags & IRON_G5_CLEAR_COLOR) { + if (flags & IRON_GPU_CLEAR_COLOR) { float clearColor[] = {((color & 0x00ff0000) >> 16) / 255.0f, ((color & 0x0000ff00) >> 8) / 255.0f, (color & 0x000000ff) / 255.0f, ((color & 0xff000000) >> 24) / 255.0f}; @@ -637,7 +637,7 @@ void iron_g5_command_list_clear(struct iron_g5_command_list *list, iron_g5_textu 0, NULL); } - if (flags & IRON_G5_CLEAR_DEPTH) { + if (flags & IRON_GPU_CLEAR_DEPTH) { D3D12_CLEAR_FLAGS d3dflags = D3D12_CLEAR_FLAG_DEPTH; if (renderTarget->impl.depthStencilDescriptorHeap != NULL) { @@ -652,7 +652,7 @@ void iron_g5_command_list_clear(struct iron_g5_command_list *list, iron_g5_textu } } -void iron_g5_command_list_render_target_to_framebuffer_barrier(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget) { +void iron_gpu_command_list_render_target_to_framebuffer_barrier(struct iron_gpu_command_list *list, iron_gpu_texture_t *renderTarget) { assert(list->impl.open); D3D12_RESOURCE_BARRIER barrier; @@ -666,7 +666,7 @@ void iron_g5_command_list_render_target_to_framebuffer_barrier(struct iron_g5_co list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } -void iron_g5_command_list_framebuffer_to_render_target_barrier(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget) { +void iron_gpu_command_list_framebuffer_to_render_target_barrier(struct iron_gpu_command_list *list, iron_gpu_texture_t *renderTarget) { assert(list->impl.open); D3D12_RESOURCE_BARRIER barrier; @@ -680,7 +680,7 @@ void iron_g5_command_list_framebuffer_to_render_target_barrier(struct iron_g5_co list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } -void iron_g5_command_list_texture_to_render_target_barrier(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget) { +void iron_gpu_command_list_texture_to_render_target_barrier(struct iron_gpu_command_list *list, iron_gpu_texture_t *renderTarget) { assert(list->impl.open); D3D12_RESOURCE_BARRIER barrier; @@ -694,7 +694,7 @@ void iron_g5_command_list_texture_to_render_target_barrier(struct iron_g5_comman list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } -void iron_g5_command_list_render_target_to_texture_barrier(struct iron_g5_command_list *list, iron_g5_texture_t *renderTarget) { +void iron_gpu_command_list_render_target_to_texture_barrier(struct iron_gpu_command_list *list, iron_gpu_texture_t *renderTarget) { assert(list->impl.open); D3D12_RESOURCE_BARRIER barrier; @@ -708,32 +708,32 @@ void iron_g5_command_list_render_target_to_texture_barrier(struct iron_g5_comman list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } -void iron_g5_command_list_set_vertex_constant_buffer(struct iron_g5_command_list *list, iron_g5_constant_buffer_t *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_vertex_constant_buffer(struct iron_gpu_command_list *list, iron_gpu_constant_buffer_t *buffer, int offset, size_t size) { assert(list->impl.open); list->impl._commandList->lpVtbl->SetGraphicsRootConstantBufferView(list->impl._commandList, 2, buffer->impl.constant_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.constant_buffer) + offset); } -void iron_g5_command_list_set_fragment_constant_buffer(struct iron_g5_command_list *list, iron_g5_constant_buffer_t *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_fragment_constant_buffer(struct iron_gpu_command_list *list, iron_gpu_constant_buffer_t *buffer, int offset, size_t size) { assert(list->impl.open); list->impl._commandList->lpVtbl->SetGraphicsRootConstantBufferView(list->impl._commandList, 3, buffer->impl.constant_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.constant_buffer) + offset); } -void iron_g5_command_list_set_compute_constant_buffer(struct iron_g5_command_list *list, iron_g5_constant_buffer_t *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_compute_constant_buffer(struct iron_gpu_command_list *list, iron_gpu_constant_buffer_t *buffer, int offset, size_t size) { assert(list->impl.open); list->impl._commandList->lpVtbl->SetComputeRootConstantBufferView(list->impl._commandList, 3, buffer->impl.constant_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.constant_buffer) + offset); } -void iron_g5_command_list_draw_indexed_vertices(struct iron_g5_command_list *list) { - iron_g5_command_list_draw_indexed_vertices_from_to(list, 0, list->impl._indexCount); +void iron_gpu_command_list_draw_indexed_vertices(struct iron_gpu_command_list *list) { + iron_gpu_command_list_draw_indexed_vertices_from_to(list, 0, list->impl._indexCount); } -void iron_g5_command_list_draw_indexed_vertices_from_to(struct iron_g5_command_list *list, int start, int count) { +void iron_gpu_command_list_draw_indexed_vertices_from_to(struct iron_gpu_command_list *list, int start, int count) { assert(list->impl.open); list->impl._commandList->lpVtbl->IASetPrimitiveTopology(list->impl._commandList, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); list->impl._commandList->lpVtbl->DrawIndexedInstanced(list->impl._commandList, count, 1, start, 0, 0); } -void iron_g5_command_list_execute(iron_g5_command_list_t *list) { +void iron_gpu_command_list_execute(iron_gpu_command_list_t *list) { assert(!list->impl.open); ID3D12CommandList *commandLists[] = {(ID3D12CommandList *)list->impl._commandList}; @@ -742,15 +742,15 @@ void iron_g5_command_list_execute(iron_g5_command_list_t *list) { commandQueue->lpVtbl->Signal(commandQueue, list->impl.fence, ++list->impl.fence_value); } -void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list) { +void iron_gpu_command_list_wait_for_execution_to_finish(iron_gpu_command_list_t *list) { waitForFence(list->impl.fence, list->impl.fence_value, list->impl.fence_event); } -bool iron_g5_non_pow2_textures_supported(void) { +bool iron_gpu_non_pow2_textures_supported(void) { return true; } -void iron_g5_command_list_viewport(struct iron_g5_command_list *list, int x, int y, int width, int height) { +void iron_gpu_command_list_viewport(struct iron_gpu_command_list *list, int x, int y, int width, int height) { assert(list->impl.open); D3D12_VIEWPORT viewport; @@ -763,7 +763,7 @@ void iron_g5_command_list_viewport(struct iron_g5_command_list *list, int x, int list->impl._commandList->lpVtbl->RSSetViewports(list->impl._commandList, 1, &viewport); } -void iron_g5_command_list_scissor(struct iron_g5_command_list *list, int x, int y, int width, int height) { +void iron_gpu_command_list_scissor(struct iron_gpu_command_list *list, int x, int y, int width, int height) { assert(list->impl.open); D3D12_RECT scissor; @@ -774,7 +774,7 @@ void iron_g5_command_list_scissor(struct iron_g5_command_list *list, int x, int list->impl._commandList->lpVtbl->RSSetScissorRects(list->impl._commandList, 1, &scissor); } -void iron_g5_command_list_disable_scissor(struct iron_g5_command_list *list) { +void iron_gpu_command_list_disable_scissor(struct iron_gpu_command_list *list) { assert(list->impl.open); if (list->impl.current_full_scissor.left >= 0) { @@ -790,7 +790,7 @@ void iron_g5_command_list_disable_scissor(struct iron_g5_command_list *list) { } } -void iron_g5_command_list_set_pipeline(struct iron_g5_command_list *list, iron_g5_pipeline_t *pipeline) { +void iron_gpu_command_list_set_pipeline(struct iron_gpu_command_list *list, iron_gpu_pipeline_t *pipeline) { assert(list->impl.open); list->impl._currentPipeline = pipeline; @@ -800,33 +800,33 @@ void iron_g5_command_list_set_pipeline(struct iron_g5_command_list *list, iron_g for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { list->impl.currentTextures[i] = NULL; } - iron_g5_internal_setConstants(list, list->impl._currentPipeline); + iron_gpu_internal_setConstants(list, list->impl._currentPipeline); } -void iron_g5_command_list_set_vertex_buffer(struct iron_g5_command_list *list, iron_g5_vertex_buffer_t *buffer) { +void iron_gpu_command_list_set_vertex_buffer(struct iron_gpu_command_list *list, iron_gpu_vertex_buffer_t *buffer) { assert(list->impl.open); D3D12_VERTEX_BUFFER_VIEW *views = (D3D12_VERTEX_BUFFER_VIEW *)alloca(sizeof(D3D12_VERTEX_BUFFER_VIEW) * 1); ZeroMemory(views, sizeof(D3D12_VERTEX_BUFFER_VIEW) * 1); views[0].BufferLocation = buffer->impl.uploadBuffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.uploadBuffer); - views[0].SizeInBytes = (iron_g5_vertex_buffer_count(buffer)) * iron_g5_vertex_buffer_stride(buffer); - views[0].StrideInBytes = iron_g5_vertex_buffer_stride(buffer); + views[0].SizeInBytes = (iron_gpu_vertex_buffer_count(buffer)) * iron_gpu_vertex_buffer_stride(buffer); + views[0].StrideInBytes = iron_gpu_vertex_buffer_stride(buffer); list->impl._commandList->lpVtbl->IASetVertexBuffers(list->impl._commandList, 0, 1, views); } -void iron_g5_command_list_set_index_buffer(struct iron_g5_command_list *list, iron_g5_index_buffer_t *buffer) { +void iron_gpu_command_list_set_index_buffer(struct iron_gpu_command_list *list, iron_gpu_index_buffer_t *buffer) { assert(list->impl.open); - list->impl._indexCount = iron_g5_index_buffer_count(buffer); + list->impl._indexCount = iron_gpu_index_buffer_count(buffer); list->impl._commandList->lpVtbl->IASetIndexBuffer(list->impl._commandList, (D3D12_INDEX_BUFFER_VIEW *) & buffer->impl.index_buffer_view); } -void iron_g5_command_list_set_render_targets(struct iron_g5_command_list *list, iron_g5_texture_t **targets, int count) { +void iron_gpu_command_list_set_render_targets(struct iron_gpu_command_list *list, iron_gpu_texture_t **targets, int count) { assert(list->impl.open); - iron_g5_texture_t *render_target = targets[0]; + iron_gpu_texture_t *render_target = targets[0]; D3D12_CPU_DESCRIPTOR_HANDLE target_descriptors[16]; for (int i = 0; i < count; ++i) { @@ -851,14 +851,14 @@ void iron_g5_command_list_set_render_targets(struct iron_g5_command_list *list, list->impl.current_full_scissor = render_target->impl.scissor; } -void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) {} +void iron_gpu_command_list_upload_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_vertex_buffer *buffer) {} -void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, iron_g5_index_buffer_t *buffer) { +void iron_gpu_command_list_upload_index_buffer(iron_gpu_command_list_t *list, iron_gpu_index_buffer_t *buffer) { assert(list->impl.open); - iron_g5_internal_index_buffer_upload(buffer, list->impl._commandList); + iron_gpu_internal_index_buffer_upload(buffer, list->impl._commandList); } -void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, iron_g5_texture_t *texture) { +void iron_gpu_command_list_upload_texture(iron_gpu_command_list_t *list, iron_gpu_texture_t *texture) { assert(list->impl.open); { @@ -910,7 +910,7 @@ static int d3d12_textureAlignment() { return D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; } -void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, iron_g5_texture_t *render_target, uint8_t *data) { +void iron_gpu_command_list_get_render_target_pixels(iron_gpu_command_list_t *list, iron_gpu_texture_t *render_target, uint8_t *data) { assert(list->impl.open); D3D12_RESOURCE_DESC desc; @@ -990,10 +990,10 @@ void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, list->impl._commandList->lpVtbl->ResourceBarrier(list->impl._commandList, 1, &barrier); } - iron_g5_command_list_end(list); - iron_g5_command_list_execute(list); - iron_g5_command_list_wait_for_execution_to_finish(list); - iron_g5_command_list_begin(list); + iron_gpu_command_list_end(list); + iron_gpu_command_list_execute(list); + iron_gpu_command_list_wait_for_execution_to_finish(list); + iron_gpu_command_list_begin(list); // Read buffer void *p; @@ -1002,60 +1002,60 @@ void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, render_target->impl.renderTargetReadback->lpVtbl->Unmap(render_target->impl.renderTargetReadback, 0, NULL); } -void iron_g5_internal_set_compute_constants(iron_g5_command_list_t *commandList); +void iron_gpu_internal_set_compute_constants(iron_gpu_command_list_t *commandList); -void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, iron_g5_compute_shader *shader) { +void iron_gpu_command_list_set_compute_shader(iron_gpu_command_list_t *list, iron_gpu_compute_shader *shader) { list->impl._commandList->lpVtbl->SetPipelineState(list->impl._commandList, shader->impl.pso); compute_pipeline_set = true; for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { list->impl.currentTextures[i] = NULL; } - iron_g5_internal_set_compute_constants(list); + iron_gpu_internal_set_compute_constants(list); } -void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z) { +void iron_gpu_command_list_compute(iron_gpu_command_list_t *list, int x, int y, int z) { assert(list->impl.open); list->impl._commandList->lpVtbl->Dispatch(list->impl._commandList, x, y, z); } -void iron_g5_internal_sampler_set(iron_g5_command_list_t *list, iron_g5_sampler_t *sampler, int unit); +void iron_gpu_internal_sampler_set(iron_gpu_command_list_t *list, iron_gpu_sampler_t *sampler, int unit); -void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler) { - if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { - iron_g5_internal_sampler_set(list, sampler, unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]); +void iron_gpu_command_list_set_sampler(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_sampler_t *sampler) { + if (unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] >= 0) { + iron_gpu_internal_sampler_set(list, sampler, unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]); } - else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { - iron_g5_internal_sampler_set(list, sampler, unit.stages[IRON_G5_SHADER_TYPE_VERTEX]); + else if (unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] >= 0) { + iron_gpu_internal_sampler_set(list, sampler, unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]); } - iron_g5_internal_set_textures(list); + iron_gpu_internal_set_textures(list); } -void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { - if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { - texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]; +void iron_gpu_command_list_set_texture(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *texture) { + if (unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] >= 0) { + texture->impl.stage = unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]; } - else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { - texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_VERTEX]; + else if (unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] >= 0) { + texture->impl.stage = unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]; } - else if (unit.stages[IRON_G5_SHADER_TYPE_COMPUTE] >= 0) { - texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_COMPUTE]; + else if (unit.stages[IRON_GPU_SHADER_TYPE_COMPUTE] >= 0) { + texture->impl.stage = unit.stages[IRON_GPU_SHADER_TYPE_COMPUTE]; } list->impl.currentTextures[texture->impl.stage] = texture; - iron_g5_internal_set_textures(list); + iron_gpu_internal_set_textures(list); } -void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { - if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { - texture->impl.stage_depth = unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]; +void iron_gpu_command_list_set_texture_from_render_target_depth(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *texture) { + if (unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] >= 0) { + texture->impl.stage_depth = unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]; } - else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { - texture->impl.stage_depth = unit.stages[IRON_G5_SHADER_TYPE_VERTEX]; + else if (unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] >= 0) { + texture->impl.stage_depth = unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]; } list->impl.currentTextures[texture->impl.stage_depth] = texture; } -void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *_data, int length) { +void iron_gpu_compute_shader_init(iron_gpu_compute_shader *shader, void *_data, int length) { unsigned index = 0; uint8_t *data = (uint8_t *)_data; @@ -1130,7 +1130,7 @@ void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *_data, in // &shader->impl.constantBuffer)); } -void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader) { +void iron_gpu_compute_shader_destroy(iron_gpu_compute_shader *shader) { if (shader->impl.pso != NULL) { shader->impl.pso->lpVtbl->Release(shader->impl.pso); shader->impl.pso = NULL; @@ -1155,8 +1155,8 @@ static iron_internal_hash_index_t *findComputeTextureUnit(iron_internal_hash_ind return NULL; } -iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name) { - iron_g5_constant_location_t location = {0}; +iron_gpu_constant_location_t iron_gpu_compute_shader_get_constant_location(iron_gpu_compute_shader *shader, const char *name) { + iron_gpu_constant_location_t location = {0}; uint32_t hash = iron_internal_hash_name((unsigned char *)name); @@ -1177,7 +1177,7 @@ iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5 return location; } -iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name) { +iron_gpu_texture_unit_t iron_gpu_compute_shader_get_texture_unit(iron_gpu_compute_shader *shader, const char *name) { char unitName[64]; int unitOffset = 0; size_t len = strlen(name); @@ -1191,8 +1191,8 @@ iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_s uint32_t hash = iron_internal_hash_name((unsigned char *)unitName); - iron_g5_texture_unit_t unit; - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { + iron_gpu_texture_unit_t unit; + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } iron_internal_hash_index_t *computeUnit = findComputeTextureUnit(shader->impl.textures, hash); @@ -1210,34 +1210,34 @@ iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_s #endif } else { - unit.stages[IRON_G5_SHADER_TYPE_COMPUTE] = computeUnit->index + unitOffset; + unit.stages[IRON_GPU_SHADER_TYPE_COMPUTE] = computeUnit->index + unitOffset; } return unit; } -void iron_g5_internal_setConstants(iron_g5_command_list_t *commandList, iron_g5_pipeline_t *pipeline) { +void iron_gpu_internal_setConstants(iron_gpu_command_list_t *commandList, iron_gpu_pipeline_t *pipeline) { commandList->impl._commandList->lpVtbl->SetGraphicsRootSignature(commandList->impl._commandList, globalRootSignature); if (pipeline->impl.textures > 0) { - iron_g5_internal_set_textures(commandList); + iron_gpu_internal_set_textures(commandList); } } -void iron_g5_internal_set_compute_constants(iron_g5_command_list_t *commandList) { +void iron_gpu_internal_set_compute_constants(iron_gpu_command_list_t *commandList) { commandList->impl._commandList->lpVtbl->SetComputeRootSignature(commandList->impl._commandList, globalComputeRootSignature); //if (pipeline->impl.textures > 0) { - iron_g5_internal_set_textures(commandList); + iron_gpu_internal_set_textures(commandList); //} } -void iron_g5_pipeline_init(iron_g5_pipeline_t *pipe) { - iron_g5_internal_pipeline_set_defaults(pipe); - iron_g5_internal_pipeline_init(pipe); +void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipe) { + iron_gpu_internal_pipeline_set_defaults(pipe); + iron_gpu_internal_pipeline_init(pipe); } -void iron_g5_pipeline_destroy(iron_g5_pipeline_t *pipe) { +void iron_gpu_pipeline_destroy(iron_gpu_pipeline_t *pipe) { if (pipe->impl.pso != NULL) { pipe->impl.pso->lpVtbl->Release(pipe->impl.pso); pipe->impl.pso = NULL; @@ -1246,7 +1246,7 @@ void iron_g5_pipeline_destroy(iron_g5_pipeline_t *pipe) { #define MAX_SHADER_THING 32 -static ShaderConstant findConstant(iron_g5_shader_t *shader, const char *name) { +static ShaderConstant findConstant(iron_gpu_shader_t *shader, const char *name) { if (shader != NULL) { for (int i = 0; i < MAX_SHADER_THING; ++i) { if (strcmp(shader->impl.constants[i].name, name) == 0) { @@ -1262,7 +1262,7 @@ static ShaderConstant findConstant(iron_g5_shader_t *shader, const char *name) { return constant; } -static ShaderTexture findTexture(iron_g5_shader_t *shader, const char *name) { +static ShaderTexture findTexture(iron_gpu_shader_t *shader, const char *name) { for (int i = 0; i < MAX_SHADER_THING; ++i) { if (strcmp(shader->impl.textures[i].name, name) == 0) { return shader->impl.textures[i]; @@ -1275,7 +1275,7 @@ static ShaderTexture findTexture(iron_g5_shader_t *shader, const char *name) { return texture; } -static ShaderAttribute findAttribute(iron_g5_shader_t *shader, const char *name) { +static ShaderAttribute findAttribute(iron_gpu_shader_t *shader, const char *name) { for (int i = 0; i < MAX_SHADER_THING; ++i) { if (strcmp(shader->impl.attributes[i].name, name) == 0) { return shader->impl.attributes[i]; @@ -1288,8 +1288,8 @@ static ShaderAttribute findAttribute(iron_g5_shader_t *shader, const char *name) return attribute; } -iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(struct iron_g5_pipeline *pipe, const char *name) { - iron_g5_constant_location_t location; +iron_gpu_constant_location_t iron_gpu_pipeline_get_constant_location(struct iron_gpu_pipeline *pipe, const char *name) { + iron_gpu_constant_location_t location; { ShaderConstant constant = findConstant(pipe->vertex_shader, name); @@ -1309,48 +1309,48 @@ iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(struct iron_g return location; } -iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipe, const char *name) { - iron_g5_texture_unit_t unit; - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { +iron_gpu_texture_unit_t iron_gpu_pipeline_get_texture_unit(iron_gpu_pipeline_t *pipe, const char *name) { + iron_gpu_texture_unit_t unit; + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } ShaderTexture vertexTexture = findTexture(pipe->vertex_shader, name); if (vertexTexture.texture != -1) { - unit.stages[IRON_G5_SHADER_TYPE_VERTEX] = vertexTexture.texture; + unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] = vertexTexture.texture; } else { ShaderTexture fragmentTexture = findTexture(pipe->fragment_shader, name); - unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] = fragmentTexture.texture; + unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] = fragmentTexture.texture; } return unit; } -static D3D12_BLEND convert_blend_factor(iron_g5_blending_factor_t factor) { +static D3D12_BLEND convert_blend_factor(iron_gpu_blending_factor_t factor) { switch (factor) { - case IRON_G5_BLEND_ONE: + case IRON_GPU_BLEND_ONE: return D3D12_BLEND_ONE; - case IRON_G5_BLEND_ZERO: + case IRON_GPU_BLEND_ZERO: return D3D12_BLEND_ZERO; - case IRON_G5_BLEND_SOURCE_ALPHA: + case IRON_GPU_BLEND_SOURCE_ALPHA: return D3D12_BLEND_SRC_ALPHA; - case IRON_G5_BLEND_DEST_ALPHA: + case IRON_GPU_BLEND_DEST_ALPHA: return D3D12_BLEND_DEST_ALPHA; - case IRON_G5_BLEND_INV_SOURCE_ALPHA: + case IRON_GPU_BLEND_INV_SOURCE_ALPHA: return D3D12_BLEND_INV_SRC_ALPHA; - case IRON_G5_BLEND_INV_DEST_ALPHA: + case IRON_GPU_BLEND_INV_DEST_ALPHA: return D3D12_BLEND_INV_DEST_ALPHA; - case IRON_G5_BLEND_SOURCE_COLOR: + case IRON_GPU_BLEND_SOURCE_COLOR: return D3D12_BLEND_SRC_COLOR; - case IRON_G5_BLEND_DEST_COLOR: + case IRON_GPU_BLEND_DEST_COLOR: return D3D12_BLEND_DEST_COLOR; - case IRON_G5_BLEND_INV_SOURCE_COLOR: + case IRON_GPU_BLEND_INV_SOURCE_COLOR: return D3D12_BLEND_INV_SRC_COLOR; - case IRON_G5_BLEND_INV_DEST_COLOR: + case IRON_GPU_BLEND_INV_DEST_COLOR: return D3D12_BLEND_INV_DEST_COLOR; - case IRON_G5_BLEND_CONSTANT: + case IRON_GPU_BLEND_CONSTANT: return D3D12_BLEND_BLEND_FACTOR; - case IRON_G5_BLEND_INV_CONSTANT: + case IRON_GPU_BLEND_INV_CONSTANT: return D3D12_BLEND_INV_BLEND_FACTOR; default: assert(false); @@ -1358,17 +1358,17 @@ static D3D12_BLEND convert_blend_factor(iron_g5_blending_factor_t factor) { } } -static D3D12_BLEND_OP convert_blend_operation(iron_g5_blending_operation_t op) { +static D3D12_BLEND_OP convert_blend_operation(iron_gpu_blending_operation_t op) { switch (op) { - case IRON_G5_BLENDOP_ADD: + case IRON_GPU_BLENDOP_ADD: return D3D12_BLEND_OP_ADD; - case IRON_G5_BLENDOP_SUBTRACT: + case IRON_GPU_BLENDOP_SUBTRACT: return D3D12_BLEND_OP_SUBTRACT; - case IRON_G5_BLENDOP_REVERSE_SUBTRACT: + case IRON_GPU_BLENDOP_REVERSE_SUBTRACT: return D3D12_BLEND_OP_REV_SUBTRACT; - case IRON_G5_BLENDOP_MIN: + case IRON_GPU_BLENDOP_MIN: return D3D12_BLEND_OP_MIN; - case IRON_G5_BLENDOP_MAX: + case IRON_GPU_BLENDOP_MAX: return D3D12_BLEND_OP_MAX; default: assert(false); @@ -1376,36 +1376,36 @@ static D3D12_BLEND_OP convert_blend_operation(iron_g5_blending_operation_t op) { } } -static D3D12_CULL_MODE convert_cull_mode(iron_g5_cull_mode_t cull_mode) { +static D3D12_CULL_MODE convert_cull_mode(iron_gpu_cull_mode_t cull_mode) { switch (cull_mode) { - case IRON_G5_CULL_MODE_CLOCKWISE: + case IRON_GPU_CULL_MODE_CLOCKWISE: return D3D12_CULL_MODE_FRONT; - case IRON_G5_CULL_MODE_COUNTERCLOCKWISE: + case IRON_GPU_CULL_MODE_COUNTERCLOCKWISE: return D3D12_CULL_MODE_BACK; - case IRON_G5_CULL_MODE_NEVER: + case IRON_GPU_CULL_MODE_NEVER: default: return D3D12_CULL_MODE_NONE; } } -static D3D12_COMPARISON_FUNC convert_compare_mode(iron_g5_compare_mode_t compare) { +static D3D12_COMPARISON_FUNC convert_compare_mode(iron_gpu_compare_mode_t compare) { switch (compare) { default: - case IRON_G5_COMPARE_MODE_ALWAYS: + case IRON_GPU_COMPARE_MODE_ALWAYS: return D3D12_COMPARISON_FUNC_ALWAYS; - case IRON_G5_COMPARE_MODE_NEVER: + case IRON_GPU_COMPARE_MODE_NEVER: return D3D12_COMPARISON_FUNC_NEVER; - case IRON_G5_COMPARE_MODE_EQUAL: + case IRON_GPU_COMPARE_MODE_EQUAL: return D3D12_COMPARISON_FUNC_EQUAL; - case IRON_G5_COMPARE_MODE_NOT_EQUAL: + case IRON_GPU_COMPARE_MODE_NOT_EQUAL: return D3D12_COMPARISON_FUNC_NOT_EQUAL; - case IRON_G5_COMPARE_MODE_LESS: + case IRON_GPU_COMPARE_MODE_LESS: return D3D12_COMPARISON_FUNC_LESS; - case IRON_G5_COMPARE_MODE_LESS_EQUAL: + case IRON_GPU_COMPARE_MODE_LESS_EQUAL: return D3D12_COMPARISON_FUNC_LESS_EQUAL; - case IRON_G5_COMPARE_MODE_GREATER: + case IRON_GPU_COMPARE_MODE_GREATER: return D3D12_COMPARISON_FUNC_GREATER; - case IRON_G5_COMPARE_MODE_GREATER_EQUAL: + case IRON_GPU_COMPARE_MODE_GREATER_EQUAL: return D3D12_COMPARISON_FUNC_GREATER_EQUAL; } } @@ -1428,9 +1428,9 @@ static DXGI_FORMAT convert_format(iron_image_format_t format) { } } -static void set_blend_state(D3D12_BLEND_DESC *blend_desc, iron_g5_pipeline_t *pipe, int target) { - blend_desc->RenderTarget[target].BlendEnable = pipe->blend_source != IRON_G5_BLEND_ONE || pipe->blend_destination != IRON_G5_BLEND_ZERO || - pipe->alpha_blend_source != IRON_G5_BLEND_ONE || pipe->alpha_blend_destination != IRON_G5_BLEND_ZERO; +static void set_blend_state(D3D12_BLEND_DESC *blend_desc, iron_gpu_pipeline_t *pipe, int target) { + blend_desc->RenderTarget[target].BlendEnable = pipe->blend_source != IRON_GPU_BLEND_ONE || pipe->blend_destination != IRON_GPU_BLEND_ZERO || + pipe->alpha_blend_source != IRON_GPU_BLEND_ONE || pipe->alpha_blend_destination != IRON_GPU_BLEND_ZERO; blend_desc->RenderTarget[target].SrcBlend = convert_blend_factor(pipe->blend_source); blend_desc->RenderTarget[target].DestBlend = convert_blend_factor(pipe->blend_destination); blend_desc->RenderTarget[target].BlendOp = convert_blend_operation(pipe->blend_operation); @@ -1444,7 +1444,7 @@ static void set_blend_state(D3D12_BLEND_DESC *blend_desc, iron_g5_pipeline_t *pi (pipe->color_write_mask_alpha[target] ? D3D12_COLOR_WRITE_ENABLE_ALPHA : 0); } -void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipe) { +void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipe) { int vertexAttributeCount = pipe->input_layout->size; D3D12_INPUT_ELEMENT_DESC *vertexDesc = (D3D12_INPUT_ELEMENT_DESC *)alloca(sizeof(D3D12_INPUT_ELEMENT_DESC) * vertexAttributeCount); @@ -1459,25 +1459,25 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipe) { vertexDesc[i].InstanceDataStepRate = 0; switch (pipe->input_layout->elements[i].data) { - case IRON_G5_VERTEX_DATA_F32_1X: + case IRON_GPU_VERTEX_DATA_F32_1X: vertexDesc[i].Format = DXGI_FORMAT_R32_FLOAT; break; - case IRON_G5_VERTEX_DATA_F32_2X: + case IRON_GPU_VERTEX_DATA_F32_2X: vertexDesc[i].Format = DXGI_FORMAT_R32G32_FLOAT; break; - case IRON_G5_VERTEX_DATA_F32_3X: + case IRON_GPU_VERTEX_DATA_F32_3X: vertexDesc[i].Format = DXGI_FORMAT_R32G32B32_FLOAT; break; - case IRON_G5_VERTEX_DATA_F32_4X: + case IRON_GPU_VERTEX_DATA_F32_4X: vertexDesc[i].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; break; - case IRON_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_GPU_VERTEX_DATA_U8_4X_NORM: vertexDesc[i].Format = DXGI_FORMAT_R8G8B8A8_UNORM; break; - case IRON_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_GPU_VERTEX_DATA_I16_2X_NORM: vertexDesc[i].Format = DXGI_FORMAT_R16G16_SNORM; break; - case IRON_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_GPU_VERTEX_DATA_I16_4X_NORM: vertexDesc[i].Format = DXGI_FORMAT_R16G16B16A16_SNORM; break; default: @@ -1562,7 +1562,7 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipe) { psoDesc.DepthStencilState.FrontFace = defaultStencilOp; psoDesc.DepthStencilState.BackFace = defaultStencilOp; - psoDesc.DepthStencilState.DepthEnable = pipe->depth_mode != IRON_G5_COMPARE_MODE_ALWAYS; + psoDesc.DepthStencilState.DepthEnable = pipe->depth_mode != IRON_GPU_COMPARE_MODE_ALWAYS; psoDesc.DepthStencilState.DepthWriteMask = pipe->depth_write ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; psoDesc.DepthStencilState.DepthFunc = convert_compare_mode(pipe->depth_mode); psoDesc.DepthStencilState.StencilEnable = false; @@ -1577,15 +1577,15 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipe) { } } -static D3D12_TEXTURE_ADDRESS_MODE convert_texture_addressing(iron_g5_texture_addressing_t addressing) { +static D3D12_TEXTURE_ADDRESS_MODE convert_texture_addressing(iron_gpu_texture_addressing_t addressing) { switch (addressing) { - case IRON_G5_TEXTURE_ADDRESSING_REPEAT: + case IRON_GPU_TEXTURE_ADDRESSING_REPEAT: return D3D12_TEXTURE_ADDRESS_MODE_WRAP; - case IRON_G5_TEXTURE_ADDRESSING_MIRROR: + case IRON_GPU_TEXTURE_ADDRESSING_MIRROR: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR; - case IRON_G5_TEXTURE_ADDRESSING_CLAMP: + case IRON_GPU_TEXTURE_ADDRESSING_CLAMP: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP; - case IRON_G5_TEXTURE_ADDRESSING_BORDER: + case IRON_GPU_TEXTURE_ADDRESSING_BORDER: return D3D12_TEXTURE_ADDRESS_MODE_BORDER; default: assert(false); @@ -1593,51 +1593,51 @@ static D3D12_TEXTURE_ADDRESS_MODE convert_texture_addressing(iron_g5_texture_add } } -static D3D12_FILTER convert_filter(iron_g5_texture_filter_t minification, iron_g5_texture_filter_t magnification, iron_g5_mipmap_filter_t mipmap) { +static D3D12_FILTER convert_filter(iron_gpu_texture_filter_t minification, iron_gpu_texture_filter_t magnification, iron_gpu_mipmap_filter_t mipmap) { switch (minification) { - case IRON_G5_TEXTURE_FILTER_POINT: + case IRON_GPU_TEXTURE_FILTER_POINT: switch (magnification) { - case IRON_G5_TEXTURE_FILTER_POINT: + case IRON_GPU_TEXTURE_FILTER_POINT: switch (mipmap) { - case IRON_G5_MIPMAP_FILTER_NONE: - case IRON_G5_MIPMAP_FILTER_POINT: + case IRON_GPU_MIPMAP_FILTER_NONE: + case IRON_GPU_MIPMAP_FILTER_POINT: return D3D12_FILTER_MIN_MAG_MIP_POINT; - case IRON_G5_MIPMAP_FILTER_LINEAR: + case IRON_GPU_MIPMAP_FILTER_LINEAR: return D3D12_FILTER_MIN_MAG_POINT_MIP_LINEAR; } - case IRON_G5_TEXTURE_FILTER_LINEAR: + case IRON_GPU_TEXTURE_FILTER_LINEAR: switch (mipmap) { - case IRON_G5_MIPMAP_FILTER_NONE: - case IRON_G5_MIPMAP_FILTER_POINT: + case IRON_GPU_MIPMAP_FILTER_NONE: + case IRON_GPU_MIPMAP_FILTER_POINT: return D3D12_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT; - case IRON_G5_MIPMAP_FILTER_LINEAR: + case IRON_GPU_MIPMAP_FILTER_LINEAR: return D3D12_FILTER_MIN_POINT_MAG_MIP_LINEAR; } - case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_GPU_TEXTURE_FILTER_ANISOTROPIC: return D3D12_FILTER_ANISOTROPIC; } - case IRON_G5_TEXTURE_FILTER_LINEAR: + case IRON_GPU_TEXTURE_FILTER_LINEAR: switch (magnification) { - case IRON_G5_TEXTURE_FILTER_POINT: + case IRON_GPU_TEXTURE_FILTER_POINT: switch (mipmap) { - case IRON_G5_MIPMAP_FILTER_NONE: - case IRON_G5_MIPMAP_FILTER_POINT: + case IRON_GPU_MIPMAP_FILTER_NONE: + case IRON_GPU_MIPMAP_FILTER_POINT: return D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT; - case IRON_G5_MIPMAP_FILTER_LINEAR: + case IRON_GPU_MIPMAP_FILTER_LINEAR: return D3D12_FILTER_MIN_MAG_MIP_LINEAR; } - case IRON_G5_TEXTURE_FILTER_LINEAR: + case IRON_GPU_TEXTURE_FILTER_LINEAR: switch (mipmap) { - case IRON_G5_MIPMAP_FILTER_NONE: - case IRON_G5_MIPMAP_FILTER_POINT: + case IRON_GPU_MIPMAP_FILTER_NONE: + case IRON_GPU_MIPMAP_FILTER_POINT: return D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; - case IRON_G5_MIPMAP_FILTER_LINEAR: + case IRON_GPU_MIPMAP_FILTER_LINEAR: return D3D12_FILTER_MIN_MAG_MIP_LINEAR; } - case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_GPU_TEXTURE_FILTER_ANISOTROPIC: return D3D12_FILTER_ANISOTROPIC; } - case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_GPU_TEXTURE_FILTER_ANISOTROPIC: return D3D12_FILTER_ANISOTROPIC; } @@ -1645,7 +1645,7 @@ static D3D12_FILTER convert_filter(iron_g5_texture_filter_t minification, iron_g return D3D12_FILTER_MIN_MAG_MIP_POINT; } -void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options) { +void iron_gpu_sampler_init(iron_gpu_sampler_t *sampler, const iron_gpu_sampler_options_t *options) { D3D12_DESCRIPTOR_HEAP_DESC descHeapSampler = {}; descHeapSampler.NumDescriptors = 2; descHeapSampler.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER; @@ -1668,9 +1668,9 @@ void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_opti device->lpVtbl->CreateSampler(device, &samplerDesc, handle); } -void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler) {} +void iron_gpu_sampler_destroy(iron_gpu_sampler_t *sampler) {} -void iron_g5_shader_init(iron_g5_shader_t *shader, const void *_data, size_t length, iron_g5_shader_type_t type) { +void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *_data, size_t length, iron_gpu_shader_type_t type) { memset(shader->impl.constants, 0, sizeof(shader->impl.constants)); memset(shader->impl.attributes, 0, sizeof(shader->impl.attributes)); memset(shader->impl.textures, 0, sizeof(shader->impl.textures)); @@ -1728,7 +1728,7 @@ void iron_g5_shader_init(iron_g5_shader_t *shader, const void *_data, size_t len memcpy(shader->impl.data, &data[index], shader->impl.length); } -void iron_g5_shader_destroy(iron_g5_shader_t *shader) { +void iron_gpu_shader_destroy(iron_gpu_shader_t *shader) { free(shader->impl.data); } @@ -1744,7 +1744,7 @@ uint32_t iron_internal_hash_name(unsigned char *str) { static const int heapSize = 1024; -void iron_g5_internal_reset_textures(struct iron_g5_command_list *list) { +void iron_gpu_internal_reset_textures(struct iron_gpu_command_list *list) { for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { list->impl.currentTextures[i] = NULL; list->impl.current_samplers[i] = NULL; @@ -1796,7 +1796,7 @@ static int formatByteSize(iron_image_format_t format) { } } -void iron_g5_internal_set_textures(iron_g5_command_list_t *list) { +void iron_gpu_internal_set_textures(iron_gpu_command_list_t *list) { if (list->impl.currentTextures[0] != NULL) { int srvStep = device->lpVtbl->GetDescriptorHandleIncrementSize(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); int samplerStep = device->lpVtbl->GetDescriptorHandleIncrementSize(device, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); @@ -1858,7 +1858,7 @@ void iron_g5_internal_set_textures(iron_g5_command_list_t *list) { } } -void createHeaps(iron_g5_command_list_t *list) { +void createHeaps(iron_gpu_command_list_t *list) { D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; heapDesc.NumDescriptors = heapSize; heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; @@ -1874,7 +1874,7 @@ void createHeaps(iron_g5_command_list_t *list) { void iron_memory_emergency(); -void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { memset(&texture->impl, 0, sizeof(texture->impl)); texture->impl.stage = 0; texture->impl.stage_depth = -1; @@ -1966,7 +1966,7 @@ void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int BYTE *pixel; texture->impl.uploadImage->lpVtbl->Map(texture->impl.uploadImage, 0, NULL, (void **)&pixel); - int pitch = iron_g5_texture_stride(texture); + int pitch = iron_gpu_texture_stride(texture); for (int y = 0; y < texture->height; ++y) { memcpy(&pixel[y * pitch], &((uint8_t *)data)[y * texture->width * formatSize], texture->width * formatSize); } @@ -1995,7 +1995,7 @@ void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int device->lpVtbl->CreateShaderResourceView(device, texture->impl.image, &shaderResourceViewDesc, handle); } -void create_texture(struct iron_g5_texture *texture, int width, int height, iron_image_format_t format, D3D12_RESOURCE_FLAGS flags) { +void create_texture(struct iron_gpu_texture *texture, int width, int height, iron_image_format_t format, D3D12_RESOURCE_FLAGS flags) { memset(&texture->impl, 0, sizeof(texture->impl)); texture->impl.stage = 0; texture->impl.stage_depth = -1; @@ -2105,20 +2105,20 @@ void create_texture(struct iron_g5_texture *texture, int width, int height, iron device->lpVtbl->CreateShaderResourceView(device, texture->impl.image, &shaderResourceViewDesc, handle); } -void iron_g5_texture_init(struct iron_g5_texture *texture, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init(struct iron_gpu_texture *texture, int width, int height, iron_image_format_t format) { create_texture(texture, width, height, format, D3D12_RESOURCE_FLAG_NONE); texture->_uploaded = true; texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; texture->format = format; } -void iron_g5_texture_init_non_sampled_access(struct iron_g5_texture *texture, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init_non_sampled_access(struct iron_gpu_texture *texture, int width, int height, iron_image_format_t format) { create_texture(texture, width, height, format, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS); texture->_uploaded = true; texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; } -void iron_g5_texture_destroy(iron_g5_texture_t *render_target) { +void iron_gpu_texture_destroy(iron_gpu_texture_t *render_target) { if (render_target->impl.framebuffer_index >= 0) { framebuffer_count -= 1; } @@ -2144,24 +2144,24 @@ void iron_g5_texture_destroy(iron_g5_texture_t *render_target) { } } -void iron_g5_internal_texture_unmipmap(struct iron_g5_texture *texture) { +void iron_gpu_internal_texture_unmipmap(struct iron_gpu_texture *texture) { texture->impl.mipmap = false; } -void iron_g5_internal_sampler_set(iron_g5_command_list_t *list, iron_g5_sampler_t *sampler, int unit) { +void iron_gpu_internal_sampler_set(iron_gpu_command_list_t *list, iron_gpu_sampler_t *sampler, int unit) { if (unit < 0) return; list->impl.current_samplers[unit] = sampler; } -int iron_g5_texture_stride(struct iron_g5_texture *texture) { +int iron_gpu_texture_stride(struct iron_gpu_texture *texture) { return texture->impl.stride; } -void iron_g5_texture_generate_mipmaps(struct iron_g5_texture *texture, int levels) {} +void iron_gpu_texture_generate_mipmaps(struct iron_gpu_texture *texture, int levels) {} -void iron_g5_texture_set_mipmap(struct iron_g5_texture *texture, struct iron_g5_texture *mipmap, int level) {} +void iron_gpu_texture_set_mipmap(struct iron_gpu_texture *texture, struct iron_gpu_texture *mipmap, int level) {} static void WaitForFence(ID3D12Fence *fence, UINT64 completionValue, HANDLE waitEvent) { if (fence->lpVtbl->GetCompletedValue(fence) < completionValue) { @@ -2203,7 +2203,7 @@ static DXGI_FORMAT convertFormat(iron_image_format_t format) { void iron_memory_emergency(); -static void render_target_init(iron_g5_texture_t *render_target, int width, int height, iron_image_format_t format, int depthBufferBits, int framebuffer_index) { +static void render_target_init(iron_gpu_texture_t *render_target, int width, int height, iron_image_format_t format, int depthBufferBits, int framebuffer_index) { render_target->width = render_target->width = width; render_target->height = render_target->height = height; render_target->impl.stage = 0; @@ -2401,33 +2401,33 @@ static void render_target_init(iron_g5_texture_t *render_target, int width, int render_target->impl.viewport.MaxDepth = 1.0f; } -void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { +void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, -1); target->_uploaded = true; target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; } -void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { +void iron_gpu_render_target_init_framebuffer(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, framebuffer_count); framebuffer_count += 1; target->_uploaded = true; target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; } -void iron_g5_render_target_set_depth_from(iron_g5_texture_t *render_target, iron_g5_texture_t *source) { +void iron_gpu_render_target_set_depth_from(iron_gpu_texture_t *render_target, iron_gpu_texture_t *source) { render_target->impl.depthStencilDescriptorHeap = source->impl.depthStencilDescriptorHeap; render_target->impl.srvDepthDescriptorHeap = source->impl.srvDepthDescriptorHeap; render_target->impl.depthStencilTexture = source->impl.depthStencilTexture; } -iron_g5_vertex_buffer_t *_current_vertex_buffer = NULL; +iron_gpu_vertex_buffer_t *_current_vertex_buffer = NULL; -void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, bool gpuMemory) { +void iron_gpu_vertex_buffer_init(iron_gpu_vertex_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, bool gpuMemory) { buffer->impl.myCount = count; buffer->impl.myStride = 0; for (int i = 0; i < structure->size; ++i) { - buffer->impl.myStride += iron_g5_vertex_data_size(structure->elements[i].data); + buffer->impl.myStride += iron_gpu_vertex_data_size(structure->elements[i].data); } int uploadBufferSize = buffer->impl.myStride * buffer->impl.myCount; @@ -2460,19 +2460,19 @@ void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron buffer->impl.view.StrideInBytes = buffer->impl.myStride; buffer->impl.lastStart = 0; - buffer->impl.lastCount = iron_g5_vertex_buffer_count(buffer); + buffer->impl.lastCount = iron_gpu_vertex_buffer_count(buffer); } -void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buffer) { +void iron_gpu_vertex_buffer_destroy(iron_gpu_vertex_buffer_t *buffer) { // buffer->impl.vertexBuffer->lpVtbl->Release(); buffer->impl.uploadBuffer->lpVtbl->Release(buffer->impl.uploadBuffer); } -float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buffer) { - return iron_g5_vertex_buffer_lock(buffer, 0, iron_g5_vertex_buffer_count(buffer)); +float *iron_gpu_vertex_buffer_lock_all(iron_gpu_vertex_buffer_t *buffer) { + return iron_gpu_vertex_buffer_lock(buffer, 0, iron_gpu_vertex_buffer_count(buffer)); } -float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buffer, int start, int count) { +float *iron_gpu_vertex_buffer_lock(iron_gpu_vertex_buffer_t *buffer, int start, int count) { buffer->impl.lastStart = start; buffer->impl.lastCount = count; @@ -2487,36 +2487,36 @@ float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buffer, int start, in return (float *)bytes; } -void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buffer) { +void iron_gpu_vertex_buffer_unlock_all(iron_gpu_vertex_buffer_t *buffer) { D3D12_RANGE range; range.Begin = buffer->impl.lastStart * buffer->impl.myStride; range.End = (buffer->impl.lastStart + buffer->impl.lastCount) * buffer->impl.myStride; buffer->impl.uploadBuffer->lpVtbl->Unmap(buffer->impl.uploadBuffer, 0, &range); } -void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t *buffer, int count) { +void iron_gpu_vertex_buffer_unlock(iron_gpu_vertex_buffer_t *buffer, int count) { D3D12_RANGE range; range.Begin = buffer->impl.lastStart * buffer->impl.myStride; range.End = (buffer->impl.lastStart + count) * buffer->impl.myStride; buffer->impl.uploadBuffer->lpVtbl->Unmap(buffer->impl.uploadBuffer, 0, &range); } -int iron_g5_internal_vertex_buffer_set(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_internal_vertex_buffer_set(iron_gpu_vertex_buffer_t *buffer) { _current_vertex_buffer = buffer; return 0; } -int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_vertex_buffer_count(iron_gpu_vertex_buffer_t *buffer) { return buffer->impl.myCount; } -int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_vertex_buffer_stride(iron_gpu_vertex_buffer_t *buffer) { return buffer->impl.myStride; } -bool iron_g5_transpose_mat = false; +bool iron_gpu_transpose_mat = false; -void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { +void iron_gpu_constant_buffer_init(iron_gpu_constant_buffer_t *buffer, int size) { buffer->impl.mySize = size; buffer->data = NULL; @@ -2550,15 +2550,15 @@ void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { buffer->impl.constant_buffer->lpVtbl->Unmap(buffer->impl.constant_buffer, 0, NULL); } -void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer) { +void iron_gpu_constant_buffer_destroy(iron_gpu_constant_buffer_t *buffer) { buffer->impl.constant_buffer->lpVtbl->Release(buffer->impl.constant_buffer); } -void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer) { - iron_g5_constant_buffer_lock(buffer, 0, iron_g5_constant_buffer_size(buffer)); +void iron_gpu_constant_buffer_lock_all(iron_gpu_constant_buffer_t *buffer) { + iron_gpu_constant_buffer_lock(buffer, 0, iron_gpu_constant_buffer_size(buffer)); } -void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count) { +void iron_gpu_constant_buffer_lock(iron_gpu_constant_buffer_t *buffer, int start, int count) { buffer->impl.lastStart = start; buffer->impl.lastCount = count; D3D12_RANGE range; @@ -2569,7 +2569,7 @@ void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, buffer->data = &p[start]; } -void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer) { +void iron_gpu_constant_buffer_unlock(iron_gpu_constant_buffer_t *buffer) { D3D12_RANGE range; range.Begin = buffer->impl.lastStart; range.End = range.Begin + buffer->impl.lastCount; @@ -2577,11 +2577,11 @@ void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer) { buffer->data = NULL; } -int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer) { +int iron_gpu_constant_buffer_size(iron_gpu_constant_buffer_t *buffer) { return buffer->impl.mySize; } -void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int count, bool gpuMemory) { +void iron_gpu_index_buffer_init(iron_gpu_index_buffer_t *buffer, int count, bool gpuMemory) { buffer->impl.count = count; buffer->impl.gpu_memory = gpuMemory; @@ -2632,10 +2632,10 @@ void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int count, bool g buffer->impl.index_buffer_view.Format = DXGI_FORMAT_R32_UINT; buffer->impl.last_start = 0; - buffer->impl.last_count = iron_g5_index_buffer_count(buffer); + buffer->impl.last_count = iron_gpu_index_buffer_count(buffer); } -void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer) { +void iron_gpu_index_buffer_destroy(iron_gpu_index_buffer_t *buffer) { if (buffer->impl.index_buffer != NULL) { buffer->impl.index_buffer->lpVtbl->Release(buffer->impl.index_buffer); buffer->impl.index_buffer = NULL; @@ -2645,46 +2645,46 @@ void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer) { buffer->impl.upload_buffer = NULL; } -static int iron_g5_internal_index_buffer_stride(iron_g5_index_buffer_t *buffer) { +static int iron_gpu_internal_index_buffer_stride(iron_gpu_index_buffer_t *buffer) { return 4; } -void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer) { - return iron_g5_index_buffer_lock(buffer, 0, iron_g5_index_buffer_count(buffer)); +void *iron_gpu_index_buffer_lock_all(iron_gpu_index_buffer_t *buffer) { + return iron_gpu_index_buffer_lock(buffer, 0, iron_gpu_index_buffer_count(buffer)); } -void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count) { +void *iron_gpu_index_buffer_lock(iron_gpu_index_buffer_t *buffer, int start, int count) { buffer->impl.last_start = start; buffer->impl.last_count = count; D3D12_RANGE range; - range.Begin = start * iron_g5_internal_index_buffer_stride(buffer); - range.End = (start + count) * iron_g5_internal_index_buffer_stride(buffer); + range.Begin = start * iron_gpu_internal_index_buffer_stride(buffer); + range.End = (start + count) * iron_gpu_internal_index_buffer_stride(buffer); void *p; buffer->impl.upload_buffer->lpVtbl->Map(buffer->impl.upload_buffer, 0, &range, &p); byte *bytes = (byte *)p; - bytes += start * iron_g5_internal_index_buffer_stride(buffer); + bytes += start * iron_gpu_internal_index_buffer_stride(buffer); return bytes; } -void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { +void iron_gpu_index_buffer_unlock_all(iron_gpu_index_buffer_t *buffer) { D3D12_RANGE range; - range.Begin = buffer->impl.last_start * iron_g5_internal_index_buffer_stride(buffer); - range.End = (buffer->impl.last_start + buffer->impl.last_count) * iron_g5_internal_index_buffer_stride(buffer); + range.Begin = buffer->impl.last_start * iron_gpu_internal_index_buffer_stride(buffer); + range.End = (buffer->impl.last_start + buffer->impl.last_count) * iron_gpu_internal_index_buffer_stride(buffer); buffer->impl.upload_buffer->lpVtbl->Unmap(buffer->impl.upload_buffer, 0, &range); } -void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { +void iron_gpu_index_buffer_unlock(iron_gpu_index_buffer_t *buffer, int count) { D3D12_RANGE range; - range.Begin = buffer->impl.last_start * iron_g5_internal_index_buffer_stride(buffer); - range.End = (buffer->impl.last_start + count) * iron_g5_internal_index_buffer_stride(buffer); + range.Begin = buffer->impl.last_start * iron_gpu_internal_index_buffer_stride(buffer); + range.End = (buffer->impl.last_start + count) * iron_gpu_internal_index_buffer_stride(buffer); buffer->impl.upload_buffer->lpVtbl->Unmap(buffer->impl.upload_buffer, 0, &range); } -void iron_g5_internal_index_buffer_upload(iron_g5_index_buffer_t *buffer, ID3D12GraphicsCommandList *commandList) { +void iron_gpu_internal_index_buffer_upload(iron_gpu_index_buffer_t *buffer, ID3D12GraphicsCommandList *commandList) { if (!buffer->impl.gpu_memory) return; @@ -2701,7 +2701,7 @@ void iron_g5_internal_index_buffer_upload(iron_g5_index_buffer_t *buffer, ID3D12 commandList->lpVtbl->ResourceBarrier(commandList, 1, barriers); } -int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer) { +int iron_gpu_index_buffer_count(iron_gpu_index_buffer_t *buffer) { return buffer->impl.count; } @@ -2719,9 +2719,9 @@ static ID3D12Device5 *dxrDevice = NULL; static ID3D12GraphicsCommandList4 *dxrCommandList = NULL; static ID3D12RootSignature *dxrRootSignature = NULL; static ID3D12DescriptorHeap *descriptorHeap = NULL; -static iron_g5_raytrace_acceleration_structure_t *accel; -static iron_g5_raytrace_pipeline_t *pipeline; -static iron_g5_texture_t *output = NULL; +static iron_gpu_raytrace_acceleration_structure_t *accel; +static iron_gpu_raytrace_pipeline_t *pipeline; +static iron_gpu_texture_t *output = NULL; static D3D12_CPU_DESCRIPTOR_HANDLE outputCpuDescriptor; static D3D12_GPU_DESCRIPTOR_HANDLE outputDescriptorHandle; static D3D12_GPU_DESCRIPTOR_HANDLE vbgpuDescriptorHandle; @@ -2736,16 +2736,16 @@ static D3D12_GPU_DESCRIPTOR_HANDLE texrankgpuDescriptorHandle; static int descriptorsAllocated = 0; static UINT descriptorSize; -static iron_g5_vertex_buffer_t *vb[16]; -static iron_g5_vertex_buffer_t *vb_last[16]; -static iron_g5_index_buffer_t *ib[16]; +static iron_gpu_vertex_buffer_t *vb[16]; +static iron_gpu_vertex_buffer_t *vb_last[16]; +static iron_gpu_index_buffer_t *ib[16]; static int vb_count = 0; static int vb_count_last = 0; static inst_t instances[1024]; static int instances_count = 0; -void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, iron_g5_command_list_t *command_list, void *ray_shader, int ray_shader_size, - iron_g5_constant_buffer_t *constant_buffer) { +void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, iron_gpu_command_list_t *command_list, void *ray_shader, int ray_shader_size, + iron_gpu_constant_buffer_t *constant_buffer) { output = NULL; descriptorsAllocated = 0; pipeline->_constant_buffer = constant_buffer; @@ -3061,14 +3061,14 @@ void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, iron_ handle.ptr + (INT64)(descriptorHeapIndex) * (UINT64)(descriptorSize); } -void iron_g5_raytrace_pipeline_destroy(iron_g5_raytrace_pipeline_t *pipeline) { +void iron_gpu_raytrace_pipeline_destroy(iron_gpu_raytrace_pipeline_t *pipeline) { pipeline->impl.dxr_state->lpVtbl->Release(pipeline->impl.dxr_state); pipeline->impl.raygen_shader_table->lpVtbl->Release(pipeline->impl.raygen_shader_table); pipeline->impl.miss_shader_table->lpVtbl->Release(pipeline->impl.miss_shader_table); pipeline->impl.hitgroup_shader_table->lpVtbl->Release(pipeline->impl.hitgroup_shader_table); } -UINT create_srv_vb(iron_g5_vertex_buffer_t *vb, UINT numElements, UINT elementSize) { +UINT create_srv_vb(iron_gpu_vertex_buffer_t *vb, UINT numElements, UINT elementSize) { D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; @@ -3102,7 +3102,7 @@ UINT create_srv_vb(iron_g5_vertex_buffer_t *vb, UINT numElements, UINT elementSi return descriptorIndex; } -UINT create_srv_ib(iron_g5_index_buffer_t *ib, UINT numElements, UINT elementSize) { +UINT create_srv_ib(iron_gpu_index_buffer_t *ib, UINT numElements, UINT elementSize) { D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; @@ -3135,12 +3135,12 @@ UINT create_srv_ib(iron_g5_index_buffer_t *ib, UINT numElements, UINT elementSiz return descriptorIndex; } -void iron_g5_raytrace_acceleration_structure_init(iron_g5_raytrace_acceleration_structure_t *accel) { +void iron_gpu_raytrace_acceleration_structure_init(iron_gpu_raytrace_acceleration_structure_t *accel) { vb_count = 0; instances_count = 0; } -void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_vertex_buffer_t *_vb, iron_g5_index_buffer_t *_ib, +void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_vertex_buffer_t *_vb, iron_gpu_index_buffer_t *_ib, iron_matrix4x4_t _transform) { int vb_i = -1; @@ -3162,18 +3162,18 @@ void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_s instances_count++; } -void _iron_g5_raytrace_acceleration_structure_destroy_bottom(iron_g5_raytrace_acceleration_structure_t *accel) { +void _iron_gpu_raytrace_acceleration_structure_destroy_bottom(iron_gpu_raytrace_acceleration_structure_t *accel) { for (int i = 0; i < vb_count_last; ++i) { accel->impl.bottom_level_accel[i]->lpVtbl->Release(accel->impl.bottom_level_accel[i]); } } -void _iron_g5_raytrace_acceleration_structure_destroy_top(iron_g5_raytrace_acceleration_structure_t *accel) { +void _iron_gpu_raytrace_acceleration_structure_destroy_top(iron_gpu_raytrace_acceleration_structure_t *accel) { accel->impl.top_level_accel->lpVtbl->Release(accel->impl.top_level_accel); } -void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_command_list_t *command_list, - iron_g5_vertex_buffer_t *_vb_full, iron_g5_index_buffer_t *_ib_full) { +void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_command_list_t *command_list, + iron_gpu_vertex_buffer_t *_vb_full, iron_gpu_index_buffer_t *_ib_full) { bool build_bottom = false; for (int i = 0; i < 16; ++i) { @@ -3185,9 +3185,9 @@ void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration if (vb_count_last > 0) { if (build_bottom) { - _iron_g5_raytrace_acceleration_structure_destroy_bottom(accel); + _iron_gpu_raytrace_acceleration_structure_destroy_bottom(accel); } - _iron_g5_raytrace_acceleration_structure_destroy_top(accel); + _iron_gpu_raytrace_acceleration_structure_destroy_top(accel); } vb_count_last = vb_count; @@ -3196,7 +3196,7 @@ void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration return; } - descriptorsAllocated = 1; // 1 descriptor already allocated in iron_g5_raytrace_pipeline_init + descriptorsAllocated = 1; // 1 descriptor already allocated in iron_gpu_raytrace_pipeline_init #ifdef is_forge create_srv_ib(_ib_full, _ib_full->impl.count, 0); @@ -3409,21 +3409,21 @@ void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration command_list->impl._commandList->lpVtbl->ResourceBarrier(command_list->impl._commandList, 1, &barrier); dxrCommandList->lpVtbl->BuildRaytracingAccelerationStructure(dxrCommandList, &topLevelBuildDesc, 0, NULL); - iron_g5_command_list_end(command_list); - iron_g5_command_list_execute(command_list); - iron_g5_command_list_wait_for_execution_to_finish(command_list); - iron_g5_command_list_begin(command_list); + iron_gpu_command_list_end(command_list); + iron_gpu_command_list_execute(command_list); + iron_gpu_command_list_wait_for_execution_to_finish(command_list); + iron_gpu_command_list_begin(command_list); scratchResource->lpVtbl->Release(scratchResource); instanceDescs->lpVtbl->Release(instanceDescs); } -void iron_g5_raytrace_acceleration_structure_destroy(iron_g5_raytrace_acceleration_structure_t *accel) { +void iron_gpu_raytrace_acceleration_structure_destroy(iron_gpu_raytrace_acceleration_structure_t *accel) { // accel->impl.bottom_level_accel->Release(); // accel->impl.top_level_accel->Release(); } -void iron_g5_raytrace_set_textures(iron_g5_texture_t *texpaint0, iron_g5_texture_t *texpaint1, iron_g5_texture_t *texpaint2, iron_g5_texture_t *texenv, iron_g5_texture_t *texsobol, iron_g5_texture_t *texscramble, iron_g5_texture_t *texrank) { +void iron_gpu_raytrace_set_textures(iron_gpu_texture_t *texpaint0, iron_gpu_texture_t *texpaint1, iron_gpu_texture_t *texpaint2, iron_gpu_texture_t *texenv, iron_gpu_texture_t *texsobol, iron_gpu_texture_t *texscramble, iron_gpu_texture_t *texrank) { D3D12_CPU_DESCRIPTOR_HANDLE handle; descriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptorHeap, &handle); @@ -3481,15 +3481,15 @@ void iron_g5_raytrace_set_textures(iron_g5_texture_t *texpaint0, iron_g5_texture texrankgpuDescriptorHandle.ptr = ghandle.ptr + 11 * (UINT64)(descriptorSize); } -void iron_g5_raytrace_set_acceleration_structure(iron_g5_raytrace_acceleration_structure_t *_accel) { +void iron_gpu_raytrace_set_acceleration_structure(iron_gpu_raytrace_acceleration_structure_t *_accel) { accel = _accel; } -void iron_g5_raytrace_set_pipeline(iron_g5_raytrace_pipeline_t *_pipeline) { +void iron_gpu_raytrace_set_pipeline(iron_gpu_raytrace_pipeline_t *_pipeline) { pipeline = _pipeline; } -void iron_g5_raytrace_set_target(iron_g5_texture_t *_output) { +void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { if (_output != output) { _output->impl.renderTarget->lpVtbl->Release(_output->impl.renderTarget); _output->impl.renderTargetDescriptorHeap->lpVtbl->Release(_output->impl.renderTargetDescriptorHeap); @@ -3560,7 +3560,7 @@ void iron_g5_raytrace_set_target(iron_g5_texture_t *_output) { output = _output; } -void iron_g5_raytrace_dispatch_rays(iron_g5_command_list_t *command_list) { +void iron_gpu_raytrace_dispatch_rays(iron_gpu_command_list_t *command_list) { command_list->impl._commandList->lpVtbl->SetComputeRootSignature(command_list->impl._commandList, dxrRootSignature); // Bind the heaps, acceleration structure and dispatch rays diff --git a/base/sources/backends/direct3d12_gpu.h b/base/sources/backends/direct3d12_gpu.h index 8168bfa2..55d38c78 100644 --- a/base/sources/backends/direct3d12_gpu.h +++ b/base/sources/backends/direct3d12_gpu.h @@ -45,16 +45,16 @@ struct dx_window { bool vsync; }; -struct iron_g5_pipeline; -struct iron_g5_texture; -struct iron_g5_sampler; +struct iron_gpu_pipeline; +struct iron_gpu_texture; +struct iron_gpu_sampler; #define IRON_INTERNAL_G5_TEXTURE_COUNT 16 typedef struct { struct ID3D12CommandAllocator *_commandAllocator; struct ID3D12GraphicsCommandList *_commandList; - struct iron_g5_pipeline *_currentPipeline; + struct iron_gpu_pipeline *_currentPipeline; int _indexCount; bool open; @@ -64,8 +64,8 @@ typedef struct { struct ID3D12Fence *fence; HANDLE fence_event; - struct iron_g5_texture *currentTextures[IRON_INTERNAL_G5_TEXTURE_COUNT]; - struct iron_g5_sampler *current_samplers[IRON_INTERNAL_G5_TEXTURE_COUNT]; + struct iron_gpu_texture *currentTextures[IRON_INTERNAL_G5_TEXTURE_COUNT]; + struct iron_gpu_sampler *current_samplers[IRON_INTERNAL_G5_TEXTURE_COUNT]; int heapIndex; struct ID3D12DescriptorHeap *srvHeap; @@ -85,7 +85,7 @@ typedef struct { uint32_t index; } iron_internal_hash_index_t; -typedef struct iron_g5_compute_shader_impl { +typedef struct iron_gpu_compute_shader_impl { iron_compute_internal_shader_constant_t constants[64]; int constantsSize; iron_internal_hash_index_t attributes[64]; @@ -94,9 +94,9 @@ typedef struct iron_g5_compute_shader_impl { int length; struct ID3D12Buffer *constantBuffer; struct ID3D12PipelineState *pso; -} iron_g5_compute_shader_impl; +} iron_gpu_compute_shader_impl; -struct iron_g5_shader; +struct iron_gpu_shader; struct ID3D12PipelineState; struct ID3D12GraphicsCommandList; @@ -132,14 +132,14 @@ typedef struct { int nothing; } AttributeLocation5Impl; -struct iron_g5_pipeline; -struct iron_g5_command_list; +struct iron_gpu_pipeline; +struct iron_gpu_command_list; -void iron_g5_internal_setConstants(struct iron_g5_command_list *commandList, struct iron_g5_pipeline *pipeline); +void iron_gpu_internal_setConstants(struct iron_gpu_command_list *commandList, struct iron_gpu_pipeline *pipeline); -typedef struct iron_g5_sampler_impl { +typedef struct iron_gpu_sampler_impl { struct ID3D12DescriptorHeap *sampler_heap; -} iron_g5_sampler_impl_t; +} iron_gpu_sampler_impl_t; typedef struct { char name[64]; @@ -200,11 +200,11 @@ typedef struct { int framebuffer_index; } Texture5Impl; -struct iron_g5_texture; -struct iron_g5_command_list; +struct iron_gpu_texture; +struct iron_gpu_command_list; -void iron_g5_internal_set_textures(struct iron_g5_command_list *commandList); -void iron_g5_internal_texture_set(struct iron_g5_command_list *commandList, struct iron_g5_texture *texture, int unit); +void iron_gpu_internal_set_textures(struct iron_gpu_command_list *commandList); +void iron_gpu_internal_texture_set(struct iron_gpu_command_list *commandList, struct iron_gpu_texture *texture, int unit); struct ID3D12Resource; @@ -247,9 +247,9 @@ typedef struct { int last_count; } IndexBuffer5Impl; -struct iron_g5_index_buffer; +struct iron_gpu_index_buffer; -void iron_g5_internal_index_buffer_upload(struct iron_g5_index_buffer *buffer, struct ID3D12GraphicsCommandList *commandList); +void iron_gpu_internal_index_buffer_upload(struct iron_gpu_index_buffer *buffer, struct ID3D12GraphicsCommandList *commandList); struct ID3D12StateObject; struct ID3D12Resource; @@ -259,9 +259,9 @@ typedef struct { struct ID3D12Resource *raygen_shader_table; struct ID3D12Resource *miss_shader_table; struct ID3D12Resource *hitgroup_shader_table; -} iron_g5_raytrace_pipeline_impl_t; +} iron_gpu_raytrace_pipeline_impl_t; typedef struct { struct ID3D12Resource *bottom_level_accel[16]; struct ID3D12Resource *top_level_accel; -} iron_g5_raytrace_acceleration_structure_impl_t; +} iron_gpu_raytrace_acceleration_structure_impl_t; diff --git a/base/sources/backends/ios_system.h b/base/sources/backends/ios_system.h index ce0ac53a..68090bac 100644 --- a/base/sources/backends/ios_system.h +++ b/base/sources/backends/ios_system.h @@ -4,7 +4,7 @@ #import #import -struct iron_g5_texture; +struct iron_gpu_texture; @interface GLView : UIView { @private diff --git a/base/sources/backends/ios_system.m b/base/sources/backends/ios_system.m index 243647e0..815fb35c 100644 --- a/base/sources/backends/ios_system.m +++ b/base/sources/backends/ios_system.m @@ -620,8 +620,8 @@ void iron_init(const char *name, int width, int height, struct iron_window_optio iron_window_options_set_defaults(&defaultWin); win = &defaultWin; } - iron_g5_internal_init(); - iron_g4_internal_init_window(win->depth_bits, true); + iron_gpu_internal_init(); + gpu_internal_init_window(win->depth_bits, true); } void endGL(void); diff --git a/base/sources/backends/linux_system.c b/base/sources/backends/linux_system.c index 82943f28..63f45fb5 100644 --- a/base/sources/backends/linux_system.c +++ b/base/sources/backends/linux_system.c @@ -340,7 +340,7 @@ int iron_window_display() { } void iron_window_destroy() { - iron_g5_internal_destroy_window(); + iron_gpu_internal_destroy_window(); xlib.XFlush(x11_ctx.display); struct iron_x11_window *window = &x11_ctx.windows[0]; @@ -424,7 +424,7 @@ void iron_window_create(iron_window_options_t *win) { xlib.XSelectExtensionEvent(x11_ctx.display, window->window, &x11_ctx.eraser.motionClass, 1); } - iron_g4_internal_init_window(win->depth_bits, win->vsync); + gpu_internal_init_window(win->depth_bits, win->vsync); } static struct { @@ -1443,7 +1443,7 @@ void iron_init(const char *name, int width, int height, iron_window_options_t *w iron_set_app_name(name); - iron_g5_internal_init(); + iron_gpu_internal_init(); iron_window_options_t defaultWin; if (win == NULL) { @@ -1460,7 +1460,7 @@ void iron_init(const char *name, int width, int height, iron_window_options_t *w } void iron_internal_shutdown() { - iron_g5_internal_destroy(); + iron_gpu_internal_destroy(); iron_linux_closeHIDGamepads(); free(clipboardString); xlib.XCloseDisplay(x11_ctx.display); diff --git a/base/sources/backends/linux_video.c b/base/sources/backends/linux_video.c index 0137c6be..bc9a1bab 100644 --- a/base/sources/backends/linux_video.c +++ b/base/sources/backends/linux_video.c @@ -18,7 +18,7 @@ // return 256; // } -// iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { +// iron_gpu_texture_t *iron_video_current_image(iron_video_t *video) { // return NULL; // } diff --git a/base/sources/backends/macos_system.h b/base/sources/backends/macos_system.h index 8bc4b1d3..68e88479 100644 --- a/base/sources/backends/macos_system.h +++ b/base/sources/backends/macos_system.h @@ -8,7 +8,7 @@ #include #include -struct iron_g5_texture; +struct iron_gpu_texture; @interface BasicOpenGLView : MTKView { @private diff --git a/base/sources/backends/macos_system.m b/base/sources/backends/macos_system.m index 06190372..403cdcdb 100644 --- a/base/sources/backends/macos_system.m +++ b/base/sources/backends/macos_system.m @@ -1230,8 +1230,8 @@ void iron_init(const char *name, int width, int height, iron_window_options_t *w } createWindow(win); - iron_g5_internal_init(); - iron_g4_internal_init_window(win->depth_bits, true); + iron_gpu_internal_init(); + gpu_internal_init_window(win->depth_bits, true); } int iron_window_width() { diff --git a/base/sources/backends/metal_gpu.h b/base/sources/backends/metal_gpu.h index cff03c51..f1e72d87 100644 --- a/base/sources/backends/metal_gpu.h +++ b/base/sources/backends/metal_gpu.h @@ -5,24 +5,24 @@ #pragma once -struct iron_g5_index_buffer; +struct iron_gpu_index_buffer; typedef struct { - struct iron_g5_index_buffer *current_index_buffer; + struct iron_gpu_index_buffer *current_index_buffer; } CommandList5Impl; -typedef struct iron_g5_compute_shader_impl { +typedef struct iron_gpu_compute_shader_impl { char name[1024]; void *_function; void *_pipeline; void *_reflection; -} iron_g5_compute_shader_impl; +} iron_gpu_compute_shader_impl; -struct iron_g5_shader; +struct iron_gpu_shader; typedef struct { - struct iron_g5_shader *vertex_shader; - struct iron_g5_shader *fragment_shader; + struct iron_gpu_shader *vertex_shader; + struct iron_gpu_shader *fragment_shader; void *_pipeline; void *_pipelineDepth; void *_reflection; @@ -40,9 +40,9 @@ typedef struct { int computeOffset; } ConstantLocation5Impl; -typedef struct iron_g5_sampler_impl { +typedef struct iron_gpu_sampler_impl { void *sampler; -} iron_g5_sampler_impl_t; +} iron_gpu_sampler_impl_t; typedef struct { char name[1024]; @@ -51,11 +51,11 @@ typedef struct { typedef struct { void *_raytracingPipeline; -} iron_g5_raytrace_pipeline_impl_t; +} iron_gpu_raytrace_pipeline_impl_t; typedef struct { void *_accelerationStructure; -} iron_g5_raytrace_acceleration_structure_impl_t; +} iron_gpu_raytrace_acceleration_structure_impl_t; typedef struct { int index; diff --git a/base/sources/backends/metal_gpu.m b/base/sources/backends/metal_gpu.m index c8a5df8a..e61472b8 100644 --- a/base/sources/backends/metal_gpu.m +++ b/base/sources/backends/metal_gpu.m @@ -26,23 +26,23 @@ id drawable; id depthTexture; int depthBits; bool iron_internal_metal_has_depth = false; -static iron_g5_texture_t fallback_render_target; +static iron_gpu_texture_t fallback_render_target; static int framebuffer_count = 0; -void iron_g5_internal_new_render_pass(iron_g5_texture_t **renderTargets, int count, bool wait, unsigned clear_flags, unsigned color, float depth); -void iron_g5_internal_pipeline_set(iron_g5_pipeline_t *pipeline); -static iron_g5_texture_t *lastRenderTargets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; -static iron_g5_pipeline_t *lastPipeline = NULL; +void iron_gpu_internal_new_render_pass(iron_gpu_texture_t **renderTargets, int count, bool wait, unsigned clear_flags, unsigned color, float depth); +void iron_gpu_internal_pipeline_set(iron_gpu_pipeline_t *pipeline); +static iron_gpu_texture_t *lastRenderTargets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +static iron_gpu_pipeline_t *lastPipeline = NULL; extern bool iron_internal_metal_has_depth; id getMetalDevice(void); id getMetalQueue(void); id getMetalEncoder(void); id getMetalLibrary(void); bool iron_internal_current_render_target_has_depth(void); -static iron_g5_raytrace_acceleration_structure_t *accel; -static iron_g5_raytrace_pipeline_t *pipeline; -static iron_g5_texture_t *output = NULL; -static iron_g5_constant_buffer_t *constant_buf; +static iron_gpu_raytrace_acceleration_structure_t *accel; +static iron_gpu_raytrace_pipeline_t *pipeline; +static iron_gpu_texture_t *output = NULL; +static iron_gpu_constant_buffer_t *constant_buf; typedef struct inst { iron_matrix4x4_t m; @@ -54,50 +54,50 @@ NSMutableArray *_primitive_accels; id _instance_accel; dispatch_semaphore_t _sem; -static iron_g5_texture_t *_texpaint0; -static iron_g5_texture_t *_texpaint1; -static iron_g5_texture_t *_texpaint2; -static iron_g5_texture_t *_texenv; -static iron_g5_texture_t *_texsobol; -static iron_g5_texture_t *_texscramble; -static iron_g5_texture_t *_texrank; +static iron_gpu_texture_t *_texpaint0; +static iron_gpu_texture_t *_texpaint1; +static iron_gpu_texture_t *_texpaint2; +static iron_gpu_texture_t *_texenv; +static iron_gpu_texture_t *_texsobol; +static iron_gpu_texture_t *_texscramble; +static iron_gpu_texture_t *_texrank; -static iron_g5_vertex_buffer_t *vb[16]; -static iron_g5_vertex_buffer_t *vb_last[16]; -static iron_g5_index_buffer_t *ib[16]; +static iron_gpu_vertex_buffer_t *vb[16]; +static iron_gpu_vertex_buffer_t *vb_last[16]; +static iron_gpu_index_buffer_t *ib[16]; static int vb_count = 0; static int vb_count_last = 0; static inst_t instances[1024]; static int instances_count = 0; -iron_g5_vertex_buffer_t *currentVertexBuffer = NULL; -bool iron_g5_transpose_mat = true; +iron_gpu_vertex_buffer_t *currentVertexBuffer = NULL; +bool iron_gpu_transpose_mat = true; id getMetalEncoder(void) { return render_command_encoder; } -void iron_g5_internal_destroy_window() { +void iron_gpu_internal_destroy_window() { } -void iron_g5_internal_destroy(void) { +void iron_gpu_internal_destroy(void) { } -void iron_g5_internal_resize(int, int); +void iron_gpu_internal_resize(int, int); void iron_internal_resize(int width, int height) { - iron_g5_internal_resize(width, height); + iron_gpu_internal_resize(width, height); } -void iron_g5_internal_init(void) { +void iron_gpu_internal_init(void) { } -void iron_g5_internal_init_window(int depthBufferBits, bool vsync) { +void iron_gpu_internal_init_window(int depthBufferBits, bool vsync) { depthBits = depthBufferBits; - iron_g5_render_target_init(&fallback_render_target, 32, 32, IRON_IMAGE_FORMAT_RGBA32, 0); + iron_gpu_render_target_init(&fallback_render_target, 32, 32, IRON_IMAGE_FORMAT_RGBA32, 0); } -void iron_g5_flush(void) { +void iron_gpu_flush(void) { } bool iron_internal_current_render_target_has_depth(void) { @@ -128,7 +128,7 @@ static void end_render_pass(void) { render_command_encoder = nil; } -void iron_g5_begin(iron_g5_texture_t *renderTarget) { +void iron_gpu_begin(iron_gpu_texture_t *renderTarget) { CAMetalLayer *metalLayer = getMetalLayer(); drawable = [metalLayer nextDrawable]; @@ -176,10 +176,10 @@ void iron_g5_begin(iron_g5_texture_t *renderTarget) { render_command_encoder = [command_buffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; } -void iron_g5_end() { +void iron_gpu_end() { } -bool iron_g5_swap_buffers(void) { +bool iron_gpu_swap_buffers(void) { if (command_buffer != nil && render_command_encoder != nil) { [render_command_encoder endEncoding]; [command_buffer presentDrawable:drawable]; @@ -192,7 +192,7 @@ bool iron_g5_swap_buffers(void) { return true; } -void iron_g5_internal_new_render_pass(iron_g5_texture_t **renderTargets, int count, bool wait, unsigned clear_flags, unsigned color, float depth) { +void iron_gpu_internal_new_render_pass(iron_gpu_texture_t **renderTargets, int count, bool wait, unsigned clear_flags, unsigned color, float depth) { if (command_buffer != nil && render_command_encoder != nil) { [render_command_encoder endEncoding]; [command_buffer commit]; @@ -223,7 +223,7 @@ void iron_g5_internal_new_render_pass(iron_g5_texture_t **renderTargets, int cou renderPassDescriptor.stencilAttachment.texture = (__bridge id)renderTargets[0]->impl._depthTex; iron_internal_metal_has_depth = renderTargets[0]->impl._depthTex != nil; } - if (clear_flags & IRON_G5_CLEAR_COLOR) { + if (clear_flags & IRON_GPU_CLEAR_COLOR) { float red, green, blue, alpha; iron_color_components(color, &red, &green, &blue, &alpha); renderPassDescriptor.colorAttachments[i].loadAction = MTLLoadActionClear; @@ -237,7 +237,7 @@ void iron_g5_internal_new_render_pass(iron_g5_texture_t **renderTargets, int cou } } - if (clear_flags & IRON_G5_CLEAR_DEPTH) { + if (clear_flags & IRON_GPU_CLEAR_DEPTH) { renderPassDescriptor.depthAttachment.clearDepth = depth; renderPassDescriptor.depthAttachment.loadAction = MTLLoadActionClear; renderPassDescriptor.depthAttachment.storeAction = MTLStoreActionStore; @@ -257,15 +257,15 @@ void iron_g5_internal_new_render_pass(iron_g5_texture_t **renderTargets, int cou render_command_encoder = [command_buffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; } -int iron_g5_max_bound_textures(void) { +int iron_gpu_max_bound_textures(void) { return 16; } -void iron_g5_command_list_init(iron_g5_command_list_t *list) { +void iron_gpu_command_list_init(iron_gpu_command_list_t *list) { list->impl.current_index_buffer = NULL; } -void iron_g5_command_list_destroy(iron_g5_command_list_t *list) {} +void iron_gpu_command_list_destroy(iron_gpu_command_list_t *list) {} static int formatSize(MTLPixelFormat format) { switch (format) { @@ -282,31 +282,31 @@ static int formatSize(MTLPixelFormat format) { } } -void iron_g5_command_list_begin(iron_g5_command_list_t *list) { +void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { list->impl.current_index_buffer = NULL; lastRenderTargets[0] = NULL; } -void iron_g5_command_list_end(iron_g5_command_list_t *list) {} +void iron_gpu_command_list_end(iron_gpu_command_list_t *list) {} -void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget, unsigned flags, unsigned color, float depth) { +void iron_gpu_command_list_clear(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget, unsigned flags, unsigned color, float depth) { if (renderTarget->framebuffer_index >= 0) { - iron_g5_internal_new_render_pass(NULL, 1, false, flags, color, depth); + iron_gpu_internal_new_render_pass(NULL, 1, false, flags, color, depth); } else { - iron_g5_internal_new_render_pass(&renderTarget, 1, false, flags, color, depth); + iron_gpu_internal_new_render_pass(&renderTarget, 1, false, flags, color, depth); } } -void iron_g5_command_list_render_target_to_framebuffer_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} +void iron_gpu_command_list_render_target_to_framebuffer_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) {} -void iron_g5_command_list_framebuffer_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} +void iron_gpu_command_list_framebuffer_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) {} -void iron_g5_command_list_draw_indexed_vertices(iron_g5_command_list_t *list) { - iron_g5_command_list_draw_indexed_vertices_from_to(list, 0, iron_g5_index_buffer_count(list->impl.current_index_buffer)); +void iron_gpu_command_list_draw_indexed_vertices(iron_gpu_command_list_t *list) { + iron_gpu_command_list_draw_indexed_vertices_from_to(list, 0, iron_gpu_index_buffer_count(list->impl.current_index_buffer)); } -void iron_g5_command_list_draw_indexed_vertices_from_to(iron_g5_command_list_t *list, int start, int count) { +void iron_gpu_command_list_draw_indexed_vertices_from_to(iron_gpu_command_list_t *list, int start, int count) { id indexBuffer = (__bridge id)list->impl.current_index_buffer->impl.metal_buffer; id encoder = getMetalEncoder(); [encoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle @@ -316,7 +316,7 @@ void iron_g5_command_list_draw_indexed_vertices_from_to(iron_g5_command_list_t * indexBufferOffset:start * 4]; } -void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_gpu_command_list_viewport(iron_gpu_command_list_t *list, int x, int y, int width, int height) { id encoder = getMetalEncoder(); MTLViewport viewport; viewport.originX = x; @@ -328,7 +328,7 @@ void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, i [encoder setViewport:viewport]; } -void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_gpu_command_list_scissor(iron_gpu_command_list_t *list, int x, int y, int width, int height) { id encoder = getMetalEncoder(); MTLScissorRect scissor; scissor.x = x; @@ -348,7 +348,7 @@ void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, in [encoder setScissorRect:scissor]; } -void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list) { +void iron_gpu_command_list_disable_scissor(iron_gpu_command_list_t *list) { id encoder = getMetalEncoder(); MTLScissorRect scissor; scissor.x = 0; @@ -364,41 +364,41 @@ void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list) { [encoder setScissorRect:scissor]; } -void iron_g5_command_list_set_pipeline(iron_g5_command_list_t *list, struct iron_g5_pipeline *pipeline) { - iron_g5_internal_pipeline_set(pipeline); +void iron_gpu_command_list_set_pipeline(iron_gpu_command_list_t *list, struct iron_gpu_pipeline *pipeline) { + iron_gpu_internal_pipeline_set(pipeline); lastPipeline = pipeline; } -void iron_g5_command_list_set_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) { - iron_g5_internal_vertex_buffer_set(buffer); +void iron_gpu_command_list_set_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_vertex_buffer *buffer) { + iron_gpu_internal_vertex_buffer_set(buffer); } -void iron_g5_command_list_set_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) { +void iron_gpu_command_list_set_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_index_buffer *buffer) { list->impl.current_index_buffer = buffer; } -void iron_g5_command_list_set_render_targets(iron_g5_command_list_t *list, struct iron_g5_texture **targets, int count) { +void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, struct iron_gpu_texture **targets, int count) { if (targets[0]->framebuffer_index >= 0) { for (int i = 0; i < 8; ++i) lastRenderTargets[i] = NULL; - iron_g5_internal_new_render_pass(NULL, 1, false, 0, 0, 0.0f); + iron_gpu_internal_new_render_pass(NULL, 1, false, 0, 0, 0.0f); } else { for (int i = 0; i < count; ++i) lastRenderTargets[i] = targets[i]; for (int i = count; i < 8; ++i) lastRenderTargets[i] = NULL; - iron_g5_internal_new_render_pass(targets, count, false, 0, 0, 0.0f); + iron_gpu_internal_new_render_pass(targets, count, false, 0, 0, 0.0f); } } -void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) {} +void iron_gpu_command_list_upload_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_index_buffer *buffer) {} -void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) {} +void iron_gpu_command_list_upload_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_vertex_buffer *buffer) {} -void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, struct iron_g5_texture *texture) {} +void iron_gpu_command_list_upload_texture(iron_gpu_command_list_t *list, struct iron_gpu_texture *texture) {} -void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, iron_g5_texture_t *render_target, uint8_t *data) { +void iron_gpu_command_list_get_render_target_pixels(iron_gpu_command_list_t *list, iron_gpu_texture_t *render_target, uint8_t *data) { // Create readback buffer if (render_target->impl._texReadback == NULL) { id device = getMetalDevice(); @@ -439,89 +439,89 @@ void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, [tex getBytes:data bytesPerRow:formatByteSize * render_target->width fromRegion:region mipmapLevel:0]; } -void iron_g5_command_list_execute(iron_g5_command_list_t *list) { +void iron_gpu_command_list_execute(iron_gpu_command_list_t *list) { if (lastRenderTargets[0] == NULL) { - iron_g5_internal_new_render_pass(NULL, 1, false, 0, 0, 0.0f); + iron_gpu_internal_new_render_pass(NULL, 1, false, 0, 0, 0.0f); } else { int count = 1; while (lastRenderTargets[count] != NULL) count++; - iron_g5_internal_new_render_pass(lastRenderTargets, count, false, 0, 0, 0.0f); + iron_gpu_internal_new_render_pass(lastRenderTargets, count, false, 0, 0, 0.0f); } if (lastPipeline != NULL) - iron_g5_internal_pipeline_set(lastPipeline); + iron_gpu_internal_pipeline_set(lastPipeline); } -void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list) { +void iron_gpu_command_list_wait_for_execution_to_finish(iron_gpu_command_list_t *list) { id commandQueue = getMetalQueue(); id commandBuffer = [commandQueue commandBuffer]; [commandBuffer commit]; [commandBuffer waitUntilCompleted]; } -void iron_g5_command_list_set_vertex_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_vertex_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { id buf = (__bridge id)buffer->impl._buffer; id encoder = getMetalEncoder(); [encoder setVertexBuffer:buf offset:offset atIndex:1]; } -void iron_g5_command_list_set_fragment_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_fragment_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { id buf = (__bridge id)buffer->impl._buffer; id encoder = getMetalEncoder(); [encoder setFragmentBuffer:buf offset:offset atIndex:0]; } -void iron_g5_command_list_set_compute_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_compute_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { assert(compute_command_encoder != nil); id buf = (__bridge id)buffer->impl._buffer; [compute_command_encoder setBuffer:buf offset:offset atIndex:1]; } -void iron_g5_command_list_render_target_to_texture_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) { +void iron_gpu_command_list_render_target_to_texture_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) { } -void iron_g5_command_list_texture_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} +void iron_gpu_command_list_texture_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) {} -void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { +void iron_gpu_command_list_set_texture(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *texture) { id tex = (__bridge id)texture->impl._tex; if (compute_command_encoder != nil) { - [compute_command_encoder setTexture:tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_COMPUTE]]; + [compute_command_encoder setTexture:tex atIndex:unit.stages[IRON_GPU_SHADER_TYPE_COMPUTE]]; } else { - if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { - [render_command_encoder setVertexTexture:tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_VERTEX]]; + if (unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] >= 0) { + [render_command_encoder setVertexTexture:tex atIndex:unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]]; } - if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { - [render_command_encoder setFragmentTexture:tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]]; + if (unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] >= 0) { + [render_command_encoder setFragmentTexture:tex atIndex:unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]]; } } } -void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *target) { +void iron_gpu_command_list_set_texture_from_render_target_depth(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *target) { id encoder = getMetalEncoder(); id depth_tex = (__bridge id)target->impl._depthTex; - if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { - [encoder setVertexTexture:depth_tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_VERTEX]]; + if (unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] >= 0) { + [encoder setVertexTexture:depth_tex atIndex:unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]]; } - if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { - [encoder setFragmentTexture:depth_tex atIndex:unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]]; + if (unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] >= 0) { + [encoder setFragmentTexture:depth_tex atIndex:unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]]; } } -void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler) { +void iron_gpu_command_list_set_sampler(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_sampler_t *sampler) { id encoder = getMetalEncoder(); id mtl_sampler = (__bridge id)sampler->impl.sampler; - if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { - [encoder setVertexSamplerState:mtl_sampler atIndex:unit.stages[IRON_G5_SHADER_TYPE_VERTEX]]; + if (unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] >= 0) { + [encoder setVertexSamplerState:mtl_sampler atIndex:unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]]; } - if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { - [encoder setFragmentSamplerState:mtl_sampler atIndex:unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]]; + if (unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] >= 0) { + [encoder setFragmentSamplerState:mtl_sampler atIndex:unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]]; } } -void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, iron_g5_compute_shader *shader) { +void iron_gpu_command_list_set_compute_shader(iron_gpu_command_list_t *list, iron_gpu_compute_shader *shader) { if (compute_command_encoder == nil) { end_render_pass(); compute_command_encoder = [command_buffer computeCommandEncoder]; @@ -531,7 +531,7 @@ void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, iron_ [compute_command_encoder setComputePipelineState:pipeline]; } -void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z) { +void iron_gpu_command_list_compute(iron_gpu_command_list_t *list, int x, int y, int z) { assert(compute_command_encoder != nil); MTLSize perGrid; @@ -551,7 +551,7 @@ void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, in start_render_pass(); } -void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *_data, int length) { +void iron_gpu_compute_shader_init(iron_gpu_compute_shader *shader, void *_data, int length) { shader->impl.name[0] = 0; { @@ -599,7 +599,7 @@ void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *_data, in shader->impl._reflection = (__bridge_retained void *)reflection; } -void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader) { +void iron_gpu_compute_shader_destroy(iron_gpu_compute_shader *shader) { id function = (__bridge_transfer id)shader->impl._function; function = nil; shader->impl._function = NULL; @@ -613,8 +613,8 @@ void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader) { shader->impl._reflection = NULL; } -iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name) { - iron_g5_constant_location_t location; +iron_gpu_constant_location_t iron_gpu_compute_shader_get_constant_location(iron_gpu_compute_shader *shader, const char *name) { + iron_gpu_constant_location_t location; location.impl.vertexOffset = -1; location.impl.fragmentOffset = -1; location.impl.computeOffset = -1; @@ -639,94 +639,94 @@ iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5 return location; } -iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name) { - iron_g5_texture_unit_t unit; - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { +iron_gpu_texture_unit_t iron_gpu_compute_shader_get_texture_unit(iron_gpu_compute_shader *shader, const char *name) { + iron_gpu_texture_unit_t unit; + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } MTLComputePipelineReflection *reflection = (__bridge MTLComputePipelineReflection *)shader->impl._reflection; for (MTLArgument *arg in reflection.arguments) { if ([arg type] == MTLArgumentTypeTexture && strcmp([[arg name] UTF8String], name) == 0) { - unit.stages[IRON_G5_SHADER_TYPE_COMPUTE] = (int)[arg index]; + unit.stages[IRON_GPU_SHADER_TYPE_COMPUTE] = (int)[arg index]; } } return unit; } -static MTLBlendFactor convert_blending_factor(iron_g5_blending_factor_t factor) { +static MTLBlendFactor convert_blending_factor(iron_gpu_blending_factor_t factor) { switch (factor) { - case IRON_G5_BLEND_ONE: + case IRON_GPU_BLEND_ONE: return MTLBlendFactorOne; - case IRON_G5_BLEND_ZERO: + case IRON_GPU_BLEND_ZERO: return MTLBlendFactorZero; - case IRON_G5_BLEND_SOURCE_ALPHA: + case IRON_GPU_BLEND_SOURCE_ALPHA: return MTLBlendFactorSourceAlpha; - case IRON_G5_BLEND_DEST_ALPHA: + case IRON_GPU_BLEND_DEST_ALPHA: return MTLBlendFactorDestinationAlpha; - case IRON_G5_BLEND_INV_SOURCE_ALPHA: + case IRON_GPU_BLEND_INV_SOURCE_ALPHA: return MTLBlendFactorOneMinusSourceAlpha; - case IRON_G5_BLEND_INV_DEST_ALPHA: + case IRON_GPU_BLEND_INV_DEST_ALPHA: return MTLBlendFactorOneMinusDestinationAlpha; - case IRON_G5_BLEND_SOURCE_COLOR: + case IRON_GPU_BLEND_SOURCE_COLOR: return MTLBlendFactorSourceColor; - case IRON_G5_BLEND_DEST_COLOR: + case IRON_GPU_BLEND_DEST_COLOR: return MTLBlendFactorDestinationColor; - case IRON_G5_BLEND_INV_SOURCE_COLOR: + case IRON_GPU_BLEND_INV_SOURCE_COLOR: return MTLBlendFactorOneMinusSourceColor; - case IRON_G5_BLEND_INV_DEST_COLOR: + case IRON_GPU_BLEND_INV_DEST_COLOR: return MTLBlendFactorOneMinusDestinationColor; - case IRON_G5_BLEND_CONSTANT: + case IRON_GPU_BLEND_CONSTANT: return MTLBlendFactorBlendColor; - case IRON_G5_BLEND_INV_CONSTANT: + case IRON_GPU_BLEND_INV_CONSTANT: return MTLBlendFactorOneMinusBlendColor; } } -static MTLBlendOperation convert_blending_operation(iron_g5_blending_operation_t op) { +static MTLBlendOperation convert_blending_operation(iron_gpu_blending_operation_t op) { switch (op) { - case IRON_G5_BLENDOP_ADD: + case IRON_GPU_BLENDOP_ADD: return MTLBlendOperationAdd; - case IRON_G5_BLENDOP_SUBTRACT: + case IRON_GPU_BLENDOP_SUBTRACT: return MTLBlendOperationSubtract; - case IRON_G5_BLENDOP_REVERSE_SUBTRACT: + case IRON_GPU_BLENDOP_REVERSE_SUBTRACT: return MTLBlendOperationReverseSubtract; - case IRON_G5_BLENDOP_MIN: + case IRON_GPU_BLENDOP_MIN: return MTLBlendOperationMin; - case IRON_G5_BLENDOP_MAX: + case IRON_GPU_BLENDOP_MAX: return MTLBlendOperationMax; } } -static MTLCompareFunction convert_compare_mode(iron_g5_compare_mode_t compare) { +static MTLCompareFunction convert_compare_mode(iron_gpu_compare_mode_t compare) { switch (compare) { - case IRON_G5_COMPARE_MODE_ALWAYS: + case IRON_GPU_COMPARE_MODE_ALWAYS: return MTLCompareFunctionAlways; - case IRON_G5_COMPARE_MODE_NEVER: + case IRON_GPU_COMPARE_MODE_NEVER: return MTLCompareFunctionNever; - case IRON_G5_COMPARE_MODE_EQUAL: + case IRON_GPU_COMPARE_MODE_EQUAL: return MTLCompareFunctionEqual; - case IRON_G5_COMPARE_MODE_NOT_EQUAL: + case IRON_GPU_COMPARE_MODE_NOT_EQUAL: return MTLCompareFunctionNotEqual; - case IRON_G5_COMPARE_MODE_LESS: + case IRON_GPU_COMPARE_MODE_LESS: return MTLCompareFunctionLess; - case IRON_G5_COMPARE_MODE_LESS_EQUAL: + case IRON_GPU_COMPARE_MODE_LESS_EQUAL: return MTLCompareFunctionLessEqual; - case IRON_G5_COMPARE_MODE_GREATER: + case IRON_GPU_COMPARE_MODE_GREATER: return MTLCompareFunctionGreater; - case IRON_G5_COMPARE_MODE_GREATER_EQUAL: + case IRON_GPU_COMPARE_MODE_GREATER_EQUAL: return MTLCompareFunctionGreaterEqual; } } -static MTLCullMode convert_cull_mode(iron_g5_cull_mode_t cull) { +static MTLCullMode convert_cull_mode(iron_gpu_cull_mode_t cull) { switch (cull) { - case IRON_G5_CULL_MODE_CLOCKWISE: + case IRON_GPU_CULL_MODE_CLOCKWISE: return MTLCullModeFront; - case IRON_G5_CULL_MODE_COUNTERCLOCKWISE: + case IRON_GPU_CULL_MODE_COUNTERCLOCKWISE: return MTLCullModeBack; - case IRON_G5_CULL_MODE_NEVER: + case IRON_GPU_CULL_MODE_NEVER: return MTLCullModeNone; } } @@ -749,12 +749,12 @@ static MTLPixelFormat convert_render_target_format(iron_image_format_t format) { } } -void iron_g5_pipeline_init(iron_g5_pipeline_t *pipeline) { +void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipeline) { memset(&pipeline->impl, 0, sizeof(pipeline->impl)); - iron_g5_internal_pipeline_set_defaults(pipeline); + iron_gpu_internal_pipeline_set_defaults(pipeline); } -void iron_g5_pipeline_destroy(iron_g5_pipeline_t *pipeline) { +void iron_gpu_pipeline_destroy(iron_gpu_pipeline_t *pipeline) { pipeline->impl._reflection = NULL; pipeline->impl._depthStencil = NULL; @@ -788,15 +788,15 @@ static int findAttributeIndex(NSArray *attributes, const c return -1; } -void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline) { +void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { MTLRenderPipelineDescriptor *renderPipelineDesc = [[MTLRenderPipelineDescriptor alloc] init]; renderPipelineDesc.vertexFunction = (__bridge id)pipeline->vertex_shader->impl.mtlFunction; renderPipelineDesc.fragmentFunction = (__bridge id)pipeline->fragment_shader->impl.mtlFunction; for (int i = 0; i < pipeline->color_attachment_count; ++i) { renderPipelineDesc.colorAttachments[i].pixelFormat = convert_render_target_format(pipeline->color_attachment[i]); renderPipelineDesc.colorAttachments[i].blendingEnabled = - pipeline->blend_source != IRON_G5_BLEND_ONE || pipeline->blend_destination != IRON_G5_BLEND_ZERO || - pipeline->alpha_blend_source != IRON_G5_BLEND_ONE || pipeline->alpha_blend_destination != IRON_G5_BLEND_ZERO; + pipeline->blend_source != IRON_GPU_BLEND_ONE || pipeline->blend_destination != IRON_GPU_BLEND_ZERO || + pipeline->alpha_blend_source != IRON_GPU_BLEND_ONE || pipeline->alpha_blend_destination != IRON_GPU_BLEND_ZERO; renderPipelineDesc.colorAttachments[i].sourceRGBBlendFactor = convert_blending_factor(pipeline->blend_source); renderPipelineDesc.colorAttachments[i].destinationRGBBlendFactor = convert_blending_factor(pipeline->blend_destination); renderPipelineDesc.colorAttachments[i].rgbBlendOperation = convert_blending_operation(pipeline->blend_operation); @@ -827,28 +827,28 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline) { vertexDescriptor.attributes[index].offset = offset; } - offset += iron_g5_vertex_data_size(pipeline->input_layout->elements[i].data); + offset += iron_gpu_vertex_data_size(pipeline->input_layout->elements[i].data); if (index >= 0) { switch (pipeline->input_layout->elements[i].data) { - case IRON_G5_VERTEX_DATA_F32_1X: + case IRON_GPU_VERTEX_DATA_F32_1X: vertexDescriptor.attributes[index].format = MTLVertexFormatFloat; break; - case IRON_G5_VERTEX_DATA_F32_2X: + case IRON_GPU_VERTEX_DATA_F32_2X: vertexDescriptor.attributes[index].format = MTLVertexFormatFloat2; break; - case IRON_G5_VERTEX_DATA_F32_3X: + case IRON_GPU_VERTEX_DATA_F32_3X: vertexDescriptor.attributes[index].format = MTLVertexFormatFloat3; break; - case IRON_G5_VERTEX_DATA_F32_4X: + case IRON_GPU_VERTEX_DATA_F32_4X: vertexDescriptor.attributes[index].format = MTLVertexFormatFloat4; break; - case IRON_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_GPU_VERTEX_DATA_U8_4X_NORM: vertexDescriptor.attributes[index].format = MTLVertexFormatUChar4Normalized; break; - case IRON_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_GPU_VERTEX_DATA_I16_2X_NORM: vertexDescriptor.attributes[index].format = MTLVertexFormatShort2Normalized; break; - case IRON_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_GPU_VERTEX_DATA_I16_4X_NORM: vertexDescriptor.attributes[index].format = MTLVertexFormatShort4Normalized; break; } @@ -894,7 +894,7 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline) { pipeline->impl._depthStencilNone = (__bridge_retained void *)[device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; } -void iron_g5_internal_pipeline_set(iron_g5_pipeline_t *pipeline) { +void iron_gpu_internal_pipeline_set(iron_gpu_pipeline_t *pipeline) { id encoder = getMetalEncoder(); if (iron_internal_current_render_target_has_depth()) { id pipe = (__bridge id)pipeline->impl._pipelineDepth; @@ -912,12 +912,12 @@ void iron_g5_internal_pipeline_set(iron_g5_pipeline_t *pipeline) { [encoder setCullMode:convert_cull_mode(pipeline->cull_mode)]; } -iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipeline_t *pipeline, const char *name) { +iron_gpu_constant_location_t iron_gpu_pipeline_get_constant_location(iron_gpu_pipeline_t *pipeline, const char *name) { if (strcmp(name, "bias") == 0) { name = "bias0"; } - iron_g5_constant_location_t location; + iron_gpu_constant_location_t location; location.impl.vertexOffset = -1; location.impl.fragmentOffset = -1; location.impl.computeOffset = -1; @@ -957,23 +957,23 @@ iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipel return location; } -iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipeline, const char *name) { - iron_g5_texture_unit_t unit = {0}; - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { +iron_gpu_texture_unit_t iron_gpu_pipeline_get_texture_unit(iron_gpu_pipeline_t *pipeline, const char *name) { + iron_gpu_texture_unit_t unit = {0}; + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } MTLRenderPipelineReflection *reflection = (__bridge MTLRenderPipelineReflection *)pipeline->impl._reflection; for (MTLArgument *arg in reflection.fragmentArguments) { if ([arg type] == MTLArgumentTypeTexture && strcmp([[arg name] UTF8String], name) == 0) { - unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] = (int)[arg index]; + unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] = (int)[arg index]; break; } } for (MTLArgument *arg in reflection.vertexArguments) { if ([arg type] == MTLArgumentTypeTexture && strcmp([[arg name] UTF8String], name) == 0) { - unit.stages[IRON_G5_SHADER_TYPE_VERTEX] = (int)[arg index]; + unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] = (int)[arg index]; break; } } @@ -981,15 +981,15 @@ iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pip return unit; } -static MTLSamplerAddressMode convert_addressing(iron_g5_texture_addressing_t mode) { +static MTLSamplerAddressMode convert_addressing(iron_gpu_texture_addressing_t mode) { switch (mode) { - case IRON_G5_TEXTURE_ADDRESSING_REPEAT: + case IRON_GPU_TEXTURE_ADDRESSING_REPEAT: return MTLSamplerAddressModeRepeat; - case IRON_G5_TEXTURE_ADDRESSING_BORDER: + case IRON_GPU_TEXTURE_ADDRESSING_BORDER: return MTLSamplerAddressModeClampToBorderColor; - case IRON_G5_TEXTURE_ADDRESSING_CLAMP: + case IRON_GPU_TEXTURE_ADDRESSING_CLAMP: return MTLSamplerAddressModeClampToEdge; - case IRON_G5_TEXTURE_ADDRESSING_MIRROR: + case IRON_GPU_TEXTURE_ADDRESSING_MIRROR: return MTLSamplerAddressModeMirrorRepeat; default: assert(false); @@ -997,13 +997,13 @@ static MTLSamplerAddressMode convert_addressing(iron_g5_texture_addressing_t mod } } -static MTLSamplerMipFilter convert_mipmap_mode(iron_g5_mipmap_filter_t filter) { +static MTLSamplerMipFilter convert_mipmap_mode(iron_gpu_mipmap_filter_t filter) { switch (filter) { - case IRON_G5_MIPMAP_FILTER_NONE: + case IRON_GPU_MIPMAP_FILTER_NONE: return MTLSamplerMipFilterNotMipmapped; - case IRON_G5_MIPMAP_FILTER_POINT: + case IRON_GPU_MIPMAP_FILTER_POINT: return MTLSamplerMipFilterNearest; - case IRON_G5_MIPMAP_FILTER_LINEAR: + case IRON_GPU_MIPMAP_FILTER_LINEAR: return MTLSamplerMipFilterLinear; default: assert(false); @@ -1011,13 +1011,13 @@ static MTLSamplerMipFilter convert_mipmap_mode(iron_g5_mipmap_filter_t filter) { } } -static MTLSamplerMinMagFilter convert_texture_filter(iron_g5_texture_filter_t filter) { +static MTLSamplerMinMagFilter convert_texture_filter(iron_gpu_texture_filter_t filter) { switch (filter) { - case IRON_G5_TEXTURE_FILTER_POINT: + case IRON_GPU_TEXTURE_FILTER_POINT: return MTLSamplerMinMagFilterNearest; - case IRON_G5_TEXTURE_FILTER_LINEAR: + case IRON_GPU_TEXTURE_FILTER_LINEAR: return MTLSamplerMinMagFilterLinear; - case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_GPU_TEXTURE_FILTER_ANISOTROPIC: return MTLSamplerMinMagFilterLinear; // ? default: assert(false); @@ -1025,7 +1025,7 @@ static MTLSamplerMinMagFilter convert_texture_filter(iron_g5_texture_filter_t fi } } -void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options) { +void iron_gpu_sampler_init(iron_gpu_sampler_t *sampler, const iron_gpu_sampler_options_t *options) { id device = getMetalDevice(); MTLSamplerDescriptor *desc = (MTLSamplerDescriptor *)[[MTLSamplerDescriptor alloc] init]; @@ -1042,18 +1042,18 @@ void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_opti sampler->impl.sampler = (__bridge_retained void *)[device newSamplerStateWithDescriptor:desc]; } -void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler) { +void iron_gpu_sampler_destroy(iron_gpu_sampler_t *sampler) { id mtl_sampler = (__bridge_transfer id)sampler->impl.sampler; mtl_sampler = nil; } -void iron_g5_shader_destroy(iron_g5_shader_t *shader) { +void iron_gpu_shader_destroy(iron_gpu_shader_t *shader) { id function = (__bridge_transfer id)shader->impl.mtlFunction; function = nil; shader->impl.mtlFunction = NULL; } -void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t length, iron_g5_shader_type_t type) { +void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *source, size_t length, iron_gpu_shader_type_t type) { shader->impl.name[0] = 0; { @@ -1094,13 +1094,13 @@ void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t le assert(shader->impl.mtlFunction); } -bool iron_g5_raytrace_supported() { +bool iron_gpu_raytrace_supported() { id device = getMetalDevice(); return device.supportsRaytracing; } -void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, iron_g5_command_list_t *command_list, void *ray_shader, int ray_shader_size, - iron_g5_constant_buffer_t *constant_buffer) { +void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, iron_gpu_command_list_t *command_list, void *ray_shader, int ray_shader_size, + iron_gpu_constant_buffer_t *constant_buffer) { id device = getMetalDevice(); if (!device.supportsRaytracing) return; constant_buf = constant_buffer; @@ -1120,7 +1120,7 @@ void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, iron_ _sem = dispatch_semaphore_create(2); } -void iron_g5_raytrace_pipeline_destroy(iron_g5_raytrace_pipeline_t *pipeline) { +void iron_gpu_raytrace_pipeline_destroy(iron_gpu_raytrace_pipeline_t *pipeline) { } id create_acceleration_sctructure(MTLAccelerationStructureDescriptor *descriptor) { @@ -1154,12 +1154,12 @@ id create_acceleration_sctructure(MTLAccelerationStruc return compacted_acceleration_structure; } -void iron_g5_raytrace_acceleration_structure_init(iron_g5_raytrace_acceleration_structure_t *accel) { +void iron_gpu_raytrace_acceleration_structure_init(iron_gpu_raytrace_acceleration_structure_t *accel) { vb_count = 0; instances_count = 0; } -void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_vertex_buffer_t *_vb, iron_g5_index_buffer_t *_ib, +void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_vertex_buffer_t *_vb, iron_gpu_index_buffer_t *_ib, iron_matrix4x4_t _transform) { int vb_i = -1; @@ -1181,18 +1181,18 @@ void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_s instances_count++; } -void _iron_g5_raytrace_acceleration_structure_destroy_bottom(iron_g5_raytrace_acceleration_structure_t *accel) { +void _iron_gpu_raytrace_acceleration_structure_destroy_bottom(iron_gpu_raytrace_acceleration_structure_t *accel) { // for (int i = 0; i < vb_count_last; ++i) { // } _primitive_accels = nil; } -void _iron_g5_raytrace_acceleration_structure_destroy_top(iron_g5_raytrace_acceleration_structure_t *accel) { +void _iron_gpu_raytrace_acceleration_structure_destroy_top(iron_gpu_raytrace_acceleration_structure_t *accel) { _instance_accel = nil; } -void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_command_list_t *command_list, - iron_g5_vertex_buffer_t *_vb_full, iron_g5_index_buffer_t *_ib_full) { +void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_command_list_t *command_list, + iron_gpu_vertex_buffer_t *_vb_full, iron_gpu_index_buffer_t *_ib_full) { bool build_bottom = false; for (int i = 0; i < 16; ++i) { @@ -1204,9 +1204,9 @@ void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration if (vb_count_last > 0) { if (build_bottom) { - _iron_g5_raytrace_acceleration_structure_destroy_bottom(accel); + _iron_gpu_raytrace_acceleration_structure_destroy_bottom(accel); } - _iron_g5_raytrace_acceleration_structure_destroy_top(accel); + _iron_gpu_raytrace_acceleration_structure_destroy_top(accel); } vb_count_last = vb_count; @@ -1254,9 +1254,9 @@ void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration _instance_accel = create_acceleration_sctructure(inst_accel_descriptor); } -void iron_g5_raytrace_acceleration_structure_destroy(iron_g5_raytrace_acceleration_structure_t *accel) {} +void iron_gpu_raytrace_acceleration_structure_destroy(iron_gpu_raytrace_acceleration_structure_t *accel) {} -void iron_g5_raytrace_set_textures(iron_g5_texture_t *texpaint0, iron_g5_texture_t *texpaint1, iron_g5_texture_t *texpaint2, iron_g5_texture_t *texenv, iron_g5_texture_t *texsobol, iron_g5_texture_t *texscramble, iron_g5_texture_t *texrank) { +void iron_gpu_raytrace_set_textures(iron_gpu_texture_t *texpaint0, iron_gpu_texture_t *texpaint1, iron_gpu_texture_t *texpaint2, iron_gpu_texture_t *texenv, iron_gpu_texture_t *texsobol, iron_gpu_texture_t *texscramble, iron_gpu_texture_t *texrank) { _texpaint0 = texpaint0; _texpaint1 = texpaint1; _texpaint2 = texpaint2; @@ -1266,19 +1266,19 @@ void iron_g5_raytrace_set_textures(iron_g5_texture_t *texpaint0, iron_g5_texture _texrank = texrank; } -void iron_g5_raytrace_set_acceleration_structure(iron_g5_raytrace_acceleration_structure_t *_accel) { +void iron_gpu_raytrace_set_acceleration_structure(iron_gpu_raytrace_acceleration_structure_t *_accel) { accel = _accel; } -void iron_g5_raytrace_set_pipeline(iron_g5_raytrace_pipeline_t *_pipeline) { +void iron_gpu_raytrace_set_pipeline(iron_gpu_raytrace_pipeline_t *_pipeline) { pipeline = _pipeline; } -void iron_g5_raytrace_set_target(iron_g5_texture_t *_output) { +void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { output = _output; } -void iron_g5_raytrace_dispatch_rays(iron_g5_command_list_t *command_list) { +void iron_gpu_raytrace_dispatch_rays(iron_gpu_command_list_t *command_list) { id device = getMetalDevice(); if (!device.supportsRaytracing) return; dispatch_semaphore_wait(_sem, DISPATCH_TIME_FOREVER); @@ -1357,7 +1357,7 @@ static int formatByteSize(iron_image_format_t format) { } } -static void create(iron_g5_texture_t *texture, int width, int height, int format, bool writable) { +static void create(iron_gpu_texture_t *texture, int width, int height, int format, bool writable) { texture->impl.has_mipmaps = false; id device = getMetalDevice(); @@ -1380,7 +1380,7 @@ static void create(iron_g5_texture_t *texture, int width, int height, int format texture->impl._tex = (__bridge_retained void *)[device newTextureWithDescriptor:descriptor]; } -void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->format = format; @@ -1392,7 +1392,7 @@ void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iro texture->framebuffer_index = -1; } -void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->format = format; @@ -1407,11 +1407,11 @@ void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int mipmapLevel:0 slice:0 withBytes:data - bytesPerRow:iron_g5_texture_stride(texture) - bytesPerImage:iron_g5_texture_stride(texture) * texture->height]; + bytesPerRow:iron_gpu_texture_stride(texture) + bytesPerImage:iron_gpu_texture_stride(texture) * texture->height]; } -void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init_non_sampled_access(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->format = format; @@ -1421,7 +1421,7 @@ void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int wid create(texture, width, height, format, true); } -void iron_g5_texture_destroy(iron_g5_texture_t *target) { +void iron_gpu_texture_destroy(iron_gpu_texture_t *target) { id tex = (__bridge_transfer id)target->impl._tex; tex = nil; target->impl._tex = NULL; @@ -1444,7 +1444,7 @@ void iron_g5_texture_destroy(iron_g5_texture_t *target) { } } -int iron_g5_texture_stride(iron_g5_texture_t *texture) { +int iron_gpu_texture_stride(iron_gpu_texture_t *texture) { switch (texture->format) { case IRON_IMAGE_FORMAT_R8: return texture->width; @@ -1459,9 +1459,9 @@ int iron_g5_texture_stride(iron_g5_texture_t *texture) { } } -void iron_g5_texture_generate_mipmaps(iron_g5_texture_t *texture, int levels) {} +void iron_gpu_texture_generate_mipmaps(iron_gpu_texture_t *texture, int levels) {} -void iron_g5_texture_set_mipmap(iron_g5_texture_t *texture, iron_g5_texture_t *mipmap, int level) { +void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t *mipmap, int level) { if (!texture->impl.has_mipmaps) { id device = getMetalDevice(); MTLTextureDescriptor *descriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:convert_image_format((iron_image_format_t)texture->format) @@ -1529,8 +1529,8 @@ static MTLPixelFormat convert_format(iron_image_format_t format) { } } -static void render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits, int framebuffer_index) { - memset(target, 0, sizeof(iron_g5_texture_t)); +static void render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits, int framebuffer_index) { + memset(target, 0, sizeof(iron_gpu_texture_t)); target->width = width; target->height = height; @@ -1572,7 +1572,7 @@ static void render_target_init(iron_g5_texture_t *target, int width, int height, target->impl._texReadback = NULL; } -void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { +void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, -1); target->width = target->width = width; target->height = target->height = height; @@ -1580,27 +1580,27 @@ void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height target->_uploaded = true; } -void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { +void iron_gpu_render_target_init_framebuffer(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, framebuffer_count); framebuffer_count += 1; } -void iron_g5_render_target_set_depth_from(iron_g5_texture_t *target, iron_g5_texture_t *source) { +void iron_gpu_render_target_set_depth_from(iron_gpu_texture_t *target, iron_gpu_texture_t *source) { target->impl._depthTex = source->impl._depthTex; } -static void vertex_buffer_unset(iron_g5_vertex_buffer_t *buffer) { +static void vertex_buffer_unset(iron_gpu_vertex_buffer_t *buffer) { if (currentVertexBuffer == buffer) currentVertexBuffer = NULL; } -void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, bool gpuMemory) { +void iron_gpu_vertex_buffer_init(iron_gpu_vertex_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, bool gpuMemory) { memset(&buffer->impl, 0, sizeof(buffer->impl)); buffer->impl.myCount = count; buffer->impl.gpuMemory = gpuMemory; for (int i = 0; i < structure->size; ++i) { - iron_g5_vertex_element_t element = structure->elements[i]; - buffer->impl.myStride += iron_g5_vertex_data_size(element.data); + iron_gpu_vertex_element_t element = structure->elements[i]; + buffer->impl.myStride += iron_gpu_vertex_data_size(element.data); } id device = getMetalDevice(); @@ -1614,22 +1614,22 @@ void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron buffer->impl.lastCount = 0; } -void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buf) { +void iron_gpu_vertex_buffer_destroy(iron_gpu_vertex_buffer_t *buf) { id buffer = (__bridge_transfer id)buf->impl.mtlBuffer; buffer = nil; buf->impl.mtlBuffer = NULL; vertex_buffer_unset(buf); } -float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buf) { +float *iron_gpu_vertex_buffer_lock_all(iron_gpu_vertex_buffer_t *buf) { buf->impl.lastStart = 0; - buf->impl.lastCount = iron_g5_vertex_buffer_count(buf); + buf->impl.lastCount = iron_gpu_vertex_buffer_count(buf); id buffer = (__bridge id)buf->impl.mtlBuffer; float *floats = (float *)[buffer contents]; return floats; } -float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buf, int start, int count) { +float *iron_gpu_vertex_buffer_lock(iron_gpu_vertex_buffer_t *buf, int start, int count) { buf->impl.lastStart = start; buf->impl.lastCount = count; id buffer = (__bridge id)buf->impl.mtlBuffer; @@ -1637,13 +1637,13 @@ float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buf, int start, int c return &floats[start * buf->impl.myStride / sizeof(float)]; } -void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buf) { +void iron_gpu_vertex_buffer_unlock_all(iron_gpu_vertex_buffer_t *buf) { } -void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t *buf, int count) { +void iron_gpu_vertex_buffer_unlock(iron_gpu_vertex_buffer_t *buf, int count) { } -int iron_g5_internal_vertex_buffer_set(iron_g5_vertex_buffer_t *buf) { +int iron_gpu_internal_vertex_buffer_set(iron_gpu_vertex_buffer_t *buf) { currentVertexBuffer = buf; id encoder = getMetalEncoder(); @@ -1653,31 +1653,31 @@ int iron_g5_internal_vertex_buffer_set(iron_g5_vertex_buffer_t *buf) { return 0; } -int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_vertex_buffer_count(iron_gpu_vertex_buffer_t *buffer) { return buffer->impl.myCount; } -int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_vertex_buffer_stride(iron_gpu_vertex_buffer_t *buffer) { return buffer->impl.myStride; } -void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { +void iron_gpu_constant_buffer_init(iron_gpu_constant_buffer_t *buffer, int size) { buffer->impl.mySize = size; buffer->data = NULL; buffer->impl._buffer = (__bridge_retained void *)[getMetalDevice() newBufferWithLength:size options:MTLResourceOptionCPUCacheModeDefault]; } -void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer) { +void iron_gpu_constant_buffer_destroy(iron_gpu_constant_buffer_t *buffer) { id buf = (__bridge_transfer id)buffer->impl._buffer; buf = nil; buffer->impl._buffer = NULL; } -void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer) { - iron_g5_constant_buffer_lock(buffer, 0, iron_g5_constant_buffer_size(buffer)); +void iron_gpu_constant_buffer_lock_all(iron_gpu_constant_buffer_t *buffer) { + iron_gpu_constant_buffer_lock(buffer, 0, iron_gpu_constant_buffer_size(buffer)); } -void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count) { +void iron_gpu_constant_buffer_lock(iron_gpu_constant_buffer_t *buffer, int start, int count) { buffer->impl.lastStart = start; buffer->impl.lastCount = count; id buf = (__bridge id)buffer->impl._buffer; @@ -1685,15 +1685,15 @@ void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, buffer->data = &data[start]; } -void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer) { +void iron_gpu_constant_buffer_unlock(iron_gpu_constant_buffer_t *buffer) { buffer->data = NULL; } -int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer) { +int iron_gpu_constant_buffer_size(iron_gpu_constant_buffer_t *buffer) { return buffer->impl.mySize; } -void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int indexCount, bool gpuMemory) { +void iron_gpu_index_buffer_init(iron_gpu_index_buffer_t *buffer, int indexCount, bool gpuMemory) { buffer->impl.count = indexCount; buffer->impl.gpu_memory = gpuMemory; buffer->impl.last_start = 0; @@ -1708,36 +1708,36 @@ void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int indexCount, b options:options]; } -void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer) { +void iron_gpu_index_buffer_destroy(iron_gpu_index_buffer_t *buffer) { id buf = (__bridge_transfer id)buffer->impl.metal_buffer; buf = nil; buffer->impl.metal_buffer = NULL; } -static int iron_g5_internal_index_buffer_stride(iron_g5_index_buffer_t *buffer) { +static int iron_gpu_internal_index_buffer_stride(iron_gpu_index_buffer_t *buffer) { return 4; } -void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer) { - return iron_g5_index_buffer_lock(buffer, 0, iron_g5_index_buffer_count(buffer)); +void *iron_gpu_index_buffer_lock_all(iron_gpu_index_buffer_t *buffer) { + return iron_gpu_index_buffer_lock(buffer, 0, iron_gpu_index_buffer_count(buffer)); } -void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count) { +void *iron_gpu_index_buffer_lock(iron_gpu_index_buffer_t *buffer, int start, int count) { buffer->impl.last_start = start; buffer->impl.last_count = count; id metal_buffer = (__bridge id)buffer->impl.metal_buffer; uint8_t *data = (uint8_t *)[metal_buffer contents]; - return &data[start * iron_g5_internal_index_buffer_stride(buffer)]; + return &data[start * iron_gpu_internal_index_buffer_stride(buffer)]; } -void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { - iron_g5_index_buffer_unlock(buffer, buffer->impl.last_count); +void iron_gpu_index_buffer_unlock_all(iron_gpu_index_buffer_t *buffer) { + iron_gpu_index_buffer_unlock(buffer, buffer->impl.last_count); } -void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { +void iron_gpu_index_buffer_unlock(iron_gpu_index_buffer_t *buffer, int count) { } -int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer) { +int iron_gpu_index_buffer_count(iron_gpu_index_buffer_t *buffer) { return buffer->impl.count; } diff --git a/base/sources/backends/vulkan_gpu.c b/base/sources/backends/vulkan_gpu.c index dc8f887a..d458e45d 100644 --- a/base/sources/backends/vulkan_gpu.c +++ b/base/sources/backends/vulkan_gpu.c @@ -23,21 +23,21 @@ static void command_list_should_wait_for_framebuffer(void); static VkDescriptorSetLayout compute_descriptor_layout; static int framebuffer_count = 0; -extern iron_g5_texture_t *vulkan_textures[16]; +extern iron_gpu_texture_t *vulkan_textures[16]; VkDescriptorSet getDescriptorSet(void); static VkDescriptorSet get_compute_descriptor_set(void); void setImageLayout(VkCommandBuffer _buffer, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout); VkRenderPassBeginInfo currentRenderPassBeginInfo; VkPipeline currentVulkanPipeline; -iron_g5_texture_t *currentRenderTargets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +iron_gpu_texture_t *currentRenderTargets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; static bool onBackBuffer = false; static uint32_t lastVertexConstantBufferOffset = 0; static uint32_t lastFragmentConstantBufferOffset = 0; static uint32_t lastComputeConstantBufferOffset = 0; -static iron_g5_pipeline_t *current_pipeline = NULL; -static iron_g5_compute_shader *current_compute_shader = NULL; +static iron_gpu_pipeline_t *current_pipeline = NULL; +static iron_gpu_compute_shader *current_compute_shader = NULL; static int mrtIndex = 0; static VkFramebuffer mrtFramebuffer[16]; static VkRenderPass mrtRenderPass[16]; @@ -50,7 +50,7 @@ static VkShaderModule create_shader_module(const void *code, size_t size); static VkDescriptorPool compute_descriptor_pool; VkDescriptorSetLayout desc_layout; -extern iron_g5_texture_t *vulkan_textures[16]; +extern iron_gpu_texture_t *vulkan_textures[16]; extern uint32_t swapchainImageCount; extern uint32_t current_buffer; @@ -114,7 +114,7 @@ struct vk_context vk_ctx = {0}; void iron_vulkan_get_instance_extensions(const char **extensions, int *index, int max); VkBool32 iron_vulkan_get_physical_device_presentation_support(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex); VkResult iron_vulkan_create_surface(VkInstance instance, VkSurfaceKHR *surface); -void iron_g5_internal_resize(int, int); +void iron_gpu_internal_resize(int, int); #define GET_INSTANCE_PROC_ADDR(instance, entrypoint) \ { \ @@ -130,7 +130,7 @@ void create_descriptor_layout(void); static void create_compute_descriptor_layout(void); void set_image_layout(VkImage image, VkImageAspectFlags aspectMask, VkImageLayout old_image_layout, VkImageLayout new_image_layout); -iron_g5_texture_t *vulkan_textures[16] = { +iron_gpu_texture_t *vulkan_textures[16] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; @@ -188,7 +188,7 @@ void iron_internal_resize(int width, int height) { window->height = height; } - iron_g5_internal_resize(width, height); + iron_gpu_internal_resize(width, height); } VkSwapchainKHR cleanup_swapchain() { @@ -670,7 +670,7 @@ static bool find_layer(VkLayerProperties *layers, int layer_count, const char *w return false; } -void iron_g5_internal_init() { +void iron_gpu_internal_init() { VkResult err; uint32_t instance_layer_count = 0; @@ -877,7 +877,7 @@ void iron_g5_internal_init() { // Allows negative viewport height to flip viewport wanted_device_extensions[wanted_device_extension_count++] = VK_KHR_MAINTENANCE1_EXTENSION_NAME; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { wanted_device_extensions[wanted_device_extension_count++] = VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME; wanted_device_extensions[wanted_device_extension_count++] = VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME; wanted_device_extensions[wanted_device_extension_count++] = VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME; @@ -1012,7 +1012,7 @@ void iron_g5_internal_init() { VkPhysicalDeviceRayTracingPipelineFeaturesKHR rayTracingPipelineExt = {0}; VkPhysicalDeviceAccelerationStructureFeaturesKHR rayTracingAccelerationStructureExt = {0}; VkPhysicalDeviceBufferDeviceAddressFeatures bufferDeviceAddressExt = {0}; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { rayTracingPipelineExt.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR; rayTracingPipelineExt.pNext = NULL; rayTracingPipelineExt.rayTracingPipeline = VK_TRUE; @@ -1060,19 +1060,19 @@ void iron_g5_internal_init() { assert(!err); } -void iron_g5_internal_destroy() {} +void iron_gpu_internal_destroy() {} void iron_vulkan_init_window() { // this function is used in the android backend struct vk_window *window = &vk_ctx.windows[0]; // delay swapchain/surface recreation - // otherwise trouble ensues due to G4onG5 backend ending the command list in iron_g4_begin + // otherwise trouble ensues due to G4onG5 backend ending the command list in gpu_begin window->resized = true; window->surface_destroyed = true; } -void iron_g5_internal_init_window(int depthBufferBits, bool vsync) { +void iron_gpu_internal_init_window(int depthBufferBits, bool vsync) { struct vk_window *window = &vk_ctx.windows[0]; window->depth_bits = depthBufferBits; @@ -1120,10 +1120,10 @@ void iron_g5_internal_init_window(int depthBufferBits, bool vsync) { create_render_target_render_pass(window); began = false; - iron_g5_begin(NULL); + iron_gpu_begin(NULL); } -void iron_g5_internal_destroy_window() { +void iron_gpu_internal_destroy_window() { struct vk_window *window = &vk_ctx.windows[0]; VkSwapchainKHR swapchain = cleanup_swapchain(); destroy_render_target_pass(window); @@ -1131,11 +1131,11 @@ void iron_g5_internal_destroy_window() { vk.fpDestroySurfaceKHR(vk_ctx.instance, window->surface, NULL); } -bool iron_g5_swap_buffers() { +bool iron_gpu_swap_buffers() { return true; } -void iron_g5_begin(iron_g5_texture_t *renderTarget) { +void iron_gpu_begin(iron_gpu_texture_t *renderTarget) { struct vk_window *window = &vk_ctx.windows[0]; if (began) { @@ -1168,7 +1168,7 @@ void iron_g5_begin(iron_g5_texture_t *renderTarget) { while (err != VK_SUCCESS && err != VK_SUBOPTIMAL_KHR); } -void iron_g5_end() { +void iron_gpu_end() { VkPresentInfoKHR present = {0}; present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; present.pNext = NULL; @@ -1198,7 +1198,7 @@ void iron_g5_end() { began = false; } -void iron_g5_flush() { +void iron_gpu_flush() { vkDeviceWaitIdle(vk_ctx.device); } @@ -1217,7 +1217,7 @@ bool iron_vulkan_internal_get_size(int *width, int *height) { } } -bool iron_g5_raytrace_supported() { +bool iron_gpu_raytrace_supported() { #ifdef IRON_ANDROID return false; #else @@ -1225,14 +1225,14 @@ bool iron_g5_raytrace_supported() { #endif } -int iron_g5_max_bound_textures(void) { +int iron_gpu_max_bound_textures(void) { VkPhysicalDeviceProperties props; vkGetPhysicalDeviceProperties(vk_ctx.gpu, &props); return props.limits.maxPerStageDescriptorSamplers; } -static void endPass(iron_g5_command_list_t *list) { +static void endPass(iron_gpu_command_list_t *list) { if (in_render_pass) { vkCmdEndRenderPass(list->impl._buffer); in_render_pass = false; @@ -1389,7 +1389,7 @@ void flush_init_cmd() { vk_ctx.setup_cmd = VK_NULL_HANDLE; } -void set_viewport_and_scissor(iron_g5_command_list_t *list) { +void set_viewport_and_scissor(iron_gpu_command_list_t *list) { VkViewport viewport; memset(&viewport, 0, sizeof(viewport)); VkRect2D scissor; @@ -1424,7 +1424,7 @@ void set_viewport_and_scissor(iron_g5_command_list_t *list) { vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } -void iron_g5_command_list_init(iron_g5_command_list_t *list) { +void iron_gpu_command_list_init(iron_gpu_command_list_t *list) { VkCommandBufferAllocateInfo cmd = {0}; cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; cmd.pNext = NULL; @@ -1445,12 +1445,12 @@ void iron_g5_command_list_init(iron_g5_command_list_t *list) { list->impl._indexCount = 0; } -void iron_g5_command_list_destroy(iron_g5_command_list_t *list) { +void iron_gpu_command_list_destroy(iron_gpu_command_list_t *list) { vkFreeCommandBuffers(vk_ctx.device, vk_ctx.cmd_pool, 1, &list->impl._buffer); vkDestroyFence(vk_ctx.device, list->impl.fence, NULL); } -void iron_g5_command_list_begin(iron_g5_command_list_t *list) { +void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { VkResult err = vkWaitForFences(vk_ctx.device, 1, &list->impl.fence, VK_TRUE, UINT64_MAX); assert(!err); @@ -1522,7 +1522,7 @@ void iron_g5_command_list_begin(iron_g5_command_list_t *list) { mrtIndex = 0; } -void iron_g5_command_list_end(iron_g5_command_list_t *list) { +void iron_gpu_command_list_end(iron_gpu_command_list_t *list) { vkCmdEndRenderPass(list->impl._buffer); VkImageMemoryBarrier prePresentBarrier = {0}; @@ -1548,7 +1548,7 @@ void iron_g5_command_list_end(iron_g5_command_list_t *list) { assert(!err); } -void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget, unsigned flags, unsigned color, float depth) { +void iron_gpu_command_list_clear(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget, unsigned flags, unsigned color, float depth) { VkClearRect clearRect = {0}; clearRect.rect.offset.x = 0; clearRect.rect.offset.y = 0; @@ -1559,7 +1559,7 @@ void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_tex int count = 0; VkClearAttachment attachments[2]; - if (flags & IRON_G5_CLEAR_COLOR) { + if (flags & IRON_GPU_CLEAR_COLOR) { VkClearColorValue clearColor = {0}; clearColor.float32[0] = ((color & 0x00ff0000) >> 16) / 255.0f; clearColor.float32[1] = ((color & 0x0000ff00) >> 8) / 255.0f; @@ -1570,7 +1570,7 @@ void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_tex attachments[count].clearValue.color = clearColor; count++; } - if ((flags & IRON_G5_CLEAR_DEPTH) && renderTarget->impl.depthBufferBits > 0) { + if ((flags & IRON_GPU_CLEAR_DEPTH) && renderTarget->impl.depthBufferBits > 0) { attachments[count].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; attachments[count].clearValue.depthStencil.depth = depth; attachments[count].clearValue.depthStencil.stencil = 0; @@ -1579,19 +1579,19 @@ void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_tex vkCmdClearAttachments(list->impl._buffer, count, attachments, 1, &clearRect); } -void iron_g5_command_list_render_target_to_framebuffer_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} +void iron_gpu_command_list_render_target_to_framebuffer_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) {} -void iron_g5_command_list_framebuffer_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} +void iron_gpu_command_list_framebuffer_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) {} -void iron_g5_command_list_draw_indexed_vertices(iron_g5_command_list_t *list) { - iron_g5_command_list_draw_indexed_vertices_from_to(list, 0, list->impl._indexCount); +void iron_gpu_command_list_draw_indexed_vertices(iron_gpu_command_list_t *list) { + iron_gpu_command_list_draw_indexed_vertices_from_to(list, 0, list->impl._indexCount); } -void iron_g5_command_list_draw_indexed_vertices_from_to(iron_g5_command_list_t *list, int start, int count) { +void iron_gpu_command_list_draw_indexed_vertices_from_to(iron_gpu_command_list_t *list, int start, int count) { vkCmdDrawIndexed(list->impl._buffer, count, 1, start, 0, 0); } -void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_gpu_command_list_viewport(iron_gpu_command_list_t *list, int x, int y, int width, int height) { VkViewport viewport; memset(&viewport, 0, sizeof(viewport)); viewport.x = (float)x; @@ -1603,7 +1603,7 @@ void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, i vkCmdSetViewport(list->impl._buffer, 0, 1, &viewport); } -void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_gpu_command_list_scissor(iron_gpu_command_list_t *list, int x, int y, int width, int height) { VkRect2D scissor; memset(&scissor, 0, sizeof(scissor)); scissor.extent.width = width; @@ -1613,7 +1613,7 @@ void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, in vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } -void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list) { +void iron_gpu_command_list_disable_scissor(iron_gpu_command_list_t *list) { VkRect2D scissor; memset(&scissor, 0, sizeof(scissor)); if (currentRenderTargets[0] == NULL || currentRenderTargets[0]->framebuffer_index >= 0) { @@ -1627,7 +1627,7 @@ void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list) { vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } -void iron_g5_command_list_set_pipeline(iron_g5_command_list_t *list, struct iron_g5_pipeline *pipeline) { +void iron_gpu_command_list_set_pipeline(iron_gpu_command_list_t *list, struct iron_gpu_pipeline *pipeline) { current_pipeline = pipeline; lastVertexConstantBufferOffset = 0; lastFragmentConstantBufferOffset = 0; @@ -1642,7 +1642,7 @@ void iron_g5_command_list_set_pipeline(iron_g5_command_list_t *list, struct iron } } -void iron_g5_command_list_set_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *vertexBuffer) { +void iron_gpu_command_list_set_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_vertex_buffer *vertexBuffer) { VkBuffer buffers[1]; VkDeviceSize offsets[1]; buffers[0] = vertexBuffer->impl.buf; @@ -1650,12 +1650,12 @@ void iron_g5_command_list_set_vertex_buffer(iron_g5_command_list_t *list, struct vkCmdBindVertexBuffers(list->impl._buffer, 0, 1, buffers, offsets); } -void iron_g5_command_list_set_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *indexBuffer) { - list->impl._indexCount = iron_g5_index_buffer_count(indexBuffer); +void iron_gpu_command_list_set_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_index_buffer *indexBuffer) { + list->impl._indexCount = iron_gpu_index_buffer_count(indexBuffer); vkCmdBindIndexBuffer(list->impl._buffer, indexBuffer->impl.buf, 0, VK_INDEX_TYPE_UINT32); } -void iron_internal_restore_render_target(iron_g5_command_list_t *list, struct iron_g5_texture *target) { +void iron_internal_restore_render_target(iron_gpu_command_list_t *list, struct iron_gpu_texture *target) { VkViewport viewport; memset(&viewport, 0, sizeof(viewport)); viewport.x = 0; @@ -1711,7 +1711,7 @@ void iron_internal_restore_render_target(iron_g5_command_list_t *list, struct ir } } -void iron_g5_command_list_set_render_targets(iron_g5_command_list_t *list, struct iron_g5_texture **targets, int count) { +void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, struct iron_gpu_texture **targets, int count) { for (int i = 0; i < count; ++i) { currentRenderTargets[i] = targets[i]; } @@ -1893,13 +1893,13 @@ void iron_g5_command_list_set_render_targets(iron_g5_command_list_t *list, struc } } -void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) {} +void iron_gpu_command_list_upload_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_index_buffer *buffer) {} -void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) {} +void iron_gpu_command_list_upload_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_vertex_buffer *buffer) {} -void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, struct iron_g5_texture *texture) {} +void iron_gpu_command_list_upload_texture(iron_gpu_command_list_t *list, struct iron_gpu_texture *texture) {} -void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, iron_g5_texture_t *render_target, uint8_t *data) { +void iron_gpu_command_list_get_render_target_pixels(iron_gpu_command_list_t *list, iron_gpu_texture_t *render_target, uint8_t *data) { VkFormat format = render_target->impl.format; int format_bytes_size = format_size(format); @@ -1956,10 +1956,10 @@ void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, vkCmdBeginRenderPass(list->impl._buffer, ¤tRenderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); in_render_pass = true; - iron_g5_command_list_end(list); - iron_g5_command_list_execute(list); - iron_g5_command_list_wait_for_execution_to_finish(list); - iron_g5_command_list_begin(list); + iron_gpu_command_list_end(list); + iron_gpu_command_list_execute(list); + iron_gpu_command_list_wait_for_execution_to_finish(list); + iron_gpu_command_list_begin(list); // Read buffer void *p; @@ -1968,19 +1968,19 @@ void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, vkUnmapMemory(vk_ctx.device, render_target->impl.readback_memory); } -void iron_g5_command_list_texture_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) { +void iron_gpu_command_list_texture_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) { // render-passes are used to transition render-targets } -void iron_g5_command_list_render_target_to_texture_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) { +void iron_gpu_command_list_render_target_to_texture_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) { // render-passes are used to transition render-targets } -void iron_g5_command_list_set_vertex_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_vertex_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { lastVertexConstantBufferOffset = offset; } -void iron_g5_command_list_set_fragment_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_fragment_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { lastFragmentConstantBufferOffset = offset; VkDescriptorSet descriptor_set = getDescriptorSet(); @@ -1988,7 +1988,7 @@ void iron_g5_command_list_set_fragment_constant_buffer(iron_g5_command_list_t *l vkCmdBindDescriptorSets(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, current_pipeline->impl.pipeline_layout, 0, 1, &descriptor_set, 2, offsets); } -void iron_g5_command_list_set_compute_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_compute_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { lastComputeConstantBufferOffset = offset; VkDescriptorSet descriptor_set = get_compute_descriptor_set(); @@ -2001,7 +2001,7 @@ static void command_list_should_wait_for_framebuffer(void) { wait_for_framebuffer = true; } -void iron_g5_command_list_execute(iron_g5_command_list_t *list) { +void iron_gpu_command_list_execute(iron_gpu_command_list_t *list) { // Make sure the previous execution is done, so we can reuse the fence // Not optimal of course VkResult err = vkWaitForFences(vk_ctx.device, 1, &list->impl.fence, VK_TRUE, UINT64_MAX); @@ -2037,46 +2037,46 @@ void iron_g5_command_list_execute(iron_g5_command_list_t *list) { assert(!err); } -void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list) { +void iron_gpu_command_list_wait_for_execution_to_finish(iron_gpu_command_list_t *list) { VkResult err = vkWaitForFences(vk_ctx.device, 1, &list->impl.fence, VK_TRUE, UINT64_MAX); assert(!err); } -void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler) { - if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { - vulkan_samplers[unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]] = sampler->impl.sampler; +void iron_gpu_command_list_set_sampler(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_sampler_t *sampler) { + if (unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] >= 0) { + vulkan_samplers[unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]] = sampler->impl.sampler; } } -void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { - if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { - texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]; - vulkan_textures[unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]] = texture; +void iron_gpu_command_list_set_texture(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *texture) { + if (unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] >= 0) { + texture->impl.stage = unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]; + vulkan_textures[unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]] = texture; } - else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { - texture->impl.stage = unit.stages[IRON_G5_SHADER_TYPE_VERTEX]; - vulkan_textures[unit.stages[IRON_G5_SHADER_TYPE_VERTEX]] = texture; + else if (unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] >= 0) { + texture->impl.stage = unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]; + vulkan_textures[unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]] = texture; } } -void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *target) { - if (unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] >= 0) { - target->impl.stage_depth = unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]; - vulkan_textures[unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT]] = target; +void iron_gpu_command_list_set_texture_from_render_target_depth(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *target) { + if (unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] >= 0) { + target->impl.stage_depth = unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]; + vulkan_textures[unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT]] = target; } - else if (unit.stages[IRON_G5_SHADER_TYPE_VERTEX] >= 0) { - target->impl.stage_depth = unit.stages[IRON_G5_SHADER_TYPE_VERTEX]; - vulkan_textures[unit.stages[IRON_G5_SHADER_TYPE_VERTEX]] = target; + else if (unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] >= 0) { + target->impl.stage_depth = unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]; + vulkan_textures[unit.stages[IRON_GPU_SHADER_TYPE_VERTEX]] = target; } } -void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, iron_g5_compute_shader *shader) { +void iron_gpu_command_list_set_compute_shader(iron_gpu_command_list_t *list, iron_gpu_compute_shader *shader) { current_compute_shader = shader; vkCmdBindPipeline(list->impl._buffer, VK_PIPELINE_BIND_POINT_COMPUTE, shader->impl.pipeline); //**vkCmdBindDescriptorSets(list->impl._buffer, VK_PIPELINE_BIND_POINT_COMPUTE, shader->impl.pipeline_layout, 0, 1, &shader->impl.descriptor_set, 0, 0); } -void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z) { +void iron_gpu_command_list_compute(iron_gpu_command_list_t *list, int x, int y, int z) { if (in_render_pass) { vkCmdEndRenderPass(list->impl._buffer); in_render_pass = false; @@ -2092,7 +2092,7 @@ void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, in ++render_target_count; } if (render_target_count > 0) { - iron_g5_command_list_set_render_targets(list, currentRenderTargets, render_target_count); + iron_gpu_command_list_set_render_targets(list, currentRenderTargets, render_target_count); } } @@ -2149,7 +2149,7 @@ static void create_compute_descriptor_layout(void) { assert(!err); } -void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *_data, int length) { +void iron_gpu_compute_shader_init(iron_gpu_compute_shader *shader, void *_data, int length) { memset(shader->impl.locations, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); memset(shader->impl.offsets, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); memset(shader->impl.texture_bindings, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); @@ -2187,17 +2187,17 @@ void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *_data, in vkDestroyShaderModule(vk_ctx.device, shader->impl.shader_module, NULL); } -void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader) {} +void iron_gpu_compute_shader_destroy(iron_gpu_compute_shader *shader) {} -iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name) { - iron_g5_constant_location_t location = {0}; +iron_gpu_constant_location_t iron_gpu_compute_shader_get_constant_location(iron_gpu_compute_shader *shader, const char *name) { + iron_gpu_constant_location_t location = {0}; uint32_t hash = iron_internal_hash_name((unsigned char *)name); return location; } -iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name) { +iron_gpu_texture_unit_t iron_gpu_compute_shader_get_texture_unit(iron_gpu_compute_shader *shader, const char *name) { char unitName[64]; int unitOffset = 0; size_t len = strlen(name); @@ -2211,11 +2211,11 @@ iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_s uint32_t hash = iron_internal_hash_name((unsigned char *)unitName); - iron_g5_texture_unit_t unit; - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { + iron_gpu_texture_unit_t unit; + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } - unit.stages[IRON_G5_SHADER_TYPE_COMPUTE] = 0; + unit.stages[IRON_GPU_SHADER_TYPE_COMPUTE] = 0; return unit; } @@ -2415,12 +2415,12 @@ static VkShaderModule create_shader_module(const void *code, size_t size) { return module; } -static VkShaderModule prepare_vs(VkShaderModule *vert_shader_module, iron_g5_shader_t *vertex_shader) { +static VkShaderModule prepare_vs(VkShaderModule *vert_shader_module, iron_gpu_shader_t *vertex_shader) { *vert_shader_module = create_shader_module(vertex_shader->impl.source, vertex_shader->impl.length); return *vert_shader_module; } -static VkShaderModule prepare_fs(VkShaderModule *frag_shader_module, iron_g5_shader_t *fragment_shader) { +static VkShaderModule prepare_fs(VkShaderModule *frag_shader_module, iron_gpu_shader_t *fragment_shader) { *frag_shader_module = create_shader_module(fragment_shader->impl.source, fragment_shader->impl.length); return *frag_shader_module; } @@ -2443,19 +2443,19 @@ static VkFormat convert_format(iron_image_format_t format) { } } -void iron_g5_pipeline_init(iron_g5_pipeline_t *pipeline) { - iron_g5_internal_pipeline_init(pipeline); - iron_g5_internal_pipeline_set_defaults(pipeline); +void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipeline) { + iron_gpu_internal_pipeline_init(pipeline); + iron_gpu_internal_pipeline_set_defaults(pipeline); } -void iron_g5_pipeline_destroy(iron_g5_pipeline_t *pipeline) { +void iron_gpu_pipeline_destroy(iron_gpu_pipeline_t *pipeline) { vkDestroyPipeline(vk_ctx.device, pipeline->impl.framebuffer_pipeline, NULL); vkDestroyPipeline(vk_ctx.device, pipeline->impl.rendertarget_pipeline, NULL); vkDestroyPipelineLayout(vk_ctx.device, pipeline->impl.pipeline_layout, NULL); } -iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipeline_t *pipeline, const char *name) { - iron_g5_constant_location_t location; +iron_gpu_constant_location_t iron_gpu_pipeline_get_constant_location(iron_gpu_pipeline_t *pipeline, const char *name) { + iron_gpu_constant_location_t location; location.impl.vertexOffset = -1; location.impl.fragmentOffset = -1; location.impl.computeOffset = -1; @@ -2468,9 +2468,9 @@ iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipel return location; } -iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipeline, const char *name) { - iron_g5_texture_unit_t unit; - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { +iron_gpu_texture_unit_t iron_gpu_pipeline_get_texture_unit(iron_gpu_pipeline_t *pipeline, const char *name) { + iron_gpu_texture_unit_t unit; + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { unit.stages[i] = -1; } @@ -2478,77 +2478,77 @@ iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pip assert(number == -1 || number >= 2); // something wrong with the SPIR-V when this triggers if (number >= 0) { - unit.stages[IRON_G5_SHADER_TYPE_VERTEX] = number - 2; + unit.stages[IRON_GPU_SHADER_TYPE_VERTEX] = number - 2; } else { number = find_number(pipeline->impl.fragmentTextureBindings, name); if (number >= 0) { - unit.stages[IRON_G5_SHADER_TYPE_FRAGMENT] = number - 2; + unit.stages[IRON_GPU_SHADER_TYPE_FRAGMENT] = number - 2; } } return unit; } -static VkCullModeFlagBits convert_cull_mode(iron_g5_cull_mode_t cull_mode) { +static VkCullModeFlagBits convert_cull_mode(iron_gpu_cull_mode_t cull_mode) { switch (cull_mode) { - case IRON_G5_CULL_MODE_CLOCKWISE: + case IRON_GPU_CULL_MODE_CLOCKWISE: return VK_CULL_MODE_BACK_BIT; - case IRON_G5_CULL_MODE_COUNTERCLOCKWISE: + case IRON_GPU_CULL_MODE_COUNTERCLOCKWISE: return VK_CULL_MODE_FRONT_BIT; - case IRON_G5_CULL_MODE_NEVER: + case IRON_GPU_CULL_MODE_NEVER: default: return VK_CULL_MODE_NONE; } } -static VkCompareOp convert_compare_mode(iron_g5_compare_mode_t compare) { +static VkCompareOp convert_compare_mode(iron_gpu_compare_mode_t compare) { switch (compare) { default: - case IRON_G5_COMPARE_MODE_ALWAYS: + case IRON_GPU_COMPARE_MODE_ALWAYS: return VK_COMPARE_OP_ALWAYS; - case IRON_G5_COMPARE_MODE_NEVER: + case IRON_GPU_COMPARE_MODE_NEVER: return VK_COMPARE_OP_NEVER; - case IRON_G5_COMPARE_MODE_EQUAL: + case IRON_GPU_COMPARE_MODE_EQUAL: return VK_COMPARE_OP_EQUAL; - case IRON_G5_COMPARE_MODE_NOT_EQUAL: + case IRON_GPU_COMPARE_MODE_NOT_EQUAL: return VK_COMPARE_OP_NOT_EQUAL; - case IRON_G5_COMPARE_MODE_LESS: + case IRON_GPU_COMPARE_MODE_LESS: return VK_COMPARE_OP_LESS; - case IRON_G5_COMPARE_MODE_LESS_EQUAL: + case IRON_GPU_COMPARE_MODE_LESS_EQUAL: return VK_COMPARE_OP_LESS_OR_EQUAL; - case IRON_G5_COMPARE_MODE_GREATER: + case IRON_GPU_COMPARE_MODE_GREATER: return VK_COMPARE_OP_GREATER; - case IRON_G5_COMPARE_MODE_GREATER_EQUAL: + case IRON_GPU_COMPARE_MODE_GREATER_EQUAL: return VK_COMPARE_OP_GREATER_OR_EQUAL; } } -static VkBlendFactor convert_blend_factor(iron_g5_blending_factor_t factor) { +static VkBlendFactor convert_blend_factor(iron_gpu_blending_factor_t factor) { switch (factor) { - case IRON_G5_BLEND_ONE: + case IRON_GPU_BLEND_ONE: return VK_BLEND_FACTOR_ONE; - case IRON_G5_BLEND_ZERO: + case IRON_GPU_BLEND_ZERO: return VK_BLEND_FACTOR_ZERO; - case IRON_G5_BLEND_SOURCE_ALPHA: + case IRON_GPU_BLEND_SOURCE_ALPHA: return VK_BLEND_FACTOR_SRC_ALPHA; - case IRON_G5_BLEND_DEST_ALPHA: + case IRON_GPU_BLEND_DEST_ALPHA: return VK_BLEND_FACTOR_DST_ALPHA; - case IRON_G5_BLEND_INV_SOURCE_ALPHA: + case IRON_GPU_BLEND_INV_SOURCE_ALPHA: return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - case IRON_G5_BLEND_INV_DEST_ALPHA: + case IRON_GPU_BLEND_INV_DEST_ALPHA: return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; - case IRON_G5_BLEND_SOURCE_COLOR: + case IRON_GPU_BLEND_SOURCE_COLOR: return VK_BLEND_FACTOR_SRC_COLOR; - case IRON_G5_BLEND_DEST_COLOR: + case IRON_GPU_BLEND_DEST_COLOR: return VK_BLEND_FACTOR_DST_COLOR; - case IRON_G5_BLEND_INV_SOURCE_COLOR: + case IRON_GPU_BLEND_INV_SOURCE_COLOR: return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; - case IRON_G5_BLEND_INV_DEST_COLOR: + case IRON_GPU_BLEND_INV_DEST_COLOR: return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR; - case IRON_G5_BLEND_CONSTANT: + case IRON_GPU_BLEND_CONSTANT: return VK_BLEND_FACTOR_CONSTANT_COLOR; - case IRON_G5_BLEND_INV_CONSTANT: + case IRON_GPU_BLEND_INV_CONSTANT: return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR; default: assert(false); @@ -2556,17 +2556,17 @@ static VkBlendFactor convert_blend_factor(iron_g5_blending_factor_t factor) { } } -static VkBlendOp convert_blend_operation(iron_g5_blending_operation_t op) { +static VkBlendOp convert_blend_operation(iron_gpu_blending_operation_t op) { switch (op) { - case IRON_G5_BLENDOP_ADD: + case IRON_GPU_BLENDOP_ADD: return VK_BLEND_OP_ADD; - case IRON_G5_BLENDOP_SUBTRACT: + case IRON_GPU_BLENDOP_SUBTRACT: return VK_BLEND_OP_SUBTRACT; - case IRON_G5_BLENDOP_REVERSE_SUBTRACT: + case IRON_GPU_BLENDOP_REVERSE_SUBTRACT: return VK_BLEND_OP_REVERSE_SUBTRACT; - case IRON_G5_BLENDOP_MIN: + case IRON_GPU_BLENDOP_MIN: return VK_BLEND_OP_MIN; - case IRON_G5_BLENDOP_MAX: + case IRON_GPU_BLENDOP_MAX: return VK_BLEND_OP_MAX; default: assert(false); @@ -2574,7 +2574,7 @@ static VkBlendOp convert_blend_operation(iron_g5_blending_operation_t op) { } } -void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline) { +void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { memset(pipeline->impl.vertexLocations, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); memset(pipeline->impl.vertexOffsets, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); memset(pipeline->impl.fragmentLocations, 0, sizeof(iron_internal_named_number) * IRON_INTERNAL_NAMED_NUMBER_COUNT); @@ -2631,33 +2631,33 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline) { uint32_t attr = 0; uint32_t offset = 0; for (int i = 0; i < pipeline->input_layout->size; ++i) { - iron_g5_vertex_element_t element = pipeline->input_layout->elements[i]; + iron_gpu_vertex_element_t element = pipeline->input_layout->elements[i]; vi_attrs[attr].binding = 0; vi_attrs[attr].location = find_number(pipeline->impl.vertexLocations, element.name); vi_attrs[attr].offset = offset; - offset += iron_g5_vertex_data_size(element.data); + offset += iron_gpu_vertex_data_size(element.data); switch (element.data) { - case IRON_G5_VERTEX_DATA_F32_1X: + case IRON_GPU_VERTEX_DATA_F32_1X: vi_attrs[attr].format = VK_FORMAT_R32_SFLOAT; break; - case IRON_G5_VERTEX_DATA_F32_2X: + case IRON_GPU_VERTEX_DATA_F32_2X: vi_attrs[attr].format = VK_FORMAT_R32G32_SFLOAT; break; - case IRON_G5_VERTEX_DATA_F32_3X: + case IRON_GPU_VERTEX_DATA_F32_3X: vi_attrs[attr].format = VK_FORMAT_R32G32B32_SFLOAT; break; - case IRON_G5_VERTEX_DATA_F32_4X: + case IRON_GPU_VERTEX_DATA_F32_4X: vi_attrs[attr].format = VK_FORMAT_R32G32B32A32_SFLOAT; break; - case IRON_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_GPU_VERTEX_DATA_U8_4X_NORM: vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_UNORM; break; - case IRON_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_GPU_VERTEX_DATA_I16_2X_NORM: vi_attrs[attr].format = VK_FORMAT_R16G16_SNORM; break; - case IRON_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_GPU_VERTEX_DATA_I16_4X_NORM: vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_SNORM; break; } @@ -2691,10 +2691,10 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline) { (pipeline->color_write_mask_green[i] ? VK_COLOR_COMPONENT_G_BIT : 0) | (pipeline->color_write_mask_blue[i] ? VK_COLOR_COMPONENT_B_BIT : 0) | (pipeline->color_write_mask_alpha[i] ? VK_COLOR_COMPONENT_A_BIT : 0); - att_state[i].blendEnable = pipeline->blend_source != IRON_G5_BLEND_ONE || - pipeline->blend_destination != IRON_G5_BLEND_ZERO || - pipeline->alpha_blend_source != IRON_G5_BLEND_ONE || - pipeline->alpha_blend_destination != IRON_G5_BLEND_ZERO; + att_state[i].blendEnable = pipeline->blend_source != IRON_GPU_BLEND_ONE || + pipeline->blend_destination != IRON_GPU_BLEND_ZERO || + pipeline->alpha_blend_source != IRON_GPU_BLEND_ONE || + pipeline->alpha_blend_destination != IRON_GPU_BLEND_ZERO; att_state[i].srcColorBlendFactor = convert_blend_factor(pipeline->blend_source); att_state[i].dstColorBlendFactor = convert_blend_factor(pipeline->blend_destination); att_state[i].colorBlendOp = convert_blend_operation(pipeline->blend_operation); @@ -2714,7 +2714,7 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline) { memset(&ds, 0, sizeof(ds)); ds.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; - ds.depthTestEnable = pipeline->depth_mode != IRON_G5_COMPARE_MODE_ALWAYS; + ds.depthTestEnable = pipeline->depth_mode != IRON_GPU_COMPARE_MODE_ALWAYS; ds.depthWriteEnable = pipeline->depth_write; ds.depthCompareOp = convert_compare_mode(pipeline->depth_mode); ds.depthBoundsTestEnable = VK_FALSE; @@ -3264,7 +3264,7 @@ static VkDescriptorSet get_compute_descriptor_set() { return descriptor_set; } -void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t length, iron_g5_shader_type_t type) { +void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *source, size_t length, iron_gpu_shader_type_t type) { shader->impl.length = (int)length; shader->impl.id = 0; shader->impl.source = (char *)malloc(length + 1); @@ -3274,22 +3274,22 @@ void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t le shader->impl.source[length] = 0; } -void iron_g5_shader_destroy(iron_g5_shader_t *shader) { +void iron_gpu_shader_destroy(iron_gpu_shader_t *shader) { free(shader->impl.source); shader->impl.source = NULL; } -static VkCompareOp convert_compare_mode(iron_g5_compare_mode_t compare); +static VkCompareOp convert_compare_mode(iron_gpu_compare_mode_t compare); -static VkSamplerAddressMode convert_addressing(iron_g5_texture_addressing_t mode) { +static VkSamplerAddressMode convert_addressing(iron_gpu_texture_addressing_t mode) { switch (mode) { - case IRON_G5_TEXTURE_ADDRESSING_REPEAT: + case IRON_GPU_TEXTURE_ADDRESSING_REPEAT: return VK_SAMPLER_ADDRESS_MODE_REPEAT; - case IRON_G5_TEXTURE_ADDRESSING_BORDER: + case IRON_GPU_TEXTURE_ADDRESSING_BORDER: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; - case IRON_G5_TEXTURE_ADDRESSING_CLAMP: + case IRON_GPU_TEXTURE_ADDRESSING_CLAMP: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; - case IRON_G5_TEXTURE_ADDRESSING_MIRROR: + case IRON_GPU_TEXTURE_ADDRESSING_MIRROR: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; default: assert(false); @@ -3297,12 +3297,12 @@ static VkSamplerAddressMode convert_addressing(iron_g5_texture_addressing_t mode } } -static VkSamplerMipmapMode convert_mipmap_mode(iron_g5_mipmap_filter_t filter) { +static VkSamplerMipmapMode convert_mipmap_mode(iron_gpu_mipmap_filter_t filter) { switch (filter) { - case IRON_G5_MIPMAP_FILTER_NONE: - case IRON_G5_MIPMAP_FILTER_POINT: + case IRON_GPU_MIPMAP_FILTER_NONE: + case IRON_GPU_MIPMAP_FILTER_POINT: return VK_SAMPLER_MIPMAP_MODE_NEAREST; - case IRON_G5_MIPMAP_FILTER_LINEAR: + case IRON_GPU_MIPMAP_FILTER_LINEAR: return VK_SAMPLER_MIPMAP_MODE_LINEAR; default: assert(false); @@ -3310,13 +3310,13 @@ static VkSamplerMipmapMode convert_mipmap_mode(iron_g5_mipmap_filter_t filter) { } } -static VkFilter convert_texture_filter(iron_g5_texture_filter_t filter) { +static VkFilter convert_texture_filter(iron_gpu_texture_filter_t filter) { switch (filter) { - case IRON_G5_TEXTURE_FILTER_POINT: + case IRON_GPU_TEXTURE_FILTER_POINT: return VK_FILTER_NEAREST; - case IRON_G5_TEXTURE_FILTER_LINEAR: + case IRON_GPU_TEXTURE_FILTER_LINEAR: return VK_FILTER_LINEAR; - case IRON_G5_TEXTURE_FILTER_ANISOTROPIC: + case IRON_GPU_TEXTURE_FILTER_ANISOTROPIC: return VK_FILTER_LINEAR; // ? default: assert(false); @@ -3324,7 +3324,7 @@ static VkFilter convert_texture_filter(iron_g5_texture_filter_t filter) { } } -void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options) { +void iron_gpu_sampler_init(iron_gpu_sampler_t *sampler, const iron_gpu_sampler_options_t *options) { VkSamplerCreateInfo info = {0}; info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; info.pNext = NULL; @@ -3340,7 +3340,7 @@ void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_opti info.minFilter = convert_texture_filter(options->minification_filter); info.anisotropyEnable = - (options->magnification_filter == IRON_G5_TEXTURE_FILTER_ANISOTROPIC || options->minification_filter == IRON_G5_TEXTURE_FILTER_ANISOTROPIC); + (options->magnification_filter == IRON_GPU_TEXTURE_FILTER_ANISOTROPIC || options->minification_filter == IRON_GPU_TEXTURE_FILTER_ANISOTROPIC); info.maxAnisotropy = 1; info.maxLod = 32; @@ -3349,7 +3349,7 @@ void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_opti vkCreateSampler(vk_ctx.device, &info, NULL, &sampler->impl.sampler); } -void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler) { +void iron_gpu_sampler_destroy(iron_gpu_sampler_t *sampler) { vkDestroySampler(vk_ctx.device, sampler->impl.sampler, NULL); } @@ -3538,7 +3538,7 @@ static int format_byte_size(iron_image_format_t format) { } } -static void update_stride(iron_g5_texture_t *texture) { +static void update_stride(iron_gpu_texture_t *texture) { VkImageSubresource subres = {0}; subres.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; subres.mipLevel = 0; @@ -3550,7 +3550,7 @@ static void update_stride(iron_g5_texture_t *texture) { texture->impl.stride = (int)layout.rowPitch; } -void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->_uploaded = false; @@ -3642,7 +3642,7 @@ void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int assert(!err); } -void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->_uploaded = true; @@ -3690,7 +3690,7 @@ void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iro assert(!err); } -void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init_non_sampled_access(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; @@ -3731,7 +3731,7 @@ void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int wid assert(!err); } -void iron_g5_texture_destroy(iron_g5_texture_t *target) { +void iron_gpu_texture_destroy(iron_gpu_texture_t *target) { if (target->framebuffer_index >= 0) { framebuffer_count -= 1; } @@ -3751,15 +3751,15 @@ void iron_g5_texture_destroy(iron_g5_texture_t *target) { } } -void iron_g5_internal_texture_set(iron_g5_texture_t *texture, int unit) {} +void iron_gpu_internal_texture_set(iron_gpu_texture_t *texture, int unit) {} -int iron_g5_texture_stride(iron_g5_texture_t *texture) { +int iron_gpu_texture_stride(iron_gpu_texture_t *texture) { return texture->impl.stride; } -void iron_g5_texture_generate_mipmaps(iron_g5_texture_t *texture, int levels) {} +void iron_gpu_texture_generate_mipmaps(iron_gpu_texture_t *texture, int levels) {} -void iron_g5_texture_set_mipmap(iron_g5_texture_t *texture, iron_g5_texture_t *mipmap, int level) { +void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t *mipmap, int level) { // VkBuffer staging_buffer; // VkDeviceMemory staging_buffer_mem; @@ -3887,7 +3887,7 @@ void setImageLayout(VkCommandBuffer _buffer, VkImage image, VkImageAspectFlags a vkCmdPipelineBarrier(_buffer, srcStageFlags, dstStageFlags, 0, 0, NULL, 0, NULL, 1, &imageMemoryBarrier); } -static void render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits, int framebuffer_index) { +static void render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits, int framebuffer_index) { target->framebuffer_index = framebuffer_index; target->width = width; target->height = height; @@ -4062,7 +4062,7 @@ static void render_target_init(iron_g5_texture_t *target, int width, int height, } } -void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { +void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, -1); target->width = width; target->height = height; @@ -4070,12 +4070,12 @@ void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height target->_uploaded = true; } -void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { +void iron_gpu_render_target_init_framebuffer(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { render_target_init(target, width, height, format, depthBufferBits, framebuffer_count); framebuffer_count += 1; } -void iron_g5_render_target_set_depth_from(iron_g5_texture_t *target, iron_g5_texture_t *source) { +void iron_gpu_render_target_set_depth_from(iron_gpu_texture_t *target, iron_gpu_texture_t *source) { target->impl.depthImage = source->impl.depthImage; target->impl.depthMemory = source->impl.depthMemory; target->impl.depthView = source->impl.depthView; @@ -4111,12 +4111,12 @@ void iron_g5_render_target_set_depth_from(iron_g5_texture_t *target, iron_g5_tex } } -void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int vertexCount, iron_g5_vertex_structure_t *structure, bool gpuMemory) { +void iron_gpu_vertex_buffer_init(iron_gpu_vertex_buffer_t *buffer, int vertexCount, iron_gpu_vertex_structure_t *structure, bool gpuMemory) { buffer->impl.myCount = vertexCount; buffer->impl.myStride = 0; for (int i = 0; i < structure->size; ++i) { - iron_g5_vertex_element_t element = structure->elements[i]; - buffer->impl.myStride += iron_g5_vertex_data_size(element.data); + iron_gpu_vertex_element_t element = structure->elements[i]; + buffer->impl.myStride += iron_gpu_vertex_data_size(element.data); } VkBufferCreateInfo buf_info = {0}; @@ -4125,7 +4125,7 @@ void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int vertexCount buf_info.size = vertexCount * buffer->impl.myStride; buf_info.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { buf_info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; buf_info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; buf_info.usage |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR; @@ -4157,7 +4157,7 @@ void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int vertexCount assert(pass); VkMemoryAllocateFlagsInfo memory_allocate_flags_info = {0}; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { memory_allocate_flags_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO; memory_allocate_flags_info.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR; buffer->impl.mem_alloc.pNext = &memory_allocate_flags_info; @@ -4170,48 +4170,48 @@ void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int vertexCount assert(!err); } -static void unset_vertex_buffer(iron_g5_vertex_buffer_t *buffer) { +static void unset_vertex_buffer(iron_gpu_vertex_buffer_t *buffer) { } -void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buffer) { +void iron_gpu_vertex_buffer_destroy(iron_gpu_vertex_buffer_t *buffer) { unset_vertex_buffer(buffer); vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } -float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buffer) { - return iron_g5_vertex_buffer_lock(buffer, 0, buffer->impl.myCount); +float *iron_gpu_vertex_buffer_lock_all(iron_gpu_vertex_buffer_t *buffer) { + return iron_gpu_vertex_buffer_lock(buffer, 0, buffer->impl.myCount); } -float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buffer, int start, int count) { +float *iron_gpu_vertex_buffer_lock(iron_gpu_vertex_buffer_t *buffer, int start, int count) { VkResult err = vkMapMemory(vk_ctx.device, buffer->impl.mem, start * buffer->impl.myStride, count * buffer->impl.myStride, 0, (void **)&buffer->impl.data); assert(!err); return buffer->impl.data; } -void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buffer) { +void iron_gpu_vertex_buffer_unlock_all(iron_gpu_vertex_buffer_t *buffer) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t *buffer, int count) { +void iron_gpu_vertex_buffer_unlock(iron_gpu_vertex_buffer_t *buffer, int count) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -int iron_g5_internal_vertex_buffer_set(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_internal_vertex_buffer_set(iron_gpu_vertex_buffer_t *buffer) { return 0; } -int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_vertex_buffer_count(iron_gpu_vertex_buffer_t *buffer) { return buffer->impl.myCount; } -int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_vertex_buffer_stride(iron_gpu_vertex_buffer_t *buffer) { return buffer->impl.myStride; } -bool iron_g5_transpose_mat = true; +bool iron_gpu_transpose_mat = true; static void createUniformBuffer(VkBuffer *buf, VkMemoryAllocateInfo *mem_alloc, VkDeviceMemory *mem, VkDescriptorBufferInfo *buffer_info, int size) { VkBufferCreateInfo buf_info; @@ -4219,7 +4219,7 @@ static void createUniformBuffer(VkBuffer *buf, VkMemoryAllocateInfo *mem_alloc, buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; buf_info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { buf_info.usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; } @@ -4249,7 +4249,7 @@ static void createUniformBuffer(VkBuffer *buf, VkMemoryAllocateInfo *mem_alloc, buffer_info->range = size; } -void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { +void iron_gpu_constant_buffer_init(iron_gpu_constant_buffer_t *buffer, int size) { buffer->impl.mySize = size; buffer->data = NULL; @@ -4273,33 +4273,33 @@ void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer) { +void iron_gpu_constant_buffer_destroy(iron_gpu_constant_buffer_t *buffer) { vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } -void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer) { - iron_g5_constant_buffer_lock(buffer, 0, iron_g5_constant_buffer_size(buffer)); +void iron_gpu_constant_buffer_lock_all(iron_gpu_constant_buffer_t *buffer) { + iron_gpu_constant_buffer_lock(buffer, 0, iron_gpu_constant_buffer_size(buffer)); } -void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count) { +void iron_gpu_constant_buffer_lock(iron_gpu_constant_buffer_t *buffer, int start, int count) { VkResult err = vkMapMemory(vk_ctx.device, buffer->impl.mem, start, count, 0, (void **)&buffer->data); assert(!err); } -void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer) { +void iron_gpu_constant_buffer_unlock(iron_gpu_constant_buffer_t *buffer) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); buffer->data = NULL; } -int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer) { +int iron_gpu_constant_buffer_size(iron_gpu_constant_buffer_t *buffer) { return buffer->impl.mySize; } -static void unset(iron_g5_index_buffer_t *buffer) { +static void unset(iron_gpu_index_buffer_t *buffer) { } -void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int indexCount, bool gpuMemory) { +void iron_gpu_index_buffer_init(iron_gpu_index_buffer_t *buffer, int indexCount, bool gpuMemory) { buffer->impl.count = indexCount; VkBufferCreateInfo buf_info = {0}; @@ -4308,7 +4308,7 @@ void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int indexCount, b buf_info.size = indexCount * sizeof(uint32_t); buf_info.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { buf_info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; buf_info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; buf_info.usage |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR; @@ -4336,7 +4336,7 @@ void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int indexCount, b assert(pass); VkMemoryAllocateFlagsInfo memory_allocate_flags_info = {0}; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { memory_allocate_flags_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO; memory_allocate_flags_info.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR; buffer->impl.mem_alloc.pNext = &memory_allocate_flags_info; @@ -4349,36 +4349,36 @@ void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int indexCount, b assert(!err); } -void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer) { +void iron_gpu_index_buffer_destroy(iron_gpu_index_buffer_t *buffer) { unset(buffer); vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } -static int iron_g5_internal_index_buffer_stride(iron_g5_index_buffer_t *buffer) { +static int iron_gpu_internal_index_buffer_stride(iron_gpu_index_buffer_t *buffer) { return 4; } -void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer) { - return iron_g5_index_buffer_lock(buffer, 0, iron_g5_index_buffer_count(buffer)); +void *iron_gpu_index_buffer_lock_all(iron_gpu_index_buffer_t *buffer) { + return iron_gpu_index_buffer_lock(buffer, 0, iron_gpu_index_buffer_count(buffer)); } -void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count) { +void *iron_gpu_index_buffer_lock(iron_gpu_index_buffer_t *buffer, int start, int count) { uint8_t *data; VkResult err = vkMapMemory(vk_ctx.device, buffer->impl.mem, 0, buffer->impl.mem_alloc.allocationSize, 0, (void **)&data); assert(!err); - return &data[start * iron_g5_internal_index_buffer_stride(buffer)]; + return &data[start * iron_gpu_internal_index_buffer_stride(buffer)]; } -void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { +void iron_gpu_index_buffer_unlock_all(iron_gpu_index_buffer_t *buffer) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { - iron_g5_index_buffer_unlock_all(buffer); +void iron_gpu_index_buffer_unlock(iron_gpu_index_buffer_t *buffer, int count) { + iron_gpu_index_buffer_unlock_all(buffer); } -int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer) { +int iron_gpu_index_buffer_count(iron_gpu_index_buffer_t *buffer) { return buffer->impl.count; } @@ -4402,19 +4402,19 @@ typedef struct inst { } inst_t; static VkDescriptorPool raytrace_descriptor_pool; -static iron_g5_raytrace_acceleration_structure_t *accel; -static iron_g5_raytrace_pipeline_t *pipeline; -static iron_g5_texture_t *output = NULL; -static iron_g5_texture_t *texpaint0; -static iron_g5_texture_t *texpaint1; -static iron_g5_texture_t *texpaint2; -static iron_g5_texture_t *texenv; -static iron_g5_texture_t *texsobol; -static iron_g5_texture_t *texscramble; -static iron_g5_texture_t *texrank; -static iron_g5_vertex_buffer_t *vb[16]; -static iron_g5_vertex_buffer_t *vb_last[16]; -static iron_g5_index_buffer_t *ib[16]; +static iron_gpu_raytrace_acceleration_structure_t *accel; +static iron_gpu_raytrace_pipeline_t *pipeline; +static iron_gpu_texture_t *output = NULL; +static iron_gpu_texture_t *texpaint0; +static iron_gpu_texture_t *texpaint1; +static iron_gpu_texture_t *texpaint2; +static iron_gpu_texture_t *texenv; +static iron_gpu_texture_t *texsobol; +static iron_gpu_texture_t *texscramble; +static iron_gpu_texture_t *texrank; +static iron_gpu_vertex_buffer_t *vb[16]; +static iron_gpu_vertex_buffer_t *vb_last[16]; +static iron_gpu_index_buffer_t *ib[16]; static int vb_count = 0; static int vb_count_last = 0; static inst_t instances[1024]; @@ -4434,8 +4434,8 @@ static PFN_vkCmdBuildAccelerationStructuresKHR _vkCmdBuildAccelerationStructures static PFN_vkDestroyAccelerationStructureKHR _vkDestroyAccelerationStructureKHR = NULL; static PFN_vkCmdTraceRaysKHR _vkCmdTraceRaysKHR = NULL; -void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, iron_g5_command_list_t *command_list, void *ray_shader, int ray_shader_size, - iron_g5_constant_buffer_t *constant_buffer) { +void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, iron_gpu_command_list_t *command_list, void *ray_shader, int ray_shader_size, + iron_gpu_constant_buffer_t *constant_buffer) { output = NULL; pipeline->_constant_buffer = constant_buffer; @@ -4750,7 +4750,7 @@ void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, iron_ } } -void iron_g5_raytrace_pipeline_destroy(iron_g5_raytrace_pipeline_t *pipeline) { +void iron_gpu_raytrace_pipeline_destroy(iron_gpu_raytrace_pipeline_t *pipeline) { vkDestroyPipeline(vk_ctx.device, pipeline->impl.pipeline, NULL); vkDestroyPipelineLayout(vk_ctx.device, pipeline->impl.pipeline_layout, NULL); vkDestroyDescriptorSetLayout(vk_ctx.device, pipeline->impl.descriptor_set_layout, NULL); @@ -4764,7 +4764,7 @@ uint64_t get_buffer_device_address(VkBuffer buffer) { return _vkGetBufferDeviceAddressKHR(vk_ctx.device, &buffer_device_address_info); } -void iron_g5_raytrace_acceleration_structure_init(iron_g5_raytrace_acceleration_structure_t *accel) { +void iron_gpu_raytrace_acceleration_structure_init(iron_gpu_raytrace_acceleration_structure_t *accel) { _vkGetBufferDeviceAddressKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkGetBufferDeviceAddressKHR"); _vkCreateAccelerationStructureKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkCreateAccelerationStructureKHR"); _vkGetAccelerationStructureDeviceAddressKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkGetAccelerationStructureDeviceAddressKHR"); @@ -4774,7 +4774,7 @@ void iron_g5_raytrace_acceleration_structure_init(iron_g5_raytrace_acceleration_ instances_count = 0; } -void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_vertex_buffer_t *_vb, iron_g5_index_buffer_t *_ib, +void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_vertex_buffer_t *_vb, iron_gpu_index_buffer_t *_ib, iron_matrix4x4_t _transform) { int vb_i = -1; @@ -4796,7 +4796,7 @@ void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_s instances_count++; } -void _iron_g5_raytrace_acceleration_structure_destroy_bottom(iron_g5_raytrace_acceleration_structure_t *accel) { +void _iron_gpu_raytrace_acceleration_structure_destroy_bottom(iron_gpu_raytrace_acceleration_structure_t *accel) { _vkDestroyAccelerationStructureKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkDestroyAccelerationStructureKHR"); for (int i = 0; i < vb_count_last; ++i) { _vkDestroyAccelerationStructureKHR(vk_ctx.device, accel->impl.bottom_level_acceleration_structure[i], NULL); @@ -4805,7 +4805,7 @@ void _iron_g5_raytrace_acceleration_structure_destroy_bottom(iron_g5_raytrace_ac } } -void _iron_g5_raytrace_acceleration_structure_destroy_top(iron_g5_raytrace_acceleration_structure_t *accel) { +void _iron_gpu_raytrace_acceleration_structure_destroy_top(iron_gpu_raytrace_acceleration_structure_t *accel) { _vkDestroyAccelerationStructureKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkDestroyAccelerationStructureKHR"); _vkDestroyAccelerationStructureKHR(vk_ctx.device, accel->impl.top_level_acceleration_structure, NULL); vkFreeMemory(vk_ctx.device, accel->impl.top_level_mem, NULL); @@ -4814,8 +4814,8 @@ void _iron_g5_raytrace_acceleration_structure_destroy_top(iron_g5_raytrace_accel vkDestroyBuffer(vk_ctx.device, accel->impl.instances_buffer, NULL); } -void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration_structure_t *accel, iron_g5_command_list_t *command_list, - iron_g5_vertex_buffer_t *_vb_full, iron_g5_index_buffer_t *_ib_full) { +void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_command_list_t *command_list, + iron_gpu_vertex_buffer_t *_vb_full, iron_gpu_index_buffer_t *_ib_full) { bool build_bottom = false; for (int i = 0; i < 16; ++i) { @@ -4827,9 +4827,9 @@ void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration if (vb_count_last > 0) { if (build_bottom) { - _iron_g5_raytrace_acceleration_structure_destroy_bottom(accel); + _iron_gpu_raytrace_acceleration_structure_destroy_bottom(accel); } - _iron_g5_raytrace_acceleration_structure_destroy_top(accel); + _iron_gpu_raytrace_acceleration_structure_destroy_top(accel); } vb_count_last = vb_count; @@ -5349,7 +5349,7 @@ void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration } } -void iron_g5_raytrace_acceleration_structure_destroy(iron_g5_raytrace_acceleration_structure_t *accel) { +void iron_gpu_raytrace_acceleration_structure_destroy(iron_gpu_raytrace_acceleration_structure_t *accel) { // _vkDestroyAccelerationStructureKHR = (void *)vkGetDeviceProcAddr(vk_ctx.device, "vkDestroyAccelerationStructureKHR"); // for (int i = 0; i < vb_count; ++i) { // _vkDestroyAccelerationStructureKHR(vk_ctx.device, accel->impl.bottom_level_acceleration_structure[i], NULL); @@ -5363,7 +5363,7 @@ void iron_g5_raytrace_acceleration_structure_destroy(iron_g5_raytrace_accelerati // vkDestroyBuffer(vk_ctx.device, accel->impl.instances_buffer, NULL); } -void iron_g5_raytrace_set_textures(iron_g5_texture_t *_texpaint0, iron_g5_texture_t *_texpaint1, iron_g5_texture_t *_texpaint2, iron_g5_texture_t *_texenv, iron_g5_texture_t *_texsobol, iron_g5_texture_t *_texscramble, iron_g5_texture_t *_texrank) { +void iron_gpu_raytrace_set_textures(iron_gpu_texture_t *_texpaint0, iron_gpu_texture_t *_texpaint1, iron_gpu_texture_t *_texpaint2, iron_gpu_texture_t *_texenv, iron_gpu_texture_t *_texsobol, iron_gpu_texture_t *_texscramble, iron_gpu_texture_t *_texrank) { texpaint0 = _texpaint0; texpaint1 = _texpaint1; texpaint2 = _texpaint2; @@ -5373,15 +5373,15 @@ void iron_g5_raytrace_set_textures(iron_g5_texture_t *_texpaint0, iron_g5_textur texrank = _texrank; } -void iron_g5_raytrace_set_acceleration_structure(iron_g5_raytrace_acceleration_structure_t *_accel) { +void iron_gpu_raytrace_set_acceleration_structure(iron_gpu_raytrace_acceleration_structure_t *_accel) { accel = _accel; } -void iron_g5_raytrace_set_pipeline(iron_g5_raytrace_pipeline_t *_pipeline) { +void iron_gpu_raytrace_set_pipeline(iron_gpu_raytrace_pipeline_t *_pipeline) { pipeline = _pipeline; } -void iron_g5_raytrace_set_target(iron_g5_texture_t *_output) { +void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { if (_output != output) { vkDestroyImage(vk_ctx.device, _output->impl.image, NULL); @@ -5435,7 +5435,7 @@ void iron_g5_raytrace_set_target(iron_g5_texture_t *_output) { output = _output; } -void iron_g5_raytrace_dispatch_rays(iron_g5_command_list_t *command_list) { +void iron_gpu_raytrace_dispatch_rays(iron_gpu_command_list_t *command_list) { VkWriteDescriptorSetAccelerationStructureKHR descriptor_acceleration_structure_info = {0}; descriptor_acceleration_structure_info.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR; descriptor_acceleration_structure_info.accelerationStructureCount = 1; diff --git a/base/sources/backends/vulkan_gpu.h b/base/sources/backends/vulkan_gpu.h index 051ad96e..c597fa72 100644 --- a/base/sources/backends/vulkan_gpu.h +++ b/base/sources/backends/vulkan_gpu.h @@ -110,7 +110,7 @@ typedef struct { VkFence fence; } CommandList5Impl; -typedef struct iron_g5_compute_shader_impl { +typedef struct iron_gpu_compute_shader_impl { iron_internal_named_number locations[IRON_INTERNAL_NAMED_NUMBER_COUNT]; iron_internal_named_number texture_bindings[IRON_INTERNAL_NAMED_NUMBER_COUNT]; iron_internal_named_number offsets[IRON_INTERNAL_NAMED_NUMBER_COUNT]; @@ -118,7 +118,7 @@ typedef struct iron_g5_compute_shader_impl { VkPipelineLayout pipeline_layout; VkPipeline pipeline; VkShaderModule shader_module; -} iron_g5_compute_shader_impl; +} iron_gpu_compute_shader_impl; typedef struct PipelineState5Impl_s { const char **textures; @@ -160,9 +160,9 @@ typedef struct { int length; } Shader5Impl; -typedef struct iron_g5_sampler_impl { +typedef struct iron_gpu_sampler_impl { VkSampler sampler; -} iron_g5_sampler_impl_t; +} iron_gpu_sampler_impl_t; typedef struct { VkImageLayout imageLayout; @@ -228,7 +228,7 @@ typedef struct { VkBuffer raygen_shader_binding_table; VkBuffer miss_shader_binding_table; VkBuffer hit_shader_binding_table; -} iron_g5_raytrace_pipeline_impl_t; +} iron_gpu_raytrace_pipeline_impl_t; typedef struct { VkAccelerationStructureKHR top_level_acceleration_structure; @@ -242,6 +242,6 @@ typedef struct { VkDeviceMemory top_level_mem; VkBuffer instances_buffer; VkDeviceMemory instances_mem; -} iron_g5_raytrace_acceleration_structure_impl_t; +} iron_gpu_raytrace_acceleration_structure_impl_t; #endif diff --git a/base/sources/backends/wasm_system.c b/base/sources/backends/wasm_system.c index fc57b695..0df17dfb 100644 --- a/base/sources/backends/wasm_system.c +++ b/base/sources/backends/wasm_system.c @@ -85,8 +85,8 @@ void iron_init(const char *name, int width, int height, iron_window_options_t *w iron_internal_window_width = width; iron_internal_window_height = height; - iron_g5_internal_init(); - iron_g4_internal_init_window(win->depth_bits, true); + iron_gpu_internal_init(); + gpu_internal_init_window(win->depth_bits, true); } bool iron_internal_handle_messages() { diff --git a/base/sources/backends/wasm_video.c b/base/sources/backends/wasm_video.c index 72e35026..c1eb9436 100644 --- a/base/sources/backends/wasm_video.c +++ b/base/sources/backends/wasm_video.c @@ -18,7 +18,7 @@ int iron_video_height(iron_video_t *video) { return 256; } -iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { +iron_gpu_texture_t *iron_video_current_image(iron_video_t *video) { return NULL; } diff --git a/base/sources/backends/webgpu_gpu.c b/base/sources/backends/webgpu_gpu.c index 7ebadebe..3e06a8eb 100644 --- a/base/sources/backends/webgpu_gpu.c +++ b/base/sources/backends/webgpu_gpu.c @@ -18,13 +18,13 @@ WGPUDevice device; WGPUQueue queue; WGPUSwapChain swapChain; -void iron_g5_internal_destroy_window() {} +void iron_gpu_internal_destroy_window() {} -void iron_g5_internal_destroy() {} +void iron_gpu_internal_destroy() {} -void iron_g5_internal_init() {} +void iron_gpu_internal_init() {} -void iron_g5_internal_init_window(int depthBufferBits, bool vsync) { +void iron_gpu_internal_init_window(int depthBufferBits, bool vsync) { newRenderTargetWidth = renderTargetWidth = iron_width(); newRenderTargetHeight = renderTargetHeight = iron_height(); @@ -51,37 +51,37 @@ void iron_g5_internal_init_window(int depthBufferBits, bool vsync) { swapChain = wgpuDeviceCreateSwapChain(device, surface, &scDesc); } -void iron_g5_begin(iron_g5_texture_t *renderTarget) {} +void iron_gpu_begin(iron_gpu_texture_t *renderTarget) {} -void iron_g5_end() {} +void iron_gpu_end() {} -bool iron_g5_swap_buffers() { +bool iron_gpu_swap_buffers() { return true; } -void iron_g5_flush() {} +void iron_gpu_flush() {} -bool iron_g5_raytrace_supported() { +bool iron_gpu_raytrace_supported() { return false; } extern WGPUDevice device; -iron_g5_vertex_buffer_t *iron_g5_internal_current_vertex_buffer = NULL; +iron_gpu_vertex_buffer_t *iron_gpu_internal_current_vertex_buffer = NULL; -void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, bool gpuMemory) { +void iron_gpu_vertex_buffer_init(iron_gpu_vertex_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, bool gpuMemory) { buffer->impl.count = count; buffer->impl.stride = 0; for (int i = 0; i < structure->size; ++i) { - buffer->impl.stride += iron_g5_vertex_data_size(structure->elements[i].data); + buffer->impl.stride += iron_gpu_vertex_data_size(structure->elements[i].data); } } -void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buffer) { +void iron_gpu_vertex_buffer_destroy(iron_gpu_vertex_buffer_t *buffer) { } -float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buffer) { +float *iron_gpu_vertex_buffer_lock_all(iron_gpu_vertex_buffer_t *buffer) { WGPUBufferDescriptor bDesc; memset(&bDesc, 0, sizeof(bDesc)); bDesc.size = buffer->impl.count * buffer->impl.stride * sizeof(float); @@ -91,93 +91,93 @@ float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buffer) { return wgpuBufferGetMappedRange(buffer->impl.buffer, 0, bDesc.size); } -float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buffer, int start, int count) { +float *iron_gpu_vertex_buffer_lock(iron_gpu_vertex_buffer_t *buffer, int start, int count) { return NULL; } -void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buffer) { +void iron_gpu_vertex_buffer_unlock_all(iron_gpu_vertex_buffer_t *buffer) { wgpuBufferUnmap(buffer->impl.buffer); } -void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t* buffer, int count) { +void iron_gpu_vertex_buffer_unlock(iron_gpu_vertex_buffer_t* buffer, int count) { } -int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_vertex_buffer_count(iron_gpu_vertex_buffer_t *buffer) { return buffer->impl.count; } -int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer) { +int iron_gpu_vertex_buffer_stride(iron_gpu_vertex_buffer_t *buffer) { return buffer->impl.stride; } -bool iron_g5_transpose_mat = false; +bool iron_gpu_transpose_mat = false; -void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size) { +void iron_gpu_constant_buffer_init(iron_gpu_constant_buffer_t *buffer, int size) { } -void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer) {} +void iron_gpu_constant_buffer_destroy(iron_gpu_constant_buffer_t *buffer) {} -void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer) { - iron_g5_constant_buffer_lock(buffer, 0, iron_g5_constant_buffer_size(buffer)); +void iron_gpu_constant_buffer_lock_all(iron_gpu_constant_buffer_t *buffer) { + iron_gpu_constant_buffer_lock(buffer, 0, iron_gpu_constant_buffer_size(buffer)); } -void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count) {} +void iron_gpu_constant_buffer_lock(iron_gpu_constant_buffer_t *buffer, int start, int count) {} -void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer) { +void iron_gpu_constant_buffer_unlock(iron_gpu_constant_buffer_t *buffer) { } -int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer) { +int iron_gpu_constant_buffer_size(iron_gpu_constant_buffer_t *buffer) { return 0; } -iron_g5_index_buffer_t *iron_g5_internal_current_index_buffer = NULL; +iron_gpu_index_buffer_t *iron_gpu_internal_current_index_buffer = NULL; -void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int count, bool gpuMemory) { +void iron_gpu_index_buffer_init(iron_gpu_index_buffer_t *buffer, int count, bool gpuMemory) { buffer->impl.count = count; } -void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer) { +void iron_gpu_index_buffer_destroy(iron_gpu_index_buffer_t *buffer) { } -static int iron_g5_internal_index_buffer_stride(iron_g5_index_buffer_t *buffer) { +static int iron_gpu_internal_index_buffer_stride(iron_gpu_index_buffer_t *buffer) { return 4; } -void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer) { - iron_g5_index_buffer_lock(buffer, 0, iron_g5_index_buffer_count(buffer)); +void *iron_gpu_index_buffer_lock_all(iron_gpu_index_buffer_t *buffer) { + iron_gpu_index_buffer_lock(buffer, 0, iron_gpu_index_buffer_count(buffer)); } -void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count) { +void *iron_gpu_index_buffer_lock(iron_gpu_index_buffer_t *buffer, int start, int count) { WGPUBufferDescriptor bDesc; memset(&bDesc, 0, sizeof(bDesc)); - bDesc.size = count * iron_g5_internal_index_buffer_stride(buffer); + bDesc.size = count * iron_gpu_internal_index_buffer_stride(buffer); bDesc.usage = WGPUBufferUsage_Index | WGPUBufferUsage_CopyDst; bDesc.mappedAtCreation = true; buffer->impl.buffer = wgpuDeviceCreateBuffer(device, &bDesc); - return wgpuBufferGetMappedRange(buffer->impl.buffer, start * iron_g5_internal_index_buffer_stride(buffer), bDesc.size); + return wgpuBufferGetMappedRange(buffer->impl.buffer, start * iron_gpu_internal_index_buffer_stride(buffer), bDesc.size); } -void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { +void iron_gpu_index_buffer_unlock_all(iron_gpu_index_buffer_t *buffer) { wgpuBufferUnmap(buffer->impl.buffer); } -void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { - iron_g5_index_buffer_unlock_all(buffer); +void iron_gpu_index_buffer_unlock(iron_gpu_index_buffer_t *buffer, int count) { + iron_gpu_index_buffer_unlock_all(buffer); } -void iron_g5_internal_index_buffer_set(iron_g5_index_buffer_t *buffer) { +void iron_gpu_internal_index_buffer_set(iron_gpu_index_buffer_t *buffer) { } -int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer) { +int iron_gpu_index_buffer_count(iron_gpu_index_buffer_t *buffer) { return buffer->impl.count; } -void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) { +void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format) { // WGPUExtent3D size = {}; // size.width = iron_width(); // size.height = iron_height(); @@ -203,21 +203,21 @@ void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iro texture->data = NULL; } -void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format) {} -void iron_g5_texture_init_from_encoded_data(iron_g5_texture_t *texture, void *data, int size, const char *format, bool readable) {} -void iron_g5_texture_init_from_data(iron_g5_texture_t *texture, void *data, int width, int height, int format, bool readable) {} -void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format) {} -void iron_g5_texture_destroy(iron_g5_texture_t *texture) {} +void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) {} +void iron_gpu_texture_init_from_encoded_data(iron_gpu_texture_t *texture, void *data, int size, const char *format, bool readable) {} +void iron_gpu_texture_init_from_data(iron_gpu_texture_t *texture, void *data, int width, int height, int format, bool readable) {} +void iron_gpu_texture_init_non_sampled_access(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format) {} +void iron_gpu_texture_destroy(iron_gpu_texture_t *texture) {} -int iron_g5_texture_stride(iron_g5_texture_t *texture) { +int iron_gpu_texture_stride(iron_gpu_texture_t *texture) { return 32; } -void iron_g5_texture_generate_mipmaps(iron_g5_texture_t *texture, int levels) {} +void iron_gpu_texture_generate_mipmaps(iron_gpu_texture_t *texture, int levels) {} -void iron_g5_texture_set_mipmap(iron_g5_texture_t *texture, iron_g5_texture_t *mipmap, int level) {} +void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t *mipmap, int level) {} -void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { +void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { target->width = target->width = width; target->height = target->height = height; target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; @@ -225,30 +225,30 @@ void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height target->_uploaded = true; } -void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) {} +void iron_gpu_render_target_init_framebuffer(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) {} -void iron_g5_render_target_set_depth_from(iron_g5_texture_t *renderTarget, iron_g5_texture_t *source) {} +void iron_gpu_render_target_set_depth_from(iron_gpu_texture_t *renderTarget, iron_gpu_texture_t *source) {} -void iron_g5_render_target_get_pixels(iron_g5_texture_t *renderTarget, uint8_t *data) {} +void iron_gpu_render_target_get_pixels(iron_gpu_texture_t *renderTarget, uint8_t *data) {} extern WGPUDevice device; -void iron_g5_pipeline_init(iron_g5_pipeline_t *pipe) { - iron_g5_internal_pipeline_init(pipe); - iron_g5_internal_pipeline_set_defaults(pipe); +void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipe) { + iron_gpu_internal_pipeline_init(pipe); + iron_gpu_internal_pipeline_set_defaults(pipe); } -iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipeline_t *pipe, const char* name) { - iron_g5_constant_location_t location; +iron_gpu_constant_location_t iron_gpu_pipeline_get_constant_location(iron_gpu_pipeline_t *pipe, const char* name) { + iron_gpu_constant_location_t location; return location; } -iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipe, const char *name) { - iron_g5_texture_unit_t unit; +iron_gpu_texture_unit_t iron_gpu_pipeline_get_texture_unit(iron_gpu_pipeline_t *pipe, const char *name) { + iron_gpu_texture_unit_t unit; return unit; } -void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipe) { +void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipe) { WGPUColorTargetState csDesc; memset(&csDesc, 0, sizeof(csDesc)); csDesc.format = WGPUTextureFormat_BGRA8Unorm; @@ -274,27 +274,27 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipe) { for (int i = 0; i < pipe->input_layout->size; ++i) { vaDesc[i].shaderLocation = i; vaDesc[i].offset = offset; - offset += iron_g5_vertex_data_size(pipe->input_layout->elements[i].data); + offset += iron_gpu_vertex_data_size(pipe->input_layout->elements[i].data); switch (pipe->input_layout->elements[i].data) { - case IRON_G5_VERTEX_DATA_F32_1X: + case IRON_GPU_VERTEX_DATA_F32_1X: vaDesc[i].format = WGPUVertexFormat_Float32; break; - case IRON_G5_VERTEX_DATA_F32_2X: + case IRON_GPU_VERTEX_DATA_F32_2X: vaDesc[i].format = WGPUVertexFormat_Float32x2; break; - case IRON_G5_VERTEX_DATA_F32_3X: + case IRON_GPU_VERTEX_DATA_F32_3X: vaDesc[i].format = WGPUVertexFormat_Float32x3; break; - case IRON_G5_VERTEX_DATA_F32_4X: + case IRON_GPU_VERTEX_DATA_F32_4X: vaDesc[i].format = WGPUVertexFormat_Float32x4; break; - case IRON_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_GPU_VERTEX_DATA_U8_4X_NORM: vaDesc[i].format = WGPUVertexFormat_Unorm8x4; break; - case IRON_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_GPU_VERTEX_DATA_I16_2X_NORM: vaDesc[i].format = WGPUVertexFormat_Snorm16x2; break; - case IRON_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_GPU_VERTEX_DATA_I16_4X_NORM: vaDesc[i].format = WGPUVertexFormat_Snorm16x4; break; } @@ -347,11 +347,11 @@ void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipe) { pipe->impl.pipeline = wgpuDeviceCreateRenderPipeline(device, &rpDesc); } -void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options) {} +void iron_gpu_sampler_init(iron_gpu_sampler_t *sampler, const iron_gpu_sampler_options_t *options) {} -void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler) {} +void iron_gpu_sampler_destroy(iron_gpu_sampler_t *sampler) {} -void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t length, iron_g5_shader_type_t type) { +void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *source, size_t length, iron_gpu_shader_type_t type) { WGPUShaderModuleSPIRVDescriptor smSpirvDesc; memset(&smSpirvDesc, 0, sizeof(smSpirvDesc)); smSpirvDesc.chain.sType = WGPUSType_ShaderModuleSPIRVDescriptor; @@ -363,7 +363,7 @@ void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t le shader->impl.module = wgpuDeviceCreateShaderModule(device, &smDesc); } -void iron_g5_shader_destroy(iron_g5_shader_t *shader) {} +void iron_gpu_shader_destroy(iron_gpu_shader_t *shader) {} @@ -377,11 +377,11 @@ extern WGPUDevice device; extern WGPUQueue queue; extern WGPUSwapChain swapChain; -void iron_g5_command_list_init(iron_g5_command_list_t *list) {} +void iron_gpu_command_list_init(iron_gpu_command_list_t *list) {} -void iron_g5_command_list_destroy(iron_g5_command_list_t *list) {} +void iron_gpu_command_list_destroy(iron_gpu_command_list_t *list) {} -void iron_g5_command_list_begin(iron_g5_command_list_t *list) { +void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { WGPUCommandEncoderDescriptor ceDesc; memset(&ceDesc, 0, sizeof(ceDesc)); list->impl.encoder = wgpuDeviceCreateCommandEncoder(device, &ceDesc); @@ -402,7 +402,7 @@ void iron_g5_command_list_begin(iron_g5_command_list_t *list) { list->impl.pass = wgpuCommandEncoderBeginRenderPass(list->impl.encoder, &passDesc); } -void iron_g5_command_list_end(iron_g5_command_list_t *list) { +void iron_gpu_command_list_end(iron_gpu_command_list_t *list) { wgpuRenderPassEncoderEnd(list->impl.pass); WGPUCommandBufferDescriptor cbDesc; @@ -411,101 +411,101 @@ void iron_g5_command_list_end(iron_g5_command_list_t *list) { wgpuQueueSubmit(queue, 1, &commands); } -void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget, unsigned flags, unsigned color, float depth) { +void iron_gpu_command_list_clear(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget, unsigned flags, unsigned color, float depth) { } -void iron_g5_command_list_render_target_to_framebuffer_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} -void iron_g5_command_list_framebuffer_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} -void iron_g5_command_list_texture_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} -void iron_g5_command_list_render_target_to_texture_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget) {} +void iron_gpu_command_list_render_target_to_framebuffer_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) {} +void iron_gpu_command_list_framebuffer_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) {} +void iron_gpu_command_list_texture_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) {} +void iron_gpu_command_list_render_target_to_texture_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) {} -void iron_g5_command_list_draw_indexed_vertices(iron_g5_command_list_t *list) { +void iron_gpu_command_list_draw_indexed_vertices(iron_gpu_command_list_t *list) { wgpuRenderPassEncoderDrawIndexed(list->impl.pass, list->impl.indexCount, 1, 0, 0, 0); } -void iron_g5_command_list_draw_indexed_vertices_from_to(iron_g5_command_list_t *list, int start, int count) { +void iron_gpu_command_list_draw_indexed_vertices_from_to(iron_gpu_command_list_t *list, int start, int count) { } -void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_gpu_command_list_viewport(iron_gpu_command_list_t *list, int x, int y, int width, int height) { } -void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, int width, int height) { +void iron_gpu_command_list_scissor(iron_gpu_command_list_t *list, int x, int y, int width, int height) { } -void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list) {} +void iron_gpu_command_list_disable_scissor(iron_gpu_command_list_t *list) {} -void iron_g5_command_list_set_pipeline(iron_g5_command_list_t *list, struct iron_g5_pipeline *pipeline) { +void iron_gpu_command_list_set_pipeline(iron_gpu_command_list_t *list, struct iron_gpu_pipeline *pipeline) { wgpuRenderPassEncoderSetPipeline(list->impl.pass, pipeline->impl.pipeline); } -void iron_g5_command_list_set_pipeline_layout(iron_g5_command_list_t *list) {} +void iron_gpu_command_list_set_pipeline_layout(iron_gpu_command_list_t *list) {} -void iron_g5_command_list_set_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) { - uint64_t size = (iron_g5_vertex_buffer_count(buffer)) * iron_g5_vertex_buffer_stride(buffer); +void iron_gpu_command_list_set_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_vertex_buffer *buffer) { + uint64_t size = (iron_gpu_vertex_buffer_count(buffer)) * iron_gpu_vertex_buffer_stride(buffer); wgpuRenderPassEncoderSetVertexBuffer(list->impl.pass, 0, buffer->impl.buffer, 0, size); } -void iron_g5_command_list_set_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) { - list->impl.indexCount = iron_g5_index_buffer_count(buffer); - uint64_t size = iron_g5_index_buffer_count(buffer) * sizeof(int); +void iron_gpu_command_list_set_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_index_buffer *buffer) { + list->impl.indexCount = iron_gpu_index_buffer_count(buffer); + uint64_t size = iron_gpu_index_buffer_count(buffer) * sizeof(int); wgpuRenderPassEncoderSetIndexBuffer(list->impl.pass, buffer->impl.buffer, WGPUIndexFormat_Uint32, 0, size); } -void iron_g5_command_list_set_render_targets(iron_g5_command_list_t *list, struct iron_g5_texture **targets, int count) { +void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, struct iron_gpu_texture **targets, int count) { } -void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer) {} -void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer) {} -void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, struct iron_g5_texture *texture) {} -void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, iron_g5_texture_t *render_target, uint8_t *data) {} +void iron_gpu_command_list_upload_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_index_buffer *buffer) {} +void iron_gpu_command_list_upload_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_vertex_buffer *buffer) {} +void iron_gpu_command_list_upload_texture(iron_gpu_command_list_t *list, struct iron_gpu_texture *texture) {} +void iron_gpu_command_list_get_render_target_pixels(iron_gpu_command_list_t *list, iron_gpu_texture_t *render_target, uint8_t *data) {} -void iron_g5_command_list_execute(iron_g5_command_list_t *list) { +void iron_gpu_command_list_execute(iron_gpu_command_list_t *list) { } -void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list) { +void iron_gpu_command_list_wait_for_execution_to_finish(iron_gpu_command_list_t *list) { } -void iron_g5_command_list_set_vertex_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_vertex_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { } -void iron_g5_command_list_set_fragment_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_fragment_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { } -void iron_g5_command_list_set_compute_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size) { +void iron_gpu_command_list_set_compute_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size) { } -void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture) { +void iron_gpu_command_list_set_texture(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *texture) { } -void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler) {} +void iron_gpu_command_list_set_sampler(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_sampler_t *sampler) {} -void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *renderTarget) {} +void iron_gpu_command_list_set_texture_from_render_target_depth(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *renderTarget) {} -void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, iron_g5_compute_shader *shader) {} +void iron_gpu_command_list_set_compute_shader(iron_gpu_command_list_t *list, iron_gpu_compute_shader *shader) {} -void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z) {} +void iron_gpu_command_list_compute(iron_gpu_command_list_t *list, int x, int y, int z) {} -void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *source, int length) {} +void iron_gpu_compute_shader_init(iron_gpu_compute_shader *shader, void *source, int length) {} -void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader) {} +void iron_gpu_compute_shader_destroy(iron_gpu_compute_shader *shader) {} -iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name) { - iron_g5_constant_location_t location = {0}; +iron_gpu_constant_location_t iron_gpu_compute_shader_get_constant_location(iron_gpu_compute_shader *shader, const char *name) { + iron_gpu_constant_location_t location = {0}; return location; } -iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name) { - iron_g5_texture_unit_t unit = {0}; +iron_gpu_texture_unit_t iron_gpu_compute_shader_get_texture_unit(iron_gpu_compute_shader *shader, const char *name) { + iron_gpu_texture_unit_t unit = {0}; return unit; } diff --git a/base/sources/backends/webgpu_gpu.h b/base/sources/backends/webgpu_gpu.h index f2c202cc..20c0a085 100644 --- a/base/sources/backends/webgpu_gpu.h +++ b/base/sources/backends/webgpu_gpu.h @@ -37,9 +37,9 @@ typedef struct { int computeOffset; } ConstantLocation5Impl; -typedef struct iron_g5_sampler_impl { +typedef struct iron_gpu_sampler_impl { int a; -} iron_g5_sampler_impl_t; +} iron_gpu_sampler_impl_t; struct WGPUShaderModuleImpl; @@ -53,6 +53,6 @@ typedef struct { int indexCount; } CommandList5Impl; -typedef struct iron_g5_compute_shader_impl { +typedef struct iron_gpu_compute_shader_impl { int nothing; -} iron_g5_compute_shader_impl; +} iron_gpu_compute_shader_impl; diff --git a/base/sources/backends/windows_system.c b/base/sources/backends/windows_system.c index 9754f672..26860981 100644 --- a/base/sources/backends/windows_system.c +++ b/base/sources/backends/windows_system.c @@ -1711,7 +1711,7 @@ void iron_init(const char *name, int width, int height, iron_window_options_t *w win->title = name; } - iron_g5_internal_init(); + iron_gpu_internal_init(); iron_window_create(win); loadXInput(); @@ -1722,7 +1722,7 @@ void iron_internal_shutdown() { iron_windows_hide_windows(); iron_internal_shutdown_callback(); iron_windows_destroy_windows(); - iron_g5_internal_destroy(); + iron_gpu_internal_destroy(); iron_windows_restore_displays(); } @@ -2044,7 +2044,7 @@ iron_window_mode_t iron_window_get_mode() { void iron_window_destroy() { WindowData *win = &windows[0]; if (win->handle != NULL) { - iron_g5_internal_destroy_window(); + iron_gpu_internal_destroy_window(); DestroyWindow(win->handle); win->handle = NULL; } @@ -2102,7 +2102,7 @@ void iron_window_create(iron_window_options_t *win) { bool vsync = win->vsync; - iron_g4_internal_init_window(win->depth_bits, vsync); + gpu_internal_init_window(win->depth_bits, vsync); if (win->visible) { iron_window_show(); diff --git a/base/sources/backends/windows_video.c b/base/sources/backends/windows_video.c index eb2f2e40..700938d0 100644 --- a/base/sources/backends/windows_video.c +++ b/base/sources/backends/windows_video.c @@ -4,7 +4,7 @@ // void iron_video_destroy(iron_video_t *video) {} -// iron_g5_texture_t *iron_video_current_image(iron_video_t *video) { +// iron_gpu_texture_t *iron_video_current_image(iron_video_t *video) { // return NULL; // } diff --git a/base/sources/iron.h b/base/sources/iron.h index 49237250..34fedf93 100644 --- a/base/sources/iron.h +++ b/base/sources/iron.h @@ -378,11 +378,11 @@ char mobile_title[1024]; int krafix_compile(const char *source, char *output, int *length, const char *targetlang, const char *system, const char *shadertype, int version); #endif -extern iron_g5_command_list_t commandList; -static iron_g5_constant_buffer_t constant_buffer; -static iron_g5_texture_t *render_target; -static iron_g5_raytrace_pipeline_t rt_pipeline; -static iron_g5_raytrace_acceleration_structure_t accel; +extern iron_gpu_command_list_t commandList; +static iron_gpu_constant_buffer_t constant_buffer; +static iron_gpu_texture_t *render_target; +static iron_gpu_raytrace_pipeline_t rt_pipeline; +static iron_gpu_raytrace_acceleration_structure_t accel; static bool raytrace_created = false; static bool raytrace_accel_created = false; const int constant_buffer_size = 24; @@ -423,10 +423,10 @@ void _update(void *data) { iron_a2_update(); #endif - iron_g4_begin(); + gpu_begin(); iron_update(); - iron_g4_end(); - iron_g5_swap_buffers(); + gpu_end(); + iron_gpu_swap_buffers(); } char *_copy(void *data) { @@ -923,66 +923,66 @@ void iron_show_keyboard(bool show) { show ? iron_keyboard_show() : iron_keyboard_hide(); } -any iron_g4_create_index_buffer(i32 count) { - iron_g5_index_buffer_t *buffer = (iron_g5_index_buffer_t *)malloc(sizeof(iron_g5_index_buffer_t)); - iron_g5_index_buffer_init(buffer, count, IRON_G4_USAGE_STATIC); +any gpu_create_index_buffer(i32 count) { + iron_gpu_index_buffer_t *buffer = (iron_gpu_index_buffer_t *)malloc(sizeof(iron_gpu_index_buffer_t)); + iron_gpu_index_buffer_init(buffer, count, GPU_USAGE_STATIC); return buffer; } -void iron_g4_delete_index_buffer(iron_g5_index_buffer_t *buffer) { - iron_g5_index_buffer_destroy(buffer); +void gpu_delete_index_buffer(iron_gpu_index_buffer_t *buffer) { + iron_gpu_index_buffer_destroy(buffer); free(buffer); } -u32_array_t *iron_g4_lock_index_buffer(iron_g5_index_buffer_t *buffer) { - void *vertices = iron_g5_index_buffer_lock_all(buffer); +u32_array_t *gpu_lock_index_buffer(iron_gpu_index_buffer_t *buffer) { + void *vertices = iron_gpu_index_buffer_lock_all(buffer); u32_array_t *ar = (u32_array_t *)malloc(sizeof(u32_array_t)); ar->buffer = vertices; - ar->length = iron_g5_index_buffer_count(buffer); + ar->length = iron_gpu_index_buffer_count(buffer); return ar; } -any iron_g4_create_vertex_buffer(i32 count, iron_g5_vertex_structure_t *structure, i32 usage) { - iron_g4_vertex_buffer_t *buffer = (iron_g4_vertex_buffer_t *)malloc(sizeof(iron_g4_vertex_buffer_t)); - iron_g4_vertex_buffer_init(buffer, count, structure, (iron_g4_usage_t)usage); +any gpu_create_vertex_buffer(i32 count, iron_gpu_vertex_structure_t *structure, i32 usage) { + gpu_vertex_buffer_t *buffer = (gpu_vertex_buffer_t *)malloc(sizeof(gpu_vertex_buffer_t)); + gpu_vertex_buffer_init(buffer, count, structure, (gpu_usage_t)usage); return buffer; } -void iron_g4_delete_vertex_buffer(iron_g4_vertex_buffer_t *buffer) { - iron_g4_vertex_buffer_destroy(buffer); +void gpu_delete_vertex_buffer(gpu_vertex_buffer_t *buffer) { + gpu_vertex_buffer_destroy(buffer); free(buffer); } -buffer_t *iron_g4_lock_vertex_buffer(iron_g4_vertex_buffer_t *buffer) { - float *vertices = iron_g4_vertex_buffer_lock_all(buffer); +buffer_t *gpu_lock_vertex_buffer(gpu_vertex_buffer_t *buffer) { + float *vertices = gpu_vertex_buffer_lock_all(buffer); buffer_t *b = (buffer_t *)malloc(sizeof(buffer_t)); b->buffer = vertices; - b->length = iron_g4_vertex_buffer_count(buffer) * iron_g4_vertex_buffer_stride(buffer); + b->length = gpu_vertex_buffer_count(buffer) * gpu_vertex_buffer_stride(buffer); return b; } -void iron_g4_draw_indexed_vertices(i32 start, i32 count) { +void gpu_draw_indexed_vertices(i32 start, i32 count) { #ifdef IRON_DIRECT3D12 - // TODO: Prevent heapIndex overflow in g5_texture.c.h/iron_g5_internal_set_textures + // TODO: Prevent heapIndex overflow in iron_gpu_internal_set_textures waitAfterNextDraw = true; #endif if (count < 0) { - iron_g5_draw_indexed_vertices(); + iron_gpu_draw_indexed_vertices(); } else { - iron_g5_draw_indexed_vertices_from_to(start, count); + iron_gpu_draw_indexed_vertices_from_to(start, count); } } -iron_g5_shader_t *iron_g4_create_shader(buffer_t *data, i32 shader_type) { - iron_g5_shader_t *shader = (iron_g5_shader_t *)malloc(sizeof(iron_g5_shader_t)); - iron_g5_shader_init(shader, data->buffer, data->length, (iron_g5_shader_type_t)shader_type); +iron_gpu_shader_t *gpu_create_shader(buffer_t *data, i32 shader_type) { + iron_gpu_shader_t *shader = (iron_gpu_shader_t *)malloc(sizeof(iron_gpu_shader_t)); + iron_gpu_shader_init(shader, data->buffer, data->length, (iron_gpu_shader_type_t)shader_type); return shader; } -iron_g5_shader_t *iron_g4_create_shader_from_source(string_t *source, iron_g5_shader_type_t shader_type) { - iron_g5_shader_t *shader = NULL; - char *temp_string_s = shader_type == IRON_G5_SHADER_TYPE_VERTEX ? temp_string_vs : temp_string_fs; +iron_gpu_shader_t *gpu_create_shader_from_source(string_t *source, iron_gpu_shader_type_t shader_type) { + iron_gpu_shader_t *shader = NULL; + char *temp_string_s = shader_type == IRON_GPU_SHADER_TYPE_VERTEX ? temp_string_vs : temp_string_fs; #ifdef WITH_D3DCOMPILER @@ -992,7 +992,7 @@ iron_g5_shader_t *iron_g4_create_shader_from_source(string_t *source, iron_g5_sh ID3DBlob *shader_buffer; UINT flags = D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_SKIP_VALIDATION; HRESULT hr = D3DCompile(temp_string_s, strlen(source) + 1, NULL, NULL, NULL, "main", - shader_type == IRON_G5_SHADER_TYPE_VERTEX ? "vs_5_0" : "ps_5_0", flags, 0, &shader_buffer, &error_message); + shader_type == IRON_GPU_SHADER_TYPE_VERTEX ? "vs_5_0" : "ps_5_0", flags, 0, &shader_buffer, &error_message); if (hr != S_OK) { iron_log("%s", (char *)error_message->lpVtbl->GetBufferPointer(error_message)); return NULL; @@ -1005,7 +1005,7 @@ iron_g5_shader_t *iron_g4_create_shader_from_source(string_t *source, iron_g5_sh char *file = malloc(size * 2); int output_len = 0; - if (shader_type == IRON_G5_SHADER_TYPE_VERTEX) { + if (shader_type == IRON_GPU_SHADER_TYPE_VERTEX) { bool has_bone = strstr(temp_string_s, " bone :") != NULL; bool has_col = strstr(temp_string_s, " col :") != NULL; bool has_nor = strstr(temp_string_s, " nor :") != NULL; @@ -1106,43 +1106,43 @@ iron_g5_shader_t *iron_g4_create_shader_from_source(string_t *source, iron_g5_sh shader_buffer->lpVtbl->Release(shader_buffer); reflector->lpVtbl->Release(reflector); - shader = (iron_g5_shader_t *)malloc(sizeof(iron_g5_shader_t)); - iron_g5_shader_init(shader, file, (int)output_len, shader_type); + shader = (iron_gpu_shader_t *)malloc(sizeof(iron_gpu_shader_t)); + iron_gpu_shader_init(shader, file, (int)output_len, shader_type); free(file); #elif defined(IRON_METAL) strcpy(temp_string_s, "// my_main\n"); strcat(temp_string_s, source); - shader = (iron_g5_shader_t *)malloc(sizeof(iron_g5_shader_t)); - iron_g5_shader_init(shader, temp_string_s, strlen(temp_string_s), shader_type); + shader = (iron_gpu_shader_t *)malloc(sizeof(iron_gpu_shader_t)); + iron_gpu_shader_init(shader, temp_string_s, strlen(temp_string_s), shader_type); #elif defined(IRON_VULKAN) && defined(KRAFIX_LIBRARY) char *output = malloc(1024 * 1024); int length; - krafix_compile(source, output, &length, "spirv", "windows", shader_type == IRON_G5_SHADER_TYPE_VERTEX ? "vert" : "frag", -1); - shader = (iron_g5_shader_t *)malloc(sizeof(iron_g5_shader_t)); - iron_g5_shader_init(shader, output, length, shader_type); + krafix_compile(source, output, &length, "spirv", "windows", shader_type == IRON_GPU_SHADER_TYPE_VERTEX ? "vert" : "frag", -1); + shader = (iron_gpu_shader_t *)malloc(sizeof(iron_gpu_shader_t)); + iron_gpu_shader_init(shader, output, length, shader_type); #endif return shader; } -iron_g5_pipeline_t *iron_g4_create_pipeline() { - iron_g5_pipeline_t *pipeline = (iron_g5_pipeline_t *)malloc(sizeof(iron_g5_pipeline_t)); - iron_g5_pipeline_init(pipeline); +iron_gpu_pipeline_t *gpu_create_pipeline() { + iron_gpu_pipeline_t *pipeline = (iron_gpu_pipeline_t *)malloc(sizeof(iron_gpu_pipeline_t)); + iron_gpu_pipeline_init(pipeline); return pipeline; } -void iron_g4_delete_pipeline(iron_g5_pipeline_t *pipeline) { - iron_g5_pipeline_destroy(pipeline); +void gpu_delete_pipeline(iron_gpu_pipeline_t *pipeline) { + iron_gpu_pipeline_destroy(pipeline); free(pipeline); } -void iron_g4_compile_pipeline(iron_g5_pipeline_t *pipeline) { - iron_g5_pipeline_compile(pipeline); +void gpu_compile_pipeline(iron_gpu_pipeline_t *pipeline) { + iron_gpu_pipeline_compile(pipeline); } bool _load_image(iron_file_reader_t *reader, const char *filename, unsigned char **output, int *width, int *height, iron_image_format_t *format) { @@ -1212,13 +1212,13 @@ bool _load_image(iron_file_reader_t *reader, const char *filename, unsigned char return success; } -iron_g5_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable); +iron_gpu_texture_t *gpu_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable); -iron_g5_texture_t *iron_load_image(string_t *file, bool readable) { +iron_gpu_texture_t *iron_load_image(string_t *file, bool readable) { #ifdef WITH_EMBED buffer_t *b = embed_get(file); if (b != NULL) { - iron_g5_texture_t *texture = iron_g4_create_texture_from_encoded_bytes(b, ".k", readable); + iron_gpu_texture_t *texture = gpu_create_texture_from_encoded_bytes(b, ".k", readable); return texture; } #endif @@ -1236,8 +1236,8 @@ iron_g5_texture_t *iron_load_image(string_t *file, bool readable) { return NULL; } - iron_g5_texture_t *texture = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); - iron_g5_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); + iron_gpu_texture_t *texture = (iron_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); + iron_gpu_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); if (!readable) { free(image_data); } @@ -1245,9 +1245,9 @@ iron_g5_texture_t *iron_load_image(string_t *file, bool readable) { return texture; } -void iron_unload_image(iron_g5_texture_t *image) { +void iron_unload_image(iron_gpu_texture_t *image) { if (image != NULL) { - iron_g5_texture_destroy(image); + iron_gpu_texture_destroy(image); // free(image); } } @@ -1280,70 +1280,70 @@ buffer_t *iron_load_blob(string_t *file) { return buffer; } -iron_g5_constant_location_t *iron_g4_get_constant_location(iron_g5_pipeline_t *pipeline, string_t *name) { - iron_g5_constant_location_t location = iron_g5_pipeline_get_constant_location(pipeline, name); - iron_g5_constant_location_t *location_copy = (iron_g5_constant_location_t *)malloc(sizeof(iron_g5_constant_location_t)); - memcpy(location_copy, &location, sizeof(iron_g5_constant_location_t)); // TODO +iron_gpu_constant_location_t *gpu_get_constant_location(iron_gpu_pipeline_t *pipeline, string_t *name) { + iron_gpu_constant_location_t location = iron_gpu_pipeline_get_constant_location(pipeline, name); + iron_gpu_constant_location_t *location_copy = (iron_gpu_constant_location_t *)malloc(sizeof(iron_gpu_constant_location_t)); + memcpy(location_copy, &location, sizeof(iron_gpu_constant_location_t)); // TODO return location_copy; } -iron_g5_texture_unit_t *iron_g4_get_texture_unit(iron_g5_pipeline_t *pipeline, string_t *name) { - iron_g5_texture_unit_t unit = iron_g5_pipeline_get_texture_unit(pipeline, name); - iron_g5_texture_unit_t *unit_copy = (iron_g5_texture_unit_t *)malloc(sizeof(iron_g5_texture_unit_t)); - memcpy(unit_copy, &unit, sizeof(iron_g5_texture_unit_t)); // TODO +iron_gpu_texture_unit_t *gpu_get_texture_unit(iron_gpu_pipeline_t *pipeline, string_t *name) { + iron_gpu_texture_unit_t unit = iron_gpu_pipeline_get_texture_unit(pipeline, name); + iron_gpu_texture_unit_t *unit_copy = (iron_gpu_texture_unit_t *)malloc(sizeof(iron_gpu_texture_unit_t)); + memcpy(unit_copy, &unit, sizeof(iron_gpu_texture_unit_t)); // TODO return unit_copy; } -void _iron_g4_set_texture(iron_g5_texture_unit_t *unit, iron_g5_texture_t *texture) { - iron_g4_set_texture(*unit, texture); +void _gpu_set_texture(iron_gpu_texture_unit_t *unit, iron_gpu_texture_t *texture) { + gpu_set_texture(*unit, texture); } -void iron_g4_set_texture_depth(iron_g5_texture_unit_t *unit, iron_g5_texture_t *render_target) { - iron_g4_render_target_use_depth_as_texture(render_target, *unit); +void gpu_set_texture_depth(iron_gpu_texture_unit_t *unit, iron_gpu_texture_t *render_target) { + gpu_render_target_use_depth_as_texture(render_target, *unit); } -void iron_g4_set_texture_parameters(iron_g5_texture_unit_t *unit, i32 u_addr, i32 v_addr, i32 min_filter, i32 mag_filter, i32 mip_filter) { - iron_g4_set_texture_addressing(*unit, IRON_G4_TEXTURE_DIRECTION_U, (iron_g4_texture_addressing_t)u_addr); - iron_g4_set_texture_addressing(*unit, IRON_G4_TEXTURE_DIRECTION_V, (iron_g4_texture_addressing_t)v_addr); - iron_g4_set_texture_minification_filter(*unit, (iron_g4_texture_filter_t)min_filter); - iron_g4_set_texture_magnification_filter(*unit, (iron_g4_texture_filter_t)mag_filter); - iron_g4_set_texture_mipmap_filter(*unit, (iron_g4_mipmap_filter_t)mip_filter); +void gpu_set_texture_parameters(iron_gpu_texture_unit_t *unit, i32 u_addr, i32 v_addr, i32 min_filter, i32 mag_filter, i32 mip_filter) { + gpu_set_texture_addressing(*unit, GPU_TEXTURE_DIRECTION_U, (gpu_texture_addressing_t)u_addr); + gpu_set_texture_addressing(*unit, GPU_TEXTURE_DIRECTION_V, (gpu_texture_addressing_t)v_addr); + gpu_set_texture_minification_filter(*unit, (gpu_texture_filter_t)min_filter); + gpu_set_texture_magnification_filter(*unit, (gpu_texture_filter_t)mag_filter); + gpu_set_texture_mipmap_filter(*unit, (gpu_mipmap_filter_t)mip_filter); } -void _iron_g4_set_bool(iron_g5_constant_location_t *location, bool value) { - iron_g4_set_bool(*location, value != 0); +void _gpu_set_bool(iron_gpu_constant_location_t *location, bool value) { + gpu_set_bool(*location, value != 0); } -void _iron_g4_set_int(iron_g5_constant_location_t *location, i32 value) { - iron_g4_set_int(*location, value); +void _gpu_set_int(iron_gpu_constant_location_t *location, i32 value) { + gpu_set_int(*location, value); } -void _iron_g4_set_float(iron_g5_constant_location_t *location, f32 value) { - iron_g4_set_float(*location, value); +void _gpu_set_float(iron_gpu_constant_location_t *location, f32 value) { + gpu_set_float(*location, value); } -void _iron_g4_set_float2(iron_g5_constant_location_t *location, f32 value1, f32 value2) { - iron_g4_set_float2(*location, value1, value2); +void _gpu_set_float2(iron_gpu_constant_location_t *location, f32 value1, f32 value2) { + gpu_set_float2(*location, value1, value2); } -void _iron_g4_set_float3(iron_g5_constant_location_t *location, f32 value1, f32 value2, f32 value3) { - iron_g4_set_float3(*location, value1, value2, value3); +void _gpu_set_float3(iron_gpu_constant_location_t *location, f32 value1, f32 value2, f32 value3) { + gpu_set_float3(*location, value1, value2, value3); } -void _iron_g4_set_float4(iron_g5_constant_location_t *location, f32 value1, f32 value2, f32 value3, f32 value4) { - iron_g4_set_float4(*location, value1, value2, value3, value4); +void _gpu_set_float4(iron_gpu_constant_location_t *location, f32 value1, f32 value2, f32 value3, f32 value4) { + gpu_set_float4(*location, value1, value2, value3, value4); } -void _iron_g4_set_floats(iron_g5_constant_location_t *location, f32_array_t *values) { - iron_g4_set_floats(*location, (float *)values->buffer, values->length); +void _gpu_set_floats(iron_gpu_constant_location_t *location, f32_array_t *values) { + gpu_set_floats(*location, (float *)values->buffer, values->length); } -void _iron_g4_set_matrix4(iron_g5_constant_location_t *location, mat4_t m) { - iron_g4_set_matrix4(*location, &m); +void _gpu_set_matrix4(iron_gpu_constant_location_t *location, mat4_t m) { + gpu_set_matrix4(*location, &m); } -void _iron_g4_set_matrix3(iron_g5_constant_location_t *location, mat3_t m) { - iron_g4_set_matrix3(*location, &m); +void _gpu_set_matrix3(iron_gpu_constant_location_t *location, mat3_t m) { + gpu_set_matrix3(*location, &m); } void iron_set_window_title(string_t *title) { @@ -1385,15 +1385,15 @@ bool iron_display_is_primary(i32 index) { return index == iron_primary_display(); } -iron_g5_texture_t *iron_g4_create_render_target(i32 width, i32 height, i32 format, i32 depth_buffer_bits) { - iron_g5_texture_t *render_target = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); - iron_g5_render_target_init(render_target, width, height, (iron_image_format_t)format, depth_buffer_bits); +iron_gpu_texture_t *gpu_create_render_target(i32 width, i32 height, i32 format, i32 depth_buffer_bits) { + iron_gpu_texture_t *render_target = (iron_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); + iron_gpu_render_target_init(render_target, width, height, (iron_image_format_t)format, depth_buffer_bits); render_target->buffer = NULL; return render_target; } -iron_g5_texture_t *iron_g4_create_texture_from_bytes(buffer_t *data, i32 width, i32 height, i32 format, bool readable) { - iron_g5_texture_t *texture = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); +iron_gpu_texture_t *gpu_create_texture_from_bytes(buffer_t *data, i32 width, i32 height, i32 format, bool readable) { + iron_gpu_texture_t *texture = (iron_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); texture->buffer = NULL; void *image_data; if (readable) { @@ -1403,12 +1403,12 @@ iron_g5_texture_t *iron_g4_create_texture_from_bytes(buffer_t *data, i32 width, else { image_data = data->buffer; } - iron_g5_texture_init_from_bytes(texture, image_data, width, height, (iron_image_format_t)format); + iron_gpu_texture_init_from_bytes(texture, image_data, width, height, (iron_image_format_t)format); return texture; } -iron_g5_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable) { - iron_g5_texture_t *texture = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); +iron_gpu_texture_t *gpu_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable) { + iron_gpu_texture_t *texture = (iron_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); texture->buffer = NULL; unsigned char *content_data = (unsigned char *)data->buffer; @@ -1452,7 +1452,7 @@ iron_g5_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, str image_format = IRON_IMAGE_FORMAT_RGBA32; } - iron_g5_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); + iron_gpu_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); if (!readable) { free(image_data);; } @@ -1478,7 +1478,7 @@ int _format_byte_size(iron_image_format_t format) { } } -buffer_t *iron_g4_get_texture_pixels(iron_g5_texture_t *image) { +buffer_t *gpu_get_texture_pixels(iron_gpu_texture_t *image) { if (image->buffer == NULL) { image->buffer = malloc(sizeof(buffer_t)); image->buffer->buffer = NULL; @@ -1491,7 +1491,7 @@ buffer_t *iron_g4_get_texture_pixels(iron_g5_texture_t *image) { } uint8_t *b = (uint8_t *)image->buffer->buffer; - iron_g5_render_target_get_pixels(image, b); + iron_gpu_render_target_get_pixels(image, b); // Release staging texture immediately to save memory #ifdef IRON_DIRECT3D12 @@ -1509,44 +1509,44 @@ buffer_t *iron_g4_get_texture_pixels(iron_g5_texture_t *image) { return image->buffer; } -void iron_g4_set_mipmaps(iron_g5_texture_t *texture, any_array_t *mipmaps) { +void gpu_set_mipmaps(iron_gpu_texture_t *texture, any_array_t *mipmaps) { for (int32_t i = 0; i < mipmaps->length; ++i) { - iron_g5_texture_t *img = mipmaps->buffer[i]; - iron_g5_texture_t *img_tex = img; - iron_g5_texture_set_mipmap(texture, img_tex, i + 1); + iron_gpu_texture_t *img = mipmaps->buffer[i]; + iron_gpu_texture_t *img_tex = img; + iron_gpu_texture_set_mipmap(texture, img_tex, i + 1); } } -void _iron_g4_begin(iron_g5_texture_t *render_target, any_array_t *additional) { +void _gpu_begin(iron_gpu_texture_t *render_target, any_array_t *additional) { if (render_target == NULL) { - iron_g4_restore_render_target(); + gpu_restore_render_target(); } else { - iron_g5_texture_t *rt = (iron_g5_texture_t *)render_target; + iron_gpu_texture_t *rt = (iron_gpu_texture_t *)render_target; int32_t length = 1; - iron_g5_texture_t *render_targets[8] = { rt, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + iron_gpu_texture_t *render_targets[8] = { rt, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; if (additional != NULL) { length = additional->length + 1; if (length > 8) { length = 8; } for (int32_t i = 1; i < length; ++i) { - iron_g5_texture_t *img = additional->buffer[i - 1]; - iron_g5_texture_t *art = (iron_g5_texture_t *)img; + iron_gpu_texture_t *img = additional->buffer[i - 1]; + iron_gpu_texture_t *art = (iron_gpu_texture_t *)img; render_targets[i] = art; } } - iron_g4_set_render_targets(render_targets, length); + gpu_set_render_targets(render_targets, length); } } -void _iron_g4_end() { +void _gpu_end() { } -void iron_g4_swap_buffers() { - iron_g4_end(); - iron_g5_swap_buffers(); - iron_g4_begin(); +void gpu_swap_buffers() { + gpu_end(); + iron_gpu_swap_buffers(); + gpu_begin(); } void iron_file_save_bytes(string_t *path, buffer_t *bytes, u64 length) { @@ -2236,47 +2236,47 @@ void iron_ml_unload() { void iron_raytrace_init(buffer_t *shader) { if (raytrace_created) { - iron_g5_constant_buffer_destroy(&constant_buffer); - iron_g5_raytrace_pipeline_destroy(&rt_pipeline); + iron_gpu_constant_buffer_destroy(&constant_buffer); + iron_gpu_raytrace_pipeline_destroy(&rt_pipeline); } raytrace_created = true; - iron_g5_constant_buffer_init(&constant_buffer, constant_buffer_size * 4); - iron_g5_raytrace_pipeline_init(&rt_pipeline, &commandList, shader->buffer, (int)shader->length, &constant_buffer); + iron_gpu_constant_buffer_init(&constant_buffer, constant_buffer_size * 4); + iron_gpu_raytrace_pipeline_init(&rt_pipeline, &commandList, shader->buffer, (int)shader->length, &constant_buffer); } void iron_raytrace_as_init() { if (raytrace_accel_created) { - iron_g5_raytrace_acceleration_structure_destroy(&accel); + iron_gpu_raytrace_acceleration_structure_destroy(&accel); } raytrace_accel_created = true; - iron_g5_raytrace_acceleration_structure_init(&accel); + iron_gpu_raytrace_acceleration_structure_init(&accel); } -void iron_raytrace_as_add(iron_g4_vertex_buffer_t *vb, iron_g5_index_buffer_t *ib, iron_matrix4x4_t transform) { - iron_g5_vertex_buffer_t *vertex_buffer = &vb->impl._buffer; - iron_g5_raytrace_acceleration_structure_add(&accel, vertex_buffer, ib, transform); +void iron_raytrace_as_add(gpu_vertex_buffer_t *vb, iron_gpu_index_buffer_t *ib, iron_matrix4x4_t transform) { + iron_gpu_vertex_buffer_t *vertex_buffer = &vb->impl._buffer; + iron_gpu_raytrace_acceleration_structure_add(&accel, vertex_buffer, ib, transform); } -void iron_raytrace_as_build(iron_g4_vertex_buffer_t *vb_full, iron_g5_index_buffer_t *ib_full) { - iron_g5_raytrace_acceleration_structure_build(&accel, &commandList, &vb_full->impl._buffer, ib_full); +void iron_raytrace_as_build(gpu_vertex_buffer_t *vb_full, iron_gpu_index_buffer_t *ib_full) { + iron_gpu_raytrace_acceleration_structure_build(&accel, &commandList, &vb_full->impl._buffer, ib_full); } -void iron_raytrace_set_textures(iron_g5_texture_t *tex0, iron_g5_texture_t *tex1, iron_g5_texture_t *tex2, iron_g5_texture_t *texenv, iron_g5_texture_t *texsobol, iron_g5_texture_t *texscramble, iron_g5_texture_t *texrank) { - iron_g5_texture_t *texpaint0; - iron_g5_texture_t *texpaint1; - iron_g5_texture_t *texpaint2; +void iron_raytrace_set_textures(iron_gpu_texture_t *tex0, iron_gpu_texture_t *tex1, iron_gpu_texture_t *tex2, iron_gpu_texture_t *texenv, iron_gpu_texture_t *texsobol, iron_gpu_texture_t *texscramble, iron_gpu_texture_t *texrank) { + iron_gpu_texture_t *texpaint0; + iron_gpu_texture_t *texpaint1; + iron_gpu_texture_t *texpaint2; - // iron_g5_texture_t *texpaint0_image = tex0; - // iron_g5_texture_t *texpaint0_tex = texpaint0_image; - // iron_g5_texture_t *texpaint0_rt = texpaint0_image->render_target_; + // iron_gpu_texture_t *texpaint0_image = tex0; + // iron_gpu_texture_t *texpaint0_tex = texpaint0_image; + // iron_gpu_texture_t *texpaint0_rt = texpaint0_image->render_target_; // if (texpaint0_tex != NULL) { - // iron_g5_texture_t *texture = texpaint0_tex; + // iron_gpu_texture_t *texture = texpaint0_tex; // if (!texture->_uploaded) { - // iron_g5_command_list_upload_texture(&commandList, texture); + // iron_gpu_command_list_upload_texture(&commandList, texture); // texture->_uploaded = true; // } - // texpaint0 = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + // texpaint0 = (iron_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); // #ifdef IRON_DIRECT3D12 // texpaint0->impl.srvDescriptorHeap = texture->impl.srvDescriptorHeap; // #endif @@ -2288,17 +2288,17 @@ void iron_raytrace_set_textures(iron_g5_texture_t *tex0, iron_g5_texture_t *tex1 // texpaint0 = texpaint0_rt; // } - // iron_g5_texture_t *texpaint1_image = tex1; - // iron_g5_texture_t *texpaint1_tex = texpaint1_image; - // iron_g5_texture_t *texpaint1_rt = texpaint1_image->render_target_; + // iron_gpu_texture_t *texpaint1_image = tex1; + // iron_gpu_texture_t *texpaint1_tex = texpaint1_image; + // iron_gpu_texture_t *texpaint1_rt = texpaint1_image->render_target_; // if (texpaint1_tex != NULL) { - // iron_g5_texture_t *texture = texpaint1_tex; + // iron_gpu_texture_t *texture = texpaint1_tex; // if (!texture->_uploaded) { - // iron_g5_command_list_upload_texture(&commandList, texture); + // iron_gpu_command_list_upload_texture(&commandList, texture); // texture->_uploaded = true; // } - // texpaint1 = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + // texpaint1 = (iron_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); // #ifdef IRON_DIRECT3D12 // texpaint1->impl.srvDescriptorHeap = texture->impl.srvDescriptorHeap; // #endif @@ -2310,17 +2310,17 @@ void iron_raytrace_set_textures(iron_g5_texture_t *tex0, iron_g5_texture_t *tex1 // texpaint1 = texpaint1_rt; // } - // iron_g5_texture_t *texpaint2_image = tex2; - // iron_g5_texture_t *texpaint2_tex = texpaint2_image; - // iron_g5_texture_t *texpaint2_rt = texpaint2_image->render_target_; + // iron_gpu_texture_t *texpaint2_image = tex2; + // iron_gpu_texture_t *texpaint2_tex = texpaint2_image; + // iron_gpu_texture_t *texpaint2_rt = texpaint2_image->render_target_; // if (texpaint2_tex != NULL) { - // iron_g5_texture_t *texture = (iron_g5_texture_t *)texpaint2_tex; + // iron_gpu_texture_t *texture = (iron_gpu_texture_t *)texpaint2_tex; // if (!texture->_uploaded) { - // iron_g5_command_list_upload_texture(&commandList, texture); + // iron_gpu_command_list_upload_texture(&commandList, texture); // texture->_uploaded = true; // } - // texpaint2 = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); + // texpaint2 = (iron_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); // #ifdef IRON_DIRECT3D12 // texpaint2->impl.srvDescriptorHeap = texture->impl.srvDescriptorHeap; // #endif @@ -2337,23 +2337,23 @@ void iron_raytrace_set_textures(iron_g5_texture_t *tex0, iron_g5_texture_t *tex1 texpaint2 = tex2; if (!texenv->_uploaded) { - iron_g5_command_list_upload_texture(&commandList, texenv); + iron_gpu_command_list_upload_texture(&commandList, texenv); texenv->_uploaded = true; } if (!texsobol->_uploaded) { - iron_g5_command_list_upload_texture(&commandList, texsobol); + iron_gpu_command_list_upload_texture(&commandList, texsobol); texsobol->_uploaded = true; } if (!texscramble->_uploaded) { - iron_g5_command_list_upload_texture(&commandList, texscramble); + iron_gpu_command_list_upload_texture(&commandList, texscramble); texscramble->_uploaded = true; } if (!texrank->_uploaded) { - iron_g5_command_list_upload_texture(&commandList, texrank); + iron_gpu_command_list_upload_texture(&commandList, texrank); texrank->_uploaded = true; } - iron_g5_raytrace_set_textures(texpaint0, texpaint1, texpaint2, texenv, texsobol, texscramble, texrank); + iron_gpu_raytrace_set_textures(texpaint0, texpaint1, texpaint2, texenv, texsobol, texscramble, texrank); // if (texpaint0_tex != NULL) { // free(texpaint0); @@ -2366,18 +2366,18 @@ void iron_raytrace_set_textures(iron_g5_texture_t *tex0, iron_g5_texture_t *tex1 // } } -void iron_raytrace_dispatch_rays(iron_g5_texture_t *render_target, buffer_t *buffer) { +void iron_raytrace_dispatch_rays(iron_gpu_texture_t *render_target, buffer_t *buffer) { float *cb = (float *)buffer->buffer; - iron_g5_constant_buffer_lock_all(&constant_buffer); + iron_gpu_constant_buffer_lock_all(&constant_buffer); for (int i = 0; i < constant_buffer_size; ++i) { - iron_g5_constant_buffer_set_float(&constant_buffer, i * 4, cb[i]); + iron_gpu_constant_buffer_set_float(&constant_buffer, i * 4, cb[i]); } - iron_g5_constant_buffer_unlock(&constant_buffer); + iron_gpu_constant_buffer_unlock(&constant_buffer); - iron_g5_raytrace_set_acceleration_structure(&accel); - iron_g5_raytrace_set_pipeline(&rt_pipeline); - iron_g5_raytrace_set_target(render_target); - iron_g5_raytrace_dispatch_rays(&commandList); + iron_gpu_raytrace_set_acceleration_structure(&accel); + iron_gpu_raytrace_set_pipeline(&rt_pipeline); + iron_gpu_raytrace_set_target(render_target); + iron_gpu_raytrace_dispatch_rays(&commandList); } #endif diff --git a/base/sources/iron_draw.c b/base/sources/iron_draw.c index ba606803..88abadf1 100644 --- a/base/sources/iron_draw.c +++ b/base/sources/iron_draw.c @@ -18,37 +18,37 @@ extern bool waitAfterNextDraw; draw_font_t *draw_font = NULL; int draw_font_size; -iron_g5_texture_t *_draw_current = NULL; +iron_gpu_texture_t *_draw_current = NULL; bool _draw_in_use = false; static iron_matrix4x4_t draw_projection_matrix; static bool draw_bilinear_filter = true; static uint32_t draw_color = 0; -static iron_g5_pipeline_t *draw_last_pipeline = NULL; -static iron_g5_pipeline_t *draw_custom_pipeline = NULL; +static iron_gpu_pipeline_t *draw_last_pipeline = NULL; +static iron_gpu_pipeline_t *draw_custom_pipeline = NULL; static iron_matrix3x3_t draw_transform; static bool _draw_thrown = false; -static iron_g4_vertex_buffer_t image_vertex_buffer; -static iron_g5_index_buffer_t image_index_buffer; -static iron_g5_shader_t image_vert_shader; -static iron_g5_shader_t image_frag_shader; -static iron_g5_pipeline_t image_pipeline; -static iron_g5_texture_unit_t image_tex_unit; -static iron_g5_constant_location_t image_proj_loc; +static gpu_vertex_buffer_t image_vertex_buffer; +static iron_gpu_index_buffer_t image_index_buffer; +static iron_gpu_shader_t image_vert_shader; +static iron_gpu_shader_t image_frag_shader; +static iron_gpu_pipeline_t image_pipeline; +static iron_gpu_texture_unit_t image_tex_unit; +static iron_gpu_constant_location_t image_proj_loc; static float *image_rect_verts = NULL; static int image_buffer_index = 0; static int image_buffer_start = 0; -static iron_g5_texture_t *image_last_texture = NULL; +static iron_gpu_texture_t *image_last_texture = NULL; -static iron_g4_vertex_buffer_t colored_rect_vertex_buffer; -static iron_g5_index_buffer_t colored_rect_index_buffer; -static iron_g4_vertex_buffer_t colored_tris_vertex_buffer; -static iron_g5_index_buffer_t colored_tris_index_buffer; -static iron_g5_shader_t colored_vert_shader; -static iron_g5_shader_t colored_frag_shader; -static iron_g5_pipeline_t colored_pipeline; -static iron_g5_constant_location_t colored_proj_loc; +static gpu_vertex_buffer_t colored_rect_vertex_buffer; +static iron_gpu_index_buffer_t colored_rect_index_buffer; +static gpu_vertex_buffer_t colored_tris_vertex_buffer; +static iron_gpu_index_buffer_t colored_tris_index_buffer; +static iron_gpu_shader_t colored_vert_shader; +static iron_gpu_shader_t colored_frag_shader; +static iron_gpu_pipeline_t colored_pipeline; +static iron_gpu_constant_location_t colored_proj_loc; static float *colored_rect_verts = NULL; static float *colored_tris_verts = NULL; static int colored_rect_buffer_index = 0; @@ -56,18 +56,18 @@ static int colored_rect_buffer_start = 0; static int colored_tris_buffer_index = 0; static int colored_tris_buffer_start = 0; -static iron_g4_vertex_buffer_t text_vertex_buffer; -static iron_g5_index_buffer_t text_index_buffer; -static iron_g5_shader_t text_vert_shader; -static iron_g5_shader_t text_frag_shader; -static iron_g5_pipeline_t text_pipeline; -static iron_g5_pipeline_t text_pipeline_rt; -static iron_g5_texture_unit_t text_tex_unit; -static iron_g5_constant_location_t text_proj_loc; +static gpu_vertex_buffer_t text_vertex_buffer; +static iron_gpu_index_buffer_t text_index_buffer; +static iron_gpu_shader_t text_vert_shader; +static iron_gpu_shader_t text_frag_shader; +static iron_gpu_pipeline_t text_pipeline; +static iron_gpu_pipeline_t text_pipeline_rt; +static iron_gpu_texture_unit_t text_tex_unit; +static iron_gpu_constant_location_t text_proj_loc; static float *text_rect_verts = NULL; static int text_buffer_index = 0; static int text_buffer_start = 0; -static iron_g5_texture_t *text_last_texture = NULL; +static iron_gpu_texture_t *text_last_texture = NULL; static i32_array_t *draw_font_glyph_blocks = NULL; static i32_array_t *draw_font_glyphs = NULL; @@ -122,7 +122,7 @@ iron_vector2_t draw_matrix3x3_multvec(iron_matrix3x3_t *m, iron_vector2_t v) { return (iron_vector2_t){x, y}; } -void draw_internal_set_projection_matrix(iron_g5_texture_t *target) { +void draw_internal_set_projection_matrix(iron_gpu_texture_t *target) { if (target != NULL) { draw_projection_matrix = draw_matrix4x4_orthogonal_projection(0.0f, (float)target->width, (float)target->height, 0.0f, 0.1f, 1000.0f); } @@ -136,33 +136,33 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ver draw_transform = iron_matrix3x3_identity(); // Image painter - iron_g5_shader_init(&image_vert_shader, image_vert->buffer, image_vert->length, IRON_G5_SHADER_TYPE_VERTEX); - iron_g5_shader_init(&image_frag_shader, image_frag->buffer, image_frag->length, IRON_G5_SHADER_TYPE_FRAGMENT); + iron_gpu_shader_init(&image_vert_shader, image_vert->buffer, image_vert->length, IRON_GPU_SHADER_TYPE_VERTEX); + iron_gpu_shader_init(&image_frag_shader, image_frag->buffer, image_frag->length, IRON_GPU_SHADER_TYPE_FRAGMENT); { - iron_g5_vertex_structure_t structure; - iron_g5_vertex_structure_init(&structure); - iron_g5_vertex_structure_add(&structure, "pos", IRON_G5_VERTEX_DATA_F32_3X); - iron_g5_vertex_structure_add(&structure, "tex", IRON_G5_VERTEX_DATA_F32_2X); - iron_g5_vertex_structure_add(&structure, "col", IRON_G5_VERTEX_DATA_U8_4X_NORM); - iron_g5_pipeline_init(&image_pipeline); + iron_gpu_vertex_structure_t structure; + iron_gpu_vertex_structure_init(&structure); + iron_gpu_vertex_structure_add(&structure, "pos", IRON_GPU_VERTEX_DATA_F32_3X); + iron_gpu_vertex_structure_add(&structure, "tex", IRON_GPU_VERTEX_DATA_F32_2X); + iron_gpu_vertex_structure_add(&structure, "col", IRON_GPU_VERTEX_DATA_U8_4X_NORM); + iron_gpu_pipeline_init(&image_pipeline); image_pipeline.input_layout = &structure; image_pipeline.vertex_shader = &image_vert_shader; image_pipeline.fragment_shader = &image_frag_shader; - image_pipeline.blend_source = IRON_G5_BLEND_ONE; - image_pipeline.blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; - image_pipeline.alpha_blend_source = IRON_G5_BLEND_ONE; - image_pipeline.alpha_blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; - iron_g5_pipeline_compile(&image_pipeline); + image_pipeline.blend_source = IRON_GPU_BLEND_ONE; + image_pipeline.blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; + image_pipeline.alpha_blend_source = IRON_GPU_BLEND_ONE; + image_pipeline.alpha_blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; + iron_gpu_pipeline_compile(&image_pipeline); - image_tex_unit = iron_g5_pipeline_get_texture_unit(&image_pipeline, "tex"); - image_proj_loc = iron_g5_pipeline_get_constant_location(&image_pipeline, "P"); + image_tex_unit = iron_gpu_pipeline_get_texture_unit(&image_pipeline, "tex"); + image_proj_loc = iron_gpu_pipeline_get_constant_location(&image_pipeline, "P"); - iron_g4_vertex_buffer_init(&image_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, IRON_G4_USAGE_DYNAMIC); - image_rect_verts = iron_g4_vertex_buffer_lock_all(&image_vertex_buffer); + gpu_vertex_buffer_init(&image_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, GPU_USAGE_DYNAMIC); + image_rect_verts = gpu_vertex_buffer_lock_all(&image_vertex_buffer); - iron_g5_index_buffer_init(&image_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); - int *indices = iron_g5_index_buffer_lock_all(&image_index_buffer); + iron_gpu_index_buffer_init(&image_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); + int *indices = iron_gpu_index_buffer_lock_all(&image_index_buffer); for (int i = 0; i < DRAW_BUFFER_SIZE; ++i) { indices[i * 3 * 2 + 0] = i * 4 + 0; indices[i * 3 * 2 + 1] = i * 4 + 1; @@ -171,36 +171,36 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ver indices[i * 3 * 2 + 4] = i * 4 + 2; indices[i * 3 * 2 + 5] = i * 4 + 3; } - iron_g4_index_buffer_unlock_all(&image_index_buffer); + gpu_index_buffer_unlock_all(&image_index_buffer); } // Colored painter - iron_g5_shader_init(&colored_vert_shader, colored_vert->buffer, colored_vert->length, IRON_G5_SHADER_TYPE_VERTEX); - iron_g5_shader_init(&colored_frag_shader, colored_frag->buffer, colored_frag->length, IRON_G5_SHADER_TYPE_FRAGMENT); + iron_gpu_shader_init(&colored_vert_shader, colored_vert->buffer, colored_vert->length, IRON_GPU_SHADER_TYPE_VERTEX); + iron_gpu_shader_init(&colored_frag_shader, colored_frag->buffer, colored_frag->length, IRON_GPU_SHADER_TYPE_FRAGMENT); { - iron_g5_vertex_structure_t structure; - iron_g5_vertex_structure_init(&structure); - iron_g5_vertex_structure_add(&structure, "pos", IRON_G5_VERTEX_DATA_F32_3X); - iron_g5_vertex_structure_add(&structure, "col", IRON_G5_VERTEX_DATA_U8_4X_NORM); - iron_g5_pipeline_init(&colored_pipeline); + iron_gpu_vertex_structure_t structure; + iron_gpu_vertex_structure_init(&structure); + iron_gpu_vertex_structure_add(&structure, "pos", IRON_GPU_VERTEX_DATA_F32_3X); + iron_gpu_vertex_structure_add(&structure, "col", IRON_GPU_VERTEX_DATA_U8_4X_NORM); + iron_gpu_pipeline_init(&colored_pipeline); colored_pipeline.input_layout = &structure; colored_pipeline.vertex_shader = &colored_vert_shader; colored_pipeline.fragment_shader = &colored_frag_shader; - // colored_pipeline.blend_source = IRON_G5_BLEND_ONE; - colored_pipeline.blend_source = IRON_G5_BLEND_SOURCE_ALPHA; - colored_pipeline.blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; - colored_pipeline.alpha_blend_source = IRON_G5_BLEND_ONE; - colored_pipeline.alpha_blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; - iron_g5_pipeline_compile(&colored_pipeline); + // colored_pipeline.blend_source = IRON_GPU_BLEND_ONE; + colored_pipeline.blend_source = IRON_GPU_BLEND_SOURCE_ALPHA; + colored_pipeline.blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; + colored_pipeline.alpha_blend_source = IRON_GPU_BLEND_ONE; + colored_pipeline.alpha_blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; + iron_gpu_pipeline_compile(&colored_pipeline); - colored_proj_loc = iron_g5_pipeline_get_constant_location(&colored_pipeline, "P"); + colored_proj_loc = iron_gpu_pipeline_get_constant_location(&colored_pipeline, "P"); - iron_g4_vertex_buffer_init(&colored_rect_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, IRON_G4_USAGE_DYNAMIC); - colored_rect_verts = iron_g4_vertex_buffer_lock_all(&colored_rect_vertex_buffer); + gpu_vertex_buffer_init(&colored_rect_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, GPU_USAGE_DYNAMIC); + colored_rect_verts = gpu_vertex_buffer_lock_all(&colored_rect_vertex_buffer); - iron_g5_index_buffer_init(&colored_rect_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); - int *indices = iron_g5_index_buffer_lock_all(&colored_rect_index_buffer); + iron_gpu_index_buffer_init(&colored_rect_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); + int *indices = iron_gpu_index_buffer_lock_all(&colored_rect_index_buffer); for (int i = 0; i < DRAW_BUFFER_SIZE; ++i) { indices[i * 3 * 2 + 0] = i * 4 + 0; indices[i * 3 * 2 + 1] = i * 4 + 1; @@ -209,59 +209,59 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ver indices[i * 3 * 2 + 4] = i * 4 + 2; indices[i * 3 * 2 + 5] = i * 4 + 3; } - iron_g4_index_buffer_unlock_all(&colored_rect_index_buffer); + gpu_index_buffer_unlock_all(&colored_rect_index_buffer); - iron_g4_vertex_buffer_init(&colored_tris_vertex_buffer, DRAW_BUFFER_SIZE * 3, &structure, IRON_G4_USAGE_DYNAMIC); - colored_tris_verts = iron_g4_vertex_buffer_lock_all(&colored_tris_vertex_buffer); + gpu_vertex_buffer_init(&colored_tris_vertex_buffer, DRAW_BUFFER_SIZE * 3, &structure, GPU_USAGE_DYNAMIC); + colored_tris_verts = gpu_vertex_buffer_lock_all(&colored_tris_vertex_buffer); - iron_g5_index_buffer_init(&colored_tris_index_buffer, DRAW_BUFFER_SIZE * 3, true); - indices = iron_g5_index_buffer_lock_all(&colored_tris_index_buffer); + iron_gpu_index_buffer_init(&colored_tris_index_buffer, DRAW_BUFFER_SIZE * 3, true); + indices = iron_gpu_index_buffer_lock_all(&colored_tris_index_buffer); for (int i = 0; i < DRAW_BUFFER_SIZE; ++i) { indices[i * 3 + 0] = i * 3 + 0; indices[i * 3 + 1] = i * 3 + 1; indices[i * 3 + 2] = i * 3 + 2; } - iron_g4_index_buffer_unlock_all(&colored_tris_index_buffer); + gpu_index_buffer_unlock_all(&colored_tris_index_buffer); } // Text painter - iron_g5_shader_init(&text_vert_shader, text_vert->buffer, text_vert->length, IRON_G5_SHADER_TYPE_VERTEX); - iron_g5_shader_init(&text_frag_shader, text_frag->buffer, text_frag->length, IRON_G5_SHADER_TYPE_FRAGMENT); + iron_gpu_shader_init(&text_vert_shader, text_vert->buffer, text_vert->length, IRON_GPU_SHADER_TYPE_VERTEX); + iron_gpu_shader_init(&text_frag_shader, text_frag->buffer, text_frag->length, IRON_GPU_SHADER_TYPE_FRAGMENT); { - iron_g5_vertex_structure_t structure; - iron_g5_vertex_structure_init(&structure); - iron_g5_vertex_structure_add(&structure, "pos", IRON_G5_VERTEX_DATA_F32_3X); - iron_g5_vertex_structure_add(&structure, "tex", IRON_G5_VERTEX_DATA_F32_2X); - iron_g5_vertex_structure_add(&structure, "col", IRON_G5_VERTEX_DATA_U8_4X_NORM); + iron_gpu_vertex_structure_t structure; + iron_gpu_vertex_structure_init(&structure); + iron_gpu_vertex_structure_add(&structure, "pos", IRON_GPU_VERTEX_DATA_F32_3X); + iron_gpu_vertex_structure_add(&structure, "tex", IRON_GPU_VERTEX_DATA_F32_2X); + iron_gpu_vertex_structure_add(&structure, "col", IRON_GPU_VERTEX_DATA_U8_4X_NORM); - iron_g5_pipeline_init(&text_pipeline); + iron_gpu_pipeline_init(&text_pipeline); text_pipeline.input_layout = &structure; text_pipeline.vertex_shader = &text_vert_shader; text_pipeline.fragment_shader = &text_frag_shader; - text_pipeline.blend_source = IRON_G5_BLEND_SOURCE_ALPHA; - text_pipeline.blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; - text_pipeline.alpha_blend_source = IRON_G5_BLEND_SOURCE_ALPHA; - text_pipeline.alpha_blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; - iron_g5_pipeline_compile(&text_pipeline); - text_tex_unit = iron_g5_pipeline_get_texture_unit(&text_pipeline, "tex"); - text_proj_loc = iron_g5_pipeline_get_constant_location(&text_pipeline, "P"); + text_pipeline.blend_source = IRON_GPU_BLEND_SOURCE_ALPHA; + text_pipeline.blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; + text_pipeline.alpha_blend_source = IRON_GPU_BLEND_SOURCE_ALPHA; + text_pipeline.alpha_blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; + iron_gpu_pipeline_compile(&text_pipeline); + text_tex_unit = iron_gpu_pipeline_get_texture_unit(&text_pipeline, "tex"); + text_proj_loc = iron_gpu_pipeline_get_constant_location(&text_pipeline, "P"); - iron_g5_pipeline_init(&text_pipeline_rt); + iron_gpu_pipeline_init(&text_pipeline_rt); text_pipeline_rt.input_layout = &structure; text_pipeline_rt.vertex_shader = &text_vert_shader; text_pipeline_rt.fragment_shader = &text_frag_shader; - text_pipeline_rt.blend_source = IRON_G5_BLEND_SOURCE_ALPHA; - text_pipeline_rt.blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; - text_pipeline_rt.alpha_blend_source = IRON_G5_BLEND_ONE; - text_pipeline_rt.alpha_blend_destination = IRON_G5_BLEND_INV_SOURCE_ALPHA; - iron_g5_pipeline_compile(&text_pipeline_rt); + text_pipeline_rt.blend_source = IRON_GPU_BLEND_SOURCE_ALPHA; + text_pipeline_rt.blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; + text_pipeline_rt.alpha_blend_source = IRON_GPU_BLEND_ONE; + text_pipeline_rt.alpha_blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; + iron_gpu_pipeline_compile(&text_pipeline_rt); - iron_g4_vertex_buffer_init(&text_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, IRON_G4_USAGE_DYNAMIC); - text_rect_verts = iron_g4_vertex_buffer_lock_all(&text_vertex_buffer); + gpu_vertex_buffer_init(&text_vertex_buffer, DRAW_BUFFER_SIZE * 4, &structure, GPU_USAGE_DYNAMIC); + text_rect_verts = gpu_vertex_buffer_lock_all(&text_vertex_buffer); - iron_g5_index_buffer_init(&text_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); - int *indices = iron_g5_index_buffer_lock_all(&text_index_buffer); + iron_gpu_index_buffer_init(&text_index_buffer, DRAW_BUFFER_SIZE * 3 * 2, true); + int *indices = iron_gpu_index_buffer_lock_all(&text_index_buffer); for (int i = 0; i < DRAW_BUFFER_SIZE; ++i) { indices[i * 3 * 2 + 0] = i * 4 + 0; indices[i * 3 * 2 + 1] = i * 4 + 1; @@ -270,7 +270,7 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ver indices[i * 3 * 2 + 4] = i * 4 + 2; indices[i * 3 * 2 + 5] = i * 4 + 3; } - iron_g4_index_buffer_unlock_all(&text_index_buffer); + gpu_index_buffer_unlock_all(&text_index_buffer); } } @@ -278,7 +278,7 @@ static void _draw_begin() { draw_set_color(0xffffffff); } -void draw_begin(iron_g5_texture_t *render_target) { +void draw_begin(iron_gpu_texture_t *render_target) { if (_draw_in_use && !_draw_thrown) { _draw_thrown = true; iron_log("End before you begin"); @@ -340,32 +340,32 @@ void draw_set_image_rect_colors(uint32_t color) { void draw_image_buffer(bool end) { if (image_buffer_index - image_buffer_start == 0) return; - iron_g4_vertex_buffer_unlock(&image_vertex_buffer, (image_buffer_index - image_buffer_start) * 4); - iron_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_pipeline); - iron_g4_set_matrix4(image_proj_loc, &draw_projection_matrix); - iron_g4_set_vertex_buffer(&image_vertex_buffer); - iron_g4_set_index_buffer(&image_index_buffer); - iron_g4_set_texture(image_tex_unit, image_last_texture); - iron_g4_set_texture_addressing(image_tex_unit, IRON_G4_TEXTURE_DIRECTION_U, IRON_G4_TEXTURE_ADDRESSING_CLAMP); - iron_g4_set_texture_addressing(image_tex_unit, IRON_G4_TEXTURE_DIRECTION_V, IRON_G4_TEXTURE_ADDRESSING_CLAMP); - // iron_g4_set_texture_mipmap_filter(image_tex_unit, draw_bilinear_filter ? IRON_G4_MIPMAP_FILTER_LINEAR : IRON_G4_MIPMAP_FILTER_NONE); - iron_g4_set_texture_mipmap_filter(image_tex_unit, IRON_G4_MIPMAP_FILTER_NONE); - iron_g4_set_texture_minification_filter(image_tex_unit, draw_bilinear_filter ? IRON_G4_TEXTURE_FILTER_LINEAR : IRON_G4_TEXTURE_FILTER_POINT); - iron_g4_set_texture_magnification_filter(image_tex_unit, draw_bilinear_filter ? IRON_G4_TEXTURE_FILTER_LINEAR : IRON_G4_TEXTURE_FILTER_POINT); - iron_g5_draw_indexed_vertices_from_to(image_buffer_start * 2 * 3, (image_buffer_index - image_buffer_start) * 2 * 3); + gpu_vertex_buffer_unlock(&image_vertex_buffer, (image_buffer_index - image_buffer_start) * 4); + iron_gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_pipeline); + gpu_set_matrix4(image_proj_loc, &draw_projection_matrix); + gpu_set_vertex_buffer(&image_vertex_buffer); + gpu_set_index_buffer(&image_index_buffer); + gpu_set_texture(image_tex_unit, image_last_texture); + gpu_set_texture_addressing(image_tex_unit, GPU_TEXTURE_DIRECTION_U, GPU_TEXTURE_ADDRESSING_CLAMP); + gpu_set_texture_addressing(image_tex_unit, GPU_TEXTURE_DIRECTION_V, GPU_TEXTURE_ADDRESSING_CLAMP); + // gpu_set_texture_mipmap_filter(image_tex_unit, draw_bilinear_filter ? GPU_MIPMAP_FILTER_LINEAR : GPU_MIPMAP_FILTER_NONE); + gpu_set_texture_mipmap_filter(image_tex_unit, GPU_MIPMAP_FILTER_NONE); + gpu_set_texture_minification_filter(image_tex_unit, draw_bilinear_filter ? GPU_TEXTURE_FILTER_LINEAR : GPU_TEXTURE_FILTER_POINT); + gpu_set_texture_magnification_filter(image_tex_unit, draw_bilinear_filter ? GPU_TEXTURE_FILTER_LINEAR : GPU_TEXTURE_FILTER_POINT); + iron_gpu_draw_indexed_vertices_from_to(image_buffer_start * 2 * 3, (image_buffer_index - image_buffer_start) * 2 * 3); if (end || image_buffer_index + 1 >= DRAW_BUFFER_SIZE) { image_buffer_start = 0; image_buffer_index = 0; - image_rect_verts = iron_g4_vertex_buffer_lock(&image_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); + image_rect_verts = gpu_vertex_buffer_lock(&image_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); } else { image_buffer_start = image_buffer_index; - image_rect_verts = iron_g4_vertex_buffer_lock(&image_vertex_buffer, image_buffer_start * 4, (DRAW_BUFFER_SIZE - image_buffer_start) * 4); + image_rect_verts = gpu_vertex_buffer_lock(&image_vertex_buffer, image_buffer_start * 4, (DRAW_BUFFER_SIZE - image_buffer_start) * 4); } } -void draw_scaled_sub_texture(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { +void draw_scaled_sub_texture(iron_gpu_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { draw_colored_end(); draw_text_end(); if (image_buffer_start + image_buffer_index + 1 >= DRAW_BUFFER_SIZE || @@ -383,34 +383,34 @@ void draw_scaled_sub_texture(iron_g5_texture_t *tex, float sx, float sy, float s image_last_texture = tex; } -void draw_scaled_texture(iron_g5_texture_t *tex, float dx, float dy, float dw, float dh) { +void draw_scaled_texture(iron_gpu_texture_t *tex, float dx, float dy, float dw, float dh) { draw_scaled_sub_texture(tex, 0, 0, (float)tex->width, (float)tex->height, dx, dy, dw, dh); } -void draw_sub_texture(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y) { +void draw_sub_texture(iron_gpu_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y) { draw_scaled_sub_texture(tex, sx, sy, sw, sh, x, y, sw, sh); } -void draw_texture(iron_g5_texture_t *tex, float x, float y) { +void draw_texture(iron_gpu_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(iron_g5_texture_t *image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { +void draw_scaled_sub_image(iron_gpu_texture_t *image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { #ifdef IRON_DIRECT3D12 waitAfterNextDraw = true; #endif draw_scaled_sub_texture(image, sx, sy, sw, sh, dx, dy, dw, dh); } -void draw_scaled_image(iron_g5_texture_t *tex, float dx, float dy, float dw, float dh) { +void draw_scaled_image(iron_gpu_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(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y) { +void draw_sub_image(iron_gpu_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(iron_g5_texture_t *tex, float x, float y) { +void draw_image(iron_gpu_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); } @@ -449,21 +449,21 @@ void draw_colored_rect_draw_buffer(bool tris_done) { if (!tris_done) draw_colored_tris_end(true); - iron_g4_vertex_buffer_unlock(&colored_rect_vertex_buffer, (colored_rect_buffer_index - colored_rect_buffer_start) * 4); - iron_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &colored_pipeline); - iron_g4_set_matrix4(colored_proj_loc, &draw_projection_matrix); - iron_g4_set_vertex_buffer(&colored_rect_vertex_buffer); - iron_g4_set_index_buffer(&colored_rect_index_buffer); - iron_g5_draw_indexed_vertices_from_to(colored_rect_buffer_start * 2 * 3, (colored_rect_buffer_index - colored_rect_buffer_start) * 2 * 3); + gpu_vertex_buffer_unlock(&colored_rect_vertex_buffer, (colored_rect_buffer_index - colored_rect_buffer_start) * 4); + iron_gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &colored_pipeline); + gpu_set_matrix4(colored_proj_loc, &draw_projection_matrix); + gpu_set_vertex_buffer(&colored_rect_vertex_buffer); + gpu_set_index_buffer(&colored_rect_index_buffer); + iron_gpu_draw_indexed_vertices_from_to(colored_rect_buffer_start * 2 * 3, (colored_rect_buffer_index - colored_rect_buffer_start) * 2 * 3); if (colored_rect_buffer_index + 1 >= DRAW_BUFFER_SIZE) { colored_rect_buffer_start = 0; colored_rect_buffer_index = 0; - colored_rect_verts = iron_g4_vertex_buffer_lock(&colored_rect_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); + colored_rect_verts = gpu_vertex_buffer_lock(&colored_rect_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); } else { colored_rect_buffer_start = colored_rect_buffer_index; - colored_rect_verts = iron_g4_vertex_buffer_lock(&colored_rect_vertex_buffer, colored_rect_buffer_start * 4, (DRAW_BUFFER_SIZE - colored_rect_buffer_start) * 4); + colored_rect_verts = gpu_vertex_buffer_lock(&colored_rect_vertex_buffer, colored_rect_buffer_start * 4, (DRAW_BUFFER_SIZE - colored_rect_buffer_start) * 4); } } @@ -497,21 +497,21 @@ void draw_colored_tris_draw_buffer(bool rect_done) { if (!rect_done) draw_colored_rect_end(true); - iron_g4_vertex_buffer_unlock(&colored_tris_vertex_buffer, (colored_tris_buffer_index - colored_tris_buffer_start) * 3); - iron_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &colored_pipeline); - iron_g4_set_matrix4(colored_proj_loc, &draw_projection_matrix); - iron_g4_set_vertex_buffer(&colored_tris_vertex_buffer); - iron_g4_set_index_buffer(&colored_tris_index_buffer); - iron_g5_draw_indexed_vertices_from_to(colored_tris_buffer_start * 3, (colored_tris_buffer_index - colored_tris_buffer_start) * 3); + gpu_vertex_buffer_unlock(&colored_tris_vertex_buffer, (colored_tris_buffer_index - colored_tris_buffer_start) * 3); + iron_gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &colored_pipeline); + gpu_set_matrix4(colored_proj_loc, &draw_projection_matrix); + gpu_set_vertex_buffer(&colored_tris_vertex_buffer); + gpu_set_index_buffer(&colored_tris_index_buffer); + iron_gpu_draw_indexed_vertices_from_to(colored_tris_buffer_start * 3, (colored_tris_buffer_index - colored_tris_buffer_start) * 3); if (colored_tris_buffer_index + 1 >= DRAW_BUFFER_SIZE) { colored_tris_buffer_start = 0; colored_tris_buffer_index = 0; - colored_tris_verts = iron_g4_vertex_buffer_lock(&colored_tris_vertex_buffer, 0, DRAW_BUFFER_SIZE * 3); + colored_tris_verts = gpu_vertex_buffer_lock(&colored_tris_vertex_buffer, 0, DRAW_BUFFER_SIZE * 3); } else { colored_tris_buffer_start = colored_tris_buffer_index; - colored_tris_verts = iron_g4_vertex_buffer_lock(&colored_tris_vertex_buffer, colored_tris_buffer_start * 3, (DRAW_BUFFER_SIZE - colored_tris_buffer_start) * 3); + colored_tris_verts = gpu_vertex_buffer_lock(&colored_tris_vertex_buffer, colored_tris_buffer_start * 3, (DRAW_BUFFER_SIZE - colored_tris_buffer_start) * 3); } } @@ -662,27 +662,27 @@ void draw_text_set_rect_colors(uint32_t color) { void draw_text_draw_buffer(bool end) { if (text_buffer_index - text_buffer_start == 0) return; - iron_g4_vertex_buffer_unlock(&text_vertex_buffer, text_buffer_index * 4); - iron_g5_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : _draw_current != NULL ? &text_pipeline_rt : &text_pipeline); - iron_g4_set_matrix4(text_proj_loc, &draw_projection_matrix); - iron_g4_set_vertex_buffer(&text_vertex_buffer); - iron_g4_set_index_buffer(&text_index_buffer); - iron_g4_set_texture(text_tex_unit, text_last_texture); - iron_g4_set_texture_addressing(text_tex_unit, IRON_G4_TEXTURE_DIRECTION_U, IRON_G4_TEXTURE_ADDRESSING_CLAMP); - iron_g4_set_texture_addressing(text_tex_unit, IRON_G4_TEXTURE_DIRECTION_V, IRON_G4_TEXTURE_ADDRESSING_CLAMP); - iron_g4_set_texture_mipmap_filter(text_tex_unit, IRON_G4_MIPMAP_FILTER_NONE); - iron_g4_set_texture_minification_filter(text_tex_unit, draw_bilinear_filter ? IRON_G4_TEXTURE_FILTER_LINEAR : IRON_G4_TEXTURE_FILTER_POINT); - iron_g4_set_texture_magnification_filter(text_tex_unit, draw_bilinear_filter ? IRON_G4_TEXTURE_FILTER_LINEAR : IRON_G4_TEXTURE_FILTER_POINT); - iron_g5_draw_indexed_vertices_from_to(text_buffer_start * 2 * 3, (text_buffer_index - text_buffer_start) * 2 * 3); + gpu_vertex_buffer_unlock(&text_vertex_buffer, text_buffer_index * 4); + iron_gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : _draw_current != NULL ? &text_pipeline_rt : &text_pipeline); + gpu_set_matrix4(text_proj_loc, &draw_projection_matrix); + gpu_set_vertex_buffer(&text_vertex_buffer); + gpu_set_index_buffer(&text_index_buffer); + gpu_set_texture(text_tex_unit, text_last_texture); + gpu_set_texture_addressing(text_tex_unit, GPU_TEXTURE_DIRECTION_U, GPU_TEXTURE_ADDRESSING_CLAMP); + gpu_set_texture_addressing(text_tex_unit, GPU_TEXTURE_DIRECTION_V, GPU_TEXTURE_ADDRESSING_CLAMP); + gpu_set_texture_mipmap_filter(text_tex_unit, GPU_MIPMAP_FILTER_NONE); + gpu_set_texture_minification_filter(text_tex_unit, draw_bilinear_filter ? GPU_TEXTURE_FILTER_LINEAR : GPU_TEXTURE_FILTER_POINT); + gpu_set_texture_magnification_filter(text_tex_unit, draw_bilinear_filter ? GPU_TEXTURE_FILTER_LINEAR : GPU_TEXTURE_FILTER_POINT); + iron_gpu_draw_indexed_vertices_from_to(text_buffer_start * 2 * 3, (text_buffer_index - text_buffer_start) * 2 * 3); if (end || text_buffer_index + 1 >= DRAW_BUFFER_SIZE) { text_buffer_start = 0; text_buffer_index = 0; - text_rect_verts = iron_g4_vertex_buffer_lock(&text_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); + text_rect_verts = gpu_vertex_buffer_lock(&text_vertex_buffer, 0, DRAW_BUFFER_SIZE * 4); } else { text_buffer_start = text_buffer_index; - text_rect_verts = iron_g4_vertex_buffer_lock(&text_vertex_buffer, text_buffer_start * 4, (DRAW_BUFFER_SIZE - text_buffer_start) * 4); + text_rect_verts = gpu_vertex_buffer_lock(&text_vertex_buffer, text_buffer_start * 4, (DRAW_BUFFER_SIZE - text_buffer_start) * 4); } } @@ -698,7 +698,7 @@ typedef struct draw_font_aligned_quad { typedef struct draw_font_image { float m_size; stbtt_bakedchar *chars; - iron_g5_texture_t *tex; + iron_gpu_texture_t *tex; int width, height, first_unused_y; float baseline, descent, line_gap; } draw_font_image_t; @@ -818,13 +818,13 @@ bool draw_font_load(draw_font_t *font, int size) { img->height = height; img->chars = baked; img->first_unused_y = status; - img->tex = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); - iron_g5_texture_init_from_bytes(img->tex, pixels, width, height, IRON_IMAGE_FORMAT_R8); + img->tex = (iron_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); + iron_gpu_texture_init_from_bytes(img->tex, pixels, width, height, IRON_IMAGE_FORMAT_R8); free(pixels); return true; } -iron_g5_texture_t *draw_font_get_texture(draw_font_t *font, int size) { +iron_gpu_texture_t *draw_font_get_texture(draw_font_t *font, int size) { draw_font_image_t *img = draw_font_get_image_internal(font, size); return img->tex; } @@ -884,7 +884,7 @@ void draw_string(const char *text, float x, float y) { draw_colored_end(); draw_font_image_t *img = draw_font_get_image_internal(draw_font, draw_font_size); - iron_g5_texture_t *tex = img->tex; + iron_gpu_texture_t *tex = img->tex; if (text_last_texture != NULL && tex != text_last_texture) draw_text_draw_buffer(false); text_last_texture = tex; @@ -955,8 +955,8 @@ void draw_font_13(draw_font_t *font) { img->width = 128; img->height = 128; img->first_unused_y = 0; - img->tex = (iron_g5_texture_t *)malloc(sizeof(iron_g5_texture_t)); - iron_g5_texture_init_from_bytes(img->tex, (void *)iron_font_13_pixels, 128, 128, IRON_IMAGE_FORMAT_R8); + img->tex = (iron_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); + iron_gpu_texture_init_from_bytes(img->tex, (void *)iron_font_13_pixels, 128, 128, IRON_IMAGE_FORMAT_R8); stbtt_bakedchar *baked = (stbtt_bakedchar *)malloc(95 * sizeof(stbtt_bakedchar)); for (int i = 0; i < 95; ++i) { @@ -1103,7 +1103,7 @@ uint32_t draw_get_color() { return draw_color; } -void draw_set_pipeline(iron_g5_pipeline_t *pipeline) { +void draw_set_pipeline(iron_gpu_pipeline_t *pipeline) { if (pipeline == draw_last_pipeline) { return; } @@ -1140,16 +1140,16 @@ void draw_restore_render_target(void) { _draw_current = NULL; _draw_end(); _draw_begin(); - iron_g4_restore_render_target(); + gpu_restore_render_target(); draw_internal_set_projection_matrix(NULL); } -void draw_set_render_target(iron_g5_texture_t *target) { +void draw_set_render_target(iron_gpu_texture_t *target) { _draw_current = target; _draw_end(); _draw_begin(); - iron_g5_texture_t *render_targets[1] = { target }; - iron_g4_set_render_targets(render_targets, 1); + iron_gpu_texture_t *render_targets[1] = { target }; + gpu_set_render_targets(render_targets, 1); draw_internal_set_projection_matrix(target); } diff --git a/base/sources/iron_draw.h b/base/sources/iron_draw.h index 44724466..7a48e48e 100644 --- a/base/sources/iron_draw.h +++ b/base/sources/iron_draw.h @@ -27,15 +27,15 @@ typedef struct draw_font { } draw_font_t; 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(iron_g5_texture_t *target); -void draw_scaled_sub_image(iron_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(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); -void draw_scaled_image(iron_g5_texture_t *tex, float dx, float dy, float dw, float dh); -void draw_sub_image(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); -void draw_image(iron_g5_texture_t *tex, float x, float y); -void draw_scaled_texture(iron_g5_texture_t *tex, float dx, float dy, float dw, float dh); -void draw_sub_texture(iron_g5_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); -void draw_texture(iron_g5_texture_t *tex, float x, float y); +void draw_begin(iron_gpu_texture_t *target); +void draw_scaled_sub_image(iron_gpu_texture_t *img, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); +void draw_scaled_sub_texture(iron_gpu_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); +void draw_scaled_image(iron_gpu_texture_t *tex, float dx, float dy, float dw, float dh); +void draw_sub_image(iron_gpu_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); +void draw_image(iron_gpu_texture_t *tex, float x, float y); +void draw_scaled_texture(iron_gpu_texture_t *tex, float dx, float dy, float dw, float dh); +void draw_sub_texture(iron_gpu_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); +void draw_texture(iron_gpu_texture_t *tex, float x, float y); void draw_filled_triangle(float x0, float y0, float x1, float y1, float x2, float y2); void draw_filled_rect(float x, float y, float width, float height); void draw_rect(float x, float y, float width, float height, float strength); @@ -45,7 +45,7 @@ void draw_string(const char *text, float x, float y); void draw_end(void); void draw_set_color(uint32_t color); uint32_t draw_get_color(); -void draw_set_pipeline(iron_g5_pipeline_t *pipeline); +void draw_set_pipeline(iron_gpu_pipeline_t *pipeline); void draw_set_transform(mat3_t matrix); bool draw_set_font(draw_font_t *font, int size); void draw_font_init(draw_font_t *font); @@ -60,7 +60,7 @@ float draw_sub_string_width(draw_font_t *font, int font_size, const char *text, int draw_string_width(draw_font_t *font, int font_size, const char *text); void draw_set_bilinear_filter(bool bilinear); void draw_restore_render_target(void); -void draw_set_render_target(iron_g5_texture_t *target); +void draw_set_render_target(iron_gpu_texture_t *target); void draw_filled_circle(float cx, float cy, float radius, int segments); void draw_circle(float cx, float cy, float radius, int segments, float strength); @@ -68,5 +68,5 @@ void draw_cubic_bezier(f32_array_t *x, f32_array_t *y, int segments, float stren extern int draw_font_size; extern draw_font_t *draw_font; -extern iron_g5_texture_t *_draw_current; +extern iron_gpu_texture_t *_draw_current; extern bool _draw_in_use; diff --git a/base/sources/iron_gpu.c b/base/sources/iron_gpu.c index 53e71328..96fa7c41 100644 --- a/base/sources/iron_gpu.c +++ b/base/sources/iron_gpu.c @@ -13,41 +13,41 @@ #define MAX_SAMPLERS_PER_STAGE 16 #define MAX_SAMPLER_CACHE_SIZE 256 -static iron_g5_sampler_options_t sampler_options[IRON_G5_SHADER_TYPE_COUNT][MAX_SAMPLERS_PER_STAGE]; +static iron_gpu_sampler_options_t sampler_options[IRON_GPU_SHADER_TYPE_COUNT][MAX_SAMPLERS_PER_STAGE]; struct sampler_cache_entry { - iron_g5_sampler_options_t options; - iron_g5_sampler_t sampler; + iron_gpu_sampler_options_t options; + iron_gpu_sampler_t sampler; }; static struct sampler_cache_entry sampler_cache[MAX_SAMPLER_CACHE_SIZE]; static int sampler_cache_size = 0; void iron_internal_samplers_reset(void); -iron_g5_sampler_t *iron_internal_get_current_sampler(int stage, int unit); +iron_gpu_sampler_t *iron_internal_get_current_sampler(int stage, int unit); -iron_g5_command_list_t commandList; +iron_gpu_command_list_t commandList; bool waitAfterNextDraw = false; -static iron_g5_constant_buffer_t vertexConstantBuffer; -static iron_g5_constant_buffer_t fragmentConstantBuffer; -static iron_g5_constant_buffer_t computeConstantBuffer; +static iron_gpu_constant_buffer_t vertexConstantBuffer; +static iron_gpu_constant_buffer_t fragmentConstantBuffer; +static iron_gpu_constant_buffer_t computeConstantBuffer; static int constantBufferIndex = 0; static struct { int currentBuffer; - iron_g5_texture_t framebuffers[FRAMEBUFFER_COUNT]; - iron_g5_texture_t *current_render_targets[8]; + iron_gpu_texture_t framebuffers[FRAMEBUFFER_COUNT]; + iron_gpu_texture_t *current_render_targets[8]; int current_render_target_count; bool resized; } windows[1] = {0}; typedef struct render_state { - iron_g5_pipeline_t *pipeline; - iron_g5_compute_shader *compute_shader; + iron_gpu_pipeline_t *pipeline; + iron_gpu_compute_shader *compute_shader; - iron_g5_index_buffer_t *index_buffer; - iron_g5_vertex_buffer_t *vertex_buffer; + iron_gpu_index_buffer_t *index_buffer; + iron_gpu_vertex_buffer_t *vertex_buffer; bool viewport_set; int viewport_x; @@ -61,12 +61,12 @@ typedef struct render_state { int scissor_width; int scissor_height; - iron_g5_texture_t *textures[MAX_TEXTURES]; - iron_g5_texture_unit_t texture_units[MAX_TEXTURES]; + iron_gpu_texture_t *textures[MAX_TEXTURES]; + iron_gpu_texture_unit_t texture_units[MAX_TEXTURES]; int texture_count; - iron_g5_texture_t *depth_render_targets[MAX_TEXTURES]; - iron_g5_texture_unit_t depth_render_target_units[MAX_TEXTURES]; + iron_gpu_texture_t *depth_render_targets[MAX_TEXTURES]; + iron_gpu_texture_unit_t depth_render_target_units[MAX_TEXTURES]; int depth_render_target_count; uint8_t vertex_constant_data[CONSTANT_BUFFER_SIZE]; @@ -76,8 +76,8 @@ typedef struct render_state { static render_state current_state; -bool iron_g5_texture_unit_equals(iron_g5_texture_unit_t *unit1, iron_g5_texture_unit_t *unit2) { - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { +bool iron_gpu_texture_unit_equals(iron_gpu_texture_unit_t *unit1, iron_gpu_texture_unit_t *unit2) { + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { if (unit1->stages[i] != unit2->stages[i]) { return false; } @@ -85,45 +85,45 @@ bool iron_g5_texture_unit_equals(iron_g5_texture_unit_t *unit1, iron_g5_texture_ return true; } -void iron_g5_internal_resize(int width, int height) { +void iron_gpu_internal_resize(int width, int height) { windows[0].resized = true; } -void iron_g5_internal_restore_render_target(void) { +void iron_gpu_internal_restore_render_target(void) { windows[0].current_render_targets[0] = NULL; - iron_g5_texture_t *render_target = &windows[0].framebuffers[windows[0].currentBuffer]; - iron_g5_command_list_set_render_targets(&commandList, &render_target, 1); + iron_gpu_texture_t *render_target = &windows[0].framebuffers[windows[0].currentBuffer]; + iron_gpu_command_list_set_render_targets(&commandList, &render_target, 1); windows[0].current_render_target_count = 1; } -void iron_g4_internal_init_window(int depthBufferBits, bool vsync) { - iron_g5_internal_init_window(depthBufferBits, vsync); +void gpu_internal_init_window(int depthBufferBits, bool vsync) { + iron_gpu_internal_init_window(depthBufferBits, vsync); - iron_g5_command_list_init(&commandList); + iron_gpu_command_list_init(&commandList); windows[0].currentBuffer = -1; for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { - iron_g5_render_target_init_framebuffer(&windows[0].framebuffers[i], iron_window_width(), iron_window_height(), + iron_gpu_render_target_init_framebuffer(&windows[0].framebuffers[i], iron_window_width(), iron_window_height(), IRON_IMAGE_FORMAT_RGBA32, depthBufferBits); } - iron_g5_constant_buffer_init(&vertexConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); - iron_g5_constant_buffer_init(&fragmentConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); - iron_g5_constant_buffer_init(&computeConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); + iron_gpu_constant_buffer_init(&vertexConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); + iron_gpu_constant_buffer_init(&fragmentConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); + iron_gpu_constant_buffer_init(&computeConstantBuffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLY); - // to support doing work after iron_g4_end and before iron_g4_begin - iron_g5_command_list_begin(&commandList); + // to support doing work after gpu_end and before gpu_begin + iron_gpu_command_list_begin(&commandList); } -void iron_g5_internal_set_samplers(int count, iron_g5_texture_unit_t *texture_units) { +void iron_gpu_internal_set_samplers(int count, iron_gpu_texture_unit_t *texture_units) { for (int i = 0; i < count; ++i) { - for (int j = 0; j < IRON_G5_SHADER_TYPE_COUNT; ++j) { + for (int j = 0; j < IRON_GPU_SHADER_TYPE_COUNT; ++j) { if (texture_units[i].stages[j] >= 0) { - iron_g5_sampler_t *sampler = iron_internal_get_current_sampler(j, texture_units[i].stages[j]); - iron_g5_texture_unit_t unit; - for (int k = 0; k < IRON_G5_SHADER_TYPE_COUNT; ++k) { + iron_gpu_sampler_t *sampler = iron_internal_get_current_sampler(j, texture_units[i].stages[j]); + iron_gpu_texture_unit_t unit; + for (int k = 0; k < IRON_GPU_SHADER_TYPE_COUNT; ++k) { unit.stages[k] = -1; } unit.stages[j] = texture_units[i].stages[j]; - iron_g5_command_list_set_sampler(&commandList, unit, sampler); + iron_gpu_command_list_set_sampler(&commandList, unit, sampler); } } } @@ -135,133 +135,133 @@ static void iron_internal_start_draw(bool compute) { memcpy(current_state.fragment_constant_data, fragmentConstantBuffer.data, CONSTANT_BUFFER_SIZE); memcpy(current_state.compute_constant_data, computeConstantBuffer.data, CONSTANT_BUFFER_SIZE); } - iron_g5_constant_buffer_unlock(&vertexConstantBuffer); - iron_g5_constant_buffer_unlock(&fragmentConstantBuffer); - iron_g5_constant_buffer_unlock(&computeConstantBuffer); + iron_gpu_constant_buffer_unlock(&vertexConstantBuffer); + iron_gpu_constant_buffer_unlock(&fragmentConstantBuffer); + iron_gpu_constant_buffer_unlock(&computeConstantBuffer); - iron_g5_internal_set_samplers(current_state.texture_count, current_state.texture_units); - iron_g5_internal_set_samplers(current_state.depth_render_target_count, current_state.depth_render_target_units); + iron_gpu_internal_set_samplers(current_state.texture_count, current_state.texture_units); + iron_gpu_internal_set_samplers(current_state.depth_render_target_count, current_state.depth_render_target_units); if (compute) { - iron_g5_command_list_set_compute_constant_buffer(&commandList, &computeConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_gpu_command_list_set_compute_constant_buffer(&commandList, &computeConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); } else { - iron_g5_command_list_set_vertex_constant_buffer(&commandList, &vertexConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); - iron_g5_command_list_set_fragment_constant_buffer(&commandList, &fragmentConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_gpu_command_list_set_vertex_constant_buffer(&commandList, &vertexConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_gpu_command_list_set_fragment_constant_buffer(&commandList, &fragmentConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); } } static void iron_internal_end_draw(bool compute) { ++constantBufferIndex; if (constantBufferIndex >= CONSTANT_BUFFER_MULTIPLY || waitAfterNextDraw) { - iron_g5_command_list_end(&commandList); - iron_g5_command_list_execute(&commandList); - iron_g5_command_list_wait_for_execution_to_finish(&commandList); - iron_g5_command_list_begin(&commandList); + iron_gpu_command_list_end(&commandList); + iron_gpu_command_list_execute(&commandList); + iron_gpu_command_list_wait_for_execution_to_finish(&commandList); + iron_gpu_command_list_begin(&commandList); if (windows[0].current_render_targets[0] == NULL) { - iron_g5_internal_restore_render_target(); + iron_gpu_internal_restore_render_target(); } else { const int count = windows[0].current_render_target_count; - iron_g5_texture_t *render_targets[16]; + iron_gpu_texture_t *render_targets[16]; for (int i = 0; i < count; ++i) { render_targets[i] = windows[0].current_render_targets[i]; } - iron_g5_command_list_set_render_targets(&commandList, render_targets, count); + iron_gpu_command_list_set_render_targets(&commandList, render_targets, count); } if (current_state.pipeline != NULL) { - iron_g5_command_list_set_pipeline(&commandList, current_state.pipeline); + iron_gpu_command_list_set_pipeline(&commandList, current_state.pipeline); } if (current_state.compute_shader != NULL) { - iron_g5_command_list_set_compute_shader(&commandList, current_state.compute_shader); + iron_gpu_command_list_set_compute_shader(&commandList, current_state.compute_shader); } if (current_state.index_buffer != NULL) { - iron_g5_command_list_set_index_buffer(&commandList, current_state.index_buffer); + iron_gpu_command_list_set_index_buffer(&commandList, current_state.index_buffer); } if (current_state.vertex_buffer != NULL) { - iron_g5_command_list_set_vertex_buffer(&commandList, current_state.vertex_buffer); + iron_gpu_command_list_set_vertex_buffer(&commandList, current_state.vertex_buffer); } if (current_state.viewport_set) { - iron_g5_command_list_viewport(&commandList, current_state.viewport_x, current_state.viewport_y, current_state.viewport_width, + iron_gpu_command_list_viewport(&commandList, current_state.viewport_x, current_state.viewport_y, current_state.viewport_width, current_state.viewport_height); } if (current_state.scissor_set) { - iron_g5_command_list_scissor(&commandList, current_state.scissor_x, current_state.scissor_y, current_state.scissor_width, + iron_gpu_command_list_scissor(&commandList, current_state.scissor_x, current_state.scissor_y, current_state.scissor_width, current_state.scissor_height); } for (int i = 0; i < current_state.texture_count; ++i) { - iron_g5_command_list_set_texture(&commandList, current_state.texture_units[i], current_state.textures[i]); + iron_gpu_command_list_set_texture(&commandList, current_state.texture_units[i], current_state.textures[i]); } for (int i = 0; i < current_state.depth_render_target_count; ++i) { - iron_g5_command_list_set_texture_from_render_target_depth(&commandList, current_state.depth_render_target_units[i], + iron_gpu_command_list_set_texture_from_render_target_depth(&commandList, current_state.depth_render_target_units[i], current_state.depth_render_targets[i]); } constantBufferIndex = 0; waitAfterNextDraw = false; - iron_g5_constant_buffer_lock(&vertexConstantBuffer, 0, CONSTANT_BUFFER_SIZE); - iron_g5_constant_buffer_lock(&fragmentConstantBuffer, 0, CONSTANT_BUFFER_SIZE); - iron_g5_constant_buffer_lock(&computeConstantBuffer, 0, CONSTANT_BUFFER_SIZE); + iron_gpu_constant_buffer_lock(&vertexConstantBuffer, 0, CONSTANT_BUFFER_SIZE); + iron_gpu_constant_buffer_lock(&fragmentConstantBuffer, 0, CONSTANT_BUFFER_SIZE); + iron_gpu_constant_buffer_lock(&computeConstantBuffer, 0, CONSTANT_BUFFER_SIZE); memcpy(vertexConstantBuffer.data, current_state.vertex_constant_data, CONSTANT_BUFFER_SIZE); memcpy(fragmentConstantBuffer.data, current_state.fragment_constant_data, CONSTANT_BUFFER_SIZE); memcpy(computeConstantBuffer.data, current_state.compute_constant_data, CONSTANT_BUFFER_SIZE); } else { - iron_g5_constant_buffer_lock(&vertexConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); - iron_g5_constant_buffer_lock(&fragmentConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); - iron_g5_constant_buffer_lock(&computeConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_gpu_constant_buffer_lock(&vertexConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_gpu_constant_buffer_lock(&fragmentConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + iron_gpu_constant_buffer_lock(&computeConstantBuffer, constantBufferIndex * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); } } -void iron_g5_draw_indexed_vertices(void) { +void iron_gpu_draw_indexed_vertices(void) { iron_internal_start_draw(false); - iron_g5_command_list_draw_indexed_vertices(&commandList); + iron_gpu_command_list_draw_indexed_vertices(&commandList); iron_internal_end_draw(false); } -void iron_g5_draw_indexed_vertices_from_to(int start, int count) { +void iron_gpu_draw_indexed_vertices_from_to(int start, int count) { iron_internal_start_draw(false); - iron_g5_command_list_draw_indexed_vertices_from_to(&commandList, start, count); + iron_gpu_command_list_draw_indexed_vertices_from_to(&commandList, start, count); iron_internal_end_draw(false); } -void iron_g5_clear(unsigned color, float depth, unsigned flags) { +void iron_gpu_clear(unsigned color, float depth, unsigned flags) { if (windows[0].current_render_target_count > 0) { if (windows[0].current_render_targets[0] == NULL) { - iron_g5_command_list_clear(&commandList, &windows[0].framebuffers[windows[0].currentBuffer], flags, color, depth); + iron_gpu_command_list_clear(&commandList, &windows[0].framebuffers[windows[0].currentBuffer], flags, color, depth); } else { if (windows[0].current_render_targets[0]->state != IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET) { - iron_g5_command_list_texture_to_render_target_barrier(&commandList, windows[0].current_render_targets[0]); + iron_gpu_command_list_texture_to_render_target_barrier(&commandList, windows[0].current_render_targets[0]); windows[0].current_render_targets[0]->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; } - iron_g5_command_list_clear(&commandList, windows[0].current_render_targets[0], flags, color, depth); + iron_gpu_command_list_clear(&commandList, windows[0].current_render_targets[0], flags, color, depth); } } } -void iron_g4_begin() { - // to support doing work after iron_g4_end and before iron_g4_begin - iron_g5_command_list_end(&commandList); - iron_g5_command_list_execute(&commandList); +void gpu_begin() { + // to support doing work after gpu_end and before gpu_begin + iron_gpu_command_list_end(&commandList); + iron_gpu_command_list_execute(&commandList); windows[0].currentBuffer = (windows[0].currentBuffer + 1) % FRAMEBUFFER_COUNT; bool resized = windows[0].resized; if (resized) { for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { - iron_g5_texture_destroy(&windows[0].framebuffers[i]); + iron_gpu_texture_destroy(&windows[0].framebuffers[i]); } windows[0].currentBuffer = 0; } - iron_g5_begin(&windows[0].framebuffers[windows[0].currentBuffer]); + iron_gpu_begin(&windows[0].framebuffers[windows[0].currentBuffer]); if (resized) { for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { - iron_g5_render_target_init_framebuffer(&windows[0].framebuffers[i], iron_window_width(), iron_window_height(), + iron_gpu_render_target_init_framebuffer(&windows[0].framebuffers[i], iron_window_width(), iron_window_height(), IRON_IMAGE_FORMAT_RGBA32, 16); } windows[0].resized = false; @@ -281,266 +281,266 @@ void iron_g4_begin() { iron_internal_samplers_reset(); - iron_g5_command_list_begin(&commandList); + iron_gpu_command_list_begin(&commandList); // Currently we do not necessarily wait at the end of a frame so for now it's iron_internal_end_draw iron_internal_end_draw(false); - iron_g5_command_list_framebuffer_to_render_target_barrier(&commandList, &windows[0].framebuffers[windows[0].currentBuffer]); - iron_g4_restore_render_target(); + iron_gpu_command_list_framebuffer_to_render_target_barrier(&commandList, &windows[0].framebuffers[windows[0].currentBuffer]); + gpu_restore_render_target(); } -void iron_g4_viewport(int x, int y, int width, int height) { +void gpu_viewport(int x, int y, int width, int height) { current_state.viewport_x = x; current_state.viewport_y = y; current_state.viewport_width = width; current_state.viewport_height = height; current_state.viewport_set = true; - iron_g5_command_list_viewport(&commandList, x, y, width, height); + iron_gpu_command_list_viewport(&commandList, x, y, width, height); } -void iron_g4_scissor(int x, int y, int width, int height) { +void gpu_scissor(int x, int y, int width, int height) { current_state.scissor_x = x; current_state.scissor_y = y; current_state.scissor_width = width; current_state.scissor_height = height; current_state.scissor_set = true; - iron_g5_command_list_scissor(&commandList, x, y, width, height); + iron_gpu_command_list_scissor(&commandList, x, y, width, height); } -void iron_g4_disable_scissor(void) { +void gpu_disable_scissor(void) { current_state.scissor_set = false; - iron_g5_command_list_disable_scissor(&commandList); + iron_gpu_command_list_disable_scissor(&commandList); } -void iron_g4_end() { - iron_g5_constant_buffer_unlock(&vertexConstantBuffer); - iron_g5_constant_buffer_unlock(&fragmentConstantBuffer); - iron_g5_constant_buffer_unlock(&computeConstantBuffer); +void gpu_end() { + iron_gpu_constant_buffer_unlock(&vertexConstantBuffer); + iron_gpu_constant_buffer_unlock(&fragmentConstantBuffer); + iron_gpu_constant_buffer_unlock(&computeConstantBuffer); - iron_g5_command_list_render_target_to_framebuffer_barrier(&commandList, &windows[0].framebuffers[windows[0].currentBuffer]); - iron_g5_command_list_end(&commandList); - iron_g5_command_list_execute(&commandList); + iron_gpu_command_list_render_target_to_framebuffer_barrier(&commandList, &windows[0].framebuffers[windows[0].currentBuffer]); + iron_gpu_command_list_end(&commandList); + iron_gpu_command_list_execute(&commandList); - iron_g5_end(); + iron_gpu_end(); - // to support doing work after iron_g4_end and before iron_g4_begin - iron_g5_command_list_begin(&commandList); + // to support doing work after gpu_end and before gpu_begin + iron_gpu_command_list_begin(&commandList); } -void iron_g4_set_int(iron_g5_constant_location_t location, int value) { +void gpu_set_int(iron_gpu_constant_location_t location, int value) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_int(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_gpu_constant_buffer_set_int(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_int(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_gpu_constant_buffer_set_int(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_int(&computeConstantBuffer, location.impl.computeOffset, value); + iron_gpu_constant_buffer_set_int(&computeConstantBuffer, location.impl.computeOffset, value); } -void iron_g4_set_int2(iron_g5_constant_location_t location, int value1, int value2) { +void gpu_set_int2(iron_gpu_constant_location_t location, int value1, int value2) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_int2(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2); + iron_gpu_constant_buffer_set_int2(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_int2(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2); + iron_gpu_constant_buffer_set_int2(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_int2(&computeConstantBuffer, location.impl.computeOffset, value1, value2); + iron_gpu_constant_buffer_set_int2(&computeConstantBuffer, location.impl.computeOffset, value1, value2); } -void iron_g4_set_int3(iron_g5_constant_location_t location, int value1, int value2, int value3) { +void gpu_set_int3(iron_gpu_constant_location_t location, int value1, int value2, int value3) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_int3(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3); + iron_gpu_constant_buffer_set_int3(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_int3(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3); + iron_gpu_constant_buffer_set_int3(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_int3(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3); + iron_gpu_constant_buffer_set_int3(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3); } -void iron_g4_set_int4(iron_g5_constant_location_t location, int value1, int value2, int value3, int value4) { +void gpu_set_int4(iron_gpu_constant_location_t location, int value1, int value2, int value3, int value4) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_int4(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3, value4); + iron_gpu_constant_buffer_set_int4(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3, value4); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_int4(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3, value4); + iron_gpu_constant_buffer_set_int4(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3, value4); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_int4(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3, value4); + iron_gpu_constant_buffer_set_int4(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3, value4); } -void iron_g4_set_ints(iron_g5_constant_location_t location, int *values, int count) { +void gpu_set_ints(iron_gpu_constant_location_t location, int *values, int count) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_ints(&vertexConstantBuffer, location.impl.vertexOffset, values, count); + iron_gpu_constant_buffer_set_ints(&vertexConstantBuffer, location.impl.vertexOffset, values, count); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_ints(&fragmentConstantBuffer, location.impl.fragmentOffset, values, count); + iron_gpu_constant_buffer_set_ints(&fragmentConstantBuffer, location.impl.fragmentOffset, values, count); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_ints(&computeConstantBuffer, location.impl.computeOffset, values, count); + iron_gpu_constant_buffer_set_ints(&computeConstantBuffer, location.impl.computeOffset, values, count); } -void iron_g4_set_float(iron_g5_constant_location_t location, float value) { +void gpu_set_float(iron_gpu_constant_location_t location, float value) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_float(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_gpu_constant_buffer_set_float(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_float(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_gpu_constant_buffer_set_float(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_float(&computeConstantBuffer, location.impl.computeOffset, value); + iron_gpu_constant_buffer_set_float(&computeConstantBuffer, location.impl.computeOffset, value); } -void iron_g4_set_float2(iron_g5_constant_location_t location, float value1, float value2) { +void gpu_set_float2(iron_gpu_constant_location_t location, float value1, float value2) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_float2(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2); + iron_gpu_constant_buffer_set_float2(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_float2(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2); + iron_gpu_constant_buffer_set_float2(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_float2(&computeConstantBuffer, location.impl.computeOffset, value1, value2); + iron_gpu_constant_buffer_set_float2(&computeConstantBuffer, location.impl.computeOffset, value1, value2); } -void iron_g4_set_float3(iron_g5_constant_location_t location, float value1, float value2, float value3) { +void gpu_set_float3(iron_gpu_constant_location_t location, float value1, float value2, float value3) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_float3(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3); + iron_gpu_constant_buffer_set_float3(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_float3(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3); + iron_gpu_constant_buffer_set_float3(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_float3(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3); + iron_gpu_constant_buffer_set_float3(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3); } -void iron_g4_set_float4(iron_g5_constant_location_t location, float value1, float value2, float value3, float value4) { +void gpu_set_float4(iron_gpu_constant_location_t location, float value1, float value2, float value3, float value4) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_float4(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3, value4); + iron_gpu_constant_buffer_set_float4(&vertexConstantBuffer, location.impl.vertexOffset, value1, value2, value3, value4); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_float4(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3, value4); + iron_gpu_constant_buffer_set_float4(&fragmentConstantBuffer, location.impl.fragmentOffset, value1, value2, value3, value4); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_float4(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3, value4); + iron_gpu_constant_buffer_set_float4(&computeConstantBuffer, location.impl.computeOffset, value1, value2, value3, value4); } -void iron_g4_set_floats(iron_g5_constant_location_t location, float *values, int count) { +void gpu_set_floats(iron_gpu_constant_location_t location, float *values, int count) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_floats(&vertexConstantBuffer, location.impl.vertexOffset, values, count); + iron_gpu_constant_buffer_set_floats(&vertexConstantBuffer, location.impl.vertexOffset, values, count); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_floats(&fragmentConstantBuffer, location.impl.fragmentOffset, values, count); + iron_gpu_constant_buffer_set_floats(&fragmentConstantBuffer, location.impl.fragmentOffset, values, count); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_floats(&computeConstantBuffer, location.impl.computeOffset, values, count); + iron_gpu_constant_buffer_set_floats(&computeConstantBuffer, location.impl.computeOffset, values, count); } -void iron_g4_set_bool(iron_g5_constant_location_t location, bool value) { +void gpu_set_bool(iron_gpu_constant_location_t location, bool value) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_bool(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_gpu_constant_buffer_set_bool(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_bool(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_gpu_constant_buffer_set_bool(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_bool(&computeConstantBuffer, location.impl.computeOffset, value); + iron_gpu_constant_buffer_set_bool(&computeConstantBuffer, location.impl.computeOffset, value); } -void iron_g4_set_matrix4(iron_g5_constant_location_t location, iron_matrix4x4_t *value) { +void gpu_set_matrix4(iron_gpu_constant_location_t location, iron_matrix4x4_t *value) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_matrix4(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_gpu_constant_buffer_set_matrix4(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_matrix4(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_gpu_constant_buffer_set_matrix4(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_matrix4(&computeConstantBuffer, location.impl.computeOffset, value); + iron_gpu_constant_buffer_set_matrix4(&computeConstantBuffer, location.impl.computeOffset, value); } -void iron_g4_set_matrix3(iron_g5_constant_location_t location, iron_matrix3x3_t *value) { +void gpu_set_matrix3(iron_gpu_constant_location_t location, iron_matrix3x3_t *value) { if (location.impl.vertexOffset >= 0) - iron_g5_constant_buffer_set_matrix3(&vertexConstantBuffer, location.impl.vertexOffset, value); + iron_gpu_constant_buffer_set_matrix3(&vertexConstantBuffer, location.impl.vertexOffset, value); if (location.impl.fragmentOffset >= 0) - iron_g5_constant_buffer_set_matrix3(&fragmentConstantBuffer, location.impl.fragmentOffset, value); + iron_gpu_constant_buffer_set_matrix3(&fragmentConstantBuffer, location.impl.fragmentOffset, value); if (location.impl.computeOffset >= 0) - iron_g5_constant_buffer_set_matrix3(&computeConstantBuffer, location.impl.computeOffset, value); + iron_gpu_constant_buffer_set_matrix3(&computeConstantBuffer, location.impl.computeOffset, value); } -void iron_g4_set_texture_addressing(iron_g5_texture_unit_t unit, iron_g4_texture_direction_t dir, iron_g4_texture_addressing_t addressing) { - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { +void gpu_set_texture_addressing(iron_gpu_texture_unit_t unit, gpu_texture_direction_t dir, gpu_texture_addressing_t addressing) { + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { if (unit.stages[i] >= 0) { - if (dir == IRON_G4_TEXTURE_DIRECTION_U) { - sampler_options[i][unit.stages[i]].u_addressing = (iron_g5_texture_addressing_t)addressing; + if (dir == GPU_TEXTURE_DIRECTION_U) { + sampler_options[i][unit.stages[i]].u_addressing = (iron_gpu_texture_addressing_t)addressing; } - if (dir == IRON_G4_TEXTURE_DIRECTION_V) { - sampler_options[i][unit.stages[i]].v_addressing = (iron_g5_texture_addressing_t)addressing; + if (dir == GPU_TEXTURE_DIRECTION_V) { + sampler_options[i][unit.stages[i]].v_addressing = (iron_gpu_texture_addressing_t)addressing; } } } } -void iron_g4_set_texture_magnification_filter(iron_g5_texture_unit_t texunit, iron_g4_texture_filter_t filter) { - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { +void gpu_set_texture_magnification_filter(iron_gpu_texture_unit_t texunit, gpu_texture_filter_t filter) { + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { if (texunit.stages[i] >= 0) { - sampler_options[i][texunit.stages[i]].magnification_filter = (iron_g5_texture_filter_t)filter; + sampler_options[i][texunit.stages[i]].magnification_filter = (iron_gpu_texture_filter_t)filter; } } } -void iron_g4_set_texture_minification_filter(iron_g5_texture_unit_t texunit, iron_g4_texture_filter_t filter) { - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { +void gpu_set_texture_minification_filter(iron_gpu_texture_unit_t texunit, gpu_texture_filter_t filter) { + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { if (texunit.stages[i] >= 0) { - sampler_options[i][texunit.stages[i]].minification_filter = (iron_g5_texture_filter_t)filter; + sampler_options[i][texunit.stages[i]].minification_filter = (iron_gpu_texture_filter_t)filter; } } } -void iron_g4_set_texture_mipmap_filter(iron_g5_texture_unit_t texunit, iron_g4_mipmap_filter_t filter) { - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { +void gpu_set_texture_mipmap_filter(iron_gpu_texture_unit_t texunit, gpu_mipmap_filter_t filter) { + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { if (texunit.stages[i] >= 0) { - sampler_options[i][texunit.stages[i]].mipmap_filter = (iron_g5_mipmap_filter_t)filter; + sampler_options[i][texunit.stages[i]].mipmap_filter = (iron_gpu_mipmap_filter_t)filter; } } } -void iron_g4_restore_render_target(void) { - iron_g5_internal_restore_render_target(); +void gpu_restore_render_target(void) { + iron_gpu_internal_restore_render_target(); current_state.viewport_set = false; current_state.scissor_set = false; } -void iron_g4_set_render_targets(iron_g5_texture_t **targets, int count) { +void gpu_set_render_targets(iron_gpu_texture_t **targets, int count) { for (int i = 0; i < count; ++i) { windows[0].current_render_targets[i] = targets[i]; if (windows[0].current_render_targets[i]->state != IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET) { - iron_g5_command_list_texture_to_render_target_barrier(&commandList, windows[0].current_render_targets[i]); + iron_gpu_command_list_texture_to_render_target_barrier(&commandList, windows[0].current_render_targets[i]); windows[0].current_render_targets[i]->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; } } windows[0].current_render_target_count = count; - iron_g5_texture_t *render_targets[16]; + iron_gpu_texture_t *render_targets[16]; for (int i = 0; i < count; ++i) { render_targets[i] = targets[i]; } - iron_g5_command_list_set_render_targets(&commandList, render_targets, count); + iron_gpu_command_list_set_render_targets(&commandList, render_targets, count); current_state.viewport_set = false; current_state.scissor_set = false; } -void iron_g4_set_vertex_buffer(iron_g4_vertex_buffer_t *buffer) { - iron_g5_vertex_buffer_t *g5_vertex_buffer = &buffer->impl._buffer[buffer->impl._currentIndex]; - current_state.vertex_buffer = g5_vertex_buffer; - iron_g5_command_list_set_vertex_buffer(&commandList, g5_vertex_buffer); +void gpu_set_vertex_buffer(gpu_vertex_buffer_t *buffer) { + iron_gpu_vertex_buffer_t *vb = &buffer->impl._buffer[buffer->impl._currentIndex]; + current_state.vertex_buffer = vb; + iron_gpu_command_list_set_vertex_buffer(&commandList, vb); } -void iron_g4_set_index_buffer(iron_g5_index_buffer_t *buffer) { +void gpu_set_index_buffer(iron_gpu_index_buffer_t *buffer) { current_state.index_buffer = buffer; - iron_g5_command_list_set_index_buffer(&commandList, buffer); + iron_gpu_command_list_set_index_buffer(&commandList, buffer); } -void iron_g5_set_pipeline(iron_g5_pipeline_t *pipeline) { +void iron_gpu_set_pipeline(iron_gpu_pipeline_t *pipeline) { current_state.pipeline = pipeline; - iron_g5_command_list_set_pipeline(&commandList, pipeline); + iron_gpu_command_list_set_pipeline(&commandList, pipeline); } -void iron_g4_set_texture(iron_g5_texture_unit_t unit, iron_g5_texture_t *render_target) { +void gpu_set_texture(iron_gpu_texture_unit_t unit, iron_gpu_texture_t *render_target) { if (!render_target->_uploaded) { - iron_g5_command_list_upload_texture(&commandList, render_target); + iron_gpu_command_list_upload_texture(&commandList, render_target); render_target->_uploaded = true; } if (render_target->state != IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE) { - iron_g5_command_list_render_target_to_texture_barrier(&commandList, render_target); + iron_gpu_command_list_render_target_to_texture_barrier(&commandList, render_target); render_target->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; } - iron_g5_texture_unit_t g5_unit; - memcpy(&g5_unit.stages[0], &unit.stages[0], IRON_G5_SHADER_TYPE_COUNT * sizeof(int)); + iron_gpu_texture_unit_t g5_unit; + memcpy(&g5_unit.stages[0], &unit.stages[0], IRON_GPU_SHADER_TYPE_COUNT * sizeof(int)); bool found = false; for (int i = 0; i < current_state.texture_count; ++i) { - if (iron_g5_texture_unit_equals(¤t_state.texture_units[i], &g5_unit)) { + if (iron_gpu_texture_unit_equals(¤t_state.texture_units[i], &g5_unit)) { current_state.textures[i] = render_target; current_state.texture_units[i] = g5_unit; found = true; @@ -553,21 +553,21 @@ void iron_g4_set_texture(iron_g5_texture_unit_t unit, iron_g5_texture_t *render_ current_state.texture_count += 1; } - iron_g5_command_list_set_texture(&commandList, g5_unit, render_target); + iron_gpu_command_list_set_texture(&commandList, g5_unit, render_target); } -void iron_g4_render_target_use_depth_as_texture(iron_g5_texture_t *render_target, iron_g5_texture_unit_t unit) { +void gpu_render_target_use_depth_as_texture(iron_gpu_texture_t *render_target, iron_gpu_texture_unit_t unit) { if (render_target->state != IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE) { - iron_g5_command_list_render_target_to_texture_barrier(&commandList, render_target); + iron_gpu_command_list_render_target_to_texture_barrier(&commandList, render_target); render_target->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; } - iron_g5_texture_unit_t g5_unit; - memcpy(&g5_unit.stages[0], &unit.stages[0], IRON_G5_SHADER_TYPE_COUNT * sizeof(int)); + iron_gpu_texture_unit_t g5_unit; + memcpy(&g5_unit.stages[0], &unit.stages[0], IRON_GPU_SHADER_TYPE_COUNT * sizeof(int)); bool found = false; for (int i = 0; i < current_state.depth_render_target_count; ++i) { - if (iron_g5_texture_unit_equals(¤t_state.depth_render_target_units[i], &g5_unit)) { + if (iron_gpu_texture_unit_equals(¤t_state.depth_render_target_units[i], &g5_unit)) { current_state.depth_render_targets[i] = render_target; current_state.depth_render_target_units[i] = g5_unit; found = true; @@ -581,60 +581,60 @@ void iron_g4_render_target_use_depth_as_texture(iron_g5_texture_t *render_target current_state.depth_render_target_count += 1; } - iron_g5_command_list_set_texture_from_render_target_depth(&commandList, g5_unit, render_target); + iron_gpu_command_list_set_texture_from_render_target_depth(&commandList, g5_unit, render_target); } -void iron_g5_set_compute_shader(iron_g5_compute_shader *shader) { +void iron_gpu_set_compute_shader(iron_gpu_compute_shader *shader) { current_state.compute_shader = shader; - iron_g5_command_list_set_compute_shader(&commandList, shader); + iron_gpu_command_list_set_compute_shader(&commandList, shader); } -void iron_g4_compute(int x, int y, int z) { +void gpu_compute(int x, int y, int z) { iron_internal_start_draw(true); - iron_g5_command_list_compute(&commandList, x, y, z); + iron_gpu_command_list_compute(&commandList, x, y, z); iron_internal_end_draw(true); } -void iron_g5_render_target_get_pixels(iron_g5_texture_t *render_target, uint8_t *data) { - iron_g5_command_list_get_render_target_pixels(&commandList, render_target, data); +void iron_gpu_render_target_get_pixels(iron_gpu_texture_t *render_target, uint8_t *data) { + iron_gpu_command_list_get_render_target_pixels(&commandList, render_target, data); } -void iron_g4_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer) { - iron_g5_index_buffer_unlock_all(buffer); - iron_g5_command_list_upload_index_buffer(&commandList, buffer); +void gpu_index_buffer_unlock_all(iron_gpu_index_buffer_t *buffer) { + iron_gpu_index_buffer_unlock_all(buffer); + iron_gpu_command_list_upload_index_buffer(&commandList, buffer); } -void iron_g4_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count) { - iron_g5_index_buffer_unlock(buffer, count); - iron_g5_command_list_upload_index_buffer(&commandList, buffer); +void gpu_index_buffer_unlock(iron_gpu_index_buffer_t *buffer, int count) { + iron_gpu_index_buffer_unlock(buffer, count); + iron_gpu_command_list_upload_index_buffer(&commandList, buffer); } -void iron_g5_vertex_structure_init(iron_g5_vertex_structure_t *structure) { +void iron_gpu_vertex_structure_init(iron_gpu_vertex_structure_t *structure) { structure->size = 0; } -void iron_g5_vertex_structure_add(iron_g5_vertex_structure_t *structure, const char *name, iron_g5_vertex_data_t data) { +void iron_gpu_vertex_structure_add(iron_gpu_vertex_structure_t *structure, const char *name, iron_gpu_vertex_data_t data) { structure->elements[structure->size].name = name; structure->elements[structure->size].data = data; structure->size++; } -void iron_g4_vertex_buffer_init(iron_g4_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, iron_g4_usage_t usage) { - buffer->impl._multiple = usage == IRON_G4_USAGE_STATIC ? 1 : 2; +void gpu_vertex_buffer_init(gpu_vertex_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, gpu_usage_t usage) { + buffer->impl._multiple = usage == GPU_USAGE_STATIC ? 1 : 2; buffer->impl._currentIndex = 0; buffer->impl.myCount = count; for (int i = 0; i < buffer->impl._multiple; ++i) { - iron_g5_vertex_buffer_init(&buffer->impl._buffer[i], count, structure, usage == IRON_G4_USAGE_STATIC); + iron_gpu_vertex_buffer_init(&buffer->impl._buffer[i], count, structure, usage == GPU_USAGE_STATIC); } } -void iron_g4_vertex_buffer_destroy(iron_g4_vertex_buffer_t *buffer) { +void gpu_vertex_buffer_destroy(gpu_vertex_buffer_t *buffer) { for (int i = 0; i < buffer->impl._multiple; ++i) { - iron_g5_vertex_buffer_destroy(&buffer->impl._buffer[i]); + iron_gpu_vertex_buffer_destroy(&buffer->impl._buffer[i]); } } -static void iron_internal_prepare_lock(iron_g4_vertex_buffer_t *buffer) { +static void iron_internal_prepare_lock(gpu_vertex_buffer_t *buffer) { ++buffer->impl._currentIndex; if (buffer->impl._currentIndex >= buffer->impl._multiple - 1) { waitAfterNextDraw = true; @@ -644,51 +644,51 @@ static void iron_internal_prepare_lock(iron_g4_vertex_buffer_t *buffer) { } } -float *iron_g4_vertex_buffer_lock_all(iron_g4_vertex_buffer_t *buffer) { +float *gpu_vertex_buffer_lock_all(gpu_vertex_buffer_t *buffer) { iron_internal_prepare_lock(buffer); - return iron_g5_vertex_buffer_lock_all(&buffer->impl._buffer[buffer->impl._currentIndex]); + return iron_gpu_vertex_buffer_lock_all(&buffer->impl._buffer[buffer->impl._currentIndex]); } -float *iron_g4_vertex_buffer_lock(iron_g4_vertex_buffer_t *buffer, int start, int count) { +float *gpu_vertex_buffer_lock(gpu_vertex_buffer_t *buffer, int start, int count) { iron_internal_prepare_lock(buffer); - return iron_g5_vertex_buffer_lock(&buffer->impl._buffer[buffer->impl._currentIndex], start, count); + return iron_gpu_vertex_buffer_lock(&buffer->impl._buffer[buffer->impl._currentIndex], start, count); } -void iron_g4_vertex_buffer_unlock_all(iron_g4_vertex_buffer_t *buffer) { - iron_g5_vertex_buffer_unlock_all(&buffer->impl._buffer[buffer->impl._currentIndex]); +void gpu_vertex_buffer_unlock_all(gpu_vertex_buffer_t *buffer) { + iron_gpu_vertex_buffer_unlock_all(&buffer->impl._buffer[buffer->impl._currentIndex]); } -void iron_g4_vertex_buffer_unlock(iron_g4_vertex_buffer_t *buffer, int count) { - iron_g5_vertex_buffer_unlock(&buffer->impl._buffer[buffer->impl._currentIndex], count); +void gpu_vertex_buffer_unlock(gpu_vertex_buffer_t *buffer, int count) { + iron_gpu_vertex_buffer_unlock(&buffer->impl._buffer[buffer->impl._currentIndex], count); } -int iron_g4_vertex_buffer_count(iron_g4_vertex_buffer_t *buffer) { +int gpu_vertex_buffer_count(gpu_vertex_buffer_t *buffer) { return buffer->impl.myCount; } -int iron_g4_vertex_buffer_stride(iron_g4_vertex_buffer_t *buffer) { - return iron_g5_vertex_buffer_stride(&buffer->impl._buffer[buffer->impl._currentIndex]); +int gpu_vertex_buffer_stride(gpu_vertex_buffer_t *buffer) { + return iron_gpu_vertex_buffer_stride(&buffer->impl._buffer[buffer->impl._currentIndex]); } -void iron_g5_constant_buffer_set_int(iron_g5_constant_buffer_t *buffer, int offset, int value) { +void iron_gpu_constant_buffer_set_int(iron_gpu_constant_buffer_t *buffer, int offset, int value) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value; } -void iron_g5_constant_buffer_set_int2(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2) { +void iron_gpu_constant_buffer_set_int2(iron_gpu_constant_buffer_t *buffer, int offset, int value1, int value2) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value1; ints[1] = value2; } -void iron_g5_constant_buffer_set_int3(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3) { +void iron_gpu_constant_buffer_set_int3(iron_gpu_constant_buffer_t *buffer, int offset, int value1, int value2, int value3) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value1; ints[1] = value2; ints[2] = value3; } -void iron_g5_constant_buffer_set_int4(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4) { +void iron_gpu_constant_buffer_set_int4(iron_gpu_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value1; ints[1] = value2; @@ -696,32 +696,32 @@ void iron_g5_constant_buffer_set_int4(iron_g5_constant_buffer_t *buffer, int off ints[3] = value4; } -void iron_g5_constant_buffer_set_ints(iron_g5_constant_buffer_t *buffer, int offset, int *values, int count) { +void iron_gpu_constant_buffer_set_ints(iron_gpu_constant_buffer_t *buffer, int offset, int *values, int count) { int *ints = (int *)(&buffer->data[offset]); for (int i = 0; i < count; ++i) { ints[i] = values[i]; } } -void iron_g5_constant_buffer_set_float(iron_g5_constant_buffer_t *buffer, int offset, float value) { +void iron_gpu_constant_buffer_set_float(iron_gpu_constant_buffer_t *buffer, int offset, float value) { float *floats = (float *)(&buffer->data[offset]); floats[0] = value; } -void iron_g5_constant_buffer_set_float2(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2) { +void iron_gpu_constant_buffer_set_float2(iron_gpu_constant_buffer_t *buffer, int offset, float value1, float value2) { float *floats = (float *)(&buffer->data[offset]); floats[0] = value1; floats[1] = value2; } -void iron_g5_constant_buffer_set_float3(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3) { +void iron_gpu_constant_buffer_set_float3(iron_gpu_constant_buffer_t *buffer, int offset, float value1, float value2, float value3) { float *floats = (float *)(&buffer->data[offset]); floats[0] = value1; floats[1] = value2; floats[2] = value3; } -void iron_g5_constant_buffer_set_float4(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4) { +void iron_gpu_constant_buffer_set_float4(iron_gpu_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4) { float *floats = (float *)(&buffer->data[offset]); floats[0] = value1; floats[1] = value2; @@ -729,14 +729,14 @@ void iron_g5_constant_buffer_set_float4(iron_g5_constant_buffer_t *buffer, int o floats[3] = value4; } -void iron_g5_constant_buffer_set_floats(iron_g5_constant_buffer_t *buffer, int offset, float *values, int count) { +void iron_gpu_constant_buffer_set_floats(iron_gpu_constant_buffer_t *buffer, int offset, float *values, int count) { float *floats = (float *)(&buffer->data[offset]); for (int i = 0; i < count; ++i) { floats[i] = values[i]; } } -void iron_g5_constant_buffer_set_bool(iron_g5_constant_buffer_t *buffer, int offset, bool value) { +void iron_gpu_constant_buffer_set_bool(iron_gpu_constant_buffer_t *buffer, int offset, bool value) { int *ints = (int *)(&buffer->data[offset]); ints[0] = value ? 1 : 0; } @@ -750,8 +750,8 @@ static void iron_internal_set_matrix3(uint8_t *constants, int offset, iron_matri } } -void iron_g5_constant_buffer_set_matrix3(iron_g5_constant_buffer_t *buffer, int offset, iron_matrix3x3_t *value) { - if (iron_g5_transpose_mat) { +void iron_gpu_constant_buffer_set_matrix3(iron_gpu_constant_buffer_t *buffer, int offset, iron_matrix3x3_t *value) { + if (iron_gpu_transpose_mat) { iron_matrix3x3_t m = *value; iron_matrix3x3_transpose(&m); iron_internal_set_matrix3(buffer->data, offset, &m); @@ -770,8 +770,8 @@ static void iron_internal_set_matrix4(uint8_t *constants, int offset, iron_matri } } -void iron_g5_constant_buffer_set_matrix4(iron_g5_constant_buffer_t *buffer, int offset, iron_matrix4x4_t *value) { - if (iron_g5_transpose_mat) { +void iron_gpu_constant_buffer_set_matrix4(iron_gpu_constant_buffer_t *buffer, int offset, iron_matrix4x4_t *value) { + if (iron_gpu_transpose_mat) { iron_matrix4x4_t m = *value; iron_matrix4x4_transpose(&m); iron_internal_set_matrix4(buffer->data, offset, &m); @@ -781,21 +781,21 @@ void iron_g5_constant_buffer_set_matrix4(iron_g5_constant_buffer_t *buffer, int } } -void iron_g5_internal_pipeline_init(iron_g5_pipeline_t *pipe) { +void iron_gpu_internal_pipeline_init(iron_gpu_pipeline_t *pipe) { pipe->input_layout = NULL; pipe->vertex_shader = NULL; pipe->fragment_shader = NULL; - pipe->cull_mode = IRON_G5_CULL_MODE_NEVER; + pipe->cull_mode = IRON_GPU_CULL_MODE_NEVER; pipe->depth_write = false; - pipe->depth_mode = IRON_G5_COMPARE_MODE_ALWAYS; + pipe->depth_mode = IRON_GPU_COMPARE_MODE_ALWAYS; - pipe->blend_source = IRON_G5_BLEND_ONE; - pipe->blend_destination = IRON_G5_BLEND_ZERO; - pipe->blend_operation = IRON_G5_BLENDOP_ADD; - pipe->alpha_blend_source = IRON_G5_BLEND_ONE; - pipe->alpha_blend_destination = IRON_G5_BLEND_ZERO; - pipe->alpha_blend_operation = IRON_G5_BLENDOP_ADD; + pipe->blend_source = IRON_GPU_BLEND_ONE; + pipe->blend_destination = IRON_GPU_BLEND_ZERO; + pipe->blend_operation = IRON_GPU_BLENDOP_ADD; + pipe->alpha_blend_source = IRON_GPU_BLEND_ONE; + pipe->alpha_blend_destination = IRON_GPU_BLEND_ZERO; + pipe->alpha_blend_operation = IRON_GPU_BLENDOP_ADD; for (int i = 0; i < 8; ++i) { pipe->color_write_mask_red[i] = true; @@ -809,21 +809,21 @@ void iron_g5_internal_pipeline_init(iron_g5_pipeline_t *pipe) { pipe->depth_attachment_bits = 0; } -void iron_g5_internal_pipeline_set_defaults(iron_g5_pipeline_t *state) { +void iron_gpu_internal_pipeline_set_defaults(iron_gpu_pipeline_t *state) { state->input_layout = NULL; state->vertex_shader = NULL; state->fragment_shader = NULL; - state->cull_mode = IRON_G5_CULL_MODE_NEVER; + state->cull_mode = IRON_GPU_CULL_MODE_NEVER; state->depth_write = false; - state->depth_mode = IRON_G5_COMPARE_MODE_ALWAYS; + state->depth_mode = IRON_GPU_COMPARE_MODE_ALWAYS; - state->blend_source = IRON_G5_BLEND_ONE; - state->blend_destination = IRON_G5_BLEND_ZERO; - state->blend_operation = IRON_G5_BLENDOP_ADD; - state->alpha_blend_source = IRON_G5_BLEND_ONE; - state->alpha_blend_destination = IRON_G5_BLEND_ZERO; - state->alpha_blend_operation = IRON_G5_BLENDOP_ADD; + state->blend_source = IRON_GPU_BLEND_ONE; + state->blend_destination = IRON_GPU_BLEND_ZERO; + state->blend_operation = IRON_GPU_BLENDOP_ADD; + state->alpha_blend_source = IRON_GPU_BLEND_ONE; + state->alpha_blend_destination = IRON_GPU_BLEND_ZERO; + state->alpha_blend_operation = IRON_GPU_BLENDOP_ADD; for (int i = 0; i < 8; ++i) { state->color_write_mask_red[i] = true; @@ -837,24 +837,24 @@ void iron_g5_internal_pipeline_set_defaults(iron_g5_pipeline_t *state) { state->depth_attachment_bits = 0; } -void iron_g5_sampler_options_set_defaults(iron_g5_sampler_options_t *options) { - options->u_addressing = IRON_G5_TEXTURE_ADDRESSING_CLAMP; - options->v_addressing = IRON_G5_TEXTURE_ADDRESSING_CLAMP; +void iron_gpu_sampler_options_set_defaults(iron_gpu_sampler_options_t *options) { + options->u_addressing = IRON_GPU_TEXTURE_ADDRESSING_CLAMP; + options->v_addressing = IRON_GPU_TEXTURE_ADDRESSING_CLAMP; - options->magnification_filter = IRON_G5_TEXTURE_FILTER_POINT; - options->minification_filter = IRON_G5_TEXTURE_FILTER_POINT; - options->mipmap_filter = IRON_G5_MIPMAP_FILTER_POINT; + options->magnification_filter = IRON_GPU_TEXTURE_FILTER_POINT; + options->minification_filter = IRON_GPU_TEXTURE_FILTER_POINT; + options->mipmap_filter = IRON_GPU_MIPMAP_FILTER_POINT; } void iron_internal_samplers_reset(void) { - for (int i = 0; i < IRON_G5_SHADER_TYPE_COUNT; ++i) { + for (int i = 0; i < IRON_GPU_SHADER_TYPE_COUNT; ++i) { for (int j = 0; j < MAX_SAMPLERS_PER_STAGE; ++j) { - iron_g5_sampler_options_set_defaults(&sampler_options[i][j]); + iron_gpu_sampler_options_set_defaults(&sampler_options[i][j]); } } } -bool sampler_options_equals(iron_g5_sampler_options_t *options1, iron_g5_sampler_options_t *options2) { +bool sampler_options_equals(iron_gpu_sampler_options_t *options1, iron_gpu_sampler_options_t *options2) { return options1->u_addressing == options2->u_addressing && options1->v_addressing == options2->v_addressing && options1->minification_filter == options2->minification_filter && @@ -862,7 +862,7 @@ bool sampler_options_equals(iron_g5_sampler_options_t *options1, iron_g5_sampler options1->mipmap_filter == options2->mipmap_filter; } -iron_g5_sampler_t *iron_internal_get_current_sampler(int stage, int unit) { +iron_gpu_sampler_t *iron_internal_get_current_sampler(int stage, int unit) { // TODO: Please make this much faster for (int i = 0; i < sampler_cache_size; ++i) { if (sampler_options_equals(&sampler_cache[i].options, &sampler_options[stage][unit])) { @@ -871,8 +871,8 @@ iron_g5_sampler_t *iron_internal_get_current_sampler(int stage, int unit) { } assert(sampler_cache_size < MAX_SAMPLER_CACHE_SIZE); - iron_g5_sampler_t *sampler = &sampler_cache[sampler_cache_size].sampler; - iron_g5_sampler_init(sampler, &sampler_options[stage][unit]); + iron_gpu_sampler_t *sampler = &sampler_cache[sampler_cache_size].sampler; + iron_gpu_sampler_init(sampler, &sampler_options[stage][unit]); sampler_cache[sampler_cache_size].options = sampler_options[stage][unit]; sampler_cache_size += 1; diff --git a/base/sources/iron_gpu.h b/base/sources/iron_gpu.h index 571f6d81..7d3b5019 100644 --- a/base/sources/iron_gpu.h +++ b/base/sources/iron_gpu.h @@ -9,8 +9,8 @@ #include #include BACKEND_GPU_H -#define IRON_G5_CLEAR_COLOR 1 -#define IRON_G5_CLEAR_DEPTH 2 +#define IRON_GPU_CLEAR_COLOR 1 +#define IRON_GPU_CLEAR_DEPTH 2 enum iron_internal_render_target_state { IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET, @@ -33,7 +33,7 @@ typedef enum iron_image_format { IRON_IMAGE_FORMAT_BGRA32 } iron_image_format_t; -typedef struct iron_g5_texture { +typedef struct iron_gpu_texture { int width; int height; @@ -49,329 +49,329 @@ typedef struct iron_g5_texture { buffer_t *buffer; Texture5Impl impl; -} iron_g5_texture_t; +} iron_gpu_texture_t; -int iron_g5_max_bound_textures(void); -void iron_g5_flush(void); -void iron_g5_begin(iron_g5_texture_t *renderTarget); -void iron_g5_end(void); -bool iron_g5_swap_buffers(void); +int iron_gpu_max_bound_textures(void); +void iron_gpu_flush(void); +void iron_gpu_begin(iron_gpu_texture_t *renderTarget); +void iron_gpu_end(void); +bool iron_gpu_swap_buffers(void); -void iron_g5_internal_init(void); -void iron_g5_internal_init_window(int depth_buffer_bits, bool vsync); -void iron_g5_internal_destroy_window(void); -void iron_g5_internal_destroy(void); +void iron_gpu_internal_init(void); +void iron_gpu_internal_init_window(int depth_buffer_bits, bool vsync); +void iron_gpu_internal_destroy_window(void); +void iron_gpu_internal_destroy(void); -struct iron_g5_pipeline; -struct iron_g5_texture; -struct iron_g5_texture_unit; -struct iron_g5_constant_location; -struct iron_g5_index_buffer; +struct iron_gpu_pipeline; +struct iron_gpu_texture; +struct iron_gpu_texture_unit; +struct iron_gpu_constant_location; +struct iron_gpu_index_buffer; typedef enum { - IRON_G4_TEXTURE_ADDRESSING_REPEAT, - IRON_G4_TEXTURE_ADDRESSING_MIRROR, - IRON_G4_TEXTURE_ADDRESSING_CLAMP, - IRON_G4_TEXTURE_ADDRESSING_BORDER -} iron_g4_texture_addressing_t; + GPU_TEXTURE_ADDRESSING_REPEAT, + GPU_TEXTURE_ADDRESSING_MIRROR, + GPU_TEXTURE_ADDRESSING_CLAMP, + GPU_TEXTURE_ADDRESSING_BORDER +} gpu_texture_addressing_t; typedef enum { - IRON_G4_TEXTURE_DIRECTION_U, - IRON_G4_TEXTURE_DIRECTION_V -} iron_g4_texture_direction_t; + GPU_TEXTURE_DIRECTION_U, + GPU_TEXTURE_DIRECTION_V +} gpu_texture_direction_t; typedef enum { - IRON_G4_TEXTURE_FILTER_POINT, - IRON_G4_TEXTURE_FILTER_LINEAR, - IRON_G4_TEXTURE_FILTER_ANISOTROPIC -} iron_g4_texture_filter_t; + GPU_TEXTURE_FILTER_POINT, + GPU_TEXTURE_FILTER_LINEAR, + GPU_TEXTURE_FILTER_ANISOTROPIC +} gpu_texture_filter_t; typedef enum { - IRON_G4_MIPMAP_FILTER_NONE, - IRON_G4_MIPMAP_FILTER_POINT, - IRON_G4_MIPMAP_FILTER_LINEAR // linear texture filter + linear mip filter -> trilinear filter -} iron_g4_mipmap_filter_t; + GPU_MIPMAP_FILTER_NONE, + GPU_MIPMAP_FILTER_POINT, + GPU_MIPMAP_FILTER_LINEAR // linear texture filter + linear mip filter -> trilinear filter +} gpu_mipmap_filter_t; -typedef enum iron_g4_usage { - IRON_G4_USAGE_STATIC, - IRON_G4_USAGE_DYNAMIC, - IRON_G4_USAGE_READABLE -} iron_g4_usage_t; +typedef enum gpu_usage { + GPU_USAGE_STATIC, + GPU_USAGE_DYNAMIC, + GPU_USAGE_READABLE +} gpu_usage_t; -void iron_g4_begin(); -void iron_g4_end(); -void iron_g5_clear(unsigned color, float depth, unsigned flags); -void iron_g4_viewport(int x, int y, int width, int height); -void iron_g4_scissor(int x, int y, int width, int height); -void iron_g4_disable_scissor(void); -void iron_g5_draw_indexed_vertices(void); -void iron_g5_draw_indexed_vertices_from_to(int start, int count); -void iron_g4_set_texture_addressing(struct iron_g5_texture_unit unit, iron_g4_texture_direction_t dir, iron_g4_texture_addressing_t addressing); -void iron_g5_set_pipeline(struct iron_g5_pipeline *pipeline); -void iron_g4_set_int(struct iron_g5_constant_location location, int value); -void iron_g4_set_int2(struct iron_g5_constant_location location, int value1, int value2); -void iron_g4_set_int3(struct iron_g5_constant_location location, int value1, int value2, int value3); -void iron_g4_set_int4(struct iron_g5_constant_location location, int value1, int value2, int value3, int value4); -void iron_g4_set_ints(struct iron_g5_constant_location location, int *values, int count); -void iron_g4_set_float(struct iron_g5_constant_location location, float value); -void iron_g4_set_float2(struct iron_g5_constant_location location, float value1, float value2); -void iron_g4_set_float3(struct iron_g5_constant_location location, float value1, float value2, float value3); -void iron_g4_set_float4(struct iron_g5_constant_location location, float value1, float value2, float value3, float value4); -void iron_g4_set_floats(struct iron_g5_constant_location location, float *values, int count); -void iron_g4_set_bool(struct iron_g5_constant_location location, bool value); -void iron_g4_set_matrix3(struct iron_g5_constant_location location, iron_matrix3x3_t *value); -void iron_g4_set_matrix4(struct iron_g5_constant_location location, iron_matrix4x4_t *value); -void iron_g4_set_texture_magnification_filter(struct iron_g5_texture_unit unit, iron_g4_texture_filter_t filter); -void iron_g4_set_texture_minification_filter(struct iron_g5_texture_unit unit, iron_g4_texture_filter_t filter); -void iron_g4_set_texture_mipmap_filter(struct iron_g5_texture_unit unit, iron_g4_mipmap_filter_t filter); -void iron_g4_restore_render_target(void); -void iron_g4_set_render_targets(struct iron_g5_texture **targets, int count); -void iron_g4_set_texture(struct iron_g5_texture_unit unit, struct iron_g5_texture *texture); -void iron_g4_compute(int x, int y, int z); -void iron_g4_set_index_buffer(struct iron_g5_index_buffer *buffer); +void gpu_begin(); +void gpu_end(); +void iron_gpu_clear(unsigned color, float depth, unsigned flags); +void gpu_viewport(int x, int y, int width, int height); +void gpu_scissor(int x, int y, int width, int height); +void gpu_disable_scissor(void); +void iron_gpu_draw_indexed_vertices(void); +void iron_gpu_draw_indexed_vertices_from_to(int start, int count); +void gpu_set_texture_addressing(struct iron_gpu_texture_unit unit, gpu_texture_direction_t dir, gpu_texture_addressing_t addressing); +void iron_gpu_set_pipeline(struct iron_gpu_pipeline *pipeline); +void gpu_set_int(struct iron_gpu_constant_location location, int value); +void gpu_set_int2(struct iron_gpu_constant_location location, int value1, int value2); +void gpu_set_int3(struct iron_gpu_constant_location location, int value1, int value2, int value3); +void gpu_set_int4(struct iron_gpu_constant_location location, int value1, int value2, int value3, int value4); +void gpu_set_ints(struct iron_gpu_constant_location location, int *values, int count); +void gpu_set_float(struct iron_gpu_constant_location location, float value); +void gpu_set_float2(struct iron_gpu_constant_location location, float value1, float value2); +void gpu_set_float3(struct iron_gpu_constant_location location, float value1, float value2, float value3); +void gpu_set_float4(struct iron_gpu_constant_location location, float value1, float value2, float value3, float value4); +void gpu_set_floats(struct iron_gpu_constant_location location, float *values, int count); +void gpu_set_bool(struct iron_gpu_constant_location location, bool value); +void gpu_set_matrix3(struct iron_gpu_constant_location location, iron_matrix3x3_t *value); +void gpu_set_matrix4(struct iron_gpu_constant_location location, iron_matrix4x4_t *value); +void gpu_set_texture_magnification_filter(struct iron_gpu_texture_unit unit, gpu_texture_filter_t filter); +void gpu_set_texture_minification_filter(struct iron_gpu_texture_unit unit, gpu_texture_filter_t filter); +void gpu_set_texture_mipmap_filter(struct iron_gpu_texture_unit unit, gpu_mipmap_filter_t filter); +void gpu_restore_render_target(void); +void gpu_set_render_targets(struct iron_gpu_texture **targets, int count); +void gpu_set_texture(struct iron_gpu_texture_unit unit, struct iron_gpu_texture *texture); +void gpu_compute(int x, int y, int z); +void gpu_set_index_buffer(struct iron_gpu_index_buffer *buffer); -void iron_g4_internal_init_window(int depth_buffer_bits, bool vsync); +void gpu_internal_init_window(int depth_buffer_bits, bool vsync); -void iron_g4_render_target_use_depth_as_texture(struct iron_g5_texture *renderTarget, struct iron_g5_texture_unit unit); +void gpu_render_target_use_depth_as_texture(struct iron_gpu_texture *renderTarget, struct iron_gpu_texture_unit unit); -void iron_g4_index_buffer_unlock_all(struct iron_g5_index_buffer *buffer); -void iron_g4_index_buffer_unlock(struct iron_g5_index_buffer *buffer, int count); +void gpu_index_buffer_unlock_all(struct iron_gpu_index_buffer *buffer); +void gpu_index_buffer_unlock(struct iron_gpu_index_buffer *buffer, int count); -#define IRON_G5_MAX_VERTEX_ELEMENTS 16 +#define IRON_GPU_MAX_VERTEX_ELEMENTS 16 -typedef enum iron_g5_vertex_data { - IRON_G5_VERTEX_DATA_F32_1X = 0, - IRON_G5_VERTEX_DATA_F32_2X = 1, - IRON_G5_VERTEX_DATA_F32_3X = 2, - IRON_G5_VERTEX_DATA_F32_4X = 3, - IRON_G5_VERTEX_DATA_U8_4X_NORM = 4, - IRON_G5_VERTEX_DATA_I16_2X_NORM = 5, - IRON_G5_VERTEX_DATA_I16_4X_NORM = 6, -} iron_g5_vertex_data_t; +typedef enum iron_gpu_vertex_data { + IRON_GPU_VERTEX_DATA_F32_1X = 0, + IRON_GPU_VERTEX_DATA_F32_2X = 1, + IRON_GPU_VERTEX_DATA_F32_3X = 2, + IRON_GPU_VERTEX_DATA_F32_4X = 3, + IRON_GPU_VERTEX_DATA_U8_4X_NORM = 4, + IRON_GPU_VERTEX_DATA_I16_2X_NORM = 5, + IRON_GPU_VERTEX_DATA_I16_4X_NORM = 6, +} iron_gpu_vertex_data_t; -typedef struct iron_g5_vertex_element { +typedef struct iron_gpu_vertex_element { const char *name; - iron_g5_vertex_data_t data; -} iron_g5_vertex_element_t; + iron_gpu_vertex_data_t data; +} iron_gpu_vertex_element_t; -typedef struct iron_g5_vertex_structure { - iron_g5_vertex_element_t elements[IRON_G5_MAX_VERTEX_ELEMENTS]; +typedef struct iron_gpu_vertex_structure { + iron_gpu_vertex_element_t elements[IRON_GPU_MAX_VERTEX_ELEMENTS]; int size; -} iron_g5_vertex_structure_t; +} iron_gpu_vertex_structure_t; -static inline int iron_g5_vertex_data_size(iron_g5_vertex_data_t data) { +static inline int iron_gpu_vertex_data_size(iron_gpu_vertex_data_t data) { switch (data) { - case IRON_G5_VERTEX_DATA_F32_1X: + case IRON_GPU_VERTEX_DATA_F32_1X: return 1 * 4; - case IRON_G5_VERTEX_DATA_F32_2X: + case IRON_GPU_VERTEX_DATA_F32_2X: return 2 * 4; - case IRON_G5_VERTEX_DATA_F32_3X: + case IRON_GPU_VERTEX_DATA_F32_3X: return 3 * 4; - case IRON_G5_VERTEX_DATA_F32_4X: + case IRON_GPU_VERTEX_DATA_F32_4X: return 4 * 4; - case IRON_G5_VERTEX_DATA_U8_4X_NORM: + case IRON_GPU_VERTEX_DATA_U8_4X_NORM: return 4 * 1; - case IRON_G5_VERTEX_DATA_I16_2X_NORM: + case IRON_GPU_VERTEX_DATA_I16_2X_NORM: return 2 * 2; - case IRON_G5_VERTEX_DATA_I16_4X_NORM: + case IRON_GPU_VERTEX_DATA_I16_4X_NORM: return 4 * 2; } } -static inline int iron_g5_vertex_struct_size(iron_g5_vertex_structure_t *s) { +static inline int iron_gpu_vertex_struct_size(iron_gpu_vertex_structure_t *s) { int size = 0; for (int i = 0; i < s->size; ++i) { - size += iron_g5_vertex_data_size(s->elements[i].data); + size += iron_gpu_vertex_data_size(s->elements[i].data); } return size; } -void iron_g5_vertex_structure_init(iron_g5_vertex_structure_t *structure); -void iron_g5_vertex_structure_add(iron_g5_vertex_structure_t *structure, const char *name, iron_g5_vertex_data_t data); +void iron_gpu_vertex_structure_init(iron_gpu_vertex_structure_t *structure); +void iron_gpu_vertex_structure_add(iron_gpu_vertex_structure_t *structure, const char *name, iron_gpu_vertex_data_t data); -void iron_g5_texture_init(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format); -void iron_g5_texture_init_from_bytes(iron_g5_texture_t *texture, void *data, int width, int height, iron_image_format_t format); -void iron_g5_texture_init_non_sampled_access(iron_g5_texture_t *texture, int width, int height, iron_image_format_t format); -void iron_g5_texture_destroy(iron_g5_texture_t *texture); -void iron_g5_texture_generate_mipmaps(iron_g5_texture_t *texture, int levels); -void iron_g5_texture_set_mipmap(iron_g5_texture_t *texture, iron_g5_texture_t *mipmap, int level); -int iron_g5_texture_stride(iron_g5_texture_t *texture); +void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format); +void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format); +void iron_gpu_texture_init_non_sampled_access(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format); +void iron_gpu_texture_destroy(iron_gpu_texture_t *texture); +void iron_gpu_texture_generate_mipmaps(iron_gpu_texture_t *texture, int levels); +void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t *mipmap, int level); +int iron_gpu_texture_stride(iron_gpu_texture_t *texture); -struct iron_g5_texture_unit; +struct iron_gpu_texture_unit; -void iron_g5_render_target_init(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits); -void iron_g5_render_target_init_framebuffer(iron_g5_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits); -void iron_g5_render_target_set_depth_from(iron_g5_texture_t *target, iron_g5_texture_t *source); +void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits); +void iron_gpu_render_target_init_framebuffer(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits); +void iron_gpu_render_target_set_depth_from(iron_gpu_texture_t *target, iron_gpu_texture_t *source); -typedef struct iron_g5_vertex_buffer { +typedef struct iron_gpu_vertex_buffer { VertexBuffer5Impl impl; -} iron_g5_vertex_buffer_t; +} iron_gpu_vertex_buffer_t; typedef struct { int myCount; - iron_g5_vertex_buffer_t _buffer[2]; + iron_gpu_vertex_buffer_t _buffer[2]; int _currentIndex; int _multiple; -} iron_g4_vertex_buffer_impl_t; +} gpu_vertex_buffer_impl_t; -typedef struct iron_g4_vertex_buffer { - iron_g4_vertex_buffer_impl_t impl; -} iron_g4_vertex_buffer_t; +typedef struct gpu_vertex_buffer { + gpu_vertex_buffer_impl_t impl; +} gpu_vertex_buffer_t; -void iron_g5_vertex_buffer_init(iron_g5_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, bool gpu_memory); -void iron_g5_vertex_buffer_destroy(iron_g5_vertex_buffer_t *buffer); -float *iron_g5_vertex_buffer_lock_all(iron_g5_vertex_buffer_t *buffer); -float *iron_g5_vertex_buffer_lock(iron_g5_vertex_buffer_t *buffer, int start, int count); -void iron_g5_vertex_buffer_unlock_all(iron_g5_vertex_buffer_t *buffer); -void iron_g5_vertex_buffer_unlock(iron_g5_vertex_buffer_t *buffer, int count); -int iron_g5_vertex_buffer_count(iron_g5_vertex_buffer_t *buffer); -int iron_g5_vertex_buffer_stride(iron_g5_vertex_buffer_t *buffer); +void iron_gpu_vertex_buffer_init(iron_gpu_vertex_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, bool gpu_memory); +void iron_gpu_vertex_buffer_destroy(iron_gpu_vertex_buffer_t *buffer); +float *iron_gpu_vertex_buffer_lock_all(iron_gpu_vertex_buffer_t *buffer); +float *iron_gpu_vertex_buffer_lock(iron_gpu_vertex_buffer_t *buffer, int start, int count); +void iron_gpu_vertex_buffer_unlock_all(iron_gpu_vertex_buffer_t *buffer); +void iron_gpu_vertex_buffer_unlock(iron_gpu_vertex_buffer_t *buffer, int count); +int iron_gpu_vertex_buffer_count(iron_gpu_vertex_buffer_t *buffer); +int iron_gpu_vertex_buffer_stride(iron_gpu_vertex_buffer_t *buffer); -int iron_g5_internal_vertex_buffer_set(iron_g5_vertex_buffer_t *buffer); +int iron_gpu_internal_vertex_buffer_set(iron_gpu_vertex_buffer_t *buffer); -void iron_g4_vertex_buffer_init(iron_g4_vertex_buffer_t *buffer, int count, iron_g5_vertex_structure_t *structure, iron_g4_usage_t usage); -void iron_g4_vertex_buffer_destroy(iron_g4_vertex_buffer_t *buffer); -float *iron_g4_vertex_buffer_lock_all(iron_g4_vertex_buffer_t *buffer); -float *iron_g4_vertex_buffer_lock(iron_g4_vertex_buffer_t *buffer, int start, int count); -void iron_g4_vertex_buffer_unlock_all(iron_g4_vertex_buffer_t *buffer); -void iron_g4_vertex_buffer_unlock(iron_g4_vertex_buffer_t *buffer, int count); -int iron_g4_vertex_buffer_count(iron_g4_vertex_buffer_t *buffer); -int iron_g4_vertex_buffer_stride(iron_g4_vertex_buffer_t *buffer); -void iron_g4_set_vertex_buffer(iron_g4_vertex_buffer_t *buffer); +void gpu_vertex_buffer_init(gpu_vertex_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, gpu_usage_t usage); +void gpu_vertex_buffer_destroy(gpu_vertex_buffer_t *buffer); +float *gpu_vertex_buffer_lock_all(gpu_vertex_buffer_t *buffer); +float *gpu_vertex_buffer_lock(gpu_vertex_buffer_t *buffer, int start, int count); +void gpu_vertex_buffer_unlock_all(gpu_vertex_buffer_t *buffer); +void gpu_vertex_buffer_unlock(gpu_vertex_buffer_t *buffer, int count); +int gpu_vertex_buffer_count(gpu_vertex_buffer_t *buffer); +int gpu_vertex_buffer_stride(gpu_vertex_buffer_t *buffer); +void gpu_set_vertex_buffer(gpu_vertex_buffer_t *buffer); -typedef struct iron_g5_constant_buffer { +typedef struct iron_gpu_constant_buffer { uint8_t *data; ConstantBuffer5Impl impl; -} iron_g5_constant_buffer_t; +} iron_gpu_constant_buffer_t; -void iron_g5_constant_buffer_init(iron_g5_constant_buffer_t *buffer, int size); -void iron_g5_constant_buffer_destroy(iron_g5_constant_buffer_t *buffer); -void iron_g5_constant_buffer_lock_all(iron_g5_constant_buffer_t *buffer); -void iron_g5_constant_buffer_lock(iron_g5_constant_buffer_t *buffer, int start, int count); -void iron_g5_constant_buffer_unlock(iron_g5_constant_buffer_t *buffer); -int iron_g5_constant_buffer_size(iron_g5_constant_buffer_t *buffer); -void iron_g5_constant_buffer_set_bool(iron_g5_constant_buffer_t *buffer, int offset, bool value); -void iron_g5_constant_buffer_set_int(iron_g5_constant_buffer_t *buffer, int offset, int value); -void iron_g5_constant_buffer_set_int2(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2); -void iron_g5_constant_buffer_set_int3(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3); -void iron_g5_constant_buffer_set_int4(iron_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4); -void iron_g5_constant_buffer_set_ints(iron_g5_constant_buffer_t *buffer, int offset, int *values, int count); -void iron_g5_constant_buffer_set_float(iron_g5_constant_buffer_t *buffer, int offset, float value); -void iron_g5_constant_buffer_set_float2(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2); -void iron_g5_constant_buffer_set_float3(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3); -void iron_g5_constant_buffer_set_float4(iron_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4); -void iron_g5_constant_buffer_set_floats(iron_g5_constant_buffer_t *buffer, int offset, float *values, int count); -void iron_g5_constant_buffer_set_matrix3(iron_g5_constant_buffer_t *buffer, int offset, iron_matrix3x3_t *value); -void iron_g5_constant_buffer_set_matrix4(iron_g5_constant_buffer_t *buffer, int offset, iron_matrix4x4_t *value); +void iron_gpu_constant_buffer_init(iron_gpu_constant_buffer_t *buffer, int size); +void iron_gpu_constant_buffer_destroy(iron_gpu_constant_buffer_t *buffer); +void iron_gpu_constant_buffer_lock_all(iron_gpu_constant_buffer_t *buffer); +void iron_gpu_constant_buffer_lock(iron_gpu_constant_buffer_t *buffer, int start, int count); +void iron_gpu_constant_buffer_unlock(iron_gpu_constant_buffer_t *buffer); +int iron_gpu_constant_buffer_size(iron_gpu_constant_buffer_t *buffer); +void iron_gpu_constant_buffer_set_bool(iron_gpu_constant_buffer_t *buffer, int offset, bool value); +void iron_gpu_constant_buffer_set_int(iron_gpu_constant_buffer_t *buffer, int offset, int value); +void iron_gpu_constant_buffer_set_int2(iron_gpu_constant_buffer_t *buffer, int offset, int value1, int value2); +void iron_gpu_constant_buffer_set_int3(iron_gpu_constant_buffer_t *buffer, int offset, int value1, int value2, int value3); +void iron_gpu_constant_buffer_set_int4(iron_gpu_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4); +void iron_gpu_constant_buffer_set_ints(iron_gpu_constant_buffer_t *buffer, int offset, int *values, int count); +void iron_gpu_constant_buffer_set_float(iron_gpu_constant_buffer_t *buffer, int offset, float value); +void iron_gpu_constant_buffer_set_float2(iron_gpu_constant_buffer_t *buffer, int offset, float value1, float value2); +void iron_gpu_constant_buffer_set_float3(iron_gpu_constant_buffer_t *buffer, int offset, float value1, float value2, float value3); +void iron_gpu_constant_buffer_set_float4(iron_gpu_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4); +void iron_gpu_constant_buffer_set_floats(iron_gpu_constant_buffer_t *buffer, int offset, float *values, int count); +void iron_gpu_constant_buffer_set_matrix3(iron_gpu_constant_buffer_t *buffer, int offset, iron_matrix3x3_t *value); +void iron_gpu_constant_buffer_set_matrix4(iron_gpu_constant_buffer_t *buffer, int offset, iron_matrix4x4_t *value); -extern bool iron_g5_transpose_mat; +extern bool iron_gpu_transpose_mat; -typedef struct iron_g5_index_buffer { +typedef struct iron_gpu_index_buffer { IndexBuffer5Impl impl; -} iron_g5_index_buffer_t; +} iron_gpu_index_buffer_t; -void iron_g5_index_buffer_init(iron_g5_index_buffer_t *buffer, int count, bool gpu_memory); -void iron_g5_index_buffer_destroy(iron_g5_index_buffer_t *buffer); -void *iron_g5_index_buffer_lock_all(iron_g5_index_buffer_t *buffer); -void *iron_g5_index_buffer_lock(iron_g5_index_buffer_t *buffer, int start, int count); -void iron_g5_index_buffer_unlock_all(iron_g5_index_buffer_t *buffer); -void iron_g5_index_buffer_unlock(iron_g5_index_buffer_t *buffer, int count); -int iron_g5_index_buffer_count(iron_g5_index_buffer_t *buffer); +void iron_gpu_index_buffer_init(iron_gpu_index_buffer_t *buffer, int count, bool gpu_memory); +void iron_gpu_index_buffer_destroy(iron_gpu_index_buffer_t *buffer); +void *iron_gpu_index_buffer_lock_all(iron_gpu_index_buffer_t *buffer); +void *iron_gpu_index_buffer_lock(iron_gpu_index_buffer_t *buffer, int start, int count); +void iron_gpu_index_buffer_unlock_all(iron_gpu_index_buffer_t *buffer); +void iron_gpu_index_buffer_unlock(iron_gpu_index_buffer_t *buffer, int count); +int iron_gpu_index_buffer_count(iron_gpu_index_buffer_t *buffer); -typedef enum iron_g5_shader_type { - IRON_G5_SHADER_TYPE_FRAGMENT, - IRON_G5_SHADER_TYPE_VERTEX, - IRON_G5_SHADER_TYPE_COMPUTE, - IRON_G5_SHADER_TYPE_COUNT -} iron_g5_shader_type_t; +typedef enum iron_gpu_shader_type { + IRON_GPU_SHADER_TYPE_FRAGMENT, + IRON_GPU_SHADER_TYPE_VERTEX, + IRON_GPU_SHADER_TYPE_COMPUTE, + IRON_GPU_SHADER_TYPE_COUNT +} iron_gpu_shader_type_t; typedef enum { - IRON_G5_BLEND_ONE, - IRON_G5_BLEND_ZERO, - IRON_G5_BLEND_SOURCE_ALPHA, - IRON_G5_BLEND_DEST_ALPHA, - IRON_G5_BLEND_INV_SOURCE_ALPHA, - IRON_G5_BLEND_INV_DEST_ALPHA, - IRON_G5_BLEND_SOURCE_COLOR, - IRON_G5_BLEND_DEST_COLOR, - IRON_G5_BLEND_INV_SOURCE_COLOR, - IRON_G5_BLEND_INV_DEST_COLOR, - IRON_G5_BLEND_CONSTANT, - IRON_G5_BLEND_INV_CONSTANT -} iron_g5_blending_factor_t; + IRON_GPU_BLEND_ONE, + IRON_GPU_BLEND_ZERO, + IRON_GPU_BLEND_SOURCE_ALPHA, + IRON_GPU_BLEND_DEST_ALPHA, + IRON_GPU_BLEND_INV_SOURCE_ALPHA, + IRON_GPU_BLEND_INV_DEST_ALPHA, + IRON_GPU_BLEND_SOURCE_COLOR, + IRON_GPU_BLEND_DEST_COLOR, + IRON_GPU_BLEND_INV_SOURCE_COLOR, + IRON_GPU_BLEND_INV_DEST_COLOR, + IRON_GPU_BLEND_CONSTANT, + IRON_GPU_BLEND_INV_CONSTANT +} iron_gpu_blending_factor_t; typedef enum { - IRON_G5_BLENDOP_ADD, - IRON_G5_BLENDOP_SUBTRACT, - IRON_G5_BLENDOP_REVERSE_SUBTRACT, - IRON_G5_BLENDOP_MIN, - IRON_G5_BLENDOP_MAX -} iron_g5_blending_operation_t; + IRON_GPU_BLENDOP_ADD, + IRON_GPU_BLENDOP_SUBTRACT, + IRON_GPU_BLENDOP_REVERSE_SUBTRACT, + IRON_GPU_BLENDOP_MIN, + IRON_GPU_BLENDOP_MAX +} iron_gpu_blending_operation_t; -typedef enum iron_g5_cull_mode { - IRON_G5_CULL_MODE_CLOCKWISE, - IRON_G5_CULL_MODE_COUNTERCLOCKWISE, - IRON_G5_CULL_MODE_NEVER -} iron_g5_cull_mode_t; +typedef enum iron_gpu_cull_mode { + IRON_GPU_CULL_MODE_CLOCKWISE, + IRON_GPU_CULL_MODE_COUNTERCLOCKWISE, + IRON_GPU_CULL_MODE_NEVER +} iron_gpu_cull_mode_t; -typedef enum iron_g5_compare_mode { - IRON_G5_COMPARE_MODE_ALWAYS, - IRON_G5_COMPARE_MODE_NEVER, - IRON_G5_COMPARE_MODE_EQUAL, - IRON_G5_COMPARE_MODE_NOT_EQUAL, - IRON_G5_COMPARE_MODE_LESS, - IRON_G5_COMPARE_MODE_LESS_EQUAL, - IRON_G5_COMPARE_MODE_GREATER, - IRON_G5_COMPARE_MODE_GREATER_EQUAL -} iron_g5_compare_mode_t; +typedef enum iron_gpu_compare_mode { + IRON_GPU_COMPARE_MODE_ALWAYS, + IRON_GPU_COMPARE_MODE_NEVER, + IRON_GPU_COMPARE_MODE_EQUAL, + IRON_GPU_COMPARE_MODE_NOT_EQUAL, + IRON_GPU_COMPARE_MODE_LESS, + IRON_GPU_COMPARE_MODE_LESS_EQUAL, + IRON_GPU_COMPARE_MODE_GREATER, + IRON_GPU_COMPARE_MODE_GREATER_EQUAL +} iron_gpu_compare_mode_t; -typedef enum iron_g5_texture_addressing { - IRON_G5_TEXTURE_ADDRESSING_REPEAT, - IRON_G5_TEXTURE_ADDRESSING_MIRROR, - IRON_G5_TEXTURE_ADDRESSING_CLAMP, - IRON_G5_TEXTURE_ADDRESSING_BORDER -} iron_g5_texture_addressing_t; +typedef enum iron_gpu_texture_addressing { + IRON_GPU_TEXTURE_ADDRESSING_REPEAT, + IRON_GPU_TEXTURE_ADDRESSING_MIRROR, + IRON_GPU_TEXTURE_ADDRESSING_CLAMP, + IRON_GPU_TEXTURE_ADDRESSING_BORDER +} iron_gpu_texture_addressing_t; -typedef enum iron_g5_texture_filter { - IRON_G5_TEXTURE_FILTER_POINT, - IRON_G5_TEXTURE_FILTER_LINEAR, - IRON_G5_TEXTURE_FILTER_ANISOTROPIC -} iron_g5_texture_filter_t; +typedef enum iron_gpu_texture_filter { + IRON_GPU_TEXTURE_FILTER_POINT, + IRON_GPU_TEXTURE_FILTER_LINEAR, + IRON_GPU_TEXTURE_FILTER_ANISOTROPIC +} iron_gpu_texture_filter_t; -typedef enum iron_g5_mipmap_filter { - IRON_G5_MIPMAP_FILTER_NONE, - IRON_G5_MIPMAP_FILTER_POINT, - IRON_G5_MIPMAP_FILTER_LINEAR // linear texture filter + linear mip filter -> trilinear filter -} iron_g5_mipmap_filter_t; +typedef enum iron_gpu_mipmap_filter { + IRON_GPU_MIPMAP_FILTER_NONE, + IRON_GPU_MIPMAP_FILTER_POINT, + IRON_GPU_MIPMAP_FILTER_LINEAR // linear texture filter + linear mip filter -> trilinear filter +} iron_gpu_mipmap_filter_t; -typedef struct iron_g5_constant_location { +typedef struct iron_gpu_constant_location { ConstantLocation5Impl impl; -} iron_g5_constant_location_t; +} iron_gpu_constant_location_t; -typedef struct iron_g5_texture_unit { - int stages[IRON_G5_SHADER_TYPE_COUNT]; -} iron_g5_texture_unit_t; +typedef struct iron_gpu_texture_unit { + int stages[IRON_GPU_SHADER_TYPE_COUNT]; +} iron_gpu_texture_unit_t; -typedef struct iron_g5_shader { +typedef struct iron_gpu_shader { Shader5Impl impl; -} iron_g5_shader_t; +} iron_gpu_shader_t; -typedef struct iron_g5_pipeline { - iron_g5_vertex_structure_t *input_layout; - iron_g5_shader_t *vertex_shader; - iron_g5_shader_t *fragment_shader; +typedef struct iron_gpu_pipeline { + iron_gpu_vertex_structure_t *input_layout; + iron_gpu_shader_t *vertex_shader; + iron_gpu_shader_t *fragment_shader; - iron_g5_cull_mode_t cull_mode; + iron_gpu_cull_mode_t cull_mode; bool depth_write; - iron_g5_compare_mode_t depth_mode; + iron_gpu_compare_mode_t depth_mode; // One, Zero deactivates blending - iron_g5_blending_factor_t blend_source; - iron_g5_blending_factor_t blend_destination; - iron_g5_blending_operation_t blend_operation; - iron_g5_blending_factor_t alpha_blend_source; - iron_g5_blending_factor_t alpha_blend_destination; - iron_g5_blending_operation_t alpha_blend_operation; + iron_gpu_blending_factor_t blend_source; + iron_gpu_blending_factor_t blend_destination; + iron_gpu_blending_operation_t blend_operation; + iron_gpu_blending_factor_t alpha_blend_source; + iron_gpu_blending_factor_t alpha_blend_destination; + iron_gpu_blending_operation_t alpha_blend_operation; bool color_write_mask_red[8]; // Per render target bool color_write_mask_green[8]; @@ -383,124 +383,124 @@ typedef struct iron_g5_pipeline { int depth_attachment_bits; PipelineState5Impl impl; -} iron_g5_pipeline_t; +} iron_gpu_pipeline_t; -typedef struct iron_g5_sampler_options { - iron_g5_texture_addressing_t u_addressing; - iron_g5_texture_addressing_t v_addressing; +typedef struct iron_gpu_sampler_options { + iron_gpu_texture_addressing_t u_addressing; + iron_gpu_texture_addressing_t v_addressing; - iron_g5_texture_filter_t minification_filter; - iron_g5_texture_filter_t magnification_filter; - iron_g5_mipmap_filter_t mipmap_filter; + iron_gpu_texture_filter_t minification_filter; + iron_gpu_texture_filter_t magnification_filter; + iron_gpu_mipmap_filter_t mipmap_filter; -} iron_g5_sampler_options_t; +} iron_gpu_sampler_options_t; -typedef struct iron_g5_sampler { - iron_g5_sampler_impl_t impl; -} iron_g5_sampler_t; +typedef struct iron_gpu_sampler { + iron_gpu_sampler_impl_t impl; +} iron_gpu_sampler_t; -void iron_g5_pipeline_init(iron_g5_pipeline_t *pipeline); -void iron_g5_internal_pipeline_init(iron_g5_pipeline_t *pipeline); -void iron_g5_pipeline_destroy(iron_g5_pipeline_t *pipeline); -void iron_g5_pipeline_compile(iron_g5_pipeline_t *pipeline); -iron_g5_constant_location_t iron_g5_pipeline_get_constant_location(iron_g5_pipeline_t *pipeline, const char *name); -iron_g5_texture_unit_t iron_g5_pipeline_get_texture_unit(iron_g5_pipeline_t *pipeline, const char *name); +void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipeline); +void iron_gpu_internal_pipeline_init(iron_gpu_pipeline_t *pipeline); +void iron_gpu_pipeline_destroy(iron_gpu_pipeline_t *pipeline); +void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline); +iron_gpu_constant_location_t iron_gpu_pipeline_get_constant_location(iron_gpu_pipeline_t *pipeline, const char *name); +iron_gpu_texture_unit_t iron_gpu_pipeline_get_texture_unit(iron_gpu_pipeline_t *pipeline, const char *name); -void iron_g5_shader_init(iron_g5_shader_t *shader, const void *source, size_t length, iron_g5_shader_type_t type); -void iron_g5_shader_destroy(iron_g5_shader_t *shader); +void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *source, size_t length, iron_gpu_shader_type_t type); +void iron_gpu_shader_destroy(iron_gpu_shader_t *shader); -void iron_g5_sampler_options_set_defaults(iron_g5_sampler_options_t *options); -void iron_g5_sampler_init(iron_g5_sampler_t *sampler, const iron_g5_sampler_options_t *options); -void iron_g5_sampler_destroy(iron_g5_sampler_t *sampler); +void iron_gpu_sampler_options_set_defaults(iron_gpu_sampler_options_t *options); +void iron_gpu_sampler_init(iron_gpu_sampler_t *sampler, const iron_gpu_sampler_options_t *options); +void iron_gpu_sampler_destroy(iron_gpu_sampler_t *sampler); -void iron_g5_internal_pipeline_set_defaults(iron_g5_pipeline_t *pipeline); +void iron_gpu_internal_pipeline_set_defaults(iron_gpu_pipeline_t *pipeline); -struct iron_g5_compute_shader; -struct iron_g5_constant_buffer; -struct iron_g5_index_buffer; -struct iron_g5_vertex_buffer; -struct iron_g5_pipeline; -struct iron_g5_texture; -struct iron_g5_texture; +struct iron_gpu_compute_shader; +struct iron_gpu_constant_buffer; +struct iron_gpu_index_buffer; +struct iron_gpu_vertex_buffer; +struct iron_gpu_pipeline; +struct iron_gpu_texture; +struct iron_gpu_texture; -typedef struct iron_g5_command_list { +typedef struct iron_gpu_command_list { CommandList5Impl impl; -} iron_g5_command_list_t; +} iron_gpu_command_list_t; -void iron_g5_command_list_init(iron_g5_command_list_t *list); -void iron_g5_command_list_destroy(iron_g5_command_list_t *list); -void iron_g5_command_list_begin(iron_g5_command_list_t *list); -void iron_g5_command_list_end(iron_g5_command_list_t *list); -void iron_g5_command_list_clear(iron_g5_command_list_t *list, struct iron_g5_texture *render_target, unsigned flags, unsigned color, float depth); -void iron_g5_command_list_render_target_to_framebuffer_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget); -void iron_g5_command_list_framebuffer_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget); -void iron_g5_command_list_texture_to_render_target_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget); -void iron_g5_command_list_render_target_to_texture_barrier(iron_g5_command_list_t *list, struct iron_g5_texture *renderTarget); -void iron_g5_command_list_draw_indexed_vertices(iron_g5_command_list_t *list); -void iron_g5_command_list_draw_indexed_vertices_from_to(iron_g5_command_list_t *list, int start, int count); -void iron_g5_command_list_viewport(iron_g5_command_list_t *list, int x, int y, int width, int height); -void iron_g5_command_list_scissor(iron_g5_command_list_t *list, int x, int y, int width, int height); -void iron_g5_command_list_disable_scissor(iron_g5_command_list_t *list); -void iron_g5_command_list_set_pipeline(iron_g5_command_list_t *list, struct iron_g5_pipeline *pipeline); -void iron_g5_command_list_set_compute_shader(iron_g5_command_list_t *list, struct iron_g5_compute_shader *shader); -void iron_g5_command_list_set_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer); -void iron_g5_command_list_set_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer); -void iron_g5_command_list_set_render_targets(iron_g5_command_list_t *list, struct iron_g5_texture **targets, int count); -void iron_g5_command_list_upload_index_buffer(iron_g5_command_list_t *list, struct iron_g5_index_buffer *buffer); -void iron_g5_command_list_upload_vertex_buffer(iron_g5_command_list_t *list, struct iron_g5_vertex_buffer *buffer); -void iron_g5_command_list_upload_texture(iron_g5_command_list_t *list, struct iron_g5_texture *texture); -void iron_g5_command_list_set_vertex_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size); -void iron_g5_command_list_set_fragment_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size); -void iron_g5_command_list_set_compute_constant_buffer(iron_g5_command_list_t *list, struct iron_g5_constant_buffer *buffer, int offset, size_t size); -void iron_g5_command_list_execute(iron_g5_command_list_t *list); -void iron_g5_command_list_wait_for_execution_to_finish(iron_g5_command_list_t *list); -void iron_g5_command_list_get_render_target_pixels(iron_g5_command_list_t *list, struct iron_g5_texture *render_target, uint8_t *data); -void iron_g5_command_list_compute(iron_g5_command_list_t *list, int x, int y, int z); -void iron_g5_command_list_set_texture(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *texture); -void iron_g5_command_list_set_texture_from_render_target_depth(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_texture_t *target); -void iron_g5_command_list_set_sampler(iron_g5_command_list_t *list, iron_g5_texture_unit_t unit, iron_g5_sampler_t *sampler); +void iron_gpu_command_list_init(iron_gpu_command_list_t *list); +void iron_gpu_command_list_destroy(iron_gpu_command_list_t *list); +void iron_gpu_command_list_begin(iron_gpu_command_list_t *list); +void iron_gpu_command_list_end(iron_gpu_command_list_t *list); +void iron_gpu_command_list_clear(iron_gpu_command_list_t *list, struct iron_gpu_texture *render_target, unsigned flags, unsigned color, float depth); +void iron_gpu_command_list_render_target_to_framebuffer_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget); +void iron_gpu_command_list_framebuffer_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget); +void iron_gpu_command_list_texture_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget); +void iron_gpu_command_list_render_target_to_texture_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget); +void iron_gpu_command_list_draw_indexed_vertices(iron_gpu_command_list_t *list); +void iron_gpu_command_list_draw_indexed_vertices_from_to(iron_gpu_command_list_t *list, int start, int count); +void iron_gpu_command_list_viewport(iron_gpu_command_list_t *list, int x, int y, int width, int height); +void iron_gpu_command_list_scissor(iron_gpu_command_list_t *list, int x, int y, int width, int height); +void iron_gpu_command_list_disable_scissor(iron_gpu_command_list_t *list); +void iron_gpu_command_list_set_pipeline(iron_gpu_command_list_t *list, struct iron_gpu_pipeline *pipeline); +void iron_gpu_command_list_set_compute_shader(iron_gpu_command_list_t *list, struct iron_gpu_compute_shader *shader); +void iron_gpu_command_list_set_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_vertex_buffer *buffer); +void iron_gpu_command_list_set_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_index_buffer *buffer); +void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, struct iron_gpu_texture **targets, int count); +void iron_gpu_command_list_upload_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_index_buffer *buffer); +void iron_gpu_command_list_upload_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_vertex_buffer *buffer); +void iron_gpu_command_list_upload_texture(iron_gpu_command_list_t *list, struct iron_gpu_texture *texture); +void iron_gpu_command_list_set_vertex_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size); +void iron_gpu_command_list_set_fragment_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size); +void iron_gpu_command_list_set_compute_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_constant_buffer *buffer, int offset, size_t size); +void iron_gpu_command_list_execute(iron_gpu_command_list_t *list); +void iron_gpu_command_list_wait_for_execution_to_finish(iron_gpu_command_list_t *list); +void iron_gpu_command_list_get_render_target_pixels(iron_gpu_command_list_t *list, struct iron_gpu_texture *render_target, uint8_t *data); +void iron_gpu_command_list_compute(iron_gpu_command_list_t *list, int x, int y, int z); +void iron_gpu_command_list_set_texture(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *texture); +void iron_gpu_command_list_set_texture_from_render_target_depth(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_texture_t *target); +void iron_gpu_command_list_set_sampler(iron_gpu_command_list_t *list, iron_gpu_texture_unit_t unit, iron_gpu_sampler_t *sampler); -void iron_g5_render_target_get_pixels(iron_g5_texture_t *render_target, uint8_t *data); +void iron_gpu_render_target_get_pixels(iron_gpu_texture_t *render_target, uint8_t *data); -typedef struct iron_g5_compute_shader { - iron_g5_compute_shader_impl impl; -} iron_g5_compute_shader; +typedef struct iron_gpu_compute_shader { + iron_gpu_compute_shader_impl impl; +} iron_gpu_compute_shader; -void iron_g5_compute_shader_init(iron_g5_compute_shader *shader, void *source, int length); -void iron_g5_compute_shader_destroy(iron_g5_compute_shader *shader); -iron_g5_constant_location_t iron_g5_compute_shader_get_constant_location(iron_g5_compute_shader *shader, const char *name); -iron_g5_texture_unit_t iron_g5_compute_shader_get_texture_unit(iron_g5_compute_shader *shader, const char *name); +void iron_gpu_compute_shader_init(iron_gpu_compute_shader *shader, void *source, int length); +void iron_gpu_compute_shader_destroy(iron_gpu_compute_shader *shader); +iron_gpu_constant_location_t iron_gpu_compute_shader_get_constant_location(iron_gpu_compute_shader *shader, const char *name); +iron_gpu_texture_unit_t iron_gpu_compute_shader_get_texture_unit(iron_gpu_compute_shader *shader, const char *name); -struct iron_g5_command_list; -struct iron_g5_constant_buffer; -struct iron_g5_index_buffer; -struct iron_g5_texture; -struct iron_g5_texture; -struct iron_g5_vertex_buffer; +struct iron_gpu_command_list; +struct iron_gpu_constant_buffer; +struct iron_gpu_index_buffer; +struct iron_gpu_texture; +struct iron_gpu_texture; +struct iron_gpu_vertex_buffer; -typedef struct iron_g5_raytrace_pipeline { - struct iron_g5_constant_buffer *_constant_buffer; - iron_g5_raytrace_pipeline_impl_t impl; -} iron_g5_raytrace_pipeline_t; +typedef struct iron_gpu_raytrace_pipeline { + struct iron_gpu_constant_buffer *_constant_buffer; + iron_gpu_raytrace_pipeline_impl_t impl; +} iron_gpu_raytrace_pipeline_t; -typedef struct iron_g5_raytrace_acceleration_structure { - iron_g5_raytrace_acceleration_structure_impl_t impl; -} iron_g5_raytrace_acceleration_structure_t; +typedef struct iron_gpu_raytrace_acceleration_structure { + iron_gpu_raytrace_acceleration_structure_impl_t impl; +} iron_gpu_raytrace_acceleration_structure_t; -bool iron_g5_raytrace_supported(void); -void iron_g5_raytrace_pipeline_init(iron_g5_raytrace_pipeline_t *pipeline, struct iron_g5_command_list *command_list, - void *ray_shader, int ray_shader_size, struct iron_g5_constant_buffer *constant_buffer); -void iron_g5_raytrace_pipeline_destroy(iron_g5_raytrace_pipeline_t *pipeline); +bool iron_gpu_raytrace_supported(void); +void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, struct iron_gpu_command_list *command_list, + void *ray_shader, int ray_shader_size, struct iron_gpu_constant_buffer *constant_buffer); +void iron_gpu_raytrace_pipeline_destroy(iron_gpu_raytrace_pipeline_t *pipeline); -void iron_g5_raytrace_acceleration_structure_init(iron_g5_raytrace_acceleration_structure_t *accel); -void iron_g5_raytrace_acceleration_structure_add(iron_g5_raytrace_acceleration_structure_t *accel, struct iron_g5_vertex_buffer *vb, struct iron_g5_index_buffer *ib, iron_matrix4x4_t transform); -void iron_g5_raytrace_acceleration_structure_build(iron_g5_raytrace_acceleration_structure_t *accel, struct iron_g5_command_list *command_list, - struct iron_g5_vertex_buffer *_vb_full, struct iron_g5_index_buffer *_ib_full); -void iron_g5_raytrace_acceleration_structure_destroy(iron_g5_raytrace_acceleration_structure_t *accel); +void iron_gpu_raytrace_acceleration_structure_init(iron_gpu_raytrace_acceleration_structure_t *accel); +void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration_structure_t *accel, struct iron_gpu_vertex_buffer *vb, struct iron_gpu_index_buffer *ib, iron_matrix4x4_t transform); +void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_acceleration_structure_t *accel, struct iron_gpu_command_list *command_list, + struct iron_gpu_vertex_buffer *_vb_full, struct iron_gpu_index_buffer *_ib_full); +void iron_gpu_raytrace_acceleration_structure_destroy(iron_gpu_raytrace_acceleration_structure_t *accel); -void iron_g5_raytrace_set_textures(struct iron_g5_texture *texpaint0, struct iron_g5_texture *texpaint1, struct iron_g5_texture *texpaint2, - struct iron_g5_texture *texenv, struct iron_g5_texture *texsobol, struct iron_g5_texture *texscramble, struct iron_g5_texture *texrank); -void iron_g5_raytrace_set_acceleration_structure(iron_g5_raytrace_acceleration_structure_t *accel); -void iron_g5_raytrace_set_pipeline(iron_g5_raytrace_pipeline_t *pipeline); -void iron_g5_raytrace_set_target(struct iron_g5_texture *output); -void iron_g5_raytrace_dispatch_rays(struct iron_g5_command_list *command_list); +void iron_gpu_raytrace_set_textures(struct iron_gpu_texture *texpaint0, struct iron_gpu_texture *texpaint1, struct iron_gpu_texture *texpaint2, + struct iron_gpu_texture *texenv, struct iron_gpu_texture *texsobol, struct iron_gpu_texture *texscramble, struct iron_gpu_texture *texrank); +void iron_gpu_raytrace_set_acceleration_structure(iron_gpu_raytrace_acceleration_structure_t *accel); +void iron_gpu_raytrace_set_pipeline(iron_gpu_raytrace_pipeline_t *pipeline); +void iron_gpu_raytrace_set_target(struct iron_gpu_texture *output); +void iron_gpu_raytrace_dispatch_rays(struct iron_gpu_command_list *command_list); diff --git a/base/sources/iron_ui.c b/base/sources/iron_ui.c index be2a9b0c..d6e48b59 100644 --- a/base/sources/iron_ui.c +++ b/base/sources/iron_ui.c @@ -473,7 +473,7 @@ void ui_end_element() { void ui_resize(ui_handle_t *handle, int w, int h) { handle->redraws = 2; if (handle->texture.width != 0) { - iron_g5_texture_destroy(&handle->texture); + iron_gpu_texture_destroy(&handle->texture); } if (w < 1) { w = 1; @@ -481,7 +481,7 @@ void ui_resize(ui_handle_t *handle, int w, int h) { if (h < 1) { h = 1; } - iron_g5_render_target_init(&handle->texture, w, h, IRON_IMAGE_FORMAT_RGBA32, 0); + iron_gpu_render_target_init(&handle->texture, w, h, IRON_IMAGE_FORMAT_RGBA32, 0); } bool ui_input_in_rect(float x, float y, float w, float h) { @@ -863,24 +863,24 @@ void ui_draw_combo(bool begin /*= true*/) { void ui_bake_elements() { if (current->check_select_image.width != 0) { - iron_g5_texture_destroy(¤t->check_select_image); + iron_gpu_texture_destroy(¤t->check_select_image); } float r = UI_CHECK_SELECT_SIZE(); - iron_g5_render_target_init(¤t->check_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + iron_gpu_render_target_init(¤t->check_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->check_select_image); - iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); + iron_gpu_clear(0x00000000, 0, IRON_GPU_CLEAR_COLOR); draw_set_color(0xffffffff); draw_line(0, r / 2.0, r / 2.0 - 2.0 * UI_SCALE(), r - 2.0 * UI_SCALE(), 2.0 * UI_SCALE()); draw_line(r / 2.0 - 3.0 * UI_SCALE(), r - 3.0 * UI_SCALE(), r / 2.0 + 5.0 * UI_SCALE(), r - 11.0 * UI_SCALE(), 2.0 * UI_SCALE()); draw_end(); if (current->radio_image.width != 0) { - iron_g5_texture_destroy(¤t->radio_image); + iron_gpu_texture_destroy(¤t->radio_image); } r = UI_CHECK_SIZE(); - iron_g5_render_target_init(¤t->radio_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + iron_gpu_render_target_init(¤t->radio_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->radio_image); - iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); + iron_gpu_clear(0x00000000, 0, IRON_GPU_CLEAR_COLOR); draw_set_color(0xffaaaaaa); draw_filled_circle(r / 2.0, r / 2.0, r / 2.0, 0); draw_set_color(0xffffffff); @@ -888,12 +888,12 @@ void ui_bake_elements() { draw_end(); if (current->radio_select_image.width != 0) { - iron_g5_texture_destroy(¤t->radio_select_image); + iron_gpu_texture_destroy(¤t->radio_select_image); } r = UI_CHECK_SELECT_SIZE(); - iron_g5_render_target_init(¤t->radio_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + iron_gpu_render_target_init(¤t->radio_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->radio_select_image); - iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); + iron_gpu_clear(0x00000000, 0, IRON_GPU_CLEAR_COLOR); draw_set_color(0xffaaaaaa); draw_filled_circle(r / 2.0, r / 2.0, 4.5 * UI_SCALE(), 0); draw_set_color(0xffffffff); @@ -902,22 +902,22 @@ void ui_bake_elements() { if (theme->ROUND_CORNERS) { if (current->filled_round_corner_image.width != 0) { - iron_g5_texture_destroy(¤t->filled_round_corner_image); + iron_gpu_texture_destroy(¤t->filled_round_corner_image); } r = 4.0 * UI_SCALE(); - iron_g5_render_target_init(¤t->filled_round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + iron_gpu_render_target_init(¤t->filled_round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->filled_round_corner_image); - iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); + iron_gpu_clear(0x00000000, 0, IRON_GPU_CLEAR_COLOR); draw_set_color(0xffffffff); draw_filled_circle(r, r, r, 0); draw_end(); if (current->round_corner_image.width != 0) { - iron_g5_texture_destroy(¤t->round_corner_image); + iron_gpu_texture_destroy(¤t->round_corner_image); } - iron_g5_render_target_init(¤t->round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + iron_gpu_render_target_init(¤t->round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(¤t->round_corner_image); - iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); + iron_gpu_clear(0x00000000, 0, IRON_GPU_CLEAR_COLOR); draw_set_color(0xffffffff); draw_circle(r, r, r, 0, 1); draw_end(); @@ -1502,7 +1502,7 @@ void ui_end_sticky() { draw_end(); current->sticky = false; current->scissor = true; - iron_g4_scissor(0, current->_y, current->_window_w, current->_window_h - current->_y); + gpu_scissor(0, current->_y, current->_window_w, current->_window_h - current->_y); current->window_header_h += current->_y - current->window_header_h; current->_y += current->current_window->scroll_offset; current->is_hovered = false; @@ -1517,7 +1517,7 @@ void ui_end_window(bool bind_global_g) { if (handle->redraws > 0 || current->is_scrolling) { if (current->scissor) { current->scissor = false; - iron_g4_disable_scissor(); + gpu_disable_scissor(); } if (current->tab_count > 0) { @@ -1681,10 +1681,10 @@ bool _ui_window(ui_handle_t *handle, int x, int y, int w, int h, bool drag) { current->tab_count = 0; if (theme->FILL_WINDOW_BG) { - iron_g5_clear(theme->WINDOW_BG_COL, 0, IRON_G5_CLEAR_COLOR); + iron_gpu_clear(theme->WINDOW_BG_COL, 0, IRON_GPU_CLEAR_COLOR); } else { - iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); + iron_gpu_clear(0x00000000, 0, IRON_GPU_CLEAR_COLOR); draw_set_color(theme->WINDOW_BG_COL); draw_filled_rect(current->_x, current->_y - handle->scroll_offset, handle->last_max_x, handle->last_max_y); } @@ -1709,7 +1709,7 @@ bool _ui_window(ui_handle_t *handle, int x, int y, int w, int h, bool drag) { return true; } -bool ui_button(char *text, int align, char *label/*, iron_g5_texture_t *icon, int sx, int sy, int sw, int sh*/) { +bool ui_button(char *text, int align, char *label/*, iron_gpu_texture_t *icon, int sx, int sy, int sw, int sh*/) { if (!ui_is_visible(UI_ELEMENT_H())) { ui_end_element(); return false; @@ -1843,22 +1843,22 @@ bool ui_panel(ui_handle_t *handle, char *text, bool is_tree, bool filled) { } static int image_width(void *image) { - return ((iron_g5_texture_t *)image)->width; + return ((iron_gpu_texture_t *)image)->width; } static int image_height(void *image) { - return ((iron_g5_texture_t *)image)->height; + return ((iron_gpu_texture_t *)image)->height; } static void _draw_scaled_image(void *image, float dx, float dy, float dw, float dh) { - draw_scaled_texture((iron_g5_texture_t *)image, dx, dy, dw, dh); + draw_scaled_texture((iron_gpu_texture_t *)image, dx, dy, dw, dh); } static void _draw_scaled_sub_image(void *image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { - draw_scaled_sub_texture((iron_g5_texture_t *)image, sx, sy, sw, sh, dx, dy, dw, dh); + draw_scaled_sub_texture((iron_gpu_texture_t *)image, sx, sy, sw, sh, dx, dy, dw, dh); } -int ui_sub_image(iron_g5_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh) { +int ui_sub_image(iron_gpu_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh) { float iw = (sw > 0 ? sw : image_width(image)) * UI_SCALE(); float ih = (sh > 0 ? sh : image_height(image)) * UI_SCALE(); float w = fmin(iw, current->_w); @@ -1929,7 +1929,7 @@ int ui_sub_image(iron_g5_texture_t *image, uint32_t tint, int h, int sx, int sy, return started ? UI_STATE_STARTED : released ? UI_STATE_RELEASED : down ? UI_STATE_DOWN : hover ? UI_STATE_HOVERED : UI_STATE_IDLE; } -int ui_image(iron_g5_texture_t *image, uint32_t tint, int h) { +int ui_image(iron_gpu_texture_t *image, uint32_t tint, int h) { return ui_sub_image(image, tint, h, 0, 0, image_width(image), image_height(image)); } @@ -2240,7 +2240,7 @@ void ui_tooltip(char *text) { current->tooltip_y = current->_y + current->_window_y; } -void ui_tooltip_image(iron_g5_texture_t *image, int max_width) { +void ui_tooltip_image(iron_gpu_texture_t *image, int max_width) { current->tooltip_img = image; current->tooltip_img_max_width = max_width; current->tooltip_invert_y = current->image_invert_y; diff --git a/base/sources/iron_ui.h b/base/sources/iron_ui.h index f9cd0e1c..ea027b7f 100644 --- a/base/sources/iron_ui.h +++ b/base/sources/iron_ui.h @@ -56,8 +56,8 @@ typedef struct ui_options { draw_font_t *font; ui_theme_t *theme; float scale_factor; - iron_g5_texture_t *color_wheel; - iron_g5_texture_t *black_white_gradient; + iron_gpu_texture_t *color_wheel; + iron_gpu_texture_t *black_white_gradient; } ui_options_t; typedef struct ui_handle_array { @@ -72,7 +72,7 @@ typedef struct ui_handle { uint32_t color; float value; char *text; - iron_g5_texture_t texture; + iron_gpu_texture_t texture; int redraws; float scroll_offset; bool scroll_enabled; @@ -232,7 +232,7 @@ typedef struct ui { int combo_to_submit; int combo_initial_value; char tooltip_text[512]; - iron_g5_texture_t *tooltip_img; + iron_gpu_texture_t *tooltip_img; int tooltip_img_max_width; bool tooltip_invert_y; float tooltip_x; @@ -251,11 +251,11 @@ typedef struct ui { bool scissor; bool elements_baked; - iron_g5_texture_t check_select_image; - iron_g5_texture_t radio_image; - iron_g5_texture_t radio_select_image; - iron_g5_texture_t round_corner_image; - iron_g5_texture_t filled_round_corner_image; + iron_gpu_texture_t check_select_image; + iron_gpu_texture_t radio_image; + iron_gpu_texture_t radio_select_image; + iron_gpu_texture_t round_corner_image; + iron_gpu_texture_t filled_round_corner_image; } ui_t; void ui_init(ui_t *ui, ui_options_t *ops); @@ -269,8 +269,8 @@ bool ui_button(char *text, int align, char *label); int ui_text(char *text, int align, int bg); bool ui_tab(ui_handle_t *handle, char *text, bool vertical, uint32_t color); bool ui_panel(ui_handle_t *handle, char *text, bool is_tree, bool filled); -int ui_sub_image(iron_g5_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh); -int ui_image(iron_g5_texture_t *image, uint32_t tint, int h); +int ui_sub_image(iron_gpu_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh); +int ui_image(iron_gpu_texture_t *image, uint32_t tint, int h); char *ui_text_input(ui_handle_t *handle, char *label, int align, bool editable, bool live_update); bool ui_check(ui_handle_t *handle, char *text, char *label); bool ui_radio(ui_handle_t *handle, int position, char *text, char *label); @@ -279,7 +279,7 @@ float ui_slider(ui_handle_t *handle, char *text, float from, float to, bool fill void ui_row(f32_array_t *ratios); void ui_separator(int h, bool fill); void ui_tooltip(char *text); -void ui_tooltip_image(iron_g5_texture_t *image, int max_width); +void ui_tooltip_image(iron_gpu_texture_t *image, int max_width); void _ui_end(bool last); void ui_end_window(bool bind_global_g); char *ui_hovered_tab_name(); diff --git a/base/sources/iron_ui_nodes.c b/base/sources/iron_ui_nodes.c index de81d179..ac0ddaf9 100644 --- a/base/sources/iron_ui_nodes.c +++ b/base/sources/iron_ui_nodes.c @@ -14,7 +14,7 @@ static ui_nodes_t *current_nodes = NULL; static bool ui_nodes_elements_baked = false; -static iron_g5_texture_t ui_socket_image; +static iron_gpu_texture_t ui_socket_image; static bool ui_box_select = false; static int ui_box_select_x = 0; static int ui_box_select_y = 0; @@ -236,11 +236,11 @@ int ui_get_socket_id(ui_node_array_t *nodes) { void ui_nodes_bake_elements() { if (ui_socket_image.width != 0) { - iron_g5_texture_destroy(&ui_socket_image); + iron_gpu_texture_destroy(&ui_socket_image); } - iron_g5_render_target_init(&ui_socket_image, 24, 24, IRON_IMAGE_FORMAT_RGBA32, 0); + iron_gpu_render_target_init(&ui_socket_image, 24, 24, IRON_IMAGE_FORMAT_RGBA32, 0); draw_set_render_target(&ui_socket_image); - iron_g5_clear(0x00000000, 0, IRON_G5_CLEAR_COLOR); + iron_gpu_clear(0x00000000, 0, IRON_GPU_CLEAR_COLOR); draw_set_color(0xff111111); draw_filled_circle(12, 12, 11, 0); diff --git a/base/sources/iron_video.h b/base/sources/iron_video.h index f39a5742..def35fb6 100644 --- a/base/sources/iron_video.h +++ b/base/sources/iron_video.h @@ -17,7 +17,7 @@ // void iron_video_stop(iron_video_t *video); // int iron_video_width(iron_video_t *video); // int iron_video_height(iron_video_t *video); -// iron_g5_texture_t *iron_video_current_image(iron_video_t *video); +// iron_gpu_texture_t *iron_video_current_image(iron_video_t *video); // double iron_video_duration(iron_video_t *video); // double iron_video_position(iron_video_t *video); // bool iron_video_finished(iron_video_t *video); diff --git a/base/sources/ts/base.ts b/base/sources/ts/base.ts index 246b47da..0c7d35d3 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: iron_g5_texture_t = null; +let base_drag_file_icon: iron_gpu_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: iron_g5_texture_t; -let base_color_wheel_gradient: iron_g5_texture_t; +let base_color_wheel: iron_gpu_texture_t; +let base_color_wheel_gradient: iron_gpu_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: iron_g5_texture_t = data_get_image("color_wheel.k"); - let image_color_wheel_gradient: iron_g5_texture_t = data_get_image("color_wheel_gradient.k"); + let image_color_wheel: iron_gpu_texture_t = data_get_image("color_wheel.k"); + let image_color_wheel_gradient: iron_gpu_texture_t = data_get_image("color_wheel_gradient.k"); base_font = font; config_load_theme(config_raw.theme, false); @@ -366,7 +366,7 @@ function base_update() { } else if (context_in_viewport()) { if (ends_with(to_lower_case(base_drag_asset.file), ".hdr")) { - let image: iron_g5_texture_t = project_get_image(base_drag_asset); + let image: iron_gpu_texture_t = project_get_image(base_drag_asset); import_envmap_run(base_drag_asset.file, image); } } @@ -503,14 +503,14 @@ function base_handle_drop_paths() { } function base_get_drag_background(): rect_t { - let icons: iron_g5_texture_t = resource_get("icons.k"); + let icons: iron_gpu_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(): iron_g5_texture_t { +function base_get_drag_image(): iron_gpu_texture_t { base_drag_tint = 0xffffffff; base_drag_size = -1; base_drag_rect = null; @@ -526,7 +526,7 @@ function base_get_drag_image(): iron_g5_texture_t { if (base_drag_file_icon != null) { return base_drag_file_icon; } - let icons: iron_g5_texture_t = resource_get("icons.k"); + let icons: iron_gpu_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; @@ -536,7 +536,7 @@ function base_get_drag_image(): iron_g5_texture_t { return base_drag_material.image_icon; } if (base_drag_layer != null && slot_layer_is_group(base_drag_layer)) { - let icons: iron_g5_texture_t = resource_get("icons.k"); + let icons: iron_gpu_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; @@ -584,7 +584,7 @@ function base_render() { if (base_is_dragging) { iron_set_mouse_cursor(1); // Hand - let img: iron_g5_texture_t = base_get_drag_image(); + let img: iron_gpu_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 ec3fcbd6..4104c00f 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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; draw_end(); if (history_undo_layers != null) { diff --git a/base/sources/ts/box_projects.ts b/base/sources/ts/box_projects.ts index 4746011e..19e602f9 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: iron_g5_texture_t = map_get(box_projects_icon_map, icon_path); + let icon: iron_gpu_texture_t = map_get(box_projects_icon_map, icon_path); if (icon == null) { - let image: iron_g5_texture_t = data_get_image(icon_path); + let image: iron_gpu_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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -241,7 +241,7 @@ function box_projects_recent_tab(ui: ui_t) { } function box_projects_draw_badge(ui: ui_t) { - let img: iron_g5_texture_t = data_get_image("badge.k"); + let img: iron_gpu_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 e87597bd..8c96391a 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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); render_path_base_apply_config(); diff --git a/base/sources/ts/console.ts b/base/sources/ts/console.ts index 44ca5eca..97e7f670 100644 --- a/base/sources/ts/console.ts +++ b/base/sources/ts/console.ts @@ -19,7 +19,7 @@ function console_draw_toast(s: string) { function _console_toast_render(s: string) { console_draw_toast(s); - iron_g4_swap_buffers(); + gpu_swap_buffers(); app_remove_render_2d(_console_toast_render); } @@ -27,7 +27,7 @@ function console_toast(s: string) { // Show a popup message app_notify_on_render_2d(_console_toast_render, s); console_trace(s); - iron_g4_swap_buffers(); + gpu_swap_buffers(); } function console_draw_progress() { @@ -53,7 +53,7 @@ function console_progress(s: string) { draw_end(); app_render(); draw_begin(); - iron_g4_swap_buffers(); + gpu_swap_buffers(); ///end } diff --git a/base/sources/ts/context.ts b/base/sources/ts/context.ts index cfabf0e8..66955b6b 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?: iron_g5_texture_t; - default_radiance_mipmaps?: iron_g5_texture_t[]; - saved_envmap?: iron_g5_texture_t; - empty_envmap?: iron_g5_texture_t; - preview_envmap?: iron_g5_texture_t; + default_radiance?: iron_gpu_texture_t; + default_radiance_mipmaps?: iron_gpu_texture_t[]; + saved_envmap?: iron_gpu_texture_t; + empty_envmap?: iron_gpu_texture_t; + preview_envmap?: iron_gpu_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?: iron_g5_texture_t; - node_previews?: map_t; + node_preview?: iron_gpu_texture_t; + node_previews?: map_t; node_previews_used?: string[]; node_preview_name?: string; - mask_preview_rgba32?: iron_g5_texture_t; + mask_preview_rgba32?: iron_gpu_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?: iron_g5_texture_t; + decal_image?: iron_gpu_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?: iron_g5_texture_t; + text_tool_image?: iron_gpu_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?: iron_g5_texture_t; + brush_mask_image?: iron_gpu_texture_t; brush_mask_image_is_alpha?: bool; - brush_stencil_image?: iron_g5_texture_t; + brush_stencil_image?: iron_gpu_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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); diff --git a/base/sources/ts/export_arm.ts b/base/sources/ts/export_arm.ts index f82340ca..5be0e9ed 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(iron_g4_get_texture_pixels(l.texpaint)) : null, + texpaint: l.texpaint != null ? lz4_encode(gpu_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(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, + texpaint_nor: l.texpaint_nor != null ? lz4_encode(gpu_get_texture_pixels(l.texpaint_nor)) : null, + texpaint_pack: l.texpaint_pack != null ? lz4_encode(gpu_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: iron_g5_texture_t = rt._image; - let mesh_icon: iron_g5_texture_t = iron_g4_create_render_target(256, 256); + let tex: iron_gpu_texture_t = rt._image; + let mesh_icon: iron_gpu_texture_t = gpu_create_render_target(256, 256); let r: f32 = app_w() / app_h(); draw_begin(mesh_icon); draw_scaled_image(tex, -(256 * r - 256) / 2, 0, 256 * r, 256); @@ -187,7 +187,7 @@ function export_arm_run_project() { draw_end(); ///end - let mesh_icon_pixels: buffer_t = iron_g4_get_texture_pixels(mesh_icon); + let mesh_icon_pixels: buffer_t = gpu_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,7 +196,7 @@ function export_arm_run_project() { export_arm_bgra_swap(mesh_icon_pixels); ///end - app_notify_on_next_frame(function (mesh_icon: iron_g5_texture_t) { + app_notify_on_next_frame(function (mesh_icon: iron_gpu_texture_t) { iron_unload_image(mesh_icon); }); @@ -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(iron_g4_get_texture_pixels(m.image))); + let buf: buffer_t = lz4_encode(export_arm_bgra_swap(gpu_get_texture_pixels(m.image))); ///else - let buf: buffer_t = lz4_encode(iron_g4_get_texture_pixels(m.image)); + let buf: buffer_t = lz4_encode(gpu_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", iron_g4_get_texture_pixels(m.image), m.image.width, m.image.height, 0); + iron_write_png(substring(path, 0, path.length - 4) + "_icon.png", gpu_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", iron_g4_get_texture_pixels(m.image), m.image.width, m.image.height, 0, 50); + iron_write_jpg(substring(path, 0, path.length - 4) + "_icon.jpg", gpu_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(iron_g4_get_texture_pixels(b.image))); + let buf: buffer_t = lz4_encode(export_arm_bgra_swap(gpu_get_texture_pixels(b.image))); ///else - let buf: buffer_t = lz4_encode(iron_g4_get_texture_pixels(b.image)); + let buf: buffer_t = lz4_encode(gpu_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", iron_g4_get_texture_pixels(b.image), b.image.width, b.image.height, 0); + iron_write_png(substring(path, 0, path.length - 4) + "_icon.png", gpu_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: iron_g5_texture_t[] = []; + let temp_images: iron_gpu_texture_t[] = []; for (let i: i32 = 0; i < assets.length; ++i) { if (!project_packed_asset_exists(raw.packed_assets, assets[i].file)) { - let image: iron_g5_texture_t = project_get_image(assets[i]); - let temp: iron_g5_texture_t = iron_g4_create_render_target(image.width, image.height); + let image: iron_gpu_texture_t = project_get_image(assets[i]); + let temp: iron_gpu_texture_t = gpu_create_render_target(image.width, image.height); draw_begin(temp); draw_image(image, 0, 0); draw_end(); @@ -495,15 +495,15 @@ 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(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) + iron_encode_jpg(gpu_get_texture_pixels(temp), temp.width, temp.height, 0, 80) : + iron_encode_png(gpu_get_texture_pixels(temp), temp.width, temp.height, 0) }; array_push(raw.packed_assets, pa); } } - app_notify_on_next_frame(function (temp_images: iron_g5_texture_t[]) { + app_notify_on_next_frame(function (temp_images: iron_gpu_texture_t[]) { for (let i: i32 = 0; i < temp_images.length; ++i) { - let image: iron_g5_texture_t = temp_images[i]; + let image: iron_gpu_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 aaef0758..46e41745 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 = iron_g4_get_texture_pixels(layers[0].texpaint_pack); + // let height: buffer_t = gpu_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 37215708..a53aeeba 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: iron_g5_texture_t = rt._image; + let empty: iron_gpu_texture_t = rt._image; // Append object mask name let export_selected: bool = context_raw.layers_export == export_mode_t.SELECTED; @@ -190,15 +190,15 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ } // Clear export layer - _iron_g4_begin(layers_expa); - iron_g5_clear(color_from_floats(0.0, 0.0, 0.0, 0.0)); - _iron_g4_end(); - _iron_g4_begin(layers_expb); - iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); - _iron_g4_end(); - _iron_g4_begin(layers_expc); - iron_g5_clear(color_from_floats(1.0, 0.0, 0.0, 0.0)); - _iron_g4_end(); + _gpu_begin(layers_expa); + iron_gpu_clear(color_from_floats(0.0, 0.0, 0.0, 0.0)); + _gpu_end(); + _gpu_begin(layers_expb); + iron_gpu_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); + _gpu_end(); + _gpu_begin(layers_expc); + iron_gpu_clear(color_from_floats(1.0, 0.0, 0.0, 0.0)); + _gpu_end(); // Flatten layers for (let i: i32 = 0; i < layers.length; ++i) { @@ -220,13 +220,13 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ } } - let mask: iron_g5_texture_t = empty; + let mask: iron_gpu_texture_t = empty; let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); if (l1masks != null && !bake_material) { if (l1masks.length > 1) { layers_make_temp_mask_img(); draw_begin(pipes_temp_mask_image); - iron_g5_clear(0x00000000); + iron_gpu_clear(0x00000000); draw_end(); let l1: slot_layer_t = { texpaint: pipes_temp_mask_image @@ -248,18 +248,18 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ draw_set_pipeline(null); draw_end(); - _iron_g4_begin(layers_expa); - iron_g5_set_pipeline(pipes_merge); - _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); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(layers_expa); + iron_gpu_set_pipeline(pipes_merge); + _gpu_set_texture(pipes_tex0, l1.texpaint); + _gpu_set_texture(pipes_tex1, empty); + _gpu_set_texture(pipes_texmask, mask); + _gpu_set_texture(pipes_texa, layers_temp_image); + _gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _gpu_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); } if (l1.paint_nor) { @@ -269,18 +269,18 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ draw_set_pipeline(null); draw_end(); - _iron_g4_begin(layers_expb); - iron_g5_set_pipeline(pipes_merge); - _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); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(layers_expb); + iron_gpu_set_pipeline(pipes_merge); + _gpu_set_texture(pipes_tex0, l1.texpaint); + _gpu_set_texture(pipes_tex1, l1.texpaint_nor); + _gpu_set_texture(pipes_texmask, mask); + _gpu_set_texture(pipes_texa, layers_temp_image); + _gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _gpu_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); } if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { @@ -312,9 +312,9 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ ///end ///end - let texpaint: iron_g5_texture_t = layers_expa; - let texpaint_nor: iron_g5_texture_t = layers_expb; - let texpaint_pack: iron_g5_texture_t = layers_expc; + let texpaint: iron_gpu_texture_t = layers_expa; + let texpaint_nor: iron_gpu_texture_t = layers_expb; + let texpaint_pack: iron_gpu_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 = iron_g4_get_texture_pixels(texpaint); + pixpaint = gpu_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 = iron_g4_get_texture_pixels(texpaint_nor); + pixpaint_nor = gpu_get_texture_pixels(texpaint_nor); } else if ((c == "occ" || c == "rough" || c == "metal" || c == "height" || c == "smooth") && pixpaint_pack == null) { - pixpaint_pack = iron_g4_get_texture_pixels(texpaint_pack); + pixpaint_pack = gpu_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 iron_g4_get_texture_pixels() + // Release staging memory allocated in gpu_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: iron_g5_texture_t = iron_g4_create_texture_from_bytes(pixels, res_x, res_y); + let image: iron_gpu_texture_t = gpu_create_texture_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 129fdcc5..50acdc81 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: iron_g5_texture_t = project_layers[0].texpaint; + let tex: iron_gpu_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: iron_g5_texture_t = blend0._image; - app_notify_on_next_frame(function (_texpaint_blend0: iron_g5_texture_t) { + let _texpaint_blend0: iron_gpu_texture_t = blend0._image; + app_notify_on_next_frame(function (_texpaint_blend0: iron_gpu_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 = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8, 0); + blend0._image = gpu_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: iron_g5_texture_t = blend1._image; - app_notify_on_next_frame(function (_texpaint_blend1: iron_g5_texture_t) { + let _texpaint_blend1: iron_gpu_texture_t = blend1._image; + app_notify_on_next_frame(function (_texpaint_blend1: iron_gpu_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 = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8, 0); + blend1._image = gpu_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,12 +238,12 @@ function import_arm_run_project(path: string) { array_push(project_layers, l); if (!is_group) { - let _texpaint: iron_g5_texture_t = null; - let _texpaint_nor: iron_g5_texture_t = null; - let _texpaint_pack: iron_g5_texture_t = null; + let _texpaint: iron_gpu_texture_t = null; + let _texpaint_nor: iron_gpu_texture_t = null; + let _texpaint_pack: iron_gpu_texture_t = null; if (is_mask) { - _texpaint = iron_g4_create_texture_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4), ld.res, ld.res, tex_format_t.RGBA32); + _texpaint = gpu_create_texture_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4), ld.res, ld.res, tex_format_t.RGBA32); draw_begin(l.texpaint); // draw_set_pipeline(pipes_copy8); draw_set_pipeline(project.is_bgra ? pipes_copy_bgra : pipes_copy); // Full bits for undo support, R8 is used @@ -253,7 +253,7 @@ function import_arm_run_project(path: string) { } else { // Layer // TODO: create render target from bytes - _texpaint = iron_g4_create_texture_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4 * bytes_per_pixel), ld.res, ld.res, format); + _texpaint = gpu_create_texture_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4 * bytes_per_pixel), ld.res, ld.res, format); draw_begin(l.texpaint); draw_set_pipeline(project.is_bgra ? pipes_copy_bgra : pipes_copy); draw_image(_texpaint, 0, 0); @@ -261,14 +261,14 @@ function import_arm_run_project(path: string) { draw_end(); ///if is_paint - _texpaint_nor = iron_g4_create_texture_from_bytes(lz4_decode(ld.texpaint_nor, ld.res * ld.res * 4 * bytes_per_pixel), ld.res, ld.res, format); + _texpaint_nor = gpu_create_texture_from_bytes(lz4_decode(ld.texpaint_nor, ld.res * ld.res * 4 * bytes_per_pixel), ld.res, ld.res, format); draw_begin(l.texpaint_nor); draw_set_pipeline(project.is_bgra ? pipes_copy_bgra : pipes_copy); draw_image(_texpaint_nor, 0, 0); draw_set_pipeline(null); draw_end(); - _texpaint_pack = iron_g4_create_texture_from_bytes(lz4_decode(ld.texpaint_pack, ld.res * ld.res * 4 * bytes_per_pixel), ld.res, ld.res, format); + _texpaint_pack = gpu_create_texture_from_bytes(lz4_decode(ld.texpaint_pack, ld.res * ld.res * 4 * bytes_per_pixel), ld.res, ld.res, format); draw_begin(l.texpaint_pack); draw_set_pipeline(project.is_bgra ? pipes_copy_bgra : pipes_copy); draw_image(_texpaint_pack, 0, 0); @@ -301,18 +301,18 @@ function import_arm_run_project(path: string) { l.paint_subs = ld.paint_subs; ///end - app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); ///if is_paint if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -633,7 +633,7 @@ function import_arm_make_pink(abs: string) { b[1] = 0; b[2] = 255; b[3] = 255; - let pink: iron_g5_texture_t = iron_g4_create_texture_from_bytes(b, 1, 1); + let pink: iron_gpu_texture_t = gpu_create_texture_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: iron_g5_texture_t = iron_g4_create_texture_from_encoded_bytes(pa.bytes, ends_with(pa.name, ".jpg") ? ".jpg" : ".png"); + let image: iron_gpu_texture_t = gpu_create_texture_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 372c016d..36ef7886 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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); diff --git a/base/sources/ts/import_envmap.ts b/base/sources/ts/import_envmap.ts index df7d06a9..46a4e635 100644 --- a/base/sources/ts/import_envmap.ts +++ b/base/sources/ts/import_envmap.ts @@ -1,35 +1,35 @@ -let import_envmap_pipeline: iron_g5_pipeline_t = null; -let import_envmap_params_loc: iron_g5_constant_location_t; +let import_envmap_pipeline: iron_gpu_pipeline_t = null; +let import_envmap_params_loc: iron_gpu_constant_location_t; let import_envmap_params: vec4_t = vec4_create(); let import_envmap_n: vec4_t = vec4_create(); -let import_envmap_radiance_loc: iron_g5_texture_unit_t; -let import_envmap_radiance: iron_g5_texture_t = null; -let import_envmap_radiance_cpu: iron_g5_texture_t = null; -let import_envmap_mips: iron_g5_texture_t[] = null; -let import_envmap_mips_cpu: iron_g5_texture_t[] = null; +let import_envmap_radiance_loc: iron_gpu_texture_unit_t; +let import_envmap_radiance: iron_gpu_texture_t = null; +let import_envmap_radiance_cpu: iron_gpu_texture_t = null; +let import_envmap_mips: iron_gpu_texture_t[] = null; +let import_envmap_mips_cpu: iron_gpu_texture_t[] = null; -function import_envmap_run(path: string, image: iron_g5_texture_t) { +function import_envmap_run(path: string, image: iron_gpu_texture_t) { // Init if (import_envmap_pipeline == null) { - import_envmap_pipeline = iron_g4_create_pipeline(); + import_envmap_pipeline = gpu_create_pipeline(); import_envmap_pipeline.vertex_shader = sys_get_shader("pass.vert"); import_envmap_pipeline.fragment_shader = sys_get_shader("prefilter_envmap.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); import_envmap_pipeline.input_layout = vs; import_envmap_pipeline.color_attachment_count = 1; ARRAY_ACCESS(import_envmap_pipeline.color_attachment, 0) = tex_format_t.RGBA128; - iron_g4_compile_pipeline(import_envmap_pipeline); - 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"); + gpu_compile_pipeline(import_envmap_pipeline); + import_envmap_params_loc = gpu_get_constant_location(import_envmap_pipeline, "params"); + import_envmap_radiance_loc = gpu_get_texture_unit(import_envmap_pipeline, "radiance"); - import_envmap_radiance = iron_g4_create_render_target(1024, 512, tex_format_t.RGBA128); + import_envmap_radiance = gpu_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, iron_g4_create_render_target(w, w > 1 ? math_floor(w / 2) : 1, tex_format_t.RGBA128)); + array_push(import_envmap_mips, gpu_create_render_target(w, w > 1 ? math_floor(w / 2) : 1, tex_format_t.RGBA128)); w = math_floor(w / 2); } } @@ -41,20 +41,20 @@ function import_envmap_run(path: string, image: iron_g5_texture_t) { draw_set_pipeline(null); draw_end(); - let radiance_pixels: buffer_t = iron_g4_get_texture_pixels(import_envmap_radiance); + let radiance_pixels: buffer_t = gpu_get_texture_pixels(import_envmap_radiance); if (import_envmap_radiance_cpu != null) { - let _radiance_cpu: iron_g5_texture_t = import_envmap_radiance_cpu; - app_notify_on_next_frame(function (_radiance_cpu: iron_g5_texture_t) { + let _radiance_cpu: iron_gpu_texture_t = import_envmap_radiance_cpu; + app_notify_on_next_frame(function (_radiance_cpu: iron_gpu_texture_t) { iron_unload_image(_radiance_cpu); }, _radiance_cpu); } - import_envmap_radiance_cpu = iron_g4_create_texture_from_bytes(radiance_pixels, import_envmap_radiance.width, import_envmap_radiance.height, tex_format_t.RGBA128); + import_envmap_radiance_cpu = gpu_create_texture_from_bytes(radiance_pixels, import_envmap_radiance.width, import_envmap_radiance.height, tex_format_t.RGBA128); // Radiance if (import_envmap_mips_cpu != null) { for (let i: i32 = 0; i < import_envmap_mips_cpu.length; ++i) { - let mip: iron_g5_texture_t = import_envmap_mips_cpu[i]; - app_notify_on_next_frame(function (mip: iron_g5_texture_t) { + let mip: iron_gpu_texture_t = import_envmap_mips_cpu[i]; + app_notify_on_next_frame(function (mip: iron_gpu_texture_t) { ///if (!arm_direct3d12) // TODO: crashes after 50+ imports iron_unload_image(mip); ///end @@ -64,9 +64,9 @@ function import_envmap_run(path: string, image: iron_g5_texture_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, iron_g4_create_texture_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)); + array_push(import_envmap_mips_cpu, gpu_create_texture_from_bytes(gpu_get_texture_pixels(import_envmap_mips[i]), import_envmap_mips[i].width, import_envmap_mips[i].height, tex_format_t.RGBA128)); } - iron_g4_set_mipmaps(import_envmap_radiance_cpu, import_envmap_mips_cpu); + gpu_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,16 +86,16 @@ function import_envmap_run(path: string, image: iron_g5_texture_t) { project_raw.envmap = path; } -function import_envmap_get_radiance_mip(mip: iron_g5_texture_t, level: i32, radiance: iron_g5_texture_t) { - _iron_g4_begin(mip); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g5_set_pipeline(import_envmap_pipeline); +function import_envmap_get_radiance_mip(mip: iron_gpu_texture_t, level: i32, radiance: iron_gpu_texture_t) { + _gpu_begin(mip); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + iron_gpu_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); - _iron_g4_set_texture(import_envmap_radiance_loc, radiance); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_set_float4(import_envmap_params_loc, import_envmap_params.x, import_envmap_params.y, import_envmap_params.z, import_envmap_params.w); + _gpu_set_texture(import_envmap_radiance_loc, radiance); + gpu_draw_indexed_vertices(); + _gpu_end(); } function import_envmap_reverse_equirect(x: f32, y: f32): vec4_t { diff --git a/base/sources/ts/import_texture.ts b/base/sources/ts/import_texture.ts index 72bc08a8..b1f71bfa 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: iron_g5_texture_t; + image: iron_gpu_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: iron_g5_texture_t = data_get_image(path); + let image: iron_gpu_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)=>iron_g5_texture_t + let importer: any = map_get(path_texture_importers, ext); // JSValue -> (s: string)=>iron_gpu_texture_t let cached: bool = map_get(data_cached_images, path) != null; // Already loaded or pink texture for missing file - let image: iron_g5_texture_t; + let image: iron_gpu_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): iron_g5_texture_t { +function import_texture_default_importer(path: string): iron_gpu_texture_t { return data_get_image(path); } diff --git a/base/sources/ts/iron/const_data.ts b/base/sources/ts/iron/const_data.ts index 1b3cab34..f3ed0d5e 100644 --- a/base/sources/ts/iron/const_data.ts +++ b/base/sources/ts/iron/const_data.ts @@ -1,8 +1,8 @@ -let const_data_screen_aligned_vb: iron_g5_vertex_buffer_t = null; -let const_data_screen_aligned_ib: iron_g5_index_buffer_t = null; -let const_data_skydome_vb: iron_g5_vertex_buffer_t = null; -let const_data_skydome_ib: iron_g5_index_buffer_t = null; +let const_data_screen_aligned_vb: iron_gpu_vertex_buffer_t = null; +let const_data_screen_aligned_ib: iron_gpu_index_buffer_t = null; +let const_data_skydome_vb: iron_gpu_vertex_buffer_t = null; +let const_data_skydome_ib: iron_gpu_index_buffer_t = null; function const_data_create_screen_aligned_data() { // Over-sized triangle @@ -10,21 +10,21 @@ function const_data_create_screen_aligned_data() { let indices: i32[] = [0, 1, 2]; // Mandatory vertex data names and sizes - let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_2X); - const_data_screen_aligned_vb = iron_g4_create_vertex_buffer(math_floor(data.length / math_floor(iron_g5_vertex_struct_size(structure) / 4)), structure, usage_t.STATIC); - let vertices: buffer_t = iron_g4_lock_vertex_buffer(const_data_screen_aligned_vb); + let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(structure, "pos", vertex_data_t.F32_2X); + const_data_screen_aligned_vb = gpu_create_vertex_buffer(math_floor(data.length / math_floor(iron_gpu_vertex_struct_size(structure) / 4)), structure, usage_t.STATIC); + let vertices: buffer_t = gpu_lock_vertex_buffer(const_data_screen_aligned_vb); for (let i: i32 = 0; i < math_floor((vertices.length) / 4); ++i) { buffer_set_f32(vertices, i * 4, data[i]); } - iron_g4_vertex_buffer_unlock_all(const_data_screen_aligned_vb); + gpu_vertex_buffer_unlock_all(const_data_screen_aligned_vb); - const_data_screen_aligned_ib = iron_g4_create_index_buffer(indices.length); - let id: u32_array_t = iron_g4_lock_index_buffer(const_data_screen_aligned_ib); + const_data_screen_aligned_ib = gpu_create_index_buffer(indices.length); + let id: u32_array_t = gpu_lock_index_buffer(const_data_screen_aligned_ib); for (let i: i32 = 0; i < id.length; ++i) { id[i] = indices[i]; } - iron_g4_index_buffer_unlock_all(const_data_screen_aligned_ib); + gpu_index_buffer_unlock_all(const_data_screen_aligned_ib); } ///include "const_data.h" @@ -36,12 +36,12 @@ declare let _const_data_skydome_nor: f32_ptr; declare let _const_data_skydome_nor_count: i32; function const_data_create_skydome_data() { - let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(structure, "nor", vertex_data_t.F32_3X); - let struct_length: i32 = math_floor(iron_g5_vertex_struct_size(structure) / 4); - const_data_skydome_vb = iron_g4_create_vertex_buffer(math_floor(_const_data_skydome_pos_count / 3), structure, usage_t.STATIC); - let vertices: buffer_t = iron_g4_lock_vertex_buffer(const_data_skydome_vb); + let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(structure, "nor", vertex_data_t.F32_3X); + let struct_length: i32 = math_floor(iron_gpu_vertex_struct_size(structure) / 4); + const_data_skydome_vb = gpu_create_vertex_buffer(math_floor(_const_data_skydome_pos_count / 3), structure, usage_t.STATIC); + let vertices: buffer_t = gpu_lock_vertex_buffer(const_data_skydome_vb); for (let i: i32 = 0; i < math_floor((vertices.length) / 4 / struct_length); ++i) { buffer_set_f32(vertices, (i * struct_length) * 4, ARRAY_ACCESS(_const_data_skydome_pos, i * 3)); buffer_set_f32(vertices, (i * struct_length + 1) * 4, ARRAY_ACCESS(_const_data_skydome_pos, i * 3 + 1)); @@ -50,12 +50,12 @@ function const_data_create_skydome_data() { buffer_set_f32(vertices, (i * struct_length + 4) * 4, ARRAY_ACCESS(_const_data_skydome_nor, i * 3 + 1)); buffer_set_f32(vertices, (i * struct_length + 5) * 4, ARRAY_ACCESS(_const_data_skydome_nor, i * 3 + 2)); } - iron_g4_vertex_buffer_unlock_all(const_data_skydome_vb); + gpu_vertex_buffer_unlock_all(const_data_skydome_vb); - const_data_skydome_ib = iron_g4_create_index_buffer(_const_data_skydome_indices_count); - let id: u32_array_t = iron_g4_lock_index_buffer(const_data_skydome_ib); + const_data_skydome_ib = gpu_create_index_buffer(_const_data_skydome_indices_count); + let id: u32_array_t = gpu_lock_index_buffer(const_data_skydome_ib); for (let i: i32 = 0; i < id.length; ++i) { id[i] = ARRAY_ACCESS(_const_data_skydome_indices, i); } - iron_g4_index_buffer_unlock_all(const_data_skydome_ib); + gpu_index_buffer_unlock_all(const_data_skydome_ib); } diff --git a/base/sources/ts/iron/data.ts b/base/sources/ts/iron/data.ts index bf27c056..0e64f314 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): iron_g5_texture_t { - let cached: iron_g5_texture_t = map_get(data_cached_images, file); +function data_get_image(file: string, readable: bool = false): iron_gpu_texture_t { + let cached: iron_gpu_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): iron_g5_texture_t return null; } - let b: iron_g5_texture_t = image_; + let b: iron_gpu_texture_t = image_; map_set(data_cached_images, file, b); data_assets_loaded++; return b; @@ -185,7 +185,7 @@ function data_delete_blob(handle: string) { } function data_delete_image(handle: string) { - let image: iron_g5_texture_t = map_get(data_cached_images, handle); + let image: iron_gpu_texture_t = map_get(data_cached_images, handle); if (image == null) { return; } @@ -246,7 +246,7 @@ function data_delete_all() { let cached_images_keys: string[] = map_keys(data_cached_images); for (let i: i32 = 0; i < cached_images_keys.length; ++i) { - let c: iron_g5_texture_t = map_get(data_cached_images, cached_images_keys[i]); + let c: iron_gpu_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/iron.ts b/base/sources/ts/iron/iron.ts index c45648c7..1775afbd 100644 --- a/base/sources/ts/iron/iron.ts +++ b/base/sources/ts/iron/iron.ts @@ -183,7 +183,7 @@ declare function color_set_ab(c: i32, i: u8): i32; declare function _iron_init(ops: iron_window_options_t): void; declare function iron_set_app_name(name: string): void; declare function iron_log(v: any): void; -declare function iron_g5_clear(color: i32, depth: f32 = 0.0, flags: i32 = clear_flag_t.COLOR): void; +declare function iron_gpu_clear(color: i32, depth: f32 = 0.0, flags: i32 = clear_flag_t.COLOR): void; declare function _iron_set_update_callback(callback: ()=>void): void; declare function _iron_set_drop_files_callback(callback: (file: string)=>void): void; declare function iron_set_cut_copy_paste_callback(on_cut: ()=>string, on_copy: ()=>string, on_paste: (text: string)=>void): void; @@ -211,26 +211,26 @@ declare function iron_mouse_set_position(x: i32, y: i32): void; declare function iron_show_mouse(show: bool): void; declare function iron_show_keyboard(show: bool): void; -declare function iron_g4_create_index_buffer(count: i32): any; -declare function iron_g4_delete_index_buffer(buffer: any): void; -declare function iron_g4_lock_index_buffer(buffer: any): u32_array_t; -declare function iron_g4_index_buffer_unlock_all(buffer: any): void; -declare function iron_g4_set_index_buffer(buffer: any): void; -declare function iron_g4_create_vertex_buffer(count: i32, structure: iron_g5_vertex_structure_t, usage: i32): any; -declare function iron_g4_delete_vertex_buffer(buffer: any): void; -declare function iron_g4_lock_vertex_buffer(buffer: any): buffer_t; -declare function iron_g4_vertex_buffer_unlock_all(buffer: any): void; -declare function iron_g4_set_vertex_buffer(buffer: any): void; -declare function iron_g4_draw_indexed_vertices(start: i32 = 0, count: i32 = -1): void; -declare function iron_g4_create_shader(data: buffer_t, type: i32): iron_g5_shader_t; -declare function iron_g4_create_shader_from_source(source: string, shader_type: shader_type_t): iron_g5_shader_t; -declare function iron_g5_shader_destroy(shader: iron_g5_shader_t): void; -declare function iron_g4_create_pipeline(): any; -declare function iron_g4_delete_pipeline(pipeline: any): void; -declare function iron_g4_compile_pipeline(pipeline: any): void; -declare function iron_g5_set_pipeline(pipeline: any): void; +declare function gpu_create_index_buffer(count: i32): any; +declare function gpu_delete_index_buffer(buffer: any): void; +declare function gpu_lock_index_buffer(buffer: any): u32_array_t; +declare function gpu_index_buffer_unlock_all(buffer: any): void; +declare function gpu_set_index_buffer(buffer: any): void; +declare function gpu_create_vertex_buffer(count: i32, structure: iron_gpu_vertex_structure_t, usage: i32): any; +declare function gpu_delete_vertex_buffer(buffer: any): void; +declare function gpu_lock_vertex_buffer(buffer: any): buffer_t; +declare function gpu_vertex_buffer_unlock_all(buffer: any): void; +declare function gpu_set_vertex_buffer(buffer: any): void; +declare function gpu_draw_indexed_vertices(start: i32 = 0, count: i32 = -1): void; +declare function gpu_create_shader(data: buffer_t, type: i32): iron_gpu_shader_t; +declare function gpu_create_shader_from_source(source: string, shader_type: shader_type_t): iron_gpu_shader_t; +declare function iron_gpu_shader_destroy(shader: iron_gpu_shader_t): void; +declare function gpu_create_pipeline(): any; +declare function gpu_delete_pipeline(pipeline: any): void; +declare function gpu_compile_pipeline(pipeline: any): void; +declare function iron_gpu_set_pipeline(pipeline: any): void; declare function iron_load_image(file: string, readable: bool): any; -declare function iron_unload_image(image: iron_g5_texture_t): void; +declare function iron_unload_image(image: iron_gpu_texture_t): void; declare function iron_load_sound(file: string): any; declare function iron_a1_sound_destroy(sound: any): void; declare function iron_a1_play_sound(sound: any, loop: bool, pitch: f32, unique: bool): audio_channel_t; @@ -240,20 +240,20 @@ declare function iron_load_blob(file: string): buffer_t; declare function iron_load_url(url: string): void; declare function iron_copy_to_clipboard(text: string): void; -declare function iron_g4_get_constant_location(pipeline: any, name: string): any; -declare function iron_g4_get_texture_unit(pipeline: any, name: string): any; -declare function _iron_g4_set_texture(stage: any, texture: any): void; -declare function iron_g4_set_texture_depth(unit: any, texture: any): void; -declare function iron_g4_set_texture_parameters(tex_unit: any, u_addr: i32, v_addr: i32, min_filter: i32, mag_filter: i32, mip_filter: i32): void; -declare function _iron_g4_set_bool(location: any, value: bool): void; -declare function _iron_g4_set_int(location: any, value: i32): void; -declare function _iron_g4_set_float(location: any, value: f32): void; -declare function _iron_g4_set_float2(location: any, value1: f32, value2: f32): void; -declare function _iron_g4_set_float3(location: any, value1: f32, value2: f32, value3: f32): void; -declare function _iron_g4_set_float4(location: any, value1: f32, value2: f32, value3: f32, value4: f32): void; -declare function _iron_g4_set_floats(location: any, values: f32_array_t): void; -declare function _iron_g4_set_matrix4(location: any, matrix: mat4_t): void; -declare function _iron_g4_set_matrix3(location: any, matrix: mat3_t): void; +declare function gpu_get_constant_location(pipeline: any, name: string): any; +declare function gpu_get_texture_unit(pipeline: any, name: string): any; +declare function _gpu_set_texture(stage: any, texture: any): void; +declare function gpu_set_texture_depth(unit: any, texture: any): void; +declare function gpu_set_texture_parameters(tex_unit: any, u_addr: i32, v_addr: i32, min_filter: i32, mag_filter: i32, mip_filter: i32): void; +declare function _gpu_set_bool(location: any, value: bool): void; +declare function _gpu_set_int(location: any, value: i32): void; +declare function _gpu_set_float(location: any, value: f32): void; +declare function _gpu_set_float2(location: any, value1: f32, value2: f32): void; +declare function _gpu_set_float3(location: any, value1: f32, value2: f32, value3: f32): void; +declare function _gpu_set_float4(location: any, value1: f32, value2: f32, value3: f32, value4: f32): void; +declare function _gpu_set_floats(location: any, values: f32_array_t): void; +declare function _gpu_set_matrix4(location: any, matrix: mat4_t): void; +declare function _gpu_set_matrix3(location: any, matrix: mat3_t): void; declare function iron_time(): f32; declare function iron_window_width(): i32; @@ -274,19 +274,19 @@ 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 = tex_format_t.RGBA32, depth_buffer_bits: i32 = 0): any; -declare function iron_g4_create_texture_from_bytes(data: buffer_t, width: i32, height: i32, format: i32 = tex_format_t.RGBA32, readable: bool = true): any; -declare function iron_g4_create_texture_from_encoded_bytes(data: buffer_t, format: string, readable: bool = false): any; -declare function iron_g4_get_texture_pixels(texture: any): buffer_t; -declare function iron_g5_texture_generate_mipmaps(texture: any, levels: i32): void; -declare function iron_g4_set_mipmaps(texture: any, mipmaps: iron_g5_texture_t[]): void; -declare function iron_g5_render_target_set_depth_from(target: any, source: any): void; -declare function iron_g4_viewport(x: i32, y: i32, width: i32, height: i32): void; -declare function iron_g4_scissor(x: i32, y: i32, width: i32, height: i32): void; -declare function iron_g4_disable_scissor(): void; -declare function _iron_g4_begin(render_target: iron_g5_texture_t, additional: iron_g5_texture_t[] = null): void; -declare function _iron_g4_end(): void; -declare function iron_g4_swap_buffers(): void; +declare function gpu_create_render_target(width: i32, height: i32, format: i32 = tex_format_t.RGBA32, depth_buffer_bits: i32 = 0): any; +declare function gpu_create_texture_from_bytes(data: buffer_t, width: i32, height: i32, format: i32 = tex_format_t.RGBA32, readable: bool = true): any; +declare function gpu_create_texture_from_encoded_bytes(data: buffer_t, format: string, readable: bool = false): any; +declare function gpu_get_texture_pixels(texture: any): buffer_t; +declare function iron_gpu_texture_generate_mipmaps(texture: any, levels: i32): void; +declare function gpu_set_mipmaps(texture: any, mipmaps: iron_gpu_texture_t[]): void; +declare function iron_gpu_render_target_set_depth_from(target: any, source: any): void; +declare function gpu_viewport(x: i32, y: i32, width: i32, height: i32): void; +declare function gpu_scissor(x: i32, y: i32, width: i32, height: i32): void; +declare function gpu_disable_scissor(): void; +declare function _gpu_begin(render_target: iron_gpu_texture_t, additional: iron_gpu_texture_t[] = null): void; +declare function _gpu_end(): void; +declare function gpu_swap_buffers(): void; declare function iron_file_save_bytes(path: string, bytes: buffer_t, length?: i32): void; declare function iron_sys_command(cmd: string): i32; declare function iron_internal_save_path(): string; @@ -296,12 +296,12 @@ declare function iron_get_files_location(): string; declare function _iron_http_request(url: string, size: i32, callback: (url: string, _: buffer_t)=>void): void; 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(render_target: iron_g5_texture_t = null): void; +declare function draw_begin(render_target: iron_gpu_texture_t = null): void; declare function draw_end(): void; -declare function draw_scaled_sub_image(image: iron_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: iron_g5_texture_t, x: f32, y: f32, sx: f32, sy: f32, sw: f32, sh: f32): void; -declare function draw_scaled_image(image: iron_g5_texture_t, dx: f32, dy: f32, dw: f32, dh: f32): void; -declare function draw_image(image: iron_g5_texture_t, x: f32, y: f32): void; +declare function draw_scaled_sub_image(image: iron_gpu_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: iron_gpu_texture_t, x: f32, y: f32, sx: f32, sy: f32, sw: f32, sh: f32): void; +declare function draw_scaled_image(image: iron_gpu_texture_t, dx: f32, dy: f32, dw: f32, dh: f32): void; +declare function draw_image(image: iron_gpu_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; @@ -358,13 +358,13 @@ declare function iron_mp4_encode(pixels: buffer_t): void; declare function iron_ml_inference(model: buffer_t, tensors: buffer_t[], input_shape?: i32[][], output_shape?: i32[], use_gpu?: bool): buffer_t; declare function iron_ml_unload(): void; -declare function iron_g5_raytrace_supported(): bool; +declare function iron_gpu_raytrace_supported(): bool; declare function iron_raytrace_init(shader: buffer_t): void; 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: iron_g5_texture_t, tex1: iron_g5_texture_t, tex2: iron_g5_texture_t, texenv: any, tex_sobol: any, tex_scramble: any, tex_rank: any): void; +declare function iron_raytrace_set_textures(tex0: iron_gpu_texture_t, tex1: iron_gpu_texture_t, tex2: iron_gpu_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 iron_window_x(): i32; @@ -579,22 +579,22 @@ declare function f32_nan(): f32; declare function f32_isnan(f: f32): bool; -function g4_vertex_struct_create(): iron_g5_vertex_structure_t { - let raw: iron_g5_vertex_structure_t = {}; +function gpu_vertex_struct_create(): iron_gpu_vertex_structure_t { + let raw: iron_gpu_vertex_structure_t = {}; return raw; } -function g4_vertex_struct_add(raw: iron_g5_vertex_structure_t, name: string, data: vertex_data_t) { - let e: iron_g5_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw.elements, raw.size)); +function gpu_vertex_struct_add(raw: iron_gpu_vertex_structure_t, name: string, data: vertex_data_t) { + let e: iron_gpu_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw.elements, raw.size)); e.name = name; e.data = data; raw.size++; } -declare function iron_g5_vertex_struct_size(s: iron_g5_vertex_structure_t): i32; -declare function iron_g5_vertex_data_size(data: vertex_data_t); +declare function iron_gpu_vertex_struct_size(s: iron_gpu_vertex_structure_t): i32; +declare function iron_gpu_vertex_data_size(data: vertex_data_t); -declare type iron_g5_pipeline_t = { +declare type iron_gpu_pipeline_t = { input_layout?: any; vertex_shader?: any; fragment_shader?: any; @@ -620,30 +620,30 @@ declare type iron_g5_pipeline_t = { impl?: any; }; -declare type iron_g5_shader_t = { +declare type iron_gpu_shader_t = { impl?: any; }; -declare type iron_g5_vertex_element_t = { +declare type iron_gpu_vertex_element_t = { name?: string; data?: vertex_data_t; }; -declare type iron_g5_vertex_structure_t = { - elements?: any; // iron_g5_vertex_element_t[IRON_G5_MAX_VERTEX_ELEMENTS]; +declare type iron_gpu_vertex_structure_t = { + elements?: any; // iron_gpu_vertex_element_t[IRON_GPU_MAX_VERTEX_ELEMENTS]; size?: i32; }; -declare type iron_g5_index_buffer_t = { +declare type iron_gpu_index_buffer_t = { impl?: any; }; -declare type iron_g5_vertex_buffer_t = { +declare type iron_gpu_vertex_buffer_t = { impl?: any; }; -declare type iron_g5_constant_location_t = any; -declare type iron_g5_texture_unit_t = any; +declare type iron_gpu_constant_location_t = any; +declare type iron_gpu_texture_unit_t = any; enum clear_flag_t { COLOR = 1, diff --git a/base/sources/ts/iron/material_data.ts b/base/sources/ts/iron/material_data.ts index 49aa2808..d4ff0041 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: iron_g5_texture_t = data_get_image(tex.file, false); + let image: iron_gpu_texture_t = data_get_image(tex.file, false); array_push(raw._.textures, image); // Set mipmaps if (tex.mipmaps != null) { - let mipmaps: iron_g5_texture_t[] = []; + let mipmaps: iron_gpu_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: iron_g5_texture_t = data_get_image(name); + let mipimg: iron_gpu_texture_t = data_get_image(name); mipmaps[j] = mipimg; } - iron_g4_set_mipmaps(image, mipmaps); + gpu_set_mipmaps(image, mipmaps); tex.mipmaps = null; tex.generate_mipmaps = false; } else if (tex.generate_mipmaps == true && image != null) { - iron_g5_texture_generate_mipmaps(image, 1000); + iron_gpu_texture_generate_mipmaps(image, 1000); tex.mipmaps = null; tex.generate_mipmaps = false; } diff --git a/base/sources/ts/iron/mesh_data.ts b/base/sources/ts/iron/mesh_data.ts index 9853cb41..aa12c41b 100644 --- a/base/sources/ts/iron/mesh_data.ts +++ b/base/sources/ts/iron/mesh_data.ts @@ -104,10 +104,10 @@ function mesh_data_create(raw: mesh_data_t): mesh_data_t { return raw; } -function mesh_data_get_vertex_struct(vertex_arrays: vertex_array_t[]): iron_g5_vertex_structure_t { - let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); +function mesh_data_get_vertex_struct(vertex_arrays: vertex_array_t[]): iron_gpu_vertex_structure_t { + let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); for (let i: i32 = 0; i < vertex_arrays.length; ++i) { - g4_vertex_struct_add(structure, vertex_arrays[i].attrib, mesh_data_get_vertex_data(vertex_arrays[i].data)); + gpu_vertex_struct_add(structure, vertex_arrays[i].attrib, mesh_data_get_vertex_data(vertex_arrays[i].data)); } return structure; } @@ -165,13 +165,13 @@ function mesh_data_get_vertex_array(raw: mesh_data_t, name: string): vertex_arra return null; } -function mesh_data_get(raw: mesh_data_t, vs: vertex_element_t[]): iron_g5_vertex_buffer_t { +function mesh_data_get(raw: mesh_data_t, vs: vertex_element_t[]): iron_gpu_vertex_buffer_t { let key: string = ""; for (let i: i32 = 0; i < vs.length; ++i) { let e: vertex_element_t = vs[i]; key += e.name; } - let vb: iron_g5_vertex_buffer_t = map_get(raw._.vertex_buffer_map, key); + let vb: iron_gpu_vertex_buffer_t = map_get(raw._.vertex_buffer_map, key); if (vb == null) { let vertex_arrays: vertex_array_t[] = []; let has_tex: bool = false; @@ -196,12 +196,12 @@ function mesh_data_get(raw: mesh_data_t, vs: vertex_element_t[]): iron_g5_vertex let positions: vertex_array_t = mesh_data_get_vertex_array(raw, "pos"); let uvs: vertex_array_t = mesh_data_get_vertex_array(raw, "tex"); let cols: vertex_array_t = mesh_data_get_vertex_array(raw, "col"); - let vstruct: iron_g5_vertex_structure_t = mesh_data_get_vertex_struct(vertex_arrays); + let vstruct: iron_gpu_vertex_structure_t = mesh_data_get_vertex_struct(vertex_arrays); let size: i32 = mesh_data_get_vertex_size(positions.data); - vb = iron_g4_create_vertex_buffer(math_floor(positions.values.length / size), vstruct, usage_t.STATIC); - raw._.vertices = iron_g4_lock_vertex_buffer(vb); + vb = gpu_create_vertex_buffer(math_floor(positions.values.length / size), vstruct, usage_t.STATIC); + raw._.vertices = gpu_lock_vertex_buffer(vb); mesh_data_build_vertices(raw._.vertices, vertex_arrays, 0, has_tex && uvs == null, tex_offset); - iron_g4_vertex_buffer_unlock_all(vb); + gpu_vertex_buffer_unlock_all(vb); map_set(raw._.vertex_buffer_map, key, vb); if (has_tex && uvs == null) { iron_log("Geometry " + raw.name + " is missing UV map"); @@ -220,14 +220,14 @@ function mesh_data_build(raw: mesh_data_t) { let positions: vertex_array_t = mesh_data_get_vertex_array(raw, "pos"); let size: i32 = mesh_data_get_vertex_size(positions.data); - raw._.vertex_buffer = iron_g4_create_vertex_buffer(math_floor(positions.values.length / size), raw._.structure, usage_t.STATIC); - raw._.vertices = iron_g4_lock_vertex_buffer(raw._.vertex_buffer); + raw._.vertex_buffer = gpu_create_vertex_buffer(math_floor(positions.values.length / size), raw._.structure, usage_t.STATIC); + raw._.vertices = gpu_lock_vertex_buffer(raw._.vertex_buffer); mesh_data_build_vertices(raw._.vertices, raw.vertex_arrays); - iron_g4_vertex_buffer_unlock_all(raw._.vertex_buffer); + gpu_vertex_buffer_unlock_all(raw._.vertex_buffer); let struct_str: string = ""; for (let i: i32 = 0; i < raw._.structure.size; ++i) { - let e: iron_g5_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw._.structure.elements, i)); + let e: iron_gpu_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw._.structure.elements, i)); struct_str += e.name; } map_set(raw._.vertex_buffer_map, struct_str, raw._.vertex_buffer); @@ -239,14 +239,14 @@ function mesh_data_build(raw: mesh_data_t) { if (id.length == 0) { continue; } - let index_buffer: iron_g5_index_buffer_t = iron_g4_create_index_buffer(id.length); + let index_buffer: iron_gpu_index_buffer_t = gpu_create_index_buffer(id.length); - let indices_array: u32_array_t = iron_g4_lock_index_buffer(index_buffer); + let indices_array: u32_array_t = gpu_lock_index_buffer(index_buffer); for (let i: i32 = 0; i < indices_array.length; ++i) { indices_array[i] = id[i]; } - iron_g4_index_buffer_unlock_all(index_buffer); + gpu_index_buffer_unlock_all(index_buffer); array_push(raw._.index_buffers, index_buffer); } @@ -340,13 +340,13 @@ function mesh_data_calculate_aabb(raw: mesh_data_t): vec4_t { function mesh_data_delete(raw: mesh_data_t) { let vertex_buffer_keys: string[] = map_keys(raw._.vertex_buffer_map); for (let i: i32 = 0; i < vertex_buffer_keys.length; ++i) { - let buf: iron_g5_vertex_buffer_t = map_get(raw._.vertex_buffer_map, vertex_buffer_keys[i]); + let buf: iron_gpu_vertex_buffer_t = map_get(raw._.vertex_buffer_map, vertex_buffer_keys[i]); if (buf != null) { - iron_g4_delete_vertex_buffer(buf); + gpu_delete_vertex_buffer(buf); } } for (let i: i32 = 0; i < raw._.index_buffers.length; ++i) { - let buf: iron_g5_index_buffer_t = raw._.index_buffers[i]; - iron_g4_delete_index_buffer(buf); + let buf: iron_gpu_index_buffer_t = raw._.index_buffers[i]; + gpu_delete_index_buffer(buf); } } diff --git a/base/sources/ts/iron/mesh_object.ts b/base/sources/ts/iron/mesh_object.ts index 79d947a5..ab1bcc21 100644 --- a/base/sources/ts/iron/mesh_object.ts +++ b/base/sources/ts/iron/mesh_object.ts @@ -12,7 +12,7 @@ type mesh_object_t = { prev_matrix?: mat4_t; }; -let _mesh_object_last_pipeline: iron_g5_pipeline_t = null; +let _mesh_object_last_pipeline: iron_gpu_pipeline_t = null; let _mesh_object_material_contexts: material_context_t[] = []; let _mesh_object_shader_contexts: shader_context_t[] = []; @@ -172,7 +172,7 @@ function mesh_object_render(raw: mesh_object_t, context: string, bind_params: st // Uniforms if (scontext._.pipe_state != _mesh_object_last_pipeline) { - iron_g5_set_pipeline(scontext._.pipe_state); + iron_gpu_set_pipeline(scontext._.pipe_state); _mesh_object_last_pipeline = scontext._.pipe_state; } uniforms_set_context_consts(scontext, bind_params); @@ -181,9 +181,9 @@ function mesh_object_render(raw: mesh_object_t, context: string, bind_params: st uniforms_set_material_consts(scontext, material_contexts[mi]); } - iron_g4_set_vertex_buffer(mesh_data_get(raw.data, elems)); - iron_g4_set_index_buffer(raw.data._.index_buffers[i]); - iron_g4_draw_indexed_vertices(); + gpu_set_vertex_buffer(mesh_data_get(raw.data, elems)); + gpu_set_index_buffer(raw.data._.index_buffers[i]); + gpu_draw_indexed_vertices(); } raw.prev_matrix = mat4_clone(raw.base.transform.world_unpack); diff --git a/base/sources/ts/iron/render_path.ts b/base/sources/ts/iron/render_path.ts index fc8b2d7b..046a0e1c 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?: iron_g5_texture_t; // RT or image + _image?: iron_gpu_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: iron_g5_texture_t = null; +let _render_path_current_image: iron_gpu_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: iron_g5_texture_t[] = null; + let additional_images: iron_gpu_texture_t[] = null; if (additional != null) { additional_images = []; for (let i: i32 = 0; i < additional.length; ++i) { @@ -108,33 +108,33 @@ 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); - iron_g5_render_target_set_depth_from(rt._image, rt_from._image); + iron_gpu_render_target_set_depth_from(rt._image, rt_from._image); } -function render_path_begin(render_target: iron_g5_texture_t = null, additional_targets: iron_g5_texture_t[] = null) { +function render_path_begin(render_target: iron_gpu_texture_t = null, additional_targets: iron_gpu_texture_t[] = null) { if (_render_path_current_image != null) { render_path_end(); } _render_path_current_image = render_target; - _iron_g4_begin(render_target, additional_targets); + _gpu_begin(render_target, additional_targets); } function render_path_end() { if (_render_path_scissor_set) { - iron_g4_disable_scissor(); + gpu_disable_scissor(); _render_path_scissor_set = false; } - _iron_g4_end(); + _gpu_end(); _render_path_current_image = null; _render_path_bind_params = null; } function render_path_set_current_viewport(view_w: i32, view_h: i32) { - iron_g4_viewport(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); + gpu_viewport(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); } function render_path_set_current_scissor(view_w: i32, view_h: i32) { - iron_g4_scissor(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); + gpu_scissor(app_x(),render_path_current_h - (view_h - app_y()), view_w, view_h); _render_path_scissor_set = true; } @@ -144,12 +144,12 @@ function render_path_set_viewport(view_w: i32, view_h: i32) { } function render_path_clear_target(color: color_t = 0x00000000, depth: f32 = 0.0, flags: i32 = clear_flag_t.COLOR) { - iron_g5_clear(color, depth, flags); + iron_gpu_clear(color, depth, flags); } function render_path_gen_mipmaps(target: string) { let rt: render_target_t = map_get(render_path_render_targets, target); - iron_g5_texture_generate_mipmaps(rt._image, 1000); + iron_gpu_texture_generate_mipmaps(rt._image, 1000); } function _render_path_sort_dist(a: any_ptr, b: any_ptr): i32 { @@ -213,12 +213,12 @@ function render_path_draw_skydome(handle: string) { if (cc.context == null) { return; // World data not specified } - iron_g5_set_pipeline(cc.context._.pipe_state); + iron_gpu_set_pipeline(cc.context._.pipe_state); uniforms_set_context_consts(cc.context, _render_path_bind_params); uniforms_set_obj_consts(cc.context, null); // External hosek - iron_g4_set_vertex_buffer(const_data_skydome_vb); - iron_g4_set_index_buffer(const_data_skydome_ib); - iron_g4_draw_indexed_vertices(); + gpu_set_vertex_buffer(const_data_skydome_vb); + gpu_set_index_buffer(const_data_skydome_ib); + gpu_draw_indexed_vertices(); render_path_end(); } @@ -239,12 +239,12 @@ function render_path_draw_shader(handle: string) { if (const_data_screen_aligned_vb == null) { const_data_create_screen_aligned_data(); } - iron_g5_set_pipeline(cc.context._.pipe_state); + iron_gpu_set_pipeline(cc.context._.pipe_state); uniforms_set_context_consts(cc.context, _render_path_bind_params); uniforms_set_obj_consts(cc.context, null); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); render_path_end(); } @@ -285,7 +285,7 @@ function render_path_unload() { } } -function _render_path_resize_on_init(_image: iron_g5_texture_t) { +function _render_path_resize_on_init(_image: iron_gpu_texture_t) { iron_unload_image(_image); } @@ -314,7 +314,7 @@ function render_path_resize() { } if (nodepth != null) { - iron_g5_render_target_set_depth_from(rt._image, nodepth._image); + iron_gpu_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: iron_g5_texture_t = rt._image; + let _image: iron_gpu_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); - iron_g5_render_target_set_depth_from(rt._image, depth_from._image); + iron_gpu_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); - iron_g5_render_target_set_depth_from(t._image, depth_target._image); + iron_gpu_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): iron_g5_texture_t { +function render_path_create_image(t: render_target_t, depth_buffer_bits: i32): iron_gpu_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 iron_g4_create_render_target(width, height, + return gpu_create_render_target(width, height, t.format != null ? render_path_get_tex_format(t.format) : tex_format_t.RGBA32, depth_buffer_bits); } diff --git a/base/sources/ts/iron/scene.ts b/base/sources/ts/iron/scene.ts index 1d85a436..3f2b40e6 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: iron_g5_texture_t = data_get_image(file); + let image: iron_gpu_texture_t = data_get_image(file); map_set(scene_embedded, file, image); } @@ -475,14 +475,14 @@ type mesh_data_t = { type mesh_data_runtime_t = { refcount?: i32; // Number of users handle?: string; // Handle used to retrieve this object in Data - vertex_buffer?: iron_g5_vertex_buffer_t; - vertex_buffer_map?: map_t; - index_buffers?: iron_g5_index_buffer_t[]; + vertex_buffer?: iron_gpu_vertex_buffer_t; + vertex_buffer_map?: map_t; + index_buffers?: iron_gpu_index_buffer_t[]; ready?: bool; vertices?: buffer_t; indices?: u32_array_t[]; material_indices?: i32[]; - structure?: iron_g5_vertex_structure_t; + structure?: iron_gpu_vertex_structure_t; ///if arm_skin skeleton_transforms_inv?: mat4_t[]; actions?: map_t; @@ -542,7 +542,7 @@ type material_context_t = { }; type material_context_runtime_t = { - textures?: iron_g5_texture_t[]; + textures?: iron_gpu_texture_t[]; }; type bind_const_t = { @@ -599,11 +599,11 @@ type shader_context_t = { }; type shader_context_runtime_t = { - pipe_state?: iron_g5_pipeline_t; - constants?: iron_g5_constant_location_t[]; - tex_units?: iron_g5_texture_unit_t[]; + pipe_state?: iron_gpu_pipeline_t; + constants?: iron_gpu_constant_location_t[]; + tex_units?: iron_gpu_texture_unit_t[]; override_context?: _shader_override_t; - structure?: iron_g5_vertex_structure_t; + structure?: iron_gpu_vertex_structure_t; }; type _shader_override_t = { @@ -651,9 +651,9 @@ type world_data_t = { }; type world_data_runtime_t = { - envmap?: iron_g5_texture_t; - radiance?: iron_g5_texture_t; - radiance_mipmaps?: iron_g5_texture_t[]; + envmap?: iron_gpu_texture_t; + radiance?: iron_gpu_texture_t; + radiance_mipmaps?: iron_gpu_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 ad4e3b14..f039e1cd 100644 --- a/base/sources/ts/iron/shader_data.ts +++ b/base/sources/ts/iron/shader_data.ts @@ -67,9 +67,9 @@ function shader_context_create(raw: shader_context_t): shader_context_t { function shader_context_compile(raw: shader_context_t): shader_context_t { if (raw._.pipe_state != null) { - iron_g4_delete_pipeline(raw._.pipe_state); + gpu_delete_pipeline(raw._.pipe_state); } - raw._.pipe_state = iron_g4_create_pipeline(); + raw._.pipe_state = gpu_create_pipeline(); raw._.constants = []; raw._.tex_units = []; @@ -133,8 +133,8 @@ function shader_context_compile(raw: shader_context_t): shader_context_t { // Shaders if (raw.shader_from_source) { - raw._.pipe_state.vertex_shader = iron_g4_create_shader_from_source(raw.vertex_shader, shader_type_t.VERTEX); - raw._.pipe_state.fragment_shader = iron_g4_create_shader_from_source(raw.fragment_shader, shader_type_t.FRAGMENT); + raw._.pipe_state.vertex_shader = gpu_create_shader_from_source(raw.vertex_shader, shader_type_t.VERTEX); + raw._.pipe_state.fragment_shader = gpu_create_shader_from_source(raw.fragment_shader, shader_type_t.FRAGMENT); // Shader compile error if (raw._.pipe_state.vertex_shader == null || raw._.pipe_state.fragment_shader == null) { @@ -149,9 +149,9 @@ function shader_context_compile(raw: shader_context_t): shader_context_t { ///else // Load shaders manually let vs_buffer: buffer_t = data_get_blob(raw.vertex_shader + shader_data_ext()); - raw._.pipe_state.vertex_shader = iron_g4_create_shader(vs_buffer, shader_type_t.VERTEX); + raw._.pipe_state.vertex_shader = gpu_create_shader(vs_buffer, shader_type_t.VERTEX); let fs_buffer: buffer_t = data_get_blob(raw.fragment_shader + shader_data_ext()); - raw._.pipe_state.fragment_shader = iron_g4_create_shader(fs_buffer, shader_type_t.FRAGMENT); + raw._.pipe_state.fragment_shader = gpu_create_shader(fs_buffer, shader_type_t.FRAGMENT); ///end } @@ -159,7 +159,7 @@ function shader_context_compile(raw: shader_context_t): shader_context_t { } function shader_context_finish_compile(raw: shader_context_t): shader_context_t { - iron_g4_compile_pipeline(raw._.pipe_state); + gpu_compile_pipeline(raw._.pipe_state); if (raw.constants != null) { for (let i: i32 = 0; i < raw.constants.length; ++i) { @@ -201,22 +201,22 @@ function shader_context_parse_data(data: string): vertex_data_t { } function shader_context_parse_vertex_struct(raw: shader_context_t) { - raw._.structure = g4_vertex_struct_create(); + raw._.structure = gpu_vertex_struct_create(); for (let i: i32 = 0; i < raw.vertex_elements.length; ++i) { let elem: vertex_element_t = raw.vertex_elements[i]; - g4_vertex_struct_add(raw._.structure, elem.name, shader_context_parse_data(elem.data)); + gpu_vertex_struct_add(raw._.structure, elem.name, shader_context_parse_data(elem.data)); } } function shader_context_delete(raw: shader_context_t) { if (raw._.pipe_state.fragment_shader != null) { - iron_g5_shader_destroy(raw._.pipe_state.fragment_shader); + iron_gpu_shader_destroy(raw._.pipe_state.fragment_shader); } if (raw._.pipe_state.vertex_shader != null) { - iron_g5_shader_destroy(raw._.pipe_state.vertex_shader); + iron_gpu_shader_destroy(raw._.pipe_state.vertex_shader); } - iron_g4_delete_pipeline(raw._.pipe_state); + gpu_delete_pipeline(raw._.pipe_state); } function shader_context_get_compare_mode(s: string): compare_mode_t { @@ -344,18 +344,18 @@ function shader_context_get_tex_format(s: string): tex_format_t { } function shader_context_add_const(raw: shader_context_t, c: shader_const_t) { - array_push(raw._.constants, iron_g4_get_constant_location(raw._.pipe_state, c.name)); + array_push(raw._.constants, gpu_get_constant_location(raw._.pipe_state, c.name)); } function shader_context_add_tex(raw: shader_context_t, tu: tex_unit_t) { - let unit: any = iron_g4_get_texture_unit(raw._.pipe_state, tu.name); + let unit: any = gpu_get_texture_unit(raw._.pipe_state, tu.name); array_push(raw._.tex_units, unit); } 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]; - iron_g4_set_texture_parameters(unit, + gpu_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/sys.ts b/base/sources/ts/iron/sys.ts index cec5eaaa..29ab62de 100644 --- a/base/sources/ts/iron/sys.ts +++ b/base/sources/ts/iron/sys.ts @@ -17,7 +17,7 @@ let _sys_drop_files_listeners: sys_string_callback_t[] = []; let _sys_start_time: f32; let _sys_window_title: string; -let _sys_shaders: map_t = map_create(); +let _sys_shaders: map_t = map_create(); declare type iron_window_options_t = { title?: string; @@ -293,10 +293,10 @@ function sys_shader_ext(): string { ///end } -function sys_get_shader(name: string): iron_g5_shader_t { - let shader: iron_g5_shader_t = map_get(_sys_shaders, name); +function sys_get_shader(name: string): iron_gpu_shader_t { + let shader: iron_gpu_shader_t = map_get(_sys_shaders, name); if (shader == null) { - shader = iron_g4_create_shader( + shader = gpu_create_shader( iron_load_blob(data_path() + name + sys_shader_ext()), ends_with(name, ".frag") ? shader_type_t.FRAGMENT : shader_type_t.VERTEX ); diff --git a/base/sources/ts/iron/ui.ts b/base/sources/ts/iron/ui.ts index 21529fd7..a21548bd 100644 --- a/base/sources/ts/iron/ui.ts +++ b/base/sources/ts/iron/ui.ts @@ -122,11 +122,11 @@ function ui_nodes_PAN_Y(): f32 { return UI_NODES_PAN_Y(); } -function _ui_image(image: iron_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 { +function _ui_image(image: iron_gpu_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: iron_g5_texture_t, max_width: i32 = 0) { +function _ui_tooltip_image(image: iron_gpu_texture_t, max_width: i32 = 0) { return ui_tooltip_image(image, max_width); } @@ -309,7 +309,7 @@ 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 iron_g5_texture_t = { +declare type iron_gpu_texture_t = { width: i32; height: i32; }; @@ -372,7 +372,7 @@ declare type ui_handle_t = { color: u32; value: f32; text: string; - // iron_g5_texture_t texture; + // iron_gpu_texture_t texture; redraws: i32; scroll_offset: f32; scroll_enabled: bool; @@ -391,8 +391,8 @@ declare type ui_options_t = { font?: draw_font_t; theme?: ui_theme_t; scale_factor?: f32; - color_wheel?: iron_g5_texture_t; - black_white_gradient?: iron_g5_texture_t; + color_wheel?: iron_gpu_texture_t; + black_white_gradient?: iron_gpu_texture_t; }; declare type ui_coloring_t = { diff --git a/base/sources/ts/iron/uniforms.ts b/base/sources/ts/iron/uniforms.ts index 19a35497..5fa86a77 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)=>iron_g5_texture_t = null; +let uniforms_tex_links: (o: object_t, md: material_data_t, s: string)=>iron_gpu_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 - _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); + _gpu_set_texture(context._.tex_units[j], map_get(scene_embedded, substring(tulink, 1, tulink.length))); + gpu_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) { - _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); + _gpu_set_texture(context._.tex_units[j], w._.radiance); + gpu_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) { - _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); + _gpu_set_texture(context._.tex_units[j], w._.envmap); + gpu_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: iron_g5_texture_t = uniforms_tex_links(object, current_material(object), tu.link); + let image: iron_gpu_texture_t = uniforms_tex_links(object, current_material(object), tu.link); if (image != null) { ends_with(tu.link, "_depth") ? - 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); + gpu_set_texture_depth(context._.tex_units[j], image) : + _gpu_set_texture(context._.tex_units[j], image); + gpu_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) { - iron_g4_set_texture_depth(context._.tex_units[j], rt._image); // sampler2D + gpu_set_texture_depth(context._.tex_units[j], rt._image); // sampler2D } else { - _iron_g4_set_texture(context._.tex_units[j], rt._image); // sampler2D + _gpu_set_texture(context._.tex_units[j], rt._image); // sampler2D } if (rt.mipmaps) { - 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); + gpu_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 - 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); + gpu_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) { - 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); + gpu_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,13 +147,13 @@ 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; - iron_g4_set_texture_parameters(context._.tex_units[j], addressing, addressing, filter, filter, mip_map_filter_t.NONE); + gpu_set_texture_parameters(context._.tex_units[j], addressing, addressing, filter, filter, mip_map_filter_t.NONE); } } } } -function uniforms_set_context_const(location: iron_g5_constant_location_t, c: shader_const_t): bool { +function uniforms_set_context_const(location: iron_gpu_constant_location_t, c: shader_const_t): bool { if (c.link == null) { return true; } @@ -191,7 +191,7 @@ function uniforms_set_context_const(location: iron_g5_constant_location_t, c: sh return false; } - _iron_g4_set_matrix4(location, m); + _gpu_set_matrix4(location, m); return true; } else if (c.type == "vec4") { @@ -202,10 +202,10 @@ function uniforms_set_context_const(location: iron_g5_constant_location_t, c: sh // } if (!vec4_isnan(v)) { - _iron_g4_set_float4(location, v.x, v.y, v.z, v.w); + _gpu_set_float4(location, v.x, v.y, v.z, v.w); } else { - _iron_g4_set_float4(location, 0, 0, 0, 0); + _gpu_set_float4(location, 0, 0, 0, 0); } return true; } @@ -223,10 +223,10 @@ function uniforms_set_context_const(location: iron_g5_constant_location_t, c: sh } if (!vec4_isnan(v)) { - _iron_g4_set_float3(location, v.x, v.y, v.z); + _gpu_set_float3(location, v.x, v.y, v.z); } else { - _iron_g4_set_float3(location, 0.0, 0.0, 0.0); + _gpu_set_float3(location, 0.0, 0.0, 0.0); } return true; } @@ -292,10 +292,10 @@ function uniforms_set_context_const(location: iron_g5_constant_location_t, c: sh } if (!vec4_isnan(v)) { - _iron_g4_set_float2(location, v.x, v.y); + _gpu_set_float2(location, v.x, v.y); } else { - _iron_g4_set_float2(location, 0.0, 0.0); + _gpu_set_float2(location, 0.0, 0.0); } return true; } @@ -312,7 +312,7 @@ function uniforms_set_context_const(location: iron_g5_constant_location_t, c: sh return false; } - _iron_g4_set_float(location, f); + _gpu_set_float(location, f); return true; } else if (c.type == "floats") { @@ -323,7 +323,7 @@ function uniforms_set_context_const(location: iron_g5_constant_location_t, c: sh } if (fa != null) { - _iron_g4_set_floats(location, fa); + _gpu_set_floats(location, fa); return true; } } @@ -338,13 +338,13 @@ function uniforms_set_context_const(location: iron_g5_constant_location_t, c: sh return false; } - _iron_g4_set_int(location, i); + _gpu_set_int(location, i); return true; } return false; } -function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, c: shader_const_t) { +function uniforms_set_obj_const(obj: object_t, loc: iron_gpu_constant_location_t, c: shader_const_t) { if (c.link == null) { return; } @@ -379,7 +379,7 @@ function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, if (mat4_isnan(m)) { return; } - _iron_g4_set_matrix4(loc, m); + _gpu_set_matrix4(loc, m); } else if (c.type == "mat3") { let m: mat3_t = mat3_nan(); @@ -396,7 +396,7 @@ function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, if (mat3_isnan(m)) { return; } - _iron_g4_set_matrix3(loc, m); + _gpu_set_matrix3(loc, m); } else if (c.type == "vec4") { let v: vec4_t = vec4_nan(); @@ -408,7 +408,7 @@ function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, if (vec4_isnan(v)) { return; } - _iron_g4_set_float4(loc, v.x, v.y, v.z, v.w); + _gpu_set_float4(loc, v.x, v.y, v.z, v.w); } else if (c.type == "vec3") { let v: vec4_t = vec4_nan(); @@ -430,7 +430,7 @@ function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, if (vec4_isnan(v)) { return; } - _iron_g4_set_float3(loc, v.x, v.y, v.z); + _gpu_set_float3(loc, v.x, v.y, v.z); } else if (c.type == "vec2") { let v: vec2_t = vec2_nan(); @@ -442,7 +442,7 @@ function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, if (vec2_isnan(v)) { return; } - _iron_g4_set_float2(loc, v.x, v.y); + _gpu_set_float2(loc, v.x, v.y); } else if (c.type == "float") { let f: f32 = f32_nan(); @@ -469,7 +469,7 @@ function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, if (f32_isnan(f)) { return; } - _iron_g4_set_float(loc, f); + _gpu_set_float(loc, f); } else if (c.type == "floats") { let fa: f32_array_t = null; @@ -488,7 +488,7 @@ function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, if (fa == null) { return; } - _iron_g4_set_floats(loc, fa); + _gpu_set_floats(loc, fa); } else if (c.type == "int") { let i: i32 = INT_MAX; @@ -504,7 +504,7 @@ function uniforms_set_obj_const(obj: object_t, loc: iron_g5_constant_location_t, return; } - _iron_g4_set_int(loc, i); + _gpu_set_int(loc, i); } } @@ -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) { - _iron_g4_set_texture(context._.tex_units[j], material_context._.textures[i]); + _gpu_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; @@ -556,23 +556,23 @@ function current_material(object: object_t): material_data_t { return null; } -function uniforms_set_material_const(location: iron_g5_constant_location_t, shader_const: shader_const_t, material_const: bind_const_t) { +function uniforms_set_material_const(location: iron_gpu_constant_location_t, shader_const: shader_const_t, material_const: bind_const_t) { if (shader_const.type == "vec4") { - _iron_g4_set_float4(location, material_const.vec[0], material_const.vec[1], material_const.vec[2], material_const.vec[3]); + _gpu_set_float4(location, material_const.vec[0], material_const.vec[1], material_const.vec[2], material_const.vec[3]); } else if (shader_const.type == "vec3") { - _iron_g4_set_float3(location, material_const.vec[0], material_const.vec[1], material_const.vec[2]); + _gpu_set_float3(location, material_const.vec[0], material_const.vec[1], material_const.vec[2]); } else if (shader_const.type == "vec2") { - _iron_g4_set_float2(location, material_const.vec[0], material_const.vec[1]); + _gpu_set_float2(location, material_const.vec[0], material_const.vec[1]); } else if (shader_const.type == "float") { - _iron_g4_set_float(location, material_const.vec[0]); + _gpu_set_float(location, material_const.vec[0]); } else if (shader_const.type == "bool") { - _iron_g4_set_bool(location, material_const.vec[0] > 0.0); + _gpu_set_bool(location, material_const.vec[0] > 0.0); } else if (shader_const.type == "int") { - _iron_g4_set_int(location, math_floor(material_const.vec[0])); + _gpu_set_int(location, math_floor(material_const.vec[0])); } } diff --git a/base/sources/ts/iron/world_data.ts b/base/sources/ts/iron/world_data.ts index a4055145..a42528cb 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: iron_g5_texture_t = data_get_image(raw.radiance); + let rad: iron_gpu_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: iron_g5_texture_t = data_get_image(base + "_" + i + ext, true); + let mipimg: iron_gpu_texture_t = data_get_image(base + "_" + i + ext, true); raw._.radiance_mipmaps[i] = mipimg; } - iron_g4_set_mipmaps(raw._.radiance, raw._.radiance_mipmaps); + gpu_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: iron_g5_texture_t = data_get_image(raw.envmap); + let image: iron_gpu_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 8b5552ba..d577e38c 100644 --- a/base/sources/ts/layers.ts +++ b/base/sources/ts/layers.ts @@ -1,8 +1,8 @@ -let layers_temp_image: iron_g5_texture_t = null; -let layers_expa: iron_g5_texture_t = null; -let layers_expb: iron_g5_texture_t = null; -let layers_expc: iron_g5_texture_t = null; +let layers_temp_image: iron_gpu_texture_t = null; +let layers_expa: iron_gpu_texture_t = null; +let layers_expb: iron_gpu_texture_t = null; +let layers_expc: iron_gpu_texture_t = null; let layers_default_base: f32 = 0.5; let layers_default_rough: f32 = 0.4; let layers_max_layers: i32 = @@ -32,20 +32,20 @@ function layers_init() { draw_begin(texpaint._image); draw_scaled_image(resource_get("placeholder.k"), 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); // Base draw_end(); - _iron_g4_begin(texpaint_nor._image); - iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor - _iron_g4_end(); - _iron_g4_begin(texpaint_pack._image); - iron_g5_clear(color_from_floats(1.0, 0.4, 0.0, 0.0)); // Occ, rough, met - _iron_g4_end(); + _gpu_begin(texpaint_nor._image); + iron_gpu_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor + _gpu_end(); + _gpu_begin(texpaint_pack._image); + iron_gpu_clear(color_from_floats(1.0, 0.4, 0.0, 0.0)); // Occ, rough, met + _gpu_end(); let texpaint_nor_empty: render_target_t = map_get(render_path_render_targets, "texpaint_nor_empty"); let texpaint_pack_empty: render_target_t = map_get(render_path_render_targets, "texpaint_pack_empty"); - _iron_g4_begin(texpaint_nor_empty._image); - iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor - _iron_g4_end(); - _iron_g4_begin(texpaint_pack_empty._image); - iron_g5_clear(color_from_floats(1.0, 0.4, 0.0, 0.0)); // Occ, rough, met - _iron_g4_end(); + _gpu_begin(texpaint_nor_empty._image); + iron_gpu_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor + _gpu_end(); + _gpu_begin(texpaint_pack_empty._image); + iron_gpu_clear(color_from_floats(1.0, 0.4, 0.0, 0.0)); // Occ, rough, met + _gpu_end(); ///end } @@ -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: iron_g5_texture_t = blend0._image; - app_notify_on_next_frame(function (_texpaint_blend0: iron_g5_texture_t) { + let _texpaint_blend0: iron_gpu_texture_t = blend0._image; + app_notify_on_next_frame(function (_texpaint_blend0: iron_gpu_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 = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + blend0._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); let blend1: render_target_t = map_get(rts, "texpaint_blend1"); - let _texpaint_blend1: iron_g5_texture_t = blend1._image; - app_notify_on_next_frame(function (_texpaint_blend1: iron_g5_texture_t) { + let _texpaint_blend1: iron_gpu_texture_t = blend1._image; + app_notify_on_next_frame(function (_texpaint_blend1: iron_gpu_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 = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + blend1._image = gpu_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: iron_g5_texture_t = blur._image; - app_notify_on_next_frame(function (_texpaint_blur: iron_g5_texture_t) { + let _texpaint_blur: iron_gpu_texture_t = blur._image; + app_notify_on_next_frame(function (_texpaint_blur: iron_gpu_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 = iron_g4_create_render_target(size_x, size_y); + blur._image = gpu_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: iron_g5_texture_t = pipes_temp_mask_image; - app_notify_on_next_frame(function (_temp_mask_image: iron_g5_texture_t) { + let _temp_mask_image: iron_gpu_texture_t = pipes_temp_mask_image; + app_notify_on_next_frame(function (_temp_mask_image: iron_gpu_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 = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + pipes_temp_mask_image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); } } @@ -180,16 +180,16 @@ 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: iron_g5_texture_t = layers_expa; - let _expb: iron_g5_texture_t = layers_expb; - let _expc: iron_g5_texture_t = layers_expc; - app_notify_on_next_frame(function (_expa: iron_g5_texture_t) { + let _expa: iron_gpu_texture_t = layers_expa; + let _expb: iron_gpu_texture_t = layers_expb; + let _expc: iron_gpu_texture_t = layers_expc; + app_notify_on_next_frame(function (_expa: iron_gpu_texture_t) { iron_unload_image(_expa); }, _expa); - app_notify_on_next_frame(function (_expb: iron_g5_texture_t) { + app_notify_on_next_frame(function (_expb: iron_gpu_texture_t) { iron_unload_image(_expb); }, _expb); - app_notify_on_next_frame(function (_expc: iron_g5_texture_t) { + app_notify_on_next_frame(function (_expc: iron_gpu_texture_t) { iron_unload_image(_expc); }, _expc); layers_expa = null; @@ -255,29 +255,29 @@ function layers_apply_mask(l: slot_layer_t, m: slot_layer_t) { draw_end(); // Apply mask - _iron_g4_begin(l.texpaint); - iron_g5_set_pipeline(pipes_apply_mask); - _iron_g4_set_texture(pipes_tex0_mask, layers_temp_image); - _iron_g4_set_texture(pipes_texa_mask, m.texpaint); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(l.texpaint); + iron_gpu_set_pipeline(pipes_apply_mask); + _gpu_set_texture(pipes_tex0_mask, layers_temp_image); + _gpu_set_texture(pipes_texa_mask, m.texpaint); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); } -function layers_commands_merge_pack(pipe: iron_g5_pipeline_t, i0: iron_g5_texture_t, i1: iron_g5_texture_t, i1pack: iron_g5_texture_t, i1mask_opacity: f32, i1texmask: iron_g5_texture_t, i1blending: i32 = -1) { - _iron_g4_begin(i0); - iron_g5_set_pipeline(pipe); - _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); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); +function layers_commands_merge_pack(pipe: iron_gpu_pipeline_t, i0: iron_gpu_texture_t, i1: iron_gpu_texture_t, i1pack: iron_gpu_texture_t, i1mask_opacity: f32, i1texmask: iron_gpu_texture_t, i1blending: i32 = -1) { + _gpu_begin(i0); + iron_gpu_set_pipeline(pipe); + _gpu_set_texture(pipes_tex0, i1); + _gpu_set_texture(pipes_tex1, i1pack); + _gpu_set_texture(pipes_texmask, i1texmask); + _gpu_set_texture(pipes_texa, layers_temp_image); + _gpu_set_float(pipes_opac, i1mask_opacity); + _gpu_set_int(pipes_blending, i1blending); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); } function layers_is_fill_material(): bool { @@ -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: iron_g5_texture_t = null; + let current: iron_gpu_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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -718,8 +718,8 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool draw_end(); let empty_rt: render_target_t = map_get(render_path_render_targets, "empty_white"); - let empty: iron_g5_texture_t = empty_rt._image; - let mask: iron_g5_texture_t = empty; + let empty: iron_gpu_texture_t = empty_rt._image; + let mask: iron_gpu_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) { @@ -729,32 +729,32 @@ 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); - iron_g5_set_pipeline(pipes_merge_mask); - _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); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(l0.texpaint); + iron_gpu_set_pipeline(pipes_merge_mask); + _gpu_set_texture(pipes_tex0_merge_mask, l1.texpaint); + _gpu_set_texture(pipes_texa_merge_mask, layers_temp_image); + _gpu_set_float(pipes_opac_merge_mask, slot_layer_get_opacity(l1)); + _gpu_set_int(pipes_blending_merge_mask, l1.blending); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); } if (slot_layer_is_layer(l1)) { if (l1.paint_base) { - _iron_g4_begin(l0.texpaint); - iron_g5_set_pipeline(pipes_merge); - _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); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(l0.texpaint); + iron_gpu_set_pipeline(pipes_merge); + _gpu_set_texture(pipes_tex0, l1.texpaint); + _gpu_set_texture(pipes_tex1, empty); + _gpu_set_texture(pipes_texmask, mask); + _gpu_set_texture(pipes_texa, layers_temp_image); + _gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _gpu_set_int(pipes_blending, l1.blending); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); } if (l0.texpaint_nor != null) { @@ -765,18 +765,18 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool draw_end(); if (l1.paint_nor) { - _iron_g4_begin(l0.texpaint_nor); - iron_g5_set_pipeline(pipes_merge); - _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); - iron_g4_set_vertex_buffer(const_data_screen_aligned_vb); - iron_g4_set_index_buffer(const_data_screen_aligned_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + _gpu_begin(l0.texpaint_nor); + iron_gpu_set_pipeline(pipes_merge); + _gpu_set_texture(pipes_tex0, l1.texpaint); + _gpu_set_texture(pipes_tex1, l1.texpaint_nor); + _gpu_set_texture(pipes_texmask, mask); + _gpu_set_texture(pipes_texa, layers_temp_image); + _gpu_set_float(pipes_opac, slot_layer_get_opacity(l1)); + _gpu_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); } } diff --git a/base/sources/ts/line_draw.ts b/base/sources/ts/line_draw.ts index a5c19831..3fee9627 100644 --- a/base/sources/ts/line_draw.ts +++ b/base/sources/ts/line_draw.ts @@ -4,14 +4,14 @@ let line_draw_strength: f32 = 0.005; let line_draw_mat: mat4_t = mat4_nan(); let line_draw_dim: vec4_t = vec4_nan(); -let line_draw_vertex_buffer: iron_g5_vertex_buffer_t; -let line_draw_index_buffer: iron_g5_index_buffer_t; -let line_draw_pipeline: iron_g5_pipeline_t = null; -let line_draw_overlay_pipeline: iron_g5_pipeline_t = null; +let line_draw_vertex_buffer: iron_gpu_vertex_buffer_t; +let line_draw_index_buffer: iron_gpu_index_buffer_t; +let line_draw_pipeline: iron_gpu_pipeline_t = null; +let line_draw_overlay_pipeline: iron_gpu_pipeline_t = null; let line_draw_vp: mat4_t; -let line_draw_vp_loc: iron_g5_constant_location_t; -let line_draw_color_loc: iron_g5_constant_location_t; +let line_draw_vp_loc: iron_gpu_constant_location_t; +let line_draw_color_loc: iron_gpu_constant_location_t; let line_draw_vb_data: buffer_t; let line_draw_ib_data: u32_array_t; @@ -40,9 +40,9 @@ let line_draw_camera_look: vec4_t = vec4_create(); function line_draw_init() { if (line_draw_pipeline == null) { - let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); - line_draw_pipeline = iron_g4_create_pipeline(); + let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); + line_draw_pipeline = gpu_create_pipeline(); line_draw_pipeline.input_layout = structure; line_draw_pipeline.fragment_shader = sys_get_shader("line.frag"); line_draw_pipeline.vertex_shader = sys_get_shader("line.vert"); @@ -54,17 +54,17 @@ function line_draw_init() { ARRAY_ACCESS(line_draw_pipeline.color_attachment, 1) = tex_format_t.RGBA64; ARRAY_ACCESS(line_draw_pipeline.color_attachment, 2) = tex_format_t.RGBA64; line_draw_pipeline.depth_attachment_bits = 24; - iron_g4_compile_pipeline(line_draw_pipeline); - line_draw_color_loc = iron_g4_get_constant_location(line_draw_pipeline, "color"); - line_draw_vp_loc = iron_g4_get_constant_location(line_draw_pipeline, "VP"); + gpu_compile_pipeline(line_draw_pipeline); + line_draw_color_loc = gpu_get_constant_location(line_draw_pipeline, "color"); + line_draw_vp_loc = gpu_get_constant_location(line_draw_pipeline, "VP"); line_draw_vp = mat4_identity(); - line_draw_vertex_buffer = iron_g4_create_vertex_buffer(line_draw_max_vertices, structure, usage_t.DYNAMIC); - line_draw_index_buffer = iron_g4_create_index_buffer(line_draw_max_indices); + line_draw_vertex_buffer = gpu_create_vertex_buffer(line_draw_max_vertices, structure, usage_t.DYNAMIC); + line_draw_index_buffer = gpu_create_index_buffer(line_draw_max_indices); } if (line_draw_overlay_pipeline == null) { - let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); - line_draw_overlay_pipeline = iron_g4_create_pipeline(); + let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); + line_draw_overlay_pipeline = gpu_create_pipeline(); line_draw_overlay_pipeline.input_layout = structure; line_draw_overlay_pipeline.fragment_shader = sys_get_shader("line_overlay.frag"); line_draw_overlay_pipeline.vertex_shader = sys_get_shader("line.vert"); @@ -73,7 +73,7 @@ function line_draw_init() { line_draw_overlay_pipeline.cull_mode = cull_mode_t.NONE; line_draw_overlay_pipeline.color_attachment_count = 1; ARRAY_ACCESS(line_draw_overlay_pipeline.color_attachment, 0) = tex_format_t.RGBA64; - iron_g4_compile_pipeline(line_draw_overlay_pipeline); + gpu_compile_pipeline(line_draw_overlay_pipeline); } } @@ -222,31 +222,31 @@ function line_draw_line(x1: f32, y1: f32, z1: f32, x2: f32, y2: f32, z2: f32) { function line_draw_begin() { line_draw_init(); line_draw_lines = 0; - line_draw_vb_data = iron_g4_lock_vertex_buffer(line_draw_vertex_buffer); - line_draw_ib_data = iron_g4_lock_index_buffer(line_draw_index_buffer); + line_draw_vb_data = gpu_lock_vertex_buffer(line_draw_vertex_buffer); + line_draw_ib_data = gpu_lock_index_buffer(line_draw_index_buffer); } function line_draw_end(overlay: bool = false) { - iron_g4_vertex_buffer_unlock_all(line_draw_vertex_buffer); - iron_g4_index_buffer_unlock_all(line_draw_index_buffer); + gpu_vertex_buffer_unlock_all(line_draw_vertex_buffer); + gpu_index_buffer_unlock_all(line_draw_index_buffer); - iron_g4_set_vertex_buffer(line_draw_vertex_buffer); - iron_g4_set_index_buffer(line_draw_index_buffer); - iron_g5_set_pipeline(overlay ? line_draw_overlay_pipeline : line_draw_pipeline); + gpu_set_vertex_buffer(line_draw_vertex_buffer); + gpu_set_index_buffer(line_draw_index_buffer); + iron_gpu_set_pipeline(overlay ? line_draw_overlay_pipeline : line_draw_pipeline); let camera: camera_object_t = scene_camera; line_draw_vp = mat4_clone(camera.v); line_draw_vp = mat4_mult_mat(line_draw_vp, camera.p); - _iron_g4_set_matrix4(line_draw_vp_loc, line_draw_vp); - _iron_g4_set_float3(line_draw_color_loc, + _gpu_set_matrix4(line_draw_vp_loc, line_draw_vp); + _gpu_set_float3(line_draw_color_loc, color_get_rb(line_draw_color) / 255, color_get_gb(line_draw_color) / 255, color_get_bb(line_draw_color) / 255 ); - iron_g4_draw_indexed_vertices(0, line_draw_lines * 6); + gpu_draw_indexed_vertices(0, line_draw_lines * 6); } -let _shape_draw_sphere_vb: iron_g5_vertex_buffer_t = null; -let _shape_draw_sphere_ib: iron_g5_index_buffer_t = null; +let _shape_draw_sphere_vb: iron_gpu_vertex_buffer_t = null; +let _shape_draw_sphere_ib: iron_gpu_index_buffer_t = null; function shape_draw_sphere(mat: mat4_t) { line_draw_init(); @@ -256,33 +256,33 @@ function shape_draw_sphere(mat: mat4_t) { let md: mesh_data_t = sphere.data; let posa: i16_array_t = md.vertex_arrays[0].values; - let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); - _shape_draw_sphere_vb = iron_g4_create_vertex_buffer(posa.length, structure, usage_t.STATIC); - let data: buffer_t = iron_g4_lock_vertex_buffer(_shape_draw_sphere_vb); + let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); + _shape_draw_sphere_vb = gpu_create_vertex_buffer(posa.length, structure, usage_t.STATIC); + let data: buffer_t = gpu_lock_vertex_buffer(_shape_draw_sphere_vb); for (let i: i32 = 0; i < posa.length / 4; ++i) { buffer_set_f32(data, (i * 3 + 0) * 4, posa[i * 4 + 0] / 32767); buffer_set_f32(data, (i * 3 + 1) * 4, posa[i * 4 + 1] / 32767); buffer_set_f32(data, (i * 3 + 2) * 4, posa[i * 4 + 2] / 32767); } - iron_g4_vertex_buffer_unlock_all(_shape_draw_sphere_vb); + gpu_vertex_buffer_unlock_all(_shape_draw_sphere_vb); _shape_draw_sphere_ib = md._.index_buffers[0]; } - iron_g4_set_vertex_buffer(_shape_draw_sphere_vb); - iron_g4_set_index_buffer(_shape_draw_sphere_ib); - iron_g5_set_pipeline(line_draw_overlay_pipeline); + gpu_set_vertex_buffer(_shape_draw_sphere_vb); + gpu_set_index_buffer(_shape_draw_sphere_ib); + iron_gpu_set_pipeline(line_draw_overlay_pipeline); let camera: camera_object_t = scene_camera; line_draw_vp = mat4_clone(mat); let f: f32 = line_draw_strength * 50; line_draw_vp = mat4_scale(line_draw_vp, vec4_create(f, f, f)); line_draw_vp = mat4_mult_mat(line_draw_vp, camera.v); line_draw_vp = mat4_mult_mat(line_draw_vp, camera.p); - _iron_g4_set_matrix4(line_draw_vp_loc, line_draw_vp); - _iron_g4_set_float3(line_draw_color_loc, + _gpu_set_matrix4(line_draw_vp_loc, line_draw_vp); + _gpu_set_float3(line_draw_color_loc, color_get_rb(line_draw_color) / 255, color_get_gb(line_draw_color) / 255, color_get_bb(line_draw_color) / 255 ); - iron_g4_draw_indexed_vertices(); + gpu_draw_indexed_vertices(); } \ No newline at end of file diff --git a/base/sources/ts/logic_node.ts b/base/sources/ts/logic_node.ts index 5d017960..10c3667c 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)=>iron_g5_texture_t; - get_cached_image?: (self: any)=>iron_g5_texture_t; + get_as_image?: (self: any, from: i32)=>iron_gpu_texture_t; + get_cached_image?: (self: any)=>iron_gpu_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): iron_g5_texture_t { +function logic_node_get_as_image(self: logic_node_t, from: i32): iron_gpu_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): iron_g5_texture_t { +function logic_node_get_cached_image(self: logic_node_t): iron_gpu_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): iron_g5_texture_t { +function logic_node_input_get_as_image(self: logic_node_input_t): iron_gpu_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 51b4b8c3..84fe7632 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?: iron_g5_texture_t; + image?: iron_gpu_texture_t; }; function color_node_create(raw: ui_node_t, args: f32_array_t): color_node_t { @@ -29,7 +29,7 @@ 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): iron_g5_texture_t { +function color_node_get_as_image(self: color_node_t, from: i32): iron_gpu_texture_t { if (self.base.inputs.length > 0) { return logic_node_input_get_as_image(self.base.inputs[0]); } @@ -41,7 +41,7 @@ function color_node_get_as_image(self: color_node_t, from: i32): iron_g5_texture buffer_set_f32(b, 4, self.value.y); buffer_set_f32(b, 8, self.value.z); buffer_set_f32(b, 12, self.value.w); - self.image = iron_g4_create_texture_from_bytes(b, 1, 1, tex_format_t.RGBA128); + self.image = gpu_create_texture_from_bytes(b, 1, 1, tex_format_t.RGBA128); return self.image; } diff --git a/base/sources/ts/nodes/float_node.ts b/base/sources/ts/nodes/float_node.ts index 9fa86902..d49fe37e 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?: iron_g5_texture_t; + image?: iron_gpu_texture_t; }; function float_node_create(raw: ui_node_t, args: f32_array_t): float_node_t { @@ -25,7 +25,7 @@ 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): iron_g5_texture_t { +function float_node_get_as_image(self: float_node_t, from: i32): iron_gpu_texture_t { if (self.base.inputs.length > 0) { return logic_node_input_get_as_image(self.base.inputs[0]); } @@ -37,7 +37,7 @@ function float_node_get_as_image(self: float_node_t, from: i32): iron_g5_texture buffer_set_f32(b, 4, self.value); buffer_set_f32(b, 8, self.value); buffer_set_f32(b, 12, 1.0); - self.image = iron_g4_create_texture_from_bytes(b, 1, 1, tex_format_t.RGBA128); + self.image = gpu_create_texture_from_bytes(b, 1, 1, tex_format_t.RGBA128); return self.image; } diff --git a/base/sources/ts/nodes/vector_node.ts b/base/sources/ts/nodes/vector_node.ts index 773fc609..3c6afaa5 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?: iron_g5_texture_t; + image?: iron_gpu_texture_t; }; function vector_node_create(raw: ui_node_t, args: f32_array_t): vector_node_t { @@ -33,7 +33,7 @@ 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): iron_g5_texture_t { +function vector_node_get_as_image(self: vector_node_t, from: i32): iron_gpu_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]); @@ -48,7 +48,7 @@ function vector_node_get_as_image(self: vector_node_t, from: i32): iron_g5_textu buffer_set_f32(b, 4, n1.value); buffer_set_f32(b, 8, n2.value); buffer_set_f32(b, 12, 1.0); - self.image = iron_g4_create_texture_from_bytes(b, 1, 1, tex_format_t.RGBA128); + self.image = gpu_create_texture_from_bytes(b, 1, 1, tex_format_t.RGBA128); return self.image; } diff --git a/base/sources/ts/parser_material.ts b/base/sources/ts/parser_material.ts index 25a024f2..90c8f89e 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: iron_g5_texture_t = context_raw.text_tool_image; + let _text_tool_image: iron_gpu_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 df1dadda..c975ebf6 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)=>iron_g5_texture_t +let path_texture_importers: map_t = map_create(); // JSValue -> (s: string)=>iron_gpu_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 c5c66461..96414b84 100644 --- a/base/sources/ts/pipes.ts +++ b/base/sources/ts/pipes.ts @@ -1,66 +1,66 @@ -let pipes_copy: iron_g5_pipeline_t; -let pipes_copy8: iron_g5_pipeline_t; -let pipes_copy128: iron_g5_pipeline_t; -let pipes_copy_bgra: iron_g5_pipeline_t; -let pipes_copy_rgb: iron_g5_pipeline_t = null; -let pipes_copy_r: iron_g5_pipeline_t; -let pipes_copy_g: iron_g5_pipeline_t; -let pipes_copy_a: iron_g5_pipeline_t; -let pipes_copy_a_tex: iron_g5_texture_unit_t; +let pipes_copy: iron_gpu_pipeline_t; +let pipes_copy8: iron_gpu_pipeline_t; +let pipes_copy128: iron_gpu_pipeline_t; +let pipes_copy_bgra: iron_gpu_pipeline_t; +let pipes_copy_rgb: iron_gpu_pipeline_t = null; +let pipes_copy_r: iron_gpu_pipeline_t; +let pipes_copy_g: iron_gpu_pipeline_t; +let pipes_copy_a: iron_gpu_pipeline_t; +let pipes_copy_a_tex: iron_gpu_texture_unit_t; -let pipes_merge: iron_g5_pipeline_t = null; -let pipes_merge_r: iron_g5_pipeline_t = null; -let pipes_merge_g: iron_g5_pipeline_t = null; -let pipes_merge_b: iron_g5_pipeline_t = null; -let pipes_merge_mask: iron_g5_pipeline_t; +let pipes_merge: iron_gpu_pipeline_t = null; +let pipes_merge_r: iron_gpu_pipeline_t = null; +let pipes_merge_g: iron_gpu_pipeline_t = null; +let pipes_merge_b: iron_gpu_pipeline_t = null; +let pipes_merge_mask: iron_gpu_pipeline_t; -let pipes_invert8: iron_g5_pipeline_t; -let pipes_apply_mask: iron_g5_pipeline_t; -let pipes_colorid_to_mask: iron_g5_pipeline_t; +let pipes_invert8: iron_gpu_pipeline_t; +let pipes_apply_mask: iron_gpu_pipeline_t; +let pipes_colorid_to_mask: iron_gpu_pipeline_t; -let pipes_tex0: iron_g5_texture_unit_t; -let pipes_tex1: iron_g5_texture_unit_t; -let pipes_texmask: iron_g5_texture_unit_t; -let pipes_texa: iron_g5_texture_unit_t; -let pipes_opac: iron_g5_constant_location_t; -let pipes_blending: iron_g5_constant_location_t; -let pipes_tex0_mask: iron_g5_texture_unit_t; -let pipes_texa_mask: iron_g5_texture_unit_t; -let pipes_tex0_merge_mask: iron_g5_texture_unit_t; -let pipes_texa_merge_mask: iron_g5_texture_unit_t; -let pipes_tex_colorid: iron_g5_texture_unit_t; -let pipes_texpaint_colorid: iron_g5_texture_unit_t; -let pipes_opac_merge_mask: iron_g5_constant_location_t; -let pipes_blending_merge_mask: iron_g5_constant_location_t; -let pipes_temp_mask_image: iron_g5_texture_t = null; +let pipes_tex0: iron_gpu_texture_unit_t; +let pipes_tex1: iron_gpu_texture_unit_t; +let pipes_texmask: iron_gpu_texture_unit_t; +let pipes_texa: iron_gpu_texture_unit_t; +let pipes_opac: iron_gpu_constant_location_t; +let pipes_blending: iron_gpu_constant_location_t; +let pipes_tex0_mask: iron_gpu_texture_unit_t; +let pipes_texa_mask: iron_gpu_texture_unit_t; +let pipes_tex0_merge_mask: iron_gpu_texture_unit_t; +let pipes_texa_merge_mask: iron_gpu_texture_unit_t; +let pipes_tex_colorid: iron_gpu_texture_unit_t; +let pipes_texpaint_colorid: iron_gpu_texture_unit_t; +let pipes_opac_merge_mask: iron_gpu_constant_location_t; +let pipes_blending_merge_mask: iron_gpu_constant_location_t; +let pipes_temp_mask_image: iron_gpu_texture_t = null; -let pipes_inpaint_preview: iron_g5_pipeline_t; -let pipes_tex0_inpaint_preview: iron_g5_texture_unit_t; -let pipes_texa_inpaint_preview: iron_g5_texture_unit_t; +let pipes_inpaint_preview: iron_gpu_pipeline_t; +let pipes_tex0_inpaint_preview: iron_gpu_texture_unit_t; +let pipes_texa_inpaint_preview: iron_gpu_texture_unit_t; -let pipes_cursor: iron_g5_pipeline_t; -let pipes_cursor_vp: iron_g5_constant_location_t; -let pipes_cursor_inv_vp: iron_g5_constant_location_t; -let pipes_cursor_mouse: iron_g5_constant_location_t; -let pipes_cursor_tex_step: iron_g5_constant_location_t; -let pipes_cursor_radius: iron_g5_constant_location_t; -let pipes_cursor_camera_right: iron_g5_constant_location_t; -let pipes_cursor_tint: iron_g5_constant_location_t; -let pipes_cursor_gbufferd: iron_g5_texture_unit_t; +let pipes_cursor: iron_gpu_pipeline_t; +let pipes_cursor_vp: iron_gpu_constant_location_t; +let pipes_cursor_inv_vp: iron_gpu_constant_location_t; +let pipes_cursor_mouse: iron_gpu_constant_location_t; +let pipes_cursor_tex_step: iron_gpu_constant_location_t; +let pipes_cursor_radius: iron_gpu_constant_location_t; +let pipes_cursor_camera_right: iron_gpu_constant_location_t; +let pipes_cursor_tint: iron_gpu_constant_location_t; +let pipes_cursor_gbufferd: iron_gpu_texture_unit_t; -function _pipes_make_merge(red: bool, green: bool, blue: bool, alpha: bool): iron_g5_pipeline_t { - let pipe: iron_g5_pipeline_t = iron_g4_create_pipeline(); +function _pipes_make_merge(red: bool, green: bool, blue: bool, alpha: bool): iron_gpu_pipeline_t { + let pipe: iron_gpu_pipeline_t = gpu_create_pipeline(); pipe.vertex_shader = sys_get_shader("pass.vert"); pipe.fragment_shader = sys_get_shader("layer_merge.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipe.input_layout = vs; ARRAY_ACCESS(pipe.color_write_mask_red, 0) = red; ARRAY_ACCESS(pipe.color_write_mask_green, 0) = green; ARRAY_ACCESS(pipe.color_write_mask_blue, 0) = blue; ARRAY_ACCESS(pipe.color_write_mask_alpha, 0) = alpha; - iron_g4_compile_pipeline(pipe); + gpu_compile_pipeline(pipe); return pipe; } @@ -70,216 +70,216 @@ function pipes_init() { pipes_merge_r = _pipes_make_merge(true, false, false, false); pipes_merge_g = _pipes_make_merge(false, true, false, false); pipes_merge_b = _pipes_make_merge(false, false, true, false); - pipes_tex0 = iron_g4_get_texture_unit(pipes_merge, "tex0"); // Always binding texpaint.a for blending - pipes_tex1 = iron_g4_get_texture_unit(pipes_merge, "tex1"); - pipes_texmask = iron_g4_get_texture_unit(pipes_merge, "texmask"); - pipes_texa = iron_g4_get_texture_unit(pipes_merge, "texa"); - pipes_opac = iron_g4_get_constant_location(pipes_merge, "opac"); - pipes_blending = iron_g4_get_constant_location(pipes_merge, "blending"); + pipes_tex0 = gpu_get_texture_unit(pipes_merge, "tex0"); // Always binding texpaint.a for blending + pipes_tex1 = gpu_get_texture_unit(pipes_merge, "tex1"); + pipes_texmask = gpu_get_texture_unit(pipes_merge, "texmask"); + pipes_texa = gpu_get_texture_unit(pipes_merge, "texa"); + pipes_opac = gpu_get_constant_location(pipes_merge, "opac"); + pipes_blending = gpu_get_constant_location(pipes_merge, "blending"); ///end { - pipes_copy = iron_g4_create_pipeline(); + pipes_copy = gpu_create_pipeline(); pipes_copy.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + gpu_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); pipes_copy.input_layout = vs; - iron_g4_compile_pipeline(pipes_copy); + gpu_compile_pipeline(pipes_copy); } { - pipes_copy_bgra = iron_g4_create_pipeline(); + pipes_copy_bgra = gpu_create_pipeline(); pipes_copy_bgra.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy_bgra.fragment_shader = sys_get_shader("layer_copy_bgra.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + gpu_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); pipes_copy_bgra.input_layout = vs; - iron_g4_compile_pipeline(pipes_copy_bgra); + gpu_compile_pipeline(pipes_copy_bgra); } { - pipes_copy8 = iron_g4_create_pipeline(); + pipes_copy8 = gpu_create_pipeline(); pipes_copy8.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy8.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + gpu_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); pipes_copy8.input_layout = vs; pipes_copy8.color_attachment_count = 1; ARRAY_ACCESS(pipes_copy8.color_attachment, 0) = tex_format_t.R8; - iron_g4_compile_pipeline(pipes_copy8); + gpu_compile_pipeline(pipes_copy8); } { - pipes_copy128 = iron_g4_create_pipeline(); + pipes_copy128 = gpu_create_pipeline(); pipes_copy128.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy128.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + gpu_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); pipes_copy128.input_layout = vs; pipes_copy128.color_attachment_count = 1; ARRAY_ACCESS(pipes_copy128.color_attachment, 0) = tex_format_t.RGBA128; - iron_g4_compile_pipeline(pipes_copy128); + gpu_compile_pipeline(pipes_copy128); } ///if (is_paint || is_sculpt) { - pipes_invert8 = iron_g4_create_pipeline(); + pipes_invert8 = gpu_create_pipeline(); pipes_invert8.vertex_shader = sys_get_shader("layer_view.vert"); pipes_invert8.fragment_shader = sys_get_shader("layer_invert.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + gpu_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); pipes_invert8.input_layout = vs; pipes_invert8.color_attachment_count = 1; ARRAY_ACCESS(pipes_invert8.color_attachment, 0) = tex_format_t.R8; - iron_g4_compile_pipeline(pipes_invert8); + gpu_compile_pipeline(pipes_invert8); } { - pipes_apply_mask = iron_g4_create_pipeline(); + pipes_apply_mask = gpu_create_pipeline(); pipes_apply_mask.vertex_shader = sys_get_shader("pass.vert"); pipes_apply_mask.fragment_shader = sys_get_shader("mask_apply.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_apply_mask.input_layout = vs; - iron_g4_compile_pipeline(pipes_apply_mask); - pipes_tex0_mask = iron_g4_get_texture_unit(pipes_apply_mask, "tex0"); - pipes_texa_mask = iron_g4_get_texture_unit(pipes_apply_mask, "texa"); + gpu_compile_pipeline(pipes_apply_mask); + pipes_tex0_mask = gpu_get_texture_unit(pipes_apply_mask, "tex0"); + pipes_texa_mask = gpu_get_texture_unit(pipes_apply_mask, "texa"); } { - pipes_merge_mask = iron_g4_create_pipeline(); + pipes_merge_mask = gpu_create_pipeline(); pipes_merge_mask.vertex_shader = sys_get_shader("pass.vert"); pipes_merge_mask.fragment_shader = sys_get_shader("mask_merge.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_merge_mask.input_layout = vs; - iron_g4_compile_pipeline(pipes_merge_mask); - pipes_tex0_merge_mask = iron_g4_get_texture_unit(pipes_merge_mask, "tex0"); - pipes_texa_merge_mask = iron_g4_get_texture_unit(pipes_merge_mask, "texa"); - pipes_opac_merge_mask = iron_g4_get_constant_location(pipes_merge_mask, "opac"); - pipes_blending_merge_mask = iron_g4_get_constant_location(pipes_merge_mask, "blending"); + gpu_compile_pipeline(pipes_merge_mask); + pipes_tex0_merge_mask = gpu_get_texture_unit(pipes_merge_mask, "tex0"); + pipes_texa_merge_mask = gpu_get_texture_unit(pipes_merge_mask, "texa"); + pipes_opac_merge_mask = gpu_get_constant_location(pipes_merge_mask, "opac"); + pipes_blending_merge_mask = gpu_get_constant_location(pipes_merge_mask, "blending"); } { - pipes_colorid_to_mask = iron_g4_create_pipeline(); + pipes_colorid_to_mask = gpu_create_pipeline(); pipes_colorid_to_mask.vertex_shader = sys_get_shader("pass.vert"); pipes_colorid_to_mask.fragment_shader = sys_get_shader("mask_colorid.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_colorid_to_mask.input_layout = vs; - iron_g4_compile_pipeline(pipes_colorid_to_mask); - pipes_texpaint_colorid = iron_g4_get_texture_unit(pipes_colorid_to_mask, "texpaint_colorid"); - pipes_tex_colorid = iron_g4_get_texture_unit(pipes_colorid_to_mask, "texcolorid"); + gpu_compile_pipeline(pipes_colorid_to_mask); + pipes_texpaint_colorid = gpu_get_texture_unit(pipes_colorid_to_mask, "texpaint_colorid"); + pipes_tex_colorid = gpu_get_texture_unit(pipes_colorid_to_mask, "texcolorid"); } ///end ///if is_lab { - pipes_copy_r = iron_g4_create_pipeline(); + pipes_copy_r = gpu_create_pipeline(); pipes_copy_r.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy_r.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + gpu_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); pipes_copy_r.input_layout = vs; ARRAY_ACCESS(pipes_copy_r.color_write_mask_green, 0) = false; ARRAY_ACCESS(pipes_copy_r.color_write_mask_blue, 0) = false; ARRAY_ACCESS(pipes_copy_r.color_write_mask_alpha, 0) = false; - iron_g4_compile_pipeline(pipes_copy_r); + gpu_compile_pipeline(pipes_copy_r); } { - pipes_copy_g = iron_g4_create_pipeline(); + pipes_copy_g = gpu_create_pipeline(); pipes_copy_g.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy_g.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + gpu_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); pipes_copy_g.input_layout = vs; ARRAY_ACCESS(pipes_copy_g.color_write_mask_red, 0) = false; ARRAY_ACCESS(pipes_copy_g.color_write_mask_blue, 0) = false; ARRAY_ACCESS(pipes_copy_g.color_write_mask_alpha, 0) = false; - iron_g4_compile_pipeline(pipes_copy_g); + gpu_compile_pipeline(pipes_copy_g); } { - pipes_inpaint_preview = iron_g4_create_pipeline(); + pipes_inpaint_preview = gpu_create_pipeline(); pipes_inpaint_preview.vertex_shader = sys_get_shader("pass.vert"); pipes_inpaint_preview.fragment_shader = sys_get_shader("inpaint_preview.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_inpaint_preview.input_layout = vs; - iron_g4_compile_pipeline(pipes_inpaint_preview); - pipes_tex0_inpaint_preview = iron_g4_get_texture_unit(pipes_inpaint_preview, "tex0"); - pipes_texa_inpaint_preview = iron_g4_get_texture_unit(pipes_inpaint_preview, "texa"); + gpu_compile_pipeline(pipes_inpaint_preview); + pipes_tex0_inpaint_preview = gpu_get_texture_unit(pipes_inpaint_preview, "tex0"); + pipes_texa_inpaint_preview = gpu_get_texture_unit(pipes_inpaint_preview, "texa"); } { - pipes_copy_a = iron_g4_create_pipeline(); + pipes_copy_a = gpu_create_pipeline(); pipes_copy_a.vertex_shader = sys_get_shader("pass.vert"); pipes_copy_a.fragment_shader = sys_get_shader("layer_copy_rrrr.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_copy_a.input_layout = vs; ARRAY_ACCESS(pipes_copy_a.color_write_mask_red, 0) = false; ARRAY_ACCESS(pipes_copy_a.color_write_mask_green, 0) = false; ARRAY_ACCESS(pipes_copy_a.color_write_mask_blue, 0) = false; - iron_g4_compile_pipeline(pipes_copy_a); - pipes_copy_a_tex = iron_g4_get_texture_unit(pipes_copy_a, "tex"); + gpu_compile_pipeline(pipes_copy_a); + pipes_copy_a_tex = gpu_get_texture_unit(pipes_copy_a, "tex"); } ///end { - pipes_copy_rgb = iron_g4_create_pipeline(); + pipes_copy_rgb = gpu_create_pipeline(); pipes_copy_rgb.vertex_shader = sys_get_shader("layer_view.vert"); pipes_copy_rgb.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + gpu_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); pipes_copy_rgb.input_layout = vs; ARRAY_ACCESS(pipes_copy_rgb.color_write_mask_alpha, 0) = false; - iron_g4_compile_pipeline(pipes_copy_rgb); + gpu_compile_pipeline(pipes_copy_rgb); } { - pipes_cursor = iron_g4_create_pipeline(); + pipes_cursor = gpu_create_pipeline(); pipes_cursor.vertex_shader = sys_get_shader("cursor.vert"); pipes_cursor.fragment_shader = sys_get_shader("cursor.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); ///if (arm_metal || arm_vulkan) - g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///else - g4_vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); - g4_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); - g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); + gpu_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///end pipes_cursor.input_layout = vs; pipes_cursor.blend_source = blend_factor_t.SOURCE_ALPHA; pipes_cursor.blend_destination = blend_factor_t.INV_SOURCE_ALPHA; pipes_cursor.depth_write = false; pipes_cursor.depth_mode = compare_mode_t.ALWAYS; - iron_g4_compile_pipeline(pipes_cursor); - pipes_cursor_vp = iron_g4_get_constant_location(pipes_cursor, "VP"); - pipes_cursor_inv_vp = iron_g4_get_constant_location(pipes_cursor, "invVP"); - pipes_cursor_mouse = iron_g4_get_constant_location(pipes_cursor, "mouse"); - pipes_cursor_tex_step = iron_g4_get_constant_location(pipes_cursor, "tex_step"); - pipes_cursor_radius = iron_g4_get_constant_location(pipes_cursor, "radius"); - pipes_cursor_camera_right = iron_g4_get_constant_location(pipes_cursor, "camera_right"); - pipes_cursor_tint = iron_g4_get_constant_location(pipes_cursor, "tint"); - pipes_cursor_gbufferd = iron_g4_get_texture_unit(pipes_cursor, "gbufferD"); + gpu_compile_pipeline(pipes_cursor); + pipes_cursor_vp = gpu_get_constant_location(pipes_cursor, "VP"); + pipes_cursor_inv_vp = gpu_get_constant_location(pipes_cursor, "invVP"); + pipes_cursor_mouse = gpu_get_constant_location(pipes_cursor, "mouse"); + pipes_cursor_tex_step = gpu_get_constant_location(pipes_cursor, "tex_step"); + pipes_cursor_radius = gpu_get_constant_location(pipes_cursor, "radius"); + pipes_cursor_camera_right = gpu_get_constant_location(pipes_cursor, "camera_right"); + pipes_cursor_tint = gpu_get_constant_location(pipes_cursor, "tint"); + pipes_cursor_gbufferd = gpu_get_texture_unit(pipes_cursor, "gbufferD"); } } diff --git a/base/sources/ts/project.ts b/base/sources/ts/project.ts index 960f4ef3..a167fa09 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(); // iron_g5_texture_t | font_t +let project_asset_map: map_t = map_create(); // iron_gpu_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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -640,7 +640,7 @@ function project_reimport_texture(asset: asset_t) { } } -function project_get_image(asset: asset_t): iron_g5_texture_t { +function project_get_image(asset: asset_t): iron_gpu_texture_t { return asset != null ? map_get(project_asset_map, asset.id) : null; } diff --git a/base/sources/ts/render_path_deferred.ts b/base/sources/ts/render_path_deferred.ts index bac97f4e..c7b30b5d 100644 --- a/base/sources/ts/render_path_deferred.ts +++ b/base/sources/ts/render_path_deferred.ts @@ -89,7 +89,7 @@ function render_path_deferred_init() { t.format = "R8"; let b: buffer_t = buffer_create(1); buffer_set_u8(b, 0, 255); - t._image = iron_g4_create_texture_from_bytes(b, t.width, t.height, tex_format_t.R8); + t._image = gpu_create_texture_from_bytes(b, t.width, t.height, tex_format_t.R8); map_set(render_path_render_targets, t.name, t); } { @@ -103,7 +103,7 @@ function render_path_deferred_init() { buffer_set_u8(b, 1, 0); buffer_set_u8(b, 2, 0); buffer_set_u8(b, 3, 0); - t._image = iron_g4_create_texture_from_bytes(b, t.width, t.height, tex_format_t.RGBA32); + t._image = gpu_create_texture_from_bytes(b, t.width, t.height, tex_format_t.RGBA32); map_set(render_path_render_targets, t.name, t); } diff --git a/base/sources/ts/render_path_raytrace.ts b/base/sources/ts/render_path_raytrace.ts index 3fd3dfbb..c1b2974f 100644 --- a/base/sources/ts/render_path_raytrace.ts +++ b/base/sources/ts/render_path_raytrace.ts @@ -7,10 +7,10 @@ let render_path_raytrace_first: bool = true; let render_path_raytrace_f32a: f32_array_t = f32_array_create(24); let render_path_raytrace_help_mat: mat4_t = mat4_identity(); let render_path_raytrace_transform: mat4_t; -let render_path_raytrace_vb: iron_g5_vertex_buffer_t; -let render_path_raytrace_ib: iron_g5_index_buffer_t; +let render_path_raytrace_vb: iron_gpu_vertex_buffer_t; +let render_path_raytrace_ib: iron_gpu_index_buffer_t; -let render_path_raytrace_last_envmap: iron_g5_texture_t = null; +let render_path_raytrace_last_envmap: iron_gpu_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: iron_g5_texture_t = null; +let render_path_raytrace_last_texpaint: iron_gpu_texture_t = null; function render_path_raytrace_init() { } @@ -45,14 +45,14 @@ function render_path_raytrace_commands(use_live_layer: bool) { } let probe: world_data_t = scene_world; - let saved_envmap: iron_g5_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; + let saved_envmap: iron_gpu_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: iron_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); - let bnoise_scramble: iron_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); - let bnoise_rank: iron_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); + let bnoise_sobol: iron_gpu_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: iron_gpu_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: iron_gpu_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, bnoise_sobol, bnoise_scramble, bnoise_rank); @@ -63,9 +63,9 @@ 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: iron_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); - let bnoise_scramble: iron_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); - let bnoise_rank: iron_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); + let bnoise_sobol: iron_gpu_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: iron_gpu_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: iron_gpu_texture_t = map_get(scene_embedded, "bnoise_rank.k"); iron_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, saved_envmap, bnoise_sobol, bnoise_scramble, bnoise_rank); } @@ -168,8 +168,8 @@ function render_path_raytrace_raytrace_init(shader_name: string, build: bool = t iron_raytrace_as_add(render_path_raytrace_vb, render_path_raytrace_ib, render_path_raytrace_transform); ///end - let vb_full: iron_g5_vertex_buffer_t = context_raw.merged_object.data._.vertex_buffer; - let ib_full: iron_g5_index_buffer_t = context_raw.merged_object.data._.index_buffers[0]; + let vb_full: iron_gpu_vertex_buffer_t = context_raw.merged_object.data._.vertex_buffer; + let ib_full: iron_gpu_index_buffer_t = context_raw.merged_object.data._.index_buffers[0]; iron_raytrace_as_build(vb_full, ib_full); } diff --git a/base/sources/ts/render_path_raytrace_bake.ts b/base/sources/ts/render_path_raytrace_bake.ts index 845c37da..58bf4c0f 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: iron_g5_texture_t = null; +let render_path_raytrace_bake_last_layer: iron_gpu_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 { @@ -74,15 +74,15 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo } let probe: world_data_t = scene_world; - let saved_envmap: iron_g5_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; + let saved_envmap: iron_gpu_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: iron_g5_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); - let bnoise_scramble: iron_g5_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); - let bnoise_rank: iron_g5_texture_t = map_get(scene_embedded, "bnoise_rank.k"); + let bnoise_sobol: iron_gpu_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: iron_gpu_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: iron_gpu_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"); diff --git a/base/sources/ts/resource.ts b/base/sources/ts/resource.ts index 984a40de..e7fc98c3 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: iron_g5_texture_t = data_get_image(s); + let image: iron_gpu_texture_t = data_get_image(s); map_set(resource_bundled, s, image); } } -function resource_get(name: string): iron_g5_texture_t { +function resource_get(name: string): iron_gpu_texture_t { return map_get(resource_bundled, name); } -function resource_tile50(img: iron_g5_texture_t, x: i32, y: i32): rect_t { +function resource_tile50(img: iron_gpu_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: iron_g5_texture_t, x: i32, y: i32): rect_t { +function resource_tile25(img: iron_gpu_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: iron_g5_texture_t, x: i32, y: i32): rect_t { +function resource_tile18(img: iron_gpu_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 20cdc90e..55d06254 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?: iron_g5_texture_t; // 200px - image_icon?: iron_g5_texture_t; // 50px + image?: iron_gpu_texture_t; // 200px + image_icon?: iron_gpu_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 d4a4e0c2..a16eb672 100644 --- a/base/sources/ts/slot_font.ts +++ b/base/sources/ts/slot_font.ts @@ -1,6 +1,6 @@ type slot_font_t = { - image?: iron_g5_texture_t; // 200px + image?: iron_gpu_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 4332dbff..c128f953 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?: iron_g5_texture_t; // Base or mask - texpaint_nor?: iron_g5_texture_t; - texpaint_pack?: iron_g5_texture_t; - texpaint_preview?: iron_g5_texture_t; // Layer preview + texpaint?: iron_gpu_texture_t; // Base or mask + texpaint_nor?: iron_gpu_texture_t; + texpaint_pack?: iron_gpu_texture_t; + texpaint_preview?: iron_gpu_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 = iron_g4_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size, tex_format_t.RGBA32); + raw.texpaint_preview = gpu_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 = iron_g4_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size, tex_format_t.RGBA32); + raw.texpaint_preview = gpu_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size, tex_format_t.RGBA32); } return raw; @@ -179,22 +179,22 @@ function slot_layer_unload(raw: slot_layer_t) { return; } - let _texpaint: iron_g5_texture_t = raw.texpaint; - let _texpaint_nor: iron_g5_texture_t = raw.texpaint_nor; - let _texpaint_pack: iron_g5_texture_t = raw.texpaint_pack; - let _texpaint_preview: iron_g5_texture_t = raw.texpaint_preview; + let _texpaint: iron_gpu_texture_t = raw.texpaint; + let _texpaint_nor: iron_gpu_texture_t = raw.texpaint_nor; + let _texpaint_pack: iron_gpu_texture_t = raw.texpaint_pack; + let _texpaint_preview: iron_gpu_texture_t = raw.texpaint_preview; - app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -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: iron_g5_texture_t = raw.texpaint; + let _texpaint: iron_gpu_texture_t = raw.texpaint; raw.texpaint = other.texpaint; other.texpaint = _texpaint; - let _texpaint_preview: iron_g5_texture_t = raw.texpaint_preview; + let _texpaint_preview: iron_gpu_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: iron_g5_texture_t = raw.texpaint_nor; - let _texpaint_pack: iron_g5_texture_t = raw.texpaint_pack; + let _texpaint_nor: iron_gpu_texture_t = raw.texpaint_nor; + let _texpaint_pack: iron_gpu_texture_t = raw.texpaint_pack; raw.texpaint_nor = other.texpaint_nor; raw.texpaint_pack = other.texpaint_pack; other.texpaint_nor = _texpaint_nor; @@ -243,10 +243,10 @@ 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: iron_g5_texture_t = null, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0) { - _iron_g4_begin(raw.texpaint); - iron_g5_clear(base_color); // Base - _iron_g4_end(); +function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_image: iron_gpu_texture_t = null, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0) { + _gpu_begin(raw.texpaint); + iron_gpu_clear(base_color); // Base + _gpu_end(); if (base_image != null) { draw_begin(raw.texpaint); draw_scaled_image(base_image, 0, 0, raw.texpaint.width, raw.texpaint.height); @@ -254,12 +254,12 @@ function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_ } if (slot_layer_is_layer(raw)) { - _iron_g4_begin(raw.texpaint_nor); - iron_g5_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor - _iron_g4_end(); - _iron_g4_begin(raw.texpaint_pack); - iron_g5_clear(color_from_floats(occlusion, roughness, metallic, 0.0)); // Occ, rough, met - _iron_g4_end(); + _gpu_begin(raw.texpaint_nor); + iron_gpu_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor + _gpu_end(); + _gpu_begin(raw.texpaint_pack); + iron_gpu_clear(color_from_floats(occlusion, roughness, metallic, 0.0)); // Occ, rough, met + _gpu_end(); } context_raw.layer_preview_dirty = true; @@ -267,14 +267,14 @@ function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_ } function slot_layer_invert_mask(raw: slot_layer_t) { - let inverted: iron_g5_texture_t = iron_g4_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32); + let inverted: iron_gpu_texture_t = gpu_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32); draw_begin(inverted); draw_set_pipeline(pipes_invert8); draw_image(raw.texpaint, 0, 0); draw_set_pipeline(null); draw_end(); - let _texpaint: iron_g5_texture_t = raw.texpaint; - app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { + let _texpaint: iron_gpu_texture_t = raw.texpaint; + app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); let rt: render_target_t = map_get(render_path_render_targets, "texpaint" + raw.id); @@ -338,7 +338,7 @@ function slot_layer_duplicate(raw: slot_layer_t): slot_layer_t { if (l.texpaint_preview != null) { draw_begin(l.texpaint_preview); - iron_g5_clear(0x00000000); + iron_gpu_clear(0x00000000); draw_set_pipeline(pipes_copy); draw_scaled_image(raw.texpaint_preview, 0, 0, raw.texpaint_preview.width, raw.texpaint_preview.height); draw_set_pipeline(null); @@ -383,17 +383,17 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { format = tex_format_t.RGBA128; ///end - let _texpaint: iron_g5_texture_t = raw.texpaint; - raw.texpaint = iron_g4_create_render_target(res_x, res_y, format); + let _texpaint: iron_gpu_texture_t = raw.texpaint; + raw.texpaint = gpu_create_render_target(res_x, res_y, format); draw_begin(raw.texpaint); draw_set_pipeline(pipes_copy); draw_scaled_image(_texpaint, 0, 0, res_x, res_y); draw_set_pipeline(null); draw_end(); - let _texpaint_nor: iron_g5_texture_t = raw.texpaint_nor; + let _texpaint_nor: iron_gpu_texture_t = raw.texpaint_nor; if (raw.texpaint_nor != null) { - raw.texpaint_nor = iron_g4_create_render_target(res_x, res_y, format); + raw.texpaint_nor = gpu_create_render_target(res_x, res_y, format); draw_begin(raw.texpaint_nor); draw_set_pipeline(pipes_copy); @@ -402,9 +402,9 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_end(); } - let _texpaint_pack: iron_g5_texture_t = raw.texpaint_pack; + let _texpaint_pack: iron_gpu_texture_t = raw.texpaint_pack; if (raw.texpaint_pack != null) { - raw.texpaint_pack = iron_g4_create_render_target(res_x, res_y, format); + raw.texpaint_pack = gpu_create_render_target(res_x, res_y, format); draw_begin(raw.texpaint_pack); draw_set_pipeline(pipes_copy); @@ -413,18 +413,18 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_end(); } - app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - app_notify_on_next_frame(function (_texpaint_nor: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - app_notify_on_next_frame(function (_texpaint_pack: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint_pack: iron_gpu_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: iron_g5_texture_t = raw.texpaint; - raw.texpaint = iron_g4_create_render_target(res_x, res_y, tex_format_t.RGBA32); + let _texpaint: iron_gpu_texture_t = raw.texpaint; + raw.texpaint = gpu_create_render_target(res_x, res_y, tex_format_t.RGBA32); draw_begin(raw.texpaint); draw_set_pipeline(pipes_copy8); @@ -452,7 +452,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_set_pipeline(null); draw_end(); - app_notify_on_next_frame(function (_texpaint: iron_g5_texture_t) { + app_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); diff --git a/base/sources/ts/slot_material.ts b/base/sources/ts/slot_material.ts index da04e083..8dca3fe7 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?: iron_g5_texture_t; - image_icon?: iron_g5_texture_t; + image?: iron_gpu_texture_t; + image_icon?: iron_gpu_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 = iron_g4_create_render_target(w, w); - raw.image_icon = iron_g4_create_render_target(w_icon, w_icon); + raw.image = gpu_create_render_target(w, w); + raw.image_icon = gpu_create_render_target(w_icon, w_icon); if (c == null) { if (slot_material_default_canvas == null) { // Synchronous diff --git a/base/sources/ts/tab_brushes.ts b/base/sources/ts/tab_brushes.ts index 56479885..87e30827 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: iron_g5_texture_t = ui_SCALE(ui) > 1 ? project_brushes[i].image : project_brushes[i].image_icon; - let img_full: iron_g5_texture_t = project_brushes[i].image; + let img: iron_gpu_texture_t = ui_SCALE(ui) > 1 ? project_brushes[i].image : project_brushes[i].image_icon; + let img_full: iron_gpu_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 6f48a748..5866a27b 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: iron_g5_texture_t = project_fonts[i].image; + let img: iron_gpu_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 @@ -80,7 +80,7 @@ function tab_fonts_draw(htab: ui_handle_t) { let state: ui_state_t = ui_state_t.IDLE; if (project_fonts[i].preview_ready) { // draw_set_pipeline(pipe); // L8 - // _iron_g4_set_int(channel_location, 1); + // _gpu_set_int(channel_location, 1); state = _ui_image(img); // draw_set_pipeline(null); } diff --git a/base/sources/ts/tab_layers.ts b/base/sources/ts/tab_layers.ts index 4e1191b3..ef7755fc 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: iron_g5_texture_t = resource_get("icons.k"); + let icons: iron_gpu_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: iron_g5_texture_t = l.texpaint_preview; + let texpaint_preview: iron_gpu_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: iron_g5_texture_t = resource_get("icons.k"); + let icons: iron_gpu_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: iron_g5_texture_t = l.texpaint_preview; + let texpaint_preview: iron_gpu_texture_t = l.texpaint_preview; - let icon: iron_g5_texture_t = l.fill_layer == null ? texpaint_preview : l.fill_layer.image_icon; + let icon: iron_gpu_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); @@ -654,7 +654,7 @@ function tab_layers_draw_layer_icon(l: slot_layer_t, i: i32, uix: f32, uiy: f32, } if (l.fill_layer == null && slot_layer_is_mask(l)) { draw_set_pipeline(ui_view2d_pipe); - _iron_g4_set_int(ui_view2d_channel_loc, 1); + _gpu_set_int(ui_view2d_channel_loc, 1); } let state: ui_state_t = _ui_image(icon, 0xffffffff, icon_h); @@ -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, iron_g4_get_texture_pixels(l.texpaint), l.texpaint.width, l.texpaint.height, 3); // RRR1 + iron_write_png(path + path_sep + f, gpu_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 = iron_g4_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size); + context_raw.mask_preview_rgba32 = gpu_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) { @@ -1008,7 +1008,7 @@ function tab_layers_make_mask_preview_rgba32(l: slot_layer_t) { let l: slot_layer_t = tab_layers_l; draw_begin(context_raw.mask_preview_rgba32); draw_set_pipeline(ui_view2d_pipe); - _iron_g4_set_int(ui_view2d_channel_loc, 1); + _gpu_set_int(ui_view2d_channel_loc, 1); draw_image(l.texpaint_preview, 0, 0); draw_end(); draw_set_pipeline(null); diff --git a/base/sources/ts/tab_materials.ts b/base/sources/ts/tab_materials.ts index d87869bc..cfd5e11d 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: iron_g5_texture_t = ui_SCALE(ui) > 1 ? project_materials[i].image : project_materials[i].image_icon; - let img_full: iron_g5_texture_t = project_materials[i].image; + let img: iron_gpu_texture_t = ui_SCALE(ui) > 1 ? project_materials[i].image : project_materials[i].image_icon; + let img_full: iron_gpu_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 0035d42b..55ac0388 100644 --- a/base/sources/ts/tab_swatches.ts +++ b/base/sources/ts/tab_swatches.ts @@ -1,20 +1,20 @@ -let _tab_swatches_empty: iron_g5_texture_t; +let _tab_swatches_empty: iron_gpu_texture_t; let tab_swatches_drag_pos: i32 = -1; let _tab_swatches_draw_i: i32; -function tab_swatches_empty_set(image: iron_g5_texture_t) { +function tab_swatches_empty_set(image: iron_gpu_texture_t) { _tab_swatches_empty = image; } -function tab_swatches_empty_get(): iron_g5_texture_t { +function tab_swatches_empty_get(): iron_gpu_texture_t { if (_tab_swatches_empty == null) { let b: u8_array_t = u8_array_create(4); b[0] = 255; b[1] = 255; b[2] = 255; b[3] = 255; - _tab_swatches_empty = iron_g4_create_texture_from_bytes(b, 1, 1); + _tab_swatches_empty = gpu_create_texture_from_bytes(b, 1, 1); } return _tab_swatches_empty; } diff --git a/base/sources/ts/tab_textures.ts b/base/sources/ts/tab_textures.ts index d47b1827..28c06a8f 100644 --- a/base/sources/ts/tab_textures.ts +++ b/base/sources/ts/tab_textures.ts @@ -1,5 +1,5 @@ -let _tab_textures_draw_img: iron_g5_texture_t; +let _tab_textures_draw_img: iron_gpu_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: iron_g5_texture_t = project_get_image(asset); + let img: iron_gpu_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: iron_g5_texture_t = _tab_textures_draw_img; - let target: iron_g5_texture_t = iron_g4_create_render_target(tab_textures_to_pow2(img.width), tab_textures_to_pow2(img.height)); + let img: iron_gpu_texture_t = _tab_textures_draw_img; + let target: iron_gpu_texture_t = gpu_create_render_target(tab_textures_to_pow2(img.width), tab_textures_to_pow2(img.height)); draw_begin(target); draw_set_pipeline(pipes_copy); draw_scaled_image(img, 0, 0, target.width, target.height); draw_set_pipeline(null); draw_end(); - app_notify_on_next_frame(function (target: iron_g5_texture_t) { + app_notify_on_next_frame(function (target: iron_gpu_texture_t) { let path: string = _tab_textures_draw_path; let f: string = ui_files_filename; if (f == "") { @@ -156,7 +156,7 @@ function tab_textures_draw(htab: ui_handle_t) { if (!ends_with(f, ".png")) { f += ".png"; } - iron_write_png(path + path_sep + f, iron_g4_get_texture_pixels(target), target.width, target.height, 0); + iron_write_png(path + path_sep + f, gpu_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: iron_g5_texture_t = resource_get("icons.k"); + let img: iron_gpu_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 171fdc92..54152947 100644 --- a/base/sources/ts/ui_base.ts +++ b/base/sources/ts/ui_base.ts @@ -131,7 +131,7 @@ function ui_base_init() { b[1] = 0; b[2] = 0; b[3] = 255; - context_raw.preview_envmap = iron_g4_create_texture_from_bytes(b, 1, 1); + context_raw.preview_envmap = gpu_create_texture_from_bytes(b, 1, 1); } let world: world_data_t = scene_world; @@ -591,7 +591,7 @@ function ui_base_update() { let shortcuts: string[] = ["l", "b", "n", "o", "r", "m", "a", "h", "e", "s", "t", "1", "2", "3", "4"]; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { array_push(modes, tr("Path Traced")); array_push(shortcuts, "p"); } @@ -1082,14 +1082,14 @@ function ui_base_update_ui() { continue; } - let target: iron_g5_texture_t = l.texpaint_preview; + let target: iron_gpu_texture_t = l.texpaint_preview; if (target == null) { continue; } - let source: iron_g5_texture_t = l.texpaint; + let source: iron_gpu_texture_t = l.texpaint; draw_begin(target); - iron_g5_clear(0x00000000); + iron_gpu_clear(0x00000000); // draw_set_pipeline(l.is_mask() ? pipes_copy8 : pipes_copy); draw_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now draw_scaled_image(source, 0, 0, target.width, target.height); @@ -1104,12 +1104,12 @@ function ui_base_update_ui() { // Update layer preview let l: slot_layer_t = context_raw.layer; - let target: iron_g5_texture_t = l.texpaint_preview; + let target: iron_gpu_texture_t = l.texpaint_preview; if (target != null) { - let source: iron_g5_texture_t = l.texpaint; + let source: iron_gpu_texture_t = l.texpaint; draw_begin(target); - iron_g5_clear(0x00000000); + iron_gpu_clear(0x00000000); // draw_set_pipeline(raw.layer.is_mask() ? pipes_copy8 : pipes_copy); draw_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now draw_scaled_image(source, 0, 0, target.width, target.height); @@ -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: iron_g5_texture_t = context_raw.material.image_icon; + let img: iron_gpu_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: iron_g5_texture_t = resource_get("icons.k"); + let img: iron_gpu_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: iron_g5_texture_t = resource_get("cursor.k"); + let cursor_img: iron_gpu_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 @@ -1579,7 +1579,7 @@ function ui_base_make_empty_envmap(col: i32) { b[1] = color_get_gb(col); b[2] = color_get_bb(col); b[3] = 255; - context_raw.empty_envmap = iron_g4_create_texture_from_bytes(b, 1, 1); + context_raw.empty_envmap = gpu_create_texture_from_bytes(b, 1, 1); } function ui_base_set_viewport_col(col: i32) { diff --git a/base/sources/ts/ui_box.ts b/base/sources/ts/ui_box.ts index fe2cf4dd..28df5887 100644 --- a/base/sources/ts/ui_box.ts +++ b/base/sources/ts/ui_box.ts @@ -196,7 +196,7 @@ function ui_box_tween_tick() { function ui_box_window_border(ui: ui_t) { if (ui.scissor) { ui.scissor = false; - iron_g4_disable_scissor(); + gpu_disable_scissor(); } // Border draw_set_color(ui.ops.theme.SEPARATOR_COL); diff --git a/base/sources/ts/ui_files.ts b/base/sources/ts/ui_files.ts index 4e5b3cd0..3ac81834 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: iron_g5_texture_t; + image: iron_gpu_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: iron_g5_texture_t): draw_cloud_icon_data_t { +function make_draw_cloud_icon_data(f: string, image: iron_gpu_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: iron_g5_texture_t = resource_get("icons.k"); + let icons: iron_gpu_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: iron_g5_texture_t = null; + let icon: iron_gpu_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: iron_g5_texture_t = rt._image; + let empty: iron_gpu_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: iron_g5_texture_t = data_get_image(abs); + let image: iron_gpu_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: iron_g5_texture_t = iron_g4_create_render_target(data.image.width, data.image.height); + let icon: iron_gpu_texture_t = gpu_create_render_target(data.image.width, data.image.height); if (ends_with(data.f, ".arm")) { // Used for material sphere alpha cutout draw_begin(icon); @@ -215,7 +215,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = } else { draw_begin(icon); - iron_g5_clear(0xffffffff); + iron_gpu_clear(0xffffffff); } draw_set_pipeline(pipes_copy_rgb); draw_image(data.image, 0, 0); @@ -266,21 +266,21 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let raw: project_format_t = armpack_decode(buffer); if (raw.material_icons != null) { let bytes_icon: any = raw.material_icons[0]; - icon = iron_g4_create_texture_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); + icon = gpu_create_texture_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); } else if (raw.mesh_icons != null) { let bytes_icon: any = raw.mesh_icons[0]; - icon = iron_g4_create_texture_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); + icon = gpu_create_texture_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); } else if (raw.brush_icons != null) { let bytes_icon: any = raw.brush_icons[0]; - icon = iron_g4_create_texture_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); + icon = gpu_create_texture_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); } ///if is_lab if (raw.mesh_icon != null) { let bytes_icon: buffer_t = raw.mesh_icon; - icon = iron_g4_create_texture_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); + icon = gpu_create_texture_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); } ///end @@ -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: iron_g5_texture_t = rt._image; + let empty: iron_gpu_texture_t = rt._image; map_set(ui_files_icon_map, shandle, empty); - let image: iron_g5_texture_t = data_get_image(shandle); + let image: iron_gpu_texture_t = data_get_image(shandle); let args: ui_files_make_icon_t = { image: image, @@ -428,12 +428,12 @@ 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: iron_g5_texture_t = args.image; + let image: iron_gpu_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: iron_g5_texture_t = iron_g4_create_render_target(sw, sh); + let icon: iron_gpu_texture_t = gpu_create_render_target(sw, sh); draw_begin(icon); - iron_g5_clear(0xffffffff); + iron_gpu_clear(0xffffffff); draw_set_pipeline(pipes_copy_rgb); draw_scaled_image(image, 0, 0, sw, sh); draw_set_pipeline(null); @@ -452,7 +452,7 @@ function ui_files_go_up(handle: ui_handle_t) { } type ui_files_make_icon_t = { - image: iron_g5_texture_t; + image: iron_gpu_texture_t; shandle: string; w: i32; }; diff --git a/base/sources/ts/ui_menu.ts b/base/sources/ts/ui_menu.ts index 0a9c67b3..c7f09fd1 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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; draw_end(); util_uv_cache_uv_map(); draw_begin(current); @@ -312,7 +312,7 @@ function ui_menu_render() { ]; let shortcuts: string[] = ["l", "b", "n", "o", "r", "m", "a", "h", "e", "s", "t", "1", "2", "3", "4"]; - if (iron_g5_raytrace_supported()) { + if (iron_gpu_raytrace_supported()) { array_push(modes, tr("Path Traced")); array_push(shortcuts, "p"); } @@ -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: iron_g5_texture_t = data_get_image("badge.k"); + let img: iron_gpu_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 0652bef7..cd172aed 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: iron_g5_texture_t = resource_get("icons.k"); + let img: iron_gpu_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 41a68305..0dc6020e 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: iron_g5_texture_t = null; +let ui_nodes_grid: iron_gpu_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; @@ -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): iron_g5_texture_t { +function ui_nodes_draw_grid(zoom: f32): iron_gpu_texture_t { let ww: i32 = config_raw.layout[layout_size_t.NODES_W]; ///if (is_paint || is_sculpt) @@ -736,9 +736,9 @@ function ui_nodes_draw_grid(zoom: f32): iron_g5_texture_t { h = 1; } - let grid: iron_g5_texture_t = iron_g4_create_render_target(w, h); + let grid: iron_gpu_texture_t = gpu_create_render_target(w, h); draw_begin(grid); - iron_g5_clear(ui_nodes_ui.ops.theme.SEPARATOR_COL); + iron_gpu_clear(ui_nodes_ui.ops.theme.SEPARATOR_COL); let sep_col: i32 = ui_nodes_ui.ops.theme.SEPARATOR_COL; let line_primary: i32 = sep_col - 0x00050505; @@ -1056,7 +1056,7 @@ function ui_nodes_render() { // Node previews if (config_raw.node_preview && nodes.nodes_selected_id.length > 0) { - let img: iron_g5_texture_t = null; + let img: iron_gpu_texture_t = null; let sel: ui_node_t = ui_get_node(c.nodes, nodes.nodes_selected_id[0]); ///if (is_paint || is_sculpt) @@ -1106,7 +1106,7 @@ function ui_nodes_render() { ///if (is_paint || is_sculpt) if (single_channel) { draw_set_pipeline(ui_view2d_pipe); - _iron_g4_set_int(ui_view2d_channel_loc, 1); + _gpu_set_int(ui_view2d_channel_loc, 1); } ///end @@ -1587,7 +1587,7 @@ function ui_nodes_make_node_preview() { } if (context_raw.node_preview == null) { - context_raw.node_preview = iron_g4_create_render_target(util_render_material_preview_size, util_render_material_preview_size); + context_raw.node_preview = gpu_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 b9497230..59bd1c2a 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: iron_g5_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_draw_tool(i: i32, ui: ui_t, img: iron_gpu_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: iron_g5_texture_t = resource_get("icons.k"); + let img: iron_gpu_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 4698aed8..f9f9aed6 100644 --- a/base/sources/ts/ui_view2d.ts +++ b/base/sources/ts/ui_view2d.ts @@ -1,6 +1,6 @@ -let ui_view2d_pipe: iron_g5_pipeline_t; -let ui_view2d_channel_loc: iron_g5_constant_location_t; +let ui_view2d_pipe: iron_gpu_pipeline_t; +let ui_view2d_channel_loc: iron_gpu_constant_location_t; let ui_view2d_text_input_hover: bool = false; let ui_view2d_uvmap_show: bool = false; let ui_view2d_tex_type: paint_tex_t = paint_tex_t.BASE; @@ -22,29 +22,29 @@ 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: iron_g5_texture_t; +let _ui_view2d_render_tex: iron_gpu_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: iron_g5_texture_t = null; +let ui_view2d_grid: iron_gpu_texture_t = null; let ui_view2d_grid_redraw: bool = true; function ui_view2d_init() { ///if (is_paint || is_sculpt) - ui_view2d_pipe = iron_g4_create_pipeline(); + ui_view2d_pipe = gpu_create_pipeline(); ui_view2d_pipe.vertex_shader = sys_get_shader("layer_view.vert"); ui_view2d_pipe.fragment_shader = sys_get_shader("layer_view.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); - g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); - g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + gpu_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); ui_view2d_pipe.input_layout = vs; ui_view2d_pipe.blend_source = blend_factor_t.BLEND_ONE; ui_view2d_pipe.blend_destination = blend_factor_t.BLEND_ZERO; ARRAY_ACCESS(ui_view2d_pipe.color_write_mask_alpha, 0) = false; - iron_g4_compile_pipeline(ui_view2d_pipe); - ui_view2d_channel_loc = iron_g4_get_constant_location(ui_view2d_pipe, "channel"); + gpu_compile_pipeline(ui_view2d_pipe); + ui_view2d_channel_loc = gpu_get_constant_location(ui_view2d_pipe, "channel"); ///end let scale: f32 = config_raw.window_scale; @@ -139,7 +139,7 @@ function ui_view2d_render() { draw_image(ui_view2d_grid, x, y); // Texture - let tex: iron_g5_texture_t = null; + let tex: iron_gpu_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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); layer = layers_flatten(); if (g2_in_use) draw_begin(current); } else if (slot_layer_is_group(layer)) { - let current: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); layer = layers_flatten(false, slot_layer_get_children(layer)); @@ -223,7 +223,7 @@ function ui_view2d_render() { if (!context_raw.texture_filter) { draw_set_bilinear_filter(false); } - _iron_g4_set_int(ui_view2d_channel_loc, channel); + _gpu_set_int(ui_view2d_channel_loc, channel); } ///end @@ -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: iron_g5_texture_t = rt._image; + let texpaint_picker: iron_gpu_texture_t = rt._image; draw_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); draw_end(); - let a: buffer_t = iron_g4_get_texture_pixels(texpaint_picker); + let a: buffer_t = gpu_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: iron_g5_texture_t = resource_get("cursor.k"); + let cursor_img: iron_gpu_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 16f470a4..924ce8b1 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): iron_g5_texture_t { +function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: string): iron_gpu_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 50f3e573..bae8288c 100644 --- a/base/sources/ts/util_mesh.ts +++ b/base/sources/ts/util_mesh.ts @@ -159,8 +159,8 @@ function util_mesh_swap_axis(a: i32, b: i32) { } let g: mesh_data_t = o.data; - let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; - let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex + let l: i32 = iron_gpu_vertex_struct_size(g._.structure) / 2; + let vertices: buffer_t = gpu_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor((vertices.length) / 2 / l); ++i) { buffer_set_i16(vertices, (i * l ) * 2, vas[0].values[i * 4 ]); buffer_set_i16(vertices, (i * l + 1) * 2, vas[0].values[i * 4 + 1]); @@ -169,7 +169,7 @@ function util_mesh_swap_axis(a: i32, b: i32) { buffer_set_i16(vertices, (i * l + 4) * 2, vas[1].values[i * 2 ]); buffer_set_i16(vertices, (i * l + 5) * 2, vas[1].values[i * 2 + 1]); } - iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + gpu_vertex_buffer_unlock_all(g._.vertex_buffer); } util_mesh_remove_merged(); @@ -184,8 +184,8 @@ function util_mesh_flip_normals() { let va0: i16_array_t = vas[0].values; let va1: i16_array_t = vas[1].values; let g: mesh_data_t = o.data; - let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; - let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex + let l: i32 = iron_gpu_vertex_struct_size(g._.structure) / 2; + let vertices: buffer_t = gpu_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor((vertices.length) / 2 / l); ++i) { va0[i * 4 + 3] = -va0[i * 4 + 3]; va1[i * 2] = -va1[i * 2]; @@ -194,7 +194,7 @@ function util_mesh_flip_normals() { buffer_set_i16(vertices, (i * l + 4) * 2, -buffer_get_i16(vertices, (i * l + 4) * 2)); buffer_set_i16(vertices, (i * l + 5) * 2, -buffer_get_i16(vertices, (i * l + 5) * 2)); } - iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + gpu_vertex_buffer_unlock_all(g._.vertex_buffer); } render_path_raytrace_ready = false; @@ -210,9 +210,9 @@ function util_mesh_calc_normals(smooth: bool = false) { for (let i: i32 = 0; i < objects.length; ++i) { let o: mesh_object_t = objects[i]; let g: mesh_data_t = o.data; - let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; + let l: i32 = iron_gpu_vertex_struct_size(g._.structure) / 2; let inda: u32_array_t = g._.indices[0]; - let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex + let vertices: buffer_t = gpu_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor(inda.length / 3); ++i) { let i1: i32 = inda[i * 3 ]; let i2: i32 = inda[i * 3 + 1]; @@ -286,7 +286,7 @@ function util_mesh_calc_normals(smooth: bool = false) { } } } - iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + gpu_vertex_buffer_unlock_all(g._.vertex_buffer); let va0: i16_array_t = o.data.vertex_arrays[0].values; let va1: i16_array_t = o.data.vertex_arrays[1].values; @@ -370,26 +370,26 @@ function util_mesh_to_origin() { va[i * 4 + 2] = math_floor((va[i * 4 + 2] * sc - dz) / max_scale * 32767); } - let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; - let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex + let l: i32 = iron_gpu_vertex_struct_size(g._.structure) / 2; + let vertices: buffer_t = gpu_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor((vertices.length) / 2 / l); ++i) { buffer_set_i16(vertices, (i * l ) * 2, va[i * 4 ]); buffer_set_i16(vertices, (i * l + 1) * 2, va[i * 4 + 1]); buffer_set_i16(vertices, (i * l + 2) * 2, va[i * 4 + 2]); } - iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + gpu_vertex_buffer_unlock_all(g._.vertex_buffer); } util_mesh_merge(); } -function util_mesh_apply_displacement(texpaint_pack: iron_g5_texture_t, strength: f32 = 0.1, uv_scale: f32 = 1.0) { - let height: buffer_t = iron_g4_get_texture_pixels(texpaint_pack); +function util_mesh_apply_displacement(texpaint_pack: iron_gpu_texture_t, strength: f32 = 0.1, uv_scale: f32 = 1.0) { + let height: buffer_t = gpu_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; - let l: i32 = iron_g5_vertex_struct_size(g._.structure) / 2; - let vertices: buffer_t = iron_g4_lock_vertex_buffer(g._.vertex_buffer); // posnortex + let l: i32 = iron_gpu_vertex_struct_size(g._.structure) / 2; + let vertices: buffer_t = gpu_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor((vertices.length) / 2 / l); ++i) { let x: i32 = math_floor(buffer_get_i16(vertices, (i * l + 6) * 2) / 32767 * res); let y: i32 = math_floor(buffer_get_i16(vertices, (i * l + 7) * 2) / 32767 * res); @@ -402,7 +402,7 @@ function util_mesh_apply_displacement(texpaint_pack: iron_g5_texture_t, strength buffer_set_i16(vertices, (i * l + 1) * 2, buffer_get_i16(vertices, (i * l + 1) * 2) - math_floor(buffer_get_i16(vertices, (i * l + 5) * 2) * h)); buffer_set_i16(vertices, (i * l + 2) * 2, buffer_get_i16(vertices, (i * l + 2) * 2) - math_floor(buffer_get_i16(vertices, (i * l + 3) * 2) * h)); } - iron_g4_vertex_buffer_unlock_all(g._.vertex_buffer); + gpu_vertex_buffer_unlock_all(g._.vertex_buffer); let va0: i16_array_t = o.data.vertex_arrays[0].values; for (let i: i32 = 0; i < math_floor((vertices.length) / 4 / l); ++i) { diff --git a/base/sources/ts/util_render.ts b/base/sources/ts/util_render.ts index c289b420..a21d8bcf 100644 --- a/base/sources/ts/util_render.ts +++ b/base/sources/ts/util_render.ts @@ -3,8 +3,8 @@ let util_render_material_preview_size: i32 = 256; let util_render_decal_preview_size: i32 = 512; let util_render_layer_preview_size: i32 = 200; let util_render_font_preview_size: i32 = 200; -let util_render_screen_aligned_full_vb: iron_g5_vertex_buffer_t = null; -let util_render_screen_aligned_full_ib: iron_g5_index_buffer_t = null; +let util_render_screen_aligned_full_vb: iron_gpu_vertex_buffer_t = null; +let util_render_screen_aligned_full_ib: iron_gpu_index_buffer_t = null; function util_render_make_material_preview() { context_raw.material_preview = true; @@ -79,12 +79,12 @@ function util_render_make_material_preview() { } function util_render_make_decal_preview() { - let current: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); if (context_raw.decal_image == null) { - context_raw.decal_image = iron_g4_create_render_target(util_render_decal_preview_size, util_render_decal_preview_size); + context_raw.decal_image = gpu_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: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -162,13 +162,13 @@ function util_render_make_text_preview() { } if (context_raw.text_tool_image == null) { ///if arm_metal - context_raw.text_tool_image = iron_g4_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); + context_raw.text_tool_image = gpu_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); ///else - context_raw.text_tool_image = iron_g4_create_render_target(tex_w, tex_w, tex_format_t.R8); + context_raw.text_tool_image = gpu_create_render_target(tex_w, tex_w, tex_format_t.R8); ///end } draw_begin(context_raw.text_tool_image); - iron_g5_clear(0xff000000); + iron_gpu_clear(0xff000000); draw_set_font(font, font_size); draw_set_color(0xffffffff); draw_string(text, tex_w / 2 - text_w / 2, tex_w / 2 - text_h / 2); @@ -178,7 +178,7 @@ function util_render_make_text_preview() { } function util_render_make_font_preview() { - let current: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -189,10 +189,10 @@ function util_render_make_font_preview() { let text_h: i32 = math_floor(draw_font_height(font, font_size)) + 8; let tex_w: i32 = text_w + 32; if (context_raw.font.image == null) { - context_raw.font.image = iron_g4_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); + context_raw.font.image = gpu_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); } draw_begin(context_raw.font.image); - iron_g5_clear(0x00000000); + iron_gpu_clear(0x00000000); draw_set_font(font, font_size); draw_set_color(0xffffffff); draw_string(text, tex_w / 2 - text_w / 2, tex_w / 2 - text_h / 2); @@ -207,7 +207,7 @@ function util_render_make_brush_preview() { return; } - let current: iron_g5_texture_t = _draw_current; + let current: iron_gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_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 = 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); + context_raw.brush.image = gpu_create_render_target(util_render_material_preview_size, util_render_material_preview_size); + context_raw.brush.image_icon = gpu_create_render_target(50, 50); } let _material: slot_material_t = context_raw.material; @@ -365,9 +365,9 @@ function util_render_make_brush_preview() { // Scale layer down to to image preview l = render_path_paint_live_layer; - let target: iron_g5_texture_t = context_raw.brush.image; + let target: iron_gpu_texture_t = context_raw.brush.image; draw_begin(target); - iron_g5_clear(0x00000000); + iron_gpu_clear(0x00000000); draw_set_pipeline(pipes_copy); draw_scaled_image(l.texpaint, 0, 0, target.width, target.height); draw_set_pipeline(null); @@ -388,7 +388,7 @@ function util_render_make_brush_preview() { if (g2_in_use) draw_begin(current); } -function util_render_make_node_preview(canvas: ui_node_canvas_t, node: ui_node_t, image: iron_g5_texture_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: iron_gpu_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; @@ -402,16 +402,16 @@ function util_render_make_node_preview(canvas: ui_node_canvas_t, node: ui_node_t context_raw.paint_object.base.transform.scale_world = 3.0; transform_build_matrix(context_raw.paint_object.base.transform); - _iron_g4_begin(image); - iron_g5_set_pipeline(res.scon._.pipe_state); + _gpu_begin(image); + iron_gpu_set_pipeline(res.scon._.pipe_state); let empty: string[] = [""]; uniforms_set_context_consts(res.scon, empty); uniforms_set_obj_consts(res.scon, context_raw.paint_object.base); uniforms_set_material_consts(res.scon, res.mcon); - iron_g4_set_vertex_buffer(util_render_screen_aligned_full_vb); - iron_g4_set_index_buffer(util_render_screen_aligned_full_ib); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + gpu_set_vertex_buffer(util_render_screen_aligned_full_vb); + gpu_set_index_buffer(util_render_screen_aligned_full_ib); + gpu_draw_indexed_vertices(); + _gpu_end(); context_raw.paint_object.base.transform.scale_world = _scale_world; transform_build_matrix(context_raw.paint_object.base.transform); @@ -458,22 +458,22 @@ function util_render_create_screen_aligned_full_data() { let indices: u32[] = [0, 1, 2]; // Mandatory vertex data names and sizes - let structure: iron_g5_vertex_structure_t = g4_vertex_struct_create(); - g4_vertex_struct_add(structure, "pos", vertex_data_t.I16_4X_NORM); - g4_vertex_struct_add(structure, "nor", vertex_data_t.I16_2X_NORM); - g4_vertex_struct_add(structure, "tex", vertex_data_t.I16_2X_NORM); - g4_vertex_struct_add(structure, "col", vertex_data_t.I16_4X_NORM); - util_render_screen_aligned_full_vb = iron_g4_create_vertex_buffer(math_floor(data.length / math_floor(iron_g5_vertex_struct_size(structure) / 2)), structure, usage_t.STATIC); - let vertices: buffer_t = iron_g4_lock_vertex_buffer(util_render_screen_aligned_full_vb); + let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + gpu_vertex_struct_add(structure, "pos", vertex_data_t.I16_4X_NORM); + gpu_vertex_struct_add(structure, "nor", vertex_data_t.I16_2X_NORM); + gpu_vertex_struct_add(structure, "tex", vertex_data_t.I16_2X_NORM); + gpu_vertex_struct_add(structure, "col", vertex_data_t.I16_4X_NORM); + util_render_screen_aligned_full_vb = gpu_create_vertex_buffer(math_floor(data.length / math_floor(iron_gpu_vertex_struct_size(structure) / 2)), structure, usage_t.STATIC); + let vertices: buffer_t = gpu_lock_vertex_buffer(util_render_screen_aligned_full_vb); for (let i: i32 = 0; i < math_floor((vertices.length) / 2); ++i) { buffer_set_i16(vertices, i * 2, data[i]); } - iron_g4_vertex_buffer_unlock_all(util_render_screen_aligned_full_vb); + gpu_vertex_buffer_unlock_all(util_render_screen_aligned_full_vb); - util_render_screen_aligned_full_ib = iron_g4_create_index_buffer(indices.length); - let id: u32_array_t = iron_g4_lock_index_buffer(util_render_screen_aligned_full_ib); + util_render_screen_aligned_full_ib = gpu_create_index_buffer(indices.length); + let id: u32_array_t = gpu_lock_index_buffer(util_render_screen_aligned_full_ib); for (let i: i32 = 0; i < id.length; ++i) { id[i] = indices[i]; } - iron_g4_index_buffer_unlock_all(util_render_screen_aligned_full_ib); + gpu_index_buffer_unlock_all(util_render_screen_aligned_full_ib); } diff --git a/base/sources/ts/util_uv.ts b/base/sources/ts/util_uv.ts index fa90dd49..38f18858 100644 --- a/base/sources/ts/util_uv.ts +++ b/base/sources/ts/util_uv.ts @@ -1,14 +1,14 @@ -let util_uv_uvmap: iron_g5_texture_t = null; +let util_uv_uvmap: iron_gpu_texture_t = null; let util_uv_uvmap_cached: bool = false; -let util_uv_trianglemap: iron_g5_texture_t = null; +let util_uv_trianglemap: iron_gpu_texture_t = null; let util_uv_trianglemap_cached: bool = false; -let util_uv_dilatemap: iron_g5_texture_t = null; +let util_uv_dilatemap: iron_gpu_texture_t = null; let util_uv_dilatemap_cached: bool = false; -let util_uv_uvislandmap: iron_g5_texture_t = null; +let util_uv_uvislandmap: iron_gpu_texture_t = null; let util_uv_uvislandmap_cached: bool = false; let util_uv_dilate_bytes: buffer_t = null; -let util_uv_pipe_dilate: iron_g5_pipeline_t = null; +let util_uv_pipe_dilate: iron_gpu_pipeline_t = null; function util_uv_cache_uv_map() { if (util_uv_uvmap != null && (util_uv_uvmap.width != config_get_texture_res_x() || util_uv_uvmap.height != config_get_texture_res_y())) { @@ -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 = iron_g4_create_render_target(res_x, res_y); + util_uv_uvmap = gpu_create_render_target(res_x, res_y); } util_uv_uvmap_cached = true; @@ -35,7 +35,7 @@ function util_uv_cache_uv_map() { let texa: i16_array_t = mesh.vertex_arrays[2].values; let inda: u32_array_t = mesh.index_arrays[0].values; draw_begin(util_uv_uvmap); - iron_g5_clear(0x00000000); + iron_gpu_clear(0x00000000); draw_set_color(0xffffffff); let strength: f32 = res_x > 2048 ? 2.0 : 1.0; let f: f32 = (1 / 32767) * util_uv_uvmap.width; @@ -65,7 +65,7 @@ function util_uv_cache_triangle_map() { } if (util_uv_trianglemap == null) { - util_uv_trianglemap = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); + util_uv_trianglemap = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y()); } util_uv_trianglemap_cached = true; @@ -74,7 +74,7 @@ function util_uv_cache_triangle_map() { let texa: i16_array_t = mesh.vertex_arrays[2].values; let inda: u32_array_t = mesh.index_arrays[0].values; draw_begin(util_uv_trianglemap); - iron_g5_clear(0xff000000); + iron_gpu_clear(0xff000000); let f: f32 = (1 / 32767) * util_uv_trianglemap.width; let color: i32 = 0xff000001; for (let i: i32 = 0; i < math_floor(inda.length / 3); ++i) { @@ -102,26 +102,26 @@ function util_uv_cache_dilate_map() { if (util_uv_dilatemap_cached) return; if (util_uv_dilatemap == null) { - util_uv_dilatemap = iron_g4_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); + util_uv_dilatemap = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); } if (util_uv_pipe_dilate == null) { - util_uv_pipe_dilate = iron_g4_create_pipeline(); + util_uv_pipe_dilate = gpu_create_pipeline(); util_uv_pipe_dilate.vertex_shader = sys_get_shader("dilate_map.vert"); util_uv_pipe_dilate.fragment_shader = sys_get_shader("dilate_map.frag"); - let vs: iron_g5_vertex_structure_t = g4_vertex_struct_create(); + let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); ///if (arm_metal || arm_vulkan) - g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///else - g4_vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); - g4_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); - g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); + gpu_vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); + gpu_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); + gpu_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///end util_uv_pipe_dilate.input_layout = vs; util_uv_pipe_dilate.depth_write = false; util_uv_pipe_dilate.depth_mode = compare_mode_t.ALWAYS; ARRAY_ACCESS(util_uv_pipe_dilate.color_attachment, 0) = tex_format_t.R8; - iron_g4_compile_pipeline(util_uv_pipe_dilate); + gpu_compile_pipeline(util_uv_pipe_dilate); // dilate_tex_unpack = getConstantLocation(pipeDilate, "tex_unpack"); } @@ -130,9 +130,9 @@ function util_uv_cache_dilate_map() { mask = context_raw.layer_filter; } let geom: mesh_data_t = mask == 0 && context_raw.merged_object != null ? context_raw.merged_object.data : context_raw.paint_object.data; - _iron_g4_begin(util_uv_dilatemap); - iron_g5_clear(0x00000000); - iron_g5_set_pipeline(util_uv_pipe_dilate); + _gpu_begin(util_uv_dilatemap); + iron_gpu_clear(0x00000000); + iron_gpu_set_pipeline(util_uv_pipe_dilate); ///if (arm_metal || arm_vulkan) let vs: vertex_element_t[] = [ { @@ -140,13 +140,13 @@ function util_uv_cache_dilate_map() { data: "short2norm" } ]; - iron_g4_set_vertex_buffer(mesh_data_get(geom, vs)); + gpu_set_vertex_buffer(mesh_data_get(geom, vs)); ///else - iron_g4_set_vertex_buffer(geom._.vertex_buffer); + gpu_set_vertex_buffer(geom._.vertex_buffer); ///end - iron_g4_set_index_buffer(geom._.index_buffers[0]); - iron_g4_draw_indexed_vertices(); - _iron_g4_end(); + gpu_set_index_buffer(geom._.index_buffers[0]); + gpu_draw_indexed_vertices(); + _gpu_end(); util_uv_dilatemap_cached = true; util_uv_dilate_bytes = 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 = iron_g4_get_texture_pixels(util_uv_dilatemap); + util_uv_dilate_bytes = gpu_get_texture_pixels(util_uv_dilatemap); } util_render_pick_pos_nor_tex(); let w: i32 = 2048; // config_get_texture_res_x() @@ -200,6 +200,6 @@ function util_uv_cache_uv_island_map() { if (util_uv_uvislandmap != null) { iron_unload_image(util_uv_uvislandmap); } - util_uv_uvislandmap = iron_g4_create_texture_from_bytes(bytes, w, h, tex_format_t.R8); + util_uv_uvislandmap = gpu_create_texture_from_bytes(bytes, w, h, tex_format_t.R8); util_uv_uvislandmap_cached = true; } diff --git a/base/tests/triangle/main.ts b/base/tests/triangle/main.ts index ca837c98..fcfc3aa8 100644 --- a/base/tests/triangle/main.ts +++ b/base/tests/triangle/main.ts @@ -2,24 +2,24 @@ // Red triangle test // ../../../make --graphics vulkan --run -let pipeline: iron_g5_pipeline_t; +let pipeline: iron_gpu_pipeline_t; let vb: any; let ib: any; function render() { - _iron_g4_begin(null, null); + _gpu_begin(null, null); let flags: i32 = 0; flags |= 1; // Color flags |= 2; // Depth - iron_g5_clear(0xff000000, 1.0, flags); + iron_gpu_clear(0xff000000, 1.0, flags); - iron_g5_set_pipeline(pipeline); - iron_g4_set_vertex_buffer(vb); - iron_g4_set_index_buffer(ib); - iron_g4_draw_indexed_vertices(0, -1); + iron_gpu_set_pipeline(pipeline); + gpu_set_vertex_buffer(vb); + gpu_set_index_buffer(ib); + gpu_draw_indexed_vertices(0, -1); - _iron_g4_end(); + _gpu_end(); } function main() { @@ -28,18 +28,18 @@ function main() { let maximizable: i32 = 4; _iron_init("Iron", 640, 480, true, 0, resizable | minimizable | maximizable, -1, -1, 60); - pipeline = iron_g4_create_pipeline(); + pipeline = gpu_create_pipeline(); let f32_3x: vertex_data_t = vertex_data_t.F32_3X; - let elem: iron_g5_vertex_element_t = { name: "pos", data: f32_3x }; - let elems: iron_g5_vertex_element_t[] = [elem]; + let elem: iron_gpu_vertex_element_t = { name: "pos", data: f32_3x }; + let elems: iron_gpu_vertex_element_t[] = [elem]; - let structure0: iron_g5_vertex_structure_t = { elements: elems }; + let structure0: iron_gpu_vertex_structure_t = { elements: elems }; let vs_buffer: buffer_t = iron_load_blob("./data/test.vert.spirv"); let fs_buffer: buffer_t = iron_load_blob("./data/test.frag.spirv"); - let vert: any = iron_g4_create_shader(vs_buffer, shader_type_t.VERTEX); - let frag: any = iron_g4_create_shader(fs_buffer, shader_type_t.FRAGMENT); + let vert: any = gpu_create_shader(vs_buffer, shader_type_t.VERTEX); + let frag: any = gpu_create_shader(fs_buffer, shader_type_t.FRAGMENT); let masks: bool[] = [true, true, true, true, true, true, true, true]; let attachments: i32[] = [0]; @@ -62,7 +62,7 @@ function main() { pipeline.fragment_shader = frag; pipeline.input_layout = structure0; - iron_g4_compile_pipeline(pipeline); + gpu_compile_pipeline(pipeline); let vertices: f32[] = [ -1.0, -1.0, 0.0, @@ -71,19 +71,19 @@ function main() { ]; let indices: i32[] = [0, 1, 2]; - vb = iron_g4_create_vertex_buffer(vertices.length / 3, structure0.elements, 0); - let vb_data: buffer_t = iron_g4_lock_vertex_buffer(vb); + vb = gpu_create_vertex_buffer(vertices.length / 3, structure0.elements, 0); + let vb_data: buffer_t = gpu_lock_vertex_buffer(vb); for (let i: i32 = 0; i < vertices.length; i++) { buffer_set_f32(vb_data, i * 4, vertices[i]); } - iron_g4_vertex_buffer_unlock_all(vb); + gpu_vertex_buffer_unlock_all(vb); - ib = iron_g4_create_index_buffer(indices.length); - let ib_data: u32_array_t = iron_g4_lock_index_buffer(ib); + ib = gpu_create_index_buffer(indices.length); + let ib_data: u32_array_t = gpu_lock_index_buffer(ib); for (let i: i32 = 0; i < indices.length; i++) { ib_data[i] = indices[i]; } - iron_g4_index_buffer_unlock_all(ib); + gpu_index_buffer_unlock_all(ib); _iron_set_update_callback(render); } diff --git a/base/tools/amake/aimage.c b/base/tools/amake/aimage.c index 82396698..215cfdec 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; -} iron_g5_texture_t; +} iron_gpu_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 iron_g5_texture_t read_png_jpg(const char *filename) { +static iron_gpu_texture_t read_png_jpg(const char *filename) { int width, height, n; char *data = stbi_load(filename, &width, &height, &n, 4); - iron_g5_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = false }; + iron_gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = false }; return img; } -static iron_g5_texture_t read_hdr(const char *filename) { +static iron_gpu_texture_t read_hdr(const char *filename) { int width, height, n; float *data = stbi_loadf(filename, &width, &height, &n, 4); - iron_g5_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = true }; + iron_gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = true }; return img; } -static void *scale_image(iron_g5_texture_t img, int width, int height) { +static void *scale_image(iron_gpu_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) { - iron_g5_texture_t img = read_png_jpg(from); + iron_gpu_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) { - iron_g5_texture_t img = read_png_jpg(from); + iron_gpu_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) { - iron_g5_texture_t img; + iron_gpu_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 a1d0a9f9..1f6ca6bb 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: iron_g5_texture_t = null; +let minimap: iron_gpu_texture_t = null; let window_header_h: i32 = 0; function drop_files(path: string) { @@ -317,11 +317,11 @@ function draw_minimap() { if (minimap != null) { iron_unload_image(minimap); } - minimap = iron_g4_create_render_target(minimap_w, minimap_h); + minimap = gpu_create_render_target(minimap_w, minimap_h); } draw_begin(minimap); - iron_g5_clear(theme.SEPARATOR_COL); + iron_gpu_clear(theme.SEPARATOR_COL); draw_set_color(0xff333333); let lines: string[] = string_split(storage.text, "\n"); let minimap_full_h: i32 = lines.length * 2;