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