ogl_beamforming

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

beamformer_parameters.h (7629B)


      1 /* See LICENSE for license details. */
      2 #include <stdint.h>
      3 
      4 /* TODO(rnp):
      5  * [ ]: shader kinds have ballooned; shader stats table needs to be compressed
      6  * [ ]: Upload previously exported data for display. maybe this is a UI thing but doing it
      7  *      programatically would be nice.
      8  * [ ]: Add interface for multi frame upload. RF upload already uses an offset into SM so
      9  *      that part works fine. We just need a way of specify a multi frame upload. (Data must
     10  *      be organized for simple offset access per frame).
     11  */
     12 
     13 typedef struct {
     14 	/* NOTE(rnp): this wants to be iterated on both dimensions. it depends entirely on which
     15 	 * visualization method you want to use. the coalescing function wants both directions */
     16 	float times[32][BeamformerShaderKind_ComputeCount];
     17 	float rf_time_deltas[32];
     18 } BeamformerComputeStatsTable;
     19 
     20 /* TODO(rnp): this is an absolute abuse of the preprocessor, but now is
     21  * not a good time to write a full metaprogram */
     22 #define BEAMFORMER_FILTER_KIND_LIST(type, _) \
     23 	X(Invalid,      type unused) \
     24 	X(Kaiser,       type cutoff_frequency _ type beta          _ type length) \
     25 	X(MatchedChirp, type duration         _ type min_frequency _ type max_frequency)
     26 
     27 #define X(kind, ...) BeamformerFilterKind_##kind,
     28 typedef enum {BEAMFORMER_FILTER_KIND_LIST(,) BeamformerFilterKind_Count} BeamformerFilterKind;
     29 #undef X
     30 
     31 /* X(type, id, pretty name) */
     32 #define BEAMFORMER_VIEW_PLANE_TAG_LIST \
     33 	X(XZ,        0, "XZ")        \
     34 	X(YZ,        1, "YZ")        \
     35 	X(XY,        2, "XY")        \
     36 	X(Arbitrary, 3, "Arbitrary")
     37 
     38 typedef enum {
     39 	#define X(type, id, pretty) BeamformerViewPlaneTag_##type = id,
     40 	BEAMFORMER_VIEW_PLANE_TAG_LIST
     41 	#undef X
     42 	BeamformerViewPlaneTag_Count,
     43 } BeamformerViewPlaneTag;
     44 
     45 #define BEAMFORMER_CONSTANTS_LIST \
     46 	X(FilterSlots,                4) \
     47 	X(MaxChannelCount,          256) \
     48 	X(MaxComputeShaderStages,    16) \
     49 	X(MaxParameterBlockSlots,    16) \
     50 	X(MaxRawDataFramesInFlight,   3) \
     51 	X(MaxSavedFrames,            16)
     52 #define X(k, v, ...) Beamformer##k = v,
     53 typedef enum {BEAMFORMER_CONSTANTS_LIST} BeamformerConstants;
     54 #undef X
     55 
     56 /* X(name, type, size, matlab_type, elements, comment) */
     57 #define BEAMFORMER_PARAMS_HEAD \
     58 	X(xdc_transform,                float,    [16], single, 16, "IMPORTANT: column major order")           \
     59 	X(xdc_element_pitch,            float,     [2], single,  2, "[m] Transducer Element Pitch {row, col}") \
     60 	X(raw_data_dimensions,          uint32_t,  [2], uint32,  2, "Raw Data Dimensions")                     \
     61 	X(focal_vector,                 float,     [2], single,  2, "[degree, m] focal point {angle, depth}")  \
     62 	X(transmit_receive_orientation, uint32_t,     , uint32,  1, "")                                        \
     63 	X(sample_count,                 uint32_t,     , uint32,  1, "")                                        \
     64 	X(channel_count,                uint32_t,     , uint32,  1, "")                                        \
     65 	X(acquisition_count,            uint32_t,     , uint32,  1, "")                                        \
     66 	X(das_shader_id,                uint32_t,     , uint32,  1, "")                                        \
     67 	X(time_offset,                  float,        , single,  1, "pulse length correction time [s]")        \
     68 	X(single_focus,                 uint8_t,      , uint8,   1, "")                                        \
     69 	X(single_orientation,           uint8_t,      , uint8,   1, "")                                        \
     70 	X(decode_mode,                  uint8_t,      , uint8,   1, "")                                        \
     71 	X(sampling_mode,                uint8_t,      , uint8,   1, "")
     72 
     73 #define BEAMFORMER_UI_PARAMS \
     74 	X(output_min_coordinate,  float,     [3], single, 3, "[m] Back-Top-Left corner of output region")                     \
     75 	X(output_max_coordinate,  float,     [3], single, 3, "[m] Front-Bottom-Right corner of output region")                \
     76 	X(output_points,          int32_t,   [4], int32,  4, "Width * Height * Depth * (Frame Average Count)")                \
     77 	X(sampling_frequency,     float,        , single, 1, "[Hz]")                                                          \
     78 	X(demodulation_frequency, float,        , single, 1, "[Hz]")                                                          \
     79 	X(speed_of_sound,         float,        , single, 1, "[m/s]")                                                         \
     80 	X(f_number,               float,        , single, 1, "F# (set to 0 to disable)")                                      \
     81 	X(off_axis_pos,           float,        , single, 1, "[m] Position on screen normal to beamform in TPW/VLS/HERCULES") \
     82 	X(interpolation_mode,     uint32_t,     , uint32, 1, "Nearest, Linear, or Cubic Interpolation of RF Samples")         \
     83 	X(coherency_weighting,    uint32_t,     , uint32, 1, "Apply coherency weighting to output data")                      \
     84 	X(beamform_plane,         uint32_t,     , uint32, 1, "Plane to Beamform in TPW/VLS/HERCULES")                         \
     85 	X(decimation_rate,        uint32_t,     , uint32, 1, "Number of times to decimate")
     86 
     87 #define BEAMFORMER_SIMPLE_PARAMS \
     88 	X(channel_mapping,               int16_t,  [BeamformerMaxChannelCount],        int16,  BeamformerMaxChannelCount) \
     89 	X(sparse_elements,               int16_t,  [BeamformerMaxChannelCount],        int16,  BeamformerMaxChannelCount) \
     90 	X(transmit_receive_orientations, uint8_t,  [BeamformerMaxChannelCount],        uint8,  BeamformerMaxChannelCount) \
     91 	X(steering_angles,               float,    [BeamformerMaxChannelCount],        single, BeamformerMaxChannelCount) \
     92 	X(focal_depths,                  float,    [BeamformerMaxChannelCount],        single, BeamformerMaxChannelCount) \
     93 	X(compute_stages,                int32_t,  [BeamformerMaxComputeShaderStages], int32,  BeamformerMaxComputeShaderStages) \
     94 	X(compute_stage_parameters,      int16_t,  [BeamformerMaxComputeShaderStages], int16,  BeamformerMaxComputeShaderStages) \
     95 	X(compute_stages_count,          uint32_t, ,                                   uint32, 1) \
     96 	X(data_kind,                     int32_t,  ,                                   int32,  1)
     97 
     98 #define X(name, type, size, ...) type name size;
     99 typedef struct {BEAMFORMER_PARAMS_HEAD} BeamformerParametersHead;
    100 typedef struct {BEAMFORMER_UI_PARAMS}   BeamformerUIParameters;
    101 
    102 typedef struct {
    103 	BEAMFORMER_PARAMS_HEAD
    104 	BEAMFORMER_UI_PARAMS
    105 } BeamformerParameters;
    106 
    107 typedef struct {
    108 	BEAMFORMER_PARAMS_HEAD
    109 	BEAMFORMER_UI_PARAMS
    110 	BEAMFORMER_SIMPLE_PARAMS
    111 } BeamformerSimpleParameters;
    112 #undef X
    113 
    114 #define BEAMFORMER_LIVE_IMAGING_DIRTY_FLAG_LIST \
    115 	X(ImagePlaneOffsets, 0) \
    116 	X(TransmitPower,     1) \
    117 	X(TGCControlPoints,  2) \
    118 	X(SaveData,          3) \
    119 	X(SaveNameTag,       4) \
    120 	X(StopImaging,       5)
    121 /* NOTE(rnp): if this exceeds 32 you need to fix the flag handling code */
    122 
    123 #define BEAMFORMER_LIVE_IMAGING_PARAMETERS_LIST \
    124 	X(active,               uint32_t, ,                               1)   \
    125 	X(save_enabled,         uint32_t, ,                               1)   \
    126 	X(save_active,          uint32_t, ,                               1)   \
    127 	X(transmit_power,       float,    ,                               1)   \
    128 	X(image_plane_offsets,  float,    [BeamformerViewPlaneTag_Count], BeamformerViewPlaneTag_Count) \
    129 	X(tgc_control_points,   float,    [8],                            8)   \
    130 	X(save_name_tag_length, int32_t,  ,                               1)   \
    131 	X(save_name_tag,        char,     [128],                          128)
    132 
    133 #define X(name, type, size, ...) type name size;
    134 typedef struct {BEAMFORMER_LIVE_IMAGING_PARAMETERS_LIST} BeamformerLiveImagingParameters;
    135 #undef X