ogl_beamforming

Ultrasound Beamforming Implemented with OpenGL
git clone anongit@rnpnr.xyz:ogl_beamforming.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

Commit: 69849c81bd11647ce32269a181873d06d2647ed4
Parent: 0444e0c6c0c6ea258c44621d2bbe31f2e4ba91a3
Author: Randy Palamar
Date:   Wed, 22 Jul 2026 06:25:05 -0700

lib: remove compute stat export from public interface

I'm the only one who uses this currently and I need to change the
format again. If it gets added again to the library it will be in
a format better suited for export and which doesn't require access
to internal shader ids, etc.

Diffstat:
Abeamformer_compute_stats.c | 10++++++++++
Mbeamformer_core.c | 7++++++-
Mbeamformer_internal.h | 2+-
Dbeamformer_parameters.h | 18------------------
Mbuild.c | 9++++-----
Mlib/ogl_beamformer_lib.c | 4++--
Mlib/ogl_beamformer_lib_base.h | 4----
7 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/beamformer_compute_stats.c b/beamformer_compute_stats.c @@ -0,0 +1,10 @@ +/* See LICENSE for license details. */ + +typedef struct { + u64 shader_count; + u32 shader_ids[BeamformerMaxComputeShaderStages]; + /* NOTE(rnp): this wants to be iterated on both dimensions. it depends entirely on which + * visualization method you want to use. the coalescing function wants both directions */ + f32 times[32][BeamformerMaxComputeShaderStages]; + f32 rf_time_deltas[32]; +} BeamformerComputeStatsTable; diff --git a/beamformer_core.c b/beamformer_core.c @@ -1,7 +1,12 @@ /* See LICENSE for license details. */ /* TODO(rnp): * [ ]: backtrace dumping on SIGSEGV - * [ ]: bug? HERCULES might be broken, we may need to to chunk on transmits instead of channels + * [ ]: cooperative shared memory loading in decode shader + * [ ]: upload previously exported data for display. maybe this is a UI thing but doing it + * programatically would be nice. + * [ ]: Add interface for multi frame upload. RF upload already uses an offset into SM so + * that part works fine. We just need a way of specify a multi frame upload. (Data must + * be organized for simple offset access per frame). * [ ]: refactor: do_compute should build its own "command graph" which tracks * dependencies better. It is very important that unnecessary barriers are * not placed between compute stages which requires knowledge of the entire diff --git a/beamformer_internal.h b/beamformer_internal.h @@ -251,7 +251,7 @@ CUDALibraryProcedureList ///////////////////////////////////// // NOTE: Core Beamformer Definitions -#include "beamformer_parameters.h" +#include "beamformer_compute_stats.c" #include "beamformer_shared_memory.c" typedef struct { diff --git a/beamformer_parameters.h b/beamformer_parameters.h @@ -1,18 +0,0 @@ -/* See LICENSE for license details. */ - -/* TODO(rnp): - * [ ]: Upload previously exported data for display. maybe this is a UI thing but doing it - * programatically would be nice. - * [ ]: Add interface for multi frame upload. RF upload already uses an offset into SM so - * that part works fine. We just need a way of specify a multi frame upload. (Data must - * be organized for simple offset access per frame). - */ - -typedef struct { - uint64_t shader_count; - uint32_t shader_ids[BeamformerMaxComputeShaderStages]; - /* NOTE(rnp): this wants to be iterated on both dimensions. it depends entirely on which - * visualization method you want to use. the coalescing function wants both directions */ - float times[32][BeamformerMaxComputeShaderStages]; - float rf_time_deltas[32]; -} BeamformerComputeStatsTable; diff --git a/build.c b/build.c @@ -4308,7 +4308,7 @@ function b32 metagen_emit_matlab_code(MetaContext *ctx, Arena arena) { b32 result = 1; - if (!needs_rebuild(OUTPUT("matlab/OGLBeamformerShaderStage.m"), "beamformer_parameters.h", "beamformer.meta")) + if (!needs_rebuild(OUTPUT("matlab/OGLBeamformerShaderStage.m"), "beamformer.meta")) return result; build_log_generate("MATLAB Bindings"); @@ -4546,8 +4546,7 @@ metagen_emit_helper_library_header(MetaContext *ctx, Arena arena) build_log_generate("Library Header"); - s8 parameters_header = read_entire_file("beamformer_parameters.h", &arena); - s8 base_header = read_entire_file("lib/ogl_beamformer_lib_base.h", &arena); + s8 base_header = read_entire_file("lib/ogl_beamformer_lib_base.h", &arena); MetaprogramContext m[1] = {{.stream = arena_stream(arena), .scratch = ctx->scratch}}; @@ -4591,7 +4590,7 @@ metagen_emit_helper_library_header(MetaContext *ctx, Arena arena) meta_push_line(m, s8("// END GENERATED CODE\n")); - meta_push(m, parameters_header, base_header); + meta_push(m, base_header); result &= meta_write_and_reset(m, out); // NOTE(rnp): matlab compatible header @@ -4633,7 +4632,7 @@ metagen_emit_helper_library_header(MetaContext *ctx, Arena arena) meta_push_line(m, s8("// END GENERATED CODE\n")); - meta_push(m, parameters_header, base_header); + meta_push(m, base_header); result &= meta_write_and_reset(m, OUTPUT("ogl_beamformer_lib_matlab.h")); } diff --git a/lib/ogl_beamformer_lib.c b/lib/ogl_beamformer_lib.c @@ -8,7 +8,6 @@ #include "../util.h" #include "../generated/beamformer.meta.c" -#include "../beamformer_parameters.h" #include "ogl_beamformer_lib_base.h" #if OS_LINUX @@ -23,6 +22,7 @@ W32(iptr) OpenFileMappingA(u32, b32, c8 *); #endif #include "../util_os.c" +#include "../beamformer_compute_stats.c" #include "../beamformer_shared_memory.c" global struct { @@ -726,7 +726,7 @@ beamformer_beamform_data(BeamformerSimpleParameters *bp, void *data, uint32_t da return result; } -b32 +BEAMFORMER_LIB_EXPORT b32 beamformer_compute_timings(BeamformerComputeStatsTable *output, i32 timeout_ms) { b32 result = 0; diff --git a/lib/ogl_beamformer_lib_base.h b/lib/ogl_beamformer_lib_base.h @@ -80,10 +80,6 @@ BEAMFORMER_LIB_EXPORT void beamformer_set_global_timeout(uint32_t timeout_ms); /////////////////////////// // NOTE: Advanced API -/* NOTE: downloads the last 32 frames worth of compute timings into output */ -BEAMFORMER_LIB_EXPORT uint32_t beamformer_compute_timings(BeamformerComputeStatsTable *output, - int32_t timeout_ms); - /* NOTE: pushes data and tries to immediately starts a compute */ BEAMFORMER_LIB_EXPORT uint32_t beamformer_push_data_with_compute(void *data, uint32_t size, uint32_t image_plane_tag,