ogl_beamforming

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

beamformer.c (27157B)


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