ogl_beamforming

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

Commit: f9b04bfbf3714a3be7309bedb15facd9f10c1b80
Parent: b3a86a2e37131f3aad0007b3cdd589d245f9ff6c
Author: Randy Palamar
Date:   Tue, 10 Dec 2024 17:30:42 -0700

don't crash when reloading shaders when no data is loaded

(Hopefully) This isn't a problem on Linux with Mesa so hopefully
it solves the issue on win32.

Diffstat:
Mbeamformer.c | 3++-
Mui.c | 13++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/beamformer.c b/beamformer.c @@ -759,7 +759,8 @@ DEBUG_EXPORT BEAMFORMER_FRAME_STEP_FN(beamformer_frame_step) if (IsKeyPressed(KEY_R)) { ctx->flags |= RELOAD_SHADERS; - ui_start_compute(ctx); + if (ui_can_start_compute(ctx)) + ui_start_compute(ctx); } if (WindowShouldClose()) ctx->flags |= SHOULD_EXIT; diff --git a/ui.c b/ui.c @@ -612,12 +612,23 @@ update_text_input(InputState *is) } } +static b32 +ui_can_start_compute(BeamformerCtx *ctx) +{ + BeamformFrame *displayed = ctx->beamform_frames + ctx->displayed_frame_index; + b32 result = ctx->beamform_work_queue.compute_in_flight == 0; + result &= displayed->dim.x != 0; + result &= displayed->dim.y != 0; + result &= displayed->dim.z != 0; + return result; +} + static void ui_start_compute(BeamformerCtx *ctx) { /* NOTE: we do not allow ui to start a work if no work was previously completed */ Arena a = {0}; - if (ctx->beamform_work_queue.compute_in_flight == 0) { + if (ui_can_start_compute(ctx)) { beamform_work_queue_push(ctx, &a, BW_RECOMPUTE); BeamformFrameIterator bfi = beamform_frame_iterator(ctx); for (BeamformFrame *frame = frame_next(&bfi); frame; frame = frame_next(&bfi)) {