Commit: 2792de75fbbf726b2f820ceff606d4f395cfd54d
Parent: 581aa965909e650ae3cb6d515551ece6e1ea37c2
Author: Randy Palamar
Date: Fri, 4 Oct 2024 13:12:08 -0600
enshitify interface as demanded by matlab
I don't how mathworks is operational given its high concentration
of terrible programmers (probably marketing department shilling to
universities). All their C parser has to do to make structs work
with their ridiculous calling convention is flatten them into an
array of bytes. Handling a nested array of structs is no different
than handling a nested struct which their code already does. There
isn't an excuse; their programmers just suck.
Diffstat:
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/beamformer.c b/beamformer.c
@@ -126,7 +126,7 @@ alloc_shader_storage(BeamformerCtx *ctx, Arena a)
}
static m3
-observation_direction_to_xdc_space(v3 direction, v3 origin, v3 corner1, v3 corner2)
+v3_to_xdc_space(v3 direction, v3 origin, v3 corner1, v3 corner2)
{
v3 edge1 = sub_v3(corner1, origin);
v3 edge2 = sub_v3(corner2, origin);
@@ -145,6 +145,14 @@ observation_direction_to_xdc_space(v3 direction, v3 origin, v3 corner1, v3 corne
return result;
}
+static v4
+f32_4_to_v4(f32 *in)
+{
+ v4 result;
+ _mm_storeu_ps(result.E, _mm_loadu_ps(in));
+ return result;
+}
+
static b32
do_volume_computation_step(BeamformerCtx *ctx, enum compute_shaders shader)
{
@@ -289,10 +297,10 @@ do_compute_shader(BeamformerCtx *ctx, enum compute_shaders shader)
texture = csctx->array_textures[i];
}
- m3 xdc_transform = observation_direction_to_xdc_space((v3){.z = 1},
- bp->xdc_origin[i].xyz,
- bp->xdc_corner1[i].xyz,
- bp->xdc_corner2[i].xyz);
+ m3 xdc_transform = v3_to_xdc_space((v3){.z = 1},
+ f32_4_to_v4(bp->xdc_origin + (4 * i)).xyz,
+ f32_4_to_v4(bp->xdc_corner1 + (4 * i)).xyz,
+ f32_4_to_v4(bp->xdc_corner2 + (4 * i)).xyz);
glBindImageTexture(0, texture, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_RG32F);
glUniform1i(csctx->xdc_index_id, i);
glUniformMatrix3fv(csctx->xdc_transform_id, 1, GL_FALSE, xdc_transform.E);
diff --git a/beamformer_parameters.h b/beamformer_parameters.h
@@ -17,9 +17,9 @@ typedef struct {
u16 channel_mapping[512]; /* Transducer Channel to Verasonics Channel */
u32 uforces_channels[128]; /* Channels used for virtual UFORCES elements */
f32 lpf_coefficients[64]; /* Low Pass Filter Cofficients */
- v4 xdc_origin[4]; /* [m] Corner of transducer being treated as origin */
- v4 xdc_corner1[4]; /* [m] Corner of transducer along first axis (arbitrary) */
- v4 xdc_corner2[4]; /* [m] Corner of transducer along second axis (arbitrary) */
+ f32 xdc_origin[16]; /* [m] (4 v4s) Corner of transducer being treated as origin */
+ f32 xdc_corner1[16]; /* [m] (4 v4s) Corner of transducer along first axis (arbitrary) */
+ f32 xdc_corner2[16]; /* [m] (4 v4s) Corner of transducer along second axis (arbitrary) */
uv4 dec_data_dim; /* Samples * Channels * Acquisitions; last element ignored */
uv4 output_points; /* Width * Height * Depth * (Frame Average Count) */
v4 output_min_coordinate; /* [m] Back-Top-Left corner of output region (w ignored) */