Make metal work

This commit is contained in:
luboslenco
2025-04-24 22:19:44 +02:00
parent fff6ced18f
commit bf2dda291d
85 changed files with 1292 additions and 1794 deletions
+3 -3
View File
@@ -1,13 +1,13 @@
#[set(everything)]
const sampler_linear: sampler;
#[set(everything)]
const tex0: tex2d;
#[set(everything)]
const texa: tex2d;
#[set(everything)]
const sampler_linear: sampler;
struct vert_in {
pos: float2;
}
+3 -3
View File
@@ -1,10 +1,10 @@
#[set(everything)]
const tex: tex2d;
#[set(everything)]
const sampler_linear: sampler;
#[set(everything)]
const tex: tex2d;
struct vert_in {
pos: float2;
}
+1 -1
View File
@@ -193,7 +193,7 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
node_shader_write_frag(kong, "n /= (abs(n.x) + abs(n.y) + abs(n.z));");
// node_shader_write_frag(kong, "n.xy = n.z >= 0.0 ? n.xy : octahedron_wrap(n.xy);");
node_shader_write_frag(kong, "if (n.z < 0.0) { n.xy = octahedron_wrap(n.xy); }");
node_shader_write_frag(kong, "output[0] = float4(n.xy, roughness, pack_f32_i16(metallic, uint(int(matid * 255.0) % 3)));");
node_shader_write_frag(kong, "output[0] = float4(n.xy, roughness, pack_f32_i16(metallic, uint(int(matid * 255.0) % float(3))));");
node_shader_write_frag(kong, "output[2] = float4(0.0, 0.0, input.tex_coord.xy);");
parser_material_finalize(con_mesh);
+3 -4
View File
@@ -33,8 +33,7 @@ function inpaint_node_init() {
if (inpaint_node_mask == null) {
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);
iron_gpu_clear(color_from_floats(1.0, 1.0, 1.0, 1.0));
_gpu_begin(inpaint_node_mask, null, clear_flag_t.COLOR, color_from_floats(1.0, 1.0, 1.0, 1.0));
_gpu_end();
});
}
@@ -88,12 +87,12 @@ function inpaint_node_get_cached_image(self: inpaint_node_t): iron_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]);
_gpu_begin(inpaint_node_image);
iron_gpu_set_pipeline(pipes_inpaint_preview);
gpu_set_pipeline(pipes_inpaint_preview);
gpu_set_texture(pipes_tex0_inpaint_preview, source);
gpu_set_texture(pipes_texa_inpaint_preview, inpaint_node_mask);
gpu_set_vertex_buffer(const_data_screen_aligned_vb);
gpu_set_index_buffer(const_data_screen_aligned_ib);
gpu_draw_indexed_vertices();
gpu_draw();
_gpu_end();
}, self);
return inpaint_node_image;
+5 -30
View File
@@ -63,20 +63,8 @@ function render_path_paint_commands_paint(dilation: bool = true) {
if (context_raw.pdirty > 0) {
if (context_raw.tool == workspace_tool_t.PICKER) {
let additional: string[] = ["texpaint_nor_picker", "texpaint_pack_picker", "texpaint_uv_picker"];
///if arm_metal
// render_path_set_target("texpaint_picker");
// render_path_clear_target(0xff000000);
// render_path_set_target("texpaint_nor_picker");
// render_path_clear_target(0xff000000);
// render_path_set_target("texpaint_pack_picker");
// render_path_clear_target(0xff000000);
render_path_set_target("texpaint_picker", additional);
///else
render_path_set_target("texpaint_picker", additional);
// render_path_clear_target(0xff000000);
///end
render_path_bind_target("gbuffer2", "gbuffer2");
// tid = context_raw.layer.id;
render_path_bind_target("texpaint" + tid, "texpaint");
@@ -188,7 +176,7 @@ 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");
gpu_set_texture_depth(pipes_cursor_gbufferd, gbuffer0._image);
gpu_set_float2(pipes_cursor_mouse, mx, my);
@@ -200,19 +188,9 @@ 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);
////if (arm_metal || arm_vulkan)
// let vs: vertex_element_t[] = [
// {
// name: "tex",
// data: "short2norm"
// }
// ];
// gpu_set_vertex_buffer(mesh_data_get(geom, vs));
////else
gpu_set_vertex_buffer(geom._.vertex_buffer);
////end
gpu_set_index_buffer(geom._.index_buffers[0]);
gpu_draw_indexed_vertices();
gpu_draw();
gpu_disable_scissor();
render_path_end();
@@ -249,14 +227,11 @@ function render_path_paint_draw() {
if (context_raw.brush_blend_dirty) {
context_raw.brush_blend_dirty = false;
///if arm_metal
render_path_set_target("texpaint_blend0");
render_path_clear_target(0x00000000);
render_path_set_target("texpaint_blend1");
render_path_clear_target(0x00000000);
render_path_set_target("texpaint_blend0", null, clear_flag_t.COLOR, 0x00000000);
render_path_set_target("texpaint_blend1", null, clear_flag_t.COLOR, 0x00000000);
///else
let additional: string[] = ["texpaint_blend1"];
render_path_set_target("texpaint_blend0", additional);
render_path_clear_target(0x00000000);
render_path_set_target("texpaint_blend0", additional, clear_flag_t.COLOR, 0x00000000);
///end
}
}
+3 -3
View File
@@ -79,11 +79,11 @@ function ui_nodes_ext_run() {
if (texheight != null) {
_gpu_begin(texpaint_pack._image);
iron_gpu_set_pipeline(pipes_copy_a);
gpu_set_pipeline(pipes_copy_a);
gpu_set_texture(pipes_copy_a_tex, texheight);
gpu_set_vertex_buffer(const_data_screen_aligned_vb);
gpu_set_index_buffer(const_data_screen_aligned_ib);
gpu_draw_indexed_vertices();
gpu_draw();
_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_all(g._.vertex_buffer);
iron_gpu_vertex_buffer_unlock(g._.vertex_buffer);
// Apply displacement
if (config_raw.displace_strength > 0) {