beamformer_parameters.h (9177B)
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 * [ ]: 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 /* X(enumarant, number, shader file name, needs header, pretty name) */ 14 #define COMPUTE_SHADERS \ 15 X(CudaDecode, 0, "", 0, "CUDA Decode") \ 16 X(CudaHilbert, 1, "", 0, "CUDA Hilbert") \ 17 X(DASCompute, 2, "das", 1, "DAS") \ 18 X(Decode, 3, "decode", 1, "Decode") \ 19 X(DecodeFloat, 4, "", 1, "Decode (F32)") \ 20 X(DecodeFloatComplex, 5, "", 1, "Decode (F32C)") \ 21 X(Demodulate, 6, "demod", 1, "Demodulate") \ 22 X(MinMax, 7, "min_max", 0, "Min/Max") \ 23 X(Sum, 8, "sum", 0, "Sum") 24 25 typedef enum { 26 #define X(e, n, s, h, pn) BeamformerShaderKind_##e = n, 27 COMPUTE_SHADERS 28 #undef X 29 BeamformerShaderKind_Render3D, 30 BeamformerShaderKind_Count, 31 32 BeamformerShaderKind_ComputeCount = BeamformerShaderKind_Render3D, 33 } BeamformerShaderKind; 34 35 typedef struct { 36 /* NOTE(rnp): this wants to be iterated on both dimensions. it depends entirely on which 37 * visualization method you want to use. the coalescing function wants both directions */ 38 float times[32][BeamformerShaderKind_Count]; 39 float rf_time_deltas[32]; 40 } BeamformerComputeStatsTable; 41 42 /* X(type, id, pretty name) */ 43 #define DECODE_TYPES \ 44 X(NONE, 0, "None") \ 45 X(HADAMARD, 1, "Hadamard") 46 47 /* X(type, id, pretty name) */ 48 #define BEAMFORMER_VIEW_PLANE_TAG_LIST \ 49 X(XZ, 0, "XZ") \ 50 X(YZ, 1, "YZ") \ 51 X(XY, 2, "XY") \ 52 X(Arbitrary, 3, "Arbitrary") 53 54 typedef enum { 55 #define X(type, id, pretty) BeamformerViewPlaneTag_##type = id, 56 BEAMFORMER_VIEW_PLANE_TAG_LIST 57 #undef X 58 BeamformerViewPlaneTag_Count, 59 } BeamformerViewPlaneTag; 60 61 /* X(type, id, pretty name, fixed transmits) */ 62 #define DAS_TYPES \ 63 X(FORCES, 0, "FORCES", 1) \ 64 X(UFORCES, 1, "UFORCES", 0) \ 65 X(HERCULES, 2, "HERCULES", 1) \ 66 X(RCA_VLS, 3, "VLS", 0) \ 67 X(RCA_TPW, 4, "TPW", 0) \ 68 X(UHERCULES, 5, "UHERCULES", 0) \ 69 X(RACES, 6, "RACES", 1) \ 70 X(EPIC_FORCES, 7, "EPIC-FORCES", 1) \ 71 X(EPIC_UFORCES, 8, "EPIC-UFORCES", 0) \ 72 X(EPIC_UHERCULES, 9, "EPIC-UHERCULES", 0) \ 73 X(FLASH, 10, "Flash", 0) 74 75 #define DECODE_LOCAL_SIZE_X 4 76 #define DECODE_LOCAL_SIZE_Y 1 77 #define DECODE_LOCAL_SIZE_Z 16 78 79 #define DECODE_FIRST_PASS_UNIFORM_LOC 1 80 81 #define DAS_LOCAL_SIZE_X 32 82 #define DAS_LOCAL_SIZE_Y 1 83 #define DAS_LOCAL_SIZE_Z 32 84 85 #define DAS_VOXEL_OFFSET_UNIFORM_LOC 2 86 #define DAS_CYCLE_T_UNIFORM_LOC 3 87 88 #define MIN_MAX_MIPS_LEVEL_UNIFORM_LOC 1 89 #define SUM_PRESCALE_UNIFORM_LOC 1 90 91 #define MAX_BEAMFORMED_SAVED_FRAMES 16 92 #define MAX_COMPUTE_SHADER_STAGES 16 93 94 /* TODO(rnp): actually use a substruct but generate a header compatible with MATLAB */ 95 /* X(name, type, size, gltype, glsize, comment) */ 96 #define BEAMFORMER_UI_PARAMS \ 97 X(output_min_coordinate, float, [4], vec4, , "/* [m] Back-Top-Left corner of output region */") \ 98 X(output_max_coordinate, float, [4], vec4, , "/* [m] Front-Bottom-Right corner of output region */") \ 99 X(output_points, uint32_t, [4], uvec4, , "/* Width * Height * Depth * (Frame Average Count) */") \ 100 X(sampling_frequency, float, , float, , "/* [Hz] */") \ 101 X(center_frequency, float, , float, , "/* [Hz] */") \ 102 X(speed_of_sound, float, , float, , "/* [m/s] */") \ 103 X(off_axis_pos, float, , float, , "/* [m] Position on screen normal to beamform in TPW/VLSHERCULES */") \ 104 X(beamform_plane, int32_t, , int, , "/* Plane to Beamform in TPW/VLS/HERCULES */") \ 105 X(f_number, float, , float, , "/* F# (set to 0 to disable) */") \ 106 X(interpolate, uint32_t, , bool, , "/* Perform Cubic Interpolation of RF Samples */") \ 107 X(coherency_weighting, uint32_t, , bool, , "/* Apply coherency weighting to output data */") 108 109 #define BEAMFORMER_PARAMS_HEAD_V0 \ 110 X(channel_mapping, uint16_t, [256], uvec4, [32], "/* Transducer Channel to Verasonics Channel */") \ 111 X(uforces_channels, uint16_t, [256], uvec4, [32], "/* Channels used for virtual UFORCES elements */") \ 112 X(focal_depths, float, [256], vec4, [64], "/* [m] Focal Depths for each transmit of a RCA imaging scheme*/") \ 113 X(transmit_angles, float, [256], vec4, [64], "/* [degrees] Transmit Angles for each transmit of a RCA imaging scheme*/") \ 114 X(xdc_transform, float, [16] , mat4, , "/* IMPORTANT: column major order */") \ 115 X(dec_data_dim, uint32_t, [4] , uvec4, , "/* Samples * Channels * Acquisitions; last element ignored */") \ 116 X(xdc_element_pitch, float, [2] , vec2, , "/* [m] Transducer Element Pitch {row, col} */") \ 117 X(rf_raw_dim, uint32_t, [2] , uvec2, , "/* Raw Data Dimensions */") \ 118 X(transmit_mode, int32_t, , int, , "/* Method/Orientation of Transmit */") \ 119 X(decode, uint32_t, , uint, , "/* Decode or just reshape data */") \ 120 X(das_shader_id, uint32_t, , uint, , "") \ 121 X(time_offset, float, , float, , "/* pulse length correction time [s] */") 122 123 #define BEAMFORMER_PARAMS_HEAD \ 124 X(xdc_transform, float, [16], mat4, , "/* IMPORTANT: column major order */") \ 125 X(dec_data_dim, uint32_t, [4] , uvec4, , "/* Samples * Channels * Acquisitions; last element ignored */") \ 126 X(xdc_element_pitch, float, [2] , vec2, , "/* [m] Transducer Element Pitch {row, col} */") \ 127 X(rf_raw_dim, uint32_t, [2] , uvec2, , "/* Raw Data Dimensions */") \ 128 X(transmit_mode, int32_t, , int, , "/* Method/Orientation of Transmit */") \ 129 X(decode, uint32_t, , uint, , "/* Decode or just reshape data */") \ 130 X(das_shader_id, uint32_t, , uint, , "") \ 131 X(time_offset, float, , float, , "/* pulse length correction time [s] */") 132 133 #define BEAMFORMER_PARAMS_TAIL \ 134 X(readi_group_id, uint32_t, , uint, , "/* Which readi group this data is from */") \ 135 X(readi_group_size, uint32_t, , uint, , "/* Size of readi transmit group */") 136 137 #define X(name, type, size, gltype, glsize, comment) type name size; 138 typedef struct { BEAMFORMER_UI_PARAMS } BeamformerUIParameters; 139 typedef struct { BEAMFORMER_PARAMS_HEAD } BeamformerParametersHead; 140 typedef struct { BEAMFORMER_PARAMS_TAIL } BeamformerParametersTail; 141 142 typedef struct { 143 BEAMFORMER_PARAMS_HEAD_V0 144 BEAMFORMER_UI_PARAMS 145 BEAMFORMER_PARAMS_TAIL 146 float _pad[2]; 147 } BeamformerParametersV0; 148 149 /* NOTE: This struct follows the OpenGL std140 layout. DO NOT modify unless you have 150 * read and understood the rules, particulary with regards to _member alignment_ */ 151 typedef struct { 152 BEAMFORMER_PARAMS_HEAD 153 BEAMFORMER_UI_PARAMS 154 BEAMFORMER_PARAMS_TAIL 155 float _pad[2]; 156 } BeamformerParameters; 157 #undef X 158 159 /* NOTE(rnp): keep this header importable for old C versions */ 160 #if __STDC_VERSION__ >= 201112L 161 _Static_assert((offsetof(BeamformerParameters, output_min_coordinate) & 15) == 0, 162 "BeamformerParameters.output_min_coordinate must lie on a 16 byte boundary"); 163 _Static_assert((sizeof(BeamformerParameters) & 15) == 0, 164 "sizeof(BeamformerParameters) must be a multiple of 16"); 165 #endif 166 167 #define BEAMFORMER_LIVE_IMAGING_DIRTY_FLAG_LIST \ 168 X(ImagePlaneOffsets, 0) \ 169 X(TransmitPower, 1) \ 170 X(TGCControlPoints, 2) \ 171 X(SaveData, 3) \ 172 X(StopImaging, 4) 173 /* NOTE(rnp): if this exceeds 32 you need to fix the flag handling code */ 174 175 typedef struct { 176 uint32_t active; 177 uint32_t save_enabled; 178 uint32_t save_active; 179 float transmit_power; 180 float image_plane_offsets[BeamformerViewPlaneTag_Count]; 181 float tgc_control_points[8]; 182 } BeamformerLiveImagingParameters;