Commit: 4fbadd677b91a6e2b464d87b0a2d6ad88255681e
Parent: e31466cec4aab2bef07643414e1d20d21a95b9e7
Author: Randy Palamar
Date: Sun, 2 Nov 2025 08:03:20 -0700
shaders/filter: drop the SamplingMode optimization
With LDS this no longer gives any performance benefit (tested for
both 4X and 2X)
Diffstat:
4 files changed, 7 insertions(+), 34 deletions(-)
diff --git a/beamformer.c b/beamformer.c
@@ -556,7 +556,6 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb)
BeamformerShaderFilterBakeParameters *fb = &sd->bake.Filter;
fb->filter_length = (u32)f->length;
- fb->sampling_mode = pb->parameters.sampling_mode;
if (demod) sd->bake.flags |= BeamformerShaderFilterFlags_Demodulate;
if (f->parameters.complex) sd->bake.flags |= BeamformerShaderFilterFlags_ComplexFilter;
if (first) sd->bake.flags |= BeamformerShaderFilterFlags_MapChannels;
diff --git a/beamformer.meta b/beamformer.meta
@@ -78,7 +78,6 @@
@Shader(filter.glsl) Filter
{
@Enumeration(DataKind)
- @Enumeration(SamplingMode)
@Flags([ComplexFilter MapChannels])
@Bake
@@ -92,7 +91,6 @@
@BakeInt(OutputSampleStride output_sample_stride )
@BakeInt(OutputTransmitStride output_transmit_stride)
@BakeInt(SampleCount sample_count )
- @BakeInt(SamplingMode sampling_mode )
@BakeFloat(DemodulationFrequency demodulation_frequency)
@BakeFloat(SamplingFrequency sampling_frequency )
}
diff --git a/generated/beamformer.meta.c b/generated/beamformer.meta.c
@@ -112,7 +112,6 @@ typedef struct {
u32 output_sample_stride;
u32 output_transmit_stride;
u32 sample_count;
- u32 sampling_mode;
f32 demodulation_frequency;
f32 sampling_frequency;
} BeamformerShaderFilterBakeParameters;
@@ -270,7 +269,7 @@ read_only global u8 beamformer_shader_flag_strings_count[] = {
read_only global i32 *beamformer_shader_header_vectors[] = {
(i32 []){0, 1},
- (i32 []){0, 3},
+ (i32 []){0},
(i32 []){4, 0, 5, 2},
0,
0,
@@ -279,7 +278,7 @@ read_only global i32 *beamformer_shader_header_vectors[] = {
read_only global i32 beamformer_shader_header_vector_lengths[] = {
2,
- 2,
+ 1,
4,
0,
0,
@@ -308,7 +307,6 @@ read_only global s8 *beamformer_shader_bake_parameter_names[] = {
s8_comp("OutputSampleStride"),
s8_comp("OutputTransmitStride"),
s8_comp("SampleCount"),
- s8_comp("SamplingMode"),
s8_comp("DemodulationFrequency"),
s8_comp("SamplingFrequency"),
},
@@ -334,7 +332,7 @@ read_only global s8 *beamformer_shader_bake_parameter_names[] = {
read_only global u8 *beamformer_shader_bake_parameter_is_float[] = {
(u8 []){0, 0, 0, 0, 0, 0, 0, 0, 0},
- (u8 []){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
+ (u8 []){0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
(u8 []){0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1},
0,
0,
@@ -343,7 +341,7 @@ read_only global u8 *beamformer_shader_bake_parameter_is_float[] = {
read_only global i32 beamformer_shader_bake_parameter_counts[] = {
9,
- 12,
+ 11,
13,
0,
0,
diff --git a/shaders/filter.glsl b/shaders/filter.glsl
@@ -43,30 +43,8 @@ vec2 complex_mul(vec2 a, vec2 b)
#if Demodulate
vec2 rotate_iq(vec2 iq, uint index)
{
- vec2 result;
- switch (SamplingMode) {
- case SamplingMode_4X:{
- // fs = 2 * fd
- // arg = PI * index
- // cos -> 1 -1 1 -1
- // sin -> 0 0 0 0
- const float scales[2] = {1, -1};
- result = scales[index & 1u] * iq;
- }break;
- case SamplingMode_2X:{
- // fs = fd
- // arg = 2 * PI * index
- // cos -> 1 1 1 1
- // sin -> 0 0 0 0
- result = iq;
- }break;
- default:{
- float arg = radians(360) * DemodulationFrequency * index / SamplingFrequency;
- mat2 phasor = mat2(cos(arg), -sin(arg),
- sin(arg), cos(arg));
- result = phasor * iq;
- }break;
- }
+ float arg = radians(360) * DemodulationFrequency * index / SamplingFrequency;
+ vec2 result = complex_mul(iq, vec2(cos(arg), -sin(arg)));
return result;
}
#endif
@@ -110,7 +88,7 @@ void main()
rf[index] = SAMPLE_TYPE(0);
} else {
#if Demodulate
- rf[index] = scale * rotate_iq(sample_rf(in_offset + index) * vec2(1, -1), -index);
+ rf[index] = scale * rotate_iq(sample_rf(in_offset + index) * vec2(1, -1), index);
#else
rf[index] = sample_rf(in_offset + index);
#endif