From a7df5974aeda2602c0f1988066bb636b9d13f4d4 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Thu, 19 Jun 2025 19:55:16 +0200 Subject: [PATCH] Gpu cleanup --- armorforge/sources/ui_toolbar_ext.ts | 2 +- armorlab/sources/layers_ext.ts | 8 +- .../sources/nodes/brush_output_node_ext.ts | 12 +- armorlab/sources/nodes/image_texture_node.ts | 6 +- armorlab/sources/nodes/inpaint_node.ts | 36 +- armorlab/sources/nodes/photo_to_pbr_node.ts | 14 +- armorlab/sources/nodes/rgb_node.ts | 6 +- armorlab/sources/nodes/text_to_photo_node.ts | 14 +- armorlab/sources/nodes/tiling_node.ts | 16 +- armorlab/sources/nodes/upscale_node.ts | 22 +- armorlab/sources/nodes/variance_node.ts | 10 +- armorlab/sources/render_path_paint.ts | 12 +- armorlab/sources/ui_nodes_ext.ts | 22 +- armorlab/sources/ui_toolbar_ext.ts | 2 +- armorpaint/sources/layers_ext.ts | 58 +- armorpaint/sources/make_material.ts | 12 +- .../sources/nodes/brush_output_node_ext.ts | 4 +- armorpaint/sources/render_path_paint.ts | 16 +- armorpaint/sources/ui_header_ext.ts | 22 +- armorpaint/sources/ui_toolbar_ext.ts | 2 +- armorsculpt/sources/export_obj.ts | 2 +- armorsculpt/sources/import_mesh.ts | 4 +- armorsculpt/sources/make_material.ts | 10 +- .../sources/nodes/brush_output_node_ext.ts | 4 +- armorsculpt/sources/render_path_sculpt.ts | 6 +- armorsculpt/sources/tab_layers.ts | 2 +- armorsculpt/sources/ui_toolbar_ext.ts | 2 +- base/sources/backends/android_system.c | 4 +- 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 | 4 +- base/sources/backends/direct3d12_gpu.c | 1158 +++++++---------- base/sources/backends/direct3d12_gpu.h | 74 +- base/sources/backends/ios_system.h | 2 +- base/sources/backends/linux_system.c | 6 +- base/sources/backends/linux_video.c | 2 +- base/sources/backends/macos_system.h | 2 +- base/sources/backends/metal_gpu.h | 10 +- base/sources/backends/metal_gpu.m | 258 ++-- base/sources/backends/vulkan_gpu.c | 328 ++--- base/sources/backends/wasm_video.c | 2 +- base/sources/backends/webgpu_gpu.c | 169 ++- base/sources/backends/windows_system.c | 6 +- base/sources/backends/windows_video.c | 2 +- base/sources/iron.h | 176 +-- base/sources/iron_draw.c | 182 +-- base/sources/iron_draw.h | 14 +- base/sources/iron_gpu.c | 52 +- base/sources/iron_gpu.h | 288 ++-- base/sources/iron_ui.c | 44 +- 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 | 16 +- base/sources/ts/export_texture.ts | 50 +- base/sources/ts/import_arm.ts | 26 +- base/sources/ts/import_blend_material.ts | 2 +- base/sources/ts/import_envmap.ts | 34 +- base/sources/ts/import_texture.ts | 10 +- base/sources/ts/iron/const_data.ts | 24 +- base/sources/ts/iron/data.ts | 12 +- base/sources/ts/iron/iron.ts | 92 +- base/sources/ts/iron/material_data.ts | 8 +- base/sources/ts/iron/mesh_data.ts | 24 +- base/sources/ts/iron/mesh_object.ts | 8 +- base/sources/ts/iron/render_path.ts | 44 +- base/sources/ts/iron/scene.ts | 24 +- base/sources/ts/iron/shader_data.ts | 4 +- base/sources/ts/iron/sys.ts | 6 +- base/sources/ts/iron/uniforms.ts | 20 +- base/sources/ts/iron/world_data.ts | 6 +- base/sources/ts/layers.ts | 126 +- base/sources/ts/line_draw.ts | 36 +- base/sources/ts/logic_node.ts | 10 +- base/sources/ts/nodes/color_node.ts | 4 +- base/sources/ts/nodes/float_node.ts | 4 +- base/sources/ts/nodes/vector_node.ts | 4 +- base/sources/ts/parser_material.ts | 2 +- base/sources/ts/path.ts | 2 +- base/sources/ts/pipes.ts | 72 +- base/sources/ts/project.ts | 8 +- 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 | 60 +- base/sources/ts/slot_material.ts | 4 +- base/sources/ts/tab_brushes.ts | 4 +- base/sources/ts/tab_fonts.ts | 2 +- base/sources/ts/tab_layers.ts | 10 +- base/sources/ts/tab_materials.ts | 4 +- base/sources/ts/tab_swatches.ts | 6 +- base/sources/ts/tab_textures.ts | 12 +- base/sources/ts/ui_base.ts | 16 +- base/sources/ts/ui_box.ts | 2 +- base/sources/ts/ui_files.ts | 26 +- base/sources/ts/ui_menu.ts | 6 +- base/sources/ts/ui_menubar.ts | 2 +- base/sources/ts/ui_nodes.ts | 8 +- base/sources/ts/ui_toolbar.ts | 4 +- base/sources/ts/ui_view2d.ts | 18 +- base/sources/ts/uniforms_ext.ts | 2 +- base/sources/ts/util_mesh.ts | 22 +- base/sources/ts/util_render.ts | 32 +- base/sources/ts/util_uv.ts | 20 +- base/tests/triangle/main.ts | 16 +- base/tools/amake/aimage.c | 18 +- base/tools/pad/sources/main.ts | 2 +- 116 files changed, 2034 insertions(+), 2211 deletions(-) diff --git a/armorforge/sources/ui_toolbar_ext.ts b/armorforge/sources/ui_toolbar_ext.ts index 57f7ade2..3b65b67f 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_gpu_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: 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 95bf141b..8f6a398e 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_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 texpaint: gpu_texture_t = context_raw.brush_output_node_inst.texpaint; + let texpaint_nor: gpu_texture_t = context_raw.brush_output_node_inst.texpaint_nor; + let texpaint_pack: 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); @@ -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_gpu_texture_t = photo_to_pbr_node_images[i]; + let image: gpu_texture_t = photo_to_pbr_node_images[i]; iron_unload_image(image); } photo_to_pbr_node_images = null; diff --git a/armorlab/sources/nodes/brush_output_node_ext.ts b/armorlab/sources/nodes/brush_output_node_ext.ts index 11bb9bac..0edd9037 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_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; + texpaint?: gpu_texture_t; + texpaint_nor?: gpu_texture_t; + texpaint_pack?: gpu_texture_t; + texpaint_nor_empty?: gpu_texture_t; + texpaint_pack_empty?: 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_gpu_texture_t { +function brush_output_node_get_as_image(self: brush_output_node_t, from: i32): 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 6c1004d5..437fbac4 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_gpu_texture_t { +function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): 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_gpu_texture_t { - let image: iron_gpu_texture_t = self.base.get_as_image(self, 0); +function image_texture_node_get_cached_image(self: image_texture_node_t): gpu_texture_t { + let image: 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 f3e29b41..985ae96e 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_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_image: gpu_texture_t = null; +let inpaint_node_mask: gpu_texture_t = null; +let inpaint_node_result: gpu_texture_t = null; -let inpaint_node_temp: iron_gpu_texture_t = null; +let inpaint_node_temp: gpu_texture_t = null; let inpaint_node_prompt: string = ""; let inpaint_node_strength: f32 = 0.5; let inpaint_node_auto: bool = true; @@ -34,7 +34,7 @@ function inpaint_node_init() { inpaint_node_mask = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8); sys_notify_on_next_frame(function () { _gpu_begin(inpaint_node_mask, null, clear_flag_t.COLOR, color_from_floats(1.0, 1.0, 1.0, 1.0)); - iron_gpu_end(); + gpu_end(); }); } @@ -67,8 +67,8 @@ function inpaint_node_button(node_id: i32) { } } -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]); +function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): gpu_texture_t { + let source: gpu_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); console_progress(tr("Processing") + " - " + tr("Inpaint")); draw_begin(inpaint_node_image); @@ -83,26 +83,26 @@ function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): iron_gpu_te } } -function inpaint_node_get_cached_image(self: inpaint_node_t): iron_gpu_texture_t { +function inpaint_node_get_cached_image(self: inpaint_node_t): gpu_texture_t { sys_notify_on_next_frame(function (self: inpaint_node_t) { - let source: iron_gpu_texture_t = logic_node_input_get_as_image(self.base.inputs[0]); + let source: 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); - iron_gpu_set_texture(pipes_tex0_inpaint_preview, source); - iron_gpu_set_texture(pipes_texa_inpaint_preview, inpaint_node_mask); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + 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(); - iron_gpu_end(); + gpu_end(); }, self); return inpaint_node_image; } -function inpaint_node_get_target(): iron_gpu_texture_t { +function inpaint_node_get_target(): gpu_texture_t { return inpaint_node_mask; } -function inpaint_node_texsynth_inpaint(image: iron_gpu_texture_t, tiling: bool, mask: iron_gpu_texture_t): iron_gpu_texture_t { +function inpaint_node_texsynth_inpaint(image: gpu_texture_t, tiling: bool, mask: gpu_texture_t): gpu_texture_t { let w: i32 = config_get_texture_res_x(); let h: i32 = config_get_texture_res_y(); @@ -115,7 +115,7 @@ function inpaint_node_texsynth_inpaint(image: iron_gpu_texture_t, tiling: bool, return inpaint_node_result; } -function inpaint_node_sd_inpaint(image: iron_gpu_texture_t, mask: iron_gpu_texture_t): iron_gpu_texture_t { +function inpaint_node_sd_inpaint(image: gpu_texture_t, mask: gpu_texture_t): gpu_texture_t { inpaint_node_init(); let bytes_img: buffer_t = gpu_get_texture_pixels(mask); diff --git a/armorlab/sources/nodes/photo_to_pbr_node.ts b/armorlab/sources/nodes/photo_to_pbr_node.ts index 6b584bfc..be64cf25 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_gpu_texture_t = null; -let photo_to_pbr_node_images: iron_gpu_texture_t[] = null; +let photo_to_pbr_node_temp: gpu_texture_t = null; +let photo_to_pbr_node_images: 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_gpu_texture_t = null; +let photo_to_pbr_node_cached_source: 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; @@ -35,9 +35,9 @@ function photo_to_pbr_node_init() { } } -function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): iron_gpu_texture_t { +function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): gpu_texture_t { - let source: iron_gpu_texture_t; + let source: gpu_texture_t; if (photo_to_pbr_node_cached_source != null) { source = photo_to_pbr_node_cached_source; } @@ -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_gpu_texture_t = gpu_create_texture_from_bytes(u8a, photo_to_pbr_node_tile_w, photo_to_pbr_node_tile_w); + let temp2: 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(); - sys_notify_on_next_frame(function(temp2: iron_gpu_texture_t) { + sys_notify_on_next_frame(function(temp2: 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 74dca075..87d363ec 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_gpu_texture_t; + image?: 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_gpu_texture_t { +function rgb_node_get_as_image(self: rgb_node_t, from: i32): gpu_texture_t { if (self.image != null) { sys_notify_on_next_frame(function (self: rgb_node_t) { iron_unload_image(self.image); @@ -33,7 +33,7 @@ function rgb_node_get_as_image(self: rgb_node_t, from: i32): iron_gpu_texture_t return self.image; } -function rgb_node_get_cached_image(self: rgb_node_t): iron_gpu_texture_t { +function rgb_node_get_cached_image(self: rgb_node_t): 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 619df60b..4bf22414 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_gpu_texture_t = null; +let text_to_photo_node_image: 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_gpu_texture_t { +function text_to_photo_node_get_as_image(self: text_to_photo_node_t, from: i32): 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_gpu_texture_t { +function text_to_photo_node_get_cached_image(self: text_to_photo_node_t): 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_gpu_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): 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_gpu_texture_t { +function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): 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_gpu_texture_t = gpu_create_texture_from_bytes(u8a, 512, 512); + let image: 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_gpu_texture_t = image; + let last_image: 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 482bc84c..9f0f0606 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_gpu_texture_t; + result?: gpu_texture_t; }; -let tiling_node_image: iron_gpu_texture_t = null; +let tiling_node_image: gpu_texture_t = null; let tiling_node_prompt: string = ""; let tiling_node_strength: f32 = 0.5; let tiling_node_auto: bool = true; @@ -43,8 +43,8 @@ function tiling_node_button(node_id: i32) { } } -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]); +function tiling_node_get_as_image(self: tiling_node_t, from: i32): gpu_texture_t { + let source: 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_gpu_text return self.result; } -function tiling_node_get_cached_image(self: tiling_node_t): iron_gpu_texture_t { +function tiling_node_get_cached_image(self: tiling_node_t): gpu_texture_t { return self.result; } -function tiling_node_sd_tiling(image: iron_gpu_texture_t, seed: i32): iron_gpu_texture_t { +function tiling_node_sd_tiling(image: gpu_texture_t, seed: i32): gpu_texture_t { text_to_photo_node_tiling = false; - let tile: iron_gpu_texture_t = gpu_create_render_target(512, 512); + let tile: 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_gpu_texture_t, seed: i32): iron_gpu_t // u8a[y * 512 + x] = 0; // } // } - let mask: iron_gpu_texture_t = gpu_create_texture_from_bytes(u8a, 512, 512, tex_format_t.R8); + let mask: 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 5ce469ae..10e69c38 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_gpu_texture_t = null; -let upscale_node_image: iron_gpu_texture_t = null; +let upscale_node_temp: gpu_texture_t = null; +let upscale_node_image: 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_gpu_texture_t { +function upscale_node_get_as_image(self: upscale_node_t, from: i32): 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_gpu_te 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_gpu_texture_t = upscale_node_image; + let last_image: 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_gpu_texture_t { +function upscale_node_get_cached_image(self: upscale_node_t): gpu_texture_t { return upscale_node_image; } -function upscale_node_do_tile(source: iron_gpu_texture_t): iron_gpu_texture_t { - let result: iron_gpu_texture_t = null; +function upscale_node_do_tile(source: gpu_texture_t): gpu_texture_t { + let result: gpu_texture_t = null; let size1w: i32 = source.width; let size1h: i32 = source.height; let size2w: i32 = math_floor(size1w * 2); @@ -91,8 +91,8 @@ function upscale_node_do_tile(source: iron_gpu_texture_t): iron_gpu_texture_t { return result; } -function upscale_node_esrgan(source: iron_gpu_texture_t): iron_gpu_texture_t { - let result: iron_gpu_texture_t = null; +function upscale_node_esrgan(source: gpu_texture_t): gpu_texture_t { + let result: gpu_texture_t = null; let size1w: i32 = source.width; let size1h: i32 = source.height; let tile_size: i32 = 512; @@ -102,7 +102,7 @@ function upscale_node_esrgan(source: iron_gpu_texture_t): iron_gpu_texture_t { let size2w: i32 = math_floor(size1w * 2); let size2h: i32 = math_floor(size1h * 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); + let tile_source: 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_gpu_texture_t): iron_gpu_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_gpu_texture_t = upscale_node_do_tile(tile_source); + let tile_result: 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 bcbdefac..3dc9ccca 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_gpu_texture_t = null; -let variance_node_image: iron_gpu_texture_t = null; +let variance_node_temp: gpu_texture_t = null; +let variance_node_image: gpu_texture_t = null; let variance_node_inst: variance_node_t = null; let variance_node_prompt: string = ""; @@ -33,11 +33,11 @@ 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_gpu_texture_t { +function variance_node_get_as_image(self: variance_node_t, from: i32): gpu_texture_t { let node: float_node_t = variance_node_inst.base.inputs[1].node; let strength: f32 = node.value; - let source: iron_gpu_texture_t = logic_node_input_get_as_image(variance_node_inst.base.inputs[0]); + let source: 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(); @@ -83,7 +83,7 @@ function variance_node_get_as_image(self: variance_node_t, from: i32): iron_gpu_ return variance_node_image; } -function variance_node_get_cached_image(self: variance_node_t): iron_gpu_texture_t { +function variance_node_get_cached_image(self: variance_node_t): gpu_texture_t { return variance_node_image; } diff --git a/armorlab/sources/render_path_paint.ts b/armorlab/sources/render_path_paint.ts index c6a4cec1..9397645d 100644 --- a/armorlab/sources/render_path_paint.ts +++ b/armorlab/sources/render_path_paint.ts @@ -176,9 +176,9 @@ 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_gpu_set_pipeline(pipes_cursor); + gpu_set_pipeline(pipes_cursor); let gbuffer0: render_target_t = map_get(render_path_render_targets, "gbuffer0"); - iron_gpu_set_texture_depth(pipes_cursor_gbufferd, gbuffer0._image); + 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); @@ -188,11 +188,11 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 gpu_set_matrix4(pipes_cursor_vp, scene_camera.vp); let inv_vp: mat4_t = mat4_inv(scene_camera.vp); gpu_set_matrix4(pipes_cursor_inv_vp, inv_vp); - iron_gpu_set_vertex_buffer(geom._.vertex_buffer); - iron_gpu_set_index_buffer(geom._.index_buffers[0]); + gpu_set_vertex_buffer(geom._.vertex_buffer); + gpu_set_index_buffer(geom._.index_buffers[0]); gpu_draw(); - iron_gpu_disable_scissor(); + gpu_disable_scissor(); render_path_end(); } @@ -236,7 +236,7 @@ function render_path_paint_draw() { } function render_path_paint_bind_layers() { - let image: iron_gpu_texture_t = null; + let image: 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 db240108..102d3da5 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_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); + let texbase: gpu_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.BASE_COLOR); + let texocc: gpu_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.OCCLUSION); + let texrough: gpu_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.ROUGHNESS); + let texnor: gpu_texture_t = logic_node_get_as_image(context_raw.brush_output_node_inst.base, channel_type_t.NORMAL_MAP); + let texheight: 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"); @@ -79,12 +79,12 @@ function ui_nodes_ext_run() { if (texheight != null) { _gpu_begin(texpaint_pack._image); - iron_gpu_set_pipeline(pipes_copy_a); - iron_gpu_set_texture(pipes_copy_a_tex, texheight); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + 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(); - iron_gpu_end(); + 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; @@ -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_gpu_vertex_buffer_unlock(g._.vertex_buffer); + gpu_vertex_buffer_unlock(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 a248ef64..4fba951b 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_gpu_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: gpu_texture_t, icon_accent: i32, keys: string[]) { } diff --git a/armorpaint/sources/layers_ext.ts b/armorpaint/sources/layers_ext.ts index 351a8d80..9cf7e4a8 100644 --- a/armorpaint/sources/layers_ext.ts +++ b/armorpaint/sources/layers_ext.ts @@ -7,15 +7,15 @@ 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_gpu_texture_t = empty_rt._image; + let empty: gpu_texture_t = empty_rt._image; // Clear export layer _gpu_begin(layers_expa, null, clear_flag_t.COLOR, color_from_floats(0.0, 0.0, 0.0, 0.0)); - iron_gpu_end(); + gpu_end(); _gpu_begin(layers_expb, null, clear_flag_t.COLOR, color_from_floats(0.5, 0.5, 1.0, 0.0)); - iron_gpu_end(); + gpu_end(); _gpu_begin(layers_expc, null, clear_flag_t.COLOR, color_from_floats(1.0, 0.0, 0.0, 0.0)); - iron_gpu_end(); + gpu_end(); // Flatten layers for (let i: i32 = 0; i < layers.length; ++i) { @@ -27,7 +27,7 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t continue; } - let mask: iron_gpu_texture_t = empty; + let mask: gpu_texture_t = empty; let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); if (l1masks != null) { if (l1masks.length > 1) { @@ -61,18 +61,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t draw_end(); ///else _gpu_begin(layers_expa); - iron_gpu_set_pipeline(pipes_merge); - iron_gpu_set_texture(pipes_tex0, l1.texpaint); - iron_gpu_set_texture(pipes_tex1, empty); - iron_gpu_set_texture(pipes_texmask, mask); - iron_gpu_set_texture(pipes_texa, layers_temp_image); + 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_float(pipes_tex1w, empty.width); gpu_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); ///end } @@ -84,18 +84,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t draw_end(); _gpu_begin(layers_expb); - iron_gpu_set_pipeline(pipes_merge); - iron_gpu_set_texture(pipes_tex0, l1.texpaint); - iron_gpu_set_texture(pipes_tex1, l1.texpaint_nor); - iron_gpu_set_texture(pipes_texmask, mask); - iron_gpu_set_texture(pipes_texa, layers_temp_image); + 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_float(pipes_tex1w, l1.texpaint_nor.width); gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); } if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { @@ -148,18 +148,18 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t draw_end(); _gpu_begin(l0.texpaint_nor); - iron_gpu_set_pipeline(pipes_merge); - iron_gpu_set_texture(pipes_tex0, layers_temp_image); - iron_gpu_set_texture(pipes_tex1, l0.texpaint_pack); - iron_gpu_set_texture(pipes_texmask, empty); - iron_gpu_set_texture(pipes_texa, empty); + 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_float(pipes_tex1w, l0.texpaint_pack.width); gpu_set_int(pipes_blending, 104); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); } return l0; diff --git a/armorpaint/sources/make_material.ts b/armorpaint/sources/make_material.ts index 1732cb91..c24ffb15 100644 --- a/armorpaint/sources/make_material.ts +++ b/armorpaint/sources/make_material.ts @@ -158,7 +158,7 @@ function make_material_parse_paint_material(bake_previews: bool = true) { } if (bake_previews) { - let current: iron_gpu_texture_t = _draw_current; + let current: gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); make_material_bake_node_previews(); @@ -235,8 +235,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_gpu_texture_t = map_get(context_raw.node_previews, key); - sys_notify_on_next_frame(function (image: iron_gpu_texture_t) { + let image: gpu_texture_t = map_get(context_raw.node_previews, key); + sys_notify_on_next_frame(function (image: gpu_texture_t) { iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); @@ -266,7 +266,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_gpu_texture_t = map_get(context_raw.node_previews, id); + let image: 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); @@ -284,7 +284,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_gpu_texture_t = map_get(context_raw.node_previews, id); + let image: 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()); @@ -300,7 +300,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_gpu_texture_t = map_get(context_raw.node_previews, id); + let image: 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()); diff --git a/armorpaint/sources/nodes/brush_output_node_ext.ts b/armorpaint/sources/nodes/brush_output_node_ext.ts index ad066ace..041f7be9 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_gpu_texture_t = context_raw.brush_mask_image; - let last_stencil: iron_gpu_texture_t = context_raw.brush_stencil_image; + let last_mask: gpu_texture_t = context_raw.brush_mask_image; + let last_stencil: 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 62425839..f1a091e0 100644 --- a/armorpaint/sources/render_path_paint.ts +++ b/armorpaint/sources/render_path_paint.ts @@ -139,8 +139,8 @@ 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_gpu_texture_t = picker0._image; - let texpaint_posnortex_picker1: iron_gpu_texture_t = picker1._image; + let texpaint_posnortex_picker0: gpu_texture_t = picker0._image; + let texpaint_posnortex_picker1: 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); @@ -439,10 +439,10 @@ 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_gpu_set_pipeline(pipes_cursor); + gpu_set_pipeline(pipes_cursor); let rt: render_target_t = map_get(render_path_render_targets, "gbuffer0"); - let gbuffer0: iron_gpu_texture_t = rt._image; - iron_gpu_set_texture_depth(pipes_cursor_gbufferd, gbuffer0); + let gbuffer0: 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); @@ -452,11 +452,11 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3 gpu_set_matrix4(pipes_cursor_vp, scene_camera.vp); let inv_vp: mat4_t = mat4_inv(scene_camera.vp); gpu_set_matrix4(pipes_cursor_inv_vp, inv_vp); - iron_gpu_set_vertex_buffer(geom._.vertex_buffer); - iron_gpu_set_index_buffer(geom._.index_buffers[0]); + gpu_set_vertex_buffer(geom._.vertex_buffer); + gpu_set_index_buffer(geom._.index_buffers[0]); gpu_draw(); - iron_gpu_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 23ff04a3..81cbc670 100644 --- a/armorpaint/sources/ui_header_ext.ts +++ b/armorpaint/sources/ui_header_ext.ts @@ -53,14 +53,14 @@ function ui_header_draw_tool_properties(ui: ui_t) { let m: slot_layer_t = layers_new_mask(false, context_raw.layer); sys_notify_on_next_frame(function (m: slot_layer_t) { _gpu_begin(m.texpaint); - iron_gpu_set_pipeline(pipes_colorid_to_mask); + gpu_set_pipeline(pipes_colorid_to_mask); let rt: render_target_t = map_get(render_path_render_targets, "texpaint_colorid"); - iron_gpu_set_texture(pipes_texpaint_colorid, rt._image); - iron_gpu_set_texture(pipes_tex_colorid, project_get_image(project_assets[context_raw.colorid_handle.position])); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + 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(); - iron_gpu_end(); + 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_gpu_raytrace_supported()) { + if (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_gpu_raytrace_supported()) { + if (!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_gpu_texture_t = _draw_current; + let current: 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_gpu_texture_t = _draw_current; + let current: 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_gpu_texture_t = _draw_current; + let current: 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 5501e645..0ca51d64 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_gpu_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: 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 c002a230..bc3984f0 100644 --- a/armorsculpt/sources/export_obj.ts +++ b/armorsculpt/sources/export_obj.ts @@ -9,7 +9,7 @@ function export_obj_run(path: string, paint_objects: mesh_object_t[], apply_disp let o: u8[] = []; export_obj_write_string(o, "# armorsculpt\n"); - let texpaint: iron_gpu_texture_t = project_layers[0].texpaint; + let texpaint: 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 fcd71aaf..ddc83581 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_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; + let imgmesh: 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: 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 7e2dcd4e..40bd3159 100644 --- a/armorsculpt/sources/make_material.ts +++ b/armorsculpt/sources/make_material.ts @@ -138,7 +138,7 @@ function make_material_parse_paint_material(bake_previews: bool = true) { } if (bake_previews) { - let current: iron_gpu_texture_t = _draw_current; + let current: gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); make_material_bake_node_previews(); @@ -211,8 +211,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_gpu_texture_t = map_get(context_raw.node_previews, key); - sys_notify_on_next_frame(function (image: iron_gpu_texture_t) { + let image: gpu_texture_t = map_get(context_raw.node_previews, key); + sys_notify_on_next_frame(function (image: gpu_texture_t) { iron_unload_image(image); }, image); map_delete(context_raw.node_previews, key); @@ -242,7 +242,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_gpu_texture_t = map_get(context_raw.node_previews, id); + let image: 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); @@ -260,7 +260,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_gpu_texture_t = map_get(context_raw.node_previews, id); + let image: 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()); diff --git a/armorsculpt/sources/nodes/brush_output_node_ext.ts b/armorsculpt/sources/nodes/brush_output_node_ext.ts index 95dec09d..4e19e15e 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_gpu_texture_t = context_raw.brush_mask_image; - let last_stencil: iron_gpu_texture_t = context_raw.brush_stencil_image; + let last_mask: gpu_texture_t = context_raw.brush_mask_image; + let last_stencil: 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 be4b7b89..c4bd79da 100644 --- a/armorsculpt/sources/render_path_sculpt.ts +++ b/armorsculpt/sources/render_path_sculpt.ts @@ -29,12 +29,12 @@ 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_gpu_set_pipeline(cc_context._.pipe_state); + 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_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); render_path_end(); } diff --git a/armorsculpt/sources/tab_layers.ts b/armorsculpt/sources/tab_layers.ts index a32f691f..ac0f4732 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_gpu_texture_t = resource_get("icons.k"); + let icons: 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 c588eed6..990836da 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_gpu_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_ext_draw_tools(ui: ui_t, img: 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/sources/backends/android_system.c b/base/sources/backends/android_system.c index b1ce9806..d73cfd3f 100644 --- a/base/sources/backends/android_system.c +++ b/base/sources/backends/android_system.c @@ -1070,7 +1070,7 @@ double iron_time() { return (double)(now.tv_sec - start_sec) + (now.tv_usec / 1000000.0); } -void iron_gpu_internal_resize(int width, int height); +void gpu_internal_resize(int width, int height); bool iron_internal_handle_messages(void) { iron_mutex_lock(&unicode_mutex); @@ -1114,7 +1114,7 @@ bool iron_internal_handle_messages(void) { activityJustResized = false; int32_t width = iron_android_width(); int32_t height = iron_android_height(); - iron_gpu_internal_resize(width, height); + gpu_internal_resize(width, height); iron_internal_call_resize_callback(width, height); } diff --git a/base/sources/backends/android_video.c b/base/sources/backends/android_video.c index 9402e495..2cdd568a 100644 --- a/base/sources/backends/android_video.c +++ b/base/sources/backends/android_video.c @@ -85,7 +85,7 @@ // return 512; // } -// iron_gpu_texture_t *iron_video_current_image(iron_video_t *video) { +// 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 75144894..4f8645c4 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_gpu_texture_t image; +// 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 9498532f..23ec050c 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_gpu_texture_t image; +// 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 a5f55c5c..6f82032e 100644 --- a/base/sources/backends/apple_video.m +++ b/base/sources/backends/apple_video.m @@ -228,7 +228,7 @@ // CGSize size = CVImageBufferGetDisplaySize(pixelBuffer); // video->impl.myWidth = size.width; // video->impl.myHeight = size.height; -// iron_gpu_texture_init(&video->impl.image, iron_video_width(video), iron_video_height(video), IRON_IMAGE_FORMAT_BGRA32); +// gpu_texture_init(&video->impl.image, iron_video_width(video), iron_video_height(video), IRON_IMAGE_FORMAT_BGRA32); // video->impl.image_initialized = true; // } @@ -283,7 +283,7 @@ // return video->impl.myHeight; // } -// iron_gpu_texture_t *iron_video_current_image(iron_video_t *video) { +// 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 f08cf815..ddba26e9 100644 --- a/base/sources/backends/direct3d12_gpu.c +++ b/base/sources/backends/direct3d12_gpu.c @@ -1,6 +1,7 @@ #define WIN32_LEAN_AND_MEAN #define HEAP_SIZE 1024 +#define TEXTURE_COUNT 16 #define FRAMEBUFFER_COUNT 2 #include #include @@ -16,83 +17,77 @@ void iron_memory_emergency(); -bool iron_gpu_transpose_mat = false; -static ID3D12RootSignature *root_signature = NULL; -static int framebuffer_count = 0; -static struct IDXGISwapChain *window_swapchain; -static UINT64 window_current_fence_value; -static UINT64 window_fence_values[FRAMEBUFFER_COUNT]; -static HANDLE window_frame_fence_events[FRAMEBUFFER_COUNT]; -static struct ID3D12Fence *window_frame_fences[FRAMEBUFFER_COUNT]; -static int window_width; -static int window_height; -static int window_new_width; -static int window_new_height; -static iron_gpu_texture_t *current_render_targets[8]; -static int current_render_targets_count = 0; -static bool window_vsync; +bool gpu_transpose_mat = false; static ID3D12Device *device = NULL; static ID3D12CommandQueue *queue; - -static struct ID3D12CommandAllocator *_commandAllocator; -static struct ID3D12GraphicsCommandList *_commandList; +static struct IDXGISwapChain *window_swapchain; +static ID3D12RootSignature *root_signature = NULL; +static struct ID3D12CommandAllocator *command_allocator; +static struct ID3D12GraphicsCommandList *command_list; static bool command_list_open = true; -static struct iron_gpu_pipeline *_currentPipeline; -static int _indexCount; +static gpu_texture_t framebuffers[FRAMEBUFFER_COUNT]; +static int framebuffer_index = 0; +static gpu_pipeline_t *current_pipeline; +static gpu_texture_t *current_textures[TEXTURE_COUNT]; +static gpu_texture_t *current_render_targets[8]; +static int current_render_targets_count = 0; +static bool window_vsync; +static int index_count; +static struct ID3D12DescriptorHeap *srv_heap; +static int srv_heap_index; + +static UINT64 window_current_fence_value; +static UINT64 window_fence_values[FRAMEBUFFER_COUNT]; +static HANDLE window_fence_events[FRAMEBUFFER_COUNT]; +static struct ID3D12Fence *window_fences[FRAMEBUFFER_COUNT]; static uint64_t fence_value; static struct ID3D12Fence *fence; static HANDLE fence_event; -static struct iron_gpu_texture *current_textures[IRON_INTERNAL_G5_TEXTURE_COUNT]; -static int heap_index; -static struct ID3D12DescriptorHeap *srvHeap; -static iron_gpu_texture_t framebuffers[FRAMEBUFFER_COUNT]; -static int framebuffer_index = 0; - -static D3D12_BLEND convert_blend_factor(iron_gpu_blending_factor_t factor) { +static D3D12_BLEND convert_blend_factor(gpu_blending_factor_t factor) { switch (factor) { - case IRON_GPU_BLEND_ONE: + case GPU_BLEND_ONE: return D3D12_BLEND_ONE; - case IRON_GPU_BLEND_ZERO: + case GPU_BLEND_ZERO: return D3D12_BLEND_ZERO; - case IRON_GPU_BLEND_SOURCE_ALPHA: + case GPU_BLEND_SOURCE_ALPHA: return D3D12_BLEND_SRC_ALPHA; - case IRON_GPU_BLEND_DEST_ALPHA: + case GPU_BLEND_DEST_ALPHA: return D3D12_BLEND_DEST_ALPHA; - case IRON_GPU_BLEND_INV_SOURCE_ALPHA: + case GPU_BLEND_INV_SOURCE_ALPHA: return D3D12_BLEND_INV_SRC_ALPHA; - case IRON_GPU_BLEND_INV_DEST_ALPHA: + case GPU_BLEND_INV_DEST_ALPHA: return D3D12_BLEND_INV_DEST_ALPHA; } } -static D3D12_BLEND_OP convert_blend_operation(iron_gpu_blending_operation_t op) { +static D3D12_BLEND_OP convert_blend_operation(gpu_blending_operation_t op) { switch (op) { - case IRON_GPU_BLENDOP_ADD: + case GPU_BLENDOP_ADD: return D3D12_BLEND_OP_ADD; } } -static D3D12_CULL_MODE convert_cull_mode(iron_gpu_cull_mode_t cull_mode) { +static D3D12_CULL_MODE convert_cull_mode(gpu_cull_mode_t cull_mode) { switch (cull_mode) { - case IRON_GPU_CULL_MODE_CLOCKWISE: + case GPU_CULL_MODE_CLOCKWISE: return D3D12_CULL_MODE_FRONT; - case IRON_GPU_CULL_MODE_COUNTERCLOCKWISE: + case GPU_CULL_MODE_COUNTERCLOCKWISE: return D3D12_CULL_MODE_BACK; - case IRON_GPU_CULL_MODE_NEVER: + case GPU_CULL_MODE_NEVER: default: return D3D12_CULL_MODE_NONE; } } -static D3D12_COMPARISON_FUNC convert_compare_mode(iron_gpu_compare_mode_t compare) { +static D3D12_COMPARISON_FUNC convert_compare_mode(gpu_compare_mode_t compare) { switch (compare) { default: - case IRON_GPU_COMPARE_MODE_ALWAYS: + case GPU_COMPARE_MODE_ALWAYS: return D3D12_COMPARISON_FUNC_ALWAYS; - case IRON_GPU_COMPARE_MODE_NEVER: + case GPU_COMPARE_MODE_NEVER: return D3D12_COMPARISON_FUNC_NEVER; - case IRON_GPU_COMPARE_MODE_LESS: + case GPU_COMPARE_MODE_LESS: return D3D12_COMPARISON_FUNC_LESS; } } @@ -137,31 +132,6 @@ static void wait_for_fence(ID3D12Fence *fence, UINT64 completion_value, HANDLE w } } -static void setup_swapchain() { - window_current_fence_value = 0; - for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { - window_frame_fence_events[i] = CreateEvent(NULL, FALSE, FALSE, NULL); - window_fence_values[i] = 0; - device->lpVtbl->CreateFence(device, window_current_fence_value, D3D12_FENCE_FLAG_NONE, &IID_ID3D12Fence, &window_frame_fences[i]); - } -} - -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); - blend_desc->RenderTarget[target].SrcBlendAlpha = convert_blend_factor(pipe->alpha_blend_source); - blend_desc->RenderTarget[target].DestBlendAlpha = convert_blend_factor(pipe->alpha_blend_destination); - blend_desc->RenderTarget[target].BlendOpAlpha = convert_blend_operation(pipe->alpha_blend_operation); - blend_desc->RenderTarget[target].RenderTargetWriteMask = - (((pipe->color_write_mask_red[target] ? D3D12_COLOR_WRITE_ENABLE_RED : 0) | - (pipe->color_write_mask_green[target] ? D3D12_COLOR_WRITE_ENABLE_GREEN : 0)) | - (pipe->color_write_mask_blue[target] ? D3D12_COLOR_WRITE_ENABLE_BLUE : 0)) | - (pipe->color_write_mask_alpha[target] ? D3D12_COLOR_WRITE_ENABLE_ALPHA : 0); -} - static UINT64 get_footprint(ID3D12Resource *destinationResource, UINT FirstSubresource, UINT NumSubresources) { D3D12_RESOURCE_DESC desc; destinationResource->lpVtbl->GetDesc(destinationResource, &desc); @@ -171,34 +141,51 @@ static UINT64 get_footprint(ID3D12Resource *destinationResource, UINT FirstSubre return requiredSize; } -void iron_gpu_destroy() { +static void gpu_barrier(gpu_texture_t *render_target, D3D12_RESOURCE_STATES state_after) { + if (render_target->impl.state == state_after) { + return; + } + D3D12_RESOURCE_BARRIER barrier = { + .Transition.pResource = render_target->impl.render_target, + .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, + .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, + .Transition.StateBefore = render_target->impl.state, + .Transition.StateAfter = state_after, + .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, + }; + command_list->lpVtbl->ResourceBarrier(command_list, 1, &barrier); + render_target->impl.state = state_after; +} + +void gpu_destroy() { if (device) { device->lpVtbl->Release(device); device = NULL; } } -static void render_target_init(iron_gpu_texture_t *render_target, int width, int height, iron_image_format_t format, int depth_buffer_bits, int framebuffer_index) { +static void render_target_init(gpu_texture_t *render_target, int width, int height, iron_image_format_t format, int depth_buffer_bits, int framebuffer_index) { render_target->width = render_target->width = width; render_target->height = render_target->height = height; render_target->impl.stage = 0; render_target->impl.stage_depth = -1; - render_target->impl.renderTargetReadback = NULL; - render_target->impl.framebuffer_index = framebuffer_index; + render_target->impl.readback = NULL; render_target->impl.image = NULL; - render_target->impl.uploadImage = NULL; + render_target->impl.upload_image = NULL; render_target->data = NULL; + render_target->uploaded = true; + render_target->impl.state = (framebuffer_index >= 0) ? D3D12_RESOURCE_STATE_PRESENT : D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - DXGI_FORMAT dxgiFormat = convert_format(format); + DXGI_FORMAT dxgi_format = convert_format(format); - D3D12_CLEAR_VALUE clearValue; - clearValue.Format = dxgiFormat; - clearValue.Color[0] = 0.0f; - clearValue.Color[1] = 0.0f; - clearValue.Color[2] = 0.0f; - clearValue.Color[3] = 1.0f; + D3D12_CLEAR_VALUE clear_value; + clear_value.Format = dxgi_format; + clear_value.Color[0] = 0.0f; + clear_value.Color[1] = 0.0f; + clear_value.Color[2] = 0.0f; + clear_value.Color[3] = 1.0f; - D3D12_HEAP_PROPERTIES heapProperties = { + D3D12_HEAP_PROPERTIES heap_properties = { .Type = D3D12_HEAP_TYPE_DEFAULT, .CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN, .MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN, @@ -206,14 +193,14 @@ static void render_target_init(iron_gpu_texture_t *render_target, int width, int .VisibleNodeMask = 1, }; - D3D12_RESOURCE_DESC texResourceDesc = { + D3D12_RESOURCE_DESC resource_desc = { .Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D, .Alignment = 0, .Width = render_target->width, .Height = render_target->height, .DepthOrArraySize = 1, .MipLevels = 1, - .Format = dxgiFormat, + .Format = dxgi_format, .SampleDesc.Count = 1, .SampleDesc.Quality = 0, .Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, @@ -225,85 +212,68 @@ static void render_target_init(iron_gpu_texture_t *render_target, int width, int .Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE, }; - device->lpVtbl->CreateDescriptorHeap(device, &heap_desc, &IID_ID3D12DescriptorHeap, &render_target->impl.renderTargetDescriptorHeap); + device->lpVtbl->CreateDescriptorHeap(device, &heap_desc, &IID_ID3D12DescriptorHeap, &render_target->impl.descriptor_heap); if (framebuffer_index >= 0) { - IDXGISwapChain *swapChain = window_swapchain; - swapChain->lpVtbl->GetBuffer(swapChain, framebuffer_index, &IID_ID3D12Resource, &render_target->impl.renderTarget); - wchar_t buffer[128]; - wsprintf(buffer, L"Backbuffer (index %i)", framebuffer_index); - render_target->impl.renderTarget->lpVtbl->SetName(render_target->impl.renderTarget, buffer); - - D3D12_RENDER_TARGET_VIEW_DESC viewDesc = { - .Format = format, - .ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D, - .Texture2D.MipSlice = 0, - .Texture2D.PlaneSlice = 0, - }; - - D3D12_CPU_DESCRIPTOR_HANDLE handle; - render_target->impl.renderTargetDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(render_target->impl.renderTargetDescriptorHeap, &handle); - device->lpVtbl->CreateRenderTargetView(device, render_target->impl.renderTarget, &viewDesc, handle); + window_swapchain->lpVtbl->GetBuffer(window_swapchain, framebuffer_index, &IID_ID3D12Resource, &render_target->impl.render_target); } else { - HRESULT result = device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &texResourceDesc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, - &clearValue, &IID_ID3D12Resource, &render_target->impl.renderTarget); + HRESULT result = device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, + &clear_value, &IID_ID3D12Resource, &render_target->impl.render_target); if (result != S_OK) { for (int i = 0; i < 10; ++i) { iron_memory_emergency(); - result = device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &texResourceDesc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, - &clearValue, &IID_ID3D12Resource, &render_target->impl.renderTarget); + result = device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, + &clear_value, &IID_ID3D12Resource, &render_target->impl.render_target); if (result == S_OK) { break; } } } - - D3D12_RENDER_TARGET_VIEW_DESC view = { - .Format = dxgiFormat, - .ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D, - .Texture2D.MipSlice = 0, - .Texture2D.PlaneSlice = 0, - }; - - D3D12_CPU_DESCRIPTOR_HANDLE handle; - render_target->impl.renderTargetDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(render_target->impl.renderTargetDescriptorHeap, &handle); - - device->lpVtbl->CreateRenderTargetView(device, render_target->impl.renderTarget, &view, handle); } - D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = { + D3D12_RENDER_TARGET_VIEW_DESC view_desc = { + .Format = dxgi_format, + .ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D, + .Texture2D.MipSlice = 0, + .Texture2D.PlaneSlice = 0, + }; + + D3D12_CPU_DESCRIPTOR_HANDLE handle; + render_target->impl.descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(render_target->impl.descriptor_heap, &handle); + + device->lpVtbl->CreateRenderTargetView(device, render_target->impl.render_target, &view_desc, handle); + + D3D12_DESCRIPTOR_HEAP_DESC descriptor_heap_desc = { .NumDescriptors = 1, .Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, .NodeMask = 0, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE, }; - device->lpVtbl->CreateDescriptorHeap(device, &descriptorHeapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.srvDescriptorHeap); + device->lpVtbl->CreateDescriptorHeap(device, &descriptor_heap_desc, &IID_ID3D12DescriptorHeap, &render_target->impl.srv_descriptor_heap); - D3D12_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc = { + D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = { .ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D, .Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, - .Format = dxgiFormat, + .Format = dxgi_format, .Texture2D.MipLevels = 1, .Texture2D.MostDetailedMip = 0, .Texture2D.ResourceMinLODClamp = 0.0f, }; - D3D12_CPU_DESCRIPTOR_HANDLE handle; - render_target->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(render_target->impl.srvDescriptorHeap, &handle); - - device->lpVtbl->CreateShaderResourceView(device, render_target->impl.renderTarget, &shaderResourceViewDesc, handle); + render_target->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(render_target->impl.srv_descriptor_heap, &handle); + device->lpVtbl->CreateShaderResourceView(device, render_target->impl.render_target, &srv_desc, handle); if (depth_buffer_bits > 0) { - D3D12_DESCRIPTOR_HEAP_DESC dsvHeapDesc = { + D3D12_DESCRIPTOR_HEAP_DESC dsv_heap_desc = { .NumDescriptors = 1, .Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE, }; - device->lpVtbl->CreateDescriptorHeap(device, &dsvHeapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.depthDescriptorHeap); + device->lpVtbl->CreateDescriptorHeap(device, &dsv_heap_desc, &IID_ID3D12DescriptorHeap, &render_target->impl.depth_descriptor_heap); - D3D12_RESOURCE_DESC depthTexture = { + D3D12_RESOURCE_DESC depth_resource_desc = { .Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D, .Alignment = 0, .Width = width, @@ -317,13 +287,13 @@ static void render_target_init(iron_gpu_texture_t *render_target, int width, int .Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL, }; - D3D12_CLEAR_VALUE clearValue = { + D3D12_CLEAR_VALUE clear_value = { .Format = DXGI_FORMAT_D32_FLOAT, .DepthStencil.Depth = 1.0f, .DepthStencil.Stencil = 0, }; - D3D12_HEAP_PROPERTIES heapProperties = { + D3D12_HEAP_PROPERTIES heap_properties = { .Type = D3D12_HEAP_TYPE_DEFAULT, .CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN, .MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN, @@ -331,13 +301,13 @@ static void render_target_init(iron_gpu_texture_t *render_target, int width, int .VisibleNodeMask = 1, }; - HRESULT result = device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &depthTexture, D3D12_RESOURCE_STATE_DEPTH_WRITE, - &clearValue, &IID_ID3D12Resource, &render_target->impl.depthTexture); + HRESULT result = device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &depth_resource_desc, D3D12_RESOURCE_STATE_DEPTH_WRITE, + &clear_value, &IID_ID3D12Resource, &render_target->impl.depth_texture); if (result != S_OK) { for (int i = 0; i < 10; ++i) { iron_memory_emergency(); - result = device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &depthTexture, D3D12_RESOURCE_STATE_DEPTH_WRITE, - &clearValue, &IID_ID3D12Resource, &render_target->impl.depthTexture); + result = device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &depth_resource_desc, D3D12_RESOURCE_STATE_DEPTH_WRITE, + &clear_value, &IID_ID3D12Resource, &render_target->impl.depth_texture); if (result == S_OK) { break; } @@ -345,19 +315,18 @@ static void render_target_init(iron_gpu_texture_t *render_target, int width, int } D3D12_CPU_DESCRIPTOR_HANDLE handle; - render_target->impl.depthDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(render_target->impl.depthDescriptorHeap, &handle); - device->lpVtbl->CreateDepthStencilView(device, render_target->impl.depthTexture, NULL, handle); + render_target->impl.depth_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(render_target->impl.depth_descriptor_heap, &handle); + device->lpVtbl->CreateDepthStencilView(device, render_target->impl.depth_texture, NULL, handle); - // Reading depth texture as a shader resource - D3D12_DESCRIPTOR_HEAP_DESC srvDepthHeapDesc = { + D3D12_DESCRIPTOR_HEAP_DESC srv_depth_heap_desc = { .NumDescriptors = 1, .Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, .NodeMask = 0, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE, }; - device->lpVtbl->CreateDescriptorHeap(device, &srvDepthHeapDesc, &IID_ID3D12DescriptorHeap, &render_target->impl.srvDepthDescriptorHeap); + device->lpVtbl->CreateDescriptorHeap(device, &srv_depth_heap_desc, &IID_ID3D12DescriptorHeap, &render_target->impl.srv_depth_descriptor_heap); - D3D12_SHADER_RESOURCE_VIEW_DESC srvDepthViewDesc = { + D3D12_SHADER_RESOURCE_VIEW_DESC srv_depth_view_desc = { .ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D, .Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, .Format = DXGI_FORMAT_R32_FLOAT, @@ -366,13 +335,13 @@ static void render_target_init(iron_gpu_texture_t *render_target, int width, int .Texture2D.ResourceMinLODClamp = 0.0f, }; - render_target->impl.srvDepthDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(render_target->impl.srvDepthDescriptorHeap, &handle); - device->lpVtbl->CreateShaderResourceView(device, render_target->impl.depthTexture, &srvDepthViewDesc, handle); + render_target->impl.srv_depth_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(render_target->impl.srv_depth_descriptor_heap, &handle); + device->lpVtbl->CreateShaderResourceView(device, render_target->impl.depth_texture, &srv_depth_view_desc, handle); } else { - render_target->impl.depthDescriptorHeap = NULL; - render_target->impl.depthTexture = NULL; - render_target->impl.srvDepthDescriptorHeap = NULL; + render_target->impl.depth_descriptor_heap = NULL; + render_target->impl.depth_texture = NULL; + render_target->impl.srv_depth_descriptor_heap = NULL; } render_target->impl.scissor.top = 0; @@ -388,14 +357,7 @@ static void render_target_init(iron_gpu_texture_t *render_target, int width, int render_target->impl.viewport.MaxDepth = 1.0f; } -void iron_gpu_render_target_init_framebuffer(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_buffer_bits) { - render_target_init(target, width, height, format, depth_buffer_bits, framebuffer_count); - framebuffer_count += 1; - target->uploaded = true; - target->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; -} - -void iron_gpu_init(int depth_buffer_bits, bool vsync) { +void gpu_init_internal(int depth_buffer_bits, bool vsync) { #ifdef _DEBUG ID3D12Debug *debug_controller = NULL; if (D3D12GetDebugInterface(&IID_ID3D12Debug, &debug_controller) == S_OK) { @@ -411,7 +373,7 @@ void iron_gpu_init(int depth_buffer_bits, bool vsync) { D3D12_ROOT_PARAMETER parameters[2] = {}; D3D12_DESCRIPTOR_RANGE range = { .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV, - .NumDescriptors = (UINT)IRON_INTERNAL_G5_TEXTURE_COUNT, + .NumDescriptors = (UINT)TEXTURE_COUNT, .BaseShaderRegister = 0, .RegisterSpace = 0, .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, @@ -424,8 +386,8 @@ void iron_gpu_init(int depth_buffer_bits, bool vsync) { parameters[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; parameters[1].Descriptor.ShaderRegister = 0; parameters[1].Descriptor.RegisterSpace = 0; - D3D12_STATIC_SAMPLER_DESC samplers[IRON_INTERNAL_G5_TEXTURE_COUNT]; - for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { + D3D12_STATIC_SAMPLER_DESC samplers[TEXTURE_COUNT]; + for (int i = 0; i < TEXTURE_COUNT; ++i) { samplers[i].ShaderRegister = i; samplers[i].Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; samplers[i].AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP; @@ -443,7 +405,7 @@ void iron_gpu_init(int depth_buffer_bits, bool vsync) { D3D12_ROOT_SIGNATURE_DESC root_signature_desc = { .NumParameters = 2, .pParameters = parameters, - .NumStaticSamplers = IRON_INTERNAL_G5_TEXTURE_COUNT, + .NumStaticSamplers = TEXTURE_COUNT, .pStaticSamplers = samplers, .Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, }; @@ -458,8 +420,6 @@ void iron_gpu_init(int depth_buffer_bits, bool vsync) { device->lpVtbl->CreateCommandQueue(device, &queue_desc, &IID_ID3D12CommandQueue, &queue); window_vsync = vsync; - window_width = window_new_width = iron_window_width(); - window_height = window_new_height = iron_window_height(); HWND hwnd = iron_windows_window_handle(); DXGI_SWAP_CHAIN_DESC swapchain_desc = { @@ -478,51 +438,56 @@ void iron_gpu_init(int depth_buffer_bits, bool vsync) { CreateDXGIFactory1(&IID_IDXGIFactory4, &dxgi_factory); dxgi_factory->lpVtbl->CreateSwapChain(dxgi_factory, (IUnknown *)queue, &swapchain_desc, &window_swapchain); - setup_swapchain(); - + window_current_fence_value = 0; for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { - iron_gpu_render_target_init_framebuffer(&framebuffers[i], iron_window_width(), iron_window_height(), IRON_IMAGE_FORMAT_RGBA32, depth_buffer_bits); + window_fence_events[i] = CreateEvent(NULL, FALSE, FALSE, NULL); + window_fence_values[i] = 0; + device->lpVtbl->CreateFence(device, window_current_fence_value, D3D12_FENCE_FLAG_NONE, &IID_ID3D12Fence, &window_fences[i]); } - device->lpVtbl->CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_DIRECT, &IID_ID3D12CommandAllocator, &_commandAllocator); - device->lpVtbl->CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, _commandAllocator, NULL, &IID_ID3D12CommandList, &_commandList); + for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { + render_target_init(&framebuffers[i], iron_window_width(), iron_window_height(), IRON_IMAGE_FORMAT_RGBA32, depth_buffer_bits, i); + } + + device->lpVtbl->CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_DIRECT, &IID_ID3D12CommandAllocator, &command_allocator); + device->lpVtbl->CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, command_allocator, NULL, &IID_ID3D12CommandList, &command_list); fence_value = 0; fence_event = CreateEvent(NULL, FALSE, FALSE, NULL); device->lpVtbl->CreateFence(device, 0, D3D12_FENCE_FLAG_NONE, &IID_ID3D12Fence, &fence); - _indexCount = 0; + index_count = 0; - for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { + for (int i = 0; i < TEXTURE_COUNT; ++i) { current_textures[i] = NULL; } - heap_index = 0; + srv_heap_index = 0; D3D12_DESCRIPTOR_HEAP_DESC heap_desc = { .NumDescriptors = HEAP_SIZE, .Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, }; - device->lpVtbl->CreateDescriptorHeap(device, &heap_desc, &IID_ID3D12DescriptorHeap, &srvHeap); + device->lpVtbl->CreateDescriptorHeap(device, &heap_desc, &IID_ID3D12DescriptorHeap, &srv_heap); } -int iron_gpu_max_bound_textures(void) { - return IRON_INTERNAL_G5_TEXTURE_COUNT; +int gpu_max_bound_textures(void) { + return TEXTURE_COUNT; } -void iron_gpu_begin(struct iron_gpu_texture **targets, int count, unsigned flags, unsigned color, float depth) { +void gpu_begin(struct gpu_texture **targets, int count, unsigned flags, unsigned color, float depth) { - iron_gpu_wait(); + gpu_wait(); if (!command_list_open) { - _commandAllocator->lpVtbl->Reset(_commandAllocator); - _commandList->lpVtbl->Reset(_commandList, _commandAllocator, NULL); + command_allocator->lpVtbl->Reset(command_allocator); + command_list->lpVtbl->Reset(command_list, command_allocator, NULL); command_list_open = true; } // if (window_resized) { // for (int i = 0; i < FRAMEBUFFER_COUNT; ++i) { - // iron_gpu_texture_destroy(&framebuffers[i]); - // iron_gpu_render_target_init_framebuffer(&framebuffers[i], iron_window_width(), iron_window_height(), IRON_IMAGE_FORMAT_RGBA32, 0); + // gpu_texture_destroy(&framebuffers[i]); + // render_target_init(&framebuffers[i], iron_window_width(), iron_window_height(), IRON_IMAGE_FORMAT_RGBA32, depth_buffer_bits); // } // framebuffer_index = 0; // window_resized = false; @@ -530,7 +495,7 @@ void iron_gpu_begin(struct iron_gpu_texture **targets, int count, unsigned flags if (current_render_targets_count > 0 && current_render_targets[0] != &framebuffers[framebuffer_index]) { for (int i = 0; i < current_render_targets_count; ++i) { - iron_gpu_render_target_to_texture_barrier(current_render_targets[i]); + gpu_barrier(current_render_targets[i], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); } } @@ -545,108 +510,109 @@ void iron_gpu_begin(struct iron_gpu_texture **targets, int count, unsigned flags current_render_targets_count = count; } - iron_gpu_texture_t *target = current_render_targets[0]; + gpu_texture_t *target = current_render_targets[0]; if (target != &framebuffers[framebuffer_index]) { for (int i = 0; i < current_render_targets_count; ++i) { - iron_gpu_texture_to_render_target_barrier(targets[i]); + gpu_barrier(current_render_targets[i], D3D12_RESOURCE_STATE_RENDER_TARGET); } } D3D12_CPU_DESCRIPTOR_HANDLE target_descriptors[16]; for (int i = 0; i < current_render_targets_count; ++i) { - current_render_targets[i]->impl.renderTargetDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(current_render_targets[i]->impl.renderTargetDescriptorHeap, &target_descriptors[i]); + current_render_targets[i]->impl.descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(current_render_targets[i]->impl.descriptor_heap, &target_descriptors[i]); } - if (target->impl.depthDescriptorHeap != NULL) { + if (target->impl.depth_descriptor_heap != NULL) { D3D12_CPU_DESCRIPTOR_HANDLE heapStart; - target->impl.depthDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(target->impl.depthDescriptorHeap, &heapStart); - _commandList->lpVtbl->OMSetRenderTargets(_commandList, current_render_targets_count, &target_descriptors[0], false, &heapStart); + target->impl.depth_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(target->impl.depth_descriptor_heap, &heapStart); + command_list->lpVtbl->OMSetRenderTargets(command_list, current_render_targets_count, &target_descriptors[0], false, &heapStart); } else { - _commandList->lpVtbl->OMSetRenderTargets(_commandList, current_render_targets_count, &target_descriptors[0], false, NULL); + command_list->lpVtbl->OMSetRenderTargets(command_list, current_render_targets_count, &target_descriptors[0], false, NULL); } - _commandList->lpVtbl->RSSetViewports(_commandList, 1, (D3D12_VIEWPORT *)&target->impl.viewport); - _commandList->lpVtbl->RSSetScissorRects(_commandList, 1, (D3D12_RECT *)&target->impl.scissor); + command_list->lpVtbl->RSSetViewports(command_list, 1, (D3D12_VIEWPORT *)&target->impl.viewport); + command_list->lpVtbl->RSSetScissorRects(command_list, 1, (D3D12_RECT *)&target->impl.scissor); - if (flags & IRON_GPU_CLEAR_COLOR) { + if (flags & GPU_CLEAR_COLOR) { float clearColor[] = {((color & 0x00ff0000) >> 16) / 255.0f, ((color & 0x0000ff00) >> 8) / 255.0f, (color & 0x000000ff) / 255.0f, ((color & 0xff000000) >> 24) / 255.0f}; D3D12_CPU_DESCRIPTOR_HANDLE handle; - target->impl.renderTargetDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(target->impl.renderTargetDescriptorHeap, &handle); - _commandList->lpVtbl->ClearRenderTargetView(_commandList, handle, clearColor, 0, NULL); + target->impl.descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(target->impl.descriptor_heap, &handle); + command_list->lpVtbl->ClearRenderTargetView(command_list, handle, clearColor, 0, NULL); } - if (flags & IRON_GPU_CLEAR_DEPTH) { + if (flags & GPU_CLEAR_DEPTH) { D3D12_CLEAR_FLAGS d3dflags = D3D12_CLEAR_FLAG_DEPTH; - if (target->impl.depthDescriptorHeap != NULL) { + if (target->impl.depth_descriptor_heap != NULL) { D3D12_CPU_DESCRIPTOR_HANDLE handle; - target->impl.depthDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(target->impl.depthDescriptorHeap, &handle); - _commandList->lpVtbl->ClearDepthStencilView(_commandList, handle, d3dflags, depth, 0, 0, NULL); + target->impl.depth_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(target->impl.depth_descriptor_heap, &handle); + command_list->lpVtbl->ClearDepthStencilView(command_list, handle, d3dflags, depth, 0, 0, NULL); } } } -void iron_gpu_end() { +void gpu_end() { if (current_render_targets_count > 0 && current_render_targets[0] != &framebuffers[framebuffer_index]) { for (int i = 0; i < current_render_targets_count; ++i) { - iron_gpu_render_target_to_texture_barrier(current_render_targets[i]); + gpu_barrier(current_render_targets[i], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); } current_render_targets_count = 0; } - _commandList->lpVtbl->Close(_commandList); + command_list->lpVtbl->Close(command_list); command_list_open = false; - ID3D12CommandList *command_lists[] = {(ID3D12CommandList *)_commandList}; + ID3D12CommandList *command_lists[] = {(ID3D12CommandList *)command_list}; queue->lpVtbl->ExecuteCommandLists(queue, 1, command_lists); queue->lpVtbl->Signal(queue, fence, ++fence_value); } -void iron_gpu_wait() { +void gpu_wait() { wait_for_fence(fence, fence_value, fence_event); } -void iron_gpu_present() { - iron_gpu_render_target_to_framebuffer_barrier(&framebuffers[framebuffer_index]); +void gpu_present() { + gpu_barrier(&framebuffers[framebuffer_index], D3D12_RESOURCE_STATE_PRESENT); window_swapchain->lpVtbl->Present(window_swapchain, window_vsync, 0); - iron_gpu_framebuffer_to_render_target_barrier(&framebuffers[framebuffer_index]); + + queue->lpVtbl->Signal(queue, window_fences[framebuffer_index], ++window_current_fence_value); + window_fence_values[framebuffer_index] = window_current_fence_value; + framebuffer_index = (framebuffer_index + 1) % FRAMEBUFFER_COUNT; + gpu_barrier(&framebuffers[framebuffer_index], D3D12_RESOURCE_STATE_RENDER_TARGET); - if (window_new_width != window_width || window_new_height != window_height) { - window_swapchain->lpVtbl->ResizeBuffers(window_swapchain, FRAMEBUFFER_COUNT, window_new_width, window_new_height, DXGI_FORMAT_R8G8B8A8_UNORM, 0); - setup_swapchain(); - window_width = window_new_width; - window_height = window_new_height; - framebuffer_index = 0; - } + wait_for_fence(window_fences[framebuffer_index], window_fence_values[framebuffer_index], window_fence_events[framebuffer_index]); - UINT64 fence_value = window_current_fence_value; - queue->lpVtbl->Signal(queue, window_frame_fences[framebuffer_index], fence_value); - window_fence_values[framebuffer_index] = fence_value; - ++window_current_fence_value; + // queue->lpVtbl->Signal(queue, window_fences[framebuffer_index], window_current_fence_value); + // window_fence_values[framebuffer_index] = window_current_fence_value; + // ++window_current_fence_value; - wait_for_fence(window_frame_fences[framebuffer_index], window_fence_values[framebuffer_index], window_frame_fence_events[framebuffer_index]); + // wait_for_fence(window_fences[framebuffer_index], window_fence_values[framebuffer_index], window_fence_events[framebuffer_index]); - if (fence_value > 0) { - iron_gpu_wait(); - _commandAllocator->lpVtbl->Reset(_commandAllocator); - _commandList->lpVtbl->Reset(_commandList, _commandAllocator, NULL); - } + // if (fence_value > 0) { + // gpu_wait(); + // command_allocator->lpVtbl->Reset(command_allocator); + // command_list->lpVtbl->Reset(command_list, command_allocator, NULL); + // } } -void iron_gpu_internal_resize(int width, int height) { +void gpu_internal_resize(int width, int height) { if (width == 0 || height == 0) { return; } - window_new_width = width; - window_new_height = height; + // if (window_new_width != window_width || window_new_height != window_height) { + // window_swapchain->lpVtbl->ResizeBuffers(window_swapchain, FRAMEBUFFER_COUNT, window_new_width, window_new_height, DXGI_FORMAT_R8G8B8A8_UNORM, 0); + // window_width = window_new_width; + // window_height = window_new_height; + // framebuffer_index = 0; + // } } -bool iron_gpu_raytrace_supported() { +bool 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; @@ -654,93 +620,39 @@ bool iron_gpu_raytrace_supported() { return false; } -void iron_gpu_render_target_to_framebuffer_barrier(iron_gpu_texture_t *render_target) { - D3D12_RESOURCE_BARRIER barrier = { - .Transition.pResource = render_target->impl.renderTarget, - .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, - .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, - .Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET, - .Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT, - .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, - }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); +void gpu_set_constant_buffer(gpu_buffer_t *buffer, int offset, size_t size) { + command_list->lpVtbl->SetGraphicsRootConstantBufferView(command_list, 1, buffer->impl.buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.buffer) + offset); } -void iron_gpu_framebuffer_to_render_target_barrier(iron_gpu_texture_t *render_target) { - D3D12_RESOURCE_BARRIER barrier = { - .Transition.pResource = render_target->impl.renderTarget, - .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, - .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, - .Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT, - .Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET, - .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, - }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); -} - -void iron_gpu_texture_to_render_target_barrier(iron_gpu_texture_t *render_target) { - if (render_target->state != IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET) { - D3D12_RESOURCE_BARRIER barrier = { - .Transition.pResource = render_target->impl.renderTarget, - .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, - .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, - .Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, - .Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET, - .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, - }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); - render_target->state = IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET; - } -} - -void iron_gpu_render_target_to_texture_barrier(iron_gpu_texture_t *render_target) { - if (render_target->state != IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE) { - D3D12_RESOURCE_BARRIER barrier = { - .Transition.pResource = render_target->impl.renderTarget, - .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, - .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, - .Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET, - .Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, - .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, - }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); - render_target->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; - } -} - -void iron_gpu_set_constant_buffer(iron_gpu_buffer_t *buffer, int offset, size_t size) { - _commandList->lpVtbl->SetGraphicsRootConstantBufferView(_commandList, 1, buffer->impl.constant_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.constant_buffer) + offset); -} - -void iron_gpu_internal_set_textures() { +void gpu_internal_set_textures() { UINT srv_step = device->lpVtbl->GetDescriptorHandleIncrementSize(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - if (heap_index + IRON_INTERNAL_G5_TEXTURE_COUNT > HEAP_SIZE) { - heap_index = 0; - } + if (srv_heap_index + TEXTURE_COUNT > HEAP_SIZE) { + srv_heap_index = 0; + } - D3D12_CPU_DESCRIPTOR_HANDLE cpu_base; - D3D12_GPU_DESCRIPTOR_HANDLE gpu_base; - srvHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(srvHeap, &cpu_base); - srvHeap->lpVtbl->GetGPUDescriptorHandleForHeapStart(srvHeap, &gpu_base); - cpu_base.ptr += heap_index * srv_step; - gpu_base.ptr += heap_index * srv_step; + D3D12_CPU_DESCRIPTOR_HANDLE cpu_base; + D3D12_GPU_DESCRIPTOR_HANDLE gpu_base; + srv_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(srv_heap, &cpu_base); + srv_heap->lpVtbl->GetGPUDescriptorHandleForHeapStart(srv_heap, &gpu_base); + cpu_base.ptr += srv_heap_index * srv_step; + gpu_base.ptr += srv_heap_index * srv_step; - for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { - iron_gpu_texture_t *texture = current_textures[i]; - if (!texture) continue; + for (int i = 0; i < TEXTURE_COUNT; ++i) { + gpu_texture_t *texture = current_textures[i]; + if (!texture) continue; - D3D12_CPU_DESCRIPTOR_HANDLE source_cpu; - ID3D12DescriptorHeap *source_heap = (texture->impl.stage_depth == i) ? - texture->impl.srvDepthDescriptorHeap : texture->impl.srvDescriptorHeap; - source_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(source_heap, &source_cpu); + D3D12_CPU_DESCRIPTOR_HANDLE source_cpu; + ID3D12DescriptorHeap *source_heap = (texture->impl.stage_depth == i) ? + texture->impl.srv_depth_descriptor_heap : texture->impl.srv_descriptor_heap; + source_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(source_heap, &source_cpu); - device->lpVtbl->CopyDescriptorsSimple(device, 1, cpu_base, source_cpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - cpu_base.ptr += srv_step; - heap_index++; - } + device->lpVtbl->CopyDescriptorsSimple(device, 1, cpu_base, source_cpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + cpu_base.ptr += srv_step; + srv_heap_index++; + } - for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { - if (!current_textures[i]) { + for (int i = 0; i < TEXTURE_COUNT; ++i) { + if (!current_textures[i]) { continue; } current_textures[i]->impl.stage = 0; @@ -748,18 +660,18 @@ void iron_gpu_internal_set_textures() { current_textures[i] = NULL; } - ID3D12DescriptorHeap *heaps[] = {srvHeap}; - _commandList->lpVtbl->SetDescriptorHeaps(_commandList, 1, heaps); - _commandList->lpVtbl->SetGraphicsRootDescriptorTable(_commandList, 0, gpu_base); + ID3D12DescriptorHeap *heaps[] = {srv_heap}; + command_list->lpVtbl->SetDescriptorHeaps(command_list, 1, heaps); + command_list->lpVtbl->SetGraphicsRootDescriptorTable(command_list, 0, gpu_base); } -void iron_gpu_draw() { - iron_gpu_internal_set_textures(); - _commandList->lpVtbl->IASetPrimitiveTopology(_commandList, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - _commandList->lpVtbl->DrawIndexedInstanced(_commandList, _indexCount, 1, 0, 0, 0); +void gpu_draw_internal() { + gpu_internal_set_textures(); + command_list->lpVtbl->IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + command_list->lpVtbl->DrawIndexedInstanced(command_list, index_count, 1, 0, 0, 0); } -void iron_gpu_viewport(int x, int y, int width, int height) { +void gpu_viewport(int x, int y, int width, int height) { D3D12_VIEWPORT viewport = { .TopLeftX = (float)x, .TopLeftY = (float)y, @@ -768,73 +680,69 @@ void iron_gpu_viewport(int x, int y, int width, int height) { .MinDepth = 0.0f, .MaxDepth = 1.0f, }; - _commandList->lpVtbl->RSSetViewports(_commandList, 1, &viewport); + command_list->lpVtbl->RSSetViewports(command_list, 1, &viewport); } -void iron_gpu_scissor(int x, int y, int width, int height) { +void gpu_scissor(int x, int y, int width, int height) { D3D12_RECT scissor = { .left = x, .top = y, .right = x + width, .bottom = y + height, }; - _commandList->lpVtbl->RSSetScissorRects(_commandList, 1, &scissor); + command_list->lpVtbl->RSSetScissorRects(command_list, 1, &scissor); } -void iron_gpu_disable_scissor() { +void gpu_disable_scissor() { D3D12_RECT scissor = { .left = 0, .top = 0, .right = current_render_targets[0]->width, .bottom = current_render_targets[0]->height, }; - _commandList->lpVtbl->RSSetScissorRects(_commandList, 1, &scissor); + command_list->lpVtbl->RSSetScissorRects(command_list, 1, &scissor); } -void iron_gpu_set_pipeline(iron_gpu_pipeline_t *pipeline) { - _currentPipeline = pipeline; - _commandList->lpVtbl->SetPipelineState(_commandList, pipeline->impl.pso); - for (int i = 0; i < IRON_INTERNAL_G5_TEXTURE_COUNT; ++i) { +void gpu_set_pipeline(gpu_pipeline_t *pipeline) { + current_pipeline = pipeline; + command_list->lpVtbl->SetPipelineState(command_list, pipeline->impl.pso); + for (int i = 0; i < TEXTURE_COUNT; ++i) { current_textures[i] = NULL; } - _commandList->lpVtbl->SetGraphicsRootSignature(_commandList, root_signature); + command_list->lpVtbl->SetGraphicsRootSignature(command_list, root_signature); } -void iron_gpu_set_vertex_buffer(iron_gpu_buffer_t *buffer) { +void gpu_set_vertex_buffer(gpu_buffer_t *buffer) { D3D12_VERTEX_BUFFER_VIEW view = { - .BufferLocation = buffer->impl.uploadBuffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.uploadBuffer), - .SizeInBytes = (iron_gpu_vertex_buffer_count(buffer)) * iron_gpu_vertex_buffer_stride(buffer), - .StrideInBytes = iron_gpu_vertex_buffer_stride(buffer), + .BufferLocation = buffer->impl.upload_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.upload_buffer), + .SizeInBytes = (gpu_vertex_buffer_count(buffer)) * gpu_vertex_buffer_stride(buffer), + .StrideInBytes = gpu_vertex_buffer_stride(buffer), }; - _commandList->lpVtbl->IASetVertexBuffers(_commandList, 0, 1, &view); + command_list->lpVtbl->IASetVertexBuffers(command_list, 0, 1, &view); } -void iron_gpu_set_index_buffer(iron_gpu_buffer_t *buffer) { - _indexCount = iron_gpu_index_buffer_count(buffer); - _commandList->lpVtbl->IASetIndexBuffer(_commandList, (D3D12_INDEX_BUFFER_VIEW *) & buffer->impl.index_buffer_view); +void gpu_set_index_buffer(gpu_buffer_t *buffer) { + index_count = gpu_index_buffer_count(buffer); + command_list->lpVtbl->IASetIndexBuffer(command_list, (D3D12_INDEX_BUFFER_VIEW *) & buffer->impl.index_buffer_view); } -void iron_gpu_upload_vertex_buffer(struct iron_gpu_buffer *buffer) {} +void gpu_upload_vertex_buffer(struct gpu_buffer *buffer) {} -void iron_gpu_upload_index_buffer(iron_gpu_buffer_t *buffer) { - if (!buffer->impl.gpu_memory) { - return; - } - - _commandList->lpVtbl->CopyBufferRegion(_commandList, buffer->impl.index_buffer, 0, buffer->impl.upload_buffer, 0, sizeof(uint32_t) * buffer->impl.count); +void gpu_upload_index_buffer(gpu_buffer_t *buffer) { + command_list->lpVtbl->CopyBufferRegion(command_list, buffer->impl.buffer, 0, buffer->impl.upload_buffer, 0, sizeof(uint32_t) * buffer->impl.count); D3D12_RESOURCE_BARRIER barrier = { .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, - .Transition.pResource = buffer->impl.index_buffer, + .Transition.pResource = buffer->impl.buffer, .Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST, .Transition.StateAfter = D3D12_RESOURCE_STATE_INDEX_BUFFER, .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); + command_list->lpVtbl->ResourceBarrier(command_list, 1, &barrier); } -void iron_gpu_upload_texture(iron_gpu_texture_t *texture) { +void gpu_upload_texture(gpu_texture_t *texture) { if (texture->uploaded) { return; } @@ -846,7 +754,7 @@ void iron_gpu_upload_texture(iron_gpu_texture_t *texture) { .Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST, .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); + command_list->lpVtbl->ResourceBarrier(command_list, 1, &barrier); D3D12_RESOURCE_DESC Desc; texture->impl.image->lpVtbl->GetDesc(texture->impl.image, &Desc); @@ -857,7 +765,7 @@ void iron_gpu_upload_texture(iron_gpu_texture_t *texture) { device->lpVtbl->Release(device); D3D12_TEXTURE_COPY_LOCATION source = { - .pResource = texture->impl.uploadImage, + .pResource = texture->impl.upload_image, .Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, .PlacedFootprint = footprint, }; @@ -868,7 +776,7 @@ void iron_gpu_upload_texture(iron_gpu_texture_t *texture) { .SubresourceIndex = 0, }; - _commandList->lpVtbl->CopyTextureRegion(_commandList, &destination, 0, 0, 0, &source, NULL); + command_list->lpVtbl->CopyTextureRegion(command_list, &destination, 0, 0, 0, &source, NULL); barrier = (D3D12_RESOURCE_BARRIER){ .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, @@ -878,15 +786,15 @@ void iron_gpu_upload_texture(iron_gpu_texture_t *texture) { .Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); + command_list->lpVtbl->ResourceBarrier(command_list, 1, &barrier); texture->uploaded = true; } -void iron_gpu_get_render_target_pixels(iron_gpu_texture_t *render_target, uint8_t *data) { +void gpu_get_render_target_pixels(gpu_texture_t *render_target, uint8_t *data) { D3D12_RESOURCE_DESC desc; - render_target->impl.renderTarget->lpVtbl->GetDesc(render_target->impl.renderTarget, &desc); - DXGI_FORMAT dxgiFormat = desc.Format; - int _formatSize = format_size(dxgiFormat); + render_target->impl.render_target->lpVtbl->GetDesc(render_target->impl.render_target, &desc); + DXGI_FORMAT dxgi_format = desc.Format; + int _formatSize = format_size(dxgi_format); int rowPitch = render_target->width * _formatSize; int align = rowPitch % D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; if (align != 0) { @@ -894,8 +802,8 @@ void iron_gpu_get_render_target_pixels(iron_gpu_texture_t *render_target, uint8_ } // Create readback buffer - if (render_target->impl.renderTargetReadback == NULL) { - D3D12_HEAP_PROPERTIES heapProperties = { + if (render_target->impl.readback == NULL) { + D3D12_HEAP_PROPERTIES heap_properties = { .Type = D3D12_HEAP_TYPE_READBACK, .CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN, .MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN, @@ -903,7 +811,7 @@ void iron_gpu_get_render_target_pixels(iron_gpu_texture_t *render_target, uint8_ .VisibleNodeMask = 1, }; - D3D12_RESOURCE_DESC resourceDesc = { + D3D12_RESOURCE_DESC resource_desc = { .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, .Alignment = 0, .Width = rowPitch * render_target->height, @@ -917,84 +825,83 @@ void iron_gpu_get_render_target_pixels(iron_gpu_texture_t *render_target, uint8_ .Flags = D3D12_RESOURCE_FLAG_NONE, }; - device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COMMON, NULL, - &IID_ID3D12Resource, &render_target->impl.renderTargetReadback); + device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_COMMON, NULL, + &IID_ID3D12Resource, &render_target->impl.readback); } // Copy render target to readback buffer D3D12_RESOURCE_BARRIER barrier = { - .Transition.pResource = render_target->impl.renderTarget, + .Transition.pResource = render_target->impl.render_target, .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, .Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, .Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE, .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); + command_list->lpVtbl->ResourceBarrier(command_list, 1, &barrier); D3D12_TEXTURE_COPY_LOCATION source = { - .pResource = render_target->impl.renderTarget, + .pResource = render_target->impl.render_target, .Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, .SubresourceIndex = 0, }; D3D12_TEXTURE_COPY_LOCATION dest = { - .pResource = render_target->impl.renderTargetReadback, + .pResource = render_target->impl.readback, .Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, .PlacedFootprint.Offset = 0, - .PlacedFootprint.Footprint.Format = dxgiFormat, + .PlacedFootprint.Footprint.Format = dxgi_format, .PlacedFootprint.Footprint.Width = render_target->width, .PlacedFootprint.Footprint.Height = render_target->height, .PlacedFootprint.Footprint.Depth = 1, .PlacedFootprint.Footprint.RowPitch = rowPitch, }; - _commandList->lpVtbl->CopyTextureRegion(_commandList , &dest, 0, 0, 0, &source, NULL); + command_list->lpVtbl->CopyTextureRegion(command_list , &dest, 0, 0, 0, &source, NULL); barrier = (D3D12_RESOURCE_BARRIER){ - .Transition.pResource = render_target->impl.renderTarget, + .Transition.pResource = render_target->impl.render_target, .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, .Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_SOURCE, .Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); + command_list->lpVtbl->ResourceBarrier(command_list, 1, &barrier); - // iron_gpu_wait(); + // gpu_wait(); // Read buffer void *p; - render_target->impl.renderTargetReadback->lpVtbl->Map(render_target->impl.renderTargetReadback, 0, NULL, &p); + render_target->impl.readback->lpVtbl->Map(render_target->impl.readback, 0, NULL, &p); memcpy(data, p, render_target->width * render_target->height * _formatSize); - render_target->impl.renderTargetReadback->lpVtbl->Unmap(render_target->impl.renderTargetReadback, 0, NULL); + render_target->impl.readback->lpVtbl->Unmap(render_target->impl.readback, 0, NULL); } -void iron_gpu_set_texture(int unit, iron_gpu_texture_t *texture) { - iron_gpu_upload_texture(texture); +void gpu_set_texture(int unit, gpu_texture_t *texture) { + gpu_upload_texture(texture); texture->impl.stage = unit; current_textures[texture->impl.stage] = texture; } -void iron_gpu_set_texture_depth(int unit, iron_gpu_texture_t *texture) { +void gpu_set_texture_depth(int unit, gpu_texture_t *texture) { texture->impl.stage_depth = unit; current_textures[texture->impl.stage_depth] = texture; } -void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipe) { +void gpu_pipeline_init(gpu_pipeline_t *pipe) { gpu_internal_pipeline_init(pipe); } -void iron_gpu_pipeline_destroy(iron_gpu_pipeline_t *pipe) { +void gpu_pipeline_destroy(gpu_pipeline_t *pipe) { if (pipe->impl.pso != NULL) { pipe->impl.pso->lpVtbl->Release(pipe->impl.pso); pipe->impl.pso = NULL; } } -void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipe) { +void gpu_pipeline_compile(gpu_pipeline_t *pipe) { int vertex_attribute_count = pipe->input_layout->size; - D3D12_INPUT_ELEMENT_DESC *vertex_desc = (D3D12_INPUT_ELEMENT_DESC *)alloca(sizeof(D3D12_INPUT_ELEMENT_DESC) * vertex_attribute_count); ZeroMemory(vertex_desc, sizeof(D3D12_INPUT_ELEMENT_DESC) * vertex_attribute_count); @@ -1005,24 +912,23 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipe) { vertex_desc[i].AlignedByteOffset = (i == 0) ? 0 : D3D12_APPEND_ALIGNED_ELEMENT; vertex_desc[i].InputSlotClass = D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; vertex_desc[i].InstanceDataStepRate = 0; - switch (pipe->input_layout->elements[i].data) { - case IRON_GPU_VERTEX_DATA_F32_1X: + case GPU_VERTEX_DATA_F32_1X: vertex_desc[i].Format = DXGI_FORMAT_R32_FLOAT; break; - case IRON_GPU_VERTEX_DATA_F32_2X: + case GPU_VERTEX_DATA_F32_2X: vertex_desc[i].Format = DXGI_FORMAT_R32G32_FLOAT; break; - case IRON_GPU_VERTEX_DATA_F32_3X: + case GPU_VERTEX_DATA_F32_3X: vertex_desc[i].Format = DXGI_FORMAT_R32G32B32_FLOAT; break; - case IRON_GPU_VERTEX_DATA_F32_4X: + case GPU_VERTEX_DATA_F32_4X: vertex_desc[i].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; break; - case IRON_GPU_VERTEX_DATA_I16_2X_NORM: + case GPU_VERTEX_DATA_I16_2X_NORM: vertex_desc[i].Format = DXGI_FORMAT_R16G16_SNORM; break; - case IRON_GPU_VERTEX_DATA_I16_4X_NORM: + case GPU_VERTEX_DATA_I16_4X_NORM: vertex_desc[i].Format = DXGI_FORMAT_R16G16B16A16_SNORM; break; default: @@ -1063,7 +969,7 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipe) { .DepthStencilState.StencilEnable = FALSE, .DepthStencilState.StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK, .DepthStencilState.StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK, - .DepthStencilState.DepthEnable = pipe->depth_mode != IRON_GPU_COMPARE_MODE_ALWAYS, + .DepthStencilState.DepthEnable = pipe->depth_mode != GPU_COMPARE_MODE_ALWAYS, .DepthStencilState.DepthWriteMask = pipe->depth_write ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO, .DepthStencilState.DepthFunc = convert_compare_mode(pipe->depth_mode), .DepthStencilState.StencilEnable = false, @@ -1079,56 +985,38 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipe) { psoDesc.RTVFormats[i] = convert_format(pipe->color_attachment[i]); } - const D3D12_RENDER_TARGET_BLEND_DESC default_render_target_blend_desc = { - FALSE, - FALSE, - D3D12_BLEND_ONE, - D3D12_BLEND_ZERO, - D3D12_BLEND_OP_ADD, - D3D12_BLEND_ONE, - D3D12_BLEND_ZERO, - D3D12_BLEND_OP_ADD, - D3D12_LOGIC_OP_NOOP, - D3D12_COLOR_WRITE_ENABLE_ALL, - }; + psoDesc.BlendState.IndependentBlendEnable = true; for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) { - psoDesc.BlendState.RenderTarget[i] = default_render_target_blend_desc; - } - - bool independent_blend = false; - for (int i = 1; i < 8; ++i) { - if (pipe->color_write_mask_red[0] != pipe->color_write_mask_red[i] || - pipe->color_write_mask_green[0] != pipe->color_write_mask_green[i] || - pipe->color_write_mask_blue[0] != pipe->color_write_mask_blue[i] || - pipe->color_write_mask_alpha[0] != pipe->color_write_mask_alpha[i]) { - independent_blend = true; - break; - } - } - - set_blend_state(&psoDesc.BlendState, pipe, 0); - if (independent_blend) { - psoDesc.BlendState.IndependentBlendEnable = true; - for (int i = 1; i < 8; ++i) { - set_blend_state(&psoDesc.BlendState, pipe, i); - } + psoDesc.BlendState.RenderTarget[i].BlendEnable = pipe->blend_source != GPU_BLEND_ONE || pipe->blend_destination != GPU_BLEND_ZERO || + pipe->alpha_blend_source != GPU_BLEND_ONE || pipe->alpha_blend_destination != GPU_BLEND_ZERO; + psoDesc.BlendState.RenderTarget[i].SrcBlend = convert_blend_factor(pipe->blend_source); + psoDesc.BlendState.RenderTarget[i].DestBlend = convert_blend_factor(pipe->blend_destination); + psoDesc.BlendState.RenderTarget[i].BlendOp = convert_blend_operation(pipe->blend_operation); + psoDesc.BlendState.RenderTarget[i].SrcBlendAlpha = convert_blend_factor(pipe->alpha_blend_source); + psoDesc.BlendState.RenderTarget[i].DestBlendAlpha = convert_blend_factor(pipe->alpha_blend_destination); + psoDesc.BlendState.RenderTarget[i].BlendOpAlpha = convert_blend_operation(pipe->alpha_blend_operation); + psoDesc.BlendState.RenderTarget[i].RenderTargetWriteMask = + (((pipe->color_write_mask_red[i] ? D3D12_COLOR_WRITE_ENABLE_RED : 0) | + (pipe->color_write_mask_green[i] ? D3D12_COLOR_WRITE_ENABLE_GREEN : 0)) | + (pipe->color_write_mask_blue[i] ? D3D12_COLOR_WRITE_ENABLE_BLUE : 0)) | + (pipe->color_write_mask_alpha[i] ? D3D12_COLOR_WRITE_ENABLE_ALPHA : 0); } device->lpVtbl->CreateGraphicsPipelineState(device, &psoDesc, &IID_ID3D12PipelineState, &pipe->impl.pso); } -void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *_data, size_t length, iron_gpu_shader_type_t type) { +void gpu_shader_init(gpu_shader_t *shader, const void *_data, size_t length, gpu_shader_type_t type) { uint8_t *data = (uint8_t *)_data; shader->impl.length = (int)length; shader->impl.data = (uint8_t *)malloc(shader->impl.length); memcpy(shader->impl.data, data, shader->impl.length); } -void iron_gpu_shader_destroy(iron_gpu_shader_t *shader) { +void gpu_shader_destroy(gpu_shader_t *shader) { free(shader->impl.data); } -void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { +void gpu_texture_init_from_bytes(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; @@ -1138,12 +1026,11 @@ void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, i texture->uploaded = false; texture->format = format; texture->data = data; - texture->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; - texture->framebuffer_index = -1; - texture->impl.renderTarget = NULL; + texture->impl.state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + texture->impl.render_target = NULL; - DXGI_FORMAT d3dformat = convert_format(format); - int _formatSize = format_size(d3dformat); + DXGI_FORMAT d3d_format = convert_format(format); + int _formatSize = format_size(d3d_format); D3D12_HEAP_PROPERTIES heapPropertiesDefault = { .Type = D3D12_HEAP_TYPE_DEFAULT, @@ -1160,7 +1047,7 @@ void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, i .Height = texture->height, .DepthOrArraySize = 1, .MipLevels = 1, - .Format = d3dformat, + .Format = d3d_format, .SampleDesc.Count = 1, .SampleDesc.Quality = 0, .Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, @@ -1205,13 +1092,13 @@ void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, i }; result = device->lpVtbl->CreateCommittedResource(device, &heapPropertiesUpload, D3D12_HEAP_FLAG_NONE, &resourceDescBuffer, - D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.uploadImage); + D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.upload_image); if (result != S_OK) { for (int i = 0; i < 10; ++i) { iron_memory_emergency(); result = device->lpVtbl->CreateCommittedResource(device, &heapPropertiesUpload, D3D12_HEAP_FLAG_NONE, &resourceDescBuffer, - D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.uploadImage); + D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.upload_image); if (result == S_OK) { break; } @@ -1221,36 +1108,36 @@ void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, i texture->impl.stride = (int)ceilf(uploadBufferSize / (float)(height * D3D12_TEXTURE_DATA_PITCH_ALIGNMENT)) * D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; BYTE *pixel; - texture->impl.uploadImage->lpVtbl->Map(texture->impl.uploadImage, 0, NULL, (void **)&pixel); - int pitch = iron_gpu_texture_stride(texture); + texture->impl.upload_image->lpVtbl->Map(texture->impl.upload_image, 0, NULL, (void **)&pixel); + int pitch = 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); } - texture->impl.uploadImage->lpVtbl->Unmap(texture->impl.uploadImage, 0, NULL); + texture->impl.upload_image->lpVtbl->Unmap(texture->impl.upload_image, 0, NULL); - D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = { + D3D12_DESCRIPTOR_HEAP_DESC descriptor_heap_desc = { .NumDescriptors = 1, .Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, .NodeMask = 0, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE, }; - device->lpVtbl->CreateDescriptorHeap(device, &descriptorHeapDesc, &IID_ID3D12DescriptorHeap, &texture->impl.srvDescriptorHeap); + device->lpVtbl->CreateDescriptorHeap(device, &descriptor_heap_desc, &IID_ID3D12DescriptorHeap, &texture->impl.srv_descriptor_heap); - D3D12_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc = { + D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = { .ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D, .Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, - .Format = d3dformat, + .Format = d3d_format, .Texture2D.MipLevels = 1, .Texture2D.MostDetailedMip = 0, .Texture2D.ResourceMinLODClamp = 0.0f, }; D3D12_CPU_DESCRIPTOR_HANDLE handle; - texture->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texture->impl.srvDescriptorHeap, &handle); - device->lpVtbl->CreateShaderResourceView(device, texture->impl.image, &shaderResourceViewDesc, handle); + texture->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texture->impl.srv_descriptor_heap, &handle); + device->lpVtbl->CreateShaderResourceView(device, texture->impl.image, &srv_desc, handle); } -void create_texture(struct iron_gpu_texture *texture, int width, int height, iron_image_format_t format, D3D12_RESOURCE_FLAGS flags) { +void gpu_texture_init(struct gpu_texture *texture, 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; @@ -1258,10 +1145,9 @@ void create_texture(struct iron_gpu_texture *texture, int width, int height, iro texture->width = width; texture->height = height; texture->data = NULL; - texture->framebuffer_index = -1; - texture->impl.renderTarget = NULL; + texture->impl.render_target = NULL; - DXGI_FORMAT d3dformat = convert_format(format); + DXGI_FORMAT d3d_format = convert_format(format); D3D12_HEAP_PROPERTIES heapPropertiesDefault = { .Type = D3D12_HEAP_TYPE_DEFAULT, @@ -1278,11 +1164,11 @@ void create_texture(struct iron_gpu_texture *texture, int width, int height, iro .Height = texture->height, .DepthOrArraySize = 1, .MipLevels = 1, - .Format = d3dformat, + .Format = d3d_format, .SampleDesc.Count = 1, .SampleDesc.Quality = 0, .Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - .Flags = flags, + .Flags = D3D12_RESOURCE_FLAG_NONE, }; HRESULT result = device->lpVtbl->CreateCommittedResource(device, &heapPropertiesDefault, D3D12_HEAP_FLAG_NONE, &resourceDescTex, @@ -1322,12 +1208,12 @@ void create_texture(struct iron_gpu_texture *texture, int width, int height, iro }; result = device->lpVtbl->CreateCommittedResource(device, &heapPropertiesUpload, D3D12_HEAP_FLAG_NONE, &resourceDescBuffer, - D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.uploadImage); + D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.upload_image); if (result != S_OK) { for (int i = 0; i < 10; ++i) { iron_memory_emergency(); result = device->lpVtbl->CreateCommittedResource(device, &heapPropertiesUpload, D3D12_HEAP_FLAG_NONE, &resourceDescBuffer, - D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.uploadImage); + D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &texture->impl.upload_image); if (result == S_OK) { break; } @@ -1336,93 +1222,85 @@ void create_texture(struct iron_gpu_texture *texture, int width, int height, iro texture->impl.stride = (int)ceilf(uploadBufferSize / (float)(height * D3D12_TEXTURE_DATA_PITCH_ALIGNMENT)) * D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; - D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = { + D3D12_DESCRIPTOR_HEAP_DESC descriptor_heap_desc = { .NumDescriptors = 1, .Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, .NodeMask = 0, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE, }; - device->lpVtbl->CreateDescriptorHeap(device, &descriptorHeapDesc, &IID_ID3D12DescriptorHeap, &texture->impl.srvDescriptorHeap); + device->lpVtbl->CreateDescriptorHeap(device, &descriptor_heap_desc, &IID_ID3D12DescriptorHeap, &texture->impl.srv_descriptor_heap); - D3D12_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc = { + D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = { .ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D, .Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, - .Format = d3dformat, + .Format = d3d_format, .Texture2D.MipLevels = 1, .Texture2D.MostDetailedMip = 0, .Texture2D.ResourceMinLODClamp = 0.0f, }; D3D12_CPU_DESCRIPTOR_HANDLE handle; - texture->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texture->impl.srvDescriptorHeap, &handle); + texture->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texture->impl.srv_descriptor_heap, &handle); + + device->lpVtbl->CreateShaderResourceView(device, texture->impl.image, &srv_desc, handle); - device->lpVtbl->CreateShaderResourceView(device, texture->impl.image, &shaderResourceViewDesc, handle); -} -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->impl.state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; texture->format = format; } -void iron_gpu_texture_destroy(iron_gpu_texture_t *render_target) { - if (render_target->impl.framebuffer_index >= 0) { - framebuffer_count -= 1; - } - - if (render_target->impl.renderTarget != NULL) { - render_target->impl.renderTarget->lpVtbl->Release(render_target->impl.renderTarget); - render_target->impl.renderTargetDescriptorHeap->lpVtbl->Release(render_target->impl.renderTargetDescriptorHeap); - render_target->impl.srvDescriptorHeap->lpVtbl->Release(render_target->impl.srvDescriptorHeap); - if (render_target->impl.depthTexture != NULL) { - render_target->impl.depthTexture->lpVtbl->Release(render_target->impl.depthTexture); - render_target->impl.depthDescriptorHeap->lpVtbl->Release(render_target->impl.depthDescriptorHeap); - render_target->impl.srvDepthDescriptorHeap->lpVtbl->Release(render_target->impl.srvDepthDescriptorHeap); +void gpu_texture_destroy(gpu_texture_t *render_target) { + if (render_target->impl.render_target != NULL) { + render_target->impl.render_target->lpVtbl->Release(render_target->impl.render_target); + render_target->impl.descriptor_heap->lpVtbl->Release(render_target->impl.descriptor_heap); + render_target->impl.srv_descriptor_heap->lpVtbl->Release(render_target->impl.srv_descriptor_heap); + if (render_target->impl.depth_texture != NULL) { + render_target->impl.depth_texture->lpVtbl->Release(render_target->impl.depth_texture); + render_target->impl.depth_descriptor_heap->lpVtbl->Release(render_target->impl.depth_descriptor_heap); + render_target->impl.srv_depth_descriptor_heap->lpVtbl->Release(render_target->impl.srv_depth_descriptor_heap); } - if (render_target->impl.renderTargetReadback != NULL) { - render_target->impl.renderTargetReadback->lpVtbl->Release(render_target->impl.renderTargetReadback); + if (render_target->impl.readback != NULL) { + render_target->impl.readback->lpVtbl->Release(render_target->impl.readback); } } if (render_target->impl.image != NULL) { render_target->impl.image->lpVtbl->Release(render_target->impl.image); - render_target->impl.uploadImage->lpVtbl->Release(render_target->impl.uploadImage); + render_target->impl.upload_image->lpVtbl->Release(render_target->impl.upload_image); } } -int iron_gpu_texture_stride(struct iron_gpu_texture *texture) { +int gpu_texture_stride(struct gpu_texture *texture) { return texture->impl.stride; } -void iron_gpu_texture_generate_mipmaps(struct iron_gpu_texture *texture, int levels) {} +void gpu_texture_generate_mipmaps(struct gpu_texture *texture, int levels) {} -void iron_gpu_texture_set_mipmap(struct iron_gpu_texture *texture, struct iron_gpu_texture *mipmap, int level) {} +void gpu_texture_set_mipmap(struct gpu_texture *texture, struct gpu_texture *mipmap, int level) {} -void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_buffer_bits) { +void gpu_render_target_init(gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_buffer_bits) { render_target_init(target, width, height, format, depth_buffer_bits, -1); - target->uploaded = true; - target->state = IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE; } -void iron_gpu_render_target_set_depth_from(iron_gpu_texture_t *render_target, iron_gpu_texture_t *source) { - render_target->impl.depthDescriptorHeap = source->impl.depthDescriptorHeap; - render_target->impl.srvDepthDescriptorHeap = source->impl.srvDepthDescriptorHeap; - render_target->impl.depthTexture = source->impl.depthTexture; +void gpu_render_target_set_depth_from(gpu_texture_t *render_target, gpu_texture_t *source) { + render_target->impl.depth_descriptor_heap = source->impl.depth_descriptor_heap; + render_target->impl.srv_depth_descriptor_heap = source->impl.srv_depth_descriptor_heap; + render_target->impl.depth_texture = source->impl.depth_texture; } -void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, bool gpuMemory) { +void gpu_vertex_buffer_init(gpu_buffer_t *buffer, int count, gpu_vertex_structure_t *structure) { buffer->count = count; - buffer->impl.myStride = 0; + buffer->impl.stride = 0; for (int i = 0; i < structure->size; ++i) { - buffer->impl.myStride += iron_gpu_vertex_data_size(structure->elements[i].data); + buffer->impl.stride += gpu_vertex_data_size(structure->elements[i].data); } - int uploadBufferSize = buffer->impl.myStride * buffer->count; + int uploadBufferSize = buffer->impl.stride * buffer->count; - D3D12_HEAP_PROPERTIES heapProperties = { + D3D12_HEAP_PROPERTIES heap_properties = { .Type = D3D12_HEAP_TYPE_UPLOAD, .CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN, .MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN, @@ -1430,7 +1308,7 @@ void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int count, iron_gpu_ .VisibleNodeMask = 1, }; - D3D12_RESOURCE_DESC resourceDesc = { + D3D12_RESOURCE_DESC resource_desc = { .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, .Alignment = 0, .Width = uploadBufferSize, @@ -1444,60 +1322,49 @@ void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int count, iron_gpu_ .Flags = D3D12_RESOURCE_FLAG_NONE, }; - device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, - &IID_ID3D12Resource, &buffer->impl.uploadBuffer); + device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, + &IID_ID3D12Resource, &buffer->impl.upload_buffer); - buffer->impl.view.BufferLocation = buffer->impl.uploadBuffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.uploadBuffer); - buffer->impl.view.SizeInBytes = uploadBufferSize; - buffer->impl.view.StrideInBytes = buffer->impl.myStride; - - buffer->impl.lastStart = 0; - buffer->impl.lastCount = iron_gpu_vertex_buffer_count(buffer); + buffer->impl.vertex_buffer_view.BufferLocation = buffer->impl.upload_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.upload_buffer); + buffer->impl.vertex_buffer_view.SizeInBytes = uploadBufferSize; + buffer->impl.vertex_buffer_view.StrideInBytes = buffer->impl.stride; } -void iron_gpu_vertex_buffer_destroy(iron_gpu_buffer_t *buffer) { - buffer->impl.uploadBuffer->lpVtbl->Release(buffer->impl.uploadBuffer); +void gpu_vertex_buffer_destroy(gpu_buffer_t *buffer) { + buffer->impl.upload_buffer->lpVtbl->Release(buffer->impl.upload_buffer); } -float *iron_gpu_vertex_buffer_lock(iron_gpu_buffer_t *buffer) { - int start = 0; - int count = iron_gpu_vertex_buffer_count(buffer); - buffer->impl.lastStart = start; - buffer->impl.lastCount = count; - +float *gpu_vertex_buffer_lock(gpu_buffer_t *buffer) { D3D12_RANGE range = { - .Begin = start * buffer->impl.myStride, - .End = (start + count) * buffer->impl.myStride, + .Begin = 0, + .End = gpu_vertex_buffer_count(buffer) * buffer->impl.stride, }; - void *p; - buffer->impl.uploadBuffer->lpVtbl->Map(buffer->impl.uploadBuffer, 0, &range, &p); - byte *bytes = (byte *)p; - bytes += start * buffer->impl.myStride; - return (float *)bytes; + buffer->impl.upload_buffer->lpVtbl->Map(buffer->impl.upload_buffer, 0, &range, &p); + return (float *)p; } -void iron_gpu_vertex_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_vertex_buffer_unlock(gpu_buffer_t *buffer) { D3D12_RANGE range = { - .Begin = buffer->impl.lastStart * buffer->impl.myStride, - .End = (buffer->impl.lastStart + buffer->impl.lastCount) * buffer->impl.myStride, + .Begin = 0, + .End = gpu_vertex_buffer_count(buffer) * buffer->impl.stride, }; - buffer->impl.uploadBuffer->lpVtbl->Unmap(buffer->impl.uploadBuffer, 0, &range); + buffer->impl.upload_buffer->lpVtbl->Unmap(buffer->impl.upload_buffer, 0, &range); } -int iron_gpu_vertex_buffer_count(iron_gpu_buffer_t *buffer) { +int gpu_vertex_buffer_count(gpu_buffer_t *buffer) { return buffer->count; } -int iron_gpu_vertex_buffer_stride(iron_gpu_buffer_t *buffer) { - return buffer->impl.myStride; +int gpu_vertex_buffer_stride(gpu_buffer_t *buffer) { + return buffer->impl.stride; } -void iron_gpu_constant_buffer_init(iron_gpu_buffer_t *buffer, int size) { - buffer->impl.mySize = size; +void gpu_constant_buffer_init(gpu_buffer_t *buffer, int size) { + buffer->impl.count = size; buffer->data = NULL; - D3D12_HEAP_PROPERTIES heapProperties = { + D3D12_HEAP_PROPERTIES heap_properties = { .Type = D3D12_HEAP_TYPE_UPLOAD, .CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN, .MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN, @@ -1505,7 +1372,7 @@ void iron_gpu_constant_buffer_init(iron_gpu_buffer_t *buffer, int size) { .VisibleNodeMask = 1, }; - D3D12_RESOURCE_DESC resourceDesc = { + D3D12_RESOURCE_DESC resource_desc = { .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, .Alignment = 0, .Width = size, @@ -1519,50 +1386,44 @@ void iron_gpu_constant_buffer_init(iron_gpu_buffer_t *buffer, int size) { .Flags = D3D12_RESOURCE_FLAG_NONE, }; - device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &buffer->impl.constant_buffer); - - void *p; - buffer->impl.constant_buffer->lpVtbl->Map(buffer->impl.constant_buffer, 0, NULL, &p); - ZeroMemory(p, size); - buffer->impl.constant_buffer->lpVtbl->Unmap(buffer->impl.constant_buffer, 0, NULL); + device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &buffer->impl.buffer); } -void iron_gpu_constant_buffer_destroy(iron_gpu_buffer_t *buffer) { - buffer->impl.constant_buffer->lpVtbl->Release(buffer->impl.constant_buffer); +void gpu_constant_buffer_destroy(gpu_buffer_t *buffer) { + buffer->impl.buffer->lpVtbl->Release(buffer->impl.buffer); } -void iron_gpu_constant_buffer_lock(iron_gpu_buffer_t *buffer, int start, int count) { - buffer->impl.lastStart = start; - buffer->impl.lastCount = count; +void gpu_constant_buffer_lock(gpu_buffer_t *buffer, int start, int count) { + buffer->impl.last_start = start; + buffer->impl.last_count = count; D3D12_RANGE range = { .Begin = start, .End = range.Begin + count, }; uint8_t *p; - buffer->impl.constant_buffer->lpVtbl->Map(buffer->impl.constant_buffer, 0, &range, (void **)&p); + buffer->impl.buffer->lpVtbl->Map(buffer->impl.buffer, 0, &range, (void **)&p); buffer->data = &p[start]; } -void iron_gpu_constant_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_constant_buffer_unlock(gpu_buffer_t *buffer) { D3D12_RANGE range = { - .Begin = buffer->impl.lastStart, - .End = range.Begin + buffer->impl.lastCount, + .Begin = buffer->impl.last_start, + .End = range.Begin + buffer->impl.last_count, }; - buffer->impl.constant_buffer->lpVtbl->Unmap(buffer->impl.constant_buffer, 0, &range); + buffer->impl.buffer->lpVtbl->Unmap(buffer->impl.buffer, 0, &range); buffer->data = NULL; } -int iron_gpu_constant_buffer_size(iron_gpu_buffer_t *buffer) { - return buffer->impl.mySize; +int gpu_constant_buffer_size(gpu_buffer_t *buffer) { + return buffer->impl.count; } -void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int count, bool gpuMemory) { +void gpu_index_buffer_init(gpu_buffer_t *buffer, int count) { buffer->impl.count = count; - buffer->impl.gpu_memory = gpuMemory; int uploadBufferSize = sizeof(uint32_t) * count; - D3D12_HEAP_PROPERTIES heapProperties = { + D3D12_HEAP_PROPERTIES heap_properties = { .Type = D3D12_HEAP_TYPE_UPLOAD, .CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN, .MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN, @@ -1570,7 +1431,7 @@ void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int count, bool gpuMe .VisibleNodeMask = 1, }; - D3D12_RESOURCE_DESC resourceDesc = { + D3D12_RESOURCE_DESC resource_desc = { .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, .Alignment = 0, .Width = uploadBufferSize, @@ -1584,76 +1445,69 @@ void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int count, bool gpuMe .Flags = D3D12_RESOURCE_FLAG_NONE, }; - device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, + device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &IID_ID3D12Resource, &buffer->impl.upload_buffer); - if (gpuMemory) { - D3D12_HEAP_PROPERTIES heapProperties = { - .Type = D3D12_HEAP_TYPE_DEFAULT, - .CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN, - .MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN, - .CreationNodeMask = 1, - .VisibleNodeMask = 1, - }; + heap_properties = (D3D12_HEAP_PROPERTIES){ + .Type = D3D12_HEAP_TYPE_DEFAULT, + .CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN, + .MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN, + .CreationNodeMask = 1, + .VisibleNodeMask = 1, + }; - device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, - D3D12_RESOURCE_STATE_COMMON, NULL, &IID_ID3D12Resource, &buffer->impl.index_buffer); + device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, + D3D12_RESOURCE_STATE_COMMON, NULL, &IID_ID3D12Resource, &buffer->impl.buffer); - buffer->impl.index_buffer_view.BufferLocation = buffer->impl.index_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.index_buffer); - } - else { - buffer->impl.index_buffer_view.BufferLocation = buffer->impl.upload_buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.upload_buffer); - } + buffer->impl.index_buffer_view.BufferLocation = buffer->impl.buffer->lpVtbl->GetGPUVirtualAddress(buffer->impl.buffer); buffer->impl.index_buffer_view.SizeInBytes = uploadBufferSize; buffer->impl.index_buffer_view.Format = DXGI_FORMAT_R32_UINT; - buffer->impl.last_start = 0; - buffer->impl.last_count = iron_gpu_index_buffer_count(buffer); + buffer->impl.last_count = gpu_index_buffer_count(buffer); } -void iron_gpu_index_buffer_destroy(iron_gpu_buffer_t *buffer) { - // if (buffer->impl.index_buffer != NULL) { - // buffer->impl.index_buffer->lpVtbl->Release(buffer->impl.index_buffer); - // buffer->impl.index_buffer = NULL; - // } - - // buffer->impl.upload_buffer->lpVtbl->Release(buffer->impl.upload_buffer); - // buffer->impl.upload_buffer = NULL; +void gpu_index_buffer_destroy(gpu_buffer_t *buffer) { + if (buffer->impl.buffer != NULL) { + buffer->impl.buffer->lpVtbl->Release(buffer->impl.buffer); + buffer->impl.buffer = NULL; + } + buffer->impl.upload_buffer->lpVtbl->Release(buffer->impl.upload_buffer); + buffer->impl.upload_buffer = NULL; } -static int iron_gpu_internal_index_buffer_stride(iron_gpu_buffer_t *buffer) { +static int gpu_internal_index_buffer_stride(gpu_buffer_t *buffer) { return 4; } -void *iron_gpu_index_buffer_lock(iron_gpu_buffer_t *buffer) { +void *gpu_index_buffer_lock(gpu_buffer_t *buffer) { int start = 0; - int count = iron_gpu_index_buffer_count(buffer); + int count = gpu_index_buffer_count(buffer); buffer->impl.last_start = start; buffer->impl.last_count = count; D3D12_RANGE range = { - .Begin = start * iron_gpu_internal_index_buffer_stride(buffer), - .End = (start + count) * iron_gpu_internal_index_buffer_stride(buffer), + .Begin = start * gpu_internal_index_buffer_stride(buffer), + .End = (start + count) * 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_gpu_internal_index_buffer_stride(buffer); + bytes += start * gpu_internal_index_buffer_stride(buffer); return bytes; } -void iron_gpu_index_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_index_buffer_unlock(gpu_buffer_t *buffer) { D3D12_RANGE range = { - .Begin = buffer->impl.last_start * iron_gpu_internal_index_buffer_stride(buffer), - .End = (buffer->impl.last_start + buffer->impl.last_count) * iron_gpu_internal_index_buffer_stride(buffer), + .Begin = buffer->impl.last_start * gpu_internal_index_buffer_stride(buffer), + .End = (buffer->impl.last_start + buffer->impl.last_count) * gpu_internal_index_buffer_stride(buffer), }; buffer->impl.upload_buffer->lpVtbl->Unmap(buffer->impl.upload_buffer, 0, &range); - iron_gpu_upload_index_buffer(buffer); + gpu_upload_index_buffer(buffer); } -int iron_gpu_index_buffer_count(iron_gpu_buffer_t *buffer) { +int gpu_index_buffer_count(gpu_buffer_t *buffer) { return buffer->impl.count; } @@ -1671,9 +1525,9 @@ static ID3D12Device5 *dxrDevice = NULL; static ID3D12GraphicsCommandList4 *dxrCommandList = NULL; static ID3D12RootSignature *dxrRootSignature = NULL; static ID3D12DescriptorHeap *descriptorHeap = NULL; -static iron_gpu_raytrace_acceleration_structure_t *accel; -static iron_gpu_raytrace_pipeline_t *pipeline; -static iron_gpu_texture_t *output = NULL; +static gpu_raytrace_acceleration_structure_t *accel; +static gpu_raytrace_pipeline_t *pipeline; +static gpu_texture_t *output = NULL; static D3D12_CPU_DESCRIPTOR_HANDLE outputCpuDescriptor; static D3D12_GPU_DESCRIPTOR_HANDLE outputDescriptorHandle; static D3D12_GPU_DESCRIPTOR_HANDLE vbgpuDescriptorHandle; @@ -1687,16 +1541,16 @@ static D3D12_GPU_DESCRIPTOR_HANDLE texscramblegpuDescriptorHandle; static D3D12_GPU_DESCRIPTOR_HANDLE texrankgpuDescriptorHandle; static int descriptorsAllocated = 0; static UINT descriptorSize; -static iron_gpu_buffer_t *vb[16]; -static iron_gpu_buffer_t *vb_last[16]; -static iron_gpu_buffer_t *ib[16]; +static gpu_buffer_t *vb[16]; +static gpu_buffer_t *vb_last[16]; +static gpu_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_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, void *ray_shader, int ray_shader_size, - struct iron_gpu_buffer *constant_buffer) { +void gpu_raytrace_pipeline_init(gpu_raytrace_pipeline_t *pipeline, void *ray_shader, int ray_shader_size, + struct gpu_buffer *constant_buffer) { output = NULL; descriptorsAllocated = 0; pipeline->_constant_buffer = constant_buffer; @@ -1704,7 +1558,7 @@ void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, voi // Allocate a heap for 3 descriptors: // 2 - bottom and top level acceleration structure // 1 - raytracing output texture SRV - D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = { + D3D12_DESCRIPTOR_HEAP_DESC descriptor_heap_desc = { .NumDescriptors = 12, .Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, @@ -1713,7 +1567,7 @@ void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, voi if (descriptorHeap != NULL) { descriptorHeap->lpVtbl->Release(descriptorHeap); } - device->lpVtbl->CreateDescriptorHeap(device, &descriptorHeapDesc, &IID_ID3D12DescriptorHeap, &descriptorHeap); + device->lpVtbl->CreateDescriptorHeap(device, &descriptor_heap_desc, &IID_ID3D12DescriptorHeap, &descriptorHeap); descriptorSize = device->lpVtbl->GetDescriptorHandleIncrementSize(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); // Device @@ -1724,7 +1578,7 @@ void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, voi if (dxrCommandList != NULL) { dxrCommandList->lpVtbl->Release(dxrCommandList); } - _commandList->lpVtbl->QueryInterface(_commandList , &IID_ID3D12GraphicsCommandList4, &dxrCommandList); + command_list->lpVtbl->QueryInterface(command_list , &IID_ID3D12GraphicsCommandList4, &dxrCommandList); // Root signatures // This is a root signature that is shared across all raytracing shaders invoked during a DispatchRays() call. @@ -1925,7 +1779,7 @@ void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, voi // Ray gen shader table { - UINT size = shaderIdSize + constant_buffer->impl.mySize; + UINT size = shaderIdSize + constant_buffer->impl.count; UINT shaderRecordSize = (size + (align - 1)) & ~(align - 1); D3D12_RESOURCE_DESC bufferDesc = { .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, @@ -1956,12 +1810,12 @@ void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, voi D3D12_RANGE cbRange = { .Begin = 0, - .End = constant_buffer->impl.mySize, + .End = constant_buffer->impl.count, }; void *constantBufferData; - constant_buffer->impl.constant_buffer->lpVtbl->Map(constant_buffer->impl.constant_buffer, 0, &cbRange, (void **)&constantBufferData); + constant_buffer->impl.buffer->lpVtbl->Map(constant_buffer->impl.buffer, 0, &cbRange, (void **)&constantBufferData); memcpy(byteDest, rayGenShaderId, size); - memcpy(byteDest + size, constantBufferData, constant_buffer->impl.mySize); + memcpy(byteDest + size, constantBufferData, constant_buffer->impl.count); pipeline->impl.raygen_shader_table->lpVtbl->Unmap(pipeline->impl.raygen_shader_table, 0, NULL); } @@ -2043,14 +1897,14 @@ void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, voi outputDescriptorHandle.ptr = handle.ptr + (INT64)(descriptorHeapIndex) * (UINT64)(descriptorSize); } -void iron_gpu_raytrace_pipeline_destroy(iron_gpu_raytrace_pipeline_t *pipeline) { +void gpu_raytrace_pipeline_destroy(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_gpu_buffer_t *vb, UINT numElements, UINT elementSize) { +UINT create_srv_vb(gpu_buffer_t *vb, UINT numElements, UINT elementSize) { D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = { .ViewDimension = D3D12_SRV_DIMENSION_BUFFER, .Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, @@ -2075,14 +1929,14 @@ UINT create_srv_vb(iron_gpu_buffer_t *vb, UINT numElements, UINT elementSize) { .ptr = handle.ptr + (INT64)(descriptorsAllocated) * (UINT64)(descriptorSize), }; UINT descriptorIndex = descriptorsAllocated++; - device->lpVtbl->CreateShaderResourceView(device, vb->impl.uploadBuffer, &srvDesc, cpuDescriptor); + device->lpVtbl->CreateShaderResourceView(device, vb->impl.upload_buffer, &srvDesc, cpuDescriptor); descriptorHeap->lpVtbl->GetGPUDescriptorHandleForHeapStart(descriptorHeap, &handle); vbgpuDescriptorHandle.ptr = handle.ptr + (INT64)(descriptorIndex) * (UINT64)(descriptorSize); return descriptorIndex; } -UINT create_srv_ib(iron_gpu_buffer_t *ib, UINT numElements, UINT elementSize) { +UINT create_srv_ib(gpu_buffer_t *ib, UINT numElements, UINT elementSize) { D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = { .ViewDimension = D3D12_SRV_DIMENSION_BUFFER, .Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, @@ -2115,12 +1969,12 @@ UINT create_srv_ib(iron_gpu_buffer_t *ib, UINT numElements, UINT elementSize) { return descriptorIndex; } -void iron_gpu_raytrace_acceleration_structure_init(iron_gpu_raytrace_acceleration_structure_t *accel) { +void gpu_raytrace_acceleration_structure_init(gpu_raytrace_acceleration_structure_t *accel) { vb_count = 0; instances_count = 0; } -void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_buffer_t *_vb, iron_gpu_buffer_t *_ib, +void gpu_raytrace_acceleration_structure_add(gpu_raytrace_acceleration_structure_t *accel, gpu_buffer_t *_vb, gpu_buffer_t *_ib, iron_matrix4x4_t _transform) { int vb_i = -1; @@ -2142,17 +1996,17 @@ void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration instances_count++; } -void _iron_gpu_raytrace_acceleration_structure_destroy_bottom(iron_gpu_raytrace_acceleration_structure_t *accel) { +void _gpu_raytrace_acceleration_structure_destroy_bottom(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_gpu_raytrace_acceleration_structure_destroy_top(iron_gpu_raytrace_acceleration_structure_t *accel) { +void _gpu_raytrace_acceleration_structure_destroy_top(gpu_raytrace_acceleration_structure_t *accel) { accel->impl.top_level_accel->lpVtbl->Release(accel->impl.top_level_accel); } -void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_buffer_t *_vb_full, iron_gpu_buffer_t *_ib_full) { +void gpu_raytrace_acceleration_structure_build(gpu_raytrace_acceleration_structure_t *accel, gpu_buffer_t *_vb_full, gpu_buffer_t *_ib_full) { bool build_bottom = false; for (int i = 0; i < 16; ++i) { @@ -2164,9 +2018,9 @@ void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_accelerati if (vb_count_last > 0) { if (build_bottom) { - _iron_gpu_raytrace_acceleration_structure_destroy_bottom(accel); + _gpu_raytrace_acceleration_structure_destroy_bottom(accel); } - _iron_gpu_raytrace_acceleration_structure_destroy_top(accel); + _gpu_raytrace_acceleration_structure_destroy_top(accel); } vb_count_last = vb_count; @@ -2175,18 +2029,18 @@ void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_accelerati return; } - descriptorsAllocated = 1; // 1 descriptor already allocated in iron_gpu_raytrace_pipeline_init + descriptorsAllocated = 1; // 1 descriptor already allocated in gpu_raytrace_pipeline_init #ifdef is_forge create_srv_ib(_ib_full, _ib_full->impl.count, 0); - create_srv_vb(_vb_full, _vb_full->count, vb[0]->impl.myStride); + create_srv_vb(_vb_full, _vb_full->count, vb[0]->impl.stride); #else create_srv_ib(ib[0], ib[0]->impl.count, 0); - create_srv_vb(vb[0], vb[0]->count, vb[0]->impl.myStride); + create_srv_vb(vb[0], vb[0]->count, vb[0]->impl.stride); #endif // Reset the command list for the acceleration structure construction - _commandList->lpVtbl->Reset(_commandList, _commandAllocator, NULL); + command_list->lpVtbl->Reset(command_list, command_allocator, NULL); // Get required sizes for an acceleration structure D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS topLevelInputs = { @@ -2217,9 +2071,9 @@ void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_accelerati }; D3D12_RESOURCE_DESC desc; - vb[i]->impl.uploadBuffer->lpVtbl->GetDesc(vb[i]->impl.uploadBuffer, &desc); + vb[i]->impl.upload_buffer->lpVtbl->GetDesc(vb[i]->impl.upload_buffer, &desc); - geometryDesc.Triangles.VertexBuffer.StartAddress = vb[i]->impl.uploadBuffer->lpVtbl->GetGPUVirtualAddress(vb[i]->impl.uploadBuffer); + geometryDesc.Triangles.VertexBuffer.StartAddress = vb[i]->impl.upload_buffer->lpVtbl->GetGPUVirtualAddress(vb[i]->impl.upload_buffer); geometryDesc.Triangles.VertexBuffer.StrideInBytes = desc.Width / vb[i]->count; geometryDesc.Flags = D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE; geometryDescs[i] = geometryDesc; @@ -2396,21 +2250,21 @@ void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_accelerati .Type = D3D12_RESOURCE_BARRIER_TYPE_UAV, .UAV.pResource = accel->impl.bottom_level_accel[0], }; - _commandList->lpVtbl->ResourceBarrier(_commandList, 1, &barrier); + command_list->lpVtbl->ResourceBarrier(command_list, 1, &barrier); dxrCommandList->lpVtbl->BuildRaytracingAccelerationStructure(dxrCommandList, &topLevelBuildDesc, 0, NULL); - // iron_gpu_wait(); + // gpu_wait(); scratchResource->lpVtbl->Release(scratchResource); instanceDescs->lpVtbl->Release(instanceDescs); } -void iron_gpu_raytrace_acceleration_structure_destroy(iron_gpu_raytrace_acceleration_structure_t *accel) { +void gpu_raytrace_acceleration_structure_destroy(gpu_raytrace_acceleration_structure_t *accel) { // accel->impl.bottom_level_accel->Release(); // accel->impl.top_level_accel->Release(); } -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) { +void gpu_raytrace_set_textures(gpu_texture_t *texpaint0, gpu_texture_t *texpaint1, gpu_texture_t *texpaint2, gpu_texture_t *texenv, gpu_texture_t *texsobol, gpu_texture_t *texscramble, gpu_texture_t *texrank) { D3D12_CPU_DESCRIPTOR_HANDLE handle; descriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptorHeap, &handle); @@ -2418,7 +2272,7 @@ void iron_gpu_raytrace_set_textures(iron_gpu_texture_t *texpaint0, iron_gpu_text cpuDescriptor.ptr = handle.ptr + 5 * (UINT64)(descriptorSize); D3D12_CPU_DESCRIPTOR_HANDLE sourceCpu; - texpaint0->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texpaint0->impl.srvDescriptorHeap, &sourceCpu); + texpaint0->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texpaint0->impl.srv_descriptor_heap, &sourceCpu); device->lpVtbl->CopyDescriptorsSimple(device, 1, cpuDescriptor, sourceCpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); D3D12_GPU_DESCRIPTOR_HANDLE ghandle; @@ -2427,62 +2281,62 @@ void iron_gpu_raytrace_set_textures(iron_gpu_texture_t *texpaint0, iron_gpu_text descriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptorHeap, &handle); cpuDescriptor.ptr = handle.ptr + 6 * (UINT64)(descriptorSize); - texpaint1->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texpaint1->impl.srvDescriptorHeap, &sourceCpu); + texpaint1->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texpaint1->impl.srv_descriptor_heap, &sourceCpu); device->lpVtbl->CopyDescriptorsSimple(device, 1, cpuDescriptor, sourceCpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); descriptorHeap->lpVtbl->GetGPUDescriptorHandleForHeapStart(descriptorHeap, &ghandle); tex1gpuDescriptorHandle.ptr = ghandle.ptr + 6 * (UINT64)(descriptorSize); descriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptorHeap, &handle); cpuDescriptor.ptr = handle.ptr + 7 * (UINT64)(descriptorSize); - texpaint2->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texpaint2->impl.srvDescriptorHeap, &sourceCpu); + texpaint2->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texpaint2->impl.srv_descriptor_heap, &sourceCpu); device->lpVtbl->CopyDescriptorsSimple(device, 1, cpuDescriptor, sourceCpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); descriptorHeap->lpVtbl->GetGPUDescriptorHandleForHeapStart(descriptorHeap, &ghandle); tex2gpuDescriptorHandle.ptr = ghandle.ptr + 7 * (UINT64)(descriptorSize); descriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptorHeap, &handle); cpuDescriptor.ptr = handle.ptr + 8 * (UINT64)(descriptorSize); - texenv->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texenv->impl.srvDescriptorHeap, &sourceCpu); + texenv->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texenv->impl.srv_descriptor_heap, &sourceCpu); device->lpVtbl->CopyDescriptorsSimple(device, 1, cpuDescriptor, sourceCpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); descriptorHeap->lpVtbl->GetGPUDescriptorHandleForHeapStart(descriptorHeap, &ghandle); texenvgpuDescriptorHandle.ptr = ghandle.ptr + 8 * (UINT64)(descriptorSize); descriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptorHeap, &handle); cpuDescriptor.ptr = handle.ptr + 9 * (UINT64)(descriptorSize); - texsobol->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texsobol->impl.srvDescriptorHeap, &sourceCpu); + texsobol->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texsobol->impl.srv_descriptor_heap, &sourceCpu); device->lpVtbl->CopyDescriptorsSimple(device, 1, cpuDescriptor, sourceCpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); descriptorHeap->lpVtbl->GetGPUDescriptorHandleForHeapStart(descriptorHeap, &ghandle); texsobolgpuDescriptorHandle.ptr = ghandle.ptr + 9 * (UINT64)(descriptorSize); descriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptorHeap, &handle); cpuDescriptor.ptr = handle.ptr + 10 * (UINT64)(descriptorSize); - texscramble->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texscramble->impl.srvDescriptorHeap , &sourceCpu); + texscramble->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texscramble->impl.srv_descriptor_heap , &sourceCpu); device->lpVtbl->CopyDescriptorsSimple(device, 1, cpuDescriptor, sourceCpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); descriptorHeap->lpVtbl->GetGPUDescriptorHandleForHeapStart(descriptorHeap, &ghandle); texscramblegpuDescriptorHandle.ptr = ghandle.ptr + 10 * (UINT64)(descriptorSize); descriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptorHeap, &handle); cpuDescriptor.ptr = handle.ptr + 11 * (UINT64)(descriptorSize); - texrank->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texrank->impl.srvDescriptorHeap , &sourceCpu); + texrank->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(texrank->impl.srv_descriptor_heap , &sourceCpu); device->lpVtbl->CopyDescriptorsSimple(device, 1, cpuDescriptor, sourceCpu, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); descriptorHeap->lpVtbl->GetGPUDescriptorHandleForHeapStart(descriptorHeap, &ghandle); texrankgpuDescriptorHandle.ptr = ghandle.ptr + 11 * (UINT64)(descriptorSize); } -void iron_gpu_raytrace_set_acceleration_structure(iron_gpu_raytrace_acceleration_structure_t *_accel) { +void gpu_raytrace_set_acceleration_structure(gpu_raytrace_acceleration_structure_t *_accel) { accel = _accel; } -void iron_gpu_raytrace_set_pipeline(iron_gpu_raytrace_pipeline_t *_pipeline) { +void gpu_raytrace_set_pipeline(gpu_raytrace_pipeline_t *_pipeline) { pipeline = _pipeline; } -void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { +void gpu_raytrace_set_target(gpu_texture_t *_output) { if (_output != output) { - _output->impl.renderTarget->lpVtbl->Release(_output->impl.renderTarget); - _output->impl.renderTargetDescriptorHeap->lpVtbl->Release(_output->impl.renderTargetDescriptorHeap); - _output->impl.srvDescriptorHeap->lpVtbl->Release(_output->impl.srvDescriptorHeap); + _output->impl.render_target->lpVtbl->Release(_output->impl.render_target); + _output->impl.descriptor_heap->lpVtbl->Release(_output->impl.descriptor_heap); + _output->impl.srv_descriptor_heap->lpVtbl->Release(_output->impl.srv_descriptor_heap); - D3D12_HEAP_PROPERTIES heapProperties = { + D3D12_HEAP_PROPERTIES heap_properties = { .Type = D3D12_HEAP_TYPE_DEFAULT, .CreationNodeMask = 1, .VisibleNodeMask = 1, @@ -2499,15 +2353,15 @@ void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { .Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, .Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, }; - D3D12_CLEAR_VALUE clearValue; - clearValue.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; - clearValue.Color[0] = 0.0f; - clearValue.Color[1] = 0.0f; - clearValue.Color[2] = 0.0f; - clearValue.Color[3] = 1.0f; + D3D12_CLEAR_VALUE clear_value; + clear_value.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; + clear_value.Color[0] = 0.0f; + clear_value.Color[1] = 0.0f; + clear_value.Color[2] = 0.0f; + clear_value.Color[3] = 1.0f; - device->lpVtbl->CreateCommittedResource(device, &heapProperties, D3D12_HEAP_FLAG_NONE, &desc, - D3D12_RESOURCE_STATE_COMMON, &clearValue, &IID_ID3D12Resource, &_output->impl.renderTarget); + device->lpVtbl->CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &desc, + D3D12_RESOURCE_STATE_COMMON, &clear_value, &IID_ID3D12Resource, &_output->impl.render_target); D3D12_RENDER_TARGET_VIEW_DESC view = { .Format = DXGI_FORMAT_R16G16B16A16_FLOAT, @@ -2520,20 +2374,20 @@ void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { .Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE, }; - device->lpVtbl->CreateDescriptorHeap(device, &heap_desc, &IID_ID3D12DescriptorHeap, &_output->impl.renderTargetDescriptorHeap); + device->lpVtbl->CreateDescriptorHeap(device, &heap_desc, &IID_ID3D12DescriptorHeap, &_output->impl.descriptor_heap); D3D12_CPU_DESCRIPTOR_HANDLE handle; - _output->impl.renderTargetDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(_output->impl.renderTargetDescriptorHeap, &handle); - device->lpVtbl->CreateRenderTargetView(device, _output->impl.renderTarget, &view, handle); + _output->impl.descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(_output->impl.descriptor_heap, &handle); + device->lpVtbl->CreateRenderTargetView(device, _output->impl.render_target, &view, handle); - D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = { + D3D12_DESCRIPTOR_HEAP_DESC descriptor_heap_desc = { .NumDescriptors = 1, .Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, .NodeMask = 0, .Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE, }; - device->lpVtbl->CreateDescriptorHeap(device, &descriptorHeapDesc, &IID_ID3D12DescriptorHeap, &_output->impl.srvDescriptorHeap); + device->lpVtbl->CreateDescriptorHeap(device, &descriptor_heap_desc, &IID_ID3D12DescriptorHeap, &_output->impl.srv_descriptor_heap); - D3D12_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc = { + D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = { .ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D, .Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, .Format = DXGI_FORMAT_R16G16B16A16_FLOAT, @@ -2541,35 +2395,35 @@ void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { .Texture2D.MostDetailedMip = 0, .Texture2D.ResourceMinLODClamp = 0.0f, }; - _output->impl.srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(_output->impl.srvDescriptorHeap, &handle); - device->lpVtbl->CreateShaderResourceView(device, _output->impl.renderTarget, &shaderResourceViewDesc, + _output->impl.srv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(_output->impl.srv_descriptor_heap, &handle); + device->lpVtbl->CreateShaderResourceView(device, _output->impl.render_target, &srv_desc, handle); D3D12_UNORDERED_ACCESS_VIEW_DESC UAVDesc = { .ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D, }; - device->lpVtbl->CreateUnorderedAccessView(device, _output->impl.renderTarget, NULL, &UAVDesc, outputCpuDescriptor); + device->lpVtbl->CreateUnorderedAccessView(device, _output->impl.render_target, NULL, &UAVDesc, outputCpuDescriptor); } output = _output; } -void iron_gpu_raytrace_dispatch_rays() { - _commandList->lpVtbl->SetComputeRootSignature(_commandList, dxrRootSignature); +void gpu_raytrace_dispatch_rays() { + command_list->lpVtbl->SetComputeRootSignature(command_list, dxrRootSignature); // Bind the heaps, acceleration structure and dispatch rays - _commandList->lpVtbl->SetDescriptorHeaps(_commandList, 1, &descriptorHeap); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 0, outputDescriptorHandle); - _commandList->lpVtbl->SetComputeRootShaderResourceView(_commandList, 1, accel->impl.top_level_accel->lpVtbl->GetGPUVirtualAddress(accel->impl.top_level_accel)); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 2, ibgpuDescriptorHandle); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 3, vbgpuDescriptorHandle); - _commandList->lpVtbl->SetComputeRootConstantBufferView(_commandList, 4, pipeline->_constant_buffer->impl.constant_buffer->lpVtbl->GetGPUVirtualAddress(pipeline->_constant_buffer->impl.constant_buffer)); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 5, tex0gpuDescriptorHandle); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 6, tex1gpuDescriptorHandle); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 7, tex2gpuDescriptorHandle); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 8, texenvgpuDescriptorHandle); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 9, texsobolgpuDescriptorHandle); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 10, texscramblegpuDescriptorHandle); - _commandList->lpVtbl->SetComputeRootDescriptorTable(_commandList, 11, texrankgpuDescriptorHandle); + command_list->lpVtbl->SetDescriptorHeaps(command_list, 1, &descriptorHeap); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 0, outputDescriptorHandle); + command_list->lpVtbl->SetComputeRootShaderResourceView(command_list, 1, accel->impl.top_level_accel->lpVtbl->GetGPUVirtualAddress(accel->impl.top_level_accel)); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 2, ibgpuDescriptorHandle); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 3, vbgpuDescriptorHandle); + command_list->lpVtbl->SetComputeRootConstantBufferView(command_list, 4, pipeline->_constant_buffer->impl.buffer->lpVtbl->GetGPUVirtualAddress(pipeline->_constant_buffer->impl.buffer)); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 5, tex0gpuDescriptorHandle); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 6, tex1gpuDescriptorHandle); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 7, tex2gpuDescriptorHandle); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 8, texenvgpuDescriptorHandle); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 9, texsobolgpuDescriptorHandle); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 10, texscramblegpuDescriptorHandle); + command_list->lpVtbl->SetComputeRootDescriptorTable(command_list, 11, texrankgpuDescriptorHandle); // Since each shader table has only one shader record, the stride is same as the size. D3D12_DISPATCH_RAYS_DESC dispatchDesc = {0}; diff --git a/base/sources/backends/direct3d12_gpu.h b/base/sources/backends/direct3d12_gpu.h index f166d8d1..b738b44f 100644 --- a/base/sources/backends/direct3d12_gpu.h +++ b/base/sources/backends/direct3d12_gpu.h @@ -3,12 +3,11 @@ #include #include -#define IRON_INTERNAL_G5_TEXTURE_COUNT 16 - struct ID3D12Resource; struct ID3D12DescriptorHeap; struct ID3D12PipelineState; struct ID3D12StateObject; +enum D3D12_RESOURCE_STATES; typedef void *HANDLE; typedef unsigned __int64 UINT64; @@ -29,25 +28,22 @@ struct D3D12Rect { long bottom; }; +struct D3D12VertexBufferView { + __int64 BufferLocation; + unsigned int SizeInBytes; + unsigned int StrideInBytes; +}; + +struct D3D12IndexBufferView { + __int64 BufferLocation; + unsigned int SizeInBytes; + int Format; +}; + typedef struct { struct ID3D12PipelineState *pso; } gpu_pipeline_impl_t; -typedef struct { - char name[64]; - uint32_t offset; -} ShaderConstant; - -typedef struct { - char name[64]; - int attribute; -} ShaderAttribute; - -typedef struct { - char name[64]; - int texture; -} ShaderTexture; - typedef struct { void *shader; uint8_t *data; @@ -60,46 +56,28 @@ typedef struct { int stage_depth; int stride; struct ID3D12Resource *image; - struct ID3D12Resource *uploadImage; - struct ID3D12DescriptorHeap *srvDescriptorHeap; - struct ID3D12Resource *renderTarget; - struct ID3D12Resource *renderTargetReadback; - struct ID3D12DescriptorHeap *renderTargetDescriptorHeap; - struct ID3D12DescriptorHeap *depthDescriptorHeap; - struct ID3D12DescriptorHeap *srvDepthDescriptorHeap; - struct ID3D12Resource *depthTexture; + struct ID3D12Resource *upload_image; + struct ID3D12DescriptorHeap *srv_descriptor_heap; + struct ID3D12Resource *render_target; + struct ID3D12Resource *readback; + struct ID3D12DescriptorHeap *descriptor_heap; + struct ID3D12DescriptorHeap *depth_descriptor_heap; + struct ID3D12DescriptorHeap *srv_depth_descriptor_heap; + struct ID3D12Resource *depth_texture; struct D3D12Viewport viewport; struct D3D12Rect scissor; - int framebuffer_index; + enum D3D12_RESOURCE_STATES state; } gpu_texture_impl_t; -struct D3D12VertexBufferView { - __int64 BufferLocation; - unsigned int SizeInBytes; - unsigned int StrideInBytes; -}; - -struct D3D12IindexBufferView { - __int64 BufferLocation; - unsigned int SizeInBytes; - int Format; -}; - typedef struct { - struct ID3D12Resource *uploadBuffer; - struct D3D12VertexBufferView view; - int myStride; - int lastStart; - int lastCount; - struct ID3D12Resource *index_buffer; - struct D3D12IindexBufferView index_buffer_view; + struct ID3D12Resource *buffer; struct ID3D12Resource *upload_buffer; + struct D3D12VertexBufferView vertex_buffer_view; + struct D3D12IndexBufferView index_buffer_view; + int stride; int count; - bool gpu_memory; int last_start; int last_count; - struct ID3D12Resource *constant_buffer; - int mySize; } gpu_buffer_impl_t; typedef struct { diff --git a/base/sources/backends/ios_system.h b/base/sources/backends/ios_system.h index db093de3..ff411b03 100644 --- a/base/sources/backends/ios_system.h +++ b/base/sources/backends/ios_system.h @@ -4,7 +4,7 @@ #import #import -struct iron_gpu_texture; +struct gpu_texture; @interface GLView : UIView { @private diff --git a/base/sources/backends/linux_system.c b/base/sources/backends/linux_system.c index ce1b2985..5a6bc7d3 100644 --- a/base/sources/backends/linux_system.c +++ b/base/sources/backends/linux_system.c @@ -473,7 +473,7 @@ static char *clipboardString = NULL; char buffer[1024]; -void iron_gpu_internal_resize(int width, int height); +void gpu_internal_resize(int width, int height); static void init_pen_device(XDeviceInfo *info, struct x11_pen_device *pen, bool eraser); static void load_lib(void **lib, const char *name) { @@ -1198,7 +1198,7 @@ static bool _handle_messages() { if (event.xconfigure.width != k_window->width || event.xconfigure.height != k_window->height) { k_window->width = event.xconfigure.width; k_window->height = event.xconfigure.height; - iron_gpu_internal_resize(event.xconfigure.width, event.xconfigure.height); + gpu_internal_resize(event.xconfigure.width, event.xconfigure.height); iron_internal_call_resize_callback(event.xconfigure.width, event.xconfigure.height); } break; @@ -1454,7 +1454,7 @@ void iron_init(const char *name, int width, int height, iron_window_options_t *w } void iron_internal_shutdown() { - iron_gpu_destroy(); + gpu_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 bc9a1bab..1367550c 100644 --- a/base/sources/backends/linux_video.c +++ b/base/sources/backends/linux_video.c @@ -18,7 +18,7 @@ // return 256; // } -// iron_gpu_texture_t *iron_video_current_image(iron_video_t *video) { +// 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 e523abef..881edc8b 100644 --- a/base/sources/backends/macos_system.h +++ b/base/sources/backends/macos_system.h @@ -8,7 +8,7 @@ #include #include -struct iron_gpu_texture; +struct gpu_texture; @interface BasicOpenGLView : MTKView { @private diff --git a/base/sources/backends/metal_gpu.h b/base/sources/backends/metal_gpu.h index b3bcb012..c04417d4 100644 --- a/base/sources/backends/metal_gpu.h +++ b/base/sources/backends/metal_gpu.h @@ -3,17 +3,17 @@ #include #include -struct iron_gpu_buffer; +struct gpu_buffer; typedef struct { - struct iron_gpu_buffer *current_index_buffer; + struct gpu_buffer *current_index_buffer; } gpu_command_list_impl_t; -struct iron_gpu_shader; +struct gpu_shader; typedef struct { - struct iron_gpu_shader *vertex_shader; - struct iron_gpu_shader *fragment_shader; + struct gpu_shader *vertex_shader; + struct gpu_shader *fragment_shader; void *_pipeline; void *_pipelineDepth; void *_reflection; diff --git a/base/sources/backends/metal_gpu.m b/base/sources/backends/metal_gpu.m index 9c32ed03..4e4489b4 100644 --- a/base/sources/backends/metal_gpu.m +++ b/base/sources/backends/metal_gpu.m @@ -12,7 +12,7 @@ id getMetalDevice(void); id getMetalQueue(void); extern int constant_buffer_index; -bool iron_gpu_transpose_mat = true; +bool gpu_transpose_mat = true; static id command_buffer = nil; static id command_encoder = nil; static id argument_encoder = nil; @@ -23,78 +23,78 @@ static id framebuffer_depth; static int depth_bits; static bool has_depth = false; static int framebuffer_count = 0; -static iron_gpu_texture_t *render_targets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +static gpu_texture_t *render_targets[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; typedef struct inst { iron_matrix4x4_t m; int i; } inst_t; -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_buffer_t *constant_buf; +static gpu_raytrace_acceleration_structure_t *accel; +static gpu_raytrace_pipeline_t *pipeline; +static gpu_texture_t *output = NULL; +static gpu_buffer_t *constant_buf; static id _raytracing_pipeline; static NSMutableArray *_primitive_accels; static id _instance_accel; static dispatch_semaphore_t _semaphore; -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_buffer_t *vb[16]; -static iron_gpu_buffer_t *vb_last[16]; -static iron_gpu_buffer_t *ib[16]; +static gpu_texture_t *_texpaint0; +static gpu_texture_t *_texpaint1; +static gpu_texture_t *_texpaint2; +static gpu_texture_t *_texenv; +static gpu_texture_t *_texsobol; +static gpu_texture_t *_texscramble; +static gpu_texture_t *_texrank; +static gpu_buffer_t *vb[16]; +static gpu_buffer_t *vb_last[16]; +static gpu_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; -static MTLBlendFactor convert_blending_factor(iron_gpu_blending_factor_t factor) { +static MTLBlendFactor convert_blending_factor(gpu_blending_factor_t factor) { switch (factor) { - case IRON_GPU_BLEND_ONE: + case GPU_BLEND_ONE: return MTLBlendFactorOne; - case IRON_GPU_BLEND_ZERO: + case GPU_BLEND_ZERO: return MTLBlendFactorZero; - case IRON_GPU_BLEND_SOURCE_ALPHA: + case GPU_BLEND_SOURCE_ALPHA: return MTLBlendFactorSourceAlpha; - case IRON_GPU_BLEND_DEST_ALPHA: + case GPU_BLEND_DEST_ALPHA: return MTLBlendFactorDestinationAlpha; - case IRON_GPU_BLEND_INV_SOURCE_ALPHA: + case GPU_BLEND_INV_SOURCE_ALPHA: return MTLBlendFactorOneMinusSourceAlpha; - case IRON_GPU_BLEND_INV_DEST_ALPHA: + case GPU_BLEND_INV_DEST_ALPHA: return MTLBlendFactorOneMinusDestinationAlpha; } } -static MTLBlendOperation convert_blending_operation(iron_gpu_blending_operation_t op) { +static MTLBlendOperation convert_blending_operation(gpu_blending_operation_t op) { switch (op) { - case IRON_GPU_BLENDOP_ADD: + case GPU_BLENDOP_ADD: return MTLBlendOperationAdd; } } -static MTLCompareFunction convert_compare_mode(iron_gpu_compare_mode_t compare) { +static MTLCompareFunction convert_compare_mode(gpu_compare_mode_t compare) { switch (compare) { - case IRON_GPU_COMPARE_MODE_ALWAYS: + case GPU_COMPARE_MODE_ALWAYS: return MTLCompareFunctionAlways; - case IRON_GPU_COMPARE_MODE_NEVER: + case GPU_COMPARE_MODE_NEVER: return MTLCompareFunctionNever; - case IRON_GPU_COMPARE_MODE_LESS: + case GPU_COMPARE_MODE_LESS: return MTLCompareFunctionLess; } } -static MTLCullMode convert_cull_mode(iron_gpu_cull_mode_t cull) { +static MTLCullMode convert_cull_mode(gpu_cull_mode_t cull) { switch (cull) { - case IRON_GPU_CULL_MODE_CLOCKWISE: + case GPU_CULL_MODE_CLOCKWISE: return MTLCullModeFront; - case IRON_GPU_CULL_MODE_COUNTERCLOCKWISE: + case GPU_CULL_MODE_COUNTERCLOCKWISE: return MTLCullModeBack; - case IRON_GPU_CULL_MODE_NEVER: + case GPU_CULL_MODE_NEVER: return MTLCullModeNone; } } @@ -166,16 +166,16 @@ static int formatByteSize(iron_image_format_t format) { } } -void iron_gpu_destroy(void) { +void gpu_destroy(void) { } -void iron_gpu_internal_resize(int width, int height) { +void gpu_internal_resize(int width, int height) { } id linear_sampler; -void iron_gpu_init(int depth_buffer_bits, bool vsync) { +void gpu_init_internal(int depth_buffer_bits, bool vsync) { depth_bits = depth_buffer_bits; id device = getMetalDevice(); @@ -247,7 +247,7 @@ void iron_gpu_init(int depth_buffer_bits, bool vsync) { argument_buffer = [device newBufferWithLength:(argument_buffer_step * 2048) options:MTLResourceStorageModeShared]; } -void iron_gpu_begin(iron_gpu_texture_t *target) { +void gpu_begin(gpu_texture_t *target) { CAMetalLayer *layer = getMetalLayer(); drawable = [layer nextDrawable]; @@ -271,7 +271,7 @@ void iron_gpu_begin(iron_gpu_texture_t *target) { has_depth = (depth_bits > 0 && framebuffer_depth != nil); } -void iron_gpu_end() { +void gpu_end() { [command_encoder endEncoding]; [command_buffer presentDrawable:drawable]; [command_buffer commit]; @@ -282,33 +282,33 @@ void iron_gpu_end() { command_encoder = nil; } -int iron_gpu_max_bound_textures(void) { +int gpu_max_bound_textures(void) { return 16; } -void iron_gpu_command_list_init(iron_gpu_command_list_t *list) { +void gpu_command_list_init(gpu_command_list_t *list) { } -void iron_gpu_command_list_destroy(iron_gpu_command_list_t *list) { +void gpu_command_list_destroy(gpu_command_list_t *list) { } -void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { +void gpu_command_list_begin(gpu_command_list_t *list) { render_targets[0] = NULL; } -void iron_gpu_command_list_end(iron_gpu_command_list_t *list) { +void gpu_command_list_end(gpu_command_list_t *list) { } -void iron_gpu_command_list_draw(iron_gpu_command_list_t *list) { +void gpu_command_list_draw(gpu_command_list_t *list) { id indexBuffer = (__bridge id)list->impl.current_index_buffer->impl.metal_buffer; [command_encoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle - indexCount:iron_gpu_index_buffer_count(list->impl.current_index_buffer) + indexCount:gpu_index_buffer_count(list->impl.current_index_buffer) indexType:MTLIndexTypeUInt32 indexBuffer:indexBuffer indexBufferOffset:0]; } -void iron_gpu_command_list_viewport(iron_gpu_command_list_t *list, int x, int y, int width, int height) { +void gpu_command_list_viewport(gpu_command_list_t *list, int x, int y, int width, int height) { MTLViewport viewport; viewport.originX = x; viewport.originY = y; @@ -319,7 +319,7 @@ void iron_gpu_command_list_viewport(iron_gpu_command_list_t *list, int x, int y, [command_encoder setViewport:viewport]; } -void iron_gpu_command_list_scissor(iron_gpu_command_list_t *list, int x, int y, int width, int height) { +void gpu_command_list_scissor(gpu_command_list_t *list, int x, int y, int width, int height) { MTLScissorRect scissor; scissor.x = x; scissor.y = y; @@ -338,7 +338,7 @@ void iron_gpu_command_list_scissor(iron_gpu_command_list_t *list, int x, int y, [command_encoder setScissorRect:scissor]; } -void iron_gpu_command_list_disable_scissor(iron_gpu_command_list_t *list) { +void gpu_command_list_disable_scissor(gpu_command_list_t *list) { MTLScissorRect scissor; scissor.x = 0; scissor.y = 0; @@ -353,7 +353,7 @@ void iron_gpu_command_list_disable_scissor(iron_gpu_command_list_t *list) { [command_encoder setScissorRect:scissor]; } -void iron_gpu_command_list_set_pipeline(iron_gpu_command_list_t *list, iron_gpu_pipeline_t *pipeline) { +void gpu_command_list_set_pipeline(gpu_command_list_t *list, gpu_pipeline_t *pipeline) { if (has_depth) { id pipe = (__bridge id)pipeline->impl._pipelineDepth; [command_encoder setRenderPipelineState:pipe]; @@ -370,16 +370,16 @@ void iron_gpu_command_list_set_pipeline(iron_gpu_command_list_t *list, iron_gpu_ [command_encoder setCullMode:convert_cull_mode(pipeline->cull_mode)]; } -void iron_gpu_command_list_set_vertex_buffer(iron_gpu_command_list_t *list, iron_gpu_buffer_t *buf) { +void gpu_command_list_set_vertex_buffer(gpu_command_list_t *list, gpu_buffer_t *buf) { id buffer = (__bridge id)buf->impl.metal_buffer; [command_encoder setVertexBuffer:buffer offset:0 atIndex:0]; } -void iron_gpu_command_list_set_index_buffer(iron_gpu_command_list_t *list, iron_gpu_buffer_t *buffer) { +void gpu_command_list_set_index_buffer(gpu_command_list_t *list, gpu_buffer_t *buffer) { list->impl.current_index_buffer = buffer; } -void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, iron_gpu_texture_t **targets, int count, unsigned flags, unsigned color, float depth) { +void gpu_command_list_set_render_targets(gpu_command_list_t *list, gpu_texture_t **targets, int count, unsigned flags, unsigned color, float depth) { if (command_buffer != nil && command_encoder != nil) { [command_encoder endEncoding]; [command_buffer commit]; @@ -411,7 +411,7 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, iro desc.depthAttachment.texture = (__bridge id)targets[0]->impl._depthTex; has_depth = targets[0]->impl._depthTex != nil; } - if (flags & IRON_GPU_CLEAR_COLOR) { + if (flags & GPU_CLEAR_COLOR) { float red, green, blue, alpha; iron_color_components(color, &red, &green, &blue, &alpha); desc.colorAttachments[i].loadAction = MTLLoadActionClear; @@ -425,7 +425,7 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, iro } } - if (flags & IRON_GPU_CLEAR_DEPTH) { + if (flags & GPU_CLEAR_DEPTH) { desc.depthAttachment.clearDepth = depth; desc.depthAttachment.loadAction = MTLLoadActionClear; desc.depthAttachment.storeAction = MTLStoreActionStore; @@ -441,16 +441,16 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, iro command_encoder = [command_buffer renderCommandEncoderWithDescriptor:desc]; } -void iron_gpu_command_list_upload_index_buffer(iron_gpu_command_list_t *list, iron_gpu_buffer_t *buffer) { +void gpu_command_list_upload_index_buffer(gpu_command_list_t *list, gpu_buffer_t *buffer) { } -void iron_gpu_command_list_upload_vertex_buffer(iron_gpu_command_list_t *list, iron_gpu_buffer_t *buffer) { +void gpu_command_list_upload_vertex_buffer(gpu_command_list_t *list, gpu_buffer_t *buffer) { } -void iron_gpu_command_list_upload_texture(iron_gpu_command_list_t *list, iron_gpu_texture_t *texture) { +void gpu_command_list_upload_texture(gpu_command_list_t *list, gpu_texture_t *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 gpu_command_list_get_render_target_pixels(gpu_command_list_t *list, gpu_texture_t *render_target, uint8_t *data) { // Create readback buffer if (render_target->impl._texReadback == NULL) { id device = getMetalDevice(); @@ -491,11 +491,11 @@ void iron_gpu_command_list_get_render_target_pixels(iron_gpu_command_list_t *lis [tex getBytes:data bytesPerRow:formatByteSize * render_target->width fromRegion:region mipmapLevel:0]; } -void iron_gpu_command_list_wait(iron_gpu_command_list_t *list) { +void gpu_command_list_wait(gpu_command_list_t *list) { } -void iron_gpu_command_list_set_constant_buffer(iron_gpu_command_list_t *list, iron_gpu_buffer_t *buffer, int offset, size_t size) { +void gpu_command_list_set_constant_buffer(gpu_command_list_t *list, gpu_buffer_t *buffer, int offset, size_t size) { id buf = (__bridge id)buffer->impl._buffer; int i = constant_buffer_index; [argument_encoder setArgumentBuffer:argument_buffer offset:argument_buffer_step * i]; @@ -506,7 +506,7 @@ void iron_gpu_command_list_set_constant_buffer(iron_gpu_command_list_t *list, ir [command_encoder useResource:buf usage:MTLResourceUsageRead stages:MTLRenderStageVertex|MTLRenderStageFragment]; } -void iron_gpu_command_list_set_texture(iron_gpu_command_list_t *list, int unit, iron_gpu_texture_t *texture) { +void gpu_command_list_set_texture(gpu_command_list_t *list, int unit, gpu_texture_t *texture) { id tex = (__bridge id)texture->impl._tex; int i = constant_buffer_index; [argument_encoder setArgumentBuffer:argument_buffer offset:argument_buffer_step * i]; @@ -514,7 +514,7 @@ void iron_gpu_command_list_set_texture(iron_gpu_command_list_t *list, int unit, [command_encoder useResource:tex usage:MTLResourceUsageRead stages:MTLRenderStageVertex|MTLRenderStageFragment]; } -void iron_gpu_set_texture_depth(iron_gpu_command_list_t *list, int unit, iron_gpu_texture_t *target) { +void gpu_set_texture_depth(gpu_command_list_t *list, int unit, gpu_texture_t *target) { id depth_tex = (__bridge id)target->impl._depthTex; int i = constant_buffer_index; [argument_encoder setArgumentBuffer:argument_buffer offset:argument_buffer_step * i]; @@ -522,12 +522,12 @@ void iron_gpu_set_texture_depth(iron_gpu_command_list_t *list, int unit, iron_gp [command_encoder useResource:depth_tex usage:MTLResourceUsageRead stages:MTLRenderStageVertex|MTLRenderStageFragment]; } -void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipeline) { +void gpu_pipeline_init(gpu_pipeline_t *pipeline) { memset(&pipeline->impl, 0, sizeof(pipeline->impl)); gpu_internal_pipeline_init(pipeline); } -void iron_gpu_pipeline_destroy(iron_gpu_pipeline_t *pipeline) { +void gpu_pipeline_destroy(gpu_pipeline_t *pipeline) { id pipe = (__bridge_transfer id)pipeline->impl._pipeline; pipe = nil; pipeline->impl._pipeline = NULL; @@ -545,7 +545,7 @@ void iron_gpu_pipeline_destroy(iron_gpu_pipeline_t *pipeline) { pipeline->impl._depthStencilNone = NULL; } -void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { +void gpu_pipeline_compile(gpu_pipeline_t *pipeline) { id device = getMetalDevice(); NSError *error = nil; id library = [device newLibraryWithSource:[[NSString alloc] initWithBytes:pipeline->vertex_shader->impl.source length:pipeline->vertex_shader->impl.length encoding:NSUTF8StringEncoding] options:nil error:&error]; @@ -566,8 +566,8 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { 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_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; + pipeline->blend_source != GPU_BLEND_ONE || pipeline->blend_destination != GPU_BLEND_ZERO || + pipeline->alpha_blend_source != GPU_BLEND_ONE || pipeline->alpha_blend_destination != 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); @@ -588,25 +588,25 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { for (int i = 0; i < pipeline->input_layout->size; ++i) { vertexDescriptor.attributes[i].bufferIndex = 0; vertexDescriptor.attributes[i].offset = offset; - offset += iron_gpu_vertex_data_size(pipeline->input_layout->elements[i].data); + offset += gpu_vertex_data_size(pipeline->input_layout->elements[i].data); switch (pipeline->input_layout->elements[i].data) { - case IRON_GPU_VERTEX_DATA_F32_1X: + case GPU_VERTEX_DATA_F32_1X: vertexDescriptor.attributes[i].format = MTLVertexFormatFloat; break; - case IRON_GPU_VERTEX_DATA_F32_2X: + case GPU_VERTEX_DATA_F32_2X: vertexDescriptor.attributes[i].format = MTLVertexFormatFloat2; break; - case IRON_GPU_VERTEX_DATA_F32_3X: + case GPU_VERTEX_DATA_F32_3X: vertexDescriptor.attributes[i].format = MTLVertexFormatFloat3; break; - case IRON_GPU_VERTEX_DATA_F32_4X: + case GPU_VERTEX_DATA_F32_4X: vertexDescriptor.attributes[i].format = MTLVertexFormatFloat4; break; - case IRON_GPU_VERTEX_DATA_I16_2X_NORM: + case GPU_VERTEX_DATA_I16_2X_NORM: vertexDescriptor.attributes[i].format = MTLVertexFormatShort2Normalized; break; - case IRON_GPU_VERTEX_DATA_I16_4X_NORM: + case GPU_VERTEX_DATA_I16_4X_NORM: vertexDescriptor.attributes[i].format = MTLVertexFormatShort4Normalized; break; } @@ -643,13 +643,13 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { pipeline->impl._depthStencilNone = (__bridge_retained void *)[device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; } -void iron_gpu_shader_destroy(iron_gpu_shader_t *shader) { +void gpu_shader_destroy(gpu_shader_t *shader) { id function = (__bridge_transfer id)shader->impl.mtlFunction; function = nil; shader->impl.mtlFunction = NULL; } -void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *data, size_t length, iron_gpu_shader_type_t type) { +void gpu_shader_init(gpu_shader_t *shader, const void *data, size_t length, gpu_shader_type_t type) { shader->impl.name[0] = 0; const char *source = data; @@ -665,7 +665,7 @@ void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *data, size_t le shader->impl.length = length; } -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_buffer_t *constant_buffer) { +void gpu_raytrace_pipeline_init(gpu_raytrace_pipeline_t *pipeline, gpu_command_list_t *command_list, void *ray_shader, int ray_shader_size, gpu_buffer_t *constant_buffer) { id device = getMetalDevice(); if (!device.supportsRaytracing) return; constant_buf = constant_buffer; @@ -685,10 +685,10 @@ void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, iro _semaphore = dispatch_semaphore_create(2); } -void iron_gpu_raytrace_pipeline_destroy(iron_gpu_raytrace_pipeline_t *pipeline) { +void gpu_raytrace_pipeline_destroy(gpu_raytrace_pipeline_t *pipeline) { } -static void create(iron_gpu_texture_t *texture, int width, int height, int format, bool writable) { +static void create(gpu_texture_t *texture, int width, int height, int format, bool writable) { texture->impl.has_mipmaps = false; id device = getMetalDevice(); @@ -711,7 +711,7 @@ static void create(iron_gpu_texture_t *texture, int width, int height, int forma texture->impl._tex = (__bridge_retained void *)[device newTextureWithDescriptor:descriptor]; } -void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format) { +void gpu_texture_init(gpu_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->format = format; @@ -723,7 +723,7 @@ void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, i texture->framebuffer_index = -1; } -void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { +void gpu_texture_init_from_bytes(gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->format = format; @@ -738,11 +738,11 @@ void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, i mipmapLevel:0 slice:0 withBytes:data - bytesPerRow:iron_gpu_texture_stride(texture) - bytesPerImage:iron_gpu_texture_stride(texture) * texture->height]; + bytesPerRow:gpu_texture_stride(texture) + bytesPerImage:gpu_texture_stride(texture) * texture->height]; } -void iron_gpu_texture_destroy(iron_gpu_texture_t *target) { +void gpu_texture_destroy(gpu_texture_t *target) { id tex = (__bridge_transfer id)target->impl._tex; tex = nil; target->impl._tex = NULL; @@ -765,7 +765,7 @@ void iron_gpu_texture_destroy(iron_gpu_texture_t *target) { } } -int iron_gpu_texture_stride(iron_gpu_texture_t *texture) { +int gpu_texture_stride(gpu_texture_t *texture) { switch (texture->format) { case IRON_IMAGE_FORMAT_R8: return texture->width; @@ -779,9 +779,9 @@ int iron_gpu_texture_stride(iron_gpu_texture_t *texture) { } } -void iron_gpu_texture_generate_mipmaps(iron_gpu_texture_t *texture, int levels) {} +void gpu_texture_generate_mipmaps(gpu_texture_t *texture, int levels) {} -void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t *mipmap, int level) { +void gpu_texture_set_mipmap(gpu_texture_t *texture, 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) @@ -831,8 +831,8 @@ void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t bytesPerRow:mipmap->width * formatByteSize(mipmap->format)]; } -static void render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_buffer_bits, int framebuffer_index) { - memset(target, 0, sizeof(iron_gpu_texture_t)); +static void render_target_init(gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_buffer_bits, int framebuffer_index) { + memset(target, 0, sizeof(gpu_texture_t)); target->width = width; target->height = height; target->data = NULL; @@ -870,7 +870,7 @@ static void render_target_init(iron_gpu_texture_t *target, int width, int height target->impl._texReadback = NULL; } -void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_buffer_bits) { +void gpu_render_target_init(gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_buffer_bits) { render_target_init(target, width, height, format, depth_buffer_bits, -1); target->width = target->width = width; target->height = target->height = height; @@ -878,22 +878,21 @@ void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int heig target->uploaded = true; } -void iron_gpu_render_target_init_framebuffer(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_buffer_bits) { +void gpu_render_target_init_framebuffer(gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_buffer_bits) { render_target_init(target, width, height, format, depth_buffer_bits, framebuffer_count); framebuffer_count += 1; } -void iron_gpu_render_target_set_depth_from(iron_gpu_texture_t *target, iron_gpu_texture_t *source) { +void gpu_render_target_set_depth_from(gpu_texture_t *target, gpu_texture_t *source) { target->impl._depthTex = source->impl._depthTex; } -void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, bool gpu_memory) { +void gpu_vertex_buffer_init(gpu_buffer_t *buffer, int count, gpu_vertex_structure_t *structure) { memset(&buffer->impl, 0, sizeof(buffer->impl)); buffer->count = count; - buffer->impl.gpu_memory = gpu_memory; for (int i = 0; i < structure->size; ++i) { - iron_gpu_vertex_element_t element = structure->elements[i]; - buffer->impl.myStride += iron_gpu_vertex_data_size(element.data); + gpu_vertex_element_t element = structure->elements[i]; + buffer->impl.myStride += gpu_vertex_data_size(element.data); } id device = getMetalDevice(); @@ -904,58 +903,57 @@ void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int count, iron_gpu_ buffer->impl.metal_buffer = (__bridge_retained void *)buf; } -void iron_gpu_vertex_buffer_destroy(iron_gpu_buffer_t *buf) { +void gpu_vertex_buffer_destroy(gpu_buffer_t *buf) { id buffer = (__bridge_transfer id)buf->impl.metal_buffer; buffer = nil; buf->impl.metal_buffer = NULL; } -float *iron_gpu_vertex_buffer_lock(iron_gpu_buffer_t *buf) { +float *gpu_vertex_buffer_lock(gpu_buffer_t *buf) { id buffer = (__bridge id)buf->impl.metal_buffer; float *floats = (float *)[buffer contents]; return floats; } -void iron_gpu_vertex_buffer_unlock(iron_gpu_buffer_t *buf) { +void gpu_vertex_buffer_unlock(gpu_buffer_t *buf) { } -int iron_gpu_vertex_buffer_count(iron_gpu_buffer_t *buffer) { +int gpu_vertex_buffer_count(gpu_buffer_t *buffer) { return buffer->count; } -int iron_gpu_vertex_buffer_stride(iron_gpu_buffer_t *buffer) { +int gpu_vertex_buffer_stride(gpu_buffer_t *buffer) { return buffer->impl.myStride; } -void iron_gpu_constant_buffer_init(iron_gpu_buffer_t *buffer, int size) { +void gpu_constant_buffer_init(gpu_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_gpu_constant_buffer_destroy(iron_gpu_buffer_t *buffer) { +void gpu_constant_buffer_destroy(gpu_buffer_t *buffer) { id buf = (__bridge_transfer id)buffer->impl._buffer; buf = nil; buffer->impl._buffer = NULL; } -void iron_gpu_constant_buffer_lock(iron_gpu_buffer_t *buffer, int start, int count) { +void gpu_constant_buffer_lock(gpu_buffer_t *buffer, int start, int count) { id buf = (__bridge id)buffer->impl._buffer; uint8_t *data = (uint8_t *)[buf contents]; buffer->data = &data[start]; } -void iron_gpu_constant_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_constant_buffer_unlock(gpu_buffer_t *buffer) { // buffer->data = NULL; } -int iron_gpu_constant_buffer_size(iron_gpu_buffer_t *buffer) { +int gpu_constant_buffer_size(gpu_buffer_t *buffer) { return buffer->impl.mySize; } -void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int indexCount, bool gpu_memory) { +void gpu_index_buffer_init(gpu_buffer_t *buffer, int indexCount) { buffer->impl.count = indexCount; - buffer->impl.gpu_memory = gpu_memory; id device = getMetalDevice(); MTLResourceOptions options = MTLResourceCPUCacheModeWriteCombined; @@ -966,32 +964,32 @@ void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int indexCount, bool options:options]; } -void iron_gpu_index_buffer_destroy(iron_gpu_buffer_t *buffer) { +void gpu_index_buffer_destroy(gpu_buffer_t *buffer) { id buf = (__bridge_transfer id)buffer->impl.metal_buffer; buf = nil; buffer->impl.metal_buffer = NULL; } -static int iron_gpu_internal_index_buffer_stride(iron_gpu_buffer_t *buffer) { +static int gpu_internal_index_buffer_stride(gpu_buffer_t *buffer) { return 4; } -void *iron_gpu_index_buffer_lock(iron_gpu_buffer_t *buffer) { +void *gpu_index_buffer_lock(gpu_buffer_t *buffer) { int start = 0; - int count = iron_gpu_index_buffer_count(buffer); + int count = gpu_index_buffer_count(buffer); id metal_buffer = (__bridge id)buffer->impl.metal_buffer; uint8_t *data = (uint8_t *)[metal_buffer contents]; - return &data[start * iron_gpu_internal_index_buffer_stride(buffer)]; + return &data[start * gpu_internal_index_buffer_stride(buffer)]; } -void iron_gpu_index_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_index_buffer_unlock(gpu_buffer_t *buffer) { } -int iron_gpu_index_buffer_count(iron_gpu_buffer_t *buffer) { +int gpu_index_buffer_count(gpu_buffer_t *buffer) { return buffer->impl.count; } -bool iron_gpu_raytrace_supported() { +bool gpu_raytrace_supported() { id device = getMetalDevice(); return device.supportsRaytracing; } @@ -1027,12 +1025,12 @@ id create_acceleration_sctructure(MTLAccelerationStruc return compacted_acceleration_structure; } -void iron_gpu_raytrace_acceleration_structure_init(iron_gpu_raytrace_acceleration_structure_t *accel) { +void gpu_raytrace_acceleration_structure_init(gpu_raytrace_acceleration_structure_t *accel) { vb_count = 0; instances_count = 0; } -void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_buffer_t *_vb, iron_gpu_buffer_t *_ib, +void gpu_raytrace_acceleration_structure_add(gpu_raytrace_acceleration_structure_t *accel, gpu_buffer_t *_vb, gpu_buffer_t *_ib, iron_matrix4x4_t _transform) { int vb_i = -1; @@ -1054,18 +1052,18 @@ void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration instances_count++; } -void _iron_gpu_raytrace_acceleration_structure_destroy_bottom(iron_gpu_raytrace_acceleration_structure_t *accel) { +void _gpu_raytrace_acceleration_structure_destroy_bottom(gpu_raytrace_acceleration_structure_t *accel) { // for (int i = 0; i < vb_count_last; ++i) { // } _primitive_accels = nil; } -void _iron_gpu_raytrace_acceleration_structure_destroy_top(iron_gpu_raytrace_acceleration_structure_t *accel) { +void _gpu_raytrace_acceleration_structure_destroy_top(gpu_raytrace_acceleration_structure_t *accel) { _instance_accel = nil; } -void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_command_list_t *command_list, - iron_gpu_buffer_t *_vb_full, iron_gpu_buffer_t *_ib_full) { +void gpu_raytrace_acceleration_structure_build(gpu_raytrace_acceleration_structure_t *accel, gpu_command_list_t *command_list, + gpu_buffer_t *_vb_full, gpu_buffer_t *_ib_full) { bool build_bottom = false; for (int i = 0; i < 16; ++i) { @@ -1077,9 +1075,9 @@ void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_accelerati if (vb_count_last > 0) { if (build_bottom) { - _iron_gpu_raytrace_acceleration_structure_destroy_bottom(accel); + _gpu_raytrace_acceleration_structure_destroy_bottom(accel); } - _iron_gpu_raytrace_acceleration_structure_destroy_top(accel); + _gpu_raytrace_acceleration_structure_destroy_top(accel); } vb_count_last = vb_count; @@ -1127,9 +1125,9 @@ void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_accelerati _instance_accel = create_acceleration_sctructure(inst_accel_descriptor); } -void iron_gpu_raytrace_acceleration_structure_destroy(iron_gpu_raytrace_acceleration_structure_t *accel) {} +void gpu_raytrace_acceleration_structure_destroy(gpu_raytrace_acceleration_structure_t *accel) {} -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) { +void gpu_raytrace_set_textures(gpu_texture_t *texpaint0, gpu_texture_t *texpaint1, gpu_texture_t *texpaint2, gpu_texture_t *texenv, gpu_texture_t *texsobol, gpu_texture_t *texscramble, gpu_texture_t *texrank) { _texpaint0 = texpaint0; _texpaint1 = texpaint1; _texpaint2 = texpaint2; @@ -1139,19 +1137,19 @@ void iron_gpu_raytrace_set_textures(iron_gpu_texture_t *texpaint0, iron_gpu_text _texrank = texrank; } -void iron_gpu_raytrace_set_acceleration_structure(iron_gpu_raytrace_acceleration_structure_t *_accel) { +void gpu_raytrace_set_acceleration_structure(gpu_raytrace_acceleration_structure_t *_accel) { accel = _accel; } -void iron_gpu_raytrace_set_pipeline(iron_gpu_raytrace_pipeline_t *_pipeline) { +void gpu_raytrace_set_pipeline(gpu_raytrace_pipeline_t *_pipeline) { pipeline = _pipeline; } -void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { +void gpu_raytrace_set_target(gpu_texture_t *_output) { output = _output; } -void iron_gpu_raytrace_dispatch_rays(iron_gpu_command_list_t *command_list) { +void gpu_raytrace_dispatch_rays(gpu_command_list_t *command_list) { id device = getMetalDevice(); if (!device.supportsRaytracing) return; dispatch_semaphore_wait(_semaphore, DISPATCH_TIME_FOREVER); diff --git a/base/sources/backends/vulkan_gpu.c b/base/sources/backends/vulkan_gpu.c index 97e1ff78..d2ce819e 100644 --- a/base/sources/backends/vulkan_gpu.c +++ b/base/sources/backends/vulkan_gpu.c @@ -32,14 +32,14 @@ struct descriptor_set { VkDescriptorSet set; }; -bool iron_gpu_transpose_mat = true; +bool gpu_transpose_mat = true; -static iron_gpu_texture_t *current_textures[16] = { +static gpu_texture_t *current_textures[16] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; -static iron_gpu_texture_t *current_render_targets[8] = { +static gpu_texture_t *current_render_targets[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; @@ -47,7 +47,7 @@ static VkSemaphore framebuffer_available; static VkSemaphore relay_semaphore; static bool wait_for_relay = false; static int framebuffer_count = 0; -static iron_gpu_pipeline_t *current_pipeline = NULL; +static gpu_pipeline_t *current_pipeline = NULL; static int mrt_index = 0; static bool on_back_buffer = false; static bool in_render_pass = false; @@ -56,7 +56,7 @@ static VkDescriptorSetLayout desc_layout; static VkDescriptorPool descriptor_pool; static struct descriptor_set descriptor_sets[MAX_DESCRIPTOR_SETS] = {0}; static int descriptor_sets_count = 0; -static iron_gpu_texture_t *window_render_target; +static gpu_texture_t *window_render_target; static int current_render_targets_count = 0; static VkRenderingInfo current_rendering_info; static VkRenderingAttachmentInfo current_color_attachment_infos[8]; @@ -113,50 +113,50 @@ static int format_size(VkFormat format) { } } -static VkCullModeFlagBits convert_cull_mode(iron_gpu_cull_mode_t cull_mode) { +static VkCullModeFlagBits convert_cull_mode(gpu_cull_mode_t cull_mode) { switch (cull_mode) { - case IRON_GPU_CULL_MODE_CLOCKWISE: + case GPU_CULL_MODE_CLOCKWISE: return VK_CULL_MODE_BACK_BIT; - case IRON_GPU_CULL_MODE_COUNTERCLOCKWISE: + case GPU_CULL_MODE_COUNTERCLOCKWISE: return VK_CULL_MODE_FRONT_BIT; - case IRON_GPU_CULL_MODE_NEVER: + case GPU_CULL_MODE_NEVER: default: return VK_CULL_MODE_NONE; } } -static VkCompareOp convert_compare_mode(iron_gpu_compare_mode_t compare) { +static VkCompareOp convert_compare_mode(gpu_compare_mode_t compare) { switch (compare) { default: - case IRON_GPU_COMPARE_MODE_ALWAYS: + case GPU_COMPARE_MODE_ALWAYS: return VK_COMPARE_OP_ALWAYS; - case IRON_GPU_COMPARE_MODE_NEVER: + case GPU_COMPARE_MODE_NEVER: return VK_COMPARE_OP_NEVER; - case IRON_GPU_COMPARE_MODE_LESS: + case GPU_COMPARE_MODE_LESS: return VK_COMPARE_OP_LESS; } } -static VkBlendFactor convert_blend_factor(iron_gpu_blending_factor_t factor) { +static VkBlendFactor convert_blend_factor(gpu_blending_factor_t factor) { switch (factor) { - case IRON_GPU_BLEND_ONE: + case GPU_BLEND_ONE: return VK_BLEND_FACTOR_ONE; - case IRON_GPU_BLEND_ZERO: + case GPU_BLEND_ZERO: return VK_BLEND_FACTOR_ZERO; - case IRON_GPU_BLEND_SOURCE_ALPHA: + case GPU_BLEND_SOURCE_ALPHA: return VK_BLEND_FACTOR_SRC_ALPHA; - case IRON_GPU_BLEND_DEST_ALPHA: + case GPU_BLEND_DEST_ALPHA: return VK_BLEND_FACTOR_DST_ALPHA; - case IRON_GPU_BLEND_INV_SOURCE_ALPHA: + case GPU_BLEND_INV_SOURCE_ALPHA: return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - case IRON_GPU_BLEND_INV_DEST_ALPHA: + case GPU_BLEND_INV_DEST_ALPHA: return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; } } -static VkBlendOp convert_blend_operation(iron_gpu_blending_operation_t op) { +static VkBlendOp convert_blend_operation(gpu_blending_operation_t op) { switch (op) { - case IRON_GPU_BLENDOP_ADD: + case GPU_BLENDOP_ADD: return VK_BLEND_OP_ADD; } } @@ -344,7 +344,7 @@ void create_descriptor_layout(void) { vkCreateDescriptorPool(vk_ctx.device, &pool_info, NULL, &descriptor_pool); } -void iron_gpu_internal_resize(int width, int height) { +void gpu_internal_resize(int width, int height) { struct vk_window *window = &vk_ctx.windows[0]; if (window->width != width || window->height != height) { window->resized = true; @@ -590,7 +590,7 @@ static bool find_layer(VkLayerProperties *layers, int layer_count, const char *w return false; } -void iron_gpu_init(int depthBufferBits, bool vsync) { +void gpu_init_internal(int depthBufferBits, bool vsync) { uint32_t instance_layer_count = 0; static const char *wanted_instance_layers[64]; @@ -764,7 +764,7 @@ void iron_gpu_init(int depthBufferBits, bool vsync) { wanted_device_extensions[wanted_device_extension_count++] = VK_KHR_SWAPCHAIN_EXTENSION_NAME; - if (iron_gpu_raytrace_supported()) { + if (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; @@ -900,7 +900,7 @@ void iron_gpu_init(int depthBufferBits, bool vsync) { VkPhysicalDeviceRayTracingPipelineFeaturesKHR raytracing_pipeline_ext = {0}; VkPhysicalDeviceAccelerationStructureFeaturesKHR raytracing_acceleration_structure_ext = {0}; VkPhysicalDeviceBufferDeviceAddressFeatures buffer_device_address_ext = {0}; - if (iron_gpu_raytrace_supported()) { + if (gpu_raytrace_supported()) { raytracing_pipeline_ext.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR; raytracing_pipeline_ext.pNext = deviceinfo.pNext; raytracing_pipeline_ext.rayTracingPipeline = VK_TRUE; @@ -983,10 +983,10 @@ void iron_gpu_init(int depthBufferBits, bool vsync) { create_swapchain(); began = false; - // iron_gpu_begin(NULL); + // gpu_begin(NULL); } -void iron_gpu_destroy() { +void gpu_destroy() { struct vk_window *window = &vk_ctx.windows[0]; VkSwapchainKHR swapchain = cleanup_swapchain(); vk.fpDestroySwapchainKHR(vk_ctx.device, swapchain, NULL); @@ -998,12 +998,12 @@ void iron_vulkan_init_window() { 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_gpu_begin + // otherwise trouble ensues due to G4onG5 backend ending the command list in gpu_begin window->resized = true; window->surface_destroyed = true; } -void iron_gpu_begin(iron_gpu_texture_t *render_target) { +void gpu_begin(gpu_texture_t *render_target) { struct vk_window *window = &vk_ctx.windows[0]; if (began) { @@ -1034,7 +1034,7 @@ void iron_gpu_begin(iron_gpu_texture_t *render_target) { while (err != VK_SUCCESS && err != VK_SUBOPTIMAL_KHR); } -void iron_gpu_end() { +void gpu_end() { VkPresentInfoKHR present = { .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, .pNext = NULL, @@ -1076,13 +1076,13 @@ bool iron_vulkan_internal_get_size(int *width, int *height) { return false; } -int iron_gpu_max_bound_textures(void) { +int gpu_max_bound_textures(void) { VkPhysicalDeviceProperties props; vkGetPhysicalDeviceProperties(vk_ctx.gpu, &props); return props.limits.maxPerStageDescriptorSamplers; } -void set_viewport_and_scissor(iron_gpu_command_list_t *list) { +void set_viewport_and_scissor(gpu_command_list_t *list) { VkViewport viewport; memset(&viewport, 0, sizeof(viewport)); VkRect2D scissor; @@ -1117,7 +1117,7 @@ void set_viewport_and_scissor(iron_gpu_command_list_t *list) { vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } -void iron_gpu_command_list_init(iron_gpu_command_list_t *list) { +void gpu_command_list_init(gpu_command_list_t *list) { VkCommandBufferAllocateInfo cmd = { .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, .pNext = NULL, @@ -1138,12 +1138,12 @@ void iron_gpu_command_list_init(iron_gpu_command_list_t *list) { list->impl._indexCount = 0; } -void iron_gpu_command_list_destroy(iron_gpu_command_list_t *list) { +void gpu_command_list_destroy(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); } -static void begin_pass(iron_gpu_command_list_t *list) { +static void begin_pass(gpu_command_list_t *list) { VkRect2D render_area = { .offset = {0, 0} }; @@ -1204,12 +1204,12 @@ static void begin_pass(iron_gpu_command_list_t *list) { in_render_pass = true; } -static void end_pass(iron_gpu_command_list_t *list) { +static void end_pass(gpu_command_list_t *list) { vkCmdEndRendering(list->impl._buffer); } -void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { - iron_gpu_command_list_wait(list); +void gpu_command_list_begin(gpu_command_list_t *list) { + gpu_command_list_wait(list); vkResetCommandBuffer(list->impl._buffer, 0); VkCommandBufferBeginInfo cmd_buf_info = { @@ -1241,7 +1241,7 @@ void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { vkCmdPipelineBarrier(list->impl._buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, 0, NULL, 0, NULL, 1, pmemory_barrier); - // iron_gpu_command_list_framebuffer_to_render_target_barrier(list, window_render_target); + // gpu_command_list_framebuffer_to_render_target_barrier(list, window_render_target); begin_pass(list); set_viewport_and_scissor(list); @@ -1249,12 +1249,12 @@ void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { mrt_index = 0; } -void iron_gpu_command_list_end(iron_gpu_command_list_t *list) { +void gpu_command_list_end(gpu_command_list_t *list) { end_pass(list); if (current_render_targets_count > 0 && current_render_targets[0] != window_render_target) { for (int i = 0; i < current_render_targets_count; ++i) { - iron_gpu_command_list_render_target_to_texture_barrier(list, current_render_targets[i]); + gpu_command_list_render_target_to_texture_barrier(list, current_render_targets[i]); } current_render_targets_count = 0; } @@ -1278,13 +1278,13 @@ void iron_gpu_command_list_end(iron_gpu_command_list_t *list) { VkImageMemoryBarrier *pmemory_barrier = &prePresentBarrier; vkCmdPipelineBarrier(list->impl._buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0, NULL, 1, pmemory_barrier); - // iron_gpu_command_list_render_target_to_framebuffer_barrier(list, window_render_target); + // gpu_command_list_render_target_to_framebuffer_barrier(list, window_render_target); vkEndCommandBuffer(list->impl._buffer); // Make sure the previous execution is done, so we can reuse the fence // Not optimal of course - iron_gpu_command_list_wait(list); + gpu_command_list_wait(list); vkResetFences(vk_ctx.device, 1, &list->impl.fence); VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; @@ -1316,7 +1316,7 @@ void iron_gpu_command_list_end(iron_gpu_command_list_t *list) { vkQueueSubmit(vk_ctx.queue, 1, &submit_info, list->impl.fence); } -void iron_gpu_command_list_render_target_to_framebuffer_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *renderTarget) { +void gpu_command_list_render_target_to_framebuffer_barrier(gpu_command_list_t *list, struct gpu_texture *renderTarget) { VkImage image = renderTarget->impl.image; VkImageMemoryBarrier barrier = { .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, @@ -1339,7 +1339,7 @@ void iron_gpu_command_list_render_target_to_framebuffer_barrier(iron_gpu_command vkCmdPipelineBarrier(list->impl._buffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0, NULL, 1, &barrier); } -void iron_gpu_command_list_framebuffer_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *render_target) { +void gpu_command_list_framebuffer_to_render_target_barrier(gpu_command_list_t *list, struct gpu_texture *render_target) { VkImage image = render_target->impl.image; VkImageMemoryBarrier barrier = { .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, @@ -1362,7 +1362,7 @@ void iron_gpu_command_list_framebuffer_to_render_target_barrier(iron_gpu_command vkCmdPipelineBarrier(list->impl._buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, 0, NULL, 0, NULL, 1, &barrier); } -void iron_gpu_command_list_texture_to_render_target_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *render_target) { +void gpu_command_list_texture_to_render_target_barrier(gpu_command_list_t *list, struct gpu_texture *render_target) { if (render_target->state != IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET) { VkImageMemoryBarrier barrier = { .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, @@ -1410,7 +1410,7 @@ void iron_gpu_command_list_texture_to_render_target_barrier(iron_gpu_command_lis } } -void iron_gpu_command_list_render_target_to_texture_barrier(iron_gpu_command_list_t *list, struct iron_gpu_texture *render_target) { +void gpu_command_list_render_target_to_texture_barrier(gpu_command_list_t *list, struct gpu_texture *render_target) { if (render_target->state != IRON_INTERNAL_RENDER_TARGET_STATE_TEXTURE) { VkImageMemoryBarrier barrier = { .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, @@ -1458,13 +1458,13 @@ void iron_gpu_command_list_render_target_to_texture_barrier(iron_gpu_command_lis } } -void iron_gpu_command_list_draw(iron_gpu_command_list_t *list) { +void gpu_command_list_draw(gpu_command_list_t *list) { int start = 0; int count = list->impl._indexCount; vkCmdDrawIndexed(list->impl._buffer, count, 1, start, 0, 0); } -void iron_gpu_command_list_viewport(iron_gpu_command_list_t *list, int x, int y, int width, int height) { +void gpu_command_list_viewport(gpu_command_list_t *list, int x, int y, int width, int height) { VkViewport viewport; memset(&viewport, 0, sizeof(viewport)); viewport.x = (float)x; @@ -1476,7 +1476,7 @@ void iron_gpu_command_list_viewport(iron_gpu_command_list_t *list, int x, int y, vkCmdSetViewport(list->impl._buffer, 0, 1, &viewport); } -void iron_gpu_command_list_scissor(iron_gpu_command_list_t *list, int x, int y, int width, int height) { +void gpu_command_list_scissor(gpu_command_list_t *list, int x, int y, int width, int height) { VkRect2D scissor; memset(&scissor, 0, sizeof(scissor)); scissor.extent.width = width; @@ -1486,7 +1486,7 @@ void iron_gpu_command_list_scissor(iron_gpu_command_list_t *list, int x, int y, vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } -void iron_gpu_command_list_disable_scissor(iron_gpu_command_list_t *list) { +void gpu_command_list_disable_scissor(gpu_command_list_t *list) { VkRect2D scissor; memset(&scissor, 0, sizeof(scissor)); if (current_render_targets[0] == NULL || current_render_targets[0]->framebuffer_index >= 0) { @@ -1500,12 +1500,12 @@ void iron_gpu_command_list_disable_scissor(iron_gpu_command_list_t *list) { vkCmdSetScissor(list->impl._buffer, 0, 1, &scissor); } -void iron_gpu_command_list_set_pipeline(iron_gpu_command_list_t *list, struct iron_gpu_pipeline *pipeline) { +void gpu_command_list_set_pipeline(gpu_command_list_t *list, struct gpu_pipeline *pipeline) { current_pipeline = pipeline; vkCmdBindPipeline(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, current_pipeline->impl.pipeline); } -void iron_gpu_command_list_set_vertex_buffer(iron_gpu_command_list_t *list, iron_gpu_buffer_t *vertexBuffer) { +void gpu_command_list_set_vertex_buffer(gpu_command_list_t *list, gpu_buffer_t *vertexBuffer) { VkBuffer buffers[1]; VkDeviceSize offsets[1]; buffers[0] = vertexBuffer->impl.buf; @@ -1513,12 +1513,12 @@ void iron_gpu_command_list_set_vertex_buffer(iron_gpu_command_list_t *list, iron vkCmdBindVertexBuffers(list->impl._buffer, 0, 1, buffers, offsets); } -void iron_gpu_command_list_set_index_buffer(iron_gpu_command_list_t *list, iron_gpu_buffer_t *indexBuffer) { - list->impl._indexCount = iron_gpu_index_buffer_count(indexBuffer); +void gpu_command_list_set_index_buffer(gpu_command_list_t *list, gpu_buffer_t *indexBuffer) { + list->impl._indexCount = gpu_index_buffer_count(indexBuffer); vkCmdBindIndexBuffer(list->impl._buffer, indexBuffer->impl.buf, 0, VK_INDEX_TYPE_UINT32); } -void iron_internal_restore_render_target(iron_gpu_command_list_t *list, struct iron_gpu_texture *target, unsigned flags, unsigned color, float depth) { +void iron_internal_restore_render_target(gpu_command_list_t *list, struct gpu_texture *target, unsigned flags, unsigned color, float depth) { set_viewport_and_scissor(list); if (on_back_buffer && in_render_pass) { @@ -1531,7 +1531,7 @@ void iron_internal_restore_render_target(iron_gpu_command_list_t *list, struct i //// if (current_render_targets_count > 0 && current_render_targets[0] != window_render_target) { for (int i = 0; i < current_render_targets_count; ++i) { - iron_gpu_command_list_render_target_to_texture_barrier(list, current_render_targets[i]); + gpu_command_list_render_target_to_texture_barrier(list, current_render_targets[i]); } } @@ -1548,10 +1548,10 @@ void iron_internal_restore_render_target(iron_gpu_command_list_t *list, struct i set_viewport_and_scissor(list); - if (flags != IRON_GPU_CLEAR_NONE) { + if (flags != GPU_CLEAR_NONE) { int count = 0; VkClearAttachment attachments[2]; - if (flags & IRON_GPU_CLEAR_COLOR) { + if (flags & GPU_CLEAR_COLOR) { VkClearColorValue clearColor = {0}; clearColor.float32[0] = ((color & 0x00ff0000) >> 16) / 255.0f; clearColor.float32[1] = ((color & 0x0000ff00) >> 8) / 255.0f; @@ -1562,7 +1562,7 @@ void iron_internal_restore_render_target(iron_gpu_command_list_t *list, struct i attachments[count].clearValue.color = clearColor; count++; } - if (flags & IRON_GPU_CLEAR_DEPTH) { + if (flags & GPU_CLEAR_DEPTH) { attachments[count].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; attachments[count].clearValue.depthStencil.depth = depth; attachments[count].clearValue.depthStencil.stencil = 0; @@ -1581,7 +1581,7 @@ void iron_internal_restore_render_target(iron_gpu_command_list_t *list, struct i } } -void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, struct iron_gpu_texture **targets, int count, unsigned flags, unsigned color, float depth) { +void gpu_command_list_set_render_targets(gpu_command_list_t *list, struct gpu_texture **targets, int count, unsigned flags, unsigned color, float depth) { if (targets[0]->framebuffer_index >= 0) { //// @@ -1600,7 +1600,7 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, str //// if (current_render_targets_count > 0 && current_render_targets[0] != window_render_target) { for (int i = 0; i < current_render_targets_count; ++i) { - iron_gpu_command_list_render_target_to_texture_barrier(list, current_render_targets[i]); + gpu_command_list_render_target_to_texture_barrier(list, current_render_targets[i]); } } @@ -1613,7 +1613,7 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, str if (targets[0] != window_render_target) { for (int i = 0; i < count; ++i) { - iron_gpu_command_list_texture_to_render_target_barrier(list, targets[i]); + gpu_command_list_texture_to_render_target_barrier(list, targets[i]); } } @@ -1687,10 +1687,10 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, str set_viewport_and_scissor(list); - if (flags != IRON_GPU_CLEAR_NONE) { + if (flags != GPU_CLEAR_NONE) { int count = 0; VkClearAttachment attachments[2]; - if (flags & IRON_GPU_CLEAR_COLOR) { + if (flags & GPU_CLEAR_COLOR) { VkClearColorValue clearColor = {0}; clearColor.float32[0] = ((color & 0x00ff0000) >> 16) / 255.0f; clearColor.float32[1] = ((color & 0x0000ff00) >> 8) / 255.0f; @@ -1701,7 +1701,7 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, str attachments[count].clearValue.color = clearColor; count++; } - if (flags & IRON_GPU_CLEAR_DEPTH) { + if (flags & GPU_CLEAR_DEPTH) { attachments[count].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; attachments[count].clearValue.depthStencil.depth = depth; attachments[count].clearValue.depthStencil.stencil = 0; @@ -1719,16 +1719,16 @@ void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, str } } -void iron_gpu_command_list_upload_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_buffer *buffer) { +void gpu_command_list_upload_index_buffer(gpu_command_list_t *list, struct gpu_buffer *buffer) { } -void iron_gpu_command_list_upload_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_buffer *buffer) { +void gpu_command_list_upload_vertex_buffer(gpu_command_list_t *list, struct gpu_buffer *buffer) { } -void iron_gpu_command_list_upload_texture(iron_gpu_command_list_t *list, struct iron_gpu_texture *texture) { +void gpu_command_list_upload_texture(gpu_command_list_t *list, struct 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 gpu_command_list_get_render_target_pixels(gpu_command_list_t *list, gpu_texture_t *render_target, uint8_t *data) { VkFormat format = render_target->impl.format; int format_bytes_size = format_size(format); @@ -1789,9 +1789,9 @@ void iron_gpu_command_list_get_render_target_pixels(iron_gpu_command_list_t *lis // begin_pass(list, ¤t_rendering_info); //// - iron_gpu_command_list_end(list); - iron_gpu_command_list_wait(list); - iron_gpu_command_list_begin(list); + gpu_command_list_end(list); + gpu_command_list_wait(list); + gpu_command_list_begin(list); // Read buffer void *p; @@ -1941,22 +1941,22 @@ VkDescriptorSet get_descriptor_set() { return descriptor_set; } -void iron_gpu_command_list_set_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_buffer *buffer, int offset, size_t size) { +void gpu_command_list_set_constant_buffer(gpu_command_list_t *list, struct gpu_buffer *buffer, int offset, size_t size) { VkDescriptorSet descriptor_set = get_descriptor_set(); uint32_t offsets[1] = {offset}; vkCmdBindDescriptorSets(list->impl._buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, current_pipeline->impl.pipeline_layout, 0, 1, &descriptor_set, 1, offsets); } -void iron_gpu_command_list_wait(iron_gpu_command_list_t *list) { +void gpu_command_list_wait(gpu_command_list_t *list) { vkWaitForFences(vk_ctx.device, 1, &list->impl.fence, VK_TRUE, UINT64_MAX); } -void iron_gpu_set_texture(iron_gpu_command_list_t *list, int unit, iron_gpu_texture_t *texture) { +void gpu_set_texture(gpu_command_list_t *list, int unit, gpu_texture_t *texture) { texture->impl.stage = unit; current_textures[unit.offset] = texture; } -void iron_gpu_set_texture_depth(iron_gpu_command_list_t *list, int unit, iron_gpu_texture_t *target) { +void gpu_set_texture_depth(gpu_command_list_t *list, int unit, gpu_texture_t *target) { target->impl.stage_depth = unit; current_textures[unit.offset] = target; } @@ -1973,16 +1973,16 @@ static VkShaderModule create_shader_module(const void *code, size_t size) { return module; } -void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipeline) { +void gpu_pipeline_init(gpu_pipeline_t *pipeline) { gpu_internal_pipeline_init(pipeline); } -void iron_gpu_pipeline_destroy(iron_gpu_pipeline_t *pipeline) { +void gpu_pipeline_destroy(gpu_pipeline_t *pipeline) { vkDestroyPipeline(vk_ctx.device, pipeline->impl.pipeline, NULL); vkDestroyPipelineLayout(vk_ctx.device, pipeline->impl.pipeline_layout, NULL); } -void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { +void gpu_pipeline_compile(gpu_pipeline_t *pipeline) { VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo = { .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .pNext = NULL, @@ -2025,29 +2025,29 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { uint32_t attr = 0; uint32_t offset = 0; for (int i = 0; i < pipeline->input_layout->size; ++i) { - iron_gpu_vertex_element_t element = pipeline->input_layout->elements[i]; + gpu_vertex_element_t element = pipeline->input_layout->elements[i]; vi_attrs[attr].binding = 0; vi_attrs[attr].location = i; vi_attrs[attr].offset = offset; - offset += iron_gpu_vertex_data_size(element.data); + offset += gpu_vertex_data_size(element.data); switch (element.data) { - case IRON_GPU_VERTEX_DATA_F32_1X: + case GPU_VERTEX_DATA_F32_1X: vi_attrs[attr].format = VK_FORMAT_R32_SFLOAT; break; - case IRON_GPU_VERTEX_DATA_F32_2X: + case GPU_VERTEX_DATA_F32_2X: vi_attrs[attr].format = VK_FORMAT_R32G32_SFLOAT; break; - case IRON_GPU_VERTEX_DATA_F32_3X: + case GPU_VERTEX_DATA_F32_3X: vi_attrs[attr].format = VK_FORMAT_R32G32B32_SFLOAT; break; - case IRON_GPU_VERTEX_DATA_F32_4X: + case GPU_VERTEX_DATA_F32_4X: vi_attrs[attr].format = VK_FORMAT_R32G32B32A32_SFLOAT; break; - case IRON_GPU_VERTEX_DATA_I16_2X_NORM: + case GPU_VERTEX_DATA_I16_2X_NORM: vi_attrs[attr].format = VK_FORMAT_R16G16_SNORM; break; - case IRON_GPU_VERTEX_DATA_I16_4X_NORM: + case GPU_VERTEX_DATA_I16_4X_NORM: vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_SNORM; break; } @@ -2081,10 +2081,10 @@ void iron_gpu_pipeline_compile(iron_gpu_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_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].blendEnable = pipeline->blend_source != GPU_BLEND_ONE || + pipeline->blend_destination != GPU_BLEND_ZERO || + pipeline->alpha_blend_source != GPU_BLEND_ONE || + pipeline->alpha_blend_destination != 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); @@ -2104,7 +2104,7 @@ void iron_gpu_pipeline_compile(iron_gpu_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_GPU_COMPARE_MODE_ALWAYS; + ds.depthTestEnable = pipeline->depth_mode != GPU_COMPARE_MODE_ALWAYS; ds.depthWriteEnable = pipeline->depth_write; ds.depthCompareOp = convert_compare_mode(pipeline->depth_mode); ds.depthBoundsTestEnable = VK_FALSE; @@ -2167,7 +2167,7 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipeline) { vkDestroyShaderModule(vk_ctx.device, pipeline->impl.vert_shader_module, NULL); } -void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *source, size_t length, iron_gpu_shader_type_t type) { +void gpu_shader_init(gpu_shader_t *shader, const void *source, size_t length, gpu_shader_type_t type) { shader->impl.length = (int)length; shader->impl.id = 0; shader->impl.source = (char *)malloc(length + 1); @@ -2177,7 +2177,7 @@ void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *source, size_t shader->impl.source[length] = 0; } -void iron_gpu_shader_destroy(iron_gpu_shader_t *shader) { +void gpu_shader_destroy(gpu_shader_t *shader) { free(shader->impl.source); shader->impl.source = NULL; } @@ -2325,7 +2325,7 @@ static void prepare_texture_image(uint8_t *tex_colors, uint32_t width, uint32_t set_image_layout(tex_obj->image, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, tex_obj->imageLayout); } -static void update_stride(iron_gpu_texture_t *texture) { +static void update_stride(gpu_texture_t *texture) { VkImageSubresource subres = { .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .mipLevel = 0, @@ -2338,7 +2338,7 @@ static void update_stride(iron_gpu_texture_t *texture) { texture->impl.stride = (int)layout.rowPitch; } -void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { +void gpu_texture_init_from_bytes(gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->uploaded = false; @@ -2432,7 +2432,7 @@ void iron_gpu_texture_init_from_bytes(iron_gpu_texture_t *texture, void *data, i vkCreateImageView(vk_ctx.device, &view, NULL, &texture->impl.view); } -void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format) { +void gpu_texture_init(gpu_texture_t *texture, int width, int height, iron_image_format_t format) { texture->width = width; texture->height = height; texture->uploaded = true; @@ -2479,7 +2479,7 @@ void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, i vkCreateImageView(vk_ctx.device, &view, NULL, &texture->impl.view); } -void iron_gpu_texture_destroy(iron_gpu_texture_t *target) { +void gpu_texture_destroy(gpu_texture_t *target) { if (target->framebuffer_index >= 0) { framebuffer_count -= 1; } @@ -2495,13 +2495,13 @@ void iron_gpu_texture_destroy(iron_gpu_texture_t *target) { } } -int iron_gpu_texture_stride(iron_gpu_texture_t *texture) { +int gpu_texture_stride(gpu_texture_t *texture) { return texture->impl.stride; } -void iron_gpu_texture_generate_mipmaps(iron_gpu_texture_t *texture, int levels) {} +void gpu_texture_generate_mipmaps(gpu_texture_t *texture, int levels) {} -void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t *mipmap, int level) { +void gpu_texture_set_mipmap(gpu_texture_t *texture, gpu_texture_t *mipmap, int level) { // VkBuffer staging_buffer; // VkDeviceMemory staging_buffer_mem; @@ -2568,7 +2568,7 @@ void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t // texture->uploaded = true; } -static void render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_bits, int framebuffer_index) { +static void render_target_init(gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_bits, int framebuffer_index) { target->framebuffer_index = framebuffer_index; target->width = width; target->height = height; @@ -2697,7 +2697,7 @@ static void render_target_init(iron_gpu_texture_t *target, int width, int height } } -void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_bits) { +void gpu_render_target_init(gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_bits) { render_target_init(target, width, height, format, depth_bits, -1); target->width = width; target->height = height; @@ -2706,12 +2706,12 @@ void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int heig target->uploaded = true; } -void iron_gpu_render_target_init_framebuffer(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_bits) { +void gpu_render_target_init_framebuffer(gpu_texture_t *target, int width, int height, iron_image_format_t format, int depth_bits) { render_target_init(target, width, height, format, depth_bits, framebuffer_count); framebuffer_count += 1; } -void iron_gpu_render_target_set_depth_from(iron_gpu_texture_t *target, iron_gpu_texture_t *source) { +void gpu_render_target_set_depth_from(gpu_texture_t *target, gpu_texture_t *source) { target->impl.depthImage = source->impl.depthImage; target->impl.depthMemory = source->impl.depthMemory; target->impl.depthView = source->impl.depthView; @@ -2719,12 +2719,12 @@ void iron_gpu_render_target_set_depth_from(iron_gpu_texture_t *target, iron_gpu_ target->depth_state = source->depth_state; } -void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int vertexCount, iron_gpu_vertex_structure_t *structure, bool gpuMemory) { +void gpu_vertex_buffer_init(gpu_buffer_t *buffer, int vertexCount, gpu_vertex_structure_t *structure) { buffer->count = vertexCount; buffer->impl.myStride = 0; for (int i = 0; i < structure->size; ++i) { - iron_gpu_vertex_element_t element = structure->elements[i]; - buffer->impl.myStride += iron_gpu_vertex_data_size(element.data); + gpu_vertex_element_t element = structure->elements[i]; + buffer->impl.myStride += gpu_vertex_data_size(element.data); } VkBufferCreateInfo buf_info = { @@ -2735,7 +2735,7 @@ void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int vertexCount, iro .flags = 0, }; - if (iron_gpu_raytrace_supported()) { + if (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; @@ -2760,7 +2760,7 @@ void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int vertexCount, iro memory_type_from_properties(mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &buffer->impl.mem_alloc.memoryTypeIndex); VkMemoryAllocateFlagsInfo memory_allocate_flags_info = {0}; - if (iron_gpu_raytrace_supported()) { + if (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; @@ -2770,31 +2770,31 @@ void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int vertexCount, iro vkBindBufferMemory(vk_ctx.device, buffer->impl.buf, buffer->impl.mem, 0); } -void iron_gpu_vertex_buffer_destroy(iron_gpu_buffer_t *buffer) { +void gpu_vertex_buffer_destroy(gpu_buffer_t *buffer) { vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } -float *iron_gpu_vertex_buffer_lock(iron_gpu_buffer_t *buffer) { +float *gpu_vertex_buffer_lock(gpu_buffer_t *buffer) { int start = 0; int count = buffer->count; vkMapMemory(vk_ctx.device, buffer->impl.mem, start * buffer->impl.myStride, count * buffer->impl.myStride, 0, (void **)&buffer->impl.data); return buffer->impl.data; } -void iron_gpu_vertex_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_vertex_buffer_unlock(gpu_buffer_t *buffer) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -int iron_gpu_vertex_buffer_count(iron_gpu_buffer_t *buffer) { +int gpu_vertex_buffer_count(gpu_buffer_t *buffer) { return buffer->count; } -int iron_gpu_vertex_buffer_stride(iron_gpu_buffer_t *buffer) { +int gpu_vertex_buffer_stride(gpu_buffer_t *buffer) { return buffer->impl.myStride; } -void iron_gpu_constant_buffer_init(iron_gpu_buffer_t *buffer, int size) { +void gpu_constant_buffer_init(gpu_buffer_t *buffer, int size) { buffer->impl.mySize = size; buffer->data = NULL; @@ -2803,7 +2803,7 @@ void iron_gpu_constant_buffer_init(iron_gpu_buffer_t *buffer, int size) { buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; buf_info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; - if (iron_gpu_raytrace_supported()) { + if (gpu_raytrace_supported()) { buf_info.usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; } @@ -2833,25 +2833,25 @@ void iron_gpu_constant_buffer_init(iron_gpu_buffer_t *buffer, int size) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -void iron_gpu_constant_buffer_destroy(iron_gpu_buffer_t *buffer) { +void gpu_constant_buffer_destroy(gpu_buffer_t *buffer) { vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } -void iron_gpu_constant_buffer_lock(iron_gpu_buffer_t *buffer, int start, int count) { +void gpu_constant_buffer_lock(gpu_buffer_t *buffer, int start, int count) { vkMapMemory(vk_ctx.device, buffer->impl.mem, start, count, 0, (void **)&buffer->data); } -void iron_gpu_constant_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_constant_buffer_unlock(gpu_buffer_t *buffer) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); buffer->data = NULL; } -int iron_gpu_constant_buffer_size(iron_gpu_buffer_t *buffer) { +int gpu_constant_buffer_size(gpu_buffer_t *buffer) { return buffer->impl.mySize; } -void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int indexCount, bool gpuMemory) { +void gpu_index_buffer_init(gpu_buffer_t *buffer, int indexCount) { buffer->count = indexCount; VkBufferCreateInfo buf_info = { @@ -2862,7 +2862,7 @@ void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int indexCount, bool .flags = 0, }; - if (iron_gpu_raytrace_supported()) { + if (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; @@ -2886,7 +2886,7 @@ void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int indexCount, bool memory_type_from_properties(mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &buffer->impl.mem_alloc.memoryTypeIndex); VkMemoryAllocateFlagsInfo memory_allocate_flags_info = {0}; - if (iron_gpu_raytrace_supported()) { + if (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; @@ -2896,29 +2896,29 @@ void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int indexCount, bool vkBindBufferMemory(vk_ctx.device, buffer->impl.buf, buffer->impl.mem, 0); } -void iron_gpu_index_buffer_destroy(iron_gpu_buffer_t *buffer) { +void gpu_index_buffer_destroy(gpu_buffer_t *buffer) { // unset(buffer); vkFreeMemory(vk_ctx.device, buffer->impl.mem, NULL); vkDestroyBuffer(vk_ctx.device, buffer->impl.buf, NULL); } -static int iron_gpu_internal_index_buffer_stride(iron_gpu_buffer_t *buffer) { +static int gpu_internal_index_buffer_stride(gpu_buffer_t *buffer) { return 4; } -void *iron_gpu_index_buffer_lock(iron_gpu_buffer_t *buffer) { +void *gpu_index_buffer_lock(gpu_buffer_t *buffer) { int start = 0; - int count = iron_gpu_index_buffer_count(buffer); + int count = gpu_index_buffer_count(buffer); uint8_t *data; vkMapMemory(vk_ctx.device, buffer->impl.mem, 0, buffer->impl.mem_alloc.allocationSize, 0, (void **)&data); - return &data[start * iron_gpu_internal_index_buffer_stride(buffer)]; + return &data[start * gpu_internal_index_buffer_stride(buffer)]; } -void iron_gpu_index_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_index_buffer_unlock(gpu_buffer_t *buffer) { vkUnmapMemory(vk_ctx.device, buffer->impl.mem); } -int iron_gpu_index_buffer_count(iron_gpu_buffer_t *buffer) { +int gpu_index_buffer_count(gpu_buffer_t *buffer) { return buffer->count; } @@ -2935,19 +2935,19 @@ typedef struct inst { } inst_t; static VkDescriptorPool raytrace_descriptor_pool; -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_buffer_t *vb[16]; -static iron_gpu_buffer_t *vb_last[16]; -static iron_gpu_buffer_t *ib[16]; +static gpu_raytrace_acceleration_structure_t *accel; +static gpu_raytrace_pipeline_t *pipeline; +static gpu_texture_t *output = NULL; +static gpu_texture_t *texpaint0; +static gpu_texture_t *texpaint1; +static gpu_texture_t *texpaint2; +static gpu_texture_t *texenv; +static gpu_texture_t *texsobol; +static gpu_texture_t *texscramble; +static gpu_texture_t *texrank; +static gpu_buffer_t *vb[16]; +static gpu_buffer_t *vb_last[16]; +static gpu_buffer_t *ib[16]; static int vb_count = 0; static int vb_count_last = 0; static inst_t instances[1024]; @@ -2967,7 +2967,7 @@ static PFN_vkCmdBuildAccelerationStructuresKHR _vkCmdBuildAccelerationStructures static PFN_vkDestroyAccelerationStructureKHR _vkDestroyAccelerationStructureKHR = NULL; static PFN_vkCmdTraceRaysKHR _vkCmdTraceRaysKHR = NULL; -bool iron_gpu_raytrace_supported() { +bool gpu_raytrace_supported() { #ifdef IRON_ANDROID return false; // Use VK_KHR_ray_query #else @@ -2975,8 +2975,8 @@ bool iron_gpu_raytrace_supported() { #endif } -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, - struct iron_gpu_buffer *constant_buffer) { +void gpu_raytrace_pipeline_init(gpu_raytrace_pipeline_t *pipeline, gpu_command_list_t *command_list, void *ray_shader, int ray_shader_size, + struct gpu_buffer *constant_buffer) { output = NULL; pipeline->_constant_buffer = constant_buffer; @@ -3312,7 +3312,7 @@ void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, iro } } -void iron_gpu_raytrace_pipeline_destroy(iron_gpu_raytrace_pipeline_t *pipeline) { +void gpu_raytrace_pipeline_destroy(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); @@ -3327,7 +3327,7 @@ uint64_t get_buffer_device_address(VkBuffer buffer) { return _vkGetBufferDeviceAddressKHR(vk_ctx.device, &buffer_device_address_info); } -void iron_gpu_raytrace_acceleration_structure_init(iron_gpu_raytrace_acceleration_structure_t *accel) { +void gpu_raytrace_acceleration_structure_init(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"); @@ -3337,7 +3337,7 @@ void iron_gpu_raytrace_acceleration_structure_init(iron_gpu_raytrace_acceleratio instances_count = 0; } -void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration_structure_t *accel, struct iron_gpu_buffer *_vb, struct iron_gpu_buffer *_ib, +void gpu_raytrace_acceleration_structure_add(gpu_raytrace_acceleration_structure_t *accel, struct gpu_buffer *_vb, struct gpu_buffer *_ib, iron_matrix4x4_t _transform) { int vb_i = -1; @@ -3359,7 +3359,7 @@ void iron_gpu_raytrace_acceleration_structure_add(iron_gpu_raytrace_acceleration instances_count++; } -void _iron_gpu_raytrace_acceleration_structure_destroy_bottom(iron_gpu_raytrace_acceleration_structure_t *accel) { +void _gpu_raytrace_acceleration_structure_destroy_bottom(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); @@ -3368,7 +3368,7 @@ void _iron_gpu_raytrace_acceleration_structure_destroy_bottom(iron_gpu_raytrace_ } } -void _iron_gpu_raytrace_acceleration_structure_destroy_top(iron_gpu_raytrace_acceleration_structure_t *accel) { +void _gpu_raytrace_acceleration_structure_destroy_top(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); @@ -3377,8 +3377,8 @@ void _iron_gpu_raytrace_acceleration_structure_destroy_top(iron_gpu_raytrace_acc vkDestroyBuffer(vk_ctx.device, accel->impl.instances_buffer, NULL); } -void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_acceleration_structure_t *accel, iron_gpu_command_list_t *command_list, - struct iron_gpu_buffer *_vb_full, struct iron_gpu_buffer *_ib_full) { +void gpu_raytrace_acceleration_structure_build(gpu_raytrace_acceleration_structure_t *accel, gpu_command_list_t *command_list, + struct gpu_buffer *_vb_full, struct gpu_buffer *_ib_full) { bool build_bottom = false; for (int i = 0; i < 16; ++i) { @@ -3390,9 +3390,9 @@ void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_accelerati if (vb_count_last > 0) { if (build_bottom) { - _iron_gpu_raytrace_acceleration_structure_destroy_bottom(accel); + _gpu_raytrace_acceleration_structure_destroy_bottom(accel); } - _iron_gpu_raytrace_acceleration_structure_destroy_top(accel); + _gpu_raytrace_acceleration_structure_destroy_top(accel); } vb_count_last = vb_count; @@ -3950,7 +3950,7 @@ void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_accelerati } } -void iron_gpu_raytrace_acceleration_structure_destroy(iron_gpu_raytrace_acceleration_structure_t *accel) { +void gpu_raytrace_acceleration_structure_destroy(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); @@ -3964,7 +3964,7 @@ void iron_gpu_raytrace_acceleration_structure_destroy(iron_gpu_raytrace_accelera // vkDestroyBuffer(vk_ctx.device, accel->impl.instances_buffer, NULL); } -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) { +void gpu_raytrace_set_textures(gpu_texture_t *_texpaint0, gpu_texture_t *_texpaint1, gpu_texture_t *_texpaint2, gpu_texture_t *_texenv, gpu_texture_t *_texsobol, gpu_texture_t *_texscramble, gpu_texture_t *_texrank) { texpaint0 = _texpaint0; texpaint1 = _texpaint1; texpaint2 = _texpaint2; @@ -3974,15 +3974,15 @@ void iron_gpu_raytrace_set_textures(iron_gpu_texture_t *_texpaint0, iron_gpu_tex texrank = _texrank; } -void iron_gpu_raytrace_set_acceleration_structure(iron_gpu_raytrace_acceleration_structure_t *_accel) { +void gpu_raytrace_set_acceleration_structure(gpu_raytrace_acceleration_structure_t *_accel) { accel = _accel; } -void iron_gpu_raytrace_set_pipeline(iron_gpu_raytrace_pipeline_t *_pipeline) { +void gpu_raytrace_set_pipeline(gpu_raytrace_pipeline_t *_pipeline) { pipeline = _pipeline; } -void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { +void gpu_raytrace_set_target(gpu_texture_t *_output) { if (_output != output) { vkDestroyImage(vk_ctx.device, _output->impl.image, NULL); @@ -4024,7 +4024,7 @@ void iron_gpu_raytrace_set_target(iron_gpu_texture_t *_output) { output = _output; } -void iron_gpu_raytrace_dispatch_rays(iron_gpu_command_list_t *command_list) { +void gpu_raytrace_dispatch_rays(gpu_command_list_t *command_list) { VkWriteDescriptorSetAccelerationStructureKHR descriptor_acceleration_structure_info = { .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR, .accelerationStructureCount = 1, diff --git a/base/sources/backends/wasm_video.c b/base/sources/backends/wasm_video.c index c1eb9436..0d466cec 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_gpu_texture_t *iron_video_current_image(iron_video_t *video) { +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 aea524d8..60d8c23c 100644 --- a/base/sources/backends/webgpu_gpu.c +++ b/base/sources/backends/webgpu_gpu.c @@ -18,9 +18,9 @@ WGPUDevice device; WGPUQueue queue; WGPUSwapChain swapChain; -void iron_gpu_destroy() {} +void gpu_destroy() {} -void iron_gpu_init(int depthBufferBits, bool vsync) { +void gpu_init_internal(int depthBufferBits, bool vsync) { newRenderTargetWidth = renderTargetWidth = iron_width(); newRenderTargetHeight = renderTargetHeight = iron_height(); @@ -47,32 +47,32 @@ void iron_gpu_init(int depthBufferBits, bool vsync) { swapChain = wgpuDeviceCreateSwapChain(device, surface, &scDesc); } -void iron_gpu_begin(iron_gpu_texture_t *renderTarget) {} +void gpu_begin(gpu_texture_t *renderTarget) {} -void iron_gpu_end() {} +void gpu_end() {} -bool iron_gpu_raytrace_supported() { +bool gpu_raytrace_supported() { return false; } extern WGPUDevice device; -iron_gpu_buffer_t *iron_gpu_internal_current_vertex_buffer = NULL; +gpu_buffer_t *gpu_internal_current_vertex_buffer = NULL; -void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, bool gpuMemory) { +void gpu_vertex_buffer_init(gpu_buffer_t *buffer, int count, gpu_vertex_structure_t *structure) { buffer->count = count; buffer->impl.count = count; buffer->impl.stride = 0; for (int i = 0; i < structure->size; ++i) { - buffer->impl.stride += iron_gpu_vertex_data_size(structure->elements[i].data); + buffer->impl.stride += gpu_vertex_data_size(structure->elements[i].data); } } -void iron_gpu_vertex_buffer_destroy(iron_gpu_buffer_t *buffer) { +void gpu_vertex_buffer_destroy(gpu_buffer_t *buffer) { } -float *iron_gpu_vertex_buffer_lock(iron_gpu_buffer_t *buffer) { +float *gpu_vertex_buffer_lock(gpu_buffer_t *buffer) { WGPUBufferDescriptor bDesc; memset(&bDesc, 0, sizeof(bDesc)); bDesc.size = buffer->impl.count * buffer->impl.stride * sizeof(float); @@ -82,75 +82,74 @@ float *iron_gpu_vertex_buffer_lock(iron_gpu_buffer_t *buffer) { return wgpuBufferGetMappedRange(buffer->impl.buffer, 0, bDesc.size); } -void iron_gpu_vertex_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_vertex_buffer_unlock(gpu_buffer_t *buffer) { wgpuBufferUnmap(buffer->impl.buffer); } -int iron_gpu_vertex_buffer_count(iron_gpu_buffer_t *buffer) { +int gpu_vertex_buffer_count(gpu_buffer_t *buffer) { return buffer->impl.count; } -int iron_gpu_vertex_buffer_stride(iron_gpu_buffer_t *buffer) { +int gpu_vertex_buffer_stride(gpu_buffer_t *buffer) { return buffer->impl.stride; } -bool iron_gpu_transpose_mat = false; - -void iron_gpu_constant_buffer_init(iron_gpu_buffer_t *buffer, int size) { +bool gpu_transpose_mat = false; +void gpu_constant_buffer_init(gpu_buffer_t *buffer, int size) { } -void iron_gpu_constant_buffer_destroy(iron_gpu_buffer_t *buffer) {} - -void iron_gpu_constant_buffer_lock(iron_gpu_buffer_t *buffer, int start, int count) {} - -void iron_gpu_constant_buffer_unlock(iron_gpu_buffer_t *buffer) { - +void gpu_constant_buffer_destroy(gpu_buffer_t *buffer) { } -int iron_gpu_constant_buffer_size(iron_gpu_buffer_t *buffer) { +void gpu_constant_buffer_lock(gpu_buffer_t *buffer, int start, int count) { +} + +void gpu_constant_buffer_unlock(gpu_buffer_t *buffer) { +} + +int gpu_constant_buffer_size(gpu_buffer_t *buffer) { return 0; } -iron_gpu_buffer_t *iron_gpu_internal_current_index_buffer = NULL; +gpu_buffer_t *gpu_internal_current_index_buffer = NULL; -void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int count, bool gpuMemory) { +void gpu_index_buffer_init(gpu_buffer_t *buffer, int count) { buffer->impl.count = count; } -void iron_gpu_index_buffer_destroy(iron_gpu_buffer_t *buffer) { - +void gpu_index_buffer_destroy(gpu_buffer_t *buffer) { } -static int iron_gpu_internal_index_buffer_stride(iron_gpu_buffer_t *buffer) { +static int gpu_internal_index_buffer_stride(gpu_buffer_t *buffer) { return 4; } -void *iron_gpu_index_buffer_lock(iron_gpu_buffer_t *buffer) { +void *gpu_index_buffer_lock(gpu_buffer_t *buffer) { int start = 0; - int count = iron_gpu_index_buffer_count(buffer); + int count = gpu_index_buffer_count(buffer); WGPUBufferDescriptor bDesc; memset(&bDesc, 0, sizeof(bDesc)); - bDesc.size = count * iron_gpu_internal_index_buffer_stride(buffer); + bDesc.size = count * 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_gpu_internal_index_buffer_stride(buffer), bDesc.size); + return wgpuBufferGetMappedRange(buffer->impl.buffer, start * gpu_internal_index_buffer_stride(buffer), bDesc.size); } -void iron_gpu_index_buffer_unlock(iron_gpu_buffer_t *buffer) { +void gpu_index_buffer_unlock(gpu_buffer_t *buffer) { wgpuBufferUnmap(buffer->impl.buffer); } -void iron_gpu_internal_index_buffer_set(iron_gpu_buffer_t *buffer) { +void gpu_internal_index_buffer_set(gpu_buffer_t *buffer) { } -int iron_gpu_index_buffer_count(iron_gpu_buffer_t *buffer) { +int gpu_index_buffer_count(gpu_buffer_t *buffer) { return buffer->impl.count; } -void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, iron_image_format_t format) { +void gpu_texture_init(gpu_texture_t *texture, int width, int height, iron_image_format_t format) { // WGPUExtent3D size = {}; // size.width = iron_width(); // size.height = iron_height(); @@ -176,20 +175,20 @@ void iron_gpu_texture_init(iron_gpu_texture_t *texture, int width, int height, i texture->data = NULL; } -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_destroy(iron_gpu_texture_t *texture) {} +void gpu_texture_init_from_bytes(gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format) {} +void gpu_texture_init_from_encoded_data(gpu_texture_t *texture, void *data, int size, const char *format, bool readable) {} +void gpu_texture_init_from_data(gpu_texture_t *texture, void *data, int width, int height, int format, bool readable) {} +void gpu_texture_destroy(gpu_texture_t *texture) {} -int iron_gpu_texture_stride(iron_gpu_texture_t *texture) { +int gpu_texture_stride(gpu_texture_t *texture) { return 32; } -void iron_gpu_texture_generate_mipmaps(iron_gpu_texture_t *texture, int levels) {} +void gpu_texture_generate_mipmaps(gpu_texture_t *texture, int levels) {} -void iron_gpu_texture_set_mipmap(iron_gpu_texture_t *texture, iron_gpu_texture_t *mipmap, int level) {} +void gpu_texture_set_mipmap(gpu_texture_t *texture, gpu_texture_t *mipmap, int level) {} -void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) { +void gpu_render_target_init(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; @@ -197,17 +196,17 @@ void iron_gpu_render_target_init(iron_gpu_texture_t *target, int width, int heig target->uploaded = true; } -void iron_gpu_render_target_init_framebuffer(iron_gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits) {} +void gpu_render_target_init_framebuffer(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 *renderTarget, iron_gpu_texture_t *source) {} +void gpu_render_target_set_depth_from(gpu_texture_t *renderTarget, gpu_texture_t *source) {} extern WGPUDevice device; -void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipe) { +void gpu_pipeline_init(gpu_pipeline_t *pipe) { gpu_internal_pipeline_init(pipe); } -void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipe) { +void gpu_pipeline_compile(gpu_pipeline_t *pipe) { WGPUColorTargetState csDesc; memset(&csDesc, 0, sizeof(csDesc)); csDesc.format = WGPUTextureFormat_BGRA8Unorm; @@ -233,24 +232,24 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipe) { for (int i = 0; i < pipe->input_layout->size; ++i) { vaDesc[i].shaderLocation = i; vaDesc[i].offset = offset; - offset += iron_gpu_vertex_data_size(pipe->input_layout->elements[i].data); + offset += gpu_vertex_data_size(pipe->input_layout->elements[i].data); switch (pipe->input_layout->elements[i].data) { - case IRON_GPU_VERTEX_DATA_F32_1X: + case GPU_VERTEX_DATA_F32_1X: vaDesc[i].format = WGPUVertexFormat_Float32; break; - case IRON_GPU_VERTEX_DATA_F32_2X: + case GPU_VERTEX_DATA_F32_2X: vaDesc[i].format = WGPUVertexFormat_Float32x2; break; - case IRON_GPU_VERTEX_DATA_F32_3X: + case GPU_VERTEX_DATA_F32_3X: vaDesc[i].format = WGPUVertexFormat_Float32x3; break; - case IRON_GPU_VERTEX_DATA_F32_4X: + case GPU_VERTEX_DATA_F32_4X: vaDesc[i].format = WGPUVertexFormat_Float32x4; break; - case IRON_GPU_VERTEX_DATA_I16_2X_NORM: + case GPU_VERTEX_DATA_I16_2X_NORM: vaDesc[i].format = WGPUVertexFormat_Snorm16x2; break; - case IRON_GPU_VERTEX_DATA_I16_4X_NORM: + case GPU_VERTEX_DATA_I16_4X_NORM: vaDesc[i].format = WGPUVertexFormat_Snorm16x4; break; } @@ -303,7 +302,7 @@ void iron_gpu_pipeline_compile(iron_gpu_pipeline_t *pipe) { pipe->impl.pipeline = wgpuDeviceCreateRenderPipeline(device, &rpDesc); } -void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *source, size_t length, iron_gpu_shader_type_t type) { +void gpu_shader_init(gpu_shader_t *shader, const void *source, size_t length, gpu_shader_type_t type) { WGPUShaderModuleSPIRVDescriptor smSpirvDesc; memset(&smSpirvDesc, 0, sizeof(smSpirvDesc)); smSpirvDesc.chain.sType = WGPUSType_ShaderModuleSPIRVDescriptor; @@ -315,13 +314,13 @@ void iron_gpu_shader_init(iron_gpu_shader_t *shader, const void *source, size_t shader->impl.module = wgpuDeviceCreateShaderModule(device, &smDesc); } -void iron_gpu_shader_destroy(iron_gpu_shader_t *shader) {} +void gpu_shader_destroy(gpu_shader_t *shader) {} -void iron_gpu_command_list_init(iron_gpu_command_list_t *list) {} +void gpu_command_list_init(gpu_command_list_t *list) {} -void iron_gpu_command_list_destroy(iron_gpu_command_list_t *list) {} +void gpu_command_list_destroy(gpu_command_list_t *list) {} -void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { +void gpu_command_list_begin(gpu_command_list_t *list) { WGPUCommandEncoderDescriptor ceDesc; memset(&ceDesc, 0, sizeof(ceDesc)); list->impl.encoder = wgpuDeviceCreateCommandEncoder(device, &ceDesc); @@ -342,7 +341,7 @@ void iron_gpu_command_list_begin(iron_gpu_command_list_t *list) { list->impl.pass = wgpuCommandEncoderBeginRenderPass(list->impl.encoder, &passDesc); } -void iron_gpu_command_list_end(iron_gpu_command_list_t *list) { +void gpu_command_list_end(gpu_command_list_t *list) { wgpuRenderPassEncoderEnd(list->impl.pass); WGPUCommandBufferDescriptor cbDesc; @@ -351,61 +350,61 @@ void iron_gpu_command_list_end(iron_gpu_command_list_t *list) { wgpuQueueSubmit(queue, 1, &commands); } -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 gpu_command_list_render_target_to_framebuffer_barrier(gpu_command_list_t *list, struct gpu_texture *renderTarget) {} +void gpu_command_list_framebuffer_to_render_target_barrier(gpu_command_list_t *list, struct gpu_texture *renderTarget) {} +void gpu_command_list_texture_to_render_target_barrier(gpu_command_list_t *list, struct gpu_texture *renderTarget) {} +void gpu_command_list_render_target_to_texture_barrier(gpu_command_list_t *list, struct gpu_texture *renderTarget) {} -void iron_gpu_command_list_draw(iron_gpu_command_list_t *list) { +void gpu_command_list_draw(gpu_command_list_t *list) { wgpuRenderPassEncoderDrawIndexed(list->impl.pass, list->impl.indexCount, 1, 0, 0, 0); } -void iron_gpu_command_list_viewport(iron_gpu_command_list_t *list, int x, int y, int width, int height) { +void gpu_command_list_viewport(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 gpu_command_list_scissor(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 gpu_command_list_disable_scissor(gpu_command_list_t *list) {} -void iron_gpu_command_list_set_pipeline(iron_gpu_command_list_t *list, struct iron_gpu_pipeline *pipeline) { +void gpu_command_list_set_pipeline(gpu_command_list_t *list, struct gpu_pipeline *pipeline) { wgpuRenderPassEncoderSetPipeline(list->impl.pass, pipeline->impl.pipeline); } -void iron_gpu_command_list_set_pipeline_layout(iron_gpu_command_list_t *list) {} +void gpu_command_list_set_pipeline_layout(gpu_command_list_t *list) {} -void iron_gpu_command_list_set_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_buffer *buffer) { - uint64_t size = (iron_gpu_vertex_buffer_count(buffer)) * iron_gpu_vertex_buffer_stride(buffer); +void gpu_command_list_set_vertex_buffer(gpu_command_list_t *list, struct gpu_buffer *buffer) { + uint64_t size = (gpu_vertex_buffer_count(buffer)) * gpu_vertex_buffer_stride(buffer); wgpuRenderPassEncoderSetVertexBuffer(list->impl.pass, 0, buffer->impl.buffer, 0, size); } -void iron_gpu_command_list_set_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_buffer *buffer) { - list->impl.indexCount = iron_gpu_index_buffer_count(buffer); - uint64_t size = iron_gpu_index_buffer_count(buffer) * sizeof(int); +void gpu_command_list_set_index_buffer(gpu_command_list_t *list, struct gpu_buffer *buffer) { + list->impl.indexCount = gpu_index_buffer_count(buffer); + uint64_t size = gpu_index_buffer_count(buffer) * sizeof(int); wgpuRenderPassEncoderSetIndexBuffer(list->impl.pass, buffer->impl.buffer, WGPUIndexFormat_Uint32, 0, size); } -void iron_gpu_command_list_set_render_targets(iron_gpu_command_list_t *list, struct iron_gpu_texture **targets, int count, unsigned flags, unsigned color, float depth) { +void gpu_command_list_set_render_targets(gpu_command_list_t *list, struct gpu_texture **targets, int count, unsigned flags, unsigned color, float depth) { } -void iron_gpu_command_list_upload_index_buffer(iron_gpu_command_list_t *list, struct iron_gpu_buffer *buffer) {} -void iron_gpu_command_list_upload_vertex_buffer(iron_gpu_command_list_t *list, struct iron_gpu_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 gpu_command_list_upload_index_buffer(gpu_command_list_t *list, struct gpu_buffer *buffer) {} +void gpu_command_list_upload_vertex_buffer(gpu_command_list_t *list, struct gpu_buffer *buffer) {} +void gpu_command_list_upload_texture(gpu_command_list_t *list, struct gpu_texture *texture) {} +void gpu_command_list_get_render_target_pixels(gpu_command_list_t *list, gpu_texture_t *render_target, uint8_t *data) {} -void iron_gpu_command_list_wait(iron_gpu_command_list_t *list) { +void gpu_command_list_wait(gpu_command_list_t *list) { } -void iron_gpu_command_list_set_constant_buffer(iron_gpu_command_list_t *list, struct iron_gpu_buffer *buffer, int offset, size_t size) { +void gpu_command_list_set_constant_buffer(gpu_command_list_t *list, struct gpu_buffer *buffer, int offset, size_t size) { } -void iron_gpu_command_list_set_texture(iron_gpu_command_list_t *list, int unit, iron_gpu_texture_t *texture) { +void gpu_command_list_set_texture(gpu_command_list_t *list, int unit, gpu_texture_t *texture) { } -void iron_gpu_set_texture_depth(iron_gpu_command_list_t *list, int unit, iron_gpu_texture_t *renderTarget) {} +void gpu_set_texture_depth(gpu_command_list_t *list, int unit, gpu_texture_t *renderTarget) {} diff --git a/base/sources/backends/windows_system.c b/base/sources/backends/windows_system.c index aa33e254..67953aa2 100644 --- a/base/sources/backends/windows_system.c +++ b/base/sources/backends/windows_system.c @@ -408,7 +408,7 @@ void iron_mouse_get_position(int *x, int *y) { __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; -void iron_gpu_internal_resize(int width, int height); +void gpu_internal_resize(int width, int height); typedef BOOL(WINAPI *GetPointerInfoType)(UINT32 pointerId, POINTER_INFO *pointerInfo); static GetPointerInfoType MyGetPointerInfo = NULL; @@ -653,7 +653,7 @@ LRESULT WINAPI IronWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L case WM_SIZE: { int width = LOWORD(lParam); int height = HIWORD(lParam); - iron_gpu_internal_resize(width, height); + gpu_internal_resize(width, height); iron_internal_call_resize_callback(width, height); break; } @@ -1691,7 +1691,7 @@ void iron_internal_shutdown() { iron_windows_hide_windows(); iron_internal_shutdown_callback(); iron_windows_destroy_windows(); - iron_gpu_destroy(); + gpu_destroy(); iron_windows_restore_displays(); } diff --git a/base/sources/backends/windows_video.c b/base/sources/backends/windows_video.c index 700938d0..f2737a60 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_gpu_texture_t *iron_video_current_image(iron_video_t *video) { +// 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 5cfef8f7..8bdfad6d 100644 --- a/base/sources/iron.h +++ b/base/sources/iron.h @@ -374,10 +374,10 @@ const char *iphonegetresourcepath(); char mobile_title[1024]; #endif -static iron_gpu_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 gpu_buffer_t constant_buffer; +static gpu_texture_t *render_target; +static gpu_raytrace_pipeline_t rt_pipeline; +static gpu_raytrace_acceleration_structure_t accel; static bool raytrace_created = false; static bool raytrace_accel_created = false; const int constant_buffer_size = 24; @@ -419,7 +419,7 @@ void _update(void *data) { #endif iron_update(); - iron_gpu_present(); + gpu_present(); } char *_copy(void *data) { @@ -917,46 +917,46 @@ void iron_show_keyboard(bool show) { } any gpu_create_index_buffer(i32 count) { - iron_gpu_buffer_t *buffer = (iron_gpu_buffer_t *)malloc(sizeof(iron_gpu_buffer_t)); - iron_gpu_index_buffer_init(buffer, count, GPU_USAGE_STATIC); + gpu_buffer_t *buffer = (gpu_buffer_t *)malloc(sizeof(gpu_buffer_t)); + gpu_index_buffer_init(buffer, count); return buffer; } -void gpu_delete_index_buffer(iron_gpu_buffer_t *buffer) { - iron_gpu_index_buffer_destroy(buffer); +void gpu_delete_index_buffer(gpu_buffer_t *buffer) { + gpu_index_buffer_destroy(buffer); free(buffer); } -u32_array_t *gpu_lock_index_buffer(iron_gpu_buffer_t *buffer) { - void *vertices = iron_gpu_index_buffer_lock(buffer); +u32_array_t *gpu_lock_index_buffer(gpu_buffer_t *buffer) { + void *vertices = gpu_index_buffer_lock(buffer); u32_array_t *ar = (u32_array_t *)malloc(sizeof(u32_array_t)); ar->buffer = vertices; - ar->length = iron_gpu_index_buffer_count(buffer); + ar->length = gpu_index_buffer_count(buffer); return ar; } -any gpu_create_vertex_buffer(i32 count, iron_gpu_vertex_structure_t *structure, i32 usage) { - iron_gpu_buffer_t *buffer = (iron_gpu_buffer_t *)malloc(sizeof(iron_gpu_buffer_t)); - iron_gpu_vertex_buffer_init(buffer, count, structure, (gpu_usage_t)usage == GPU_USAGE_STATIC); +any gpu_create_vertex_buffer(i32 count, gpu_vertex_structure_t *structure, i32 usage) { + gpu_buffer_t *buffer = (gpu_buffer_t *)malloc(sizeof(gpu_buffer_t)); + gpu_vertex_buffer_init(buffer, count, structure); return buffer; } -void gpu_delete_vertex_buffer(iron_gpu_buffer_t *buffer) { - iron_gpu_vertex_buffer_destroy(buffer); +void gpu_delete_vertex_buffer(gpu_buffer_t *buffer) { + gpu_vertex_buffer_destroy(buffer); free(buffer); } -buffer_t *gpu_lock_vertex_buffer(iron_gpu_buffer_t *buffer) { - float *vertices = iron_gpu_vertex_buffer_lock(buffer); +buffer_t *gpu_lock_vertex_buffer(gpu_buffer_t *buffer) { + float *vertices = gpu_vertex_buffer_lock(buffer); buffer_t *b = (buffer_t *)malloc(sizeof(buffer_t)); b->buffer = vertices; - b->length = buffer->count * iron_gpu_vertex_buffer_stride(buffer); + b->length = buffer->count * gpu_vertex_buffer_stride(buffer); return b; } -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); +gpu_shader_t *gpu_create_shader(buffer_t *data, i32 shader_type) { + gpu_shader_t *shader = (gpu_shader_t *)malloc(sizeof(gpu_shader_t)); + gpu_shader_init(shader, data->buffer, data->length, (gpu_shader_type_t)shader_type); return shader; } @@ -1043,9 +1043,9 @@ void gpu_create_shaders_from_kong(char *kong, char **vs, char **fs, int *vs_size #endif -iron_gpu_shader_t *gpu_create_shader_from_source(string_t *source, int source_size, iron_gpu_shader_type_t shader_type) { - iron_gpu_shader_t *shader = (iron_gpu_shader_t *)malloc(sizeof(iron_gpu_shader_t)); - char *temp_string_s = shader_type == IRON_GPU_SHADER_TYPE_VERTEX ? temp_string_vs : temp_string_fs; +gpu_shader_t *gpu_create_shader_from_source(string_t *source, int source_size, gpu_shader_type_t shader_type) { + gpu_shader_t *shader = (gpu_shader_t *)malloc(sizeof(gpu_shader_t)); + char *temp_string_s = shader_type == GPU_SHADER_TYPE_VERTEX ? temp_string_vs : temp_string_fs; #ifdef WITH_D3DCOMPILER @@ -1055,43 +1055,43 @@ iron_gpu_shader_t *gpu_create_shader_from_source(string_t *source, int source_si 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_GPU_SHADER_TYPE_VERTEX ? "vs_5_0" : "ps_5_0", flags, 0, &shader_buffer, &error_message); + shader_type == 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; } int size = shader_buffer->lpVtbl->GetBufferSize(shader_buffer); - iron_gpu_shader_init(shader, (char *)shader_buffer->lpVtbl->GetBufferPointer(shader_buffer), size, shader_type); + gpu_shader_init(shader, (char *)shader_buffer->lpVtbl->GetBufferPointer(shader_buffer), size, shader_type); shader_buffer->lpVtbl->Release(shader_buffer); #elif defined(IRON_METAL) strcpy(temp_string_s, source); - iron_gpu_shader_init(shader, temp_string_s, strlen(temp_string_s), shader_type); + gpu_shader_init(shader, temp_string_s, strlen(temp_string_s), shader_type); #elif defined(IRON_VULKAN) - iron_gpu_shader_init(shader, source, source_size, shader_type); + gpu_shader_init(shader, source, source_size, shader_type); #endif return shader; } -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); +gpu_pipeline_t *gpu_create_pipeline() { + gpu_pipeline_t *pipeline = (gpu_pipeline_t *)malloc(sizeof(gpu_pipeline_t)); + gpu_pipeline_init(pipeline); return pipeline; } -void gpu_delete_pipeline(iron_gpu_pipeline_t *pipeline) { - iron_gpu_pipeline_destroy(pipeline); +void gpu_delete_pipeline(gpu_pipeline_t *pipeline) { + gpu_pipeline_destroy(pipeline); free(pipeline); } -void gpu_compile_pipeline(iron_gpu_pipeline_t *pipeline) { - iron_gpu_pipeline_compile(pipeline); +void gpu_compile_pipeline(gpu_pipeline_t *pipeline) { + 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) { @@ -1161,13 +1161,13 @@ bool _load_image(iron_file_reader_t *reader, const char *filename, unsigned char return success; } -iron_gpu_texture_t *gpu_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable); +gpu_texture_t *gpu_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable); -iron_gpu_texture_t *iron_load_image(string_t *file, bool readable) { +gpu_texture_t *iron_load_image(string_t *file, bool readable) { #ifdef WITH_EMBED buffer_t *b = embed_get(file); if (b != NULL) { - iron_gpu_texture_t *texture = gpu_create_texture_from_encoded_bytes(b, ".k", readable); + gpu_texture_t *texture = gpu_create_texture_from_encoded_bytes(b, ".k", readable); return texture; } #endif @@ -1185,8 +1185,8 @@ iron_gpu_texture_t *iron_load_image(string_t *file, bool readable) { return NULL; } - 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); + gpu_texture_t *texture = (gpu_texture_t *)malloc(sizeof(gpu_texture_t)); + gpu_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); if (!readable) { free(image_data); } @@ -1194,9 +1194,9 @@ iron_gpu_texture_t *iron_load_image(string_t *file, bool readable) { return texture; } -void iron_unload_image(iron_gpu_texture_t *image) { +void iron_unload_image(gpu_texture_t *image) { if (image != NULL) { - iron_gpu_texture_destroy(image); + gpu_texture_destroy(image); // free(image); } } @@ -1268,15 +1268,15 @@ bool iron_display_is_primary(i32 index) { return index == iron_primary_display(); } -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); +gpu_texture_t *gpu_create_render_target(i32 width, i32 height, i32 format, i32 depth_buffer_bits) { + gpu_texture_t *render_target = (gpu_texture_t *)malloc(sizeof(gpu_texture_t)); + gpu_render_target_init(render_target, width, height, (iron_image_format_t)format, depth_buffer_bits); render_target->buffer = NULL; return render_target; } -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)); +gpu_texture_t *gpu_create_texture_from_bytes(buffer_t *data, i32 width, i32 height, i32 format, bool readable) { + gpu_texture_t *texture = (gpu_texture_t *)malloc(sizeof(gpu_texture_t)); texture->buffer = NULL; void *image_data; if (readable) { @@ -1286,12 +1286,12 @@ iron_gpu_texture_t *gpu_create_texture_from_bytes(buffer_t *data, i32 width, i32 else { image_data = data->buffer; } - iron_gpu_texture_init_from_bytes(texture, image_data, width, height, (iron_image_format_t)format); + gpu_texture_init_from_bytes(texture, image_data, width, height, (iron_image_format_t)format); return texture; } -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)); +gpu_texture_t *gpu_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable) { + gpu_texture_t *texture = (gpu_texture_t *)malloc(sizeof(gpu_texture_t)); texture->buffer = NULL; unsigned char *content_data = (unsigned char *)data->buffer; @@ -1335,7 +1335,7 @@ iron_gpu_texture_t *gpu_create_texture_from_encoded_bytes(buffer_t *data, string image_format = IRON_IMAGE_FORMAT_RGBA32; } - iron_gpu_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); + gpu_texture_init_from_bytes(texture, image_data, image_width, image_height, image_format); if (!readable) { free(image_data);; } @@ -1360,7 +1360,7 @@ int _format_byte_size(iron_image_format_t format) { } } -buffer_t *gpu_get_texture_pixels(iron_gpu_texture_t *image) { +buffer_t *gpu_get_texture_pixels(gpu_texture_t *image) { if (image->buffer == NULL) { image->buffer = malloc(sizeof(buffer_t)); image->buffer->buffer = NULL; @@ -1373,12 +1373,12 @@ buffer_t *gpu_get_texture_pixels(iron_gpu_texture_t *image) { } uint8_t *b = (uint8_t *)image->buffer->buffer; - iron_gpu_get_render_target_pixels(image, b); + gpu_get_render_target_pixels(image, b); // Release staging texture immediately to save memory #ifdef IRON_DIRECT3D12 - image->impl.renderTargetReadback->lpVtbl->Release(image->impl.renderTargetReadback); - image->impl.renderTargetReadback = NULL; + image->impl.readback->lpVtbl->Release(image->impl.readback); + image->impl.readback = NULL; #elif defined(IRON_METAL) // id texReadback = (__bridge_transfer id)image->impl._texReadback; // texReadback = nil; @@ -1391,28 +1391,28 @@ buffer_t *gpu_get_texture_pixels(iron_gpu_texture_t *image) { return image->buffer; } -void gpu_set_mipmaps(iron_gpu_texture_t *texture, any_array_t *mipmaps) { +void gpu_set_mipmaps(gpu_texture_t *texture, any_array_t *mipmaps) { for (int32_t i = 0; i < mipmaps->length; ++i) { - 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); + gpu_texture_t *img = mipmaps->buffer[i]; + gpu_texture_t *img_tex = img; + gpu_texture_set_mipmap(texture, img_tex, i + 1); } } -void _gpu_begin(iron_gpu_texture_t *render_target, any_array_t *additional, unsigned flags, unsigned color, float depth) { +void _gpu_begin(gpu_texture_t *render_target, any_array_t *additional, unsigned flags, unsigned color, float depth) { if (render_target == NULL) { - iron_gpu_begin(NULL, 0, flags, color, depth); + gpu_begin(NULL, 0, flags, color, depth); } else { int32_t length = 1; - iron_gpu_texture_t *render_targets[8] = { render_target, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + gpu_texture_t *render_targets[8] = { render_target, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; if (additional != NULL) { length = additional->length + 1; for (int32_t i = 1; i < length; ++i) { render_targets[i] = additional->buffer[i - 1]; } } - iron_gpu_begin(render_targets, length, flags, color, depth); + gpu_begin(render_targets, length, flags, color, depth); } } @@ -2103,64 +2103,64 @@ void iron_ml_unload() { void iron_raytrace_init(buffer_t *shader) { if (raytrace_created) { - iron_gpu_constant_buffer_destroy(&constant_buffer); - iron_gpu_raytrace_pipeline_destroy(&rt_pipeline); + gpu_constant_buffer_destroy(&constant_buffer); + gpu_raytrace_pipeline_destroy(&rt_pipeline); } raytrace_created = true; - iron_gpu_constant_buffer_init(&constant_buffer, constant_buffer_size * 4); - iron_gpu_raytrace_pipeline_init(&rt_pipeline, shader->buffer, (int)shader->length, &constant_buffer); + gpu_constant_buffer_init(&constant_buffer, constant_buffer_size * 4); + gpu_raytrace_pipeline_init(&rt_pipeline, shader->buffer, (int)shader->length, &constant_buffer); } void iron_raytrace_as_init() { if (raytrace_accel_created) { - iron_gpu_raytrace_acceleration_structure_destroy(&accel); + gpu_raytrace_acceleration_structure_destroy(&accel); } raytrace_accel_created = true; - iron_gpu_raytrace_acceleration_structure_init(&accel); + gpu_raytrace_acceleration_structure_init(&accel); } -void iron_raytrace_as_add(struct iron_gpu_buffer *vb, iron_gpu_buffer_t *ib, iron_matrix4x4_t transform) { - iron_gpu_raytrace_acceleration_structure_add(&accel, vb, ib, transform); +void iron_raytrace_as_add(struct gpu_buffer *vb, gpu_buffer_t *ib, iron_matrix4x4_t transform) { + gpu_raytrace_acceleration_structure_add(&accel, vb, ib, transform); } -void iron_raytrace_as_build(struct iron_gpu_buffer *vb_full, iron_gpu_buffer_t *ib_full) { - iron_gpu_raytrace_acceleration_structure_build(&accel, vb_full, ib_full); +void iron_raytrace_as_build(struct gpu_buffer *vb_full, gpu_buffer_t *ib_full) { + gpu_raytrace_acceleration_structure_build(&accel, vb_full, ib_full); } -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) { +void iron_raytrace_set_textures(gpu_texture_t *tex0, gpu_texture_t *tex1, gpu_texture_t *tex2, gpu_texture_t *texenv, gpu_texture_t *texsobol, gpu_texture_t *texscramble, gpu_texture_t *texrank) { if (!texenv->uploaded) { - iron_gpu_upload_texture(texenv); + gpu_upload_texture(texenv); texenv->uploaded = true; } if (!texsobol->uploaded) { - iron_gpu_upload_texture(texsobol); + gpu_upload_texture(texsobol); texsobol->uploaded = true; } if (!texscramble->uploaded) { - iron_gpu_upload_texture(texscramble); + gpu_upload_texture(texscramble); texscramble->uploaded = true; } if (!texrank->uploaded) { - iron_gpu_upload_texture(texrank); + gpu_upload_texture(texrank); texrank->uploaded = true; } - iron_gpu_raytrace_set_textures(tex0, tex1, tex2, texenv, texsobol, texscramble, texrank); + gpu_raytrace_set_textures(tex0, tex1, tex2, texenv, texsobol, texscramble, texrank); } -void iron_raytrace_dispatch_rays(iron_gpu_texture_t *render_target, buffer_t *buffer) { +void iron_raytrace_dispatch_rays(gpu_texture_t *render_target, buffer_t *buffer) { float *cb = (float *)buffer->buffer; - iron_gpu_constant_buffer_lock(&constant_buffer, 0, iron_gpu_constant_buffer_size(&constant_buffer)); + gpu_constant_buffer_lock(&constant_buffer, 0, gpu_constant_buffer_size(&constant_buffer)); for (int i = 0; i < constant_buffer_size; ++i) { float *floats = (float *)(&constant_buffer.data[i * 4]); floats[0] = cb[i]; } - iron_gpu_constant_buffer_unlock(&constant_buffer); + gpu_constant_buffer_unlock(&constant_buffer); - 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(); + gpu_raytrace_set_acceleration_structure(&accel); + gpu_raytrace_set_pipeline(&rt_pipeline); + gpu_raytrace_set_target(render_target); + gpu_raytrace_dispatch_rays(); } #endif diff --git a/base/sources/iron_draw.c b/base/sources/iron_draw.c index ef3d1b93..3cbb1ff4 100644 --- a/base/sources/iron_draw.c +++ b/base/sources/iron_draw.c @@ -14,51 +14,51 @@ draw_font_t *draw_font = NULL; int draw_font_size; -iron_gpu_texture_t *_draw_current = NULL; +gpu_texture_t *_draw_current = NULL; bool _draw_in_use = false; static iron_matrix4x4_t draw_projection_matrix; static iron_matrix3x3_t draw_transform; static bool draw_bilinear_filter = true; static uint32_t draw_color = 0; -static iron_gpu_pipeline_t *draw_custom_pipeline = NULL; +static gpu_pipeline_t *draw_custom_pipeline = NULL; static bool _draw_thrown = false; -static iron_gpu_buffer_t rect_vertex_buffer; -static iron_gpu_buffer_t rect_index_buffer; -static iron_gpu_buffer_t tris_vertex_buffer; -static iron_gpu_buffer_t tris_index_buffer; -static iron_gpu_vertex_structure_t draw_structure; +static gpu_buffer_t rect_vertex_buffer; +static gpu_buffer_t rect_index_buffer; +static gpu_buffer_t tris_vertex_buffer; +static gpu_buffer_t tris_index_buffer; +static gpu_vertex_structure_t draw_structure; -static iron_gpu_shader_t image_vert_shader; -static iron_gpu_shader_t image_frag_shader; -static iron_gpu_pipeline_t image_pipeline; +static gpu_shader_t image_vert_shader; +static gpu_shader_t image_frag_shader; +static gpu_pipeline_t image_pipeline; static int image_tex_unit; static int image_p_loc; static int image_pos_loc; static int image_tex_loc; static int image_col_loc; -static iron_gpu_shader_t rect_vert_shader; -static iron_gpu_shader_t rect_frag_shader; -static iron_gpu_pipeline_t rect_pipeline; +static gpu_shader_t rect_vert_shader; +static gpu_shader_t rect_frag_shader; +static gpu_pipeline_t rect_pipeline; static int rect_p_loc; static int rect_pos_loc; static int rect_col_loc; -static iron_gpu_shader_t tris_vert_shader; -static iron_gpu_shader_t tris_frag_shader; -static iron_gpu_pipeline_t tris_pipeline; +static gpu_shader_t tris_vert_shader; +static gpu_shader_t tris_frag_shader; +static gpu_pipeline_t tris_pipeline; static int tris_p_loc; static int tris_pos0_loc; static int tris_pos1_loc; static int tris_pos2_loc; static int tris_col_loc; -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 gpu_shader_t text_vert_shader; +static gpu_shader_t text_frag_shader; +static gpu_pipeline_t text_pipeline; +static gpu_pipeline_t text_pipeline_rt; static int text_tex_unit; static int text_p_loc; static int text_pos_loc; @@ -97,13 +97,13 @@ static int vh() { return _draw_current != NULL ? _draw_current->height : iron_window_height(); } -static void draw_pipeline_init(iron_gpu_pipeline_t *pipe, iron_gpu_shader_t *vert, iron_gpu_shader_t *frag) { - iron_gpu_pipeline_init(pipe); +static void draw_pipeline_init(gpu_pipeline_t *pipe, gpu_shader_t *vert, gpu_shader_t *frag) { + gpu_pipeline_init(pipe); pipe->input_layout = &draw_structure; - pipe->blend_source = IRON_GPU_BLEND_ONE; - pipe->blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; - pipe->alpha_blend_source = IRON_GPU_BLEND_ONE; - pipe->alpha_blend_destination = IRON_GPU_BLEND_INV_SOURCE_ALPHA; + pipe->blend_source = GPU_BLEND_ONE; + pipe->blend_destination = GPU_BLEND_INV_SOURCE_ALPHA; + pipe->alpha_blend_source = GPU_BLEND_ONE; + pipe->alpha_blend_destination = GPU_BLEND_INV_SOURCE_ALPHA; pipe->vertex_shader = vert; pipe->fragment_shader = frag; } @@ -111,11 +111,11 @@ static void draw_pipeline_init(iron_gpu_pipeline_t *pipe, iron_gpu_shader_t *ver void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, buffer_t *rect_frag, buffer_t *tris_vert, buffer_t *tris_frag, buffer_t *text_vert, buffer_t *text_frag) { draw_transform = iron_matrix3x3_identity(); draw_structure.size = 0; - gpu_vertex_structure_add(&draw_structure, "pos", IRON_GPU_VERTEX_DATA_F32_2X); + gpu_vertex_structure_add(&draw_structure, "pos", GPU_VERTEX_DATA_F32_2X); { - iron_gpu_vertex_buffer_init(&rect_vertex_buffer, 4, &draw_structure, true); - float *verts = iron_gpu_vertex_buffer_lock(&rect_vertex_buffer); + gpu_vertex_buffer_init(&rect_vertex_buffer, 4, &draw_structure); + float *verts = gpu_vertex_buffer_lock(&rect_vertex_buffer); verts[0] = 0.0; // Bottom-left verts[1] = 1.0; verts[2] = 0.0; // Top-left @@ -124,44 +124,44 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, verts[5] = 0.0; verts[6] = 1.0; // Bottom-right verts[7] = 1.0; - iron_gpu_vertex_buffer_unlock(&rect_vertex_buffer); + gpu_vertex_buffer_unlock(&rect_vertex_buffer); - iron_gpu_index_buffer_init(&rect_index_buffer, 3 * 2, true); - int *indices = iron_gpu_index_buffer_lock(&rect_index_buffer); + gpu_index_buffer_init(&rect_index_buffer, 3 * 2); + int *indices = gpu_index_buffer_lock(&rect_index_buffer); indices[0] = 0; indices[1] = 1; indices[2] = 2; indices[3] = 0; indices[4] = 2; indices[5] = 3; - iron_gpu_index_buffer_unlock(&rect_index_buffer); + gpu_index_buffer_unlock(&rect_index_buffer); } { - iron_gpu_vertex_buffer_init(&tris_vertex_buffer, 3, &draw_structure, true); - float *verts = iron_gpu_vertex_buffer_lock(&tris_vertex_buffer); + gpu_vertex_buffer_init(&tris_vertex_buffer, 3, &draw_structure); + float *verts = gpu_vertex_buffer_lock(&tris_vertex_buffer); verts[0] = 0.0; // Bottom-left verts[1] = 1.0; verts[2] = 0.0; // Top-left verts[3] = 0.0; verts[4] = 1.0; // Top-right verts[5] = 0.0; - iron_gpu_vertex_buffer_unlock(&tris_vertex_buffer); + gpu_vertex_buffer_unlock(&tris_vertex_buffer); - iron_gpu_index_buffer_init(&tris_index_buffer, 3, true); - int *indices = iron_gpu_index_buffer_lock(&tris_index_buffer); + gpu_index_buffer_init(&tris_index_buffer, 3); + int *indices = gpu_index_buffer_lock(&tris_index_buffer); indices[0] = 0; indices[1] = 1; indices[2] = 2; - iron_gpu_index_buffer_unlock(&tris_index_buffer); + gpu_index_buffer_unlock(&tris_index_buffer); } // Image painter { - 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); + gpu_shader_init(&image_vert_shader, image_vert->buffer, image_vert->length, GPU_SHADER_TYPE_VERTEX); + gpu_shader_init(&image_frag_shader, image_frag->buffer, image_frag->length, GPU_SHADER_TYPE_FRAGMENT); draw_pipeline_init(&image_pipeline, &image_vert_shader, &image_frag_shader); - iron_gpu_pipeline_compile(&image_pipeline); + gpu_pipeline_compile(&image_pipeline); image_tex_unit = 0; image_p_loc = 0; image_pos_loc = 64; @@ -171,11 +171,11 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, // Rect painter { - iron_gpu_shader_init(&rect_vert_shader, rect_vert->buffer, rect_vert->length, IRON_GPU_SHADER_TYPE_VERTEX); - iron_gpu_shader_init(&rect_frag_shader, rect_frag->buffer, rect_frag->length, IRON_GPU_SHADER_TYPE_FRAGMENT); + gpu_shader_init(&rect_vert_shader, rect_vert->buffer, rect_vert->length, GPU_SHADER_TYPE_VERTEX); + gpu_shader_init(&rect_frag_shader, rect_frag->buffer, rect_frag->length, GPU_SHADER_TYPE_FRAGMENT); draw_pipeline_init(&rect_pipeline, &rect_vert_shader, &rect_frag_shader); - rect_pipeline.blend_source = IRON_GPU_BLEND_SOURCE_ALPHA; - iron_gpu_pipeline_compile(&rect_pipeline); + rect_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA; + gpu_pipeline_compile(&rect_pipeline); rect_p_loc = 0; rect_pos_loc = 64; rect_col_loc = 80; @@ -183,11 +183,11 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, // Tris painter { - iron_gpu_shader_init(&tris_vert_shader, tris_vert->buffer, tris_vert->length, IRON_GPU_SHADER_TYPE_VERTEX); - iron_gpu_shader_init(&tris_frag_shader, tris_frag->buffer, tris_frag->length, IRON_GPU_SHADER_TYPE_FRAGMENT); + gpu_shader_init(&tris_vert_shader, tris_vert->buffer, tris_vert->length, GPU_SHADER_TYPE_VERTEX); + gpu_shader_init(&tris_frag_shader, tris_frag->buffer, tris_frag->length, GPU_SHADER_TYPE_FRAGMENT); draw_pipeline_init(&tris_pipeline, &tris_vert_shader, &tris_frag_shader); - tris_pipeline.blend_source = IRON_GPU_BLEND_SOURCE_ALPHA; - iron_gpu_pipeline_compile(&tris_pipeline); + tris_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA; + gpu_pipeline_compile(&tris_pipeline); tris_p_loc = 0; tris_pos0_loc = 64; tris_pos1_loc = 72; @@ -197,11 +197,11 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, // Text painter { - 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); + gpu_shader_init(&text_vert_shader, text_vert->buffer, text_vert->length, GPU_SHADER_TYPE_VERTEX); + gpu_shader_init(&text_frag_shader, text_frag->buffer, text_frag->length, GPU_SHADER_TYPE_FRAGMENT); draw_pipeline_init(&text_pipeline, &text_vert_shader, &text_frag_shader); - text_pipeline.blend_source = IRON_GPU_BLEND_SOURCE_ALPHA; - iron_gpu_pipeline_compile(&text_pipeline); + text_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA; + gpu_pipeline_compile(&text_pipeline); text_tex_unit = 0; text_p_loc = 0; text_pos_loc = 64; @@ -209,12 +209,12 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, text_col_loc = 96; draw_pipeline_init(&text_pipeline_rt, &text_vert_shader, &text_frag_shader); - text_pipeline_rt.blend_source = IRON_GPU_BLEND_SOURCE_ALPHA; - iron_gpu_pipeline_compile(&text_pipeline_rt); + text_pipeline_rt.blend_source = GPU_BLEND_SOURCE_ALPHA; + gpu_pipeline_compile(&text_pipeline_rt); } } -void draw_begin(iron_gpu_texture_t *target, bool clear, unsigned color) { +void draw_begin(gpu_texture_t *target, bool clear, unsigned color) { if (_draw_in_use && !_draw_thrown) { _draw_thrown = true; iron_log("End before you begin"); @@ -225,11 +225,11 @@ void draw_begin(iron_gpu_texture_t *target, bool clear, unsigned color) { _draw_current = target; if (target == NULL) { - iron_gpu_begin(NULL, 0, clear ? IRON_GPU_CLEAR_COLOR : IRON_GPU_CLEAR_NONE, color, 0.0); + gpu_begin(NULL, 0, clear ? GPU_CLEAR_COLOR : GPU_CLEAR_NONE, color, 0.0); } else { - iron_gpu_texture_t *targets[1] = { target }; - iron_gpu_begin(targets, 1, clear ? IRON_GPU_CLEAR_COLOR : IRON_GPU_CLEAR_NONE, color, 0.0); + gpu_texture_t *targets[1] = { target }; + gpu_begin(targets, 1, clear ? GPU_CLEAR_COLOR : GPU_CLEAR_NONE, color, 0.0); } } @@ -239,37 +239,37 @@ void draw_end(void) { iron_log("Begin before you end"); } _draw_in_use = false; - iron_gpu_end(); + gpu_end(); } -void draw_scaled_sub_image(iron_gpu_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { - iron_gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_pipeline); - iron_gpu_set_vertex_buffer(&rect_vertex_buffer); - iron_gpu_set_index_buffer(&rect_index_buffer); +void draw_scaled_sub_image(gpu_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { + gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_pipeline); + gpu_set_vertex_buffer(&rect_vertex_buffer); + gpu_set_index_buffer(&rect_index_buffer); gpu_set_matrix4(image_p_loc, draw_projection_matrix); gpu_set_float4(image_pos_loc, dx / vw(), dy / vh(), dw / vw(), dh / vh()); gpu_set_float4(image_tex_loc, sx / tex->width, sy / tex->height, sw / tex->width, sh / tex->height); gpu_set_float4(image_col_loc, _draw_color_r(draw_color) / 255.0, _draw_color_g(draw_color) / 255.0, _draw_color_b(draw_color) / 255.0, _draw_color_a(draw_color) / 255.0); - iron_gpu_set_texture(image_tex_unit, tex); + gpu_set_texture(image_tex_unit, tex); gpu_draw(); } -void draw_scaled_image(iron_gpu_texture_t *tex, float dx, float dy, float dw, float dh) { +void draw_scaled_image(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_gpu_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y) { +void draw_sub_image(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_gpu_texture_t *tex, float x, float y) { +void draw_image(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); } void draw_filled_triangle(float x0, float y0, float x1, float y1, float x2, float y2) { - iron_gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &tris_pipeline); - iron_gpu_set_vertex_buffer(&tris_vertex_buffer); - iron_gpu_set_index_buffer(&tris_index_buffer); + gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &tris_pipeline); + gpu_set_vertex_buffer(&tris_vertex_buffer); + gpu_set_index_buffer(&tris_index_buffer); gpu_set_matrix4(tris_p_loc, draw_projection_matrix); gpu_set_float2(tris_pos0_loc, x0 / vw(), y0 / vh()); gpu_set_float2(tris_pos1_loc, x1 / vw(), y1 / vh()); @@ -279,9 +279,9 @@ void draw_filled_triangle(float x0, float y0, float x1, float y1, float x2, floa } void draw_filled_rect(float x, float y, float width, float height) { - iron_gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &rect_pipeline); - iron_gpu_set_vertex_buffer(&rect_vertex_buffer); - iron_gpu_set_index_buffer(&rect_index_buffer); + gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &rect_pipeline); + gpu_set_vertex_buffer(&rect_vertex_buffer); + gpu_set_index_buffer(&rect_index_buffer); gpu_set_matrix4(rect_p_loc, draw_projection_matrix); gpu_set_float4(rect_pos_loc, x / vw(), y / vh(), width / vw(), height / vh()); gpu_set_float4(rect_col_loc, _draw_color_r(draw_color) / 255.0, _draw_color_g(draw_color) / 255.0, _draw_color_b(draw_color) / 255.0, _draw_color_a(draw_color) / 255.0); @@ -343,7 +343,7 @@ typedef struct draw_font_aligned_quad { typedef struct draw_font_image { float m_size; stbtt_bakedchar *chars; - iron_gpu_texture_t *tex; + gpu_texture_t *tex; int width, height, first_unused_y; float baseline, descent, line_gap; } draw_font_image_t; @@ -463,13 +463,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_gpu_texture_t *)malloc(sizeof(iron_gpu_texture_t)); - iron_gpu_texture_init_from_bytes(img->tex, pixels, width, height, IRON_IMAGE_FORMAT_R8); + img->tex = (gpu_texture_t *)malloc(sizeof(gpu_texture_t)); + gpu_texture_init_from_bytes(img->tex, pixels, width, height, IRON_IMAGE_FORMAT_R8); free(pixels); return true; } -iron_gpu_texture_t *draw_font_get_texture(draw_font_t *font, int size) { +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; } @@ -526,16 +526,16 @@ bool draw_font_get_baked_quad(draw_font_t *font, int size, draw_font_aligned_qua void draw_string(const char *text, float x, float y) { draw_font_image_t *img = draw_font_get_image_internal(draw_font, draw_font_size); - iron_gpu_texture_t *tex = img->tex; + gpu_texture_t *tex = img->tex; float xpos = x; float ypos = y + img->baseline; draw_font_aligned_quad_t q; - // iron_gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : _draw_current != NULL ? &text_pipeline_rt : &text_pipeline); - // iron_gpu_set_vertex_buffer(&rect_vertex_buffer); - // iron_gpu_set_index_buffer(&rect_index_buffer); - // iron_gpu_set_texture(text_tex_unit, tex); + // gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : _draw_current != NULL ? &text_pipeline_rt : &text_pipeline); + // gpu_set_vertex_buffer(&rect_vertex_buffer); + // gpu_set_index_buffer(&rect_index_buffer); + // gpu_set_texture(text_tex_unit, tex); for (int i = 0; text[i] != 0; ) { int l = 0; @@ -546,10 +546,10 @@ void draw_string(const char *text, float x, float y) { xpos += q.xadvance; // - iron_gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : _draw_current != NULL ? &text_pipeline_rt : &text_pipeline); - iron_gpu_set_vertex_buffer(&rect_vertex_buffer); - iron_gpu_set_index_buffer(&rect_index_buffer); - iron_gpu_set_texture(text_tex_unit, tex); + gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : _draw_current != NULL ? &text_pipeline_rt : &text_pipeline); + gpu_set_vertex_buffer(&rect_vertex_buffer); + gpu_set_index_buffer(&rect_index_buffer); + gpu_set_texture(text_tex_unit, tex); // gpu_set_float4(text_pos_loc, q.x0 / vw(), q.y0 / vh(), (q.x1 - q.x0) / vw(), (q.y1 - q.y0) / vh()); @@ -605,8 +605,8 @@ void draw_font_13(draw_font_t *font) { img->width = 128; img->height = 128; img->first_unused_y = 0; - 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); + img->tex = (gpu_texture_t *)malloc(sizeof(gpu_texture_t)); + 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) { @@ -723,7 +723,7 @@ uint32_t draw_get_color() { return draw_color; } -void draw_set_pipeline(iron_gpu_pipeline_t *pipeline) { +void draw_set_pipeline(gpu_pipeline_t *pipeline) { draw_custom_pipeline = pipeline; } diff --git a/base/sources/iron_draw.h b/base/sources/iron_draw.h index a35b9c5a..dec5564c 100644 --- a/base/sources/iron_draw.h +++ b/base/sources/iron_draw.h @@ -27,11 +27,11 @@ typedef struct draw_font { } draw_font_t; void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, buffer_t *rect_frag, buffer_t *tris_vert, buffer_t *tris_frag, buffer_t *text_vert, buffer_t *text_frag); -void draw_begin(iron_gpu_texture_t *target, bool clear, unsigned color); -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_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_begin(gpu_texture_t *target, bool clear, unsigned color); +void draw_scaled_sub_image(gpu_texture_t *img, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); +void draw_scaled_image(gpu_texture_t *tex, float dx, float dy, float dw, float dh); +void draw_sub_image(gpu_texture_t *tex, float sx, float sy, float sw, float sh, float x, float y); +void draw_image(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); @@ -41,7 +41,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_gpu_pipeline_t *pipeline); +void draw_set_pipeline(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); @@ -62,5 +62,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_gpu_texture_t *_draw_current; +extern 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 8b920782..67c73ea0 100644 --- a/base/sources/iron_gpu.c +++ b/base/sources/iron_gpu.c @@ -3,23 +3,23 @@ #define CONSTANT_BUFFER_SIZE 256 #define CONSTANT_BUFFER_MULTIPLE 2048 int constant_buffer_index = 0; -static iron_gpu_buffer_t constant_buffer; +static gpu_buffer_t constant_buffer; void gpu_init(int depth_buffer_bits, bool vsync) { - iron_gpu_init(depth_buffer_bits, vsync); - iron_gpu_constant_buffer_init(&constant_buffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLE); - iron_gpu_constant_buffer_lock(&constant_buffer, 0, CONSTANT_BUFFER_SIZE); + gpu_init_internal(depth_buffer_bits, vsync); + gpu_constant_buffer_init(&constant_buffer, CONSTANT_BUFFER_SIZE * CONSTANT_BUFFER_MULTIPLE); + gpu_constant_buffer_lock(&constant_buffer, 0, CONSTANT_BUFFER_SIZE); } void gpu_draw() { - iron_gpu_constant_buffer_unlock(&constant_buffer); - iron_gpu_set_constant_buffer(&constant_buffer, constant_buffer_index * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); - iron_gpu_draw(); + gpu_constant_buffer_unlock(&constant_buffer); + gpu_set_constant_buffer(&constant_buffer, constant_buffer_index * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + gpu_draw_internal(); ++constant_buffer_index; if (constant_buffer_index >= CONSTANT_BUFFER_MULTIPLE) { constant_buffer_index = 0; } - iron_gpu_constant_buffer_lock(&constant_buffer, constant_buffer_index * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); + gpu_constant_buffer_lock(&constant_buffer, constant_buffer_index * CONSTANT_BUFFER_SIZE, CONSTANT_BUFFER_SIZE); } void gpu_set_int(int location, int value) { @@ -93,7 +93,7 @@ void gpu_set_bool(int location, bool value) { ints[0] = value ? 1 : 0; } -static void iron_internal_set_matrix3(uint8_t *constants, int offset, iron_matrix3x3_t *value) { +static void gpu_internal_set_matrix3(uint8_t *constants, int offset, iron_matrix3x3_t *value) { float *floats = (float *)(&constants[offset]); for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { @@ -102,7 +102,7 @@ static void iron_internal_set_matrix3(uint8_t *constants, int offset, iron_matri } } -static void iron_internal_set_matrix4(uint8_t *constants, int offset, iron_matrix4x4_t *value) { +static void gpu_internal_set_matrix4(uint8_t *constants, int offset, iron_matrix4x4_t *value) { float *floats = (float *)(&constants[offset]); for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { @@ -112,46 +112,46 @@ static void iron_internal_set_matrix4(uint8_t *constants, int offset, iron_matri } void gpu_set_matrix3(int location, iron_matrix3x3_t value) { - if (iron_gpu_transpose_mat) { + if (gpu_transpose_mat) { iron_matrix3x3_t m = value; iron_matrix3x3_transpose(&m); - iron_internal_set_matrix3(constant_buffer.data, location, &m); + gpu_internal_set_matrix3(constant_buffer.data, location, &m); } else { - iron_internal_set_matrix3(constant_buffer.data, location, &value); + gpu_internal_set_matrix3(constant_buffer.data, location, &value); } } void gpu_set_matrix4(int location, iron_matrix4x4_t value) { - if (iron_gpu_transpose_mat) { + if (gpu_transpose_mat) { iron_matrix4x4_t m = value; iron_matrix4x4_transpose(&m); - iron_internal_set_matrix4(constant_buffer.data, location, &m); + gpu_internal_set_matrix4(constant_buffer.data, location, &m); } else { - iron_internal_set_matrix4(constant_buffer.data, location, &value); + gpu_internal_set_matrix4(constant_buffer.data, location, &value); } } -void gpu_vertex_structure_add(iron_gpu_vertex_structure_t *structure, const char *name, iron_gpu_vertex_data_t data) { +void gpu_vertex_structure_add(gpu_vertex_structure_t *structure, const char *name, gpu_vertex_data_t data) { structure->elements[structure->size].name = name; structure->elements[structure->size].data = data; structure->size++; } -void gpu_internal_pipeline_init(iron_gpu_pipeline_t *pipe) { +void gpu_internal_pipeline_init(gpu_pipeline_t *pipe) { pipe->input_layout = NULL; pipe->vertex_shader = NULL; pipe->fragment_shader = NULL; - pipe->cull_mode = IRON_GPU_CULL_MODE_NEVER; + pipe->cull_mode = GPU_CULL_MODE_NEVER; pipe->depth_write = false; - pipe->depth_mode = IRON_GPU_COMPARE_MODE_ALWAYS; - 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; + pipe->depth_mode = GPU_COMPARE_MODE_ALWAYS; + pipe->blend_source = GPU_BLEND_ONE; + pipe->blend_destination = GPU_BLEND_ZERO; + pipe->blend_operation = GPU_BLENDOP_ADD; + pipe->alpha_blend_source = GPU_BLEND_ONE; + pipe->alpha_blend_destination = GPU_BLEND_ZERO; + pipe->alpha_blend_operation = GPU_BLENDOP_ADD; for (int i = 0; i < 8; ++i) { pipe->color_write_mask_red[i] = true; pipe->color_write_mask_green[i] = true; diff --git a/base/sources/iron_gpu.h b/base/sources/iron_gpu.h index 55df4f8d..12adaebe 100644 --- a/base/sources/iron_gpu.h +++ b/base/sources/iron_gpu.h @@ -9,10 +9,10 @@ #include #include BACKEND_GPU_H -#define IRON_GPU_CLEAR_NONE 0 -#define IRON_GPU_CLEAR_COLOR 1 -#define IRON_GPU_CLEAR_DEPTH 2 -#define IRON_GPU_MAX_VERTEX_ELEMENTS 16 +#define GPU_CLEAR_NONE 0 +#define GPU_CLEAR_COLOR 1 +#define GPU_CLEAR_DEPTH 2 +#define GPU_MAX_VERTEX_ELEMENTS 16 typedef enum iron_internal_render_target_state { IRON_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET, @@ -40,47 +40,47 @@ typedef enum { GPU_USAGE_READABLE } gpu_usage_t; -typedef enum iron_gpu_vertex_data { - IRON_GPU_VERTEX_DATA_F32_1X, - IRON_GPU_VERTEX_DATA_F32_2X, - IRON_GPU_VERTEX_DATA_F32_3X, - IRON_GPU_VERTEX_DATA_F32_4X, - IRON_GPU_VERTEX_DATA_I16_2X_NORM, - IRON_GPU_VERTEX_DATA_I16_4X_NORM, -} iron_gpu_vertex_data_t; +typedef enum gpu_vertex_data { + GPU_VERTEX_DATA_F32_1X, + GPU_VERTEX_DATA_F32_2X, + GPU_VERTEX_DATA_F32_3X, + GPU_VERTEX_DATA_F32_4X, + GPU_VERTEX_DATA_I16_2X_NORM, + GPU_VERTEX_DATA_I16_4X_NORM, +} gpu_vertex_data_t; -typedef enum iron_gpu_shader_type { - IRON_GPU_SHADER_TYPE_VERTEX, - IRON_GPU_SHADER_TYPE_FRAGMENT, - IRON_GPU_SHADER_TYPE_COUNT -} iron_gpu_shader_type_t; +typedef enum gpu_shader_type { + GPU_SHADER_TYPE_VERTEX, + GPU_SHADER_TYPE_FRAGMENT, + GPU_SHADER_TYPE_COUNT +} gpu_shader_type_t; typedef enum { - 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_blending_factor_t; + GPU_BLEND_ONE, + GPU_BLEND_ZERO, + GPU_BLEND_SOURCE_ALPHA, + GPU_BLEND_DEST_ALPHA, + GPU_BLEND_INV_SOURCE_ALPHA, + GPU_BLEND_INV_DEST_ALPHA +} gpu_blending_factor_t; typedef enum { - IRON_GPU_BLENDOP_ADD -} iron_gpu_blending_operation_t; + GPU_BLENDOP_ADD +} gpu_blending_operation_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 gpu_cull_mode { + GPU_CULL_MODE_CLOCKWISE, + GPU_CULL_MODE_COUNTERCLOCKWISE, + GPU_CULL_MODE_NEVER +} gpu_cull_mode_t; -typedef enum iron_gpu_compare_mode { - IRON_GPU_COMPARE_MODE_ALWAYS, - IRON_GPU_COMPARE_MODE_NEVER, - IRON_GPU_COMPARE_MODE_LESS -} iron_gpu_compare_mode_t; +typedef enum gpu_compare_mode { + GPU_COMPARE_MODE_ALWAYS, + GPU_COMPARE_MODE_NEVER, + GPU_COMPARE_MODE_LESS +} gpu_compare_mode_t; -typedef struct iron_gpu_texture { +typedef struct gpu_texture { int width; int height; iron_image_format_t format; @@ -92,41 +92,41 @@ typedef struct iron_gpu_texture { iron_internal_render_target_state_t depth_state; buffer_t *buffer; gpu_texture_impl_t impl; -} iron_gpu_texture_t; +} gpu_texture_t; -typedef struct iron_gpu_buffer { +typedef struct gpu_buffer { int count; uint8_t *data; gpu_buffer_impl_t impl; -} iron_gpu_buffer_t; +} gpu_buffer_t; -typedef struct iron_gpu_vertex_element { +typedef struct gpu_vertex_element { const char *name; - iron_gpu_vertex_data_t data; -} iron_gpu_vertex_element_t; + gpu_vertex_data_t data; +} gpu_vertex_element_t; -typedef struct iron_gpu_vertex_structure { - iron_gpu_vertex_element_t elements[IRON_GPU_MAX_VERTEX_ELEMENTS]; +typedef struct gpu_vertex_structure { + gpu_vertex_element_t elements[GPU_MAX_VERTEX_ELEMENTS]; int size; -} iron_gpu_vertex_structure_t; +} gpu_vertex_structure_t; -typedef struct iron_gpu_shader { +typedef struct gpu_shader { gpu_shader_impl_t impl; -} iron_gpu_shader_t; +} gpu_shader_t; -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_gpu_cull_mode_t cull_mode; +typedef struct gpu_pipeline { + gpu_vertex_structure_t *input_layout; + gpu_shader_t *vertex_shader; + gpu_shader_t *fragment_shader; + gpu_cull_mode_t cull_mode; bool depth_write; - iron_gpu_compare_mode_t depth_mode; - 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; + gpu_compare_mode_t depth_mode; + gpu_blending_factor_t blend_source; + gpu_blending_factor_t blend_destination; + gpu_blending_operation_t blend_operation; + gpu_blending_factor_t alpha_blend_source; + gpu_blending_factor_t alpha_blend_destination; + gpu_blending_operation_t alpha_blend_operation; bool color_write_mask_red[8]; bool color_write_mask_green[8]; bool color_write_mask_blue[8]; @@ -135,28 +135,28 @@ typedef struct iron_gpu_pipeline { int color_attachment_count; int depth_attachment_bits; gpu_pipeline_impl_t impl; -} iron_gpu_pipeline_t; +} gpu_pipeline_t; -typedef struct iron_gpu_raytrace_pipeline { - iron_gpu_buffer_t *_constant_buffer; +typedef struct gpu_raytrace_pipeline { + gpu_buffer_t *_constant_buffer; gpu_raytrace_pipeline_impl_t impl; -} iron_gpu_raytrace_pipeline_t; +} gpu_raytrace_pipeline_t; -typedef struct iron_gpu_raytrace_acceleration_structure { +typedef struct gpu_raytrace_acceleration_structure { gpu_raytrace_acceleration_structure_impl_t impl; -} iron_gpu_raytrace_acceleration_structure_t; +} gpu_raytrace_acceleration_structure_t; -struct iron_gpu_pipeline; -struct iron_gpu_texture; -struct iron_gpu_buffer; +struct gpu_pipeline; +struct gpu_texture; +struct gpu_buffer; -int iron_gpu_max_bound_textures(void); -void iron_gpu_begin(struct iron_gpu_texture **targets, int count, unsigned flags, unsigned color, float depth); -void iron_gpu_end(void); -void iron_gpu_wait(void); -void iron_gpu_present(void); -void iron_gpu_init(int depth_buffer_bits, bool vsync); -void iron_gpu_destroy(void); +int gpu_max_bound_textures(void); +void gpu_begin(struct gpu_texture **targets, int count, unsigned flags, unsigned color, float depth); +void gpu_end(void); +void gpu_wait(void); +void gpu_present(void); +void gpu_init_internal(int depth_buffer_bits, bool vsync); +void gpu_destroy(void); void gpu_draw(void); void gpu_set_int(int location, int value); void gpu_set_int2(int location, int value1, int value2); @@ -173,93 +173,89 @@ void gpu_set_matrix3(int location, iron_matrix3x3_t value); void gpu_set_matrix4(int location, iron_matrix4x4_t value); void gpu_init(int depth_buffer_bits, bool vsync); -void gpu_vertex_structure_add(iron_gpu_vertex_structure_t *structure, const char *name, iron_gpu_vertex_data_t data); -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_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); -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_set_depth_from(iron_gpu_texture_t *target, iron_gpu_texture_t *source); -void iron_gpu_vertex_buffer_init(iron_gpu_buffer_t *buffer, int count, iron_gpu_vertex_structure_t *structure, bool gpu_memory); -void iron_gpu_vertex_buffer_destroy(iron_gpu_buffer_t *buffer); -float *iron_gpu_vertex_buffer_lock(iron_gpu_buffer_t *buffer); -void iron_gpu_vertex_buffer_unlock(iron_gpu_buffer_t *buffer); -int iron_gpu_vertex_buffer_count(iron_gpu_buffer_t *buffer); -int iron_gpu_vertex_buffer_stride(iron_gpu_buffer_t *buffer); -void iron_gpu_constant_buffer_init(iron_gpu_buffer_t *buffer, int size); -void iron_gpu_constant_buffer_destroy(iron_gpu_buffer_t *buffer); -void iron_gpu_constant_buffer_lock(iron_gpu_buffer_t *buffer, int start, int count); -void iron_gpu_constant_buffer_unlock(iron_gpu_buffer_t *buffer); -int iron_gpu_constant_buffer_size(iron_gpu_buffer_t *buffer); -void iron_gpu_index_buffer_init(iron_gpu_buffer_t *buffer, int count, bool gpu_memory); -void iron_gpu_index_buffer_destroy(iron_gpu_buffer_t *buffer); -void *iron_gpu_index_buffer_lock(iron_gpu_buffer_t *buffer); -void iron_gpu_index_buffer_unlock(iron_gpu_buffer_t *buffer); -int iron_gpu_index_buffer_count(iron_gpu_buffer_t *buffer); +void gpu_vertex_structure_add(gpu_vertex_structure_t *structure, const char *name, gpu_vertex_data_t data); +void gpu_texture_init(gpu_texture_t *texture, int width, int height, iron_image_format_t format); +void gpu_texture_init_from_bytes(gpu_texture_t *texture, void *data, int width, int height, iron_image_format_t format); +void gpu_texture_destroy(gpu_texture_t *texture); +void gpu_texture_generate_mipmaps(gpu_texture_t *texture, int levels); +void gpu_texture_set_mipmap(gpu_texture_t *texture, gpu_texture_t *mipmap, int level); +int gpu_texture_stride(gpu_texture_t *texture); +void gpu_render_target_init(gpu_texture_t *target, int width, int height, iron_image_format_t format, int depthBufferBits); +void gpu_render_target_set_depth_from(gpu_texture_t *target, gpu_texture_t *source); +void gpu_vertex_buffer_init(gpu_buffer_t *buffer, int count, gpu_vertex_structure_t *structure); +void gpu_vertex_buffer_destroy(gpu_buffer_t *buffer); +float *gpu_vertex_buffer_lock(gpu_buffer_t *buffer); +void gpu_vertex_buffer_unlock(gpu_buffer_t *buffer); +int gpu_vertex_buffer_count(gpu_buffer_t *buffer); +int gpu_vertex_buffer_stride(gpu_buffer_t *buffer); +void gpu_constant_buffer_init(gpu_buffer_t *buffer, int size); +void gpu_constant_buffer_destroy(gpu_buffer_t *buffer); +void gpu_constant_buffer_lock(gpu_buffer_t *buffer, int start, int count); +void gpu_constant_buffer_unlock(gpu_buffer_t *buffer); +int gpu_constant_buffer_size(gpu_buffer_t *buffer); +void gpu_index_buffer_init(gpu_buffer_t *buffer, int count); +void gpu_index_buffer_destroy(gpu_buffer_t *buffer); +void *gpu_index_buffer_lock(gpu_buffer_t *buffer); +void gpu_index_buffer_unlock(gpu_buffer_t *buffer); +int gpu_index_buffer_count(gpu_buffer_t *buffer); -void iron_gpu_pipeline_init(iron_gpu_pipeline_t *pipeline); -void 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); -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 gpu_pipeline_init(gpu_pipeline_t *pipeline); +void gpu_internal_pipeline_init(gpu_pipeline_t *pipeline); +void gpu_pipeline_destroy(gpu_pipeline_t *pipeline); +void gpu_pipeline_compile(gpu_pipeline_t *pipeline); +void gpu_shader_init(gpu_shader_t *shader, const void *source, size_t length, gpu_shader_type_t type); +void gpu_shader_destroy(gpu_shader_t *shader); -void iron_gpu_render_target_to_framebuffer_barrier(struct iron_gpu_texture *render_target); -void iron_gpu_framebuffer_to_render_target_barrier(struct iron_gpu_texture *render_target); -void iron_gpu_texture_to_render_target_barrier(struct iron_gpu_texture *render_target); -void iron_gpu_render_target_to_texture_barrier(struct iron_gpu_texture *render_target); -void iron_gpu_draw(); -void iron_gpu_viewport(int x, int y, int width, int height); -void iron_gpu_scissor(int x, int y, int width, int height); -void iron_gpu_disable_scissor(); -void iron_gpu_set_pipeline(struct iron_gpu_pipeline *pipeline); -void iron_gpu_set_vertex_buffer(iron_gpu_buffer_t *buffer); -void iron_gpu_set_index_buffer(iron_gpu_buffer_t *buffer); -void iron_gpu_upload_vertex_buffer(struct iron_gpu_buffer *buffer); -void iron_gpu_upload_texture(struct iron_gpu_texture *texture); -void iron_gpu_set_constant_buffer(iron_gpu_buffer_t *buffer, int offset, size_t size); -void iron_gpu_get_render_target_pixels(struct iron_gpu_texture *render_target, uint8_t *data); -void iron_gpu_set_texture(int unit, iron_gpu_texture_t *texture); -void iron_gpu_set_texture_depth(int unit, iron_gpu_texture_t *target); +void gpu_draw_internal(); +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 gpu_set_pipeline(struct gpu_pipeline *pipeline); +void gpu_set_vertex_buffer(gpu_buffer_t *buffer); +void gpu_set_index_buffer(gpu_buffer_t *buffer); +void gpu_upload_vertex_buffer(struct gpu_buffer *buffer); +void gpu_upload_texture(struct gpu_texture *texture); +void gpu_set_constant_buffer(gpu_buffer_t *buffer, int offset, size_t size); +void gpu_get_render_target_pixels(struct gpu_texture *render_target, uint8_t *data); +void gpu_set_texture(int unit, gpu_texture_t *texture); +void gpu_set_texture_depth(int unit, gpu_texture_t *target); -bool iron_gpu_raytrace_supported(void); -void iron_gpu_raytrace_pipeline_init(iron_gpu_raytrace_pipeline_t *pipeline, void *ray_shader, int ray_shader_size, struct iron_gpu_buffer *constant_buffer); -void iron_gpu_raytrace_pipeline_destroy(iron_gpu_raytrace_pipeline_t *pipeline); -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_buffer *vb, struct iron_gpu_buffer *ib, iron_matrix4x4_t transform); -void iron_gpu_raytrace_acceleration_structure_build(iron_gpu_raytrace_acceleration_structure_t *accel, struct iron_gpu_buffer *_vb_full, struct iron_gpu_buffer *_ib_full); -void iron_gpu_raytrace_acceleration_structure_destroy(iron_gpu_raytrace_acceleration_structure_t *accel); -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(); +bool gpu_raytrace_supported(void); +void gpu_raytrace_pipeline_init(gpu_raytrace_pipeline_t *pipeline, void *ray_shader, int ray_shader_size, struct gpu_buffer *constant_buffer); +void gpu_raytrace_pipeline_destroy(gpu_raytrace_pipeline_t *pipeline); +void gpu_raytrace_acceleration_structure_init(gpu_raytrace_acceleration_structure_t *accel); +void gpu_raytrace_acceleration_structure_add(gpu_raytrace_acceleration_structure_t *accel, struct gpu_buffer *vb, struct gpu_buffer *ib, iron_matrix4x4_t transform); +void gpu_raytrace_acceleration_structure_build(gpu_raytrace_acceleration_structure_t *accel, struct gpu_buffer *_vb_full, struct gpu_buffer *_ib_full); +void gpu_raytrace_acceleration_structure_destroy(gpu_raytrace_acceleration_structure_t *accel); +void gpu_raytrace_set_textures(struct gpu_texture *texpaint0, struct gpu_texture *texpaint1, struct gpu_texture *texpaint2, struct gpu_texture *texenv, struct gpu_texture *texsobol, struct gpu_texture *texscramble, struct gpu_texture *texrank); +void gpu_raytrace_set_acceleration_structure(gpu_raytrace_acceleration_structure_t *accel); +void gpu_raytrace_set_pipeline(gpu_raytrace_pipeline_t *pipeline); +void gpu_raytrace_set_target(struct gpu_texture *output); +void gpu_raytrace_dispatch_rays(); -extern bool iron_gpu_transpose_mat; +extern bool gpu_transpose_mat; -static inline int iron_gpu_vertex_data_size(iron_gpu_vertex_data_t data) { +static inline int gpu_vertex_data_size(gpu_vertex_data_t data) { switch (data) { - case IRON_GPU_VERTEX_DATA_F32_1X: + case GPU_VERTEX_DATA_F32_1X: return 1 * 4; - case IRON_GPU_VERTEX_DATA_F32_2X: + case GPU_VERTEX_DATA_F32_2X: return 2 * 4; - case IRON_GPU_VERTEX_DATA_F32_3X: + case GPU_VERTEX_DATA_F32_3X: return 3 * 4; - case IRON_GPU_VERTEX_DATA_F32_4X: + case GPU_VERTEX_DATA_F32_4X: return 4 * 4; - case IRON_GPU_VERTEX_DATA_I16_2X_NORM: + case GPU_VERTEX_DATA_I16_2X_NORM: return 2 * 2; - case IRON_GPU_VERTEX_DATA_I16_4X_NORM: + case GPU_VERTEX_DATA_I16_4X_NORM: return 4 * 2; } } -static inline int iron_gpu_vertex_struct_size(iron_gpu_vertex_structure_t *s) { +static inline int gpu_vertex_struct_size(gpu_vertex_structure_t *s) { int size = 0; for (int i = 0; i < s->size; ++i) { - size += iron_gpu_vertex_data_size(s->elements[i].data); + size += gpu_vertex_data_size(s->elements[i].data); } return size; } diff --git a/base/sources/iron_ui.c b/base/sources/iron_ui.c index 4038f718..72d6cbd0 100644 --- a/base/sources/iron_ui.c +++ b/base/sources/iron_ui.c @@ -504,7 +504,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_gpu_texture_destroy(&handle->texture); + gpu_texture_destroy(&handle->texture); } if (w < 1) { w = 1; @@ -512,7 +512,7 @@ void ui_resize(ui_handle_t *handle, int w, int h) { if (h < 1) { h = 1; } - iron_gpu_render_target_init(&handle->texture, w, h, IRON_IMAGE_FORMAT_RGBA32, 0); + 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) { @@ -894,10 +894,10 @@ void ui_draw_combo(bool begin /*= true*/) { void ui_bake_elements() { if (current->check_select_image.width != 0) { - iron_gpu_texture_destroy(¤t->check_select_image); + gpu_texture_destroy(¤t->check_select_image); } float r = UI_CHECK_SELECT_SIZE(); - iron_gpu_render_target_init(¤t->check_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + gpu_render_target_init(¤t->check_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_begin(¤t->check_select_image, true, 0x00000000); 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()); @@ -905,10 +905,10 @@ void ui_bake_elements() { draw_end(); if (current->radio_image.width != 0) { - iron_gpu_texture_destroy(¤t->radio_image); + gpu_texture_destroy(¤t->radio_image); } r = UI_CHECK_SIZE(); - iron_gpu_render_target_init(¤t->radio_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + gpu_render_target_init(¤t->radio_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_begin(¤t->radio_image, true, 0x00000000); draw_set_color(0xffaaaaaa); draw_filled_circle(r / 2.0, r / 2.0, r / 2.0, 0); @@ -917,10 +917,10 @@ void ui_bake_elements() { draw_end(); if (current->radio_select_image.width != 0) { - iron_gpu_texture_destroy(¤t->radio_select_image); + gpu_texture_destroy(¤t->radio_select_image); } r = UI_CHECK_SELECT_SIZE(); - iron_gpu_render_target_init(¤t->radio_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + gpu_render_target_init(¤t->radio_select_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_begin(¤t->radio_select_image, true, 0x00000000); draw_set_color(0xffaaaaaa); draw_filled_circle(r / 2.0, r / 2.0, 4.5 * UI_SCALE(), 0); @@ -930,19 +930,19 @@ void ui_bake_elements() { if (theme->ROUND_CORNERS) { if (current->filled_round_corner_image.width != 0) { - iron_gpu_texture_destroy(¤t->filled_round_corner_image); + gpu_texture_destroy(¤t->filled_round_corner_image); } r = 4.0 * UI_SCALE(); - iron_gpu_render_target_init(¤t->filled_round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + gpu_render_target_init(¤t->filled_round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_begin(¤t->filled_round_corner_image, true, 0x00000000); draw_set_color(0xffffffff); draw_filled_circle(r, r, r, 0); draw_end(); if (current->round_corner_image.width != 0) { - iron_gpu_texture_destroy(¤t->round_corner_image); + gpu_texture_destroy(¤t->round_corner_image); } - iron_gpu_render_target_init(¤t->round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); + gpu_render_target_init(¤t->round_corner_image, r, r, IRON_IMAGE_FORMAT_RGBA32, 0); draw_begin(¤t->round_corner_image, true, 0x00000000); draw_set_color(0xffffffff); draw_circle(r, r, r, 0, 1); @@ -1541,7 +1541,7 @@ void ui_end_sticky() { // draw_end(); current->sticky = false; current->scissor = true; - iron_gpu_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; @@ -1556,7 +1556,7 @@ void ui_end_window(bool bind_global_g) { if (handle->redraws > 0 || current->is_scrolling) { if (current->scissor) { current->scissor = false; - iron_gpu_disable_scissor(); + gpu_disable_scissor(); } if (current->tab_count > 0) { @@ -1746,7 +1746,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_gpu_texture_t *icon, int sx, int sy, int sw, int sh*/) { +bool ui_button(char *text, int align, char *label/*, gpu_texture_t *icon, int sx, int sy, int sw, int sh*/) { if (!ui_is_visible(UI_ELEMENT_H())) { ui_end_element(); return false; @@ -1880,22 +1880,22 @@ bool ui_panel(ui_handle_t *handle, char *text, bool is_tree, bool filled) { } static int image_width(void *image) { - return ((iron_gpu_texture_t *)image)->width; + return ((gpu_texture_t *)image)->width; } static int image_height(void *image) { - return ((iron_gpu_texture_t *)image)->height; + return ((gpu_texture_t *)image)->height; } static void _draw_scaled_image(void *image, float dx, float dy, float dw, float dh) { - draw_scaled_image((iron_gpu_texture_t *)image, dx, dy, dw, dh); + draw_scaled_image((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_image((iron_gpu_texture_t *)image, sx, sy, sw, sh, dx, dy, dw, dh); + draw_scaled_sub_image((gpu_texture_t *)image, sx, sy, sw, sh, dx, dy, dw, dh); } -int ui_sub_image(iron_gpu_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh) { +int ui_sub_image(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); @@ -1966,7 +1966,7 @@ int ui_sub_image(iron_gpu_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_gpu_texture_t *image, uint32_t tint, int h) { +int ui_image(gpu_texture_t *image, uint32_t tint, int h) { return ui_sub_image(image, tint, h, 0, 0, image_width(image), image_height(image)); } @@ -2277,7 +2277,7 @@ void ui_tooltip(char *text) { current->tooltip_y = current->_y + current->_window_y; } -void ui_tooltip_image(iron_gpu_texture_t *image, int max_width) { +void ui_tooltip_image(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 237af461..7611f902 100644 --- a/base/sources/iron_ui.h +++ b/base/sources/iron_ui.h @@ -67,8 +67,8 @@ typedef struct ui_options { draw_font_t *font; ui_theme_t *theme; float scale_factor; - iron_gpu_texture_t *color_wheel; - iron_gpu_texture_t *black_white_gradient; + gpu_texture_t *color_wheel; + gpu_texture_t *black_white_gradient; } ui_options_t; typedef struct ui_handle_array { @@ -83,7 +83,7 @@ typedef struct ui_handle { uint32_t color; float value; char *text; - iron_gpu_texture_t texture; + gpu_texture_t texture; int redraws; float scroll_offset; bool scroll_enabled; @@ -243,7 +243,7 @@ typedef struct ui { int combo_to_submit; int combo_initial_value; char tooltip_text[512]; - iron_gpu_texture_t *tooltip_img; + gpu_texture_t *tooltip_img; int tooltip_img_max_width; bool tooltip_invert_y; float tooltip_x; @@ -262,11 +262,11 @@ typedef struct ui { bool scissor; bool elements_baked; - 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; + gpu_texture_t check_select_image; + gpu_texture_t radio_image; + gpu_texture_t radio_select_image; + gpu_texture_t round_corner_image; + gpu_texture_t filled_round_corner_image; } ui_t; void ui_init(ui_t *ui, ui_options_t *ops); @@ -280,8 +280,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_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); +int ui_sub_image(gpu_texture_t *image, uint32_t tint, int h, int sx, int sy, int sw, int sh); +int ui_image(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); @@ -296,7 +296,7 @@ void ui_row6(); void ui_row7(); void ui_separator(int h, bool fill); void ui_tooltip(char *text); -void ui_tooltip_image(iron_gpu_texture_t *image, int max_width); +void ui_tooltip_image(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 15882f5c..92a14a64 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_gpu_texture_t ui_socket_image; +static 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,16 +236,14 @@ int ui_get_socket_id(ui_node_array_t *nodes) { void ui_nodes_bake_elements() { if (ui_socket_image.width != 0) { - iron_gpu_texture_destroy(&ui_socket_image); + gpu_texture_destroy(&ui_socket_image); } - iron_gpu_render_target_init(&ui_socket_image, 24, 24, IRON_IMAGE_FORMAT_RGBA32, 0); + gpu_render_target_init(&ui_socket_image, 24, 24, IRON_IMAGE_FORMAT_RGBA32, 0); draw_begin(&ui_socket_image, true, 0x00000000); - draw_set_color(0xff111111); draw_filled_circle(12, 12, 11, 0); draw_set_color(0xffffffff); draw_filled_circle(12, 12, 9, 0); - draw_end(); ui_nodes_elements_baked = true; } diff --git a/base/sources/iron_video.h b/base/sources/iron_video.h index def35fb6..45876ecb 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_gpu_texture_t *iron_video_current_image(iron_video_t *video); +// 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 a36c1838..c72c7863 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_gpu_texture_t = null; +let base_drag_file_icon: 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_gpu_texture_t; -let base_color_wheel_gradient: iron_gpu_texture_t; +let base_color_wheel: gpu_texture_t; +let base_color_wheel_gradient: 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_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"); + let image_color_wheel: gpu_texture_t = data_get_image("color_wheel.k"); + let image_color_wheel_gradient: 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_gpu_texture_t = project_get_image(base_drag_asset); + let image: 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_gpu_texture_t = resource_get("icons.k"); + let icons: 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_gpu_texture_t { +function base_get_drag_image(): 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_gpu_texture_t { if (base_drag_file_icon != null) { return base_drag_file_icon; } - let icons: iron_gpu_texture_t = resource_get("icons.k"); + let icons: 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_gpu_texture_t { return base_drag_material.image_icon; } if (base_drag_layer != null && slot_layer_is_group(base_drag_layer)) { - let icons: iron_gpu_texture_t = resource_get("icons.k"); + let icons: 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_gpu_texture_t = base_get_drag_image(); + let img: 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 6ed5b944..bcae03a6 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_gpu_texture_t = _draw_current; + let current: 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 79576eaa..b6469ea6 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_gpu_texture_t = map_get(box_projects_icon_map, icon_path); + let icon: gpu_texture_t = map_get(box_projects_icon_map, icon_path); if (icon == null) { - let image: iron_gpu_texture_t = data_get_image(icon_path); + let image: 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_gpu_texture_t = _draw_current; + let current: 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_gpu_texture_t = data_get_image("badge.k"); + let img: 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 977187e8..d445a717 100644 --- a/base/sources/ts/config.ts +++ b/base/sources/ts/config.ts @@ -251,7 +251,7 @@ function config_apply() { config_save(); context_raw.ddirty = 2; - let current: iron_gpu_texture_t = _draw_current; + let current: 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 f1c8271d..b48e4f52 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_gpu_present(); + gpu_present(); sys_remove_render_2d(_console_toast_render); } @@ -27,7 +27,7 @@ function console_toast(s: string) { // Show a popup message sys_notify_on_render_2d(_console_toast_render, s); console_trace(s); - iron_gpu_present(); + gpu_present(); } function console_draw_progress() { @@ -53,7 +53,7 @@ function console_progress(s: string) { draw_end(); sys_render(); draw_begin(); - iron_gpu_present(); + gpu_present(); ///end } diff --git a/base/sources/ts/context.ts b/base/sources/ts/context.ts index 44f4f815..65e2f842 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_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; + default_radiance?: gpu_texture_t; + default_radiance_mipmaps?: gpu_texture_t[]; + saved_envmap?: gpu_texture_t; + empty_envmap?: gpu_texture_t; + preview_envmap?: 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_gpu_texture_t; - node_previews?: map_t; + node_preview?: gpu_texture_t; + node_previews?: map_t; node_previews_used?: string[]; node_preview_name?: string; - mask_preview_rgba32?: iron_gpu_texture_t; + mask_preview_rgba32?: 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_gpu_texture_t; + decal_image?: 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_gpu_texture_t; + text_tool_image?: 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_gpu_texture_t; + brush_mask_image?: gpu_texture_t; brush_mask_image_is_alpha?: bool; - brush_stencil_image?: iron_gpu_texture_t; + brush_stencil_image?: gpu_texture_t; brush_stencil_image_is_alpha?: bool; brush_stencil_x?: f32; brush_stencil_y?: f32; @@ -545,7 +545,7 @@ function context_set_layer(l: slot_layer_t) { context_raw.layer = l; ui_header_handle.redraws = 2; - let current: iron_gpu_texture_t = _draw_current; + let current: 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 c2907b0f..f27e23b7 100644 --- a/base/sources/ts/export_arm.ts +++ b/base/sources/ts/export_arm.ts @@ -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, "buf"); - let tex: iron_gpu_texture_t = rt._image; - let mesh_icon: iron_gpu_texture_t = gpu_create_render_target(256, 256); + let tex: gpu_texture_t = rt._image; + let mesh_icon: gpu_texture_t = gpu_create_render_target(256, 256); let r: f32 = sys_w() / sys_h(); draw_begin(mesh_icon); draw_scaled_image(tex, -(256 * r - 256) / 2, 0, 256 * r, 256); @@ -196,7 +196,7 @@ function export_arm_run_project() { export_arm_bgra_swap(mesh_icon_pixels); ///end - sys_notify_on_next_frame(function (mesh_icon: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (mesh_icon: gpu_texture_t) { iron_unload_image(mesh_icon); }); @@ -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_gpu_texture_t[] = []; + let temp_images: 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_gpu_texture_t = project_get_image(assets[i]); - let temp: iron_gpu_texture_t = gpu_create_render_target(image.width, image.height); + let image: gpu_texture_t = project_get_image(assets[i]); + let temp: gpu_texture_t = gpu_create_render_target(image.width, image.height); draw_begin(temp); draw_image(image, 0, 0); draw_end(); @@ -501,9 +501,9 @@ function export_arm_pack_assets(raw: project_format_t, assets: asset_t[]) { array_push(raw.packed_assets, pa); } } - sys_notify_on_next_frame(function (temp_images: iron_gpu_texture_t[]) { + sys_notify_on_next_frame(function (temp_images: gpu_texture_t[]) { for (let i: i32 = 0; i < temp_images.length; ++i) { - let image: iron_gpu_texture_t = temp_images[i]; + let image: gpu_texture_t = temp_images[i]; iron_unload_image(image); } }, temp_images); diff --git a/base/sources/ts/export_texture.ts b/base/sources/ts/export_texture.ts index 39540971..90d11a67 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_gpu_texture_t = rt._image; + let empty: gpu_texture_t = rt._image; // Append object mask name let export_selected: bool = context_raw.layers_export == export_mode_t.SELECTED; @@ -191,11 +191,11 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ // Clear export layer _gpu_begin(layers_expa, null, clear_flag_t.COLOR, color_from_floats(0.0, 0.0, 0.0, 0.0)); - iron_gpu_end(); + gpu_end(); _gpu_begin(layers_expb, null, clear_flag_t.COLOR, color_from_floats(0.5, 0.5, 1.0, 0.0)); - iron_gpu_end(); + gpu_end(); _gpu_begin(layers_expc, null, clear_flag_t.COLOR, color_from_floats(1.0, 0.0, 0.0, 0.0)); - iron_gpu_end(); + gpu_end(); // Flatten layers for (let i: i32 = 0; i < layers.length; ++i) { @@ -217,7 +217,7 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ } } - let mask: iron_gpu_texture_t = empty; + let mask: gpu_texture_t = empty; let l1masks: slot_layer_t[] = slot_layer_get_masks(l1); if (l1masks != null && !bake_material) { if (l1masks.length > 1) { @@ -245,18 +245,18 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ draw_end(); _gpu_begin(layers_expa); - iron_gpu_set_pipeline(pipes_merge); - iron_gpu_set_texture(pipes_tex0, l1.texpaint); - iron_gpu_set_texture(pipes_tex1, empty); - iron_gpu_set_texture(pipes_texmask, mask); - iron_gpu_set_texture(pipes_texa, layers_temp_image); + 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_float(pipes_tex1w, empty.width); gpu_set_int(pipes_blending, layers.length > 1 ? l1.blending : 0); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); } if (l1.paint_nor) { @@ -267,18 +267,18 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ draw_end(); _gpu_begin(layers_expb); - iron_gpu_set_pipeline(pipes_merge); - iron_gpu_set_texture(pipes_tex0, l1.texpaint); - iron_gpu_set_texture(pipes_tex1, l1.texpaint_nor); - iron_gpu_set_texture(pipes_texmask, mask); - iron_gpu_set_texture(pipes_texa, layers_temp_image); + 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_float(pipes_tex1w, l1.texpaint_nor.width); gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); } if (l1.paint_occ || l1.paint_rough || l1.paint_met || l1.paint_height) { @@ -310,9 +310,9 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ ///end ///end - 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; + let texpaint: gpu_texture_t = layers_expa; + let texpaint_nor: gpu_texture_t = layers_expb; + let texpaint_pack: gpu_texture_t = layers_expc; ///if is_lab texpaint = context_raw.brush_output_node_inst.texpaint; @@ -462,7 +462,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_gpu_texture_t = gpu_create_texture_from_bytes(pixels, res_x, res_y); + let image: 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 ff386137..59499064 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_gpu_texture_t = project_layers[0].texpaint; + let tex: 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,16 +196,16 @@ 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_gpu_texture_t = blend0._image; - sys_notify_on_next_frame(function (_texpaint_blend0: iron_gpu_texture_t) { + let _texpaint_blend0: gpu_texture_t = blend0._image; + sys_notify_on_next_frame(function (_texpaint_blend0: gpu_texture_t) { iron_unload_image(_texpaint_blend0); }, _texpaint_blend0); blend0.width = config_get_texture_res_x(); blend0.height = config_get_texture_res_y(); blend0._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8, 0); let blend1: render_target_t = map_get(rts, "texpaint_blend1"); - let _texpaint_blend1: iron_gpu_texture_t = blend1._image; - sys_notify_on_next_frame(function (_texpaint_blend1: iron_gpu_texture_t) { + let _texpaint_blend1: gpu_texture_t = blend1._image; + sys_notify_on_next_frame(function (_texpaint_blend1: gpu_texture_t) { iron_unload_image(_texpaint_blend1); }, _texpaint_blend1); blend1.width = config_get_texture_res_x(); @@ -238,9 +238,9 @@ function import_arm_run_project(path: string) { array_push(project_layers, l); if (!is_group) { - let _texpaint: iron_gpu_texture_t = null; - let _texpaint_nor: iron_gpu_texture_t = null; - let _texpaint_pack: iron_gpu_texture_t = null; + let _texpaint: gpu_texture_t = null; + let _texpaint_nor: gpu_texture_t = null; + let _texpaint_pack: gpu_texture_t = null; if (is_mask) { _texpaint = gpu_create_texture_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4), ld.res, ld.res, tex_format_t.RGBA32); @@ -301,18 +301,18 @@ function import_arm_run_project(path: string) { l.paint_subs = ld.paint_subs; ///end - sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint: gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); ///if is_paint if (_texpaint_nor != null) { - sys_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_nor: gpu_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - sys_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_pack: 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_gpu_texture_t = gpu_create_texture_from_bytes(b, 1, 1); + let pink: 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_gpu_texture_t = gpu_create_texture_from_encoded_bytes(pa.bytes, ends_with(pa.name, ".jpg") ? ".jpg" : ".png"); + let image: 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 c97370ee..886a1420 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_gpu_texture_t = _draw_current; + let current: 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 8f1c78c8..5567d477 100644 --- a/base/sources/ts/import_envmap.ts +++ b/base/sources/ts/import_envmap.ts @@ -1,21 +1,21 @@ -let import_envmap_pipeline: iron_gpu_pipeline_t = null; +let import_envmap_pipeline: gpu_pipeline_t = null; let import_envmap_params_loc: i32; let import_envmap_params: vec4_t = vec4_create(); let import_envmap_n: vec4_t = vec4_create(); let import_envmap_radiance_loc: i32; -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; +let import_envmap_radiance: gpu_texture_t = null; +let import_envmap_radiance_cpu: gpu_texture_t = null; +let import_envmap_mips: gpu_texture_t[] = null; +let import_envmap_mips_cpu: gpu_texture_t[] = null; -function import_envmap_run(path: string, image: iron_gpu_texture_t) { +function import_envmap_run(path: string, image: gpu_texture_t) { // Init if (import_envmap_pipeline == null) { import_envmap_pipeline = gpu_create_pipeline(); import_envmap_pipeline.vertex_shader = sys_get_shader("prefilter_envmap.vert"); import_envmap_pipeline.fragment_shader = sys_get_shader("prefilter_envmap.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: 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; @@ -44,8 +44,8 @@ function import_envmap_run(path: string, image: iron_gpu_texture_t) { let radiance_pixels: buffer_t = gpu_get_texture_pixels(import_envmap_radiance); if (import_envmap_radiance_cpu != null) { - let _radiance_cpu: iron_gpu_texture_t = import_envmap_radiance_cpu; - sys_notify_on_next_frame(function (_radiance_cpu: iron_gpu_texture_t) { + let _radiance_cpu: gpu_texture_t = import_envmap_radiance_cpu; + sys_notify_on_next_frame(function (_radiance_cpu: gpu_texture_t) { iron_unload_image(_radiance_cpu); }, _radiance_cpu); } @@ -54,8 +54,8 @@ function import_envmap_run(path: string, image: iron_gpu_texture_t) { // Radiance if (import_envmap_mips_cpu != null) { for (let i: i32 = 0; i < import_envmap_mips_cpu.length; ++i) { - let mip: iron_gpu_texture_t = import_envmap_mips_cpu[i]; - sys_notify_on_next_frame(function (mip: iron_gpu_texture_t) { + let mip: gpu_texture_t = import_envmap_mips_cpu[i]; + sys_notify_on_next_frame(function (mip: gpu_texture_t) { ///if (!arm_direct3d12) // TODO: crashes after 50+ imports iron_unload_image(mip); ///end @@ -87,16 +87,16 @@ function import_envmap_run(path: string, image: iron_gpu_texture_t) { project_raw.envmap = path; } -function import_envmap_get_radiance_mip(mip: iron_gpu_texture_t, level: i32, radiance: iron_gpu_texture_t) { +function import_envmap_get_radiance_mip(mip: gpu_texture_t, level: i32, radiance: gpu_texture_t) { _gpu_begin(mip); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); - iron_gpu_set_pipeline(import_envmap_pipeline); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_pipeline(import_envmap_pipeline); import_envmap_params.x = 0.1 + level / 8; gpu_set_float4(import_envmap_params_loc, import_envmap_params.x, import_envmap_params.y, import_envmap_params.z, import_envmap_params.w); - iron_gpu_set_texture(import_envmap_radiance_loc, radiance); + gpu_set_texture(import_envmap_radiance_loc, radiance); gpu_draw(); - iron_gpu_end(); + 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 7e86178d..412bae82 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_gpu_texture_t; + image: 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_gpu_texture_t = data_get_image(path); + let image: gpu_texture_t = data_get_image(path); let itd: import_texture_data_t = { path: path, image: image }; sys_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_gpu_texture_t + let importer: any = map_get(path_texture_importers, ext); // JSValue -> (s: string)=>gpu_texture_t let cached: bool = map_get(data_cached_images, path) != null; // Already loaded or pink texture for missing file - let image: iron_gpu_texture_t; + let image: 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_gpu_texture_t { +function import_texture_default_importer(path: string): 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 f16d19c9..357a1fc9 100644 --- a/base/sources/ts/iron/const_data.ts +++ b/base/sources/ts/iron/const_data.ts @@ -1,29 +1,29 @@ -let const_data_screen_aligned_vb: iron_gpu_buffer_t = null; -let const_data_screen_aligned_ib: iron_gpu_buffer_t = null; -let const_data_skydome_vb: iron_gpu_buffer_t = null; -let const_data_skydome_ib: iron_gpu_buffer_t = null; +let const_data_screen_aligned_vb: gpu_buffer_t = null; +let const_data_screen_aligned_ib: gpu_buffer_t = null; +let const_data_skydome_vb: gpu_buffer_t = null; +let const_data_skydome_ib: gpu_buffer_t = null; function const_data_create_screen_aligned_data() { // Over-sized triangle let data: f32[] = [-1.0, -1.0, 3.0, -1.0, -1.0, 3.0]; let indices: i32[] = [0, 1, 2]; - let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let structure: 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); + const_data_screen_aligned_vb = gpu_create_vertex_buffer(math_floor(data.length / math_floor(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_gpu_vertex_buffer_unlock(const_data_screen_aligned_vb); + gpu_vertex_buffer_unlock(const_data_screen_aligned_vb); 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_gpu_index_buffer_unlock(const_data_screen_aligned_ib); + gpu_index_buffer_unlock(const_data_screen_aligned_ib); } ///include "const_data.h" @@ -35,10 +35,10 @@ 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_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let structure: 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); + let struct_length: i32 = math_floor(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) { @@ -49,12 +49,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_gpu_vertex_buffer_unlock(const_data_skydome_vb); + gpu_vertex_buffer_unlock(const_data_skydome_vb); 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_gpu_index_buffer_unlock(const_data_skydome_ib); + gpu_index_buffer_unlock(const_data_skydome_ib); } diff --git a/base/sources/ts/iron/data.ts b/base/sources/ts/iron/data.ts index 0e64f314..7327995b 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_gpu_texture_t { - let cached: iron_gpu_texture_t = map_get(data_cached_images, file); +function data_get_image(file: string, readable: bool = false): gpu_texture_t { + let cached: 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_gpu_texture_ return null; } - let b: iron_gpu_texture_t = image_; + let b: 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_gpu_texture_t = map_get(data_cached_images, handle); + let image: 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_gpu_texture_t = map_get(data_cached_images, cached_images_keys[i]); + let c: 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 ee551619..fb98f318 100644 --- a/base/sources/ts/iron/iron.ts +++ b/base/sources/ts/iron/iron.ts @@ -214,23 +214,23 @@ declare function iron_show_keyboard(show: bool): 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 iron_gpu_index_buffer_unlock(buffer: any): void; -declare function iron_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_index_buffer_unlock(buffer: any): void; +declare function gpu_set_index_buffer(buffer: any): void; +declare function gpu_create_vertex_buffer(count: i32, structure: gpu_vertex_structure_t, usage: i32): any; declare function gpu_delete_vertex_buffer(buffer: any): void; declare function gpu_lock_vertex_buffer(buffer: any): buffer_t; -declare function iron_gpu_vertex_buffer_unlock(buffer: any): void; -declare function iron_gpu_set_vertex_buffer(buffer: any): void; +declare function gpu_vertex_buffer_unlock(buffer: any): void; +declare function gpu_set_vertex_buffer(buffer: any): void; declare function gpu_draw(): void; -declare function gpu_create_shader(data: buffer_t, type: i32): iron_gpu_shader_t; -declare function gpu_create_shader_from_source(source: string, source_size: i32, 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_shader(data: buffer_t, type: i32): gpu_shader_t; +declare function gpu_create_shader_from_source(source: string, source_size: i32, shader_type: shader_type_t): gpu_shader_t; +declare function gpu_shader_destroy(shader: 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 gpu_set_pipeline(pipeline: any): void; declare function iron_load_image(file: string, readable: bool): any; -declare function iron_unload_image(image: iron_gpu_texture_t): void; +declare function iron_unload_image(image: gpu_texture_t): void; declare function iron_load_sound(file: string): any; declare function iron_a1_sound_destroy(sound: any): void; declare function iron_a1_play_sound(sound: any, loop: bool, pitch: f32, unique: bool): audio_channel_t; @@ -240,8 +240,8 @@ 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_gpu_set_texture(stage: i32, texture: iron_gpu_texture_t): void; -declare function iron_gpu_set_texture_depth(unit: i32, texture: iron_gpu_texture_t): void; +declare function gpu_set_texture(stage: i32, texture: gpu_texture_t): void; +declare function gpu_set_texture_depth(unit: i32, texture: gpu_texture_t): void; declare function gpu_set_bool(location: i32, value: bool): void; declare function gpu_set_int(location: i32, value: i32): void; declare function gpu_set_float(location: i32, value: f32): void; @@ -275,15 +275,15 @@ declare function gpu_create_render_target(width: i32, height: i32, format: i32 = 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 iron_gpu_viewport(x: i32, y: i32, width: i32, height: i32): void; -declare function iron_gpu_scissor(x: i32, y: i32, width: i32, height: i32): void; -declare function iron_gpu_disable_scissor(): void; -declare function _gpu_begin(render_target: iron_gpu_texture_t, additional: iron_gpu_texture_t[] = null, flags: i32 = clear_flag_t.NONE, color: i32 = 0, depth: f32 = 0.0): void; -declare function iron_gpu_end(): void; -declare function iron_gpu_present(): void; +declare function gpu_texture_generate_mipmaps(texture: any, levels: i32): void; +declare function gpu_set_mipmaps(texture: any, mipmaps: gpu_texture_t[]): void; +declare function 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: gpu_texture_t, additional: gpu_texture_t[] = null, flags: i32 = clear_flag_t.NONE, color: i32 = 0, depth: f32 = 0.0): void; +declare function gpu_end(): void; +declare function gpu_present(): 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; @@ -293,12 +293,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, rect_vert: buffer_t, rect_frag: buffer_t, tris_vert: buffer_t, tris_frag: buffer_t, text_vert: buffer_t, text_frag: buffer_t): void; -declare function draw_begin(render_target: iron_gpu_texture_t = null, clear: bool = false, color: u32 = 0): void; +declare function draw_begin(render_target: gpu_texture_t = null, clear: bool = false, color: u32 = 0): void; declare function draw_end(): 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_scaled_sub_image(image: 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: gpu_texture_t, x: f32, y: f32, sx: f32, sy: f32, sw: f32, sh: f32): void; +declare function draw_scaled_image(image: gpu_texture_t, dx: f32, dy: f32, dw: f32, dh: f32): void; +declare function draw_image(image: 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; @@ -355,13 +355,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_gpu_raytrace_supported(): bool; +declare function 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_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_set_textures(tex0: gpu_texture_t, tex1: gpu_texture_t, tex2: 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; @@ -576,22 +576,22 @@ declare function f32_nan(): f32; declare function f32_isnan(f: f32): bool; -function gpu_vertex_struct_create(): iron_gpu_vertex_structure_t { - let raw: iron_gpu_vertex_structure_t = {}; +function gpu_vertex_struct_create(): gpu_vertex_structure_t { + let raw: gpu_vertex_structure_t = {}; return raw; } -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)); +function gpu_vertex_struct_add(raw: gpu_vertex_structure_t, name: string, data: vertex_data_t) { + let e: gpu_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw.elements, raw.size)); e.name = name; e.data = data; raw.size++; } -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 function gpu_vertex_struct_size(s: gpu_vertex_structure_t): i32; +declare function gpu_vertex_data_size(data: vertex_data_t); -declare type iron_gpu_pipeline_t = { +declare type gpu_pipeline_t = { input_layout?: any; vertex_shader?: any; fragment_shader?: any; @@ -617,21 +617,21 @@ declare type iron_gpu_pipeline_t = { impl?: any; }; -declare type iron_gpu_shader_t = { +declare type gpu_shader_t = { impl?: any; }; -declare type iron_gpu_vertex_element_t = { +declare type gpu_vertex_element_t = { name?: string; data?: vertex_data_t; }; -declare type iron_gpu_vertex_structure_t = { - elements?: any; // iron_gpu_vertex_element_t[IRON_GPU_MAX_VERTEX_ELEMENTS]; +declare type gpu_vertex_structure_t = { + elements?: any; // gpu_vertex_element_t[GPU_MAX_VERTEX_ELEMENTS]; size?: i32; }; -declare type iron_gpu_buffer_t = { +declare type gpu_buffer_t = { impl?: any; }; @@ -774,7 +774,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_gpu_texture_t = { +declare type gpu_texture_t = { width: i32; height: i32; }; @@ -837,7 +837,7 @@ declare type ui_handle_t = { color: u32; value: f32; text: string; - // iron_gpu_texture_t texture; + // gpu_texture_t texture; redraws: i32; scroll_offset: f32; scroll_enabled: bool; @@ -856,8 +856,8 @@ declare type ui_options_t = { font?: draw_font_t; theme?: ui_theme_t; scale_factor?: f32; - color_wheel?: iron_gpu_texture_t; - black_white_gradient?: iron_gpu_texture_t; + color_wheel?: gpu_texture_t; + black_white_gradient?: gpu_texture_t; }; declare type ui_coloring_t = { @@ -965,7 +965,7 @@ let ui_children: map_t = map_create(); let ui_nodes_custom_buttons: map_tvoid> = map_create(); declare function UI_OUTPUTS_H(sockets_count: i32, length: i32 = -1): f32; -declare function ui_tooltip_image(image: iron_gpu_texture_t, max_width: i32 = 0); +declare function ui_tooltip_image(image: gpu_texture_t, max_width: i32 = 0); function ui_SCALE(ui: ui_t): f32 { let current: ui_t = ui_get_current(); @@ -1008,7 +1008,7 @@ function ui_nodes_INPUT_Y(canvas: ui_node_canvas_t, sockets: ui_node_socket_t[], return UI_INPUT_Y(canvas, sockets.buffer, sockets.length, pos); } -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 { +function _ui_image(image: 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); } diff --git a/base/sources/ts/iron/material_data.ts b/base/sources/ts/iron/material_data.ts index ac806aaa..96dae369 100644 --- a/base/sources/ts/iron/material_data.ts +++ b/base/sources/ts/iron/material_data.ts @@ -79,19 +79,19 @@ function material_context_create(raw: material_context_t): material_context_t { continue; } - let image: iron_gpu_texture_t = data_get_image(tex.file, false); + let image: gpu_texture_t = data_get_image(tex.file, false); array_push(raw._.textures, image); // Set mipmaps if (tex.mipmaps != null) { - let mipmaps: iron_gpu_texture_t[] = []; + let mipmaps: 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_gpu_texture_t = data_get_image(name); + let mipimg: gpu_texture_t = data_get_image(name); mipmaps[j] = mipimg; } @@ -100,7 +100,7 @@ function material_context_create(raw: material_context_t): material_context_t { tex.generate_mipmaps = false; } else if (tex.generate_mipmaps == true && image != null) { - iron_gpu_texture_generate_mipmaps(image, 1000); + 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 0b1dd5a5..d2a83eb1 100644 --- a/base/sources/ts/iron/mesh_data.ts +++ b/base/sources/ts/iron/mesh_data.ts @@ -104,8 +104,8 @@ 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_gpu_vertex_structure_t { - let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); +function mesh_data_get_vertex_struct(vertex_arrays: vertex_array_t[]): gpu_vertex_structure_t { + let structure: gpu_vertex_structure_t = gpu_vertex_struct_create(); for (let i: i32 = 0; i < vertex_arrays.length; ++i) { gpu_vertex_struct_add(structure, vertex_arrays[i].attrib, mesh_data_get_vertex_data(vertex_arrays[i].data)); } @@ -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_gpu_buffer_t { +function mesh_data_get(raw: mesh_data_t, vs: vertex_element_t[]): gpu_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_gpu_buffer_t = map_get(raw._.vertex_buffer_map, key); + let vb: gpu_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_gpu_buffe 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_gpu_vertex_structure_t = mesh_data_get_vertex_struct(vertex_arrays); + let vstruct: gpu_vertex_structure_t = mesh_data_get_vertex_struct(vertex_arrays); let size: i32 = mesh_data_get_vertex_size(positions.data); 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_gpu_vertex_buffer_unlock(vb); + gpu_vertex_buffer_unlock(vb); map_set(raw._.vertex_buffer_map, key, vb); if (has_tex && uvs == null) { iron_log("Geometry " + raw.name + " is missing UV map"); @@ -223,11 +223,11 @@ function mesh_data_build(raw: mesh_data_t) { 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_gpu_vertex_buffer_unlock(raw._.vertex_buffer); + gpu_vertex_buffer_unlock(raw._.vertex_buffer); let struct_str: string = ""; for (let i: i32 = 0; i < raw._.structure.size; ++i) { - let e: iron_gpu_vertex_element_t = ADDRESS(ARRAY_ACCESS(raw._.structure.elements, i)); + let e: 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_gpu_buffer_t = gpu_create_index_buffer(id.length); + let index_buffer: gpu_buffer_t = gpu_create_index_buffer(id.length); 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_gpu_index_buffer_unlock(index_buffer); + gpu_index_buffer_unlock(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_gpu_buffer_t = map_get(raw._.vertex_buffer_map, vertex_buffer_keys[i]); + let buf: gpu_buffer_t = map_get(raw._.vertex_buffer_map, vertex_buffer_keys[i]); if (buf != null) { gpu_delete_vertex_buffer(buf); } } for (let i: i32 = 0; i < raw._.index_buffers.length; ++i) { - let buf: iron_gpu_buffer_t = raw._.index_buffers[i]; + let buf: gpu_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 12005bbd..30db23de 100644 --- a/base/sources/ts/iron/mesh_object.ts +++ b/base/sources/ts/iron/mesh_object.ts @@ -11,7 +11,7 @@ type mesh_object_t = { force_context?: string; // Draw only this context }; -let _mesh_object_last_pipeline: iron_gpu_pipeline_t = null; +let _mesh_object_last_pipeline: gpu_pipeline_t = null; let _mesh_object_material_contexts: material_context_t[] = []; let _mesh_object_shader_contexts: shader_context_t[] = []; @@ -170,7 +170,7 @@ function mesh_object_render(raw: mesh_object_t, context: string, bind_params: st // Uniforms if (scontext._.pipe_state != _mesh_object_last_pipeline) { - iron_gpu_set_pipeline(scontext._.pipe_state); + gpu_set_pipeline(scontext._.pipe_state); _mesh_object_last_pipeline = scontext._.pipe_state; } uniforms_set_context_consts(scontext, bind_params); @@ -179,8 +179,8 @@ function mesh_object_render(raw: mesh_object_t, context: string, bind_params: st uniforms_set_material_consts(scontext, material_contexts[mi]); } - iron_gpu_set_vertex_buffer(mesh_data_get(raw.data, elems)); - iron_gpu_set_index_buffer(raw.data._.index_buffers[i]); + gpu_set_vertex_buffer(mesh_data_get(raw.data, elems)); + gpu_set_index_buffer(raw.data._.index_buffers[i]); gpu_draw(); } } diff --git a/base/sources/ts/iron/render_path.ts b/base/sources/ts/iron/render_path.ts index b52d1825..05f3b61a 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_gpu_texture_t; // RT or image + _image?: 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_gpu_texture_t = null; +let _render_path_current_image: 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, fla else { // Render target let rt: render_target_t = map_get(render_path_render_targets, target); _render_path_current_target = rt; - let additional_images: iron_gpu_texture_t[] = null; + let additional_images: gpu_texture_t[] = null; if (additional != null) { additional_images = []; for (let i: i32 = 0; i < additional.length; ++i) { @@ -108,10 +108,10 @@ function render_path_set_target(target: string, additional: string[] = null, fla 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_gpu_render_target_set_depth_from(rt._image, rt_from._image); + gpu_render_target_set_depth_from(rt._image, rt_from._image); } -function render_path_begin(render_target: iron_gpu_texture_t, additional_targets: iron_gpu_texture_t[], flags: i32, color: i32, depth: f32) { +function render_path_begin(render_target: gpu_texture_t, additional_targets: gpu_texture_t[], flags: i32, color: i32, depth: f32) { if (_render_path_current_image != null) { render_path_end(); } @@ -121,20 +121,20 @@ function render_path_begin(render_target: iron_gpu_texture_t, additional_targets function render_path_end() { if (_render_path_scissor_set) { - iron_gpu_disable_scissor(); + gpu_disable_scissor(); _render_path_scissor_set = false; } - iron_gpu_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_gpu_viewport(sys_x(),render_path_current_h - (view_h - sys_y()), view_w, view_h); + gpu_viewport(sys_x(),render_path_current_h - (view_h - sys_y()), view_w, view_h); } function render_path_set_current_scissor(view_w: i32, view_h: i32) { - iron_gpu_scissor(sys_x(),render_path_current_h - (view_h - sys_y()), view_w, view_h); + gpu_scissor(sys_x(),render_path_current_h - (view_h - sys_y()), view_w, view_h); _render_path_scissor_set = true; } @@ -145,7 +145,7 @@ function render_path_set_viewport(view_w: i32, view_h: i32) { function render_path_gen_mipmaps(target: string) { let rt: render_target_t = map_get(render_path_render_targets, target); - iron_gpu_texture_generate_mipmaps(rt._image, 1000); + gpu_texture_generate_mipmaps(rt._image, 1000); } function _render_path_sort_dist(a: any_ptr, b: any_ptr): i32 { @@ -209,11 +209,11 @@ function render_path_draw_skydome(handle: string) { if (cc.context == null) { return; // World data not specified } - iron_gpu_set_pipeline(cc.context._.pipe_state); + 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_gpu_set_vertex_buffer(const_data_skydome_vb); - iron_gpu_set_index_buffer(const_data_skydome_ib); + gpu_set_vertex_buffer(const_data_skydome_vb); + gpu_set_index_buffer(const_data_skydome_ib); gpu_draw(); render_path_end(); } @@ -235,11 +235,11 @@ function render_path_draw_shader(handle: string) { if (const_data_screen_aligned_vb == null) { const_data_create_screen_aligned_data(); } - iron_gpu_set_pipeline(cc.context._.pipe_state); + 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_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); render_path_end(); @@ -281,7 +281,7 @@ function render_path_unload() { } } -function _render_path_resize_on_init(_image: iron_gpu_texture_t) { +function _render_path_resize_on_init(_image: gpu_texture_t) { iron_unload_image(_image); } @@ -310,7 +310,7 @@ function render_path_resize() { } if (nodepth != null) { - iron_gpu_render_target_set_depth_from(rt._image, nodepth._image); + gpu_render_target_set_depth_from(rt._image, nodepth._image); } } @@ -318,7 +318,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_gpu_texture_t = rt._image; + let _image: gpu_texture_t = rt._image; sys_notify_on_init(_render_path_resize_on_init, _image); rt._image = render_path_create_image(rt, rt._depth_buffer_bits); } @@ -329,7 +329,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_gpu_render_target_set_depth_from(rt._image, depth_from._image); + gpu_render_target_set_depth_from(rt._image, depth_from._image); } } } @@ -368,7 +368,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_gpu_render_target_set_depth_from(t._image, depth_target._image); + gpu_render_target_set_depth_from(t._image, depth_target._image); } } else { // No depth buffer @@ -379,7 +379,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_gpu_texture_t { +function render_path_create_image(t: render_target_t, depth_buffer_bits: i32): gpu_texture_t { let width: i32 = t.width == 0 ? sys_w() : t.width; let height: i32 = t.height == 0 ? sys_h() : t.height; width = math_floor(width * t.scale); diff --git a/base/sources/ts/iron/scene.ts b/base/sources/ts/iron/scene.ts index 05c1dc0f..95ee573b 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_gpu_texture_t = data_get_image(file); + let image: 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_gpu_buffer_t; - vertex_buffer_map?: map_t; - index_buffers?: iron_gpu_buffer_t[]; + vertex_buffer?: gpu_buffer_t; + vertex_buffer_map?: map_t; + index_buffers?: gpu_buffer_t[]; ready?: bool; vertices?: buffer_t; indices?: u32_array_t[]; material_indices?: i32[]; - structure?: iron_gpu_vertex_structure_t; + structure?: 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_gpu_texture_t[]; + textures?: gpu_texture_t[]; }; type bind_const_t = { @@ -594,10 +594,10 @@ type shader_context_t = { }; type shader_context_runtime_t = { - pipe_state?: iron_gpu_pipeline_t; + pipe_state?: gpu_pipeline_t; constants?: i32[]; tex_units?: i32[]; - structure?: iron_gpu_vertex_structure_t; + structure?: gpu_vertex_structure_t; vertex_shader_size?: i32; fragment_shader_size?: i32; }; @@ -641,9 +641,9 @@ type world_data_t = { }; type world_data_runtime_t = { - envmap?: iron_gpu_texture_t; - radiance?: iron_gpu_texture_t; - radiance_mipmaps?: iron_gpu_texture_t[]; + envmap?: gpu_texture_t; + radiance?: gpu_texture_t; + radiance_mipmaps?: 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 05aeeca3..e716865f 100644 --- a/base/sources/ts/iron/shader_data.ts +++ b/base/sources/ts/iron/shader_data.ts @@ -274,10 +274,10 @@ function shader_context_parse_vertex_struct(raw: shader_context_t) { function shader_context_delete(raw: shader_context_t) { if (raw._.pipe_state.fragment_shader != null) { - iron_gpu_shader_destroy(raw._.pipe_state.fragment_shader); + gpu_shader_destroy(raw._.pipe_state.fragment_shader); } if (raw._.pipe_state.vertex_shader != null) { - iron_gpu_shader_destroy(raw._.pipe_state.vertex_shader); + gpu_shader_destroy(raw._.pipe_state.vertex_shader); } gpu_delete_pipeline(raw._.pipe_state); } diff --git a/base/sources/ts/iron/sys.ts b/base/sources/ts/iron/sys.ts index 8c2fd739..902c194d 100644 --- a/base/sources/ts/iron/sys.ts +++ b/base/sources/ts/iron/sys.ts @@ -22,7 +22,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; @@ -300,8 +300,8 @@ function sys_shader_ext(): string { ///end } -function sys_get_shader(name: string): iron_gpu_shader_t { - let shader: iron_gpu_shader_t = map_get(_sys_shaders, name); +function sys_get_shader(name: string): gpu_shader_t { + let shader: gpu_shader_t = map_get(_sys_shaders, name); if (shader == null) { shader = gpu_create_shader( iron_load_blob(data_path() + name + sys_shader_ext()), diff --git a/base/sources/ts/iron/uniforms.ts b/base/sources/ts/iron/uniforms.ts index e0141a4a..589aeed5 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_gpu_texture_t = null; +let uniforms_tex_links: (o: object_t, md: material_data_t, s: string)=>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,18 +57,18 @@ function uniforms_set_context_consts(context: shader_context_t, bind_params: str } if (char_at(tulink, 0) == "$") { // Link to embedded data - iron_gpu_set_texture(context._.tex_units[j], map_get(scene_embedded, substring(tulink, 1, tulink.length))); + gpu_set_texture(context._.tex_units[j], map_get(scene_embedded, substring(tulink, 1, tulink.length))); } else if (tulink == "_envmap_radiance") { let w: world_data_t = scene_world; if (w != null) { - iron_gpu_set_texture(context._.tex_units[j], w._.radiance); + gpu_set_texture(context._.tex_units[j], w._.radiance); } } else if (tulink == "_envmap") { let w: world_data_t = scene_world; if (w != null) { - iron_gpu_set_texture(context._.tex_units[j], w._.envmap); + gpu_set_texture(context._.tex_units[j], w._.envmap); } } } @@ -93,11 +93,11 @@ function uniforms_set_obj_consts(context: shader_context_t, object: object_t) { continue; } - let image: iron_gpu_texture_t = uniforms_tex_links(object, current_material(object), tu.link); + let image: gpu_texture_t = uniforms_tex_links(object, current_material(object), tu.link); if (image != null) { ends_with(tu.link, "_depth") ? - iron_gpu_set_texture_depth(context._.tex_units[j], image) : - iron_gpu_set_texture(context._.tex_units[j], image); + gpu_set_texture_depth(context._.tex_units[j], image) : + gpu_set_texture(context._.tex_units[j], image); } } } @@ -113,10 +113,10 @@ function uniforms_bind_render_target(rt: render_target_t, context: shader_contex for (let j: i32 = 0; j < tus.length; ++j) { // Set texture if (sampler_id == tus[j].name) { if (attach_depth) { - iron_gpu_set_texture_depth(context._.tex_units[j], rt._image); // sampler2D + gpu_set_texture_depth(context._.tex_units[j], rt._image); // sampler2D } else { - iron_gpu_set_texture(context._.tex_units[j], rt._image); // sampler2D + gpu_set_texture(context._.tex_units[j], rt._image); // sampler2D } } } @@ -560,7 +560,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_gpu_set_texture(context._.tex_units[j], material_context._.textures[i]); + gpu_set_texture(context._.tex_units[j], material_context._.textures[i]); break; } } diff --git a/base/sources/ts/iron/world_data.ts b/base/sources/ts/iron/world_data.ts index a42528cb..d21ece74 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_gpu_texture_t = data_get_image(raw.radiance); + let rad: 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,7 +25,7 @@ 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_gpu_texture_t = data_get_image(base + "_" + i + ext, true); + let mipimg: gpu_texture_t = data_get_image(base + "_" + i + ext, true); raw._.radiance_mipmaps[i] = mipimg; } gpu_set_mipmaps(raw._.radiance, raw._.radiance_mipmaps); @@ -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_gpu_texture_t = data_get_image(raw.envmap); + let image: 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 21417e66..41baa61f 100644 --- a/base/sources/ts/layers.ts +++ b/base/sources/ts/layers.ts @@ -1,8 +1,8 @@ -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_temp_image: gpu_texture_t = null; +let layers_expa: gpu_texture_t = null; +let layers_expb: gpu_texture_t = null; +let layers_expc: gpu_texture_t = null; let layers_default_base: f32 = 0.5; let layers_default_rough: f32 = 0.4; let layers_max_layers: i32 = @@ -34,18 +34,18 @@ function layers_init() { draw_end(); // Nor _gpu_begin(texpaint_nor._image, null, clear_flag_t.COLOR, color_from_floats(0.5, 0.5, 1.0, 0.0)); - iron_gpu_end(); + gpu_end(); // Occ, rough, met _gpu_begin(texpaint_pack._image, null, clear_flag_t.COLOR, color_from_floats(1.0, 0.4, 0.0, 0.0)); - iron_gpu_end(); + 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"); // Nor _gpu_begin(texpaint_nor_empty._image, null, clear_flag_t.COLOR, color_from_floats(0.5, 0.5, 1.0, 0.0)); - iron_gpu_end(); + gpu_end(); // Occ, rough, met _gpu_begin(texpaint_pack_empty._image, null, clear_flag_t.COLOR, color_from_floats(1.0, 0.4, 0.0, 0.0)); - iron_gpu_end(); + gpu_end(); ///end } @@ -75,8 +75,8 @@ 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_gpu_texture_t = blend0._image; - sys_notify_on_next_frame(function (_texpaint_blend0: iron_gpu_texture_t) { + let _texpaint_blend0: gpu_texture_t = blend0._image; + sys_notify_on_next_frame(function (_texpaint_blend0: gpu_texture_t) { iron_unload_image(_texpaint_blend0); }, _texpaint_blend0); blend0.width = config_get_texture_res_x(); @@ -84,8 +84,8 @@ function layers_resize() { 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_gpu_texture_t = blend1._image; - sys_notify_on_next_frame(function (_texpaint_blend1: iron_gpu_texture_t) { + let _texpaint_blend1: gpu_texture_t = blend1._image; + sys_notify_on_next_frame(function (_texpaint_blend1: gpu_texture_t) { iron_unload_image(_texpaint_blend1); }, _texpaint_blend1); blend1.width = config_get_texture_res_x(); @@ -96,8 +96,8 @@ function layers_resize() { let blur: render_target_t = map_get(rts, "texpaint_blur"); if (blur != null) { - let _texpaint_blur: iron_gpu_texture_t = blur._image; - sys_notify_on_next_frame(function (_texpaint_blur: iron_gpu_texture_t) { + let _texpaint_blur: gpu_texture_t = blur._image; + sys_notify_on_next_frame(function (_texpaint_blur: gpu_texture_t) { iron_unload_image(_texpaint_blur); }, _texpaint_blur); let size_x: f32 = math_floor(config_get_texture_res_x() * 0.95); @@ -160,8 +160,8 @@ 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_gpu_texture_t = pipes_temp_mask_image; - sys_notify_on_next_frame(function (_temp_mask_image: iron_gpu_texture_t) { + let _temp_mask_image: gpu_texture_t = pipes_temp_mask_image; + sys_notify_on_next_frame(function (_temp_mask_image: gpu_texture_t) { iron_unload_image(_temp_mask_image); }, _temp_mask_image); pipes_temp_mask_image = null; @@ -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_gpu_texture_t = layers_expa; - let _expb: iron_gpu_texture_t = layers_expb; - let _expc: iron_gpu_texture_t = layers_expc; - sys_notify_on_next_frame(function (_expa: iron_gpu_texture_t) { + let _expa: gpu_texture_t = layers_expa; + let _expb: gpu_texture_t = layers_expb; + let _expc: gpu_texture_t = layers_expc; + sys_notify_on_next_frame(function (_expa: gpu_texture_t) { iron_unload_image(_expa); }, _expa); - sys_notify_on_next_frame(function (_expb: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_expb: gpu_texture_t) { iron_unload_image(_expb); }, _expb); - sys_notify_on_next_frame(function (_expc: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_expc: gpu_texture_t) { iron_unload_image(_expc); }, _expc); layers_expa = null; @@ -256,29 +256,29 @@ function layers_apply_mask(l: slot_layer_t, m: slot_layer_t) { // Apply mask _gpu_begin(l.texpaint); - iron_gpu_set_pipeline(pipes_apply_mask); - iron_gpu_set_texture(pipes_tex0_mask, layers_temp_image); - iron_gpu_set_texture(pipes_texa_mask, m.texpaint); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + 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(); - iron_gpu_end(); + gpu_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) { +function layers_commands_merge_pack(pipe: gpu_pipeline_t, i0: gpu_texture_t, i1: gpu_texture_t, i1pack: gpu_texture_t, i1mask_opacity: f32, i1texmask: gpu_texture_t, i1blending: i32 = -1) { _gpu_begin(i0); - iron_gpu_set_pipeline(pipe); - iron_gpu_set_texture(pipes_tex0, i1); - iron_gpu_set_texture(pipes_tex1, i1pack); - iron_gpu_set_texture(pipes_texmask, i1texmask); - iron_gpu_set_texture(pipes_texa, layers_temp_image); + 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_float(pipes_tex1w, i1pack.width); gpu_set_int(pipes_blending, i1blending); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); } function layers_is_fill_material(): bool { @@ -300,7 +300,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_gpu_texture_t = null; + let current: gpu_texture_t = null; if (context_raw.tool == workspace_tool_t.MATERIAL) { if (render_path_paint_live_layer == null) { @@ -400,7 +400,7 @@ function layers_update_fill_layers() { } function layers_update_fill_layer(parse_paint: bool = true) { - let current: iron_gpu_texture_t = _draw_current; + let current: gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -719,8 +719,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_gpu_texture_t = empty_rt._image; - let mask: iron_gpu_texture_t = empty; + let empty: gpu_texture_t = empty_rt._image; + let mask: 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) { @@ -731,32 +731,32 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool if (slot_layer_is_mask(l1)) { _gpu_begin(l0.texpaint); - iron_gpu_set_pipeline(pipes_merge_mask); - iron_gpu_set_texture(pipes_tex0_merge_mask, l1.texpaint); - iron_gpu_set_texture(pipes_texa_merge_mask, layers_temp_image); + 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); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); } if (slot_layer_is_layer(l1)) { if (l1.paint_base) { _gpu_begin(l0.texpaint); - iron_gpu_set_pipeline(pipes_merge); - iron_gpu_set_texture(pipes_tex0, l1.texpaint); - iron_gpu_set_texture(pipes_tex1, empty); - iron_gpu_set_texture(pipes_texmask, mask); - iron_gpu_set_texture(pipes_texa, layers_temp_image); + 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_float(pipes_tex1w, empty.width); gpu_set_int(pipes_blending, l1.blending); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); } if (l0.texpaint_nor != null) { @@ -768,18 +768,18 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool if (l1.paint_nor) { _gpu_begin(l0.texpaint_nor); - iron_gpu_set_pipeline(pipes_merge); - iron_gpu_set_texture(pipes_tex0, l1.texpaint); - iron_gpu_set_texture(pipes_tex1, l1.texpaint_nor); - iron_gpu_set_texture(pipes_texmask, mask); - iron_gpu_set_texture(pipes_texa, layers_temp_image); + 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_float(pipes_tex1w, l1.texpaint_nor.width); gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101); - iron_gpu_set_vertex_buffer(const_data_screen_aligned_vb); - iron_gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); } } diff --git a/base/sources/ts/line_draw.ts b/base/sources/ts/line_draw.ts index 2668e868..31b921bc 100644 --- a/base/sources/ts/line_draw.ts +++ b/base/sources/ts/line_draw.ts @@ -4,10 +4,10 @@ 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_gpu_buffer_t; -let line_draw_index_buffer: iron_gpu_buffer_t; -let line_draw_pipeline: iron_gpu_pipeline_t = null; -let line_draw_overlay_pipeline: iron_gpu_pipeline_t = null; +let line_draw_vertex_buffer: gpu_buffer_t; +let line_draw_index_buffer: gpu_buffer_t; +let line_draw_pipeline: gpu_pipeline_t = null; +let line_draw_overlay_pipeline: gpu_pipeline_t = null; let line_draw_vp: mat4_t; let line_draw_vp_loc: i32; @@ -40,7 +40,7 @@ let line_draw_camera_look: vec4_t = vec4_create(); function line_draw_init() { if (line_draw_pipeline == null) { - let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let structure: 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; @@ -63,7 +63,7 @@ function line_draw_init() { line_draw_index_buffer = gpu_create_index_buffer(line_draw_max_indices); } if (line_draw_overlay_pipeline == null) { - let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let structure: 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; @@ -228,12 +228,12 @@ function line_draw_begin() { } function line_draw_end(overlay: bool = false) { - iron_gpu_vertex_buffer_unlock(line_draw_vertex_buffer); - iron_gpu_index_buffer_unlock(line_draw_index_buffer); + gpu_vertex_buffer_unlock(line_draw_vertex_buffer); + gpu_index_buffer_unlock(line_draw_index_buffer); - iron_gpu_set_vertex_buffer(line_draw_vertex_buffer); - iron_gpu_set_index_buffer(line_draw_index_buffer); - iron_gpu_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); + 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); @@ -248,8 +248,8 @@ function line_draw_end(overlay: bool = false) { //// } -let _shape_draw_sphere_vb: iron_gpu_buffer_t = null; -let _shape_draw_sphere_ib: iron_gpu_buffer_t = null; +let _shape_draw_sphere_vb: gpu_buffer_t = null; +let _shape_draw_sphere_ib: gpu_buffer_t = null; function shape_draw_sphere(mat: mat4_t) { line_draw_init(); @@ -259,7 +259,7 @@ 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_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let structure: 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); @@ -268,13 +268,13 @@ function shape_draw_sphere(mat: mat4_t) { 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_gpu_vertex_buffer_unlock(_shape_draw_sphere_vb); + gpu_vertex_buffer_unlock(_shape_draw_sphere_vb); _shape_draw_sphere_ib = md._.index_buffers[0]; } - iron_gpu_set_vertex_buffer(_shape_draw_sphere_vb); - iron_gpu_set_index_buffer(_shape_draw_sphere_ib); - iron_gpu_set_pipeline(line_draw_overlay_pipeline); + gpu_set_vertex_buffer(_shape_draw_sphere_vb); + gpu_set_index_buffer(_shape_draw_sphere_ib); + 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; diff --git a/base/sources/ts/logic_node.ts b/base/sources/ts/logic_node.ts index 10c3667c..c2991f2a 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_gpu_texture_t; - get_cached_image?: (self: any)=>iron_gpu_texture_t; + get_as_image?: (self: any, from: i32)=>gpu_texture_t; + get_cached_image?: (self: any)=>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_gpu_texture_t { +function logic_node_get_as_image(self: logic_node_t, from: i32): 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_gpu_texture_t { +function logic_node_get_cached_image(self: logic_node_t): 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_gpu_texture_t { +function logic_node_input_get_as_image(self: logic_node_input_t): 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 84fe7632..ac6b554f 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_gpu_texture_t; + image?: 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_gpu_texture_t { +function color_node_get_as_image(self: color_node_t, from: i32): gpu_texture_t { if (self.base.inputs.length > 0) { return logic_node_input_get_as_image(self.base.inputs[0]); } diff --git a/base/sources/ts/nodes/float_node.ts b/base/sources/ts/nodes/float_node.ts index d49fe37e..4556cd26 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_gpu_texture_t; + image?: 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_gpu_texture_t { +function float_node_get_as_image(self: float_node_t, from: i32): gpu_texture_t { if (self.base.inputs.length > 0) { return logic_node_input_get_as_image(self.base.inputs[0]); } diff --git a/base/sources/ts/nodes/vector_node.ts b/base/sources/ts/nodes/vector_node.ts index 3c6afaa5..cc147e28 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_gpu_texture_t; + image?: 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_gpu_texture_t { +function vector_node_get_as_image(self: vector_node_t, from: i32): 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]); diff --git a/base/sources/ts/parser_material.ts b/base/sources/ts/parser_material.ts index fc75fb23..6829a5a9 100644 --- a/base/sources/ts/parser_material.ts +++ b/base/sources/ts/parser_material.ts @@ -469,7 +469,7 @@ function _parser_material_cache_tex_text_node(file: string, text: string) { if (map_get(data_cached_images, file) == null) { sys_notify_on_init(function(text: string) { let _text_tool_text: string = context_raw.text_tool_text; - let _text_tool_image: iron_gpu_texture_t = context_raw.text_tool_image; + let _text_tool_image: 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 c975ebf6..3205d14b 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_gpu_texture_t +let path_texture_importers: map_t = map_create(); // JSValue -> (s: string)=>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 589c7825..8229eed3 100644 --- a/base/sources/ts/pipes.ts +++ b/base/sources/ts/pipes.ts @@ -1,23 +1,23 @@ -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: gpu_pipeline_t; +let pipes_copy8: gpu_pipeline_t; +let pipes_copy128: gpu_pipeline_t; +let pipes_copy_bgra: gpu_pipeline_t; +let pipes_copy_rgb: gpu_pipeline_t = null; +let pipes_copy_r: gpu_pipeline_t; +let pipes_copy_g: gpu_pipeline_t; +let pipes_copy_a: gpu_pipeline_t; let pipes_copy_a_tex: i32; -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_merge: gpu_pipeline_t = null; +let pipes_merge_r: gpu_pipeline_t = null; +let pipes_merge_g: gpu_pipeline_t = null; +let pipes_merge_b: gpu_pipeline_t = null; +let pipes_merge_mask: gpu_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_invert8: gpu_pipeline_t; +let pipes_apply_mask: gpu_pipeline_t; +let pipes_colorid_to_mask: gpu_pipeline_t; let pipes_tex0: i32; let pipes_tex1: i32; @@ -34,13 +34,13 @@ let pipes_tex_colorid: i32; let pipes_texpaint_colorid: i32; let pipes_opac_merge_mask: i32; let pipes_blending_merge_mask: i32; -let pipes_temp_mask_image: iron_gpu_texture_t = null; +let pipes_temp_mask_image: gpu_texture_t = null; -let pipes_inpaint_preview: iron_gpu_pipeline_t; +let pipes_inpaint_preview: gpu_pipeline_t; let pipes_tex0_inpaint_preview: i32; let pipes_texa_inpaint_preview: i32; -let pipes_cursor: iron_gpu_pipeline_t; +let pipes_cursor: gpu_pipeline_t; let pipes_cursor_vp: i32; let pipes_cursor_inv_vp: i32; let pipes_cursor_mouse: i32; @@ -52,11 +52,11 @@ let pipes_cursor_gbufferd: i32; let pipes_offset: i32; -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(); +function _pipes_make_merge(red: bool, green: bool, blue: bool, alpha: bool): gpu_pipeline_t { + let pipe: gpu_pipeline_t = gpu_create_pipeline(); pipe.vertex_shader = sys_get_shader("layer_merge.vert"); pipe.fragment_shader = sys_get_shader("layer_merge.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: 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; @@ -87,7 +87,7 @@ function pipes_init() { pipes_copy = gpu_create_pipeline(); pipes_copy.vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_copy.input_layout = vs; gpu_compile_pipeline(pipes_copy); @@ -97,7 +97,7 @@ function pipes_init() { pipes_copy_bgra = gpu_create_pipeline(); pipes_copy_bgra.vertex_shader = sys_get_shader("layer_copy_bgra.vert"); pipes_copy_bgra.fragment_shader = sys_get_shader("layer_copy_bgra.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_copy_bgra.input_layout = vs; gpu_compile_pipeline(pipes_copy_bgra); @@ -107,7 +107,7 @@ function pipes_init() { pipes_copy8 = gpu_create_pipeline(); pipes_copy8.vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy8.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_copy8.input_layout = vs; pipes_copy8.color_attachment_count = 1; @@ -119,7 +119,7 @@ function pipes_init() { pipes_copy128 = gpu_create_pipeline(); pipes_copy128.vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy128.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_copy128.input_layout = vs; pipes_copy128.color_attachment_count = 1; @@ -132,7 +132,7 @@ function pipes_init() { pipes_invert8 = gpu_create_pipeline(); pipes_invert8.vertex_shader = sys_get_shader("layer_invert.vert"); pipes_invert8.fragment_shader = sys_get_shader("layer_invert.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_invert8.input_layout = vs; pipes_invert8.color_attachment_count = 1; @@ -144,7 +144,7 @@ function pipes_init() { pipes_apply_mask = gpu_create_pipeline(); pipes_apply_mask.vertex_shader = sys_get_shader("mask_apply.vert"); pipes_apply_mask.fragment_shader = sys_get_shader("mask_apply.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: 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; gpu_compile_pipeline(pipes_apply_mask); @@ -156,7 +156,7 @@ function pipes_init() { pipes_merge_mask = gpu_create_pipeline(); pipes_merge_mask.vertex_shader = sys_get_shader("mask_merge.vert"); pipes_merge_mask.fragment_shader = sys_get_shader("mask_merge.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: 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; gpu_compile_pipeline(pipes_merge_mask); @@ -171,7 +171,7 @@ function pipes_init() { pipes_colorid_to_mask = gpu_create_pipeline(); pipes_colorid_to_mask.vertex_shader = sys_get_shader("mask_colorid.vert"); pipes_colorid_to_mask.fragment_shader = sys_get_shader("mask_colorid.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: 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; gpu_compile_pipeline(pipes_colorid_to_mask); @@ -185,7 +185,7 @@ function pipes_init() { pipes_copy_r = gpu_create_pipeline(); pipes_copy_r.vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy_r.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_copy_r.input_layout = vs; ARRAY_ACCESS(pipes_copy_r.color_write_mask_green, 0) = false; @@ -198,7 +198,7 @@ function pipes_init() { pipes_copy_g = gpu_create_pipeline(); pipes_copy_g.vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy_g.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_copy_g.input_layout = vs; ARRAY_ACCESS(pipes_copy_g.color_write_mask_red, 0) = false; @@ -211,7 +211,7 @@ function pipes_init() { pipes_inpaint_preview = gpu_create_pipeline(); pipes_inpaint_preview.vertex_shader = sys_get_shader("inpaint_preview.vert"); pipes_inpaint_preview.fragment_shader = sys_get_shader("inpaint_preview.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: 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; gpu_compile_pipeline(pipes_inpaint_preview); @@ -223,7 +223,7 @@ function pipes_init() { pipes_copy_a = gpu_create_pipeline(); pipes_copy_a.vertex_shader = sys_get_shader("layer_copy_rrrr.vert"); pipes_copy_a.fragment_shader = sys_get_shader("layer_copy_rrrr.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: 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; @@ -238,7 +238,7 @@ function pipes_init() { pipes_copy_rgb = gpu_create_pipeline(); pipes_copy_rgb.vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy_rgb.fragment_shader = sys_get_shader("layer_copy.frag"); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipes_copy_rgb.input_layout = vs; ARRAY_ACCESS(pipes_copy_rgb.color_write_mask_alpha, 0) = false; @@ -249,7 +249,7 @@ function pipes_init() { 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_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); 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); diff --git a/base/sources/ts/project.ts b/base/sources/ts/project.ts index 4ecccdb4..9e1bc7a3 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_gpu_texture_t | font_t +let project_asset_map: map_t = map_create(); // 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_gpu_texture_t = _draw_current; + let current: 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_gpu_texture_t = _draw_current; + let current: 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_gpu_texture_t { +function project_get_image(asset: asset_t): gpu_texture_t { return asset != null ? map_get(project_asset_map, asset.id) : null; } diff --git a/base/sources/ts/render_path_raytrace.ts b/base/sources/ts/render_path_raytrace.ts index b65aa110..46779d51 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_gpu_buffer_t; -let render_path_raytrace_ib: iron_gpu_buffer_t; +let render_path_raytrace_vb: gpu_buffer_t; +let render_path_raytrace_ib: gpu_buffer_t; -let render_path_raytrace_last_envmap: iron_gpu_texture_t = null; +let render_path_raytrace_last_envmap: 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_gpu_texture_t = null; +let render_path_raytrace_last_texpaint: 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_gpu_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; + let saved_envmap: 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_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 bnoise_sobol: gpu_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: gpu_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: 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_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 bnoise_sobol: gpu_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: gpu_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: 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_gpu_buffer_t = context_raw.merged_object.data._.vertex_buffer; - let ib_full: iron_gpu_buffer_t = context_raw.merged_object.data._.index_buffers[0]; + let vb_full: gpu_buffer_t = context_raw.merged_object.data._.vertex_buffer; + let ib_full: gpu_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 2c0da60f..ecf0206f 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_gpu_texture_t = null; +let render_path_raytrace_bake_last_layer: 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_gpu_texture_t = context_raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : context_raw.saved_envmap; + let saved_envmap: 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_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 bnoise_sobol: gpu_texture_t = map_get(scene_embedded, "bnoise_sobol.k"); + let bnoise_scramble: gpu_texture_t = map_get(scene_embedded, "bnoise_scramble.k"); + let bnoise_rank: 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 e7fc98c3..79c8cf70 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_gpu_texture_t = data_get_image(s); + let image: gpu_texture_t = data_get_image(s); map_set(resource_bundled, s, image); } } -function resource_get(name: string): iron_gpu_texture_t { +function resource_get(name: string): gpu_texture_t { return map_get(resource_bundled, name); } -function resource_tile50(img: iron_gpu_texture_t, x: i32, y: i32): rect_t { +function resource_tile50(img: 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_gpu_texture_t, x: i32, y: i32): rect_t { +function resource_tile25(img: 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_gpu_texture_t, x: i32, y: i32): rect_t { +function resource_tile18(img: 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 55d06254..c3669fee 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_gpu_texture_t; // 200px - image_icon?: iron_gpu_texture_t; // 50px + image?: gpu_texture_t; // 200px + image_icon?: 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 a16eb672..c90e8eb2 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_gpu_texture_t; // 200px + image?: 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 9b0d8561..ff5f9ac6 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_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 + texpaint?: gpu_texture_t; // Base or mask + texpaint_nor?: gpu_texture_t; + texpaint_pack?: gpu_texture_t; + texpaint_preview?: gpu_texture_t; // Layer preview mask_opacity?: f32; // Opacity mask fill_layer?: slot_material_t; show_panel?: bool; @@ -179,22 +179,22 @@ function slot_layer_unload(raw: slot_layer_t) { return; } - 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; + let _texpaint: gpu_texture_t = raw.texpaint; + let _texpaint_nor: gpu_texture_t = raw.texpaint_nor; + let _texpaint_pack: gpu_texture_t = raw.texpaint_pack; + let _texpaint_preview: gpu_texture_t = raw.texpaint_preview; - sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint: gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - sys_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_nor: gpu_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - sys_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_pack: 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_gpu_texture_t = raw.texpaint; + let _texpaint: gpu_texture_t = raw.texpaint; raw.texpaint = other.texpaint; other.texpaint = _texpaint; - let _texpaint_preview: iron_gpu_texture_t = raw.texpaint_preview; + let _texpaint_preview: 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_gpu_texture_t = raw.texpaint_nor; - let _texpaint_pack: iron_gpu_texture_t = raw.texpaint_pack; + let _texpaint_nor: gpu_texture_t = raw.texpaint_nor; + let _texpaint_pack: 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_gpu_texture_t = null, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0) { +function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_image: gpu_texture_t = null, occlusion: f32 = 1.0, roughness: f32 = layers_default_rough, metallic: f32 = 0.0) { // Base _gpu_begin(raw.texpaint, null, clear_flag_t.COLOR, base_color); - iron_gpu_end(); + gpu_end(); if (base_image != null) { draw_begin(raw.texpaint); draw_scaled_image(base_image, 0, 0, raw.texpaint.width, raw.texpaint.height); @@ -256,10 +256,10 @@ function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_ if (slot_layer_is_layer(raw)) { // Nor _gpu_begin(raw.texpaint_nor, null, clear_flag_t.COLOR, color_from_floats(0.5, 0.5, 1.0, 0.0)); - iron_gpu_end(); + gpu_end(); // Occ, rough, met _gpu_begin(raw.texpaint_pack, null, clear_flag_t.COLOR, color_from_floats(occlusion, roughness, metallic, 0.0)); - iron_gpu_end(); + 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_gpu_texture_t = gpu_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32); + let inverted: 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_gpu_texture_t = raw.texpaint; - sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + let _texpaint: gpu_texture_t = raw.texpaint; + sys_notify_on_next_frame(function (_texpaint: gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); let rt: render_target_t = map_get(render_path_render_targets, "texpaint" + raw.id); @@ -382,7 +382,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { format = tex_format_t.RGBA128; ///end - let _texpaint: iron_gpu_texture_t = raw.texpaint; + let _texpaint: 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); @@ -390,7 +390,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_set_pipeline(null); draw_end(); - let _texpaint_nor: iron_gpu_texture_t = raw.texpaint_nor; + let _texpaint_nor: gpu_texture_t = raw.texpaint_nor; if (raw.texpaint_nor != null) { raw.texpaint_nor = gpu_create_render_target(res_x, res_y, format); @@ -401,7 +401,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_end(); } - let _texpaint_pack: iron_gpu_texture_t = raw.texpaint_pack; + let _texpaint_pack: gpu_texture_t = raw.texpaint_pack; if (raw.texpaint_pack != null) { raw.texpaint_pack = gpu_create_render_target(res_x, res_y, format); @@ -412,18 +412,18 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_end(); } - sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint: gpu_texture_t) { iron_unload_image(_texpaint); }, _texpaint); if (_texpaint_nor != null) { - sys_notify_on_next_frame(function (_texpaint_nor: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_nor: gpu_texture_t) { iron_unload_image(_texpaint_nor); }, _texpaint_nor); } if (_texpaint_pack != null) { - sys_notify_on_next_frame(function (_texpaint_pack: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint_pack: gpu_texture_t) { iron_unload_image(_texpaint_pack); }, _texpaint_pack); } @@ -442,7 +442,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { } } else if (slot_layer_is_mask(raw)) { - let _texpaint: iron_gpu_texture_t = raw.texpaint; + let _texpaint: gpu_texture_t = raw.texpaint; raw.texpaint = gpu_create_render_target(res_x, res_y, tex_format_t.RGBA32); draw_begin(raw.texpaint); @@ -451,7 +451,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) { draw_set_pipeline(null); draw_end(); - sys_notify_on_next_frame(function (_texpaint: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (_texpaint: 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 4481df19..24d17e69 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_gpu_texture_t; - image_icon?: iron_gpu_texture_t; + image?: gpu_texture_t; + image_icon?: gpu_texture_t; preview_ready?: bool; data?: material_data_t; id?: i32; diff --git a/base/sources/ts/tab_brushes.ts b/base/sources/ts/tab_brushes.ts index 0c68229b..30e18d89 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_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; + let img: gpu_texture_t = ui_SCALE(ui) > 1 ? project_brushes[i].image : project_brushes[i].image_icon; + let img_full: 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 f1c64566..71ed10e5 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_gpu_texture_t = project_fonts[i].image; + let img: 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 diff --git a/base/sources/ts/tab_layers.ts b/base/sources/ts/tab_layers.ts index af64670e..0060bb29 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_gpu_texture_t = resource_get("icons.k"); + let icons: 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_gpu_texture_t = l.texpaint_preview; + let texpaint_preview: 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_gpu_texture_t = resource_get("icons.k"); + let icons: 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_gpu_texture_t = l.texpaint_preview; + let texpaint_preview: gpu_texture_t = l.texpaint_preview; - let icon: iron_gpu_texture_t = l.fill_layer == null ? texpaint_preview : l.fill_layer.image_icon; + let icon: 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); diff --git a/base/sources/ts/tab_materials.ts b/base/sources/ts/tab_materials.ts index 0360ce2d..d3e3ac4a 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_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; + let img: gpu_texture_t = ui_SCALE(ui) > 1 ? project_materials[i].image : project_materials[i].image_icon; + let img_full: 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 b669741a..6a60cc97 100644 --- a/base/sources/ts/tab_swatches.ts +++ b/base/sources/ts/tab_swatches.ts @@ -1,13 +1,13 @@ -let _tab_swatches_empty: iron_gpu_texture_t; +let _tab_swatches_empty: gpu_texture_t; let tab_swatches_drag_pos: i32 = -1; let _tab_swatches_draw_i: i32; -function tab_swatches_empty_set(image: iron_gpu_texture_t) { +function tab_swatches_empty_set(image: gpu_texture_t) { _tab_swatches_empty = image; } -function tab_swatches_empty_get(): iron_gpu_texture_t { +function tab_swatches_empty_get(): gpu_texture_t { if (_tab_swatches_empty == null) { let b: u8_array_t = u8_array_create(4); b[0] = 255; diff --git a/base/sources/ts/tab_textures.ts b/base/sources/ts/tab_textures.ts index 4dbd3d56..3134a01a 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_gpu_texture_t; +let _tab_textures_draw_img: 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_gpu_texture_t = project_get_image(asset); + let img: 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; sys_notify_on_next_frame(function () { - 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)); + let img: gpu_texture_t = _tab_textures_draw_img; + let target: 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(); - sys_notify_on_next_frame(function (target: iron_gpu_texture_t) { + sys_notify_on_next_frame(function (target: gpu_texture_t) { let path: string = _tab_textures_draw_path; let f: string = ui_files_filename; if (f == "") { @@ -220,7 +220,7 @@ function tab_textures_draw(htab: ui_handle_t) { } } else { - let img: iron_gpu_texture_t = resource_get("icons.k"); + let img: 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 80cfdbef..cc9cc541 100644 --- a/base/sources/ts/ui_base.ts +++ b/base/sources/ts/ui_base.ts @@ -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_gpu_raytrace_supported()) { + if (gpu_raytrace_supported()) { array_push(modes, tr("Path Traced")); array_push(shortcuts, "p"); } @@ -1082,12 +1082,12 @@ function ui_base_update_ui() { continue; } - let target: iron_gpu_texture_t = l.texpaint_preview; + let target: gpu_texture_t = l.texpaint_preview; if (target == null) { continue; } - let source: iron_gpu_texture_t = l.texpaint; + let source: gpu_texture_t = l.texpaint; draw_begin(target, true, 0x00000000); // draw_set_pipeline(l.is_mask() ? pipes_copy8 : pipes_copy); draw_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now @@ -1103,10 +1103,10 @@ function ui_base_update_ui() { // Update layer preview let l: slot_layer_t = context_raw.layer; - let target: iron_gpu_texture_t = l.texpaint_preview; + let target: gpu_texture_t = l.texpaint_preview; if (target != null) { - let source: iron_gpu_texture_t = l.texpaint; + let source: gpu_texture_t = l.texpaint; draw_begin(target, true, 0x00000000); // draw_set_pipeline(raw.layer.is_mask() ? pipes_copy8 : pipes_copy); draw_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now @@ -1336,16 +1336,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_gpu_texture_t = context_raw.material.image_icon; + let img: 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_gpu_texture_t = resource_get("icons.k"); + let img: 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_gpu_texture_t = resource_get("cursor.k"); + let cursor_img: 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 diff --git a/base/sources/ts/ui_box.ts b/base/sources/ts/ui_box.ts index e7fad076..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_gpu_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 9c3a3bda..ea24310f 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_gpu_texture_t; + image: 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_gpu_texture_t): draw_cloud_icon_data_t { +function make_draw_cloud_icon_data(f: string, image: 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_gpu_texture_t = resource_get("icons.k"); + let icons: 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_gpu_texture_t = null; + let icon: 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_gpu_texture_t = rt._image; + let empty: 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_gpu_texture_t = data_get_image(abs); + let image: 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); sys_notify_on_init(function (data: draw_cloud_icon_data_t) { - let icon: iron_gpu_texture_t = gpu_create_render_target(data.image.width, data.image.height); + let icon: 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); @@ -311,9 +311,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_gpu_texture_t = rt._image; + let empty: gpu_texture_t = rt._image; map_set(ui_files_icon_map, shandle, empty); - let image: iron_gpu_texture_t = data_get_image(shandle); + let image: gpu_texture_t = data_get_image(shandle); let args: ui_files_make_icon_t = { image: image, @@ -427,10 +427,10 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = function ui_files_make_icon (args: ui_files_make_icon_t) { let w: i32 = args.w; - let image: iron_gpu_texture_t = args.image; + let image: 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_gpu_texture_t = gpu_create_render_target(sw, sh); + let icon: gpu_texture_t = gpu_create_render_target(sw, sh); draw_begin(icon, true, 0xffffffff); draw_set_pipeline(pipes_copy_rgb); draw_scaled_image(image, 0, 0, sw, sh); @@ -450,7 +450,7 @@ function ui_files_go_up(handle: ui_handle_t) { } type ui_files_make_icon_t = { - image: iron_gpu_texture_t; + image: gpu_texture_t; shandle: string; w: i32; }; diff --git a/base/sources/ts/ui_menu.ts b/base/sources/ts/ui_menu.ts index c7f09fd1..4698e545 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_gpu_texture_t = _draw_current; + let current: 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_gpu_raytrace_supported()) { + if (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_gpu_texture_t = data_get_image("badge.k"); + let img: 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 fdabe093..0a887d0c 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_gpu_texture_t = resource_get("icons.k"); + let img: 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 514ed184..eb65b219 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_gpu_texture_t = null; +let ui_nodes_grid: 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; @@ -719,7 +719,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_gpu_texture_t { +function ui_nodes_draw_grid(zoom: f32): gpu_texture_t { let ww: i32 = config_raw.layout[layout_size_t.NODES_W]; ///if (is_paint || is_sculpt) @@ -740,7 +740,7 @@ function ui_nodes_draw_grid(zoom: f32): iron_gpu_texture_t { h = 1; } - let grid: iron_gpu_texture_t = gpu_create_render_target(w, h); + let grid: gpu_texture_t = gpu_create_render_target(w, h); draw_begin(grid, true, ui_nodes_ui.ops.theme.SEPARATOR_COL); let sep_col: i32 = ui_nodes_ui.ops.theme.SEPARATOR_COL; @@ -1059,7 +1059,7 @@ function ui_nodes_render() { // Node previews if (config_raw.node_preview && nodes.nodes_selected_id.length > 0) { - let img: iron_gpu_texture_t = null; + let img: gpu_texture_t = null; let sel: ui_node_t = ui_get_node(c.nodes, nodes.nodes_selected_id[0]); ///if (is_paint || is_sculpt) diff --git a/base/sources/ts/ui_toolbar.ts b/base/sources/ts/ui_toolbar.ts index 16acd1cc..208a525c 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_gpu_texture_t, icon_accent: i32, keys: string[]) { +function ui_toolbar_draw_tool(i: i32, ui: ui_t, img: 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_gpu_texture_t = resource_get("icons.k"); + let img: 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 07821f37..2e14af8b 100644 --- a/base/sources/ts/ui_view2d.ts +++ b/base/sources/ts/ui_view2d.ts @@ -1,5 +1,5 @@ -let ui_view2d_pipe: iron_gpu_pipeline_t; +let ui_view2d_pipe: gpu_pipeline_t; let ui_view2d_channel_loc: i32; let ui_view2d_text_input_hover: bool = false; let ui_view2d_uvmap_show: bool = false; @@ -22,12 +22,12 @@ let ui_view2d_pan_y: f32 = 0.0; let ui_view2d_pan_scale: f32 = 1.0; let ui_view2d_tiled_show: bool = false; let ui_view2d_controls_down: bool = false; -let _ui_view2d_render_tex: iron_gpu_texture_t; +let _ui_view2d_render_tex: 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_gpu_texture_t = null; +let ui_view2d_grid: gpu_texture_t = null; let ui_view2d_grid_redraw: bool = true; function ui_view2d_init() { @@ -35,7 +35,7 @@ function ui_view2d_init() { 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_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); ui_view2d_pipe.input_layout = vs; ui_view2d_pipe.blend_source = blend_factor_t.BLEND_ONE; @@ -142,7 +142,7 @@ function ui_view2d_render() { draw_image(ui_view2d_grid, x, y); // Texture - let tex: iron_gpu_texture_t = null; + let tex: gpu_texture_t = null; let l: slot_layer_t = context_raw.layer; let channel: i32 = 0; @@ -180,14 +180,14 @@ function ui_view2d_render() { } if (ui_view2d_layer_mode == view_2d_layer_mode_t.VISIBLE) { - let current: iron_gpu_texture_t = _draw_current; + let current: 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_gpu_texture_t = _draw_current; + let current: 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)); @@ -261,7 +261,7 @@ function ui_view2d_render() { sys_notify_on_next_frame(function () { let rt: render_target_t = map_get(render_path_render_targets, "texpaint_picker"); - let texpaint_picker: iron_gpu_texture_t = rt._image; + let texpaint_picker: 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(); @@ -413,7 +413,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_gpu_texture_t = resource_get("cursor.k"); + let cursor_img: 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 5336ce81..ec38daf6 100644 --- a/base/sources/ts/uniforms_ext.ts +++ b/base/sources/ts/uniforms_ext.ts @@ -312,7 +312,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_gpu_texture_t { +function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: string): 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 ec1b861d..b38a7831 100644 --- a/base/sources/ts/util_mesh.ts +++ b/base/sources/ts/util_mesh.ts @@ -159,7 +159,7 @@ function util_mesh_swap_axis(a: i32, b: i32) { } let g: mesh_data_t = o.data; - let l: i32 = iron_gpu_vertex_struct_size(g._.structure) / 2; + let l: i32 = 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 ]); @@ -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_gpu_vertex_buffer_unlock(g._.vertex_buffer); + gpu_vertex_buffer_unlock(g._.vertex_buffer); } util_mesh_remove_merged(); @@ -184,7 +184,7 @@ 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_gpu_vertex_struct_size(g._.structure) / 2; + let l: i32 = 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]; @@ -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_gpu_vertex_buffer_unlock(g._.vertex_buffer); + gpu_vertex_buffer_unlock(g._.vertex_buffer); } render_path_raytrace_ready = false; @@ -210,7 +210,7 @@ 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_gpu_vertex_struct_size(g._.structure) / 2; + let l: i32 = gpu_vertex_struct_size(g._.structure) / 2; let inda: u32_array_t = g._.indices[0]; let vertices: buffer_t = gpu_lock_vertex_buffer(g._.vertex_buffer); // posnortex for (let i: i32 = 0; i < math_floor(inda.length / 3); ++i) { @@ -286,7 +286,7 @@ function util_mesh_calc_normals(smooth: bool = false) { } } } - iron_gpu_vertex_buffer_unlock(g._.vertex_buffer); + gpu_vertex_buffer_unlock(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,25 +370,25 @@ function util_mesh_to_origin() { va[i * 4 + 2] = math_floor((va[i * 4 + 2] * sc - dz) / max_scale * 32767); } - let l: i32 = iron_gpu_vertex_struct_size(g._.structure) / 2; + let l: i32 = 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_gpu_vertex_buffer_unlock(g._.vertex_buffer); + gpu_vertex_buffer_unlock(g._.vertex_buffer); } util_mesh_merge(); } -function util_mesh_apply_displacement(texpaint_pack: iron_gpu_texture_t, strength: f32 = 0.1, uv_scale: f32 = 1.0) { +function util_mesh_apply_displacement(texpaint_pack: 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_gpu_vertex_struct_size(g._.structure) / 2; + let l: i32 = 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); @@ -402,7 +402,7 @@ function util_mesh_apply_displacement(texpaint_pack: iron_gpu_texture_t, strengt 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_gpu_vertex_buffer_unlock(g._.vertex_buffer); + gpu_vertex_buffer_unlock(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 9096b520..2d08ed20 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_gpu_buffer_t = null; -let util_render_screen_aligned_full_ib: iron_gpu_buffer_t = null; +let util_render_screen_aligned_full_vb: gpu_buffer_t = null; +let util_render_screen_aligned_full_ib: gpu_buffer_t = null; function util_render_make_material_preview() { context_raw.material_preview = true; @@ -79,7 +79,7 @@ function util_render_make_material_preview() { } function util_render_make_decal_preview() { - let current: iron_gpu_texture_t = _draw_current; + let current: gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -143,7 +143,7 @@ function util_render_make_decal_preview() { } function util_render_make_text_preview() { - let current: iron_gpu_texture_t = _draw_current; + let current: gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -177,7 +177,7 @@ function util_render_make_text_preview() { } function util_render_make_font_preview() { - let current: iron_gpu_texture_t = _draw_current; + let current: gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -205,7 +205,7 @@ function util_render_make_brush_preview() { return; } - let current: iron_gpu_texture_t = _draw_current; + let current: gpu_texture_t = _draw_current; let g2_in_use: bool = _draw_in_use; if (g2_in_use) draw_end(); @@ -363,7 +363,7 @@ function util_render_make_brush_preview() { // Scale layer down to to image preview l = render_path_paint_live_layer; - let target: iron_gpu_texture_t = context_raw.brush.image; + let target: gpu_texture_t = context_raw.brush.image; draw_begin(target, true, 0x00000000); draw_set_pipeline(pipes_copy); draw_scaled_image(l.texpaint, 0, 0, target.width, target.height); @@ -385,7 +385,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_gpu_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: 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; @@ -400,15 +400,15 @@ function util_render_make_node_preview(canvas: ui_node_canvas_t, node: ui_node_t transform_build_matrix(context_raw.paint_object.base.transform); _gpu_begin(image); - iron_gpu_set_pipeline(res.scon._.pipe_state); + 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_gpu_set_vertex_buffer(util_render_screen_aligned_full_vb); - iron_gpu_set_index_buffer(util_render_screen_aligned_full_ib); + gpu_set_vertex_buffer(util_render_screen_aligned_full_vb); + gpu_set_index_buffer(util_render_screen_aligned_full_ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); context_raw.paint_object.base.transform.scale_world = _scale_world; transform_build_matrix(context_raw.paint_object.base.transform); @@ -455,22 +455,22 @@ function util_render_create_screen_aligned_full_data() { let indices: u32[] = [0, 1, 2]; // Mandatory vertex data names and sizes - let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let structure: 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); + util_render_screen_aligned_full_vb = gpu_create_vertex_buffer(math_floor(data.length / math_floor(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_gpu_vertex_buffer_unlock(util_render_screen_aligned_full_vb); + gpu_vertex_buffer_unlock(util_render_screen_aligned_full_vb); 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_gpu_index_buffer_unlock(util_render_screen_aligned_full_ib); + gpu_index_buffer_unlock(util_render_screen_aligned_full_ib); } diff --git a/base/sources/ts/util_uv.ts b/base/sources/ts/util_uv.ts index 02a6be59..81e8cd2b 100644 --- a/base/sources/ts/util_uv.ts +++ b/base/sources/ts/util_uv.ts @@ -1,14 +1,14 @@ -let util_uv_uvmap: iron_gpu_texture_t = null; +let util_uv_uvmap: gpu_texture_t = null; let util_uv_uvmap_cached: bool = false; -let util_uv_trianglemap: iron_gpu_texture_t = null; +let util_uv_trianglemap: gpu_texture_t = null; let util_uv_trianglemap_cached: bool = false; -let util_uv_dilatemap: iron_gpu_texture_t = null; +let util_uv_dilatemap: gpu_texture_t = null; let util_uv_dilatemap_cached: bool = false; -let util_uv_uvislandmap: iron_gpu_texture_t = null; +let util_uv_uvislandmap: 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_gpu_pipeline_t = null; +let util_uv_pipe_dilate: gpu_pipeline_t = null; function util_uv_cache_uv_map() { if (util_uv_uvmap != null && (util_uv_uvmap.width != config_get_texture_res_x() || util_uv_uvmap.height != config_get_texture_res_y())) { @@ -107,7 +107,7 @@ function util_uv_cache_dilate_map() { 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_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); 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); @@ -125,11 +125,11 @@ function util_uv_cache_dilate_map() { } let geom: mesh_data_t = mask == 0 && context_raw.merged_object != null ? context_raw.merged_object.data : context_raw.paint_object.data; _gpu_begin(util_uv_dilatemap, null, clear_flag_t.COLOR, 0x00000000); - iron_gpu_set_pipeline(util_uv_pipe_dilate); - iron_gpu_set_vertex_buffer(geom._.vertex_buffer); - iron_gpu_set_index_buffer(geom._.index_buffers[0]); + gpu_set_pipeline(util_uv_pipe_dilate); + gpu_set_vertex_buffer(geom._.vertex_buffer); + gpu_set_index_buffer(geom._.index_buffers[0]); gpu_draw(); - iron_gpu_end(); + gpu_end(); util_uv_dilatemap_cached = true; util_uv_dilate_bytes = null; } diff --git a/base/tests/triangle/main.ts b/base/tests/triangle/main.ts index 830897ca..cdd10b78 100644 --- a/base/tests/triangle/main.ts +++ b/base/tests/triangle/main.ts @@ -2,17 +2,17 @@ // Red triangle test // ../../make --run -let pipeline: iron_gpu_pipeline_t; +let pipeline: gpu_pipeline_t; let vb: any; let ib: any; function render() { _gpu_begin(null, null, clear_flag_t.COLOR | clear_flag_t.DEPTH, 0xff000000, 1.0); - iron_gpu_set_pipeline(pipeline); - iron_gpu_set_vertex_buffer(vb); - iron_gpu_set_index_buffer(ib); + gpu_set_pipeline(pipeline); + gpu_set_vertex_buffer(vb); + gpu_set_index_buffer(ib); gpu_draw(); - iron_gpu_end(); + gpu_end(); } function main() { @@ -31,7 +31,7 @@ function main() { _iron_init(ops); pipeline = gpu_create_pipeline(); - let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create(); + let vs: gpu_vertex_structure_t = gpu_vertex_struct_create(); gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); let vs_buffer: buffer_t = iron_load_blob("./data/test.vert" + sys_shader_ext()); let fs_buffer: buffer_t = iron_load_blob("./data/test.frag" + sys_shader_ext()); @@ -54,14 +54,14 @@ function main() { for (let i: i32 = 0; i < vertices.length; i++) { buffer_set_f32(vb_data, i * 4, vertices[i]); } - iron_gpu_vertex_buffer_unlock(vb); + gpu_vertex_buffer_unlock(vb); 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_gpu_index_buffer_unlock(ib); + gpu_index_buffer_unlock(ib); _iron_set_update_callback(render); } diff --git a/base/tools/amake/aimage.c b/base/tools/amake/aimage.c index 51d22362..1cdfbaa0 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_gpu_texture_t; +} 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_gpu_texture_t read_png_jpg(const char *filename) { +static gpu_texture_t read_png_jpg(const char *filename) { int width, height, n; char *data = stbi_load(filename, &width, &height, &n, 4); - iron_gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = false }; + gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = false }; return img; } -static iron_gpu_texture_t read_hdr(const char *filename) { +static gpu_texture_t read_hdr(const char *filename) { int width, height, n; float *data = stbi_loadf(filename, &width, &height, &n, 4); - iron_gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = true }; + gpu_texture_t img = { .data = data, .width = width, .height = height, .is_hdr = true }; return img; } -static void *scale_image(iron_gpu_texture_t img, int width, int height) { +static void *scale_image(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_gpu_texture_t img = read_png_jpg(from); + gpu_texture_t img = read_png_jpg(from); FILE *file = fopen(to, "wb"); unsigned char *data256 = scale_image(img, 256, 256); @@ -126,7 +126,7 @@ void export_ico(const char *from, const char *to) { } void export_png(const char *from, const char *to, int width, int height) { - iron_gpu_texture_t img = read_png_jpg(from); + gpu_texture_t img = read_png_jpg(from); if (width > 0 && height > 0) { unsigned char *scaled = scale_image(img, width, height); @@ -162,7 +162,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_gpu_texture_t img; + 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 a0a51e1d..6286b774 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_gpu_texture_t = null; +let minimap: gpu_texture_t = null; let window_header_h: i32 = 0; function drop_files(path: string) {