Skip to content

Commit

Permalink
WIP: adding vulkan kernels
Browse files Browse the repository at this point in the history
  • Loading branch information
gboisse committed Jan 22, 2018
1 parent 353d828 commit 5ed9faf
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 2 deletions.
71 changes: 70 additions & 1 deletion RadeonRays/src/kernels/GLSL/bvh2.comp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,73 @@
// THE SOFTWARE.
//

layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
#define INVALID_ADDR 0xffffffffu
#define INTERNAL_NODE(node) ((node).addr_left != INVALID_ADDR)

#define GROUP_SIZE 64
#define STACK_SIZE 32
#define LDS_STACK_SIZE 8

struct BvhNode
{
vec3 aabb_left_min_or_v0;
uint addr_left;
vec3 aabb_left_max_or_v1;
uint mesh_id;
vec3 aabb_right_min_or_v2;
uint addr_right;
vec3 aabb_right_max;
uint prim_id;
};

struct Intersection
{
int shape_id;
int prim_id;
ivec2 padding;
vec4 uvwt;
};

struct ray
{
vec4 o;
vec4 d;
ivec2 extra;
ivec2 padding;
};

layout(std140, binding = 0) buffer restrict readonly NodesBlock
{
BvhNode Nodes[];
};

layout(std140, binding = 1) buffer restrict readonly RaysBlock
{
ray Rays[];
};

layout(std140, binding = 2) buffer restrict readonly NumraysBlock
{
int Numrays;
};

layout(std430, binding = 3) buffer StackBlock
{
int Stack[];
};

layout(std430, binding = 4) buffer restrict writeonly HitsBlock
{
Intersection Hits[];
};

layout(std430, binding = 4) buffer restrict writeonly HitsResults
{
int Hitresults[];
};

layout(local_size_x = GROUP_SIZE, local_size_y = 1, local_size_z = 1) in;

shared uint lds_stack[GROUP_SIZE * LDS_STACK_SIZE];

// TODO: implement traversal kernels (gboisse)
72 changes: 71 additions & 1 deletion RadeonRays/src/kernels/GLSL/bvh2_fp16.comp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#version 430
#extension GL_AMD_gpu_shader_half_float : require

// Note Anvil define system assumes first line is alway a #version so don't rearrange

Expand All @@ -24,4 +25,73 @@
// THE SOFTWARE.
//

layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
#define INVALID_ADDR 0xffffffffu
#define INTERNAL_NODE(node) ((node).addr0 != INVALID_ADDR)

#define GROUP_SIZE 64
#define STACK_SIZE 32
#define LDS_STACK_SIZE 16

struct BvhNode
{
uvec3 aabb01_min_or_v0;
uint addr0;
uvec3 aabb01_max_or_v1;
uint addr1_or_mesh_id;
uvec3 aabb23_min_or_v2;
uint addr2_or_prim_id;
uvec3 aabb23_max;
uint addr3;
};

struct Intersection
{
int shape_id;
int prim_id;
ivec2 padding;
vec4 uvwt;
};

struct ray
{
vec4 o;
vec4 d;
ivec2 extra;
ivec2 padding;
};

layout(std140, binding = 0) buffer restrict readonly NodesBlock
{
BvhNode Nodes[];
};

layout(std140, binding = 1) buffer restrict readonly RaysBlock
{
ray Rays[];
};

layout(std140, binding = 2) buffer restrict readonly NumraysBlock
{
int Numrays;
};

layout(std430, binding = 3) buffer StackBlock
{
int Stack[];
};

layout(std430, binding = 4) buffer restrict writeonly HitsBlock
{
Intersection Hits[];
};

layout(std430, binding = 4) buffer restrict writeonly HitsResults
{
int Hitresults[];
};

layout(local_size_x = GROUP_SIZE, local_size_y = 1, local_size_z = 1) in;

shared uint lds_stack[GROUP_SIZE * LDS_STACK_SIZE];

// TODO: implement traversal kernels (gboisse)

0 comments on commit 5ed9faf

Please sign in to comment.