summaryrefslogtreecommitdiff
path: root/src/logos/tasks.h
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-19 09:56:36 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-19 09:56:36 +1000
commit0942a484a90695749f05d49273951f2b8d452866 (patch)
tree319aff81e879168b152505875e608aee26fed5ff /src/logos/tasks.h
parent01d598220b403f4ac4da3b7aa1f0ce398be3198f (diff)
merge
Diffstat (limited to 'src/logos/tasks.h')
-rw-r--r--src/logos/tasks.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/logos/tasks.h b/src/logos/tasks.h
new file mode 100644
index 0000000..3e6bd06
--- /dev/null
+++ b/src/logos/tasks.h
@@ -0,0 +1,60 @@
+/**
+ * Common jobs that get run
+ */
+#pragma once
+#include "defines.h"
+#include "logos/threadpool.h"
+#include "render_types.h"
+#include "str.h"
+
+typedef struct Task {
+ char* debug_name;
+ void* params;
+ bool is_done;
+} Task;
+
+// Macro : give Params and Result structs and it creates a function that knows
+// correct sizes
+
+typedef struct Task_ModelLoad_Params {
+ Str8 filepath; // filepath to the model on disk
+ } Task_ModelLoad_Params;
+typedef struct Task_ModelLoad_Result {
+ Model model;
+} Task_ModelLoad_Result;
+
+// Internally it will allocate data for each
+
+static bool Task_ModelLoad_Typed(
+ Task_ModelLoad_Params* params,
+ Task_ModelLoad_Result* result,
+ tpool_task_start run_task,
+ tpool_task_on_complete on_success,
+ tpool_task_on_complete on_failure
+) {
+ threadpool_add_task(pool, , tpool_task_on_complete on_success, tpool_task_on_complete on_fail, bool buffer_result_for_main_thread, void *param_data, u32 param_data_size, u32 result_data_size)
+}
+
+// do task
+// success
+void model_load_success(task_globals* globals, void* result) {
+ Task_ModelLoad_Result* load_res = result;
+
+ // push into render -> renderables ?
+}
+// fail
+
+
+// we can define our custom task here that wraps the more verbose function pointers
+static Task Task_ModelLoad(
+ Task_ModelLoad_Params* params,
+ Task_ModelLoad_Result* result
+) {
+ Task task;
+ task.debug_name = "Load Model";
+ task.params = params;
+
+ Task_ModelLoad_Typed(params, result, tpool_task_start run_task, tpool_task_on_complete on_success, tpool_task_on_complete on_failure)
+
+ return task;
+}