ogl_beamforming

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

Commit: 32e995451418d44882dea6cf6bc85172f35105f7
Parent: a71039397348cc86227c3146a606bd3e5cd999ac
Author: Randy Palamar
Date:   Mon, 24 Aug 2026 19:56:00 -0700

das: unconfuse shader compiler with modf in interpolation

I was trying to figure out why a TPW run was blowing 1.8% of
shader execution time on multiplying a floating point register
with 1.f and I noticed the fract instruction was happening before
the buffer load instructions were issued. Changing to the fract()
glsl builtin gets the compiler to move it after the load thus
providing more math overlap with waiting for the fetch. This gets
rid of the strange multiply with 1.0 and improves the performance
(of TPW) by ~13%. It also improves the perfomance of FORCES by
~7%.

Diffstat:
Mshaders/das.glsl | 10++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/shaders/das.glsl b/shaders/das.glsl @@ -111,17 +111,15 @@ SAMPLE_TYPE sample_rf(const int rf_offset, const float index) }break; case InterpolationMode_Linear:{ if (index >= 0.f && index < f32(SampleCount - 1)) { - float tk, t = modf(index, tk); - int n = rf_offset + int(tk); + s32 n = rf_offset + int(index); + f32 t = fract(index); result = (1 - t) * rf[n] + t * rf[n + 1]; result = rotate_iq(result, index / SamplingFrequency); } }break; case InterpolationMode_Cubic:{ - if (index >= 1.f && index < f32(SampleCount - 2)) { - float tk, t = modf(index, tk); - result = rotate_iq(cubic(rf_offset + int(index), t), index / SamplingFrequency); - } + if (index >= 1.f && index < f32(SampleCount - 2)) + result = rotate_iq(cubic(rf_offset + int(index), fract(index)), index / SamplingFrequency); }break; } return result;