Space Sim
Loading...
Searching...
No Matches
bit_reversal.comp
Go to the documentation of this file.
1#version 440
2
3layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
4layout(rgba32f, binding = 0) readonly uniform image2D inIMG;
5layout(rgba32f, binding = 1) writeonly uniform image2D outIMG;
6
12
13#define N 128
14
15uint reverseBits(uint x, uint log2N)
16{
17 uint n = 0;
18 for (uint i = 0; i < log2N; i++)
19 {
20 n = (n << 1) | (x & 1);
21 x >>= 1;
22 }
23 return n;
24}
25uniform int log2N;
26void main()
27{
28 uint x = gl_GlobalInvocationID.x;
29 uint y = gl_GlobalInvocationID.y;
30 if (x >= N || y >= N) return;
31 uint rx = reverseBits(x, log2N);
32 uint ry = reverseBits(y, log2N);
33
34 vec4 val = imageLoad(inIMG, ivec2(rx, ry));
35 imageStore(outIMG, ivec2(x, y), val);
36}
#define N
layout(local_size_x=16, local_size_y=16, local_size_z=1) in
uniform int log2N
uint reverseBits(uint x, uint log2N)
int main(int argc, char *argv[])
Definition main.c:1726
Definition types.h:47