Commit: 25eaa2baec4e1090349f5da57bdf2968411b6859
Parent: 360ffed25c216cc3beab6ddc67a25782bf8140e8
Author: Randy Palamar
Date: Tue, 30 Dec 2025 17:07:41 -0700
core: move program memory into BeamformerInput
Diffstat:
5 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/beamformer.c b/beamformer.c
@@ -1472,7 +1472,7 @@ DEBUG_EXPORT BEAMFORMER_RF_UPLOAD_FN(beamformer_rf_upload)
DEBUG_EXPORT BEAMFORMER_FRAME_STEP_FN(beamformer_frame_step)
{
- BeamformerCtx *ctx = BeamformerContextMemory(memory);
+ BeamformerCtx *ctx = BeamformerContextMemory(input->memory);
dt_for_frame = input->dt;
if (IsWindowResized()) {
diff --git a/beamformer.h b/beamformer.h
@@ -26,10 +26,11 @@ function OS_WRITE_FILE_FN(os_write_file);
#include "util_gl.c"
typedef struct {
- f64 dt;
- v2 mouse;
- v2 last_mouse;
- b32 executable_reloaded;
+ Arena memory;
+ f64 dt;
+ v2 mouse;
+ v2 last_mouse;
+ b32 executable_reloaded;
} BeamformerInput;
#define CUDA_INIT_FN(name) void name(u32 *input_dims, u32 *decoded_dims)
@@ -337,7 +338,7 @@ struct ShaderReloadContext {
i32 reloadable_info_index;
};
-#define BEAMFORMER_FRAME_STEP_FN(name) void name(Arena memory, BeamformerInput *input)
+#define BEAMFORMER_FRAME_STEP_FN(name) void name(BeamformerInput *input)
typedef BEAMFORMER_FRAME_STEP_FN(beamformer_frame_step_fn);
#define BEAMFORMER_COMPLETE_COMPUTE_FN(name) void name(iptr user_context, Arena *arena, iptr gl_context)
diff --git a/main_linux.c b/main_linux.c
@@ -81,9 +81,10 @@ main(void)
os_linux_context.inotify_handle = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
- BeamformerInput *input = push_struct(&program_memory, BeamformerInput);
+ BeamformerInput *input = push_struct(&program_memory, BeamformerInput);
+ input->memory = program_memory;
input->executable_reloaded = 1;
- beamformer_init(program_memory, input);
+ beamformer_init(input);
struct pollfd fds[1] = {{0}};
fds[0].fd = os_linux_context.inotify_handle;
@@ -102,7 +103,7 @@ main(void)
input->dt = (f64)(now - last_time) / (f64)os_get_timer_frequency();
last_time = now;
- beamformer_frame_step(program_memory, input);
+ beamformer_frame_step(input);
input->executable_reloaded = 0;
}
diff --git a/main_w32.c b/main_w32.c
@@ -120,9 +120,10 @@ main(void)
os_w32_context.error_handle = GetStdHandle(STD_ERROR_HANDLE);
os_w32_context.io_completion_handle = CreateIoCompletionPort(INVALID_FILE, 0, 0, 0);
- BeamformerInput *input = push_struct(&program_memory, BeamformerInput);
+ BeamformerInput *input = push_struct(&program_memory, BeamformerInput);
+ input->memory = program_memory;
input->executable_reloaded = 1;
- beamformer_init(program_memory, input);
+ beamformer_init(input);
u64 last_time = os_get_timer_counter();
while (!WindowShouldClose()) {
@@ -139,7 +140,7 @@ main(void)
input->dt = (f64)(now - last_time) / (f64)os_w32_context.timer_frequency;
last_time = now;
- beamformer_frame_step(program_memory, input);
+ beamformer_frame_step(input);
input->executable_reloaded = 0;
}
diff --git a/static.c b/static.c
@@ -329,8 +329,9 @@ function OS_THREAD_ENTRY_POINT_FN(beamformer_upload_entry_point)
}
function void
-beamformer_init(Arena memory, BeamformerInput *input)
+beamformer_init(BeamformerInput *input)
{
+ Arena memory = input->memory;
Arena compute_arena = sub_arena_end(&memory, MB(2), KB(4));
Arena upload_arena = sub_arena_end(&memory, KB(4), KB(4));
Arena ui_arena = sub_arena_end(&memory, MB(2), KB(4));