ogl_beamforming

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

Commit: be078df83f891b28012954efef2f25cfe3e8638f
Parent: 726ed738aa8ff43ec7208d190d45dfb66bb0f1e7
Author: Randy Palamar
Date:   Mon,  9 Dec 2024 21:27:16 -0700

don't flood the work queue with in flight frames

Diffstat:
Mbeamformer.c | 24++++++++++++++++++------
Mbeamformer.h | 1+
2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/beamformer.c b/beamformer.c @@ -158,10 +158,13 @@ beamform_work_queue_pop(BeamformWorkQueue *q) case BW_RECOMPUTE: case BW_PARTIAL_COMPUTE: /* NOTE: only one compute is allowed per frame */ - if (q->did_compute_this_frame) + if (q->did_compute_this_frame) { result = 0; - else + } else { + q->compute_in_flight--; q->did_compute_this_frame = 1; + ASSERT(q->compute_in_flight >= 0); + } break; } } @@ -173,6 +176,7 @@ beamform_work_queue_pop(BeamformWorkQueue *q) q->last = 0; } } + return result; } @@ -194,7 +198,12 @@ beamform_work_queue_push(BeamformerCtx *ctx, Arena *a, enum beamform_work work_t switch (work_type) { case BW_FULL_COMPUTE: - /* TODO: limiting to make sure we don't have too many of these in the queue */ + if (q->compute_in_flight >= ARRAY_COUNT(cs->raw_data_fences)) { + result->next = q->next_free; + q->next_free = result; + result = 0; + break; + } cs->raw_data_index++; if (cs->raw_data_index >= ARRAY_COUNT(cs->raw_data_fences)) cs->raw_data_index = 0; @@ -233,16 +242,19 @@ beamform_work_queue_push(BeamformerCtx *ctx, Arena *a, enum beamform_work work_t s8("Beamformed_Data")); } } - } break; + } /* FALLTHROUGH */ case BW_PARTIAL_COMPUTE: + q->compute_in_flight++; case BW_SAVE_FRAME: case BW_SEND_FRAME: case BW_SSBO_COPY: break; } - if (q->last) q->last = q->last->next = result; - else q->last = q->first = result; + if (result) { + if (q->last) q->last = q->last->next = result; + else q->last = q->first = result; + } } return result; diff --git a/beamformer.h b/beamformer.h @@ -250,6 +250,7 @@ typedef struct { BeamformWork *first; BeamformWork *last; BeamformWork *next_free; + i32 compute_in_flight; b32 did_compute_this_frame; } BeamformWorkQueue;