ogl_beamforming

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

beamformer.c (26311B)


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