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