gKit2 light
Loading...
Searching...
No Matches
histogram2.glsl
1
2// version avec memoire partagee...
3
4#version 430
5
6#ifdef COMPUTE_SHADER
7
8layout(std430, binding= 0) coherent buffer HistogramData
9{
10 int histogram[16];
11};
12
13// image resultat
14layout(binding= 0, rgba8) readonly uniform image2D image;
15
16shared int group_histogram[16];
17
18layout(local_size_x= 8, local_size_y= 8) in;
19void main( )
20{
21 vec4 pixel= imageLoad(image, ivec2(gl_GlobalInvocationID.xy));
22
23 // calculer la cellule de l'histogramme pour le pixel
24 float grey= (pixel.r + pixel.g + pixel.b) / 3; // entre 0 et 1
25 int bin= int(grey * 15);
26
27 uint ID= gl_LocalInvocationIndex;
28 if(ID < 16)
29 group_histogram[ID]= 0;
30
31 // attend que tous les sous groupes s'executent
32 barrier();
33
34 atomicAdd(group_histogram[bin], 1);
35
36 // attend que tous les sous groupes s'executent
37 barrier();
38
39 if(ID < 16)
40 atomicAdd(histogram[ID], group_histogram[ID]);
41}
42
43#endif
vecteur generique 4d, ou 3d homogene, utilitaire.
Definition vec.h:192