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