ogl_beamforming

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

beamformer.c (26417B)


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