Untitled
Loading...
Searching...
No Matches
elements_prefix.comp
Go to the documentation of this file.
1
2#version 430 core
3
4layout (local_size_x = 128, local_size_y = 1, local_size_z = 1) in;
5
7 uint count;
8 uint instanceCount;
9 uint firstIndex;
10 uint baseVertex;
11 uint baseInstance;
12 uint instanceOffset; // the amount of instances pushed this frame
13};
14
15layout(std430, binding = 5) buffer DrawElementsData {
16
18};
19
20layout(std430, binding = 6) buffer DrawElementsOutData {
21
23};
24
25uniform uint n;
26
27shared uint temp[1024];
28
29void main()
30{
31
32 uint id = gl_GlobalInvocationID.x;
33 bool worker = (id < n);
34 int pin = 1;
35 int pout = 0;
36 // if (id >= n) return;
37
38 if (id < n)
39 {
40 temp[id] = (id > 0) ? in_arr[id - 1].instanceOffset : 0;
41
42 }
43 else
44 {
45 temp[id] = 0;
46 }
47 // temp[id] = in_arr[id].instanceCount;
48
49 memoryBarrierShared();
50 barrier();
51
52 for (int i = 1; i < n; i *= 2)
53 {
54
55 pout = 1 - pout;
56 pin = 1 - pout;
57
58 uint val = 0;
59 if (id >= i)
60 {
61 val = temp[id - i];
62 // temp[pout * n + id] += temp[pin * n + id - i];
63 }
64 else
65 {
66 // temp[pout * n + id] = temp[pin * n + id];
67 }
68 memoryBarrierShared();
69 barrier();
70 temp[id] += val;
71
72
73 memoryBarrierShared();
74 barrier();
75 }
76
77 out_arr[id] = in_arr[id];
78 // out_arr[id].baseInstance = temp[pout * n + id];
79 out_arr[id].baseInstance = temp[id];
80 in_arr[id].instanceCount = 0;
81 in_arr[id].baseInstance = 0;
82 in_arr[id].instanceOffset = 0;
83
84
85}
layout(local_size_x=16, local_size_y=16) in
void main()
uniform uint n
shared uint temp[1024]
DrawArraysIndirect commands are used for non-static meshes.