minor tweaks & fixes
This commit is contained in:
parent
63c309b64f
commit
3061d465d1
24
build.c
24
build.c
@ -640,10 +640,12 @@ void OnBuild(StringList cli_args)
|
|||||||
D_AddDependency(&store, pch_c_file, pch_c_src_gen_obj_file);
|
D_AddDependency(&store, pch_c_file, pch_c_src_gen_obj_file);
|
||||||
if (IsDirty(pch_c_file)) {
|
if (IsDirty(pch_c_file)) {
|
||||||
D_ClearWrite(pch_c_src_gen_file, Lit(""));
|
D_ClearWrite(pch_c_src_gen_file, Lit(""));
|
||||||
BuildStepSimpleCommandArg *bs_arg = ArenaPush(&arena, BuildStepSimpleCommandArg);
|
BuildStepMsvcCompileCommandArg *bs_arg = ArenaPush(&arena, BuildStepMsvcCompileCommandArg);
|
||||||
bs_arg->cmd = StringF(&arena, pch_c_compile_args_fmt, FmtStr(pch_header_file.full_path), FmtStr(pch_c_src_gen_file.full_path));
|
bs_arg->cmd = StringF(&arena, pch_c_compile_args_fmt, FmtStr(pch_header_file.full_path), FmtStr(pch_c_src_gen_file.full_path));
|
||||||
|
bs_arg->depfile_dependent = pch_header_file;
|
||||||
|
bs_arg->output_depfile = dep_file;
|
||||||
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header_file)), FmtStr(D_GetName(pch_c_file)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header_file)), FmtStr(D_GetName(pch_c_file)));
|
||||||
AddStep(step_name, &BuildStepSimpleCommand, bs_arg);
|
AddStep(step_name, &BuildStepMsvcCompileCommand, bs_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cpp */
|
/* Cpp */
|
||||||
@ -651,10 +653,12 @@ void OnBuild(StringList cli_args)
|
|||||||
D_AddDependency(&store, pch_cpp_file, pch_cpp_src_gen_obj_file);
|
D_AddDependency(&store, pch_cpp_file, pch_cpp_src_gen_obj_file);
|
||||||
if (IsDirty(pch_cpp_file)) {
|
if (IsDirty(pch_cpp_file)) {
|
||||||
D_ClearWrite(pch_cpp_src_gen_file, Lit(""));
|
D_ClearWrite(pch_cpp_src_gen_file, Lit(""));
|
||||||
BuildStepSimpleCommandArg *bs_arg = ArenaPush(&arena, BuildStepSimpleCommandArg);
|
BuildStepMsvcCompileCommandArg *bs_arg = ArenaPush(&arena, BuildStepMsvcCompileCommandArg);
|
||||||
bs_arg->cmd = StringF(&arena, pch_cpp_compile_args_fmt, FmtStr(pch_header_file.full_path), FmtStr(pch_cpp_src_gen_file.full_path));
|
bs_arg->cmd = StringF(&arena, pch_cpp_compile_args_fmt, FmtStr(pch_header_file.full_path), FmtStr(pch_cpp_src_gen_file.full_path));
|
||||||
|
bs_arg->depfile_dependent = pch_header_file;
|
||||||
|
bs_arg->output_depfile = dep_file;
|
||||||
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header_file)), FmtStr(D_GetName(pch_cpp_file)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header_file)), FmtStr(D_GetName(pch_cpp_file)));
|
||||||
AddStep(step_name, &BuildStepSimpleCommand, bs_arg);
|
AddStep(step_name, &BuildStepMsvcCompileCommand, bs_arg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
StringListAppend(&arena, &c_compile_args, StringF(&arena, Lit("-include-pch %F"), FmtStr(pch_c_file.full_path)));
|
StringListAppend(&arena, &c_compile_args, StringF(&arena, Lit("-include-pch %F"), FmtStr(pch_c_file.full_path)));
|
||||||
@ -665,22 +669,18 @@ void OnBuild(StringList cli_args)
|
|||||||
|
|
||||||
/* C */
|
/* C */
|
||||||
if (IsDirty(pch_c_file)) {
|
if (IsDirty(pch_c_file)) {
|
||||||
BuildStepMsvcCompileCommandArg *bs_arg = ArenaPush(&arena, BuildStepMsvcCompileCommandArg);
|
BuildStepSimpleCommandArg *bs_arg = ArenaPush(&arena, BuildStepSimpleCommandArg);
|
||||||
bs_arg->cmd = StringF(&arena, pch_c_compile_args_fmt, FmtStr(pch_header_file.full_path), FmtStr(pch_c_file.full_path));
|
bs_arg->cmd = StringF(&arena, pch_c_compile_args_fmt, FmtStr(pch_header_file.full_path), FmtStr(pch_c_file.full_path));
|
||||||
bs_arg->depfile_dependent = pch_header_file;
|
|
||||||
bs_arg->output_depfile = dep_file;
|
|
||||||
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header_file)), FmtStr(D_GetName(pch_c_file)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header_file)), FmtStr(D_GetName(pch_c_file)));
|
||||||
AddStep(step_name, &BuildStepMsvcCompileCommand, bs_arg);
|
AddStep(step_name, &BuildStepSimpleCommand, bs_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cpp */
|
/* Cpp */
|
||||||
if (IsDirty(pch_cpp_file)) {
|
if (IsDirty(pch_cpp_file)) {
|
||||||
BuildStepMsvcCompileCommandArg *bs_arg = ArenaPush(&arena, BuildStepMsvcCompileCommandArg);
|
BuildStepSimpleCommandArg *bs_arg = ArenaPush(&arena, BuildStepSimpleCommandArg);
|
||||||
bs_arg->cmd = StringF(&arena, pch_cpp_compile_args_fmt, FmtStr(pch_header_file.full_path), FmtStr(pch_cpp_file.full_path));
|
bs_arg->cmd = StringF(&arena, pch_cpp_compile_args_fmt, FmtStr(pch_header_file.full_path), FmtStr(pch_cpp_file.full_path));
|
||||||
bs_arg->depfile_dependent = pch_header_file;
|
|
||||||
bs_arg->output_depfile = dep_file;
|
|
||||||
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header_file)), FmtStr(D_GetName(pch_cpp_file)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header_file)), FmtStr(D_GetName(pch_cpp_file)));
|
||||||
AddStep(step_name, &BuildStepMsvcCompileCommand, bs_arg);
|
AddStep(step_name, &BuildStepSimpleCommand, bs_arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
res/graphics/tim.ase
(Stored with Git LFS)
BIN
res/graphics/tim.ase
(Stored with Git LFS)
Binary file not shown.
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
/* How many ticks back in time should the user blend between?
|
/* How many ticks back in time should the user blend between?
|
||||||
* <Delay ms> = <USER_INTERP_OFFSET_TICK_RATIO> * <Game tick rate>
|
* <Delay ms> = <USER_INTERP_OFFSET_TICK_RATIO> * <Game tick rate>
|
||||||
* E.g: At 1.5, the user thread will render 49.5ms back in time (if game thread runs at 30FPS)
|
* E.g: At 1.5, the user thread will render 75ms back in time (if game thread runs at 50FPS)
|
||||||
*/
|
*/
|
||||||
#define USER_INTERP_OFFSET_TICK_RATIO 1.1
|
#define USER_INTERP_OFFSET_TICK_RATIO 1.1
|
||||||
#define USER_INTERP_ENABLED 1
|
#define USER_INTERP_ENABLED 1
|
||||||
|
|||||||
21
src/game.c
21
src/game.c
@ -196,6 +196,9 @@ INTERNAL void game_update(void)
|
|||||||
e->valid = true;
|
e->valid = true;
|
||||||
e->rel_xform = XFORM_TRS(.t = pos, .r = r, .s = size);
|
e->rel_xform = XFORM_TRS(.t = pos, .r = r, .s = size);
|
||||||
|
|
||||||
|
e->sprite = sprite_tag_from_path(STR("res/graphics/tim.ase"));;
|
||||||
|
e->sprite_span_name = STR("idle.unarmed");
|
||||||
|
|
||||||
struct v2 sprite_pos = V2(0, 0);
|
struct v2 sprite_pos = V2(0, 0);
|
||||||
f32 sprite_rot = 0;
|
f32 sprite_rot = 0;
|
||||||
struct v2 sprite_size = V2(0.5f, 0.5f);
|
struct v2 sprite_size = V2(0.5f, 0.5f);
|
||||||
@ -213,9 +216,6 @@ INTERNAL void game_update(void)
|
|||||||
sprite_xf = xform_translate(sprite_xf, v2_neg(sprite_pivot));
|
sprite_xf = xform_translate(sprite_xf, v2_neg(sprite_pivot));
|
||||||
sprite_xf = xform_scale(sprite_xf, sprite_size);
|
sprite_xf = xform_scale(sprite_xf, sprite_size);
|
||||||
e->sprite_quad_xform = sprite_xf;
|
e->sprite_quad_xform = sprite_xf;
|
||||||
|
|
||||||
e->sprite = sprite_tag_from_path(STR("res/graphics/tim.ase"));;
|
|
||||||
e->sprite_span_name = STR("UNARMED");
|
|
||||||
e->sprite_tint = COLOR_WHITE;
|
e->sprite_tint = COLOR_WHITE;
|
||||||
|
|
||||||
entity_enable_prop(e, ENTITY_PROP_PLAYER_CONTROLLED);
|
entity_enable_prop(e, ENTITY_PROP_PLAYER_CONTROLLED);
|
||||||
@ -265,6 +265,9 @@ INTERNAL void game_update(void)
|
|||||||
/* Movement */
|
/* Movement */
|
||||||
case GAME_CMD_KIND_PLAYER_MOVE: {
|
case GAME_CMD_KIND_PLAYER_MOVE: {
|
||||||
G.world.player_move_dir = cmd.move_dir;
|
G.world.player_move_dir = cmd.move_dir;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case GAME_CMD_KIND_PLAYER_AIM: {
|
||||||
G.world.player_aim = cmd.aim;
|
G.world.player_aim = cmd.aim;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -439,17 +442,6 @@ INTERNAL void game_update(void)
|
|||||||
struct entity *follow = entity_from_handle(&G.world.entity_store, ent->camera_follow);
|
struct entity *follow = entity_from_handle(&G.world.entity_store, ent->camera_follow);
|
||||||
|
|
||||||
if (entity_has_prop(follow, ENTITY_PROP_PLAYER_CONTROLLED)) {
|
if (entity_has_prop(follow, ENTITY_PROP_PLAYER_CONTROLLED)) {
|
||||||
#if 0
|
|
||||||
/* Regular style camera */
|
|
||||||
f32 target_dist_x = 0.5;
|
|
||||||
//f32 target_dist_y = target_dist_x * (16.0f / 9.0f);
|
|
||||||
f32 target_dist_y = target_dist_x;
|
|
||||||
struct v2 target_dir = v2_mul_v2(v2_norm(follow->player_aim), V2(target_dist_x, target_dist_y));
|
|
||||||
struct v2 target_pos = v2_add(ent->camera_rel_xform_target.og, target_dir);
|
|
||||||
ent->camera_rel_xform_target = ent->rel_xform;
|
|
||||||
ent->camera_rel_xform_target.og = target_pos;
|
|
||||||
#else
|
|
||||||
/* "Look" style camera */
|
|
||||||
f32 aspect_ratio = 1.0;
|
f32 aspect_ratio = 1.0;
|
||||||
{
|
{
|
||||||
struct xform quad_xf = xform_mul(ent->world_xform, ent->camera_quad_xform);
|
struct xform quad_xf = xform_mul(ent->world_xform, ent->camera_quad_xform);
|
||||||
@ -464,7 +456,6 @@ INTERNAL void game_update(void)
|
|||||||
struct v2 camera_focus_pos = v2_add(follow->world_xform.og, camera_focus_dir);
|
struct v2 camera_focus_pos = v2_add(follow->world_xform.og, camera_focus_dir);
|
||||||
ent->camera_rel_xform_target = ent->rel_xform;
|
ent->camera_rel_xform_target = ent->rel_xform;
|
||||||
ent->camera_rel_xform_target.og = camera_focus_pos;
|
ent->camera_rel_xform_target.og = camera_focus_pos;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lerp camera */
|
/* Lerp camera */
|
||||||
|
|||||||
@ -10,6 +10,7 @@ enum game_cmd_kind {
|
|||||||
GAME_CMD_KIND_NONE,
|
GAME_CMD_KIND_NONE,
|
||||||
|
|
||||||
GAME_CMD_KIND_PLAYER_MOVE,
|
GAME_CMD_KIND_PLAYER_MOVE,
|
||||||
|
GAME_CMD_KIND_PLAYER_AIM,
|
||||||
|
|
||||||
/* Testing */
|
/* Testing */
|
||||||
GAME_CMD_KIND_CLEAR_ALL,
|
GAME_CMD_KIND_CLEAR_ALL,
|
||||||
@ -22,6 +23,8 @@ struct game_cmd {
|
|||||||
|
|
||||||
/* GAME_CMD_KIND_PLAYER_MOVE */
|
/* GAME_CMD_KIND_PLAYER_MOVE */
|
||||||
struct v2 move_dir;
|
struct v2 move_dir;
|
||||||
|
|
||||||
|
/* GAME_CMD_KIND_PLAYER_AIM */
|
||||||
struct v2 aim;
|
struct v2 aim;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
23
src/sprite.c
23
src/sprite.c
@ -801,23 +801,13 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sprite_evictor_thread_entry_point, arg)
|
|||||||
{
|
{
|
||||||
(UNUSED)arg;
|
(UNUSED)arg;
|
||||||
|
|
||||||
b32 abort = false;
|
sys_mutex_lock(&G.evictor_mutex);
|
||||||
while (!abort) {
|
{
|
||||||
|
while (!G.evictor_shutdown) {
|
||||||
struct temp_arena scratch = scratch_begin_no_conflict();
|
struct temp_arena scratch = scratch_begin_no_conflict();
|
||||||
struct evict_node *head_consider = NULL;
|
struct evict_node *head_consider = NULL;
|
||||||
struct evict_node *head_consider_lru = NULL;
|
struct evict_node *head_consider_lru = NULL;
|
||||||
struct evict_node *head_evicted = NULL;
|
struct evict_node *head_evicted = NULL;
|
||||||
|
|
||||||
sys_mutex_lock(&G.evictor_mutex);
|
|
||||||
{
|
|
||||||
/* Thread shutdown */
|
|
||||||
if (G.evictor_shutdown) {
|
|
||||||
abort = true;
|
|
||||||
} else {
|
|
||||||
/* Wait */
|
|
||||||
sys_condition_variable_wait_time(&G.evictor_cv, &G.evictor_mutex, EVICTOR_CYCLE_INTERVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!G.evictor_shutdown) {
|
if (!G.evictor_shutdown) {
|
||||||
u32 cur_cycle = *atomic_u32_raw(&G.evictor_cycle);
|
u32 cur_cycle = *atomic_u32_raw(&G.evictor_cycle);
|
||||||
|
|
||||||
@ -981,8 +971,11 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sprite_evictor_thread_entry_point, arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
atomic_u32_inc_eval(&G.evictor_cycle);
|
atomic_u32_inc_eval(&G.evictor_cycle);
|
||||||
|
scratch_end(scratch);
|
||||||
|
|
||||||
|
/* Wait */
|
||||||
|
sys_condition_variable_wait_time(&G.evictor_cv, &G.evictor_mutex, EVICTOR_CYCLE_INTERVAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sys_mutex_unlock(&G.evictor_mutex);
|
sys_mutex_unlock(&G.evictor_mutex);
|
||||||
scratch_end(scratch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -393,7 +393,7 @@ struct sys_condition_variable sys_condition_variable_alloc(void);
|
|||||||
void sys_condition_variable_release(struct sys_condition_variable *cv);
|
void sys_condition_variable_release(struct sys_condition_variable *cv);
|
||||||
void sys_condition_variable_wait(struct sys_condition_variable *cv, struct sys_mutex *mutex);
|
void sys_condition_variable_wait(struct sys_condition_variable *cv, struct sys_mutex *mutex);
|
||||||
void sys_condition_variable_wait_time(struct sys_condition_variable *cv, struct sys_mutex *mutex, f64 seconds);
|
void sys_condition_variable_wait_time(struct sys_condition_variable *cv, struct sys_mutex *mutex, f64 seconds);
|
||||||
void sys_condition_variable_signal(struct sys_condition_variable *cv);
|
void sys_condition_variable_signal(struct sys_condition_variable *cv, u32 count);
|
||||||
void sys_condition_variable_broadcast(struct sys_condition_variable *cv);
|
void sys_condition_variable_broadcast(struct sys_condition_variable *cv);
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
|
|||||||
@ -1542,11 +1542,20 @@ void sys_condition_variable_wait_time(struct sys_condition_variable *cv, struct
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_condition_variable_signal(struct sys_condition_variable *cv)
|
void sys_condition_variable_signal(struct sys_condition_variable *cv, u32 count)
|
||||||
{
|
{
|
||||||
__prof;
|
__prof;
|
||||||
struct win32_condition_variable *w32cv = (struct win32_condition_variable *)cv->handle;
|
struct win32_condition_variable *w32cv = (struct win32_condition_variable *)cv->handle;
|
||||||
|
/* Windows will wake all waiters if many single-wakes occur anyway, so we
|
||||||
|
* might as well wake all ourselves.
|
||||||
|
* https://devblogs.microsoft.com/oldnewthing/20180201-00/?p=97946 */
|
||||||
|
if (count <= 24) {
|
||||||
|
for (u32 i = 0; i < count; ++i) {
|
||||||
WakeConditionVariable(&w32cv->condition_variable);
|
WakeConditionVariable(&w32cv->condition_variable);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WakeAllConditionVariable(&w32cv->condition_variable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_condition_variable_broadcast(struct sys_condition_variable *cv)
|
void sys_condition_variable_broadcast(struct sys_condition_variable *cv)
|
||||||
|
|||||||
46
src/user.c
46
src/user.c
@ -761,8 +761,6 @@ INTERNAL void user_update(void)
|
|||||||
if (!sprite_tag_is_nil(ent->sprite)) {
|
if (!sprite_tag_is_nil(ent->sprite)) {
|
||||||
/* Draw texture */
|
/* Draw texture */
|
||||||
struct sprite_tag sprite = ent->sprite;
|
struct sprite_tag sprite = ent->sprite;
|
||||||
/* TODO: Remove this once renderer is rewritten to work with tags */
|
|
||||||
struct sprite_texture *texture = sprite_texture_from_tag_async(sprite_frame_scope, sprite);
|
|
||||||
|
|
||||||
struct xform xf = xform_mul(ent->world_xform, ent->sprite_quad_xform);
|
struct xform xf = xform_mul(ent->world_xform, ent->sprite_quad_xform);
|
||||||
struct quad quad = quad_mul_xform(QUAD_UNIT_SQUARE_CENTERED, xf);
|
struct quad quad = quad_mul_xform(QUAD_UNIT_SQUARE_CENTERED, xf);
|
||||||
@ -791,33 +789,11 @@ INTERNAL void user_update(void)
|
|||||||
|
|
||||||
struct draw_sprite_params params = DRAW_SPRITE_PARAMS(.sprite = sprite, .tint = tint, .clip = frame.clip);
|
struct draw_sprite_params params = DRAW_SPRITE_PARAMS(.sprite = sprite, .tint = tint, .clip = frame.clip);
|
||||||
|
|
||||||
/* TODO: Check for texture loading as well */
|
|
||||||
if (sheet->loaded && texture->loaded) {
|
|
||||||
/* TODO: Fade in a placeholder or something instead of drawing nothing. */
|
/* TODO: Fade in a placeholder or something instead of drawing nothing. */
|
||||||
|
struct sprite_texture *texture = sprite_texture_from_tag_async(sprite_frame_scope, sprite);
|
||||||
|
if (sheet->loaded && texture->loaded) {
|
||||||
draw_sprite_quad(G.world_canvas, params, quad);
|
draw_sprite_quad(G.world_canvas, params, quad);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (G.debug_draw && !skip_debug_draw) {
|
|
||||||
/* Debug draw sprite quad */
|
|
||||||
{
|
|
||||||
f32 thickness = 2.f;
|
|
||||||
u32 color = RGBA_32_F(1, 1, 0, 0.25);
|
|
||||||
draw_solid_quad_line(G.world_canvas, quad, (thickness / PIXELS_PER_UNIT / G.world_view.zoom), color);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Debug draw sprite transform */
|
|
||||||
{
|
|
||||||
debug_draw_xform(xf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Debug draw sprite pivot */
|
|
||||||
{
|
|
||||||
u32 color = RGBA_32_F(1, 0, 0, 1);
|
|
||||||
draw_solid_circle(G.world_canvas, ent->world_xform.og, 0.02, color, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Debug draw info */
|
/* Debug draw info */
|
||||||
@ -970,19 +946,21 @@ INTERNAL void user_update(void)
|
|||||||
input_move_dir = v2_norm(input_move_dir);
|
input_move_dir = v2_norm(input_move_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Aim */
|
/* Queue move cmd */
|
||||||
struct v2 input_aim = player->player_aim;
|
|
||||||
if (!G.debug_camera) {
|
|
||||||
input_aim = v2_sub(G.world_cursor, player->world_xform.og);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Queue cmd */
|
|
||||||
queue_game_cmd(&cmd_list, (struct game_cmd) {
|
queue_game_cmd(&cmd_list, (struct game_cmd) {
|
||||||
.kind = GAME_CMD_KIND_PLAYER_MOVE,
|
.kind = GAME_CMD_KIND_PLAYER_MOVE,
|
||||||
.move_dir = input_move_dir,
|
.move_dir = input_move_dir,
|
||||||
.aim = input_aim
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Queue aim cmd */
|
||||||
|
if (!G.debug_camera) {
|
||||||
|
struct v2 input_aim = v2_sub(G.world_cursor, player->world_xform.og);
|
||||||
|
queue_game_cmd(&cmd_list, (struct game_cmd) {
|
||||||
|
.kind = GAME_CMD_KIND_PLAYER_AIM,
|
||||||
|
.aim = input_aim,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|||||||
11
src/util.h
11
src/util.h
@ -129,7 +129,7 @@ struct sync_flag {
|
|||||||
/* TODO: Make this a rw mutex? */
|
/* TODO: Make this a rw mutex? */
|
||||||
struct sys_mutex mutex;
|
struct sys_mutex mutex;
|
||||||
struct sys_condition_variable cv;
|
struct sys_condition_variable cv;
|
||||||
struct atomic_i32 flag;
|
b32 flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
INLINE struct sync_flag sync_flag_alloc(void)
|
INLINE struct sync_flag sync_flag_alloc(void)
|
||||||
@ -149,21 +149,24 @@ INLINE void sync_flag_release(struct sync_flag *sf)
|
|||||||
INLINE void sync_flag_set(struct sync_flag *sf)
|
INLINE void sync_flag_set(struct sync_flag *sf)
|
||||||
{
|
{
|
||||||
__prof;
|
__prof;
|
||||||
if (atomic_i32_eval_compare_exchange(&sf->flag, 0, 1) == 0) {
|
sys_mutex_lock(&sf->mutex);
|
||||||
|
{
|
||||||
|
sf->flag = 1;
|
||||||
sys_condition_variable_broadcast(&sf->cv);
|
sys_condition_variable_broadcast(&sf->cv);
|
||||||
}
|
}
|
||||||
|
sys_mutex_unlock(&sf->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void sync_flag_wait(struct sync_flag *sf)
|
INLINE void sync_flag_wait(struct sync_flag *sf)
|
||||||
{
|
{
|
||||||
__prof;
|
__prof;
|
||||||
while (atomic_i32_eval(&sf->flag) == 0) {
|
|
||||||
sys_mutex_lock(&sf->mutex);
|
sys_mutex_lock(&sf->mutex);
|
||||||
{
|
{
|
||||||
|
while (sf->flag == 0) {
|
||||||
sys_condition_variable_wait(&sf->cv, &sf->mutex);
|
sys_condition_variable_wait(&sf->cv, &sf->mutex);
|
||||||
}
|
}
|
||||||
sys_mutex_unlock(&sf->mutex);
|
|
||||||
}
|
}
|
||||||
|
sys_mutex_unlock(&sf->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
|
|||||||
@ -272,10 +272,7 @@ INTERNAL void work_schedule_assume_locked(struct work *work)
|
|||||||
|
|
||||||
G.scheduled_work_priority_tails[priority] = work;
|
G.scheduled_work_priority_tails[priority] = work;
|
||||||
|
|
||||||
WRITE_BARRIER();
|
sys_condition_variable_signal(&G.cv, work->tasks_incomplete);
|
||||||
for (u64 i = 0; i < work->tasks_incomplete; ++i) {
|
|
||||||
sys_condition_variable_signal(&G.cv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INTERNAL void work_unschedule_assume_locked(struct work *work)
|
INTERNAL void work_unschedule_assume_locked(struct work *work)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user