system startup receipts

This commit is contained in:
jacob 2024-03-28 13:31:35 -05:00
parent 508c77abfd
commit 04eb118e60
34 changed files with 239 additions and 89 deletions

View File

@ -99,10 +99,11 @@ void app_entry_point(void)
scratch_end(scratch);
}
logf_info("Startup");
console_startup();
/* Startup console */
struct console_startup_receipt console_sr = console_startup();
/* Startup window & renderer */
/* Create window */
struct sys_window window = sys_window_alloc();
{
/* Read window settings from file */
@ -111,24 +112,25 @@ void app_entry_point(void)
sys_window_update_settings(&window, &window_settings);
}
renderer_startup(&window);
/* Startup systems */
struct renderer_startup_receipt renderer_sr = renderer_startup(&window);
struct work_startup_receipt work_sr = work_startup(worker_count);
struct resource_startup_receipt resource_sr = resource_startup();
struct asset_cache_startup_receipt asset_cache_sr = asset_cache_startup(&work_sr);
struct ttf_startup_receipt ttf_sr = ttf_startup();
struct font_startup_receipt font_sr = font_startup(&work_sr, &renderer_sr, &asset_cache_sr, &ttf_sr, &resource_sr);
struct texture_startup_receipt texture_sr = texture_startup(&work_sr, &renderer_sr, &asset_cache_sr, &resource_sr);
struct sheet_startup_receipt sheet_sr = sheet_startup(&work_sr, &asset_cache_sr, &resource_sr);
struct mixer_startup_receipt mixer_sr = mixer_startup();
struct sound_startup_receipt sound_sr = sound_startup(&work_sr, &asset_cache_sr, &resource_sr);
struct draw_startup_receipt draw_sr = draw_startup(&renderer_sr, &font_sr);
struct game_startup_receipt game_sr = game_startup(&mixer_sr, &sheet_sr, &sound_sr);
struct user_startup_receipt user_sr = user_startup(&work_sr, &renderer_sr, &font_sr, &texture_sr, &draw_sr, &game_sr, &asset_cache_sr, &mixer_sr, &window);
struct playback_startup_receipt playback_sr = playback_startup(&mixer_sr);
/* Startup subsystems */
resource_startup();
asset_cache_startup();
ttf_startup();
font_startup();
texture_startup();
sheet_startup();
mixer_startup();
sound_startup();
draw_startup();
/* Startup threaded systems */
work_startup(worker_count);
game_startup();
user_startup(&window);
playback_startup();
(UNUSED)console_sr;
(UNUSED)user_sr;
(UNUSED)playback_sr;
/* Show window */
sys_window_show(&window);

View File

@ -35,8 +35,10 @@ GLOBAL struct {
* Startup
* ========================== */
void asset_cache_startup(void)
struct asset_cache_startup_receipt asset_cache_startup(struct work_startup_receipt *work_sr)
{
(UNUSED)work_sr;
/* Init lookup */
L.lookup_rw_mutex = sys_rw_mutex_alloc();
/* Init store */
@ -46,6 +48,8 @@ void asset_cache_startup(void)
/* Init debug */
L.dbg_table_mutex = sys_mutex_alloc();
#endif
return (struct asset_cache_startup_receipt) { 0 };
}
/* ========================== *

View File

@ -5,6 +5,8 @@
#include "work.h"
#include "util.h"
struct work_startup_receipt;
enum asset_status {
ASSET_STATUS_NONE,
@ -38,7 +40,8 @@ struct asset_cache_store {
struct sys_rw_mutex *rw_mutex;
};
void asset_cache_startup(void);
struct asset_cache_startup_receipt { i32 _; };
struct asset_cache_startup_receipt asset_cache_startup(struct work_startup_receipt *work_sr);
struct asset *asset_cache_touch(struct string key, u64 hash, b32 *is_first_touch);

View File

@ -15,9 +15,10 @@ INTERNAL void console_log_callback(struct log_event event)
(UNUSED)event;
}
void console_startup(void)
struct console_startup_receipt console_startup(void)
{
log_register_callback(&console_log_callback);
return (struct console_startup_receipt) { 0 };
}
/* ========================== *

View File

@ -3,7 +3,8 @@
#include "sys.h"
void console_startup(void);
struct console_startup_receipt { i32 _; };
struct console_startup_receipt console_startup(void);
b32 console_process_event(struct sys_event event);
#endif

View File

@ -1,7 +1,6 @@
#include "draw.h"
#include "renderer.h"
#include "math.h"
#include "texture.h"
#include "font.h"
#include "scratch.h"
@ -13,8 +12,12 @@ GLOBAL struct {
* Startup
* ========================== */
void draw_startup(void)
struct draw_startup_receipt draw_startup(struct renderer_startup_receipt *renderer_sr,
struct font_startup_receipt *font_sr)
{
(UNUSED)renderer_sr;
(UNUSED)font_sr;
/* Generate solid white texture */
{
struct temp_arena scratch = scratch_begin_no_conflict();
@ -27,6 +30,8 @@ void draw_startup(void)
L.solid_white = renderer_texture_alloc(image_data);
scratch_end(scratch);
}
return (struct draw_startup_receipt) { 0 };
}
/* ========================== *

View File

@ -3,6 +3,8 @@
struct renderer_canvas;
struct font;
struct renderer_startup_receipt;
struct font_startup_receipt;
#define DRAW_TEXTURE_PARAMS(...) ((struct draw_texture_params) { \
.tint = COLOR_WHITE, \
@ -15,7 +17,9 @@ struct draw_texture_params {
u32 tint;
};
void draw_startup(void);
struct draw_startup_receipt { i32 _; };
struct draw_startup_receipt draw_startup(struct renderer_startup_receipt *renderer_sr,
struct font_startup_receipt *font_sr);
void draw_texture_quad(struct renderer_canvas *canvas, struct draw_texture_params params, struct quad quad);
void draw_texture_rect(struct renderer_canvas *canvas, struct draw_texture_params params, struct rect rect);

View File

@ -7,6 +7,7 @@
#include "resource.h"
#include "log.h"
#include "string.h"
#include "renderer.h"
#define FONT_CHARS " !\"#$%&\'()-.,*/0123456789:;<=+>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
#define LOOKUP_TABLE_SIZE (256)
@ -38,10 +39,22 @@ GLOBAL struct {
* Startup
* ========================== */
void font_startup(void)
struct font_startup_receipt font_startup(struct work_startup_receipt *work_sr,
struct renderer_startup_receipt *renderer_sr,
struct asset_cache_startup_receipt *asset_cache_sr,
struct ttf_startup_receipt *ttf_sr,
struct resource_startup_receipt *resource_sr)
{
(UNUSED)work_sr;
(UNUSED)renderer_sr;
(UNUSED)asset_cache_sr;
(UNUSED)ttf_sr;
(UNUSED)resource_sr;
L.params.arena = arena_alloc(GIGABYTE(64));
L.params.mutex = sys_mutex_alloc();
return (struct font_startup_receipt) { 0 };
}
/* ========================== *

View File

@ -4,7 +4,13 @@
#include "texture.h"
#include "util.h"
struct asset;
struct work_startup_receipt;
struct renderer_startup_receipt;
struct asset_cache_startup_receipt;
struct ttf_startup_receipt;
struct resource_startup_receipt;
struct font_glyph {
f32 off_x;
@ -23,7 +29,12 @@ struct font {
u16 *lookup;
};
void font_startup(void);
struct font_startup_receipt { i32 _; };
struct font_startup_receipt font_startup(struct work_startup_receipt *work_sr,
struct renderer_startup_receipt *renderer_sr,
struct asset_cache_startup_receipt *asset_cache_sr,
struct ttf_startup_receipt *ttf_sr,
struct resource_startup_receipt *resource_sr);
struct asset *font_load_asset(struct string path, f32 point_size, b32 help);
struct font *font_load_async(struct string path, f32 point_size);

View File

@ -1,5 +1,4 @@
#include "game.h"
#include "app.h"
#include "sys.h"
#include "util.h"
#include "world.h"
@ -556,8 +555,14 @@ INTERNAL SYS_THREAD_FUNC_DEF(game_thread_entry_point, arg)
}
}
void game_startup(void)
struct game_startup_receipt game_startup(struct mixer_startup_receipt *mixer_sr,
struct sheet_startup_receipt *sheet_sr,
struct sound_startup_receipt *sound_sr)
{
(UNUSED)mixer_sr;
(UNUSED)sheet_sr;
(UNUSED)sound_sr;
/* Initialize game cmd storage */
L.game_cmds_mutex = sys_mutex_alloc();
L.game_cmds_arena = arena_alloc(GIGABYTE(64));
@ -572,6 +577,8 @@ void game_startup(void)
L.world.timescale = GAME_TIMESCALE;
L.game_thread = sys_thread_init(&game_thread_entry_point, NULL, STR("[P2] Game thread"));
return (struct game_startup_receipt) { 0 };
}
void game_shutdown(void)

View File

@ -2,6 +2,9 @@
#define GAME_H
struct world;
struct mixer_startup_receipt;
struct sheet_startup_receipt;
struct sound_startup_receipt;
enum game_cmd_kind {
GAME_CMD_KIND_NONE,
@ -27,7 +30,10 @@ struct game_cmd_array {
u64 count;
};
void game_startup(void);
struct game_startup_receipt { i32 _; };
struct game_startup_receipt game_startup(struct mixer_startup_receipt *mixer_sr,
struct sheet_startup_receipt *sheet_sr,
struct sound_startup_receipt *sound_sr);
void game_shutdown(void);
void game_get_latest_tick(struct world *dest);

View File

@ -1,7 +1,13 @@
#include "log.h"
#include "scratch.h"
#include "string.h"
#include "app.h"
#include "atomic.h"
#if RTC
# define ASSERT_INITIALIZED ASSERT(atomic_i32_eval(&L.initialized) == 1)
#else
# define ASSERT_INITIALIZED
#endif
struct log_event_callback {
log_event_callback_func *func;
@ -14,6 +20,10 @@ struct log_event_callback {
* ========================== */
GLOBAL struct {
#if RTC
struct atomic_i32 initialized;
#endif
struct sys_mutex mutex;
struct arena arena;
log_event_callback_func *callbacks_head;
@ -52,7 +62,7 @@ GLOBAL READONLY const struct log_level_settings g_log_level_settings[LOG_LEVEL_C
* Startup
* ========================== */
void log_startup(struct string logfile_path)
struct log_startup_receipt log_startup(struct string logfile_path)
{
L.mutex = sys_mutex_alloc();
L.arena = arena_alloc(GIGABYTE(64));
@ -65,6 +75,12 @@ void log_startup(struct string logfile_path)
L.file_valid = true;
}
}
#if RTC
atomic_i32_eval_exchange(&L.initialized, 1);
#endif
return (struct log_startup_receipt) { 0 };
}
/* ========================== *
@ -73,6 +89,7 @@ void log_startup(struct string logfile_path)
void log_register_callback(log_event_callback_func *func)
{
ASSERT_INITIALIZED;
sys_mutex_lock(&L.mutex);
{
/* TODO */
@ -88,6 +105,8 @@ void log_register_callback(log_event_callback_func *func)
INTERNAL void append_to_logfile(struct string msg)
{
__prof;
ASSERT_INITIALIZED;
if (L.file_valid) {
struct temp_arena scratch = scratch_begin_no_conflict();
struct string msg_line = string_cat(scratch.arena, msg, STR("\n"));
@ -103,6 +122,7 @@ void _log(i32 level, struct string msg)
#endif
{
__prof;
ASSERT_INITIALIZED;
if (level < 0 || level >= LOG_LEVEL_COUNT) {
sys_panic(STR("Invalid log level"));
@ -172,6 +192,7 @@ void _logfv(i32 level, struct string file, u32 line, struct string fmt, va_list
void _logfv(i32 level, struct string fmt, va_list args)
#endif
{
ASSERT_INITIALIZED;
struct temp_arena scratch = scratch_begin_no_conflict();
struct string msg = string_formatv(scratch.arena, fmt, args);
#if LOG_INCLUDE_SOURCE_LOCATION
@ -188,6 +209,7 @@ void _logf(i32 level, struct string file, u32 line, struct string fmt, ...)
void _logf(i32 level, struct string fmt, ...)
#endif
{
ASSERT_INITIALIZED;
va_list args;
va_start(args, fmt);
#if LOG_INCLUDE_SOURCE_LOCATION

View File

@ -124,7 +124,8 @@ void log_register_callback(log_event_callback_func *func);
* Function declarations
* ========================== */
void log_startup(struct string logfile_path);
struct log_startup_receipt { i32 _; };
struct log_startup_receipt log_startup(struct string logfile_path);
#if LOG_INCLUDE_SOURCE_LOCATION
void _log(i32 level, struct string file, u32 line, struct string msg);

View File

@ -3,7 +3,6 @@
#include "scratch.h"
#include "sound.h"
#include "sys.h"
#include "playback.h"
#include "math.h"
/* TODO: Cap max sounds playing. */
@ -71,12 +70,14 @@ GLOBAL struct {
* Startup
* ========================== */
void mixer_startup(void)
struct mixer_startup_receipt mixer_startup(void)
{
L.track_arena = arena_alloc(GIGABYTE(64));
L.mutex = sys_mutex_alloc();
L.listener_pos = V2(0, 0);
L.listener_dir = V2(0, -1);
return (struct mixer_startup_receipt) { 0 };
}
/* ========================== *

View File

@ -38,7 +38,8 @@ struct mixed_pcm_f32 {
f32 *samples;
};
void mixer_startup(void);
struct mixer_startup_receipt { i32 _; };
struct mixer_startup_receipt mixer_startup(void);
/* Interface */
struct mixer_track_handle mixer_play(struct sound *sound);

View File

@ -3,7 +3,10 @@
#define PLAYBACK_SAMPLE_RATE 48000
void playback_startup(void);
struct mixer_startup_receipt;
struct playback_startup_receipt { i32 _; };
struct playback_startup_receipt playback_startup(struct mixer_startup_receipt *mixer_sr);
void playback_shutdown(void);
#endif

View File

@ -9,7 +9,6 @@
#include "scratch.h"
#include "sys.h"
#include "mixer.h"
#include "app.h"
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
@ -221,10 +220,14 @@ INTERNAL SYS_THREAD_FUNC_DEF(playback_thread_entry_point, arg)
}
}
void playback_startup(void)
struct playback_startup_receipt playback_startup(struct mixer_startup_receipt *mixer_sr)
{
(UNUSED)mixer_sr;
wasapi_initialize();
L.playback_thread = sys_thread_init(&playback_thread_entry_point, NULL, STR("[P3] Audio thread"));
return (struct playback_startup_receipt) { 0 };
}
void playback_shutdown(void)

View File

@ -41,7 +41,8 @@ struct texture_shader_vertex {
* Startup
* ========================== */
void renderer_startup(struct sys_window *window);
struct renderer_startup_receipt { i32 _; };
struct renderer_startup_receipt renderer_startup(struct sys_window *window);
/* ========================== *
* Canvas

View File

@ -1,10 +1,8 @@
#include "renderer.h"
#include "sys.h"
#include "app.h"
#include "memory.h"
#include "arena.h"
#include "scratch.h"
#include "texture.h"
#include "string.h"
#include "math.h"
#include "inc.h"
@ -116,7 +114,6 @@ struct dx11_shader_desc {
};
GLOBAL struct {
b32 initialized;
struct arena arena;
struct tar_archive shaders_archive; /* Tar archive including shader sources */
@ -383,7 +380,7 @@ INTERNAL void shader_init(struct dx11_shader *shader, enum shader_kind kind)
* Startup
* ========================== */
void renderer_startup(struct sys_window *window)
struct renderer_startup_receipt renderer_startup(struct sys_window *window)
{
__profscope(initializing_d3d11);
@ -601,8 +598,7 @@ void renderer_startup(struct sys_window *window)
shader_init(&L.shaders[i], i);
}
WRITE_BARRIER();
L.initialized = true;
return (struct renderer_startup_receipt) { 0 };
}
/* ========================== *

View File

@ -15,7 +15,7 @@ GLOBAL struct {
} L = { 0 }, DEBUG_LVAR(L_resource);
#endif
void resource_startup(void)
struct resource_startup_receipt resource_startup(void)
{
#if RESOURCES_EMBEDDED
struct buffer embedded_data = inc_res_tar();
@ -31,6 +31,8 @@ void resource_startup(void)
sys_panic(STR("Resource directory \"res\" not found"));
}
#endif
return (struct resource_startup_receipt) { 0 };
}
b32 resource_exists(struct string path)

View File

@ -14,8 +14,8 @@ struct resource {
#endif
};
void resource_startup(void);
struct resource_startup_receipt { i32 _; };
struct resource_startup_receipt resource_startup(void);
b32 resource_exists(struct string path);
struct resource resource_open(struct string path);

View File

@ -7,6 +7,7 @@
#include "asset_cache.h"
#include "ase.h"
#include "util.h"
#include "work.h"
struct sheet_task_params {
struct sheet_task_params *next_free;
@ -35,10 +36,18 @@ GLOBAL struct {
* Startup
* ========================== */
void sheet_startup(void)
struct sheet_startup_receipt sheet_startup(struct work_startup_receipt *work_sr,
struct asset_cache_startup_receipt *asset_cache_sr,
struct resource_startup_receipt *resource_sr)
{
(UNUSED)work_sr;
(UNUSED)asset_cache_sr;
(UNUSED)resource_sr;
L.params.arena = arena_alloc(GIGABYTE(64));
L.params.mutex = sys_mutex_alloc();
return (struct sheet_startup_receipt) { 0 };
}
/* ========================== *

View File

@ -5,6 +5,9 @@
struct asset;
struct sheet_frame;
struct work_startup_receipt;
struct asset_cache_startup_receipt;
struct resource_startup_receipt;
struct sheet {
struct v2 image_size;
@ -27,7 +30,10 @@ struct sheet_frame {
struct clip_rect clip;
};
void sheet_startup(void);
struct sheet_startup_receipt { i32 _; };
struct sheet_startup_receipt sheet_startup(struct work_startup_receipt *work_sr,
struct asset_cache_startup_receipt *asset_cache_srm,
struct resource_startup_receipt *resource_sr);
struct asset *sheet_load_asset(struct string path, b32 wait);
struct sheet *sheet_load_async(struct string path);

View File

@ -6,6 +6,7 @@
#include "resource.h"
#include "asset_cache.h"
#include "mp3.h"
#include "work.h"
struct sound_task_params {
struct sound_task_params *next_free;
@ -34,10 +35,18 @@ GLOBAL struct {
* Startup
* ========================== */
void sound_startup(void)
struct sound_startup_receipt sound_startup(struct work_startup_receipt *work_sr,
struct asset_cache_startup_receipt *asset_cache_sr,
struct resource_startup_receipt *resource_sr)
{
(UNUSED)work_sr;
(UNUSED)asset_cache_sr;
(UNUSED)resource_sr;
L.params.arena = arena_alloc(GIGABYTE(64));
L.params.mutex = sys_mutex_alloc();
return (struct sound_startup_receipt) { 0 };
}
/* ========================== *

View File

@ -5,13 +5,19 @@
#define SOUND_FLAG_STEREO 0x1
struct asset;
struct work_startup_receipt;
struct asset_cache_startup_receipt;
struct resource_startup_receipt;
struct sound {
u32 flags;
struct pcm pcm;
};
void sound_startup(void);
struct sound_startup_receipt { i32 _; };
struct sound_startup_receipt sound_startup(struct work_startup_receipt *work_sr,
struct asset_cache_startup_receipt *asset_cache_sr,
struct resource_startup_receipt *resource_sr);
struct asset *sound_load_asset(struct string path, u32 flags, b32 wait);
struct sound *sound_load_async(struct string path, u32 flags);

View File

@ -168,26 +168,3 @@ struct tar_entry *tar_get(const struct tar_archive *archive, struct string name)
{
return fixed_dict_get(&archive->lookup, name);
}
#if 0
b32 tar_is_file(const struct tar_archive *archive, struct string name)
{
struct tar_entry *entry = fixed_dict_get(&archive->file_lookup, name);
return entry && !entry->is_dir;
}
b32 tar_is_dir(const struct tar_archive *archive, struct string name)
{
struct tar_entry *entry = fixed_dict_get(&archive->file_lookup, name);
return entry && entry->is_dir;
}
struct buffer *tar_data(const struct tar_archive *archive, struct string name)
{
struct tar_entry *entry = fixed_dict_get(&archive->file_lookup, name);
if (entry) {
return entry->data;
}
return BUFFER(0, 0);
}
#endif

View File

@ -1,7 +1,6 @@
#include "texture.h"
#include "arena.h"
#include "memory.h"
#include "json.h"
#include "renderer.h"
#include "util.h"
#include "asset_cache.h"
@ -39,10 +38,20 @@ GLOBAL struct {
* Startup
* ========================== */
void texture_startup(void)
struct texture_startup_receipt texture_startup(struct work_startup_receipt *work_sr,
struct renderer_startup_receipt *renderer_sr,
struct asset_cache_startup_receipt *asset_cache_sr,
struct resource_startup_receipt *resource_sr)
{
(UNUSED)work_sr;
(UNUSED)renderer_sr;
(UNUSED)asset_cache_sr;
(UNUSED)resource_sr;
L.params.arena = arena_alloc(GIGABYTE(64));
L.params.mutex = sys_mutex_alloc();
return (struct texture_startup_receipt) { 0 };
}
/* ========================== *

View File

@ -1,11 +1,14 @@
#ifndef TEXTURE_H
#define TEXTURE_H
#include "json.h"
#include "renderer.h"
#include "util.h"
struct asset;
struct work_startup_receipt;
struct renderer_startup_receipt;
struct asset_cache_startup_receipt;
struct resource_startup_receipt;
struct texture_frame {
struct clip_rect clip;
@ -26,7 +29,11 @@ struct texture {
struct v2 size;
};
void texture_startup(void);
struct texture_startup_receipt { i32 _; };
struct texture_startup_receipt texture_startup(struct work_startup_receipt *work_sr,
struct renderer_startup_receipt *renderer_sr,
struct asset_cache_startup_receipt *asset_cache_sr,
struct resource_startup_receipt *resource_sr);
struct asset *texture_load_asset(struct string path, b32 wait);
struct texture *texture_load_async(struct string path);

View File

@ -12,7 +12,8 @@ struct ttf_decode_result {
struct image_rgba image_data;
};
void ttf_startup(void);
struct ttf_startup_receipt { i32 _; };
struct ttf_startup_receipt ttf_startup(void);
struct ttf_decode_result ttf_decode(struct arena *arena, struct buffer encoded, f32 point_size, struct string cache_chars);
#endif

View File

@ -6,7 +6,6 @@
extern "C"
{
#include "ttf.h"
#include "renderer.h"
#include "scratch.h"
#include "util.h"
@ -16,7 +15,6 @@ extern "C"
#include "arena.h"
#include "font.h"
#include "texture.h"
}
#pragma warning( pop )
@ -52,7 +50,7 @@ INTERNAL i32 round_up(f32 x)
}
/* Call this during font system startup */
void ttf_startup(void)
struct ttf_startup_receipt ttf_startup(void)
{
ASSERT(!L.factory);
/* FIXME: I think IDWriteFactory5 only exists on later updates of windows
@ -70,6 +68,8 @@ void ttf_startup(void)
if (error) {
sys_panic(STR("Error creating DWrite factory"));
}
return (struct ttf_startup_receipt) { 0 };
}
struct ttf_decode_result ttf_decode(struct arena *arena, struct buffer encoded, f32 point_size, struct string cache_chars)

View File

@ -1041,8 +1041,25 @@ INTERNAL SYS_THREAD_FUNC_DEF(user_thread_entry_point, arg)
}
}
void user_startup(struct sys_window *window)
struct user_startup_receipt user_startup(struct work_startup_receipt *work_sr,
struct renderer_startup_receipt *renderer_sr,
struct font_startup_receipt *font_sr,
struct texture_startup_receipt *texture_sr,
struct draw_startup_receipt *draw_sr,
struct game_startup_receipt *game_sr,
struct asset_cache_startup_receipt *asset_cache_sr,
struct mixer_startup_receipt *mixer_sr,
struct sys_window *window)
{
(UNUSED)work_sr;
(UNUSED)renderer_sr;
(UNUSED)font_sr;
(UNUSED)texture_sr;
(UNUSED)draw_sr;
(UNUSED)game_sr;
(UNUSED)asset_cache_sr;
(UNUSED)mixer_sr;
L.arena = arena_alloc(GIGABYTE(64));
L.sys_events_mutex = sys_mutex_alloc();
@ -1060,6 +1077,8 @@ void user_startup(struct sys_window *window)
sys_window_register_event_callback(L.window, &window_event_callback);
L.user_thread = sys_thread_init(&user_thread_entry_point, NULL, STR("[P1] User thread"));
return (struct user_startup_receipt) { 0 };
}
void user_shutdown(void)

View File

@ -2,6 +2,14 @@
#define USER_H
struct sys_window;
struct work_startup_receipt;
struct renderer_startup_receipt;
struct font_startup_receipt;
struct texture_startup_receipt;
struct draw_startup_receipt;
struct game_startup_receipt;
struct asset_cache_startup_receipt;
struct mixer_startup_receipt;
enum user_bind_kind {
USER_BIND_KIND_NONE,
@ -24,7 +32,16 @@ enum user_bind_kind {
USER_BIND_KIND_COUNT
};
void user_startup(struct sys_window *window);
struct user_startup_receipt { i32 _; };
struct user_startup_receipt user_startup(struct work_startup_receipt *work_sr,
struct renderer_startup_receipt *renderer_sr,
struct font_startup_receipt *font_sr,
struct texture_startup_receipt *texture_sr,
struct draw_startup_receipt *draw_sr,
struct game_startup_receipt *game_sr,
struct asset_cache_startup_receipt *asset_cache_sr,
struct mixer_startup_receipt *mixer_sr,
struct sys_window *window);
void user_shutdown(void);
#endif

View File

@ -93,7 +93,7 @@ INTERNAL void worker_thread_entry_point(void *thread_data);
* Startup
* ========================== */
void work_startup(u32 num_worker_threads)
struct work_startup_receipt work_startup(u32 num_worker_threads)
{
struct temp_arena scratch = scratch_begin_no_conflict();
@ -131,6 +131,8 @@ void work_startup(u32 num_worker_threads)
}
scratch_end(scratch);
return (struct work_startup_receipt) { 0 };
}
void work_shutdown(void)

View File

@ -35,7 +35,8 @@ struct worker_context {
b32 is_worker;
};
void work_startup(u32 num_worker_threads);
struct work_startup_receipt { i32 _; };
struct work_startup_receipt work_startup(u32 num_worker_threads);
void work_shutdown(void);
struct work_slate work_slate_begin(void);