Space Sim
Loading...
Searching...
No Matches
next.comp
Go to the documentation of this file.
1
2#version 440
8#define WORKGROUP_SIZE 128
9#define RADIX_SORT_BINS 128
10#define SUBGROUP_SIZE 32
11
12#define BODY_COUNT 15000
13#define MAX_NODES 45000
14layout (local_size_x = WORKGROUP_SIZE) in;
15struct Node {
16 vec4 com_m;
17 // min and size
18 vec4 min;
19 // max and next
20 vec3 max;
21 int next;
22 // left child, right child, parent, depth
23 ivec4 lrpd;
24};
25#define MAX_DEPTH 64
26layout(std430, binding=4) buffer NodeData {
27 uint ready_queue[MAX_NODES];
28 uint children_remaining[MAX_NODES];
29 uint depth_offsets[MAX_DEPTH+1];
30 uint pad0;
31 uint pad1;
32 uint pad2;
33 // center of mass and mass
34 vec4 com_m[MAX_NODES];
35 // left right
36 vec4 lrsn[MAX_NODES];
37 // min and parent
38 vec4 nmin[MAX_NODES];
39 // max and depth
40 vec4 nmax[MAX_NODES];
41};
42uniform int depth;
43uniform int max_depth;
44uniform bool first_iter;
46uniform uint current_amt;
47
48void main()
49{
50 uint id = gl_GlobalInvocationID.x;
51 if (id >= MAX_NODES) return;
52
53
54 int d = floatBitsToInt(nmax[id].w);
55
56 // set all child node's "next" to the parent's right node
57 // this must be done from the top-down (root first and then each depth subsequently)
58 // if current node's depth isn't the current depth
59 if (d < depth || d == 999 || d > depth) {
60 return;
61 }
62
63 int p = floatBitsToInt(nmin[id].w);
64
65 // if parent
66 if (p != -1)
67 {
68
69 // check parent lrsn (left right radius next)
70 vec4 lr = lrsn[p];
71 int left = floatBitsToInt(lr.x);
72 int right = floatBitsToInt(lr.y);
73 int n = floatBitsToInt(lr.w);
74 // if we are our parent's left child, set our next to its right child
75 if (left == id)
76 {
77 lrsn[id].w = lr.y;
78 }
79 else
80 {
81 // else set it to our parent next
82 lrsn[id].w = lr.w;
83 }
84 }
85 else
86 {
87 // if no parent, set parent right to -1
88 lrsn[id].w = intBitsToFloat(-1);
89 }
90
91}
layout(local_size_x=16, local_size_y=16, local_size_z=1) in
uniform int depth
Definition com22.comp:76
int main(int argc, char *argv[])
Definition main.c:1726
vec3 max
Definition com22.comp:49
vec4 com_m
Definition com22.comp:45
int next
Definition com22.comp:50
ivec4 lrpd
Definition com22.comp:52
vec4 min
Definition com22.comp:47
Definition types.h:109
uniform int max_depth
Definition next.comp:43
uniform uint current_amt
Definition next.comp:46
uniform bool first_iter
Definition next.comp:44
uniform uint current_depth_offset
Definition next.comp:45
float w
Definition types.h:47
float x
Definition types.h:47
#define WORKGROUP_SIZE
Definition types.h:171
#define MAX_DEPTH
Definition types.h:154
float y
Definition types.h:47
#define MAX_NODES
Definition types.h:40
Definition types.h:49
Definition main.h:5
Definition types.h:47