From e3b02f8832530931bd480cb7168daebd7e2c6233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Sat, 31 Aug 2024 09:02:19 +0200 Subject: [PATCH] changes --- bind/v4k.lua | 1 + engine/joint/v4k.h | 33 +++++++++++++++++++++++++++------ engine/split/v4k_editor.c | 16 ++++++++++------ engine/split/v4k_render.c | 16 ++++++++++++++++ engine/split/v4k_render.h | 1 + engine/v4k.c | 32 ++++++++++++++++++++++++++------ engine/v4k.h | 1 + 7 files changed, 82 insertions(+), 18 deletions(-) diff --git a/bind/v4k.lua b/bind/v4k.lua index ae62763..b242eba 100644 --- a/bind/v4k.lua +++ b/bind/v4k.lua @@ -1217,6 +1217,7 @@ typedef struct shadowmap_t { bool shadowmap_step(shadowmap_t *s); void shadowmap_light(shadowmap_t *s, light_t *l, mat44 cam_proj, mat44 cam_view); void shadowmap_end(shadowmap_t *s); + void ui_shadowmap(shadowmap_t *s); unsigned shader(const char *vs, const char *fs, const char *attribs, const char *fragcolor, const char *defines); unsigned shader_geom(const char *gs, const char *vs, const char *fs, const char *attribs, const char *fragcolor, const char *defines); unsigned shader_bind(unsigned program); diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index b7d7469..82a322e 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -17359,6 +17359,7 @@ API void shadowmap_begin(shadowmap_t *s); API bool shadowmap_step(shadowmap_t *s); //< roll over to the next light if it returns false API void shadowmap_light(shadowmap_t *s, light_t *l, mat44 cam_proj, mat44 cam_view); //< must be called at most once per shadowmap_step API void shadowmap_end(shadowmap_t *s); +API void ui_shadowmap(shadowmap_t *s); // ----------------------------------------------------------------------------- // shaders @@ -383959,6 +383960,22 @@ void shadowmap_end(shadowmap_t *s) { } } +void ui_shadowmap(shadowmap_t *s) { + if (!s) return; + + int vsm_width = s->vsm_texture_width; + int csm_width = s->csm_texture_width; + ui_int("Texture Width (VSM)", &vsm_width); + ui_int("Texture Width (CSM)", &csm_width); + + if (ui_collapse("VRAM Usage", "vram_usage")) { + ui_label2("Total VRAM", va("%lld KB", s->vram_usage_total / 1024)); + ui_label2("VSM VRAM", va("%lld KB", s->vram_usage_vsm / 1024)); + ui_label2("CSM VRAM", va("%lld KB", s->vram_usage_csm / 1024)); + ui_collapse_end(); + } +} + // ----------------------------------------------------------------------------- // Occlusion queries @@ -396640,7 +396657,7 @@ struct editor_t { } editor = { .active = 1, .gamepad = 1, - .hz_high = 60, .hz_medium = 18, .hz_low = 5, + .hz_high = 60, .hz_medium = 40, .hz_low = 30, }; int editor_begin(const char *title, int mode) { @@ -396948,10 +396965,14 @@ const char* editor_recv(int jobid, double timeout_ss) { } // plain and ctrl keys -EDITOR_BIND(play, "down(F5)", { window_pause(0); /* if(!editor.slomo) editor.active = 0; */ editor.slomo = 1; } ); -EDITOR_BIND(stop, "down(ESC)", { if(editor.t > 0) { window_pause(1), editor.frame = 0, editor.t = 0, editor.dt = 0, editor.slomo = 0, editor.active = 1; editor_select("**"); editor_destroy_selected(); }} ); +EDITOR_BIND(play, "down(F5)", { + if(editor.t > 0) { window_pause(1), editor.frame = 0, editor.t = 0, editor.dt = 0, editor.slomo = 0, editor.active = 1; window_cursor(1); editor_select("**"); editor_destroy_selected(); } + window_pause(0); /* if(!editor.slomo) editor.active = 0; */ editor.slomo = 1; + } +); +EDITOR_BIND(stop, "down(ESC)", { if(editor.t > 0) { window_pause(1), editor.frame = 0, editor.t = 0, editor.dt = 0, editor.slomo = 0, editor.active = 1; window_cursor(1); editor_select("**"); editor_destroy_selected(); }} ); EDITOR_BIND(eject, "down(F1)", { /*window_pause(!editor.active); editor.slomo = !!editor.active;*/ editor.active ^= 1; } ); -EDITOR_BIND(pause, "(held(CTRL) & down(P)) | down(PAUSE)", { window_pause( window_has_pause() ^ 1 ); } ); +EDITOR_BIND(pause, "(held(CTRL) & down(P)) | down(PAUSE) | down(F6)", { window_pause( window_has_pause() ^ 1 ); } ); EDITOR_BIND(frame, "held(CTRL) & down(LEFT)", { window_pause(1); editor.frame++, editor.t += (editor.dt = 1/60.f); } ); EDITOR_BIND(slomo, "held(CTRL) & down(RIGHT)", { window_pause(0); editor.slomo = maxf(fmod(editor.slomo * 2, 16), 0.125); } ); EDITOR_BIND(reload, "held(CTRL) & down(F5)", { window_reload(); } ); @@ -397047,8 +397068,8 @@ void editor_frame( void (*game)(unsigned, float, double) ) { window_cursor_shape(CURSOR_SW_AUTO); editor.hz_high = window_fps_target(); - fx_load("**/editorOutline.fs"); - fx_enable(0, 1); + // fx_load("**/editorOutline.fs"); + // fx_enable(0, 1); obj_setname(editor.root = obj_new(obj), "Signals"); obj_setname(editor.on_init = obj_new(obj), "onInit"); diff --git a/engine/split/v4k_editor.c b/engine/split/v4k_editor.c index cdccfac..f362628 100644 --- a/engine/split/v4k_editor.c +++ b/engine/split/v4k_editor.c @@ -142,7 +142,7 @@ struct editor_t { } editor = { .active = 1, .gamepad = 1, - .hz_high = 60, .hz_medium = 18, .hz_low = 5, + .hz_high = 60, .hz_medium = 40, .hz_low = 30, }; int editor_begin(const char *title, int mode) { @@ -450,10 +450,14 @@ const char* editor_recv(int jobid, double timeout_ss) { } // plain and ctrl keys -EDITOR_BIND(play, "down(F5)", { window_pause(0); /* if(!editor.slomo) editor.active = 0; */ editor.slomo = 1; } ); -EDITOR_BIND(stop, "down(ESC)", { if(editor.t > 0) { window_pause(1), editor.frame = 0, editor.t = 0, editor.dt = 0, editor.slomo = 0, editor.active = 1; editor_select("**"); editor_destroy_selected(); }} ); +EDITOR_BIND(play, "down(F5)", { + if(editor.t > 0) { window_pause(1), editor.frame = 0, editor.t = 0, editor.dt = 0, editor.slomo = 0, editor.active = 1; window_cursor(1); editor_select("**"); editor_destroy_selected(); } + window_pause(0); /* if(!editor.slomo) editor.active = 0; */ editor.slomo = 1; + } +); +EDITOR_BIND(stop, "down(ESC)", { if(editor.t > 0) { window_pause(1), editor.frame = 0, editor.t = 0, editor.dt = 0, editor.slomo = 0, editor.active = 1; window_cursor(1); editor_select("**"); editor_destroy_selected(); }} ); EDITOR_BIND(eject, "down(F1)", { /*window_pause(!editor.active); editor.slomo = !!editor.active;*/ editor.active ^= 1; } ); -EDITOR_BIND(pause, "(held(CTRL) & down(P)) | down(PAUSE)", { window_pause( window_has_pause() ^ 1 ); } ); +EDITOR_BIND(pause, "(held(CTRL) & down(P)) | down(PAUSE) | down(F6)", { window_pause( window_has_pause() ^ 1 ); } ); EDITOR_BIND(frame, "held(CTRL) & down(LEFT)", { window_pause(1); editor.frame++, editor.t += (editor.dt = 1/60.f); } ); EDITOR_BIND(slomo, "held(CTRL) & down(RIGHT)", { window_pause(0); editor.slomo = maxf(fmod(editor.slomo * 2, 16), 0.125); } ); EDITOR_BIND(reload, "held(CTRL) & down(F5)", { window_reload(); } ); @@ -549,8 +553,8 @@ void editor_frame( void (*game)(unsigned, float, double) ) { window_cursor_shape(CURSOR_SW_AUTO); editor.hz_high = window_fps_target(); - fx_load("**/editorOutline.fs"); - fx_enable(0, 1); + // fx_load("**/editorOutline.fs"); + // fx_enable(0, 1); obj_setname(editor.root = obj_new(obj), "Signals"); obj_setname(editor.on_init = obj_new(obj), "onInit"); diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index 7637607..01cc910 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -2217,6 +2217,22 @@ void shadowmap_end(shadowmap_t *s) { } } +void ui_shadowmap(shadowmap_t *s) { + if (!s) return; + + int vsm_width = s->vsm_texture_width; + int csm_width = s->csm_texture_width; + ui_int("Texture Width (VSM)", &vsm_width); + ui_int("Texture Width (CSM)", &csm_width); + + if (ui_collapse("VRAM Usage", "vram_usage")) { + ui_label2("Total VRAM", va("%lld KB", s->vram_usage_total / 1024)); + ui_label2("VSM VRAM", va("%lld KB", s->vram_usage_vsm / 1024)); + ui_label2("CSM VRAM", va("%lld KB", s->vram_usage_csm / 1024)); + ui_collapse_end(); + } +} + // ----------------------------------------------------------------------------- // Occlusion queries diff --git a/engine/split/v4k_render.h b/engine/split/v4k_render.h index 24c20be..0473b41 100644 --- a/engine/split/v4k_render.h +++ b/engine/split/v4k_render.h @@ -391,6 +391,7 @@ API void shadowmap_begin(shadowmap_t *s); API bool shadowmap_step(shadowmap_t *s); //< roll over to the next light if it returns false API void shadowmap_light(shadowmap_t *s, light_t *l, mat44 cam_proj, mat44 cam_view); //< must be called at most once per shadowmap_step API void shadowmap_end(shadowmap_t *s); +API void ui_shadowmap(shadowmap_t *s); // ----------------------------------------------------------------------------- // shaders diff --git a/engine/v4k.c b/engine/v4k.c index 7228f96..ddeada8 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -19016,6 +19016,22 @@ void shadowmap_end(shadowmap_t *s) { } } +void ui_shadowmap(shadowmap_t *s) { + if (!s) return; + + int vsm_width = s->vsm_texture_width; + int csm_width = s->csm_texture_width; + ui_int("Texture Width (VSM)", &vsm_width); + ui_int("Texture Width (CSM)", &csm_width); + + if (ui_collapse("VRAM Usage", "vram_usage")) { + ui_label2("Total VRAM", va("%lld KB", s->vram_usage_total / 1024)); + ui_label2("VSM VRAM", va("%lld KB", s->vram_usage_vsm / 1024)); + ui_label2("CSM VRAM", va("%lld KB", s->vram_usage_csm / 1024)); + ui_collapse_end(); + } +} + // ----------------------------------------------------------------------------- // Occlusion queries @@ -31697,7 +31713,7 @@ struct editor_t { } editor = { .active = 1, .gamepad = 1, - .hz_high = 60, .hz_medium = 18, .hz_low = 5, + .hz_high = 60, .hz_medium = 40, .hz_low = 30, }; int editor_begin(const char *title, int mode) { @@ -32005,10 +32021,14 @@ const char* editor_recv(int jobid, double timeout_ss) { } // plain and ctrl keys -EDITOR_BIND(play, "down(F5)", { window_pause(0); /* if(!editor.slomo) editor.active = 0; */ editor.slomo = 1; } ); -EDITOR_BIND(stop, "down(ESC)", { if(editor.t > 0) { window_pause(1), editor.frame = 0, editor.t = 0, editor.dt = 0, editor.slomo = 0, editor.active = 1; editor_select("**"); editor_destroy_selected(); }} ); +EDITOR_BIND(play, "down(F5)", { + if(editor.t > 0) { window_pause(1), editor.frame = 0, editor.t = 0, editor.dt = 0, editor.slomo = 0, editor.active = 1; window_cursor(1); editor_select("**"); editor_destroy_selected(); } + window_pause(0); /* if(!editor.slomo) editor.active = 0; */ editor.slomo = 1; + } +); +EDITOR_BIND(stop, "down(ESC)", { if(editor.t > 0) { window_pause(1), editor.frame = 0, editor.t = 0, editor.dt = 0, editor.slomo = 0, editor.active = 1; window_cursor(1); editor_select("**"); editor_destroy_selected(); }} ); EDITOR_BIND(eject, "down(F1)", { /*window_pause(!editor.active); editor.slomo = !!editor.active;*/ editor.active ^= 1; } ); -EDITOR_BIND(pause, "(held(CTRL) & down(P)) | down(PAUSE)", { window_pause( window_has_pause() ^ 1 ); } ); +EDITOR_BIND(pause, "(held(CTRL) & down(P)) | down(PAUSE) | down(F6)", { window_pause( window_has_pause() ^ 1 ); } ); EDITOR_BIND(frame, "held(CTRL) & down(LEFT)", { window_pause(1); editor.frame++, editor.t += (editor.dt = 1/60.f); } ); EDITOR_BIND(slomo, "held(CTRL) & down(RIGHT)", { window_pause(0); editor.slomo = maxf(fmod(editor.slomo * 2, 16), 0.125); } ); EDITOR_BIND(reload, "held(CTRL) & down(F5)", { window_reload(); } ); @@ -32104,8 +32124,8 @@ void editor_frame( void (*game)(unsigned, float, double) ) { window_cursor_shape(CURSOR_SW_AUTO); editor.hz_high = window_fps_target(); - fx_load("**/editorOutline.fs"); - fx_enable(0, 1); + // fx_load("**/editorOutline.fs"); + // fx_enable(0, 1); obj_setname(editor.root = obj_new(obj), "Signals"); obj_setname(editor.on_init = obj_new(obj), "onInit"); diff --git a/engine/v4k.h b/engine/v4k.h index 84eacb2..eaae701 100644 --- a/engine/v4k.h +++ b/engine/v4k.h @@ -3426,6 +3426,7 @@ API void shadowmap_begin(shadowmap_t *s); API bool shadowmap_step(shadowmap_t *s); //< roll over to the next light if it returns false API void shadowmap_light(shadowmap_t *s, light_t *l, mat44 cam_proj, mat44 cam_view); //< must be called at most once per shadowmap_step API void shadowmap_end(shadowmap_t *s); +API void ui_shadowmap(shadowmap_t *s); // ----------------------------------------------------------------------------- // shaders