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 (7923B)


      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 /* X(type, id, pretty name, fixed transmits) */
     46 #define DAS_SHADER_KIND_LIST \
     47 	X(FORCES,          0, "FORCES",         1) \
     48 	X(UFORCES,         1, "UFORCES",        0) \
     49 	X(HERCULES,        2, "HERCULES",       1) \
     50 	X(RCA_VLS,         3, "VLS",            0) \
     51 	X(RCA_TPW,         4, "TPW",            0) \
     52 	X(UHERCULES,       5, "UHERCULES",      0) \
     53 	X(RACES,           6, "RACES",          1) \
     54 	X(EPIC_FORCES,     7, "EPIC-FORCES",    1) \
     55 	X(EPIC_UFORCES,    8, "EPIC-UFORCES",   0) \
     56 	X(EPIC_UHERCULES,  9, "EPIC-UHERCULES", 0) \
     57 	X(Flash,          10, "Flash",          0)
     58 
     59 typedef enum {
     60 	#define X(type, id, ...) BeamformerDASKind_##type = id,
     61 	DAS_SHADER_KIND_LIST
     62 	#undef X
     63 	BeamformerDASKind_Count
     64 } BeamformerDASKind;
     65 
     66 #define BEAMFORMER_CONSTANTS_LIST \
     67 	X(FilterSlots,                4) \
     68 	X(MaxChannelCount,          256) \
     69 	X(MaxComputeShaderStages,    16) \
     70 	X(MaxParameterBlockSlots,    16) \
     71 	X(MaxRawDataFramesInFlight,   3) \
     72 	X(MaxSavedFrames,            16)
     73 #define X(k, v, ...) Beamformer##k = v,
     74 typedef enum {BEAMFORMER_CONSTANTS_LIST} BeamformerConstants;
     75 #undef X
     76 
     77 /* X(name, type, size, matlab_type, elements, comment) */
     78 #define BEAMFORMER_PARAMS_HEAD \
     79 	X(xdc_transform,          float,    [16], single, 16, "IMPORTANT: column major order")           \
     80 	X(xdc_element_pitch,      float,     [2], single,  2, "[m] Transducer Element Pitch {row, col}") \
     81 	X(raw_data_dimensions,    uint32_t,  [2], uint32,  2, "Raw Data Dimensions")                     \
     82 	X(sample_count,           uint32_t,     , uint32,  1, "")                                        \
     83 	X(channel_count,          uint32_t,     , uint32,  1, "")                                        \
     84 	X(acquisition_count,      uint32_t,     , uint32,  1, "")                                        \
     85 	X(das_shader_id,          uint32_t,     , uint32,  1, "")                                        \
     86 	X(time_offset,            float,        , single,  1, "pulse length correction time [s]")        \
     87 	X(decode,                 uint8_t,      , uint8,   1, "Decode or just reshape data")             \
     88 	X(transmit_mode,          uint8_t,      , uint8,   1, "Method/Orientation of Transmit")          \
     89 	X(receive_mode,           uint8_t,      , uint8,   1, "Method/Orientation of Receive")           \
     90 	X(sampling_mode,          uint8_t,      , uint8,   1, "")
     91 
     92 #define BEAMFORMER_UI_PARAMS \
     93 	X(output_min_coordinate,  float,     [3], single, 3, "[m] Back-Top-Left corner of output region")                     \
     94 	X(output_max_coordinate,  float,     [3], single, 3, "[m] Front-Bottom-Right corner of output region")                \
     95 	X(output_points,          int32_t,   [4], int32,  4, "Width * Height * Depth * (Frame Average Count)")                \
     96 	X(sampling_frequency,     float,        , single, 1, "[Hz]")                                                          \
     97 	X(demodulation_frequency, float,        , single, 1, "[Hz]")                                                          \
     98 	X(speed_of_sound,         float,        , single, 1, "[m/s]")                                                         \
     99 	X(f_number,               float,        , single, 1, "F# (set to 0 to disable)")                                      \
    100 	X(off_axis_pos,           float,        , single, 1, "[m] Position on screen normal to beamform in TPW/VLS/HERCULES") \
    101 	X(interpolate,            uint32_t,     , uint32, 1, "Perform Cubic Interpolation of RF Samples")                     \
    102 	X(coherency_weighting,    uint32_t,     , uint32, 1, "Apply coherency weighting to output data")                      \
    103 	X(beamform_plane,         uint32_t,     , uint32, 1, "Plane to Beamform in TPW/VLS/HERCULES")                         \
    104 	X(decimation_rate,        uint32_t,     , uint32, 1, "Number of times to decimate")
    105 
    106 #define BEAMFORMER_SIMPLE_PARAMS \
    107 	X(channel_mapping,          int16_t,  [BeamformerMaxChannelCount],        int16,  BeamformerMaxChannelCount) \
    108 	X(sparse_elements,          int16_t,  [BeamformerMaxChannelCount],        int16,  BeamformerMaxChannelCount) \
    109 	X(steering_angles,          float,    [BeamformerMaxChannelCount],        single, BeamformerMaxChannelCount) \
    110 	X(focal_depths,             float,    [BeamformerMaxChannelCount],        single, BeamformerMaxChannelCount) \
    111 	X(compute_stages,           int32_t,  [BeamformerMaxComputeShaderStages], int32,  BeamformerMaxComputeShaderStages) \
    112 	X(compute_stage_parameters, int16_t,  [BeamformerMaxComputeShaderStages], int16,  BeamformerMaxComputeShaderStages) \
    113 	X(compute_stages_count,     uint32_t, ,                                   uint32, 1) \
    114 	X(data_kind,                int32_t,  ,                                   int32,  1)
    115 
    116 #define X(name, type, size, ...) type name size;
    117 typedef struct {BEAMFORMER_PARAMS_HEAD} BeamformerParametersHead;
    118 typedef struct {BEAMFORMER_UI_PARAMS}   BeamformerUIParameters;
    119 
    120 typedef struct {
    121 	BEAMFORMER_PARAMS_HEAD
    122 	BEAMFORMER_UI_PARAMS
    123 } BeamformerParameters;
    124 
    125 typedef struct {
    126 	BEAMFORMER_PARAMS_HEAD
    127 	BEAMFORMER_UI_PARAMS
    128 	BEAMFORMER_SIMPLE_PARAMS
    129 } BeamformerSimpleParameters;
    130 #undef X
    131 
    132 #define BEAMFORMER_LIVE_IMAGING_DIRTY_FLAG_LIST \
    133 	X(ImagePlaneOffsets, 0) \
    134 	X(TransmitPower,     1) \
    135 	X(TGCControlPoints,  2) \
    136 	X(SaveData,          3) \
    137 	X(SaveNameTag,       4) \
    138 	X(StopImaging,       5)
    139 /* NOTE(rnp): if this exceeds 32 you need to fix the flag handling code */
    140 
    141 #define BEAMFORMER_LIVE_IMAGING_PARAMETERS_LIST \
    142 	X(active,               uint32_t, ,                               1)   \
    143 	X(save_enabled,         uint32_t, ,                               1)   \
    144 	X(save_active,          uint32_t, ,                               1)   \
    145 	X(transmit_power,       float,    ,                               1)   \
    146 	X(image_plane_offsets,  float,    [BeamformerViewPlaneTag_Count], BeamformerViewPlaneTag_Count) \
    147 	X(tgc_control_points,   float,    [8],                            8)   \
    148 	X(save_name_tag_length, int32_t,  ,                               1)   \
    149 	X(save_name_tag,        char,     [128],                          128)
    150 
    151 #define X(name, type, size, ...) type name size;
    152 typedef struct {BEAMFORMER_LIVE_IMAGING_PARAMETERS_LIST} BeamformerLiveImagingParameters;
    153 #undef X