summaryrefslogtreecommitdiff
path: root/src/logos
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-19 14:33:34 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-19 14:33:34 +1000
commit82515f9d90ac149984013f0d64c1cab37b349b29 (patch)
tree6da445874d055e3e66ab1825d4aa3bb784955fc9 /src/logos
parent5359c011a08ef2e06ed54104cc16c32868ca88ff (diff)
chore clang format + tidy
Diffstat (limited to 'src/logos')
-rw-r--r--src/logos/tasks.h66
-rw-r--r--src/logos/threadpool.h2
2 files changed, 41 insertions, 27 deletions
diff --git a/src/logos/tasks.h b/src/logos/tasks.h
index 3e6bd06..2e3dc53 100644
--- a/src/logos/tasks.h
+++ b/src/logos/tasks.h
@@ -7,54 +7,68 @@
#include "render_types.h"
#include "str.h"
+typedef enum TaskLifetime {
+ /** ephemeral tasks must be finished by the end of the frame and thus we use a leak and clear
+ allocation strategy */
+ TASK_EPHEMERAL,
+ /** multi-frame tasks have a more complex lifetime and must be cleaned up by the caller or in a
+ separate cleanup callback */
+ TASK_MULTIFRAME,
+ TASK_COUNT
+} TaskLifetime;
+
+typedef enum TaskKind {
+ TASK_RENDER,
+ TASK_PHYSICS,
+ TASK_GAMEPLAY,
+ TASK_ASSET,
+ TASK_USERLAND,
+ TASKKIND_COUNT
+} TaskKind;
+
typedef struct Task {
- char* debug_name;
- void* params;
- bool is_done;
+ 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;
+ Str8 filepath; // filepath to the model on disk
+} Task_ModelLoad_Params;
typedef struct Task_ModelLoad_Result {
- Model model;
+ 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)
+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;
+ Task_ModelLoad_Result* load_res = result;
- // push into render -> renderables ?
+ // 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;
+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)
+ Task_ModelLoad_Typed(params, result, tpool_task_start run_task, tpool_task_on_complete on_success,
+ tpool_task_on_complete on_failure)
- return task;
+ return task;
}
diff --git a/src/logos/threadpool.h b/src/logos/threadpool.h
index fbe43d6..2cd70fd 100644
--- a/src/logos/threadpool.h
+++ b/src/logos/threadpool.h
@@ -93,4 +93,4 @@ bool threadpool_add_task(threadpool *pool, tpool_task_start do_task,
void threadpool_process_results(threadpool *pool, int num_to_process);
-u32 Tpool_GetNumWorkers(); // how many threads are we using \ No newline at end of file
+u32 Tpool_GetNumWorkers(); // how many threads are we using \ No newline at end of file