ogl_beamforming

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

Commit: 43521d3122065b555f4398d30a1c73d82fad7485
Parent: d869fa9a2ae8f730205133bda65ae2ce8261e21f
Author: Randy Palamar
Date:   Sat, 21 Jun 2025 20:31:39 -0600

core: swap order of compute stats table

The first visualization I want to use for the stats wants the
order to be like this. Some visualization would prefer the other
order but if those are added they will just need to do a seperate
extraction step.

Diffstat:
Mbeamformer.c | 15+++++++--------
Mbeamformer.h | 4+++-
2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/beamformer.c b/beamformer.c @@ -695,7 +695,7 @@ coalesce_timing_table(ComputeTimingTable *t, ComputeShaderStats *stats) * info item. this could result in garbage entries but they shouldn't really matter */ u32 target = atomic_load_u32(&t->write_index); - u32 stats_index = (stats->latest_frame_index + 1) % countof(stats->times[0]); + u32 stats_index = (stats->latest_frame_index + 1) % countof(stats->times); static_assert(ShaderKind_Count + 1 <= 32, "timing coalescence bitfield test"); u32 seen_info_test = 0; @@ -707,17 +707,16 @@ coalesce_timing_table(ComputeTimingTable *t, ComputeShaderStats *stats) assert(t->compute_frame_active == 0); t->compute_frame_active = 1; /* NOTE(rnp): allow multiple instances of same shader to accumulate */ - for EachEnumValue(ShaderKind, shader) - stats->times[shader][stats_index] = 0; + mem_clear(stats->times[stats_index], 0, sizeof(stats->times[stats_index])); }break; case ComputeTimingInfoKind_ComputeFrameEnd:{ assert(t->compute_frame_active == 1); t->compute_frame_active = 0; stats->latest_frame_index = stats_index; - stats_index = (stats_index + 1) % countof(stats->times[0]); + stats_index = (stats_index + 1) % countof(stats->times); }break; case ComputeTimingInfoKind_Shader:{ - stats->times[info.shader][stats_index] += (f32)info.timer_count / 1.0e9; + stats->times[stats_index][info.shader] += (f32)info.timer_count / 1.0e9; seen_info_test |= (1 << info.shader); }break; case ComputeTimingInfoKind_RF_Data:{ @@ -734,9 +733,9 @@ coalesce_timing_table(ComputeTimingTable *t, ComputeShaderStats *stats) for EachEnumValue(ShaderKind, shader) { if (seen_info_test & (1 << shader)) { f32 sum = 0; - for EachElement(stats->times[shader], i) - sum += stats->times[shader][i]; - stats->average_times[shader] = sum / countof(stats->times[shader]); + for EachElement(stats->times, i) + sum += stats->times[i][shader]; + stats->average_times[shader] = sum / countof(stats->times); } } diff --git a/beamformer.h b/beamformer.h @@ -119,7 +119,9 @@ typedef enum { } ShaderKind; typedef struct { - f32 times[ShaderKind_Count][32]; + /* 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][ShaderKind_Count]; f32 average_times[ShaderKind_Count]; u64 last_rf_timer_count;