From e7d392dac8549cac026a2e8fd209631ee2dc32dd Mon Sep 17 00:00:00 2001 From: Valerio Santinelli Date: Fri, 11 Oct 2024 17:07:00 +0200 Subject: [PATCH 1/6] Changes to improve the flat pipeline --- src/binocle/core/binocle_app_wrap.c | 34 +++++++- src/binocle/core/binocle_gd.c | 125 +++++----------------------- src/binocle/core/binocle_gd.h | 4 +- src/binocle/core/binocle_gd_wrap.c | 7 +- 4 files changed, 58 insertions(+), 112 deletions(-) diff --git a/src/binocle/core/binocle_app_wrap.c b/src/binocle/core/binocle_app_wrap.c index 4a89b7ff..e7457023 100644 --- a/src/binocle/core/binocle_app_wrap.c +++ b/src/binocle/core/binocle_app_wrap.c @@ -12,10 +12,36 @@ int l_binocle_app_assets_dir(lua_State *L) { } int l_binocle_app_shader_prefix(lua_State *L) { -#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) - char *s = "gles"; +#if defined(BINOCLE_MACOS) && defined(BINOCLE_METAL) + char *s = "dst/metal-macos"; +#elif defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) + char *s = "dst/gles"; #else - char *s = "gl33"; + char *s = "dst/gl33"; +#endif + lua_pushstring(L, s); + return 1; +} + +int l_binocle_app_shader_vs_suffix(lua_State *L) { +#if defined(BINOCLE_MACOS) && defined(BINOCLE_METAL) + char *s = "_metal_macos_vs.metal"; +#elif defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) + char *s = "_glsl300es_vs.glsl"; +#else + char *s = "_glsl410_vs.glsl"; +#endif + lua_pushstring(L, s); + return 1; +} + +int l_binocle_app_shader_fs_suffix(lua_State *L) { +#if defined(BINOCLE_MACOS) && defined(BINOCLE_METAL) + char *s = "_metal_macos_fs.metal"; +#elif defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) + char *s = "_glsl300es_fs.glsl"; +#else + char *s = "_glsl410_fs.glsl"; #endif lua_pushstring(L, s); return 1; @@ -24,6 +50,8 @@ int l_binocle_app_shader_prefix(lua_State *L) { static const struct luaL_Reg app [] = { {"assets_dir", l_binocle_app_assets_dir}, {"shader_prefix", l_binocle_app_shader_prefix}, + {"shader_vs_suffix", l_binocle_app_shader_vs_suffix}, + {"shader_fs_suffix", l_binocle_app_shader_fs_suffix}, {NULL, NULL} }; diff --git a/src/binocle/core/binocle_gd.c b/src/binocle/core/binocle_gd.c index 8d4a4db6..8938e635 100644 --- a/src/binocle/core/binocle_gd.c +++ b/src/binocle/core/binocle_gd.c @@ -27,67 +27,6 @@ typedef struct binocle_gd_flat_shader_fs_params_t { float color[4]; } binocle_gd_flat_shader_fs_params_t; -const char *binocle_shader_flat_vertex_src_gles = -"#version 300 es\n" -"precision mediump float;\n" -"precision mediump int;\n" -"in vec3 vertexPosition;\n" -"in vec4 vertexColor;\n" -"in vec2 vertexTexture;\n" -"\n" -"uniform mat4 projectionMatrix;\n" -"uniform mat4 viewMatrix;\n" -"uniform mat4 modelMatrix;\n" -"\n" -"out vec4 color;\n" -"\n" -"void main(void) {\n" -" gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(vertexPosition, 1.0);\n" -" gl_PointSize = 1.0;\n" -" color = vertexColor;\n" -"}\n"; - -const char *binocle_shader_flat_frag_src_gles = -"#version 300 es\n" -"precision mediump float;\n" -"precision mediump int;\n" -"in vec4 color;\n" -"out vec4 fragColor;\n" -"void main(void)\n" -"{\n" -" fragColor = color;\n" -" //gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n" -"}\n"; - -const char *binocle_shader_flat_vertex_src_gl33 = -"#version 330\n" -"in vec3 vertexPosition;\n" -"in vec4 vertexColor;\n" -"in vec2 vertexTexture;\n" -"\n" -"uniform mat4 projectionMatrix;\n" -"uniform mat4 viewMatrix;\n" -"uniform mat4 modelMatrix;\n" -"\n" -"out vec4 color;" -"\n" -"void main(void) {\n" -" gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(vertexPosition, 1.0);\n" -" //gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n" -" gl_PointSize = 1.0;\n" -" color = vertexColor;\n" -"}\n"; - -const char *binocle_shader_flat_src_gl33 = -"#version 330\n" -"in vec4 color;\n" -"out vec4 fragColor;\n" -"void main(void)\n" -"{\n" -" fragColor = color;\n" -" //fragColor = vec4(1.0, 1.0, 1.0, 1.0);\n" -"}\n"; - binocle_gd binocle_gd_new() { binocle_gd res = {0}; res.vertices = malloc(sizeof(binocle_vpct) * BINOCLE_GD_MAX_VERTICES); @@ -491,17 +430,11 @@ void binocle_gd_render(binocle_gd *gd, struct binocle_window *window, float desi binocle_gd_render_screen(gd, window, design_width, design_height, viewport, matrix, scale); } -void binocle_gd_setup_flat_pipeline(binocle_gd *gd) { -#if defined(BINOCLE_MACOS) && defined(BINOCLE_METAL) -#include "../../assets/metal/default-metal-macosx.h" -#include "../../assets/metal/screen-metal-macosx.h" -#endif +void binocle_gd_setup_flat_pipeline(binocle_gd *gd, const char *vs_src, const char *fs_src) { sg_shader_desc screen_shader_desc = { -#ifdef BINOCLE_GL -#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) - .vs.source = binocle_shader_flat_vertex_src_gles, -#else - .vs.source = binocle_shader_flat_vertex_src_gl33, + .vs.source = vs_src, +#if defined(BINOCLE_METAL) + .vs.entry = "main0", #endif .vs.uniform_blocks[0] = { .size = sizeof(struct binocle_gd_flat_shader_vs_params_t), @@ -511,24 +444,14 @@ void binocle_gd_setup_flat_pipeline(binocle_gd *gd) { [2] = { .name = "modelMatrix", .type = SG_UNIFORMTYPE_MAT4 }, }, }, -#else - .vs.bytecode.ptr = screen_vs_bytecode, - .vs.bytecode.size = sizeof(screen_vs_bytecode), -#endif .attrs = { [0].name = "vertexPosition", [1].name = "vertexColor", [2].name = "vertexTexture", }, -#ifdef BINOCLE_GL -#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) - .fs.source = binocle_shader_flat_frag_src_gles, -#else - .fs.source = binocle_shader_flat_src_gl33, -#endif -#else - .fs.bytecode.ptr = screen_fs_bytecode, - .fs.bytecode.size = sizeof(screen_fs_bytecode), + .fs.source = fs_src, +#if defined(BINOCLE_METAL) + .fs.entry = "main0", #endif // .fs.uniform_blocks[0] = { // .size = sizeof(struct binocle_gd_flat_shader_fs_params_t), @@ -577,7 +500,7 @@ void binocle_gd_setup_flat_pipeline(binocle_gd *gd) { #ifdef BINOCLE_GL .pixel_format = SG_PIXELFORMAT_RGBA8, #else - .pixel_format = SG_PIXELFORMAT_BGRA8, + .pixel_format = SG_PIXELFORMAT_RGBA8, #endif .blend = { .enabled = true, @@ -1240,14 +1163,12 @@ void binocle_gd_draw_test_cube(struct sg_shader *shader) { // glCheck(glDeleteBuffers(1, &quad_indexbuffer)); } -sg_shader_desc binocle_gd_create_offscreen_shader_desc(const char *shader_vs_src, const char *shader_fs_src) { +sg_shader_desc binocle_gd_create_offscreen_shader_desc(const char *name, const char *shader_vs_src, const char *shader_fs_src) { sg_shader_desc shader_desc = { -#ifdef BINOCLE_GL - .vs.source = shader_vs_src, -#else + .label = name, .vs.source = shader_vs_src, - // .vs.byte_code = default_vs_bytecode, - // .vs.byte_code_size = sizeof(default_vs_bytecode), +#if defined(BINOCLE_METAL) + .vs.entry = "main0", #endif .attrs = { [0].name = "vertexPosition", @@ -1256,23 +1177,19 @@ sg_shader_desc binocle_gd_create_offscreen_shader_desc(const char *shader_vs_src }, .vs.uniform_blocks[0] = { .size = sizeof(float) * 16 * 3, + .layout = SG_UNIFORMLAYOUT_STD140, .uniforms = { - [0] = { .name = "projectionMatrix", .type = SG_UNIFORMTYPE_MAT4}, - [1] = { .name = "viewMatrix", .type = SG_UNIFORMTYPE_MAT4}, - [2] = { .name = "modelMatrix", .type = SG_UNIFORMTYPE_MAT4}, + [0] = { .name = "vs_params", .type = SG_UNIFORMTYPE_FLOAT4, .array_count = 12}, } }, -#ifdef BINOCLE_GL - .fs.source = shader_fs_src, -#else .fs.source = shader_fs_src, - // .fs.byte_code = default_fs_bytecode, - // .fs.byte_code_size = sizeof(default_fs_bytecode), +#if defined(BINOCLE_METAL) + .fs.entry = "main0", #endif - .fs.images[0] = {.used = true, .image_type = SG_IMAGETYPE_2D}, + .fs.images[0] = {.used = true, .image_type = SG_IMAGETYPE_2D, .sample_type = SG_IMAGESAMPLETYPE_FLOAT,}, .fs.samplers[0] = {.used = true, .sampler_type = SG_SAMPLERTYPE_FILTERING}, .fs.image_sampler_pairs[0] = {.used = true, - .glsl_name = "tex0", + .glsl_name = "tex0_smp", .image_slot = 0, .sampler_slot = 0}, }; @@ -1324,16 +1241,16 @@ void binocle_gd_add_uniform_to_shader_desc(sg_shader_desc *shader_desc, sg_shade case SG_SHADERSTAGE_VS: shader_desc->vs.uniform_blocks[0].uniforms[idx].name = SDL_strdup(uniform_name);; shader_desc->vs.uniform_blocks[0].uniforms[idx].type = uniform_type; + shader_desc->vs.uniform_blocks[0].size = binocle_gd_compute_uniform_block_size(shader_desc->vs.uniform_blocks[0]); break; case SG_SHADERSTAGE_FS: shader_desc->fs.uniform_blocks[0].uniforms[idx].name = SDL_strdup(uniform_name);; shader_desc->fs.uniform_blocks[0].uniforms[idx].type = uniform_type; + shader_desc->fs.uniform_blocks[0].size = binocle_gd_compute_uniform_block_size(shader_desc->fs.uniform_blocks[0]); break; default: break; } - shader_desc->vs.uniform_blocks[0].size = binocle_gd_compute_uniform_block_size(shader_desc->vs.uniform_blocks[0]); - shader_desc->fs.uniform_blocks[0].size = binocle_gd_compute_uniform_block_size(shader_desc->fs.uniform_blocks[0]); } sg_shader binocle_gd_create_shader(sg_shader_desc desc) { @@ -1365,7 +1282,7 @@ sg_pipeline binocle_gd_create_offscreen_pipeline(sg_shader shader) { #ifdef BINOCLE_GL .pixel_format = SG_PIXELFORMAT_RGBA8, #else - .pixel_format = SG_PIXELFORMAT_BGRA8, + .pixel_format = SG_PIXELFORMAT_RGBA8, #endif .blend = { .enabled = true, diff --git a/src/binocle/core/binocle_gd.h b/src/binocle/core/binocle_gd.h index 9ac1ab94..66cb381e 100644 --- a/src/binocle/core/binocle_gd.h +++ b/src/binocle/core/binocle_gd.h @@ -332,10 +332,10 @@ void binocle_gd_draw_with_state(binocle_gd *gd, const struct binocle_vpct *verti void binocle_gd_draw_mesh(binocle_gd *gd, const struct binocle_mesh *mesh, kmAABB2 viewport, struct binocle_camera_3d *camera); void binocle_gd_draw_test_triangle(struct sg_shader *shader); void binocle_gd_draw_test_cube(struct sg_shader *shader); -void binocle_gd_setup_flat_pipeline(binocle_gd *gd); +void binocle_gd_setup_flat_pipeline(binocle_gd *gd, const char *vs_src, const char *fs_src); void binocle_gd_render_flat(binocle_gd *gd); -sg_shader_desc binocle_gd_create_offscreen_shader_desc(const char *shader_vs_src, const char *shader_fs_src); +sg_shader_desc binocle_gd_create_offscreen_shader_desc(const char *name, const char *shader_vs_src, const char *shader_fs_src); size_t binocle_gd_compute_uniform_block_size(sg_shader_uniform_block_desc desc); void binocle_gd_add_uniform_to_shader_desc(sg_shader_desc *shader_desc, sg_shader_stage stage, size_t idx, const char *uniform_name, sg_uniform_type uniform_type); sg_shader binocle_gd_create_shader(sg_shader_desc desc); diff --git a/src/binocle/core/binocle_gd_wrap.c b/src/binocle/core/binocle_gd_wrap.c index 61ed9223..384e56e1 100644 --- a/src/binocle/core/binocle_gd_wrap.c +++ b/src/binocle/core/binocle_gd_wrap.c @@ -160,9 +160,10 @@ int l_binocle_gd_render_screen(lua_State *L) { } int l_create_offscreen_shader_desc(lua_State *L) { - const char *vs = luaL_checkstring(L, 1); - const char *fs = luaL_checkstring(L, 2); - sg_shader_desc desc = binocle_gd_create_offscreen_shader_desc(vs, fs); + const char *name = luaL_checkstring(L, 1); + const char *vs = luaL_checkstring(L, 2); + const char *fs = luaL_checkstring(L, 3); + sg_shader_desc desc = binocle_gd_create_offscreen_shader_desc(name, vs, fs); l_binocle_shader_t *shader = lua_newuserdata(L, sizeof(l_binocle_shader_t)); lua_getfield(L, LUA_REGISTRYINDEX, "binocle_shader"); lua_setmetatable(L, -2); From 9cef91fccb0f90260547972fdc22591f07735515 Mon Sep 17 00:00:00 2001 From: Valerio Santinelli Date: Fri, 11 Oct 2024 17:08:46 +0200 Subject: [PATCH 2/6] Added the flat shader generation --- assets/shaders/src/flat.glsl | 36 ++++++++++++++++++++++++++++++++++++ example/main.c | 6 ++++++ 2 files changed, 42 insertions(+) create mode 100644 assets/shaders/src/flat.glsl diff --git a/assets/shaders/src/flat.glsl b/assets/shaders/src/flat.glsl new file mode 100644 index 00000000..e3ce8fed --- /dev/null +++ b/assets/shaders/src/flat.glsl @@ -0,0 +1,36 @@ +#pragma sokol @vs vs + +in vec3 vertexPosition; +in vec4 vertexColor; +in vec2 vertexTexture; + +uniform vs_params { + mat4 projectionMatrix; + mat4 viewMatrix; + mat4 modelMatrix; +}; + +out vec4 color; + +void main(void) { + gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(vertexPosition, 1.0); + //gl_Position = vec4(0.0, 0.0, 0.0, 1.0); + gl_PointSize = 1.0; + color = vertexColor; +} + +#pragma sokol @end + +#pragma sokol @fs fs + +in vec4 color; +out vec4 fragColor; +void main(void) +{ + fragColor = color; + //fragColor = vec4(1.0, 1.0, 1.0, 1.0); +} + +#pragma sokol @end + +#pragma sokol @program flat vs fs \ No newline at end of file diff --git a/example/main.c b/example/main.c index 86644a03..e562037f 100644 --- a/example/main.c +++ b/example/main.c @@ -43,18 +43,24 @@ #define DEFAULT_FS_FILENAME "default.glsl_default_metal_macos_fs.metal" #define SCREEN_VS_FILENAME "screen.glsl_default_metal_macos_vs.metal" #define SCREEN_FS_FILENAME "screen.glsl_default_metal_macos_fs.metal" +#define FLAT_VS_FILENAME "flat_flat_metal_macos_vs.metal" +#define FLAT_FS_FILENAME "flat_flat_metal_macos_fs.metal" #elif defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) #define SHADER_PATH "dst/gles" #define DEFAULT_VS_FILENAME "default.glsl_default_glsl300es_vs.glsl" #define DEFAULT_FS_FILENAME "default.glsl_default_glsl300es_fs.glsl" #define SCREEN_VS_FILENAME "screen.glsl_default_glsl300es_vs.glsl" #define SCREEN_FS_FILENAME "screen.glsl_default_glsl300es_fs.glsl" +#define FLAT_VS_FILENAME "flat_flat_glsl300es_vs.glsl" +#define FLAT_FS_FILENAME "flat_flat_glsl300es_fs.glsl" #else #define SHADER_PATH "dst/gl33" #define DEFAULT_VS_FILENAME "default.glsl_default_glsl410_vs.glsl" #define DEFAULT_FS_FILENAME "default.glsl_default_glsl410_fs.glsl" #define SCREEN_VS_FILENAME "screen.glsl_default_glsl410_vs.glsl" #define SCREEN_FS_FILENAME "screen.glsl_default_glsl410_fs.glsl" +#define FLAT_VS_FILENAME "flat_flat_glsl410_vs.glsl" +#define FLAT_FS_FILENAME "flat_flat_glsl410_fs.glsl" #endif typedef struct default_shader_params_t { From 831ad722a9fd5397dcc1e8b99e1073d090ec8086 Mon Sep 17 00:00:00 2001 From: Valerio Santinelli Date: Wed, 16 Oct 2024 14:18:08 +0200 Subject: [PATCH 3/6] Fixed the flat pipeline and split out being and end pass from the rendering function --- src/binocle/core/binocle_gd.c | 53 ++++++++++++++++++++---------- src/binocle/core/binocle_gd.h | 17 ++++++++++ src/binocle/core/binocle_gd_wrap.c | 21 ++++++++++++ 3 files changed, 74 insertions(+), 17 deletions(-) diff --git a/src/binocle/core/binocle_gd.c b/src/binocle/core/binocle_gd.c index 8938e635..d2920d35 100644 --- a/src/binocle/core/binocle_gd.c +++ b/src/binocle/core/binocle_gd.c @@ -410,17 +410,32 @@ void binocle_gd_render_screen(binocle_gd *gd, struct binocle_window *window, flo gd->display.bind.fs.images[0] = gd->offscreen.render_target; - sg_begin_pass(&(sg_pass){ - .action = gd->display.action, - .swapchain = binocle_window_get_swapchain(window), - }); + // sg_begin_pass(&(sg_pass){ + // .action = gd->display.action, + // .swapchain = binocle_window_get_swapchain(window), + // }); sg_apply_pipeline(gd->display.pip); sg_apply_bindings(&gd->display.bind); sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(screen_vs_params)); sg_apply_uniforms(SG_SHADERSTAGE_FS, 0, &SG_RANGE(screen_fs_params)); sg_draw(0, 6, 1); + // sg_end_pass(); + + // sg_commit(); +} + +void binocle_gd_begin_screen_pass(binocle_gd *gd, binocle_window *window) { + sg_begin_pass(&(sg_pass){ + .action = gd->display.action, + .swapchain = binocle_window_get_swapchain(window), +}); +} + +void binocle_gd_end_screen_pass() { sg_end_pass(); +} +void binocle_gd_commit() { sg_commit(); } @@ -438,10 +453,9 @@ void binocle_gd_setup_flat_pipeline(binocle_gd *gd, const char *vs_src, const ch #endif .vs.uniform_blocks[0] = { .size = sizeof(struct binocle_gd_flat_shader_vs_params_t), + .layout = SG_UNIFORMLAYOUT_STD140, .uniforms = { - [0] = { .name = "projectionMatrix", .type = SG_UNIFORMTYPE_MAT4 }, - [1] = { .name = "viewMatrix", .type = SG_UNIFORMTYPE_MAT4 }, - [2] = { .name = "modelMatrix", .type = SG_UNIFORMTYPE_MAT4 }, + [0] = { .name = "vs_params", .type = SG_UNIFORMTYPE_FLOAT4, .array_count = 12 }, }, }, .attrs = { @@ -466,8 +480,9 @@ void binocle_gd_setup_flat_pipeline(binocle_gd *gd, const char *vs_src, const ch sg_pass_action action = { .colors[0] = { - .load_action = SG_LOADACTION_DONTCARE, + .load_action = SG_LOADACTION_LOAD, .clear_value = {0.0f, 1.0f, 0.0f, 1.0f}, + .store_action = SG_STOREACTION_STORE, } }; gd->flat.action = action; @@ -486,15 +501,15 @@ void binocle_gd_setup_flat_pipeline(binocle_gd *gd, const char *vs_src, const ch }, }, .shader = shader, - .index_type = SG_INDEXTYPE_NONE, - .depth = { - .pixel_format = SG_PIXELFORMAT_NONE, - .compare = SG_COMPAREFUNC_NEVER, - .write_enabled = false, - }, - .stencil = { - .enabled = false, - }, + // .index_type = SG_INDEXTYPE_NONE, + // .depth = { + // .pixel_format = SG_PIXELFORMAT_NONE, + // .compare = SG_COMPAREFUNC_NEVER, + // .write_enabled = false, + // }, + // .stencil = { + // .enabled = false, + // }, .colors = { [0] = { #ifdef BINOCLE_GL @@ -506,6 +521,10 @@ void binocle_gd_setup_flat_pipeline(binocle_gd *gd, const char *vs_src, const ch .enabled = true, .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA, .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, + .op_rgb = SG_BLENDOP_ADD, + .src_factor_alpha = SG_BLENDFACTOR_SRC_ALPHA, + .dst_factor_alpha = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, + .op_alpha = SG_BLENDOP_ADD, } } } diff --git a/src/binocle/core/binocle_gd.h b/src/binocle/core/binocle_gd.h index 66cb381e..0a5c7d9b 100644 --- a/src/binocle/core/binocle_gd.h +++ b/src/binocle/core/binocle_gd.h @@ -329,6 +329,23 @@ void binocle_gd_draw_circle(binocle_gd *gd, kmVec2 center, float radius, struct void binocle_gd_draw_with_state(binocle_gd *gd, const struct binocle_vpct *vertices, size_t vertex_count, struct binocle_render_state *render_state, float depth); +/** + * /brief Begins the screen pass. Multiple pipelines can be applied during this pass. + * @param gd the graphics device instance + * @param window the window instance + */ +void binocle_gd_begin_screen_pass(binocle_gd *gd, struct binocle_window *window); + +/** + * /brief Ends the screen pass. + */ +void binocle_gd_end_screen_pass(); + +/** + * /brief Commits all the buffers after the screen pass is done + */ +void binocle_gd_commit(); + void binocle_gd_draw_mesh(binocle_gd *gd, const struct binocle_mesh *mesh, kmAABB2 viewport, struct binocle_camera_3d *camera); void binocle_gd_draw_test_triangle(struct sg_shader *shader); void binocle_gd_draw_test_cube(struct sg_shader *shader); diff --git a/src/binocle/core/binocle_gd_wrap.c b/src/binocle/core/binocle_gd_wrap.c index 384e56e1..5f37d9a9 100644 --- a/src/binocle/core/binocle_gd_wrap.c +++ b/src/binocle/core/binocle_gd_wrap.c @@ -236,6 +236,24 @@ int l_binocle_gd_create_offscreen_pipeline(lua_State *L) { return 0; } +int l_binocle_gd_begin_screen_pass(lua_State *L) { + l_binocle_gd_t *gd = luaL_checkudata(L, 1, "binocle_gd"); + l_binocle_window_t *window = luaL_checkudata(L, 2, "binocle_window"); + binocle_gd_begin_screen_pass(gd->gd, window->window); + + return 0; +} + +int l_binocle_gd_end_screen_pass(lua_State *L) { + binocle_gd_end_screen_pass(); + return 0; +} + +int l_binocle_gd_commit(lua_State *L) { + binocle_gd_commit(); + return 0; +} + static const struct luaL_Reg gd [] = { {"new", l_binocle_gd_new}, {"init", l_binocle_gd_init}, @@ -254,6 +272,9 @@ static const struct luaL_Reg gd [] = { {"add_uniform_to_shader_desc", l_binocle_gd_add_uniform_to_shader_desc}, {"create_shader", l_binocle_gd_create_shader}, {"create_pipeline", l_binocle_gd_create_offscreen_pipeline}, + {"begin_screen_pass", l_binocle_gd_begin_screen_pass}, + {"end_screen_pass", l_binocle_gd_end_screen_pass}, + {"commit", l_binocle_gd_commit}, {NULL, NULL} }; From 85cfec5cca45c1d927b9202a2e627d82689879a6 Mon Sep 17 00:00:00 2001 From: Valerio Santinelli Date: Wed, 16 Oct 2024 14:21:31 +0200 Subject: [PATCH 4/6] Fixed the default renderer to call into begin/end pass and commit --- .idea/misc.xml | 3 +-- src/binocle/core/binocle_gd.c | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 16b6f421..d02f648e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,8 +4,7 @@