Untitled
Toggle main menu visibility
Loading...
Searching...
No Matches
elements_prefix.comp
Go to the documentation of this file.
1
2
#version 430 core
3
4
layout
(local_size_x = 128, local_size_y = 1, local_size_z = 1) in;
5
6
struct
DrawElementsIndirectCommand
{
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
15
layout
(std430, binding = 5) buffer DrawElementsData {
16
17
DrawElementsIndirectCommand
in_arr[];
18
};
19
20
layout
(std430, binding = 6) buffer DrawElementsOutData {
21
22
DrawElementsIndirectCommand
out_arr[];
23
};
24
25
uniform uint
n
;
26
27
shared uint
temp
[1024];
28
29
void
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
layout(local_size_x=16, local_size_y=16) in
main
void main()
Definition
audio_probe_bake.comp:465
n
uniform uint n
Definition
elements_prefix.comp:25
temp
shared uint temp[1024]
Definition
elements_prefix.comp:27
DrawElementsIndirectCommand
DrawArraysIndirect commands are used for non-static meshes.
Definition
engine_types.h:857
src
render
elements_prefix.comp
Generated by
1.18.0