Commit: aff38282fe3fc69f698f6df22d7b1ac3591d1373
Parent: ee2f58e9e845a9abf507be060429c6bdf66a6b76
Author: Randy Palamar
Date: Sun, 27 Jul 2025 20:47:42 -0600
shaders/demod: index forward on RF data
the performance is identical but this direction is easier for me
to handle for implementing normal filtering on i16 rf data
Diffstat:
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/beamformer.c b/beamformer.c
@@ -4,7 +4,6 @@
* - this means that das should have a RF version and an IQ version
* - this will also flip the current hack to support demodulate after decode to
* being a hack to support CudaHilbert after decode
- * [ ]: measure filtering performance when indexing forward on RF data
* [ ]: filter sampling frequency should be a filter creation parameter
* [ ]: reinvestigate ring buffer raw_data_ssbo
* - to minimize latency the main thread should manage the subbuffer upload so that the
diff --git a/shaders/demod.glsl b/shaders/demod.glsl
@@ -48,23 +48,21 @@ void main()
output_transmit_stride * transmit +
output_sample_stride * out_sample;
- bool in_bounds;
+ int target;
if (map_channels) {
- in_bounds = out_sample < output_channel_stride / output_sample_stride;
+ target = int(output_channel_stride / output_sample_stride);
} else {
- in_bounds = out_sample < output_transmit_stride;
+ target = int(out_sample < output_transmit_stride);
}
- if (in_bounds) {
- vec2 result = vec2(0);
- int index = int(in_sample);
- for (int i = 0;
- i < imageSize(filter_coefficients).x && index >= 0;
- i++, index -= int(input_sample_stride))
- {
- vec2 data = sample_rf(in_offset + index) * vec2(1, -1);
- vec2 iq = sqrt(2.0f) * rotate_iq(data, index);
- result += imageLoad(filter_coefficients, i).x * iq;
+ if (out_sample < target) {
+ vec2 result = vec2(0);
+ int index = int(in_sample) - imageSize(filter_coefficients).x;
+ int start = index < 0 ? -index : 0;
+ index += start;
+ for (int i = start; i < imageSize(filter_coefficients).x && index < target; i++, index++) {
+ vec2 iq = sqrt(2.0f) * rotate_iq(sample_rf(in_offset + index) * vec2(1, -1), index);
+ result += iq * imageLoad(filter_coefficients, imageSize(filter_coefficients).x - i - 1).x;
}
out_data[out_offset] = RESULT_TYPE_CAST(result);
}