diff --git a/src/config.h b/src/config.h index 3b07856b..3496649b 100644 --- a/src/config.h +++ b/src/config.h @@ -80,7 +80,7 @@ -#define DX12_TEST 1 +#define DX12_TEST 0 diff --git a/src/sprite.c b/src/sprite.c index 25e40de9..cb79b2ee 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -1047,6 +1047,13 @@ struct sprite_texture *sprite_texture_from_tag_async(struct sprite_scope *scope, return (struct sprite_texture *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_TEXTURE, false); } + +void sprite_texture_from_tag_prefetch(struct sprite_scope *scope, struct sprite_tag tag) +{ + __prof; + data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_TEXTURE, false); +} + /* ========================== * * Sheet * ========================== */ @@ -1063,6 +1070,13 @@ struct sprite_sheet *sprite_sheet_from_tag_async(struct sprite_scope *scope, str return (struct sprite_sheet *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_SHEET, false); } +void sprite_sheet_from_tag_prefetch(struct sprite_scope *scope, struct sprite_tag tag) +{ + __prof; + data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_SHEET, false); +} + + struct sprite_sheet_frame sprite_sheet_get_frame(struct sprite_sheet *sheet, u32 index) { __prof; diff --git a/src/sprite.h b/src/sprite.h index e5c178ed..aceb3168 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -55,6 +55,7 @@ struct sprite_texture { struct sprite_texture *sprite_texture_from_tag_await(struct sprite_scope *scope, struct sprite_tag tag); struct sprite_texture *sprite_texture_from_tag_async(struct sprite_scope *scope, struct sprite_tag tag); +void sprite_texture_from_tag_prefetch(struct sprite_scope *scope, struct sprite_tag tag); /* ========================== * * Sheet load @@ -80,6 +81,7 @@ struct sprite_sheet { struct sprite_sheet *sprite_sheet_from_tag_await(struct sprite_scope *scope, struct sprite_tag tag); struct sprite_sheet *sprite_sheet_from_tag_async(struct sprite_scope *scope, struct sprite_tag tag); +void sprite_sheet_from_tag_prefetch(struct sprite_scope *scope, struct sprite_tag tag); /* ========================== * * Sheet query diff --git a/src/sys_win32.c b/src/sys_win32.c index 218a6eb5..0ff5b6cf 100644 --- a/src/sys_win32.c +++ b/src/sys_win32.c @@ -1608,10 +1608,16 @@ struct sys_mutex *sys_mutex_alloc(void) void sys_mutex_release(struct sys_mutex *mutex) { __prof; + struct win32_mutex *m = (struct win32_mutex *)mutex; + ASSERT(atomic_i64_eval(&m->count) == 0); /* Mutex should be unlocked */ + { + struct sys_lock lock = sys_mutex_lock_e(G.mutexes_mutex); + m->next_free = G.first_free_mutex; + G.first_free_mutex = m; + sys_mutex_unlock(&lock); + } __proflock_release(m->profiling_ctx); - /* Mutex should be unlocked */ - ASSERT(atomic_i64_eval(&m->count) == 0); } struct sys_lock sys_mutex_lock_e(struct sys_mutex *mutex) @@ -2361,10 +2367,10 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, timeBeginPeriod(G.scheduler_period_ms); /* Setup mutexes */ - struct win32_mutex first_mutex = ZI; - win32_mutex_init(&first_mutex); - G.mutexes_mutex = (struct sys_mutex *)&first_mutex; G.mutexes_arena = arena_alloc(GIGABYTE(64)); + struct win32_mutex *first_mutex = arena_push(G.mutexes_arena, struct win32_mutex); + win32_mutex_init(first_mutex); + G.mutexes_mutex = (struct sys_mutex *)first_mutex; /* Set up condition variables */ G.condition_variables_mutex = sys_mutex_alloc(); diff --git a/src/user.c b/src/user.c index 77694029..86552d23 100644 --- a/src/user.c +++ b/src/user.c @@ -1252,12 +1252,9 @@ INTERNAL void user_update(void) } /* Draw sprite */ - //if ((false)) { if (!sprite_tag_is_nil(sprite)) { - /* Async load */ struct sprite_sheet *sheet = sprite_sheet_from_tag_async(sprite_frame_scope, sprite); - struct sprite_texture *texture = sprite_texture_from_tag_async(sprite_frame_scope, sprite); - (UNUSED)texture; + sprite_texture_from_tag_prefetch(sprite_frame_scope, sprite); /* TODO: Fade in placeholder if texture isn't loaded */ if (sheet->loaded) {