vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: f7448063875eb0c1cbbaa86e7c02b4754f59128c
Parent: 21b785b9f39cd95de0783feb0a955257c47b16cb
Author: Randy Palamar
Date:   Sun,  8 Dec 2024 20:55:24 -0700

push reload all shaders into the work queue

Diffstat:
Mutil.c | 11+++++++++++
Mutil.h | 5++---
Mvtgl.c | 21+++++++++------------
3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/util.c b/util.c @@ -141,6 +141,17 @@ work_queue_empty(u32 *q, u32 capacity) } static void +work_queue_insert(Term *t, u32 type, void *ctx) +{ + i32 index = work_queue_push(&t->work_queue, t->work_queue_capacity); + /* NOTE(rnp): if we ever fill this up we need to resize the queue */ + ASSERT(index != -1); + work_queue_push_commit(&t->work_queue); + t->work_queue_items[index].type = type; + t->work_queue_items[index].ctx = ctx; +} + +static void mem_copy(void *src, void *dest, size len) { ASSERT(len >= 0); diff --git a/util.h b/util.h @@ -426,9 +426,8 @@ typedef struct RenderCtx { } RenderCtx; enum work_queue_entry_type { - WQ_FILL_RENDERBUFFER, - WQ_SHADER_RELOAD, - WQ_WINDOW_RESIZE, + WQ_RELOAD_SHADER, + WQ_RELOAD_ALL_SHADERS, }; typedef struct { diff --git a/vtgl.c b/vtgl.c @@ -170,14 +170,8 @@ reload_all_shaders(GLCtx *gl, PlatformAPI *platform, Arena a) static PLATFORM_FILE_WATCH_CALLBACK_FN(queue_shader_reload) { queue_shader_reload_ctx *ctx = user_ctx; - i32 index = work_queue_push(&ctx->t->work_queue, ctx->t->work_queue_capacity); - /* NOTE(rnp): if we ever fill this up we need to resize the queue */ - ASSERT(index != -1); - work_queue_push_commit(&ctx->t->work_queue); - ctx->path = path; - ctx->t->work_queue_items[index].type = WQ_SHADER_RELOAD; - ctx->t->work_queue_items[index].ctx = ctx; + work_queue_insert(ctx->t, WQ_RELOAD_SHADER, ctx); } static v4 @@ -1237,19 +1231,18 @@ DEBUG_EXPORT VTGL_RENDER_FRAME_FN(vtgl_render_frame) work_queue_pop_commit(&t->work_queue); work_queue_entry *entry = t->work_queue_items + queue_item; switch (entry->type) { - case WQ_SHADER_RELOAD: { + case WQ_RELOAD_SHADER: { queue_shader_reload_ctx *ctx = entry->ctx; reload_shader(&t->gl, &memory->platform_api, ctx->path, ctx->stage, ctx->info, arena); } break; + case WQ_RELOAD_ALL_SHADERS: { + reload_all_shaders(&t->gl, &memory->platform_api, arena); + } break; default: INVALID_CODE_PATH; } } - if (input->executable_reloaded) { - reload_all_shaders(&t->gl, &memory->platform_api, arena); - } - /* NOTE: default state which can be overwritten later in the frame */ /* TODO: if (!t->ui_active) */ { @@ -1349,6 +1342,10 @@ DEBUG_EXPORT VTGL_FRAME_STEP_FN(vtgl_frame_step) } } + if (input->executable_reloaded) { + work_queue_insert(t, WQ_RELOAD_ALL_SHADERS, 0); + } + BEGIN_NAMED_BLOCK(mouse_and_keyboard_input); if (input->character_input.len) { if (t->scroll_offset) {