lpf.glsl (2309B)
1 /* See LICENSE for license details. */ 2 #version 460 core 3 layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in; 4 5 layout(std430, binding = 1) readonly restrict buffer buffer_1 { 6 vec2 in_data[]; 7 }; 8 9 layout(std430, binding = 2) writeonly restrict buffer buffer_2 { 10 vec2 out_data[]; 11 }; 12 13 layout(std140, binding = 0) uniform parameters { 14 uvec4 channel_mapping[64]; /* Transducer Channel to Verasonics Channel */ 15 uvec4 uforces_channels[32]; /* Channels used for virtual UFORCES elements */ 16 vec4 lpf_coefficients[16]; /* Low Pass Filter Cofficients */ 17 uvec4 dec_data_dim; /* Samples * Channels * Acquisitions; last element ignored */ 18 uvec4 output_points; /* Width * Height * Depth; last element ignored */ 19 uvec2 rf_raw_dim; /* Raw Data Dimensions */ 20 vec2 output_min_xz; /* [m] Top left corner of output region */ 21 vec2 output_max_xz; /* [m] Bottom right corner of output region */ 22 vec2 xdc_min_xy; /* [m] Min center of transducer elements */ 23 vec2 xdc_max_xy; /* [m] Max center of transducer elements */ 24 uint channel_offset; /* Offset into channel_mapping: 0 or 128 (rows or columns) */ 25 uint lpf_order; /* Order of Low Pass Filter */ 26 float speed_of_sound; /* [m/s] */ 27 float sampling_frequency; /* [Hz] */ 28 float center_frequency; /* [Hz] */ 29 float focal_depth; /* [m] */ 30 float time_offset; /* pulse length correction time [s] */ 31 uint uforces; /* mode is UFORCES (1) or FORCES (0) */ 32 float off_axis_pos; /* Where on the 3rd axis to render the image (Hercules only) */ 33 }; 34 35 void main() 36 { 37 uint time_sample = gl_GlobalInvocationID.x; 38 uint channel = gl_GlobalInvocationID.y; 39 uint acq = gl_GlobalInvocationID.z; 40 41 /* NOTE: offsets for storing the results in the output data */ 42 uint stride = dec_data_dim.x * dec_data_dim.y; 43 uint off = dec_data_dim.x * channel + stride * acq + time_sample; 44 45 vec2 sum = vec2(0); 46 for (int i = 0; i <= lpf_order; i++) { 47 vec2 data; 48 /* NOTE: make sure data samples come from the same acquisition */ 49 if (time_sample > i) data = in_data[off - i]; 50 else data = vec2(0); 51 sum += lpf_coefficients[i / 4][i % 4] * data; 52 } 53 out_data[off] = sum; 54 }