ogl_beamforming

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

Commit: 64fcfa5c6ac52b400146906fd76c3cf0488251e5
Parent: 4230dc0ccdf5599738e2d8dff4d69ac4c32fa53d
Author: Randy Palamar
Date:   Mon,  2 Nov 2026 17:52:07 -0700

math: ceil_div_u32 -> DivRoundUp

Diffstat:
Mbeamformer_core.c | 28++++++++++++++--------------
Mmath.c | 7-------
2 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/beamformer_core.c b/beamformer_core.c @@ -452,9 +452,9 @@ function uv3 dispatch_for_output(uv3 layout, iv3 points) { uv3 result; - result.x = ceil_div_u32(points.x, layout.x); - result.y = ceil_div_u32(points.y, layout.y); - result.z = ceil_div_u32(points.z, layout.z); + result.x = DivRoundUp(points.x, (u32)layout.x); + result.y = DivRoundUp(points.y, (u32)layout.y); + result.z = DivRoundUp(points.z, (u32)layout.z); return result; } @@ -838,16 +838,16 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A sd->layout.y = 4; sd->layout.z = 1; - sd->dispatch.x = ceil_div_u32(db->TransmitCount / db->ToProcess, sd->layout.x); - sd->dispatch.y = ceil_div_u32(db->ChunkChannelCount, sd->layout.y); - sd->dispatch.z = ceil_div_u32(decode_sample_count, sd->layout.z); + sd->dispatch.x = DivRoundUp(db->TransmitCount / db->ToProcess, sd->layout.x); + sd->dispatch.y = DivRoundUp(db->ChunkChannelCount, sd->layout.y); + sd->dispatch.z = DivRoundUp(decode_sample_count, sd->layout.z); } else { /* NOTE(rnp): register caching. using more threads will cause the compiler to do * contortions to avoid spilling registers. using less gives higher performance */ sd->layout = (uv3){{subgroup_size / 2, 1, 1}}; - sd->dispatch.x = ceil_div_u32(decode_sample_count, sd->layout.x); - sd->dispatch.y = ceil_div_u32(db->ChunkChannelCount, sd->layout.y); + sd->dispatch.x = DivRoundUp(decode_sample_count, sd->layout.x); + sd->dispatch.y = DivRoundUp(db->ChunkChannelCount, sd->layout.y); sd->dispatch.z = 1; } @@ -908,9 +908,9 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A } sd->layout = (uv3){{subgroup_size, 1, 1}}; - sd->dispatch.x = ceil_div_u32(node->rf_dimensions.E[BeamformerRFDimension_Samples], sd->layout.x); - sd->dispatch.y = ceil_div_u32(node->rf_dimensions.E[BeamformerRFDimension_Channels], sd->layout.y); - sd->dispatch.z = ceil_div_u32(node->rf_dimensions.E[BeamformerRFDimension_Events], sd->layout.z); + sd->dispatch.x = DivRoundUp(node->rf_dimensions.E[BeamformerRFDimension_Samples], sd->layout.x); + sd->dispatch.y = DivRoundUp(node->rf_dimensions.E[BeamformerRFDimension_Channels], sd->layout.y); + sd->dispatch.z = DivRoundUp(node->rf_dimensions.E[BeamformerRFDimension_Events], sd->layout.z); }break; case BeamformerShaderKind_DAS:{ @@ -1038,9 +1038,9 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A sd->layout.z = Min(subgroup_size, rb->SizeZ); sd->layout.y = subgroup_size / sd->layout.z; - sd->dispatch.x = ceil_div_u32(rb->SizeX, sd->layout.x); - sd->dispatch.y = ceil_div_u32(rb->SizeY, sd->layout.y); - sd->dispatch.z = ceil_div_u32(rb->SizeZ, sd->layout.z); + sd->dispatch.x = DivRoundUp(rb->SizeX, sd->layout.x); + sd->dispatch.y = DivRoundUp(rb->SizeY, sd->layout.y); + sd->dispatch.z = DivRoundUp(rb->SizeZ, sd->layout.z); }break; default:{}break; diff --git a/math.c b/math.c @@ -132,13 +132,6 @@ make_hadamard_transpose(Arena *arena, i32 dim, b32 row_major) return result; } -function u32 -ceil_div_u32(u32 a, u32 b) -{ - u32 result = ((u64)a + b - 1) / b; - return result; -} - function b32 u128_equal(u128 a, u128 b) {