summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-01-10 23:33:45 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-01-11 22:31:31 -0800
commit470305ae1c7b038fa0ad58223a2d48f60158a7bf (patch)
treea863ca2b2cf1116109e4e3360bc34288caa9851e /src
parentd94affec0e772e529479b0a4624464690919fed4 (diff)
main,til_args: employ the stream, add --print-pipes
This is a rudimentary integration of the new til_stream_t into rototiller. If the stream is going to continue living in til_fb_fragment_t, the fragmenters and other nested frame scenarios likely need to be updated to copy the stream through to make the pipes available to the nested renders. --print-pipes dumps the values found at the pipes' driver taps to stdout on every frame. Right now there's no way to externally write these values, but with --print-pipes you can already see where things are going and it's a nice visibility tool for tapped variables in modules. Only stars and plato tap variables presently, but that will improve.
Diffstat (limited to 'src')
-rw-r--r--src/main.c12
-rw-r--r--src/til_args.c3
-rw-r--r--src/til_args.h1
3 files changed, 15 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 0718bfd..5b2024d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,8 +12,9 @@
#include "til.h"
#include "til_args.h"
-#include "til_settings.h"
#include "til_fb.h"
+#include "til_settings.h"
+#include "til_stream.h"
#include "til_util.h"
#include "fps.h"
@@ -53,6 +54,7 @@ typedef struct rototiller_t {
til_args_t args;
const til_module_t *module;
til_module_context_t *module_context;
+ til_stream_t *stream;
pthread_t thread;
til_fb_t *fb;
struct timeval start_tv;
@@ -329,10 +331,14 @@ static void * rototiller_thread(void *_rt)
unsigned ticks;
fragment = til_fb_page_get(rt->fb);
+ fragment->stream = rt->stream;
gettimeofday(&now, NULL);
ticks = get_ticks(&rt->start_tv, &now, rt->ticks_offset);
til_module_render(rt->module_context, ticks, &fragment);
til_fb_fragment_submit(fragment);
+
+ if (rt->args.print_pipes) /* render threads are idle at this point */
+ til_stream_fprint(rt->stream, stdout);
}
return NULL;
@@ -376,6 +382,9 @@ int main(int argc, const char *argv[])
exit_if((r = til_fb_new(fb_ops, setup.video_setup, NUM_FB_PAGES, &rototiller.fb)) < 0,
"unable to create fb: %s", strerror(-r));
+ exit_if(!(rototiller.stream = til_stream_new()),
+ "unable to create root stream");
+
exit_if(!fps_setup(),
"unable to setup fps counter");
@@ -405,6 +414,7 @@ int main(int argc, const char *argv[])
pthread_join(rototiller.thread, NULL);
til_shutdown();
til_module_context_free(rototiller.module_context);
+ til_stream_free(rototiller.stream);
til_fb_free(rototiller.fb);
return EXIT_SUCCESS;
diff --git a/src/til_args.c b/src/til_args.c
index 8969d89..11f2487 100644
--- a/src/til_args.c
+++ b/src/til_args.c
@@ -12,6 +12,7 @@
* ./rototiller --defaults // use default settings where unspecified
* ./rototiller --go // don't show args and wait for user input before proceeding
* ./rototiller --seed=0xdeadbeef // explicitly set global random seed instead of generating one
+ * ./rototiller --print-pipes // print values for the pipes every frame
*
* unrecognized arguments trigger an -EINVAL error, unless res_{argc,argv} are non-NULL
* where a new argv will be allocated and populated with the otherwise invalid arguments
@@ -54,6 +55,8 @@ static int args_parse(int argc, const char *argv[], til_args_t *res_args, int *r
res_args->help = 1;
} else if (!strcasecmp("--go", argv[i])) {
res_args->gogogo = 1;
+ } else if (!strcasecmp("--print-pipes", argv[i])) {
+ res_args->print_pipes = 1;
} else {
if (!res_argv)
return -EINVAL;
diff --git a/src/til_args.h b/src/til_args.h
index d45b619..85d4d7b 100644
--- a/src/til_args.h
+++ b/src/til_args.h
@@ -11,6 +11,7 @@ typedef struct til_args_t {
unsigned use_defaults:1;
unsigned help:1;
unsigned gogogo:1;
+ unsigned print_pipes:1;
} til_args_t;
int til_args_parse(int argc, const char *argv[], til_args_t *res_args);
© All Rights Reserved