ogl_beamforming

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

beamformer.c (26237B)


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