Commit: dd10528d53dd459123cc7c43a9ffc2adba469953
Parent: d885a8dbeaf4b2b09958c76676093fd148f0dae0
Author: Randy Palamar
Date: Fri, 16 Aug 2024 13:35:11 -0600
add set_beamformer_pipeline to matlab helper lib
Diffstat:
4 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/beamformer.h b/beamformer.h
@@ -41,17 +41,6 @@ typedef union {
Rectangle rl;
} Rect;
-enum compute_shaders {
- /* TODO: Probably this should be split up */
- CS_CUDA_DECODE_AND_DEMOD,
- CS_HADAMARD,
- CS_HERCULES,
- CS_LPF,
- CS_MIN_MAX,
- CS_UFORCES,
- CS_LAST
-};
-
enum program_flags {
RELOAD_SHADERS = 1 << 0,
ALLOC_SSBOS = 1 << 1,
diff --git a/beamformer_parameters.h b/beamformer_parameters.h
@@ -1,4 +1,14 @@
/* See LICENSE for license details. */
+enum compute_shaders {
+ /* TODO: Probably this should be split up */
+ CS_CUDA_DECODE_AND_DEMOD = 0,
+ CS_HADAMARD = 1,
+ CS_HERCULES = 2,
+ CS_LPF = 3,
+ CS_MIN_MAX = 4,
+ CS_UFORCES = 5,
+ CS_LAST
+};
/* NOTE: This struct follows the OpenGL std140 layout. DO NOT modify unless you have
* read and understood the rules, particulary with regards to _member alignment_ */
diff --git a/helpers/ogl_beamformer_lib.c b/helpers/ogl_beamformer_lib.c
@@ -1,9 +1,13 @@
#include "ogl_beamformer_lib.h"
typedef struct {
BeamformerParameters raw;
- b32 upload;
+ enum compute_shaders compute_stages[16];
+ u32 compute_stages_count;
+ b32 upload;
} BeamformerParametersFull;
+#define ARRAY_COUNT(a) (sizeof(a) / sizeof(*a))
+
#if defined(__unix__)
#include <fcntl.h>
#include <sys/mman.h>
@@ -124,6 +128,35 @@ check_shared_memory(char *name)
}
void
+set_beamformer_pipeline(char *shm_name, i32 *stages, i32 stages_count)
+{
+ if (stages_count > ARRAY_COUNT(g_bp->compute_stages)) {
+ mexErrMsgIdAndTxt("ogl_beamformer:config", "maximum stage count is %u",
+ ARRAY_COUNT(g_bp->compute_stages));
+ return;
+ }
+
+ check_shared_memory(shm_name);
+
+ for (i32 i = 0; i < stages_count; i++) {
+ switch (stages[i]) {
+ case CS_CUDA_DECODE_AND_DEMOD:
+ case CS_HADAMARD:
+ case CS_HERCULES:
+ case CS_LPF:
+ case CS_MIN_MAX:
+ case CS_UFORCES:
+ g_bp->compute_stages[i] = stages[i];
+ break;
+ default:
+ mexErrMsgIdAndTxt("ogl_beamformer:config", "invalid shader stage: %d",
+ stages[i]);
+ return;
+ }
+ }
+}
+
+void
send_data(char *pipe_name, char *shm_name, i16 *data, uv2 data_dim)
{
if (g_pipe.file == OS_INVALID_FILE) {
diff --git a/helpers/ogl_beamformer_lib.h b/helpers/ogl_beamformer_lib.h
@@ -26,4 +26,5 @@ typedef struct { u32 x, y, z, w; } uv4;
#include "../beamformer_parameters.h"
LIB_FN void set_beamformer_parameters(char *shm_name, BeamformerParameters *);
+LIB_FN void set_beamformer_pipeline(char *shm_name, i32 *stages, i32 stages_count);
LIB_FN void send_data(char *pipe_name, char *shm_name, i16 *data, uv2 data_dim);