ogl_beamforming

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

beamformer.c (27494B)


      1 /* See LICENSE for license details. */
      2 
      3 // GENERATED CODE
      4 
      5 // NOTE: Constants (Integer)
      6 #define BeamformerChunkChannelCount        (16)
      7 #define BeamformerFilterSlots              (4)
      8 #define BeamformerMaxBacklogFrames         (4096)
      9 #define BeamformerMaxChannelCount          (256)
     10 #define BeamformerMaxEmissionsCount        (256)
     11 #define BeamformerMaxComputeShaderStages   (16)
     12 #define BeamformerMaxParameterBlocks       (16)
     13 #define BeamformerMaxRawDataFramesInFlight (3)
     14 
     15 typedef enum {
     16 	BeamformerDecodeMode_None     = 0,
     17 	BeamformerDecodeMode_Hadamard = 1,
     18 	BeamformerDecodeMode_Count,
     19 } BeamformerDecodeMode;
     20 
     21 typedef enum {
     22 	BeamformerRCAOrientation_None    = 0,
     23 	BeamformerRCAOrientation_Rows    = 1,
     24 	BeamformerRCAOrientation_Columns = 2,
     25 	BeamformerRCAOrientation_Count,
     26 } BeamformerRCAOrientation;
     27 
     28 typedef enum {
     29 	BeamformerSamplingMode_2X = 0,
     30 	BeamformerSamplingMode_4X = 1,
     31 	BeamformerSamplingMode_Count,
     32 } BeamformerSamplingMode;
     33 
     34 typedef enum {
     35 	BeamformerDataKind_Int16          = 0,
     36 	BeamformerDataKind_Int16Complex   = 1,
     37 	BeamformerDataKind_Float32        = 2,
     38 	BeamformerDataKind_Float32Complex = 3,
     39 	BeamformerDataKind_Float16        = 4,
     40 	BeamformerDataKind_Float16Complex = 5,
     41 	BeamformerDataKind_Count,
     42 } BeamformerDataKind;
     43 
     44 typedef enum {
     45 	BeamformerRFDimension_Channels = 0,
     46 	BeamformerRFDimension_Events   = 1,
     47 	BeamformerRFDimension_Samples  = 2,
     48 	BeamformerRFDimension_Frames   = 3,
     49 	BeamformerRFDimension_Count,
     50 } BeamformerRFDimension;
     51 
     52 typedef enum {
     53 	BeamformerDataLayout_ChannelEventSample = 0,
     54 	BeamformerDataLayout_ChannelSampleEvent = 1,
     55 	BeamformerDataLayout_EventChannelSample = 2,
     56 	BeamformerDataLayout_SampleChannelEvent = 3,
     57 	BeamformerDataLayout_Image              = 4,
     58 	BeamformerDataLayout_Count,
     59 } BeamformerDataLayout;
     60 
     61 typedef enum {
     62 	BeamformerContrastMode_None = 0,
     63 	BeamformerContrastMode_A1S2 = 1,
     64 	BeamformerContrastMode_Count,
     65 } BeamformerContrastMode;
     66 
     67 typedef enum {
     68 	BeamformerEmissionKind_Sine  = 0,
     69 	BeamformerEmissionKind_Chirp = 1,
     70 	BeamformerEmissionKind_Count,
     71 } BeamformerEmissionKind;
     72 
     73 typedef enum {
     74 	BeamformerInterpolationMode_Nearest = 0,
     75 	BeamformerInterpolationMode_Linear  = 1,
     76 	BeamformerInterpolationMode_Cubic   = 2,
     77 	BeamformerInterpolationMode_Count,
     78 } BeamformerInterpolationMode;
     79 
     80 typedef enum {
     81 	BeamformerViewPlaneTag_XZ        = 0,
     82 	BeamformerViewPlaneTag_YZ        = 1,
     83 	BeamformerViewPlaneTag_XY        = 2,
     84 	BeamformerViewPlaneTag_Arbitrary = 3,
     85 	BeamformerViewPlaneTag_Count,
     86 } BeamformerViewPlaneTag;
     87 
     88 typedef enum {
     89 	BeamformerAcquisitionKind_FORCES         = 0,
     90 	BeamformerAcquisitionKind_UFORCES        = 1,
     91 	BeamformerAcquisitionKind_HERCULES       = 2,
     92 	BeamformerAcquisitionKind_RCA_VLS        = 3,
     93 	BeamformerAcquisitionKind_RCA_TPW        = 4,
     94 	BeamformerAcquisitionKind_UHERCULES      = 5,
     95 	BeamformerAcquisitionKind_RACES          = 6,
     96 	BeamformerAcquisitionKind_EPIC_FORCES    = 7,
     97 	BeamformerAcquisitionKind_EPIC_UFORCES   = 8,
     98 	BeamformerAcquisitionKind_EPIC_UHERCULES = 9,
     99 	BeamformerAcquisitionKind_Flash          = 10,
    100 	BeamformerAcquisitionKind_HERO_PA        = 11,
    101 	BeamformerAcquisitionKind_ULM            = 12,
    102 	BeamformerAcquisitionKind_Count,
    103 } BeamformerAcquisitionKind;
    104 
    105 typedef enum {
    106 	BeamformerFilterKind_Kaiser       = 0,
    107 	BeamformerFilterKind_MatchedChirp = 1,
    108 	BeamformerFilterKind_Count,
    109 } BeamformerFilterKind;
    110 
    111 typedef enum {
    112 	BeamformerLiveFeedbackFlags_ImagePlaneOffsets = 0,
    113 	BeamformerLiveFeedbackFlags_TransmitPower     = 1,
    114 	BeamformerLiveFeedbackFlags_TGCControlPoints  = 2,
    115 	BeamformerLiveFeedbackFlags_SaveData          = 3,
    116 	BeamformerLiveFeedbackFlags_SaveNameTag       = 4,
    117 	BeamformerLiveFeedbackFlags_StopImaging       = 5,
    118 	BeamformerLiveFeedbackFlags_AcquisitionKind   = 6,
    119 	BeamformerLiveFeedbackFlags_Count,
    120 } BeamformerLiveFeedbackFlags;
    121 
    122 typedef enum {
    123 	BeamformerAcquisitionKindFlags_FixedTransmits = 1 << 0,
    124 	BeamformerAcquisitionKindFlags_Sparse         = 1 << 1,
    125 } BeamformerAcquisitionKindFlags;
    126 
    127 typedef enum {
    128 	BeamformerLiveImagingDirtyFlags_ImagePlaneOffsets = 1 << 0,
    129 	BeamformerLiveImagingDirtyFlags_TransmitPower     = 1 << 1,
    130 	BeamformerLiveImagingDirtyFlags_TGCControlPoints  = 1 << 2,
    131 	BeamformerLiveImagingDirtyFlags_SaveData          = 1 << 3,
    132 	BeamformerLiveImagingDirtyFlags_SaveNameTag       = 1 << 4,
    133 	BeamformerLiveImagingDirtyFlags_StopImaging       = 1 << 5,
    134 	BeamformerLiveImagingDirtyFlags_AcquisitionKind   = 1 << 6,
    135 } BeamformerLiveImagingDirtyFlags;
    136 
    137 typedef enum {
    138 	BeamformerDecodeCompileFlags_CooperativeMatrix = 1 << 0,
    139 	BeamformerDecodeCompileFlags_UseSharedMemory   = 1 << 1,
    140 } BeamformerDecodeCompileFlags;
    141 
    142 typedef enum {
    143 	BeamformerFilterCompileFlags_ComplexFilter = 1 << 0,
    144 	BeamformerFilterCompileFlags_Demodulate    = 1 << 1,
    145 } BeamformerFilterCompileFlags;
    146 
    147 typedef enum {
    148 	BeamformerDASCompileFlags_CoherencyWeighting = 1 << 0,
    149 	BeamformerDASCompileFlags_Sparse             = 1 << 1,
    150 } BeamformerDASCompileFlags;
    151 
    152 typedef enum {
    153 	BeamformerReshapeCompileFlags_Deinterleave = 1 << 0,
    154 	BeamformerReshapeCompileFlags_Interleave   = 1 << 1,
    155 } BeamformerReshapeCompileFlags;
    156 
    157 typedef enum {
    158 	BeamformerShaderKind_Decode             = 0,
    159 	BeamformerShaderKind_Filter             = 1,
    160 	BeamformerShaderKind_Demodulate         = 2,
    161 	BeamformerShaderKind_DAS                = 3,
    162 	BeamformerShaderKind_Hilbert            = 4,
    163 	BeamformerShaderKind_CoherencyWeighting = 5,
    164 	BeamformerShaderKind_Reshape            = 6,
    165 	BeamformerShaderKind_MinMax             = 7,
    166 	BeamformerShaderKind_Sum                = 8,
    167 	BeamformerShaderKind_RenderBeamformed   = 9,
    168 	BeamformerShaderKind_Count,
    169 
    170 	BeamformerShaderKind_ComputeFirst        = BeamformerShaderKind_Decode,
    171 	BeamformerShaderKind_ComputeLast         = BeamformerShaderKind_Hilbert,
    172 	BeamformerShaderKind_ComputeCount        = 5,
    173 	BeamformerShaderKind_ComputeHelpersFirst = BeamformerShaderKind_CoherencyWeighting,
    174 	BeamformerShaderKind_ComputeHelpersLast  = BeamformerShaderKind_Sum,
    175 	BeamformerShaderKind_ComputeHelpersCount = 4,
    176 	BeamformerShaderKind_RenderFirst         = BeamformerShaderKind_RenderBeamformed,
    177 	BeamformerShaderKind_RenderLast          = BeamformerShaderKind_RenderBeamformed,
    178 	BeamformerShaderKind_RenderCount         = 1,
    179 } BeamformerShaderKind;
    180 
    181 typedef struct {
    182 	u32 Hadamard;
    183 	u32 DecodeMode;
    184 	u32 OutputChannelStride;
    185 	u32 OutputSampleStride;
    186 	u32 OutputTransmitStride;
    187 	u32 ToProcess;
    188 	u32 TransmitCount;
    189 	u32 ChunkChannelCount;
    190 	u32 CooperativeMatrixM;
    191 	u32 CooperativeMatrixN;
    192 	u32 CooperativeMatrixK;
    193 } BeamformerDecodeBakeParameters;
    194 
    195 typedef struct {
    196 	u32 FilterCoefficients;
    197 	u32 FilterLength;
    198 	f32 SamplesPerWave;
    199 	u32 DecimationRate;
    200 	u32 SampleCount;
    201 	u32 BatchSampleCount;
    202 	u32 InputChannelStride;
    203 	u32 InputSampleStride;
    204 	u32 InputTransmitStride;
    205 	u32 OutputChannelStride;
    206 	u32 OutputSampleStride;
    207 	u32 OutputTransmitStride;
    208 } BeamformerFilterBakeParameters;
    209 
    210 typedef struct {
    211 	u32 FocalVectors;
    212 	u32 Hadamard;
    213 	u32 IncoherentFrame;
    214 	u32 SparseElements;
    215 	u32 TransducerTransforms;
    216 	u32 TransmitReceiveOrientations;
    217 	u32 AcquisitionKind;
    218 	i32 AcquisitionCount;
    219 	i32 SampleCount;
    220 	u32 AcquisitionByteStride;
    221 	u32 ChannelByteStride;
    222 	u16 ReceiveChannelCount;
    223 	u16 TransmitChannelCount;
    224 	u16 ReceiveTileCount;
    225 	u16 TransmitTileCount;
    226 	u16 ChunkChannelCount;
    227 	u16 TransmitReceiveOrientation;
    228 	u16 InterpolationMode;
    229 	u16 ReadiGroupCount;
    230 	f32 SamplingFrequency;
    231 	f32 SamplesPerWave;
    232 	f32 SpeedOfSound;
    233 	f32 TimeOffset;
    234 	f32 FNumber;
    235 	u32 OutputSizeX;
    236 	u32 OutputSizeY;
    237 	u32 OutputSizeZ;
    238 } BeamformerDASBakeParameters;
    239 
    240 typedef struct {
    241 	u32 IncoherentSum;
    242 	f32 Scale;
    243 	u32 OutputVoxels;
    244 } BeamformerCoherencyWeightingBakeParameters;
    245 
    246 typedef struct {
    247 	u32 SizeX;
    248 	u32 SizeY;
    249 	u32 SizeZ;
    250 	u32 InputStrideX;
    251 	u32 InputStrideY;
    252 	u32 InputStrideZ;
    253 	u32 OutputStrideX;
    254 	u32 OutputStrideY;
    255 	u32 OutputStrideZ;
    256 } BeamformerReshapeBakeParameters;
    257 
    258 typedef struct {
    259 	u64 rf_buffer;
    260 	u64 output_buffer;
    261 } BeamformerDecodePushConstants;
    262 
    263 typedef struct {
    264 	u64 input_buffer;
    265 	u64 output_buffer;
    266 } BeamformerFilterPushConstants;
    267 
    268 typedef struct {
    269 	m4  voxel_transform;
    270 	v2  xdc_element_pitch;
    271 	u64 rf_data;
    272 	u64 output_frame;
    273 	u32 channel_offset;
    274 	f32 focus_depth;
    275 	f32 steering_angle;
    276 	u16 tx_rx_orientation;
    277 	u16 readi_group;
    278 } BeamformerDASPushConstants;
    279 
    280 typedef struct {
    281 	u64 coherent_sum;
    282 } BeamformerCoherencyWeightingPushConstants;
    283 
    284 typedef struct {
    285 	u64 output_buffer;
    286 	u64 left_input_buffer;
    287 	u64 right_input_buffer;
    288 } BeamformerReshapePushConstants;
    289 
    290 typedef struct {
    291 	u64 output_data;
    292 	u64 input_data;
    293 	u32 image_elements;
    294 	f32 scale;
    295 } BeamformerSumPushConstants;
    296 
    297 typedef struct {
    298 	m4  mvp_matrix;
    299 	u64 positions;
    300 	u64 normals;
    301 	v4  bounding_box_colour;
    302 	f32 bounding_box_fraction;
    303 	f32 db_cutoff;
    304 	f32 threshold;
    305 	f32 gamma;
    306 	u64 input_data;
    307 	u32 input_size_x;
    308 	u32 input_size_y;
    309 	u32 input_size_z;
    310 	u32 data_kind;
    311 } BeamformerRenderBeamformedPushConstants;
    312 
    313 typedef struct {
    314 	f32 cycles;
    315 	f32 frequency;
    316 } BeamformerSineParameters;
    317 
    318 typedef struct {
    319 	f32 duration;
    320 	f32 min_frequency;
    321 	f32 max_frequency;
    322 } BeamformerChirpParameters;
    323 
    324 typedef struct {
    325 	BeamformerEmissionKind kind;
    326 	union {
    327 		BeamformerSineParameters  sine;
    328 		BeamformerChirpParameters chirp;
    329 	};
    330 } BeamformerEmissionParameters;
    331 
    332 typedef struct {
    333 	f32 cutoff_frequency;
    334 	f32 beta;
    335 	u32 length;
    336 } BeamformerKaiserFilterParameters;
    337 
    338 typedef struct {
    339 	f32 duration;
    340 	f32 min_frequency;
    341 	f32 max_frequency;
    342 } BeamformerMatchedChirpFilterParameters;
    343 
    344 typedef struct {
    345 	BeamformerFilterKind kind;
    346 	f32                  sampling_frequency;
    347 	b32                  complex;
    348 	union {
    349 		BeamformerKaiserFilterParameters       kaiser;
    350 		BeamformerMatchedChirpFilterParameters matched_chirp;
    351 	};
    352 } BeamformerFilterParameters;
    353 
    354 typedef struct {
    355 	m4                           das_voxel_transform;
    356 	m4                           xdc_transform;
    357 	v2                           xdc_element_pitch;
    358 	uv2                          raw_data_dimensions;
    359 	v2                           focal_vector;
    360 	u32                          transmit_receive_orientation;
    361 	u32                          sample_count;
    362 	u32                          channel_count;
    363 	u32                          acquisition_count;
    364 	BeamformerAcquisitionKind    acquisition_kind;
    365 	BeamformerDecodeMode         decode_mode;
    366 	BeamformerSamplingMode       sampling_mode;
    367 	f32                          time_offset;
    368 	b32                          single_focus;
    369 	b32                          single_orientation;
    370 	iv4                          output_points;
    371 	f32                          sampling_frequency;
    372 	f32                          demodulation_frequency;
    373 	f32                          speed_of_sound;
    374 	f32                          f_number;
    375 	BeamformerInterpolationMode  interpolation_mode;
    376 	b32                          coherency_weighting;
    377 	u32                          decimation_rate;
    378 	BeamformerContrastMode       contrast_mode;
    379 	BeamformerEmissionParameters emission_parameters;
    380 	u32                          readi_group_count;
    381 	u32                          readi_group;
    382 } BeamformerParameters;
    383 
    384 typedef struct {
    385 	m4                           das_voxel_transform;
    386 	m4                           xdc_transform;
    387 	v2                           xdc_element_pitch;
    388 	uv2                          raw_data_dimensions;
    389 	v2                           focal_vector;
    390 	u32                          transmit_receive_orientation;
    391 	u32                          sample_count;
    392 	u32                          channel_count;
    393 	u32                          acquisition_count;
    394 	BeamformerAcquisitionKind    acquisition_kind;
    395 	BeamformerDecodeMode         decode_mode;
    396 	BeamformerSamplingMode       sampling_mode;
    397 	f32                          time_offset;
    398 	b32                          single_focus;
    399 	b32                          single_orientation;
    400 	iv4                          output_points;
    401 	f32                          sampling_frequency;
    402 	f32                          demodulation_frequency;
    403 	f32                          speed_of_sound;
    404 	f32                          f_number;
    405 	BeamformerInterpolationMode  interpolation_mode;
    406 	b32                          coherency_weighting;
    407 	u32                          decimation_rate;
    408 	BeamformerContrastMode       contrast_mode;
    409 	BeamformerEmissionParameters emission_parameters;
    410 	u32                          readi_group_count;
    411 	u32                          readi_group;
    412 	i16                          channel_mapping[BeamformerMaxChannelCount];
    413 	i16                          sparse_elements[BeamformerMaxEmissionsCount];
    414 	u8                           transmit_receive_orientations[BeamformerMaxEmissionsCount];
    415 	f32                          steering_angles[BeamformerMaxEmissionsCount];
    416 	f32                          focal_depths[BeamformerMaxEmissionsCount];
    417 	i32                          compute_stages[BeamformerMaxComputeShaderStages];
    418 	i32                          compute_stage_parameters[BeamformerMaxComputeShaderStages];
    419 	u32                          compute_stages_count;
    420 	BeamformerDataKind           data_kind;
    421 } BeamformerSimpleParameters;
    422 
    423 typedef struct {
    424 	u32 active;
    425 	u32 save_enabled;
    426 	u32 save_active;
    427 	u32 acquisition_kind;
    428 	u64 acquisition_kind_enabled_flags;
    429 	f32 transmit_power;
    430 	f32 image_plane_offsets[BeamformerViewPlaneTag_Count];
    431 	f32 tgc_control_points[8];
    432 	i32 save_name_tag_length;
    433 	u8  save_name_tag[128];
    434 } BeamformerLiveImagingParameters;
    435 
    436 typedef union {
    437 	BeamformerDecodeBakeParameters             Decode;
    438 	BeamformerFilterBakeParameters             Filter;
    439 	BeamformerDASBakeParameters                DAS;
    440 	BeamformerCoherencyWeightingBakeParameters CoherencyWeighting;
    441 	BeamformerReshapeBakeParameters            Reshape;
    442 } BeamformerShaderBakeParameters;
    443 
    444 typedef enum {
    445 	BeamformerStructKind_DecodeBakeParameters             = 0,
    446 	BeamformerStructKind_FilterBakeParameters             = 1,
    447 	BeamformerStructKind_DASBakeParameters                = 2,
    448 	BeamformerStructKind_CoherencyWeightingBakeParameters = 3,
    449 	BeamformerStructKind_ReshapeBakeParameters            = 4,
    450 	BeamformerStructKind_Count,
    451 } BeamformerStructKind;
    452 
    453 read_only MetaStructMember *meta_struct_members_by_id[] = {
    454 	(MetaStructMember []){
    455 		{18, 0,  1, 0},
    456 		{18, 4,  1, 0},
    457 		{18, 8,  1, 0},
    458 		{18, 12, 1, 0},
    459 		{18, 16, 1, 0},
    460 		{18, 20, 1, 0},
    461 		{18, 24, 1, 0},
    462 		{18, 28, 1, 0},
    463 		{18, 32, 1, 0},
    464 		{18, 36, 1, 0},
    465 		{18, 40, 1, 0},
    466 	},
    467 	(MetaStructMember []){
    468 		{18, 0,  1, 0},
    469 		{18, 4,  1, 0},
    470 		{8,  8,  1, 0},
    471 		{18, 12, 1, 0},
    472 		{18, 16, 1, 0},
    473 		{18, 20, 1, 0},
    474 		{18, 24, 1, 0},
    475 		{18, 28, 1, 0},
    476 		{18, 32, 1, 0},
    477 		{18, 36, 1, 0},
    478 		{18, 40, 1, 0},
    479 		{18, 44, 1, 0},
    480 	},
    481 	(MetaStructMember []){
    482 		{18, 0,  1, 0},
    483 		{18, 4,  1, 0},
    484 		{18, 8,  1, 0},
    485 		{18, 12, 1, 0},
    486 		{18, 16, 1, 0},
    487 		{18, 20, 1, 0},
    488 		{18, 24, 1, 0},
    489 		{10, 28, 1, 0},
    490 		{10, 32, 1, 0},
    491 		{18, 36, 1, 0},
    492 		{18, 40, 1, 0},
    493 		{19, 44, 1, 0},
    494 		{19, 46, 1, 0},
    495 		{19, 48, 1, 0},
    496 		{19, 50, 1, 0},
    497 		{19, 52, 1, 0},
    498 		{19, 54, 1, 0},
    499 		{19, 56, 1, 0},
    500 		{19, 58, 1, 0},
    501 		{8,  60, 1, 0},
    502 		{8,  64, 1, 0},
    503 		{8,  68, 1, 0},
    504 		{8,  72, 1, 0},
    505 		{8,  76, 1, 0},
    506 		{18, 80, 1, 0},
    507 		{18, 84, 1, 0},
    508 		{18, 88, 1, 0},
    509 	},
    510 	(MetaStructMember []){
    511 		{18, 0, 1, 0},
    512 		{8,  4, 1, 0},
    513 		{18, 8, 1, 0},
    514 	},
    515 	(MetaStructMember []){
    516 		{18, 0,  1, 0},
    517 		{18, 4,  1, 0},
    518 		{18, 8,  1, 0},
    519 		{18, 12, 1, 0},
    520 		{18, 16, 1, 0},
    521 		{18, 20, 1, 0},
    522 		{18, 24, 1, 0},
    523 		{18, 28, 1, 0},
    524 		{18, 32, 1, 0},
    525 	},
    526 };
    527 
    528 read_only str8 *meta_struct_member_names_by_id[] = {
    529 	(str8 []){
    530 		str8_comp("Hadamard"),
    531 		str8_comp("DecodeMode"),
    532 		str8_comp("OutputChannelStride"),
    533 		str8_comp("OutputSampleStride"),
    534 		str8_comp("OutputTransmitStride"),
    535 		str8_comp("ToProcess"),
    536 		str8_comp("TransmitCount"),
    537 		str8_comp("ChunkChannelCount"),
    538 		str8_comp("CooperativeMatrixM"),
    539 		str8_comp("CooperativeMatrixN"),
    540 		str8_comp("CooperativeMatrixK"),
    541 	},
    542 	(str8 []){
    543 		str8_comp("FilterCoefficients"),
    544 		str8_comp("FilterLength"),
    545 		str8_comp("SamplesPerWave"),
    546 		str8_comp("DecimationRate"),
    547 		str8_comp("SampleCount"),
    548 		str8_comp("BatchSampleCount"),
    549 		str8_comp("InputChannelStride"),
    550 		str8_comp("InputSampleStride"),
    551 		str8_comp("InputTransmitStride"),
    552 		str8_comp("OutputChannelStride"),
    553 		str8_comp("OutputSampleStride"),
    554 		str8_comp("OutputTransmitStride"),
    555 	},
    556 	(str8 []){
    557 		str8_comp("FocalVectors"),
    558 		str8_comp("Hadamard"),
    559 		str8_comp("IncoherentFrame"),
    560 		str8_comp("SparseElements"),
    561 		str8_comp("TransducerTransforms"),
    562 		str8_comp("TransmitReceiveOrientations"),
    563 		str8_comp("AcquisitionKind"),
    564 		str8_comp("AcquisitionCount"),
    565 		str8_comp("SampleCount"),
    566 		str8_comp("AcquisitionByteStride"),
    567 		str8_comp("ChannelByteStride"),
    568 		str8_comp("ReceiveChannelCount"),
    569 		str8_comp("TransmitChannelCount"),
    570 		str8_comp("ReceiveTileCount"),
    571 		str8_comp("TransmitTileCount"),
    572 		str8_comp("ChunkChannelCount"),
    573 		str8_comp("TransmitReceiveOrientation"),
    574 		str8_comp("InterpolationMode"),
    575 		str8_comp("ReadiGroupCount"),
    576 		str8_comp("SamplingFrequency"),
    577 		str8_comp("SamplesPerWave"),
    578 		str8_comp("SpeedOfSound"),
    579 		str8_comp("TimeOffset"),
    580 		str8_comp("FNumber"),
    581 		str8_comp("OutputSizeX"),
    582 		str8_comp("OutputSizeY"),
    583 		str8_comp("OutputSizeZ"),
    584 	},
    585 	(str8 []){
    586 		str8_comp("IncoherentSum"),
    587 		str8_comp("Scale"),
    588 		str8_comp("OutputVoxels"),
    589 	},
    590 	(str8 []){
    591 		str8_comp("SizeX"),
    592 		str8_comp("SizeY"),
    593 		str8_comp("SizeZ"),
    594 		str8_comp("InputStrideX"),
    595 		str8_comp("InputStrideY"),
    596 		str8_comp("InputStrideZ"),
    597 		str8_comp("OutputStrideX"),
    598 		str8_comp("OutputStrideY"),
    599 		str8_comp("OutputStrideZ"),
    600 	},
    601 };
    602 
    603 read_only MetaStructInfo meta_struct_info_by_id[] = {
    604 	{str8_comp("DecodeBakeParameters"),             11, 44, 0},
    605 	{str8_comp("FilterBakeParameters"),             12, 48, 0},
    606 	{str8_comp("DASBakeParameters"),                27, 92, 0},
    607 	{str8_comp("CoherencyWeightingBakeParameters"), 3,  12, 0},
    608 	{str8_comp("ReshapeBakeParameters"),            9,  36, 0},
    609 };
    610 
    611 read_only str8 beamformer_shader_names[] = {
    612 	str8_comp("Decode"),
    613 	str8_comp("Filter"),
    614 	str8_comp("Demodulate"),
    615 	str8_comp("DAS"),
    616 	str8_comp("Hilbert"),
    617 	str8_comp("CoherencyWeighting"),
    618 	str8_comp("Reshape"),
    619 	str8_comp("MinMax"),
    620 	str8_comp("Sum"),
    621 	str8_comp("RenderBeamformed"),
    622 };
    623 
    624 read_only BeamformerShaderKind beamformer_reloadable_shader_kinds[] = {
    625 	BeamformerShaderKind_Decode,
    626 	BeamformerShaderKind_Filter,
    627 	BeamformerShaderKind_DAS,
    628 	BeamformerShaderKind_CoherencyWeighting,
    629 	BeamformerShaderKind_Reshape,
    630 	BeamformerShaderKind_MinMax,
    631 	BeamformerShaderKind_Sum,
    632 	BeamformerShaderKind_RenderBeamformed,
    633 };
    634 
    635 read_only str8 *beamformer_reloadable_shader_files[] = {
    636 	(str8 []){str8_comp("decode.glsl")},
    637 	(str8 []){str8_comp("filter.glsl")},
    638 	(str8 []){str8_comp("das.glsl")},
    639 	(str8 []){str8_comp("coherency_weighting.glsl")},
    640 	(str8 []){str8_comp("reshape.glsl")},
    641 	(str8 []){str8_comp("min_max.glsl")},
    642 	(str8 []){str8_comp("sum.glsl")},
    643 	(str8 []){str8_comp("render_3d.vert.glsl"), str8_comp("render_3d.frag.glsl")},
    644 };
    645 
    646 read_only i32 beamformer_shader_reloadable_index_by_shader[] = {
    647 	0,
    648 	1,
    649 	1,
    650 	2,
    651 	-1,
    652 	3,
    653 	4,
    654 	5,
    655 	6,
    656 	7,
    657 };
    658 
    659 read_only i32 beamformer_reloadable_compute_shader_info_indices[] = {
    660 	0,
    661 	1,
    662 	2,
    663 };
    664 
    665 read_only i32 beamformer_reloadable_compute_helpers_shader_info_indices[] = {
    666 	3,
    667 	4,
    668 	5,
    669 	6,
    670 };
    671 
    672 read_only i32 beamformer_reloadable_render_shader_info_indices[] = {
    673 	7,
    674 };
    675 
    676 read_only str8 beamformer_shader_global_header_strings[] = {
    677 	str8_comp(""
    678 	"#define DecodeMode_None     0\n"
    679 	"#define DecodeMode_Hadamard 1\n"
    680 	"\n"),
    681 	str8_comp(""
    682 	"#define CooperativeMatrix ((CompileFlags & (1 << 0)) != 0)\n"
    683 	"#define UseSharedMemory   ((CompileFlags & (1 << 1)) != 0)\n"
    684 	"\n"),
    685 	str8_comp(""
    686 	"layout(push_constant, std430) uniform PushConstants {\n"
    687 	"  uint64_t rf_buffer;\n"
    688 	"  uint64_t output_buffer;\n"
    689 	"};\n"
    690 	"\n"),
    691 	str8_comp(""
    692 	"#define ComplexFilter ((CompileFlags & (1 << 0)) != 0)\n"
    693 	"#define Demodulate    ((CompileFlags & (1 << 1)) != 0)\n"
    694 	"\n"),
    695 	str8_comp(""
    696 	"layout(push_constant, std430) uniform PushConstants {\n"
    697 	"  uint64_t input_buffer;\n"
    698 	"  uint64_t output_buffer;\n"
    699 	"};\n"
    700 	"\n"),
    701 	str8_comp(""
    702 	"#define AcquisitionKind_FORCES         0\n"
    703 	"#define AcquisitionKind_UFORCES        1\n"
    704 	"#define AcquisitionKind_HERCULES       2\n"
    705 	"#define AcquisitionKind_RCA_VLS        3\n"
    706 	"#define AcquisitionKind_RCA_TPW        4\n"
    707 	"#define AcquisitionKind_UHERCULES      5\n"
    708 	"#define AcquisitionKind_RACES          6\n"
    709 	"#define AcquisitionKind_EPIC_FORCES    7\n"
    710 	"#define AcquisitionKind_EPIC_UFORCES   8\n"
    711 	"#define AcquisitionKind_EPIC_UHERCULES 9\n"
    712 	"#define AcquisitionKind_Flash          10\n"
    713 	"#define AcquisitionKind_HERO_PA        11\n"
    714 	"#define AcquisitionKind_ULM            12\n"
    715 	"\n"),
    716 	str8_comp(""
    717 	"#define InterpolationMode_Nearest 0\n"
    718 	"#define InterpolationMode_Linear  1\n"
    719 	"#define InterpolationMode_Cubic   2\n"
    720 	"\n"),
    721 	str8_comp(""
    722 	"#define RCAOrientation_None    0\n"
    723 	"#define RCAOrientation_Rows    1\n"
    724 	"#define RCAOrientation_Columns 2\n"
    725 	"\n"),
    726 	str8_comp(""
    727 	"#define CoherencyWeighting ((CompileFlags & (1 << 0)) != 0)\n"
    728 	"#define Sparse             ((CompileFlags & (1 << 1)) != 0)\n"
    729 	"\n"),
    730 	str8_comp(""
    731 	"layout(push_constant, std430) uniform PushConstants {\n"
    732 	"  f32mat4   voxel_transform;\n"
    733 	"  f32vec2   xdc_element_pitch;\n"
    734 	"  uint64_t  rf_data;\n"
    735 	"  uint64_t  output_frame;\n"
    736 	"  uint32_t  channel_offset;\n"
    737 	"  float32_t focus_depth;\n"
    738 	"  float32_t steering_angle;\n"
    739 	"  uint16_t  tx_rx_orientation;\n"
    740 	"  uint16_t  readi_group;\n"
    741 	"};\n"
    742 	"\n"),
    743 	str8_comp(""
    744 	"layout(push_constant, std430) uniform PushConstants {\n"
    745 	"  uint64_t coherent_sum;\n"
    746 	"};\n"
    747 	"\n"),
    748 	str8_comp(""
    749 	"#define Deinterleave ((CompileFlags & (1 << 0)) != 0)\n"
    750 	"#define Interleave   ((CompileFlags & (1 << 1)) != 0)\n"
    751 	"\n"),
    752 	str8_comp(""
    753 	"layout(push_constant, std430) uniform PushConstants {\n"
    754 	"  uint64_t output_buffer;\n"
    755 	"  uint64_t left_input_buffer;\n"
    756 	"  uint64_t right_input_buffer;\n"
    757 	"};\n"
    758 	"\n"),
    759 	str8_comp(""
    760 	"layout(push_constant, std430) uniform PushConstants {\n"
    761 	"  uint64_t  output_data;\n"
    762 	"  uint64_t  input_data;\n"
    763 	"  uint32_t  image_elements;\n"
    764 	"  float32_t scale;\n"
    765 	"};\n"
    766 	"\n"),
    767 	str8_comp(""
    768 	"layout(push_constant, std430) uniform PushConstants {\n"
    769 	"  f32mat4   mvp_matrix;\n"
    770 	"  uint64_t  positions;\n"
    771 	"  uint64_t  normals;\n"
    772 	"  f32vec4   bounding_box_colour;\n"
    773 	"  float32_t bounding_box_fraction;\n"
    774 	"  float32_t db_cutoff;\n"
    775 	"  float32_t threshold;\n"
    776 	"  float32_t gamma;\n"
    777 	"  uint64_t  input_data;\n"
    778 	"  uint32_t  input_size_x;\n"
    779 	"  uint32_t  input_size_y;\n"
    780 	"  uint32_t  input_size_z;\n"
    781 	"  uint32_t  data_kind;\n"
    782 	"};\n"
    783 	"\n"),
    784 };
    785 
    786 read_only b8 beamformer_shader_has_primitive[] = {
    787 	0,
    788 	0,
    789 	0,
    790 	0,
    791 	0,
    792 	0,
    793 	0,
    794 	1,
    795 };
    796 
    797 read_only b8 beamformer_shader_primitive_is_vertex[] = {
    798 	0,
    799 	0,
    800 	0,
    801 	0,
    802 	0,
    803 	0,
    804 	0,
    805 	1,
    806 };
    807 
    808 read_only i32 *beamformer_shader_header_vectors[] = {
    809 	(i32 []){0, 1, 2},
    810 	(i32 []){3, 4},
    811 	(i32 []){5, 6, 7, 8, 9},
    812 	(i32 []){10},
    813 	(i32 []){11, 12},
    814 	0,
    815 	(i32 []){13},
    816 	(i32 []){14},
    817 };
    818 
    819 read_only i32 beamformer_shader_header_vector_lengths[] = {
    820 	3,
    821 	2,
    822 	5,
    823 	1,
    824 	2,
    825 	0,
    826 	1,
    827 	1,
    828 };
    829 
    830 read_only str8 *beamformer_shader_compile_flag_names[] = {
    831 	(str8 []){
    832 		str8_comp("CooperativeMatrix"),
    833 		str8_comp("UseSharedMemory"),
    834 	},
    835 	(str8 []){
    836 		str8_comp("ComplexFilter"),
    837 		str8_comp("Demodulate"),
    838 	},
    839 	(str8 []){
    840 		str8_comp("CoherencyWeighting"),
    841 		str8_comp("Sparse"),
    842 	},
    843 	0,
    844 	(str8 []){
    845 		str8_comp("Deinterleave"),
    846 		str8_comp("Interleave"),
    847 	},
    848 	0,
    849 	0,
    850 	0,
    851 };
    852 
    853 read_only u8 beamformer_shader_compile_flag_counts[] = {
    854 	2,
    855 	2,
    856 	2,
    857 	0,
    858 	2,
    859 	0,
    860 	0,
    861 	0,
    862 };
    863 
    864 read_only i32 beamformer_base_shader_to_bake_struct_id[] = {
    865 	0,
    866 	1,
    867 	2,
    868 	3,
    869 	4,
    870 	-1,
    871 	-1,
    872 	-1,
    873 };
    874 
    875 read_only u8 beamformer_shader_push_constant_sizes[] = {
    876 	sizeof(BeamformerDecodePushConstants),
    877 	sizeof(BeamformerFilterPushConstants),
    878 	sizeof(BeamformerDASPushConstants),
    879 	sizeof(BeamformerCoherencyWeightingPushConstants),
    880 	sizeof(BeamformerReshapePushConstants),
    881 	0,
    882 	sizeof(BeamformerSumPushConstants),
    883 	sizeof(BeamformerRenderBeamformedPushConstants),
    884 };
    885 
    886 read_only u8 beamformer_data_kind_element_size[] = {
    887 	2,
    888 	2,
    889 	4,
    890 	4,
    891 	2,
    892 	2,
    893 };
    894 
    895 read_only u8 beamformer_data_kind_element_count[] = {
    896 	1,
    897 	2,
    898 	1,
    899 	2,
    900 	1,
    901 	2,
    902 };
    903 
    904 read_only u8 beamformer_data_kind_byte_size[] = {
    905 	2 * 1,
    906 	2 * 2,
    907 	4 * 1,
    908 	4 * 2,
    909 	2 * 1,
    910 	2 * 2,
    911 };
    912 
    913 read_only b8 beamformer_data_kind_complex[] = {
    914 	0,
    915 	1,
    916 	0,
    917 	1,
    918 	0,
    919 	1,
    920 };
    921 
    922 read_only str8 beamformer_data_kind_glsl_type[] = {
    923 	str8_comp("int16_t"),
    924 	str8_comp("i16vec2"),
    925 	str8_comp("float32_t"),
    926 	str8_comp("f32vec2"),
    927 	str8_comp("float16_t"),
    928 	str8_comp("f16vec2"),
    929 };
    930 
    931 read_only str8 beamformer_data_kind_str8[] = {
    932 	str8_comp("Int16"),
    933 	str8_comp("Int16Complex"),
    934 	str8_comp("Float32"),
    935 	str8_comp("Float32Complex"),
    936 	str8_comp("Float16"),
    937 	str8_comp("Float16Complex"),
    938 };
    939 
    940 read_only f32 beamformer_sampling_mode_samples_per_wave[] = {
    941 	2,
    942 	4,
    943 };
    944 
    945 read_only u32 beamformer_acquisition_kind_flags[] = {
    946 	(1*BeamformerAcquisitionKindFlags_FixedTransmits)|(0*BeamformerAcquisitionKindFlags_Sparse),
    947 	(0*BeamformerAcquisitionKindFlags_FixedTransmits)|(1*BeamformerAcquisitionKindFlags_Sparse),
    948 	(1*BeamformerAcquisitionKindFlags_FixedTransmits)|(0*BeamformerAcquisitionKindFlags_Sparse),
    949 	(0*BeamformerAcquisitionKindFlags_FixedTransmits)|(0*BeamformerAcquisitionKindFlags_Sparse),
    950 	(0*BeamformerAcquisitionKindFlags_FixedTransmits)|(0*BeamformerAcquisitionKindFlags_Sparse),
    951 	(0*BeamformerAcquisitionKindFlags_FixedTransmits)|(1*BeamformerAcquisitionKindFlags_Sparse),
    952 	(1*BeamformerAcquisitionKindFlags_FixedTransmits)|(0*BeamformerAcquisitionKindFlags_Sparse),
    953 	(1*BeamformerAcquisitionKindFlags_FixedTransmits)|(0*BeamformerAcquisitionKindFlags_Sparse),
    954 	(0*BeamformerAcquisitionKindFlags_FixedTransmits)|(1*BeamformerAcquisitionKindFlags_Sparse),
    955 	(0*BeamformerAcquisitionKindFlags_FixedTransmits)|(1*BeamformerAcquisitionKindFlags_Sparse),
    956 	(0*BeamformerAcquisitionKindFlags_FixedTransmits)|(0*BeamformerAcquisitionKindFlags_Sparse),
    957 	(0*BeamformerAcquisitionKindFlags_FixedTransmits)|(0*BeamformerAcquisitionKindFlags_Sparse),
    958 	(0*BeamformerAcquisitionKindFlags_FixedTransmits)|(0*BeamformerAcquisitionKindFlags_Sparse),
    959 };
    960 
    961 read_only str8 beamformer_acquisition_kind_strings[] = {
    962 	str8_comp("FORCES"),
    963 	str8_comp("UFORCES"),
    964 	str8_comp("HERCULES"),
    965 	str8_comp("VLS"),
    966 	str8_comp("TPW"),
    967 	str8_comp("UHERCULES"),
    968 	str8_comp("RACES"),
    969 	str8_comp("EPIC-FORCES"),
    970 	str8_comp("EPIC-UFORCES"),
    971 	str8_comp("EPIC-UHERCULES"),
    972 	str8_comp("Flash"),
    973 	str8_comp("HERO-PA"),
    974 	str8_comp("ULM"),
    975 };
    976 
    977 read_only u8 beamformer_contrast_mode_samples[] = {
    978 	1,
    979 	3,
    980 };
    981 
    982 read_only str8 beamformer_contrast_mode_strings[] = {
    983 	str8_comp("None"),
    984 	str8_comp("A1S2"),
    985 };
    986 
    987 read_only str8 beamformer_view_plane_tag_strings[] = {
    988 	str8_comp("XZ"),
    989 	str8_comp("YZ"),
    990 	str8_comp("XY"),
    991 	str8_comp("Arbitrary"),
    992 };
    993 
    994 read_only str8 beamformer_emission_kind_strings[] = {
    995 	str8_comp("Sine"),
    996 	str8_comp("Chirp"),
    997 };
    998 
    999 read_only str8 beamformer_interpolation_mode_strings[] = {
   1000 	str8_comp("Nearest"),
   1001 	str8_comp("Linear"),
   1002 	str8_comp("Cubic"),
   1003 };
   1004 
   1005 read_only u8 beamformer_data_stride_indices[BeamformerDataLayout_Count][3] = {
   1006 	[BeamformerDataLayout_ChannelEventSample] = {BeamformerRFDimension_Channels, BeamformerRFDimension_Events,   BeamformerRFDimension_Samples},
   1007 	[BeamformerDataLayout_ChannelSampleEvent] = {BeamformerRFDimension_Channels, BeamformerRFDimension_Samples,  BeamformerRFDimension_Events},
   1008 	[BeamformerDataLayout_EventChannelSample] = {BeamformerRFDimension_Events,   BeamformerRFDimension_Channels, BeamformerRFDimension_Samples},
   1009 	[BeamformerDataLayout_SampleChannelEvent] = {BeamformerRFDimension_Samples,  BeamformerRFDimension_Channels, BeamformerRFDimension_Events},
   1010 };
   1011