+ // Because of the memory layout (see below) and because we use offsets,
+ // the support texture values for many consecutive values will be
+ // the same. Thus, we can store a smaller texture (giving a small
+ // performance boost) and just sample it with NEAREST. Also, this
+ // counteracts any precision issues we might get from linear
+ // interpolation.
+ glActiveTexture(GL_TEXTURE0 + *sampler_num);
+ check_error();
+ glBindTexture(GL_TEXTURE_2D, tex);
+ check_error();
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ check_error();
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ check_error();
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ check_error();
+
+ int input_size = (direction == VERTICAL) ? input_height : input_width;
+ if (last_fft_size != fft_size ||
+ last_direction != direction ||
+ last_pass_number != pass_number ||
+ last_inverse != inverse ||
+ last_input_size != input_size) {
+ generate_support_texture();
+ }
+
+ uniform_support_tex = *sampler_num;
+ ++*sampler_num;
+
+ assert(input_size % fft_size == 0);
+ uniform_num_repeats = input_size / fft_size;
+}
+
+void FFTPassEffect::generate_support_texture()
+{
+ int input_size = (direction == VERTICAL) ? input_height : input_width;
+