SPIRV-Cross/shaders/vulkan/comp/buffer-reference.nocompat.vk.comp
Hans-Kristian Arntzen 2cc374a0c8 GLSL: Implement GL_EXT_buffer_reference.
Buffer objects can contain arbitrary pointers to blocks.
We can also implement ConvertPtrToU and ConvertUToPtr.
The latter can cast a uint64_t to any type as it pleases,
so we will need to generate fake buffer reference blocks to be able to
cast the type.
2019-04-26 11:43:51 +02:00

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);
}