WIP: Untested more process runtime bootstrapping, some decisions on how grime is setup..

This commit is contained in:
2025-10-13 12:47:16 -04:00
parent 4abd2401f0
commit 0d904fba7c
15 changed files with 257 additions and 203 deletions

View File

@@ -1,14 +1,18 @@
package sectr
import "core:dynlib"
import "core:sync"
// Sokol should only be used here and in the client_api_sokol_callbacks.odin
Path_Assets :: "../assets/"
Path_Shaders :: "../shaders/"
Path_Input_Replay :: "input.sectr_replay"
import sokol_app "thirdparty:sokol/app"
import sokol_gfx "thirdparty:sokol/gfx"
import sokol_glue "thirdparty:sokol/glue"
import sokol_gp "thirdparty:sokol/gp"
/*
This definies the client interface for the host process to call into
*/
ModuleAPI :: struct {
lib: dynlib.Library,
lib: DynLibrary,
write_time: FileTime,
lib_version : int,
@@ -19,8 +23,6 @@ ModuleAPI :: struct {
clean_frame: type_of( clean_frame),
}
StartupContext :: struct {}
/*
Called by host.main when it completes its setup.
@@ -34,44 +36,63 @@ startup :: proc(host_mem: ^ProcessMemory, thread_mem: ^ThreadMemory)
}
/*
Called by sync_client_api when the client module has be reloaded.
Called by host.sync_client_api when the client module has be reloaded.
Threads will eventually return to their tick_lane upon completion.
*/
@export
hot_reload :: proc(host_mem: ^ProcessMemory, thread_mem: ^ThreadMemory)
{
thread_ctx = thread_mem
if thread_ctx.id == .Master_Prepper {
cache_coherent_store(& memory, host_mem, .Release)
thread = thread_mem
if thread.id == .Master_Prepper {
sync_store(& memory, host_mem, .Release)
}
}
/*
Called by host_tick_lane_startup
Used for lane specific startup operations
The lane tick cannot be handled it, its call must be done by the host module.
(We need threads to not be within a client callstack in the even of a hot-reload)
Called by host_tick_lane_startup
Used for lane specific startup operations
The lane tick cannot be handled it, its call must be done by the host module.
(We need threads to not be within a client callstack in the even of a hot-reload)
*/
@export
tick_lane_startup :: proc(thread_mem: ^ThreadMemory)
{
thread_ctx = thread_mem
thread_ctx.live_lanes = THREAD_TICK_LANES
thread = thread_mem
thread.live_lanes = THREAD_TICK_LANES
}
/*
*/
@export
tick_lane :: proc(host_delta_time_ms: f64, host_delta_ns: Duration) -> (should_close: b64)
{
@thread_local dummy: int = 0;
dummy += 2
profile_begin("sokol_app: pre_client_tick")
// should_close |= cast(b64) sokol_app.pre_client_frame()
profile_end()
profile_begin("Client Tick")
profile_end()
profile_begin("sokol_app: post_client_tick")
profile_end()
tick_lane_frametime()
return true
}
tick_lane_frametime :: proc()
{
}
@export
clean_frame :: proc()
{
@thread_local dummy: int = 0;
dummy += 1
if thread.id == .Master_Prepper
{
}
return
}

View File

@@ -5,6 +5,12 @@ import "core:sync"
/*
Everything defined for the host module within the client module
so that the client module has full awareness of relevant host definitions
Client interaction with host is very minimal,
host will only provide the base runtime for client's tick lanes and job system workers.
Host is has all statically (data/bss) defined memory for the application, it will not mess with
client_memory however.
*/
ProcessMemory :: struct {
@@ -19,8 +25,7 @@ ProcessMemory :: struct {
logger: Logger,
// Profiling
spall_profiler: SpallProfiler,
// TODO(Ed): Try Superluminal!
spall_profiler: ^SpallProfiler,
// Multi-threading
threads: [MAX_THREADS](SysThread),
@@ -34,12 +39,8 @@ ProcessMemory :: struct {
}
Host_API :: struct {
launch_tick_lane_thread: #type proc(WorkerID),
request_virtual_memory: #type proc(),
request_virtual_mapped_io: #type proc(),
sync_client_module : #type proc(),
}
ThreadMemory :: struct {