gKit2 light
Toggle main menu visibility
Loading...
Searching...
No Matches
gkit2_tutos
M2
aaquads_count.glsl
1
2
#version 430
3
4
#ifdef COMPUTE_SHADER
5
6
layout(binding= 0, r32ui) writeonly uniform uimage2D counters;
// 1024*1024
7
layout(binding= 1, r32ui) readonly uniform uimage2D primitives;
// 8192*8192
8
9
shared uint group_primitives[64];
10
shared uint count;
11
12
layout(local_size_x= 8, local_size_y= 8) in;
13
void
main( )
14
{
15
if
(gl_LocalInvocationIndex == 0)
16
count= 0;
17
uint local_primitive= uint( imageLoad(primitives, ivec2(gl_GlobalInvocationID)) );
18
group_primitives[gl_LocalInvocationIndex]= local_primitive;
19
barrier();
20
21
// compter le nombre de triangles dans un bloc 8x8 de pixels / 1 groupe de threads
22
// beurk o(n*n)...
23
for
(
int
i= 0; i < 64; i++)
24
{
25
uint primitive= group_primitives[i];
26
if
(gl_LocalInvocationIndex == 0 && primitive > 0)
27
count++;
28
29
if
(local_primitive == primitive)
30
group_primitives[gl_LocalInvocationIndex]= 0;
31
barrier();
32
}
33
34
if
(gl_LocalInvocationIndex == 0)
35
imageStore(counters, ivec2(gl_WorkGroupID), uvec4( count ));
36
}
37
#endif
Generated on
for gKit2 light by
1.17.0