File: fft_fragment_program_complex.glsl.frag.h

package info (click to toggle)
retroarch 1.7.3%2Bdfsg1-1.1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 49,188 kB
  • sloc: ansic: 600,492; cpp: 23,670; objc: 8,299; asm: 6,404; sh: 2,203; xml: 2,144; makefile: 1,867; python: 1,582; java: 941; perl: 393
file content (33 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "shaders_common.h"

static const char *fft_fragment_program_complex = GLSL_300(
   precision mediump float;
   precision highp int;
   precision highp usampler2D;
   precision highp isampler2D;

   in vec2 vTex;
   uniform usampler2D sTexture;
   uniform usampler2D sParameterTexture;
   uniform int uViewportOffset;
   out uvec2 FragColor;

   vec2 compMul(vec2 a, vec2 b) { return vec2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }

   void main() {
      uvec2 params = texture(sParameterTexture, vec2(vTex.x, 0.5)).rg;
      uvec2 coord  = uvec2((params.x >> 16u) & 0xffffu, params.x & 0xffffu);
      int ycoord   = int(gl_FragCoord.y) - uViewportOffset;
      vec2 twiddle = unpackHalf2x16(params.y);

      uvec2 x = texelFetch(sTexture, ivec2(int(coord.x), ycoord), 0).rg;
      uvec2 y = texelFetch(sTexture, ivec2(int(coord.y), ycoord), 0).rg;
      vec4 a = vec4(unpackHalf2x16(x.x), unpackHalf2x16(x.y));
      vec4 b = vec4(unpackHalf2x16(y.x), unpackHalf2x16(y.y));
      b.xy = compMul(b.xy, twiddle);
      b.zw = compMul(b.zw, twiddle);

      vec4 res = a + b;
      FragColor = uvec2(packHalf2x16(res.xy), packHalf2x16(res.zw));
   }
);