Commit: 851731ccf607c0d1f73cdf1c1ec56c588f8a28ff
Parent: 0fd7940791ef6adb20d1d20cfaf793466da9910b
Author: Randy Palamar
Date: Sat, 26 Jul 2025 17:56:57 -0600
core: bind only filled portion of rf buffer for DAS
I'm still not sure how a channel is accessing data beyond the
region that was filled and reading NaNs but it is. This prevents
part of the image from being polluted.
This only seems to happen when we demodulate after decoding which
doesn't make a whole lot of sense to me. A similiar effect can be
created by using an unsupported decimation rate. But in that case
demod first produces a buffer that won't beamform correctly but
still contains non NaN data.
Future commit will size the buffer in plan_compute_pipeline() but
when the beamformer decodes first it still needs to be oversized
to accommodate the extra samples.
Diffstat:
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/beamformer.c b/beamformer.c
@@ -471,6 +471,8 @@ plan_compute_pipeline(SharedMemoryRegion *os_sm, BeamformerComputePipeline *cp,
bp->sampling_frequency /= (f32)mp->decimation_rate * (f32)time_compression;
bp->dec_data_dim[0] /= mp->decimation_rate * time_compression;
}
+ /* TODO(rnp): if IQ (* 8) else (* 4) */
+ cp->rf_size = (iz)(bp->dec_data_dim[0] * bp->dec_data_dim[1] * bp->dec_data_dim[2] * 8);
}
function m4
@@ -606,8 +608,8 @@ do_compute_shader(BeamformerCtx *ctx, Arena arena, BeamformerComputeFrame *frame
glBindImageTexture(0, frame->frame.texture, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_RG32F);
}
- glBindBufferBase(GL_UNIFORM_BUFFER, 0, cp->ubos[BeamformerComputeUBOKind_DAS]);
- glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, csctx->rf_data_ssbos[input_ssbo_idx]);
+ glBindBufferBase(GL_UNIFORM_BUFFER, 0, cp->ubos[BeamformerComputeUBOKind_DAS]);
+ glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 1, csctx->rf_data_ssbos[input_ssbo_idx], 0, cp->rf_size);
glBindImageTexture(1, csctx->sparse_elements_texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16I);
glBindImageTexture(2, csctx->focal_vectors_texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RG32F);
diff --git a/beamformer.h b/beamformer.h
@@ -165,6 +165,8 @@ typedef struct {
uv3 decode_dispatch;
uv3 demod_dispatch;
+ iz rf_size;
+
u32 ubos[BeamformerComputeUBOKind_Count];
#define X(k, type, name) type name ##_ubo_data;