From 5cffa1a2e4d2bae244a1f8c29d3d6bcd61b1456e Mon Sep 17 00:00:00 2001 From: Larpon Date: Fri, 7 Jan 2022 18:52:44 +0100 Subject: [PATCH] sokol: use V type for SG_SHADERSTAGE_[VS|FS] (#13086) --- examples/sokol/02_cubes_glsl/cube_glsl.v | 4 ++-- examples/sokol/03_march_tracing_glsl/rt_glsl.v | 4 ++-- examples/sokol/04_multi_shader_glsl/rt_glsl.v | 8 ++++---- examples/sokol/05_instancing_glsl/rt_glsl.v | 4 ++-- examples/sokol/06_obj_viewer/modules/obj/rend.v | 4 ++-- vlib/sokol/gfx/gfx.c.v | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/sokol/02_cubes_glsl/cube_glsl.v b/examples/sokol/02_cubes_glsl/cube_glsl.v index e7c518c2c5..666353f11e 100644 --- a/examples/sokol/02_cubes_glsl/cube_glsl.v +++ b/examples/sokol/02_cubes_glsl/cube_glsl.v @@ -370,7 +370,7 @@ fn draw_cube_glsl(app App) { ptr: &tr_matrix size: usize(4 * 16) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_VS, C.SLOT_vs_params, &vs_uniforms_range) + gfx.apply_uniforms(.vs, C.SLOT_vs_params, &vs_uniforms_range) // fs uniforms time_ticks := f32(time.ticks() - app.ticks) / 1000 @@ -384,7 +384,7 @@ fn draw_cube_glsl(app App) { ptr: unsafe { &text_res } size: usize(4 * 4) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_FS, C.SLOT_fs_params, &fs_uniforms_range) + gfx.apply_uniforms(.fs, C.SLOT_fs_params, &fs_uniforms_range) gfx.draw(0, (3 * 2) * 6, 1) gfx.end_pass() diff --git a/examples/sokol/03_march_tracing_glsl/rt_glsl.v b/examples/sokol/03_march_tracing_glsl/rt_glsl.v index 955b3b33d8..c1c7ce4458 100644 --- a/examples/sokol/03_march_tracing_glsl/rt_glsl.v +++ b/examples/sokol/03_march_tracing_glsl/rt_glsl.v @@ -268,7 +268,7 @@ fn draw_cube_glsl(app App) { ptr: &tr_matrix size: usize(4 * 16) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_VS, C.SLOT_vs_params, &vs_uniforms_range) + gfx.apply_uniforms(.vs, C.SLOT_vs_params, &vs_uniforms_range) // *** fragment shader uniforms *** time_ticks := f32(time.ticks() - app.ticks) / 1000 @@ -286,7 +286,7 @@ fn draw_cube_glsl(app App) { ptr: unsafe { &tmp_fs_params } size: usize(sizeof(tmp_fs_params)) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_FS, C.SLOT_fs_params, &fs_uniforms_range) + gfx.apply_uniforms(.fs, C.SLOT_fs_params, &fs_uniforms_range) // 3 vertices for triangle * 2 triangles per face * 6 faces = 36 vertices to draw gfx.draw(0, (3 * 2) * 6, 1) diff --git a/examples/sokol/04_multi_shader_glsl/rt_glsl.v b/examples/sokol/04_multi_shader_glsl/rt_glsl.v index b4742cabe9..94902c8d38 100644 --- a/examples/sokol/04_multi_shader_glsl/rt_glsl.v +++ b/examples/sokol/04_multi_shader_glsl/rt_glsl.v @@ -377,7 +377,7 @@ fn draw_cube_glsl_m(app App) { ptr: &tr_matrix size: usize(4 * 16) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_VS, C.SLOT_vs_params_m, &vs_uniforms_range) + gfx.apply_uniforms(.vs, C.SLOT_vs_params_m, &vs_uniforms_range) // *** fragment shader uniforms *** time_ticks := f32(time.ticks() - app.ticks) / 1000 @@ -397,7 +397,7 @@ fn draw_cube_glsl_m(app App) { ptr: unsafe { &tmp_fs_params } size: usize(sizeof(tmp_fs_params)) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_FS, C.SLOT_fs_params_p, &fs_uniforms_range) + gfx.apply_uniforms(.fs, C.SLOT_fs_params_p, &fs_uniforms_range) // 3 vertices for triangle * 2 triangles per face * 6 faces = 36 vertices to draw gfx.draw(0, (3 * 2) * 3, 1) @@ -429,7 +429,7 @@ fn draw_cube_glsl_p(app App) { ptr: &tr_matrix size: usize(4 * 16) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_VS, C.SLOT_vs_params_p, &vs_uniforms_range) + gfx.apply_uniforms(.vs, C.SLOT_vs_params_p, &vs_uniforms_range) // *** fragment shader uniforms *** time_ticks := f32(time.ticks() - app.ticks) / 1000 @@ -449,7 +449,7 @@ fn draw_cube_glsl_p(app App) { ptr: unsafe { &tmp_fs_params } size: usize(sizeof(tmp_fs_params)) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_FS, C.SLOT_fs_params_p, &fs_uniforms_range) + gfx.apply_uniforms(.fs, C.SLOT_fs_params_p, &fs_uniforms_range) // 3 vertices for triangle * 2 triangles per face * 6 faces = 36 vertices to draw gfx.draw(0, (3 * 2) * 3, 1) diff --git a/examples/sokol/05_instancing_glsl/rt_glsl.v b/examples/sokol/05_instancing_glsl/rt_glsl.v index 5e67e3df8c..0584dd2124 100644 --- a/examples/sokol/05_instancing_glsl/rt_glsl.v +++ b/examples/sokol/05_instancing_glsl/rt_glsl.v @@ -324,7 +324,7 @@ fn draw_cube_glsl_i(mut app App){ ptr: unsafe { &tr_matrix } size: usize(4 * 16) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_VS, C.SLOT_vs_params_i, &vs_uniforms_range) + gfx.apply_uniforms(.vs, C.SLOT_vs_params_i, &vs_uniforms_range) /* // *** fragment shader uniforms *** @@ -342,7 +342,7 @@ fn draw_cube_glsl_i(mut app App){ ptr: unsafe { &tmp_fs_params } size: usize(sizeof(tmp_fs_params)) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_FS, C.SLOT_fs_params, &fs_uniforms_range) + gfx.apply_uniforms(.fs, C.SLOT_fs_params, &fs_uniforms_range) */ // 3 vertices for triangle * 2 triangles per face * 6 faces = 36 vertices to draw for num_inst times gfx.draw(0, (3 * 2) * 6, num_inst) diff --git a/examples/sokol/06_obj_viewer/modules/obj/rend.v b/examples/sokol/06_obj_viewer/modules/obj/rend.v index 41d929a5ce..8a9f480f0b 100644 --- a/examples/sokol/06_obj_viewer/modules/obj/rend.v +++ b/examples/sokol/06_obj_viewer/modules/obj/rend.v @@ -243,8 +243,8 @@ pub fn (obj_part ObjPart) bind_and_draw(rend_data_index int, in_data Shader_data size: usize(in_data.fs_len) } - gfx.apply_uniforms(C.SG_SHADERSTAGE_VS, C.SLOT_vs_params, &vs_uniforms_range) - gfx.apply_uniforms(C.SG_SHADERSTAGE_FS, C.SLOT_fs_params, &fs_uniforms_range) + gfx.apply_uniforms(.vs, C.SLOT_vs_params, &vs_uniforms_range) + gfx.apply_uniforms(.fs, C.SLOT_fs_params, &fs_uniforms_range) gfx.draw(0, int(part_render_data.n_vert), 1) return part_render_data.n_vert } diff --git a/vlib/sokol/gfx/gfx.c.v b/vlib/sokol/gfx/gfx.c.v index 7c07eb045f..993bf3f968 100644 --- a/vlib/sokol/gfx/gfx.c.v +++ b/vlib/sokol/gfx/gfx.c.v @@ -131,8 +131,8 @@ pub fn apply_bindings(bindings &Bindings) { } [inline] -pub fn apply_uniforms(stage int, ub_index int, data &Range) { - C.sg_apply_uniforms(stage, ub_index, data) +pub fn apply_uniforms(stage ShaderStage, ub_index int, data &Range) { + C.sg_apply_uniforms(int(stage), ub_index, data) } [inline]