From af6824e6dbd21a63613ed5cf1cdb03b617a7a87c Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sun, 22 Sep 2024 23:10:36 -0500 Subject: [PATCH] add render --- scripts/engine.js | 11 +++++++++++ scripts/profile.js | 7 ++++++- scripts/prosperon.js | 6 ++---- scripts/render.js | 7 ------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/scripts/engine.js b/scripts/engine.js index 894e561..76a894a 100644 --- a/scripts/engine.js +++ b/scripts/engine.js @@ -349,3 +349,14 @@ if (!profile.enabled) use = stripped_use; Object.assign(globalThis, use("scripts/prosperon.js")); + + +app.interval(_ => { + profile.frame("hotreload"); + actor.hotreload(); + render.hotreload(); + game.tex_hotreload(); + repl.hotreload(); + profile.endframe(); +}, 1); + diff --git a/scripts/profile.js b/scripts/profile.js index 04a172c..f84cb5d 100644 --- a/scripts/profile.js +++ b/scripts/profile.js @@ -1,3 +1,8 @@ +/* + TYPES OF PROFILING + +*/ + var t_units = ["ns", "us", "ms", "s", "ks", "Ms"]; function calc_cpu(fn, times, diff=0) @@ -37,7 +42,6 @@ profile.ms = function(t) { return profile.secs(t)*1000; } var callgraph = {}; profile.cpu_cg = callgraph; -var st = profile.now(); function add_callgraph(fn, line, time) { var cc = callgraph[line]; @@ -63,6 +67,7 @@ profile.start_cpu_gather = function(gathertime = 5) // gather cpu frames for 'ti { if (cpu_start) return; cpu_start = profile.now(); + var st = cpu_start; profile.gather(hittar, function() { var time = profile.now()-st; diff --git a/scripts/prosperon.js b/scripts/prosperon.js index 348869f..5486098 100644 --- a/scripts/prosperon.js +++ b/scripts/prosperon.js @@ -183,15 +183,13 @@ game.tex_hotreload = function() { for (var path in game.texture.cache) { if (io.mod(path) > game.texture.time_cache[path]) { - say(`HOT SWAPPING IMAGE ${path}`); var tex = game.texture.cache[path]; game.texture.time_cache[path] = io.mod(path); os.texture_swap(path, game.texture.cache[path]); for (var sprite of Object.values(allsprites)) { if (sprite.texture == tex) { - say('syncing a sprite ...'); - sprite.tex_sync(); - } + sprite.tex_sync(); + } } } } diff --git a/scripts/render.js b/scripts/render.js index 1ef1154..8e978c8 100644 --- a/scripts/render.js +++ b/scripts/render.js @@ -1147,13 +1147,6 @@ prosperon.process = function process() { var dt = profile.secs(profile.now()) - frame_t; frame_t = profile.secs(profile.now()); - profile.frame("hotreload"); - actor.hotreload(); - render.hotreload(); - game.tex_hotreload(); - repl.hotreload(); - profile.endframe(); - /* debugging: check for gc */ profile.print_gc();