ogl_beamforming

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

beamformer_parameters.h (5134B)


      1 /* See LICENSE for license details. */
      2 
      3 /* X(enumarant, number, shader file name, needs header, pretty name) */
      4 #define COMPUTE_SHADERS \
      5 	X(CUDA_DECODE,           0, "",         0, "CUDA Decoding")   \
      6 	X(CUDA_HILBERT,          1, "",         0, "CUDA Hilbert")    \
      7 	X(DAS,                   2, "das",      1, "DAS")             \
      8 	X(DECODE,                3, "decode",   1, "Decoding")        \
      9 	X(DECODE_FLOAT,          4, "",         1, "Decoding (F32)")  \
     10 	X(DECODE_FLOAT_COMPLEX,  5, "",         1, "Decoding (F32C)") \
     11 	X(DEMOD,                 6, "demod",    1, "Demodulation")    \
     12 	X(MIN_MAX,               7, "min_max",  0, "Min/Max")         \
     13 	X(SUM,                   8, "sum",      0, "Sum")
     14 
     15 typedef enum {
     16 	#define X(e, n, s, h, pn) CS_ ##e = n,
     17 	COMPUTE_SHADERS
     18 	#undef X
     19 	CS_LAST
     20 } ComputeShaderID;
     21 
     22 /* X(type, id, pretty name) */
     23 #define DECODE_TYPES \
     24 	X(NONE,     0, "None")     \
     25 	X(HADAMARD, 1, "Hadamard")
     26 
     27 /* X(type, id, pretty name, fixed transmits) */
     28 #define DAS_TYPES \
     29 	X(FORCES,       0, "FORCES",       1) \
     30 	X(UFORCES,      1, "UFORCES",      0) \
     31 	X(HERCULES,     2, "HERCULES",     1) \
     32 	X(RCA_VLS,      3, "VLS",          0) \
     33 	X(RCA_TPW,      4, "TPW",          0) \
     34 	X(UHERCULES,    5, "UHERCULES",    0) \
     35 	X(ACE_HERCULES, 6, "ACE-HERCULES", 1)
     36 
     37 #define DAS_LOCAL_SIZE_X 32
     38 #define DAS_LOCAL_SIZE_Y  1
     39 #define DAS_LOCAL_SIZE_Z 32
     40 
     41 #define MAX_BEAMFORMED_SAVED_FRAMES 16
     42 
     43 /* TODO(rnp): actually use a substruct but generate a header compatible with MATLAB */
     44 /* X(name, type, size, gltype, glsize, comment) */
     45 #define BEAMFORMER_UI_PARAMS \
     46 	X(output_min_coordinate, v4,  , vec4,  , "/* [m] Back-Top-Left corner of output region */")                    \
     47 	X(output_max_coordinate, v4,  , vec4,  , "/* [m] Front-Bottom-Right corner of output region */")               \
     48 	X(output_points,         uv4, , uvec4, , "/* Width * Height * Depth * (Frame Average Count) */")               \
     49 	X(sampling_frequency,    f32, , float, , "/* [Hz]  */")                                                        \
     50 	X(center_frequency,      f32, , float, , "/* [Hz]  */")                                                        \
     51 	X(speed_of_sound,        f32, , float, , "/* [m/s] */")                                                        \
     52 	X(off_axis_pos,          f32, , float, , "/* [m] Position on screen normal to beamform in TPW/VLSHERCULES */") \
     53 	X(beamform_plane,        i32, , int,   , "/* Plane to Beamform in TPW/VLS/HERCULES */")                        \
     54 	X(f_number,              f32, , float, , "/* F# (set to 0 to disable) */")                                     \
     55 	X(interpolate,           b32, , bool,  , "/* Perform Cubic Interpolation of RF Samples */")
     56 
     57 #define BEAMFORMER_PARAMS_HEAD \
     58 	X(channel_mapping,   u16, [256], uvec4, [32], "/* Transducer Channel to Verasonics Channel */")                           \
     59 	X(uforces_channels,  u16, [256], uvec4, [32], "/* Channels used for virtual UFORCES elements */")                         \
     60 	X(focal_depths,      f32, [256], vec4,  [64], "/* [m] Focal Depths for each transmit of a RCA imaging scheme*/")          \
     61 	X(transmit_angles,   f32, [256], vec4,  [64], "/* [radians] Transmit Angles for each transmit of a RCA imaging scheme*/") \
     62 	X(xdc_transform,     f32, [16] , mat4,      , "/* IMPORTANT: column major order */")                                      \
     63 	X(dec_data_dim,      uv4,      , uvec4,     , "/* Samples * Channels * Acquisitions; last element ignored */")            \
     64 	X(xdc_element_pitch, f32, [2]  , vec2,      , "/* [m] Transducer Element Pitch {row, col} */")                            \
     65 	X(rf_raw_dim,        uv2,      , uvec2,     , "/* Raw Data Dimensions */")                                                \
     66 	X(transmit_mode,     i32,      , int,       , "/* Method/Orientation of Transmit */")                                     \
     67 	X(decode,            u32,      , uint,      , "/* Decode or just reshape data */")                                        \
     68 	X(das_shader_id,     u32,      , uint,      , "")                                                                         \
     69 	X(time_offset,       f32,      , float,     , "/* pulse length correction time [s] */")
     70 
     71 #define BEAMFORMER_PARAMS_TAIL \
     72 	X(readi_group_id,   u32, , uint, , "/* Which readi group this data is from */") \
     73 	X(readi_group_size, u32, , uint, , "/* Size of readi transmit group */")
     74 
     75 #define X(name, type, size, gltype, glsize, comment) type name size;
     76 typedef struct { BEAMFORMER_UI_PARAMS } BeamformerUIParameters;
     77 
     78 /* NOTE: This struct follows the OpenGL std140 layout. DO NOT modify unless you have
     79  * read and understood the rules, particulary with regards to _member alignment_ */
     80 typedef struct {
     81 	BEAMFORMER_PARAMS_HEAD
     82 	BEAMFORMER_UI_PARAMS
     83 	BEAMFORMER_PARAMS_TAIL
     84 	f32 _pad[3];
     85 } BeamformerParameters;
     86 #undef X
     87 
     88 _Static_assert((offsetof(BeamformerParameters, output_min_coordinate) & 15) == 0,
     89                "BeamformerParameters.output_min_coordinate must lie on a 16 byte boundary");
     90 _Static_assert((sizeof(BeamformerParameters) & 15) == 0,
     91                "sizeof(BeamformerParameters) must be a multiple of 16");