ogl_beamforming

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

Commit: 9438e92e5eef55ec906624dc611667606ceddea6
Parent: 873d18cf8624916dcbff34243ca2f7a06294f975
Author: Randy Palamar
Date:   Thu,  2 Apr 2026 06:10:02 -0600

shaders/das: use integer comparisons for bounds check

This is mostly important for cubic where the truncated index needs
to be greater than 0, if it is 0 sampling will be out of bounds.

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

diff --git a/shaders/das.glsl b/shaders/das.glsl @@ -97,11 +97,11 @@ SAMPLE_TYPE sample_rf(const int rf_offset, const float index) SAMPLE_TYPE result = SAMPLE_TYPE(0); switch (InterpolationMode) { case InterpolationMode_Nearest:{ - if (index >= 0 && int(round(index)) < SampleCount) + if (int(index) >= 0 && int(round(index)) < SampleCount) result = rotate_iq(rf_data[rf_offset + int(round(index))], index / SamplingFrequency); }break; case InterpolationMode_Linear:{ - if (index >= 0 && int(round(index)) < SampleCount) { + if (int(index) >= 0 && int(index) < SampleCount - 1) { float tk, t = modf(index, tk); int n = rf_offset + int(tk); result = (1 - t) * rf_data[n] + t * rf_data[n + 1]; @@ -109,7 +109,7 @@ SAMPLE_TYPE sample_rf(const int rf_offset, const float index) } }break; case InterpolationMode_Cubic:{ - if (index > 0 && int(index) < SampleCount - 2) { + if (int(index) > 0 && int(index) < SampleCount - 2) { float tk, t = modf(index, tk); result = rotate_iq(cubic(rf_offset + int(index), t), index / SamplingFrequency); }