beamformer_parameters.h (7776B)
1 /* See LICENSE for license details. */ 2 #include <stdint.h> 3 4 /* TODO(rnp): 5 * [ ]: Have a method for the library caller to take ownership of a "compute context" 6 * [ ]: Upload previously exported data for display. maybe this is a UI thing but doing it 7 * programatically would be nice. 8 */ 9 10 #define BEAMFORMER_PARAMETERS_VERSION (2UL) 11 12 /* X(enumarant, number, shader file name, needs header, pretty name) */ 13 #define COMPUTE_SHADERS \ 14 X(CudaDecode, 0, "", 0, "CUDA Decode") \ 15 X(CudaHilbert, 1, "", 0, "CUDA Hilbert") \ 16 X(DASCompute, 2, "das", 1, "DAS") \ 17 X(Decode, 3, "decode", 1, "Decode") \ 18 X(DecodeFloat, 4, "", 1, "Decode (F32)") \ 19 X(DecodeFloatComplex, 5, "", 1, "Decode (F32C)") \ 20 X(Demodulate, 6, "demod", 1, "Demodulate") \ 21 X(MinMax, 7, "min_max", 0, "Min/Max") \ 22 X(Sum, 8, "sum", 0, "Sum") 23 24 typedef enum { 25 #define X(e, n, s, h, pn) ComputeShaderKind_##e = n, 26 COMPUTE_SHADERS 27 #undef X 28 ComputeShaderKind_Count 29 } ComputeShaderKind; 30 31 /* X(type, id, pretty name) */ 32 #define DECODE_TYPES \ 33 X(NONE, 0, "None") \ 34 X(HADAMARD, 1, "Hadamard") 35 36 /* X(type, id, pretty name) */ 37 #define IMAGE_PLANE_TAGS \ 38 X(XZ, 0, "XZ") \ 39 X(YZ, 1, "YZ") \ 40 X(XY, 2, "XY") \ 41 X(ARBITRARY, 3, "Arbitrary") 42 43 typedef enum { 44 #define X(type, id, pretty) IPT_ ##type = id, 45 IMAGE_PLANE_TAGS 46 #undef X 47 IPT_LAST 48 } ImagePlaneTag; 49 50 /* X(type, id, pretty name, fixed transmits) */ 51 #define DAS_TYPES \ 52 X(FORCES, 0, "FORCES", 1) \ 53 X(UFORCES, 1, "UFORCES", 0) \ 54 X(HERCULES, 2, "HERCULES", 1) \ 55 X(RCA_VLS, 3, "VLS", 0) \ 56 X(RCA_TPW, 4, "TPW", 0) \ 57 X(UHERCULES, 5, "UHERCULES", 0) \ 58 X(RACES, 6, "RACES", 1) \ 59 X(EPIC_FORCES, 7, "EPIC-FORCES", 1) \ 60 X(EPIC_UFORCES, 8, "EPIC-UFORCES", 0) \ 61 X(EPIC_UHERCULES, 9, "EPIC-UHERCULES", 0) \ 62 X(FLASH, 10, "Flash", 0) 63 64 #define DAS_LOCAL_SIZE_X 32 65 #define DAS_LOCAL_SIZE_Y 1 66 #define DAS_LOCAL_SIZE_Z 32 67 68 #define DAS_VOXEL_OFFSET_UNIFORM_LOC 2 69 #define DAS_CYCLE_T_UNIFORM_LOC 3 70 71 #define MAX_BEAMFORMED_SAVED_FRAMES 16 72 #define MAX_COMPUTE_SHADER_STAGES 16 73 74 /* TODO(rnp): actually use a substruct but generate a header compatible with MATLAB */ 75 /* X(name, type, size, gltype, glsize, comment) */ 76 #define BEAMFORMER_UI_PARAMS \ 77 X(output_min_coordinate, float, [4], vec4, , "/* [m] Back-Top-Left corner of output region */") \ 78 X(output_max_coordinate, float, [4], vec4, , "/* [m] Front-Bottom-Right corner of output region */") \ 79 X(output_points, uint32_t, [4], uvec4, , "/* Width * Height * Depth * (Frame Average Count) */") \ 80 X(sampling_frequency, float, , float, , "/* [Hz] */") \ 81 X(center_frequency, float, , float, , "/* [Hz] */") \ 82 X(speed_of_sound, float, , float, , "/* [m/s] */") \ 83 X(off_axis_pos, float, , float, , "/* [m] Position on screen normal to beamform in TPW/VLSHERCULES */") \ 84 X(beamform_plane, int32_t, , int, , "/* Plane to Beamform in TPW/VLS/HERCULES */") \ 85 X(f_number, float, , float, , "/* F# (set to 0 to disable) */") \ 86 X(interpolate, uint32_t, , bool, , "/* Perform Cubic Interpolation of RF Samples */") \ 87 X(coherency_weighting, uint32_t, , bool, , "/* Apply coherency weighting to output data */") 88 89 #define BEAMFORMER_PARAMS_HEAD_V0 \ 90 X(channel_mapping, uint16_t, [256], uvec4, [32], "/* Transducer Channel to Verasonics Channel */") \ 91 X(uforces_channels, uint16_t, [256], uvec4, [32], "/* Channels used for virtual UFORCES elements */") \ 92 X(focal_depths, float, [256], vec4, [64], "/* [m] Focal Depths for each transmit of a RCA imaging scheme*/") \ 93 X(transmit_angles, float, [256], vec4, [64], "/* [degrees] Transmit Angles for each transmit of a RCA imaging scheme*/") \ 94 X(xdc_transform, float, [16] , mat4, , "/* IMPORTANT: column major order */") \ 95 X(dec_data_dim, uint32_t, [4] , uvec4, , "/* Samples * Channels * Acquisitions; last element ignored */") \ 96 X(xdc_element_pitch, float, [2] , vec2, , "/* [m] Transducer Element Pitch {row, col} */") \ 97 X(rf_raw_dim, uint32_t, [2] , uvec2, , "/* Raw Data Dimensions */") \ 98 X(transmit_mode, int32_t, , int, , "/* Method/Orientation of Transmit */") \ 99 X(decode, uint32_t, , uint, , "/* Decode or just reshape data */") \ 100 X(das_shader_id, uint32_t, , uint, , "") \ 101 X(time_offset, float, , float, , "/* pulse length correction time [s] */") 102 103 #define BEAMFORMER_PARAMS_HEAD \ 104 X(xdc_transform, float, [16], mat4, , "/* IMPORTANT: column major order */") \ 105 X(dec_data_dim, uint32_t, [4] , uvec4, , "/* Samples * Channels * Acquisitions; last element ignored */") \ 106 X(xdc_element_pitch, float, [2] , vec2, , "/* [m] Transducer Element Pitch {row, col} */") \ 107 X(rf_raw_dim, uint32_t, [2] , uvec2, , "/* Raw Data Dimensions */") \ 108 X(transmit_mode, int32_t, , int, , "/* Method/Orientation of Transmit */") \ 109 X(decode, uint32_t, , uint, , "/* Decode or just reshape data */") \ 110 X(das_shader_id, uint32_t, , uint, , "") \ 111 X(time_offset, float, , float, , "/* pulse length correction time [s] */") 112 113 #define BEAMFORMER_PARAMS_TAIL \ 114 X(readi_group_id, uint32_t, , uint, , "/* Which readi group this data is from */") \ 115 X(readi_group_size, uint32_t, , uint, , "/* Size of readi transmit group */") 116 117 #define X(name, type, size, gltype, glsize, comment) type name size; 118 typedef struct { BEAMFORMER_UI_PARAMS } BeamformerUIParameters; 119 typedef struct { BEAMFORMER_PARAMS_HEAD } BeamformerParametersHead; 120 typedef struct { BEAMFORMER_PARAMS_TAIL } BeamformerParametersTail; 121 122 typedef struct { 123 BEAMFORMER_PARAMS_HEAD_V0 124 BEAMFORMER_UI_PARAMS 125 BEAMFORMER_PARAMS_TAIL 126 float _pad[2]; 127 } BeamformerParametersV0; 128 129 /* NOTE: This struct follows the OpenGL std140 layout. DO NOT modify unless you have 130 * read and understood the rules, particulary with regards to _member alignment_ */ 131 typedef struct { 132 BEAMFORMER_PARAMS_HEAD 133 BEAMFORMER_UI_PARAMS 134 BEAMFORMER_PARAMS_TAIL 135 float _pad[2]; 136 } BeamformerParameters; 137 #undef X 138 139 /* NOTE(rnp): keep this header importable for old C versions */ 140 #if __STDC_VERSION__ >= 201112L 141 _Static_assert((offsetof(BeamformerParameters, output_min_coordinate) & 15) == 0, 142 "BeamformerParameters.output_min_coordinate must lie on a 16 byte boundary"); 143 _Static_assert((sizeof(BeamformerParameters) & 15) == 0, 144 "sizeof(BeamformerParameters) must be a multiple of 16"); 145 #endif