From 3769413a502a60bb550e4e46241d655db002b06c Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 19 Jul 2025 00:07:36 -0400 Subject: [PATCH] messing around with testing using keyword in proc args (with new debug support) --- code/grime/profiler.odin | 40 ++++++++++++++----------------- code/host/host.odin | 3 +++ code/sectr/engine/config.odin | 1 + code/sectr/engine/job_system.odin | 4 ++-- code/sectr/engine/profiler.odin | 3 --- code/sectr/engine/state.odin | 4 ++-- code/sectr/input/events.odin | 4 ++-- scripts/build.ps1 | 4 +++- 8 files changed, 31 insertions(+), 32 deletions(-) create mode 100644 code/sectr/engine/config.odin delete mode 100644 code/sectr/engine/profiler.odin diff --git a/code/grime/profiler.odin b/code/grime/profiler.odin index e576317..8c2444b 100644 --- a/code/grime/profiler.odin +++ b/code/grime/profiler.odin @@ -12,30 +12,26 @@ SpallProfiler :: struct { buffer : spall.Buffer, } -// The rest is a snippet to implement in the target codebase. -when false -{ - @(private) - Module_Context : ^SpallProfiler +@(private) +Module_Context : ^SpallProfiler - set_profiler_module_context :: #force_inline proc "contextless" ( ctx : ^SpallProfiler ) { - Module_Context = ctx - } +set_profiler_module_context :: #force_inline proc "contextless" ( ctx : ^SpallProfiler ) { + Module_Context = ctx +} - DISABLE_PROFILING :: true +DISABLE_PROFILING :: true - @(deferred_none = profile_end, disabled = DISABLE_PROFILING) - profile :: #force_inline proc "contextless" ( name : string, loc := #caller_location ) { - spall._buffer_begin( & Module_Context.ctx, & Module_Context.buffer, name, "", loc ) - } +@(deferred_none = profile_end, disabled = DISABLE_PROFILING) +profile :: #force_inline proc "contextless" ( name : string, loc := #caller_location ) { + spall._buffer_begin( & Module_Context.ctx, & Module_Context.buffer, name, "", loc ) +} - @(disabled = DISABLE_PROFILING) - profile_begin :: #force_inline proc "contextless" ( name : string, loc := #caller_location ) { - spall._buffer_begin( & Module_Context.ctx, & Module_Context.buffer, name, "", loc ) - } +@(disabled = DISABLE_PROFILING) +profile_begin :: #force_inline proc "contextless" ( name : string, loc := #caller_location ) { + spall._buffer_begin( & Module_Context.ctx, & Module_Context.buffer, name, "", loc ) +} - @(disabled = DISABLE_PROFILING) - profile_end :: #force_inline proc "contextless" () { - spall._buffer_end( & Module_Context.ctx, & Module_Context.buffer) - } -} \ No newline at end of file +@(disabled = DISABLE_PROFILING) +profile_end :: #force_inline proc "contextless" () { + spall._buffer_end( & Module_Context.ctx, & Module_Context.buffer) +} diff --git a/code/host/host.odin b/code/host/host.odin index db3dff7..6153a3c 100644 --- a/code/host/host.odin +++ b/code/host/host.odin @@ -114,6 +114,7 @@ RuntimeState :: struct { @thread_local worker_thread: sectr.ThreadWorkerContext +// TODO(Ed): Only persisent needs to be allocated by the host. ClientMemory :: struct { persistent : VArena, frame : VArena, @@ -279,6 +280,8 @@ sync_sectr_api :: proc( sectr_api : ^sectr.ModuleAPI, memory : ^ClientMemory, lo } } +// TODO(Ed): Put data segment memory in a Host_DataSegment struct. + fmt_backing : [16 * Kilobyte] u8 persistent_backing : [32 * Megabyte] byte diff --git a/code/sectr/engine/config.odin b/code/sectr/engine/config.odin new file mode 100644 index 0000000..3876406 --- /dev/null +++ b/code/sectr/engine/config.odin @@ -0,0 +1 @@ +package sectr \ No newline at end of file diff --git a/code/sectr/engine/job_system.odin b/code/sectr/engine/job_system.odin index 8bbc474..55c29f3 100644 --- a/code/sectr/engine/job_system.odin +++ b/code/sectr/engine/job_system.odin @@ -20,10 +20,10 @@ Job :: struct { next: ^Job, cb: JobProc, data: rawptr, + // scratch: ^CArena, group: ^JobGroup, ignored: IgnoredThreads, dbg_lbl: string, - // scratch: CArena, } JobList :: struct { @@ -43,7 +43,7 @@ JobSystemContext :: struct { ThreadWorkerContext :: struct { system_ctx: Thread, index: int, -} +} WorkerID :: enum u32 { Master_Prepper = 0, diff --git a/code/sectr/engine/profiler.odin b/code/sectr/engine/profiler.odin deleted file mode 100644 index 7ba6dc6..0000000 --- a/code/sectr/engine/profiler.odin +++ /dev/null @@ -1,3 +0,0 @@ -package sectr - - diff --git a/code/sectr/engine/state.odin b/code/sectr/engine/state.odin index b0059e9..5add48d 100644 --- a/code/sectr/engine/state.odin +++ b/code/sectr/engine/state.odin @@ -40,7 +40,7 @@ Memory :: struct { state : ^State, - replay : ReplayState, + replay : ReplayState, // TODO(Ed): Were not doing it this way. logger : Logger, profiler : ^SpallProfiler } @@ -182,7 +182,7 @@ State :: struct { transient_clear_time : f32, // Time in seconds for the usual period to clear transient transient_clear_elapsed : f32, // Time since last clear - job_system : JobSystemContext, + job_system : ^JobSystemContext, string_cache : StringCache, diff --git a/code/sectr/input/events.odin b/code/sectr/input/events.odin index 1e2825c..bbb9c22 100644 --- a/code/sectr/input/events.odin +++ b/code/sectr/input/events.odin @@ -69,14 +69,14 @@ append_staged_input_events :: #force_inline proc( event : InputEvent ) { append( & state.staged_input_events, event ) } -pull_staged_input_events :: proc( input : ^InputState, input_events : ^InputEvents, staged_events : Array(InputEvent) ) +pull_staged_input_events :: proc( input : ^InputState, using input_events : ^InputEvents, using staged_events : Array(InputEvent) ) { // TODO(Ed) : Add guards for multi-threading staged_events_slice := array_to_slice(staged_events) push( & input_events.events, staged_events_slice ) - using input_events + // using input_events for event in staged_events_slice { diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 5f0aad3..4c56122 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -225,6 +225,7 @@ push-location $path_root # $build_args += $flag_sanitize_address # $build_args += $flag_sanitize_memory # $build_args += $flag_show_debug_messages + # TODO(Ed): Enforce nil default allocator # foreach ($arg in $build_args) { # write-host `t $arg -ForegroundColor Cyan @@ -287,7 +288,7 @@ push-location $path_root $build_args += ($flag_collection + $pkg_collection_codebase) $build_args += ($flag_collection + $pkg_collection_thirdparty) # $build_args += $flag_micro_architecture_native - $build_args += $flag_use_separate_modules + # $build_args += $flag_use_separate_modules $build_args += $flag_thread_count + $CoreCount_Physical # $build_args += $flag_optimize_none $build_args += $flag_optimize_minimal @@ -305,6 +306,7 @@ push-location $path_root $build_args += ($flag_max_error_count + '10') # $build_args += $flag_sanitize_address # $build_args += $flag_sanitize_memory + # TODO(Ed): Enforce nil default allocator # foreach ($arg in $build_args) { # write-host `t $arg -ForegroundColor Cyan