Commit: 61f780dc2b0d0c865bfc66cbf6217d4ac0a7da15
Parent: ac6590635db5ad0b8a21586a41d7da5fc541f938
Author: Randy Palamar
Date: Thu, 5 Sep 2024 15:29:21 -0600
make sure cuda lib function pointers are always valid
also we use external here not extern
Diffstat:
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/beamformer.h b/beamformer.h
@@ -91,8 +91,8 @@ typedef struct {
#define DEBUG_EXPORT static
#endif
- #define OS_CUDA_LIB_NAME "./extern/cuda_toolkit.so"
- #define OS_CUDA_LIB_TEMP_NAME "./extern/cuda_toolkit_temp.so"
+ #define OS_CUDA_LIB_NAME "./external/cuda_toolkit.so"
+ #define OS_CUDA_LIB_TEMP_NAME "./external/cuda_toolkit_temp.so"
#define OS_PIPE_NAME "/tmp/beamformer_data_fifo"
#define OS_SMEM_NAME "/ogl_beamformer_parameters"
@@ -107,8 +107,8 @@ typedef struct {
#define DEBUG_EXPORT static
#endif
- #define OS_CUDA_LIB_NAME "extern/cuda_toolkit.dll"
- #define OS_CUDA_LIB_TEMP_NAME "extern/cuda_toolkit_temp.dll"
+ #define OS_CUDA_LIB_NAME "external\\cuda_toolkit.dll"
+ #define OS_CUDA_LIB_TEMP_NAME "external\\cuda_toolkit_temp.dll"
#define OS_PIPE_NAME "\\\\.\\pipe\\beamformer_data_fifo"
#define OS_SMEM_NAME "Local\\ogl_beamformer_parameters"
diff --git a/main.c b/main.c
@@ -131,6 +131,15 @@ reload_shaders(BeamformerCtx *ctx, Arena a)
}
static void
+validate_cuda_lib(CudaLib *cl)
+{
+ if (!cl->init_cuda_configuration) cl->init_cuda_configuration = init_cuda_configuration_stub;
+ if (!cl->register_cuda_buffers) cl->register_cuda_buffers = register_cuda_buffers_stub;
+ if (!cl->cuda_decode) cl->cuda_decode = cuda_decode_stub;
+ if (!cl->cuda_hilbert) cl->cuda_hilbert = cuda_hilbert_stub;
+}
+
+static void
check_and_load_cuda_lib(CudaLib *cl)
{
os_file_stats current = os_get_file_stats(OS_CUDA_LIB_NAME);
@@ -148,10 +157,7 @@ check_and_load_cuda_lib(CudaLib *cl)
cl->cuda_decode = os_lookup_dynamic_symbol(cl->lib, "cuda_decode");
cl->cuda_hilbert = os_lookup_dynamic_symbol(cl->lib, "cuda_hilbert");
- if (!cl->init_cuda_configuration) cl->init_cuda_configuration = init_cuda_configuration_stub;
- if (!cl->register_cuda_buffers) cl->register_cuda_buffers = register_cuda_buffers_stub;
- if (!cl->cuda_decode) cl->cuda_decode = cuda_decode_stub;
- if (!cl->cuda_hilbert) cl->cuda_hilbert = cuda_hilbert_stub;
+ validate_cuda_lib(cl);
}
int
@@ -204,6 +210,9 @@ main(void)
}
}
+ /* NOTE: make sure function pointers are valid even if we are not using the cuda lib */
+ validate_cuda_lib(&ctx.cuda_lib);
+
/* NOTE: set up OpenGL debug logging */
glDebugMessageCallback(gl_debug_logger, NULL);
#ifdef _DEBUG