41 lines
789 B
Plaintext
41 lines
789 B
Plaintext
|
#version 450
|
||
|
#extension GL_EXT_buffer_reference : require
|
||
|
#extension GL_ARB_gpu_shader_int64 : require
|
||
|
|
||
|
layout(buffer_reference) buffer Node;
|
||
|
layout(buffer_reference) buffer Node
|
||
|
{
|
||
|
int value;
|
||
|
layout(offset = 16) Node next;
|
||
|
layout(offset = 32) Node prev;
|
||
|
};
|
||
|
|
||
|
layout(std430, set = 0, binding = 0) buffer LinkedList
|
||
|
{
|
||
|
restrict Node head1;
|
||
|
restrict Node head2;
|
||
|
};
|
||
|
|
||
|
void copy_node(restrict Node dst, restrict Node a, restrict Node b)
|
||
|
{
|
||
|
dst.value = a.value + b.value;
|
||
|
}
|
||
|
|
||
|
void overwrite_node(out Node dst, Node src)
|
||
|
{
|
||
|
dst = src;
|
||
|
}
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
restrict Node n = gl_WorkGroupID.x < 4u ? head1 : head2;
|
||
|
copy_node(n.next, head1, head2);
|
||
|
overwrite_node(n, head1);
|
||
|
int v = head2.value;
|
||
|
n.value = 20;
|
||
|
n.value = v * 10;
|
||
|
|
||
|
uint64_t uptr = uint64_t(head2.next);
|
||
|
Node unode = Node(uptr);
|
||
|
}
|