8 layout(std430, binding= 0) coherent buffer HistogramData
14 layout(binding= 0, rgba8) readonly uniform image2D image;
16 shared
int group_histogram[16];
18 layout(local_size_x= 8, local_size_y= 8) in;
21 uint ID= gl_LocalInvocationIndex;
23 group_histogram[ID]= 0;
28 int local_histogram[16]=
int[16](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
30 for(
int i= 0; i < 16; i++)
32 ivec2 offset= ivec2((i % 4), (i / 4));
33 vec4 pixel= imageLoad(image, ivec2(gl_WorkGroupID.xy)*32 + ivec2(gl_LocalInvocationID.xy) + offset*8);
36 float grey= (pixel.r + pixel.g + pixel.b) / 3;
37 int bin= int(grey * 15);
39 local_histogram[bin]++;
42 for(
int i= 0; i < 16; i++)
43 if(local_histogram[i] > 0)
44 atomicAdd(group_histogram[i], local_histogram[i]);
50 atomicAdd(histogram[ID], group_histogram[ID]);
vecteur generique 4d, ou 3d homogene, utilitaire.