Skip to content

Commit

Permalink
Fixed naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
gboisse committed Jan 23, 2018
1 parent 5e44473 commit ffe35a2
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 104 deletions.
80 changes: 40 additions & 40 deletions RadeonRays/src/intersector/intersector_lds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace RadeonRays

IntersectorLDS::IntersectorLDS(Calc::Device *device)
: Intersector(device)
, m_gpuData(new GpuData(device))
, m_gpudata(new GpuData(device))
{
std::string buildopts;
#ifdef RR_RAY_MASK
Expand All @@ -108,49 +108,49 @@ namespace RadeonRays

int numheaders = sizeof(headers) / sizeof(const char *);

m_gpuData->bvh_prog.executable = m_device->CompileExecutable("../RadeonRays/src/kernels/CL/intersect_bvh2_lds.cl", headers, numheaders, buildopts.c_str());
m_gpuData->qbvh_prog.executable = m_device->CompileExecutable("../RadeonRays/src/kernels/CL/intersect_bvh2_lds_fp16.cl", headers, numheaders, buildopts.c_str());
m_gpudata->bvh_prog.executable = m_device->CompileExecutable("../RadeonRays/src/kernels/CL/intersect_bvh2_lds.cl", headers, numheaders, buildopts.c_str());
m_gpudata->qbvh_prog.executable = m_device->CompileExecutable("../RadeonRays/src/kernels/CL/intersect_bvh2_lds_fp16.cl", headers, numheaders, buildopts.c_str());
}
else
{
assert(device->GetPlatform() == Calc::Platform::kVulkan);
m_gpuData->bvh_prog.executable = m_device->CompileExecutable("../RadeonRays/src/kernels/GLSL/bvh2.comp", nullptr, 0, buildopts.c_str());
m_gpuData->qbvh_prog.executable = m_device->CompileExecutable("../RadeonRays/src/kernels/GLSL/bvh2_fp16.comp", nullptr, 0, buildopts.c_str());
m_gpudata->bvh_prog.executable = m_device->CompileExecutable("../RadeonRays/src/kernels/GLSL/bvh2.comp", nullptr, 0, buildopts.c_str());
m_gpudata->qbvh_prog.executable = m_device->CompileExecutable("../RadeonRays/src/kernels/GLSL/bvh2_fp16.comp", nullptr, 0, buildopts.c_str());
}
#else
#if USE_OPENCL
if (device->GetPlatform() == Calc::Platform::kOpenCL)
{
m_gpuData->bvh_prog.executable = m_device->CompileExecutable(g_intersect_bvh2_lds_opencl, std::strlen(g_intersect_bvh2_lds_opencl), buildopts.c_str());
m_gpuData->qbvh_prog.executable = m_device->CompileExecutable(g_intersect_bvh2_lds_fp16_opencl, std::strlen(g_intersect_bvh2_lds_fp16_opencl), buildopts.c_str());
m_gpudata->bvh_prog.executable = m_device->CompileExecutable(g_intersect_bvh2_lds_opencl, std::strlen(g_intersect_bvh2_lds_opencl), buildopts.c_str());
m_gpudata->qbvh_prog.executable = m_device->CompileExecutable(g_intersect_bvh2_lds_fp16_opencl, std::strlen(g_intersect_bvh2_lds_fp16_opencl), buildopts.c_str());
}
#endif
#if USE_VULKAN
if (device->GetPlatform() == Calc::Platform::kVulkan)
{
if (m_gpuData->bvh_prog.executable == nullptr)
m_gpuData->bvh_prog.executable = m_device->CompileExecutable(g_bvh2_vulkan, std::strlen(g_bvh2_vulkan), buildopts.c_str());
if (m_gpuData->qbvh_prog.executable == nullptr)
m_gpuData->qbvh_prog.executable = m_device->CompileExecutable(g_bvh2_fp16_vulkan, std::strlen(g_bvh2_fp16_vulkan), buildopts.c_str());
if (m_gpudata->bvh_prog.executable == nullptr)
m_gpudata->bvh_prog.executable = m_device->CompileExecutable(g_bvh2_vulkan, std::strlen(g_bvh2_vulkan), buildopts.c_str());
if (m_gpudata->qbvh_prog.executable == nullptr)
m_gpudata->qbvh_prog.executable = m_device->CompileExecutable(g_bvh2_fp16_vulkan, std::strlen(g_bvh2_fp16_vulkan), buildopts.c_str());
}
#endif
#endif

m_gpuData->bvh_prog.isect_func = m_gpuData->bvh_prog.executable->CreateFunction("intersect_main");
m_gpuData->qbvh_prog.isect_func = m_gpuData->qbvh_prog.executable->CreateFunction("intersect_main");
m_gpuData->bvh_prog.occlude_func = m_gpuData->bvh_prog.executable->CreateFunction("occluded_main");
m_gpuData->qbvh_prog.occlude_func = m_gpuData->qbvh_prog.executable->CreateFunction("occluded_main");
m_gpudata->bvh_prog.isect_func = m_gpudata->bvh_prog.executable->CreateFunction("intersect_main");
m_gpudata->qbvh_prog.isect_func = m_gpudata->qbvh_prog.executable->CreateFunction("intersect_main");
m_gpudata->bvh_prog.occlude_func = m_gpudata->bvh_prog.executable->CreateFunction("occluded_main");
m_gpudata->qbvh_prog.occlude_func = m_gpudata->qbvh_prog.executable->CreateFunction("occluded_main");
}

void IntersectorLDS::Process(const World &world)
{
// If something has been changed we need to rebuild BVH
if (!m_gpuData->bvh || world.has_changed() || world.GetStateChange() != ShapeImpl::kStateChangeNone)
if (!m_gpudata->bvh || world.has_changed() || world.GetStateChange() != ShapeImpl::kStateChangeNone)
{
// Free previous data
if (m_gpuData->bvh)
if (m_gpudata->bvh)
{
m_device->DeleteBuffer(m_gpuData->bvh);
m_device->DeleteBuffer(m_gpudata->bvh);
}

// Look up build options for world
Expand Down Expand Up @@ -183,13 +183,13 @@ namespace RadeonRays
if (!use_qbvh)
{
auto bvh_size_in_bytes = bvh.GetSizeInBytes();
m_gpuData->bvh = m_device->CreateBuffer(bvh_size_in_bytes, Calc::BufferType::kRead);
m_gpudata->bvh = m_device->CreateBuffer(bvh_size_in_bytes, Calc::BufferType::kRead);

// Get the pointer to mapped data
Calc::Event *e = nullptr;
Bvh2::Node *bvhdata = nullptr;

m_device->MapBuffer(m_gpuData->bvh, 0, 0, bvh_size_in_bytes, Calc::MapType::kMapWrite, (void **)&bvhdata, &e);
m_device->MapBuffer(m_gpudata->bvh, 0, 0, bvh_size_in_bytes, Calc::MapType::kMapWrite, (void **)&bvhdata, &e);

e->Wait();
m_device->DeleteEvent(e);
Expand All @@ -199,13 +199,13 @@ namespace RadeonRays
bvhdata[i] = bvh.m_nodes[i];

// Unmap gpu data
m_device->UnmapBuffer(m_gpuData->bvh, 0, bvhdata, &e);
m_device->UnmapBuffer(m_gpudata->bvh, 0, bvhdata, &e);

e->Wait();
m_device->DeleteEvent(e);

// Select intersection program
m_gpuData->prog = &m_gpuData->bvh_prog;
m_gpudata->prog = &m_gpudata->bvh_prog;
}
else
{
Expand All @@ -214,13 +214,13 @@ namespace RadeonRays

// Update GPU data
auto bvh_size_in_bytes = translator.GetSizeInBytes();
m_gpuData->bvh = m_device->CreateBuffer(bvh_size_in_bytes, Calc::BufferType::kRead);
m_gpudata->bvh = m_device->CreateBuffer(bvh_size_in_bytes, Calc::BufferType::kRead);

// Get the pointer to mapped data
Calc::Event *e = nullptr;
QBvhTranslator::Node *bvhdata = nullptr;

m_device->MapBuffer(m_gpuData->bvh, 0, 0, bvh_size_in_bytes, Calc::MapType::kMapWrite, (void **)&bvhdata, &e);
m_device->MapBuffer(m_gpudata->bvh, 0, 0, bvh_size_in_bytes, Calc::MapType::kMapWrite, (void **)&bvhdata, &e);

e->Wait();
m_device->DeleteEvent(e);
Expand All @@ -231,13 +231,13 @@ namespace RadeonRays
bvhdata[i++] = *it;

// Unmap gpu data
m_device->UnmapBuffer(m_gpuData->bvh, 0, bvhdata, &e);
m_device->UnmapBuffer(m_gpudata->bvh, 0, bvhdata, &e);

e->Wait();
m_device->DeleteEvent(e);

// Select intersection program
m_gpuData->prog = &m_gpuData->qbvh_prog;
m_gpudata->prog = &m_gpudata->qbvh_prog;
}

// Make sure everything is committed
Expand All @@ -252,22 +252,22 @@ namespace RadeonRays
std::size_t stack_size = 4 * max_rays * kMaxStackSize;

// Check if we need to reallocate memory
if (!m_gpuData->stack || stack_size > m_gpuData->stack->GetSize())
if (!m_gpudata->stack || stack_size > m_gpudata->stack->GetSize())
{
m_device->DeleteBuffer(m_gpuData->stack);
m_gpuData->stack = m_device->CreateBuffer(stack_size, Calc::BufferType::kWrite);
m_device->DeleteBuffer(m_gpudata->stack);
m_gpudata->stack = m_device->CreateBuffer(stack_size, Calc::BufferType::kWrite);
}

assert(m_gpuData->prog);
auto &func = m_gpuData->prog->isect_func;
assert(m_gpudata->prog);
auto &func = m_gpudata->prog->isect_func;

// Set args
int arg = 0;

func->SetArg(arg++, m_gpuData->bvh);
func->SetArg(arg++, m_gpudata->bvh);
func->SetArg(arg++, rays);
func->SetArg(arg++, num_rays);
func->SetArg(arg++, m_gpuData->stack);
func->SetArg(arg++, m_gpudata->stack);
func->SetArg(arg++, hits);

std::size_t localsize = kWorkGroupSize;
Expand All @@ -283,22 +283,22 @@ namespace RadeonRays
std::size_t stack_size = 4 * max_rays * kMaxStackSize;

// Check if we need to reallocate memory
if (!m_gpuData->stack || stack_size > m_gpuData->stack->GetSize())
if (!m_gpudata->stack || stack_size > m_gpudata->stack->GetSize())
{
m_device->DeleteBuffer(m_gpuData->stack);
m_gpuData->stack = m_device->CreateBuffer(stack_size, Calc::BufferType::kWrite);
m_device->DeleteBuffer(m_gpudata->stack);
m_gpudata->stack = m_device->CreateBuffer(stack_size, Calc::BufferType::kWrite);
}

assert(m_gpuData->prog);
auto &func = m_gpuData->prog->occlude_func;
assert(m_gpudata->prog);
auto &func = m_gpudata->prog->occlude_func;

// Set args
int arg = 0;

func->SetArg(arg++, m_gpuData->bvh);
func->SetArg(arg++, m_gpudata->bvh);
func->SetArg(arg++, rays);
func->SetArg(arg++, num_rays);
func->SetArg(arg++, m_gpuData->stack);
func->SetArg(arg++, m_gpudata->stack);
func->SetArg(arg++, hits);

std::size_t localsize = kWorkGroupSize;
Expand Down
2 changes: 1 addition & 1 deletion RadeonRays/src/intersector/intersector_lds.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ namespace RadeonRays
struct GpuData;

// Implementation data
std::unique_ptr<GpuData> m_gpuData;
std::unique_ptr<GpuData> m_gpudata;
};
}
52 changes: 26 additions & 26 deletions RadeonRays/src/kernelcache/kernels_cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2534,17 +2534,17 @@ static const char g_intersect_bvh2_lds_opencl[]= \
" // Handle only working subset \n"\
" if (index < *num_rays) \n"\
" { \n"\
" const ray myRay = rays[index]; \n"\
" const ray my_ray = rays[index]; \n"\
" \n"\
" if (ray_is_active(&myRay)) \n"\
" if (ray_is_active(&my_ray)) \n"\
" { \n"\
" __local uint lds_stack[GROUP_SIZE * LDS_STACK_SIZE]; \n"\
" \n"\
" const float3 invDir = safe_invdir(myRay); \n"\
" const float3 oxInvDir = -myRay.o.xyz * invDir; \n"\
" const float3 invDir = safe_invdir(my_ray); \n"\
" const float3 oxInvDir = -my_ray.o.xyz * invDir; \n"\
" \n"\
" // Intersection parametric distance \n"\
" float closest_t = myRay.o.w; \n"\
" float closest_t = my_ray.o.w; \n"\
" \n"\
" // Current node address \n"\
" uint addr = 0; \n"\
Expand Down Expand Up @@ -2614,7 +2614,7 @@ static const char g_intersect_bvh2_lds_opencl[]= \
" else \n"\
" { \n"\
" float t = fast_intersect_triangle( \n"\
" myRay, \n"\
" my_ray, \n"\
" node.aabb_left_min_or_v0_and_addr_left.xyz, \n"\
" node.aabb_left_max_or_v1_and_mesh_id.xyz, \n"\
" node.aabb_right_min_or_v2_and_addr_right.xyz, \n"\
Expand Down Expand Up @@ -2647,7 +2647,7 @@ static const char g_intersect_bvh2_lds_opencl[]= \
" { \n"\
" // Calculate hit position \n"\
" const bvh_node node = nodes[closest_addr]; \n"\
" const float3 p = myRay.o.xyz + closest_t * myRay.d.xyz; \n"\
" const float3 p = my_ray.o.xyz + closest_t * my_ray.d.xyz; \n"\
" \n"\
" // Calculate barycentric coordinates \n"\
" const float2 uv = triangle_calculate_barycentrics( \n"\
Expand Down Expand Up @@ -2690,17 +2690,17 @@ static const char g_intersect_bvh2_lds_opencl[]= \
" // Handle only working subset \n"\
" if (index < *num_rays) \n"\
" { \n"\
" const ray myRay = rays[index]; \n"\
" const ray my_ray = rays[index]; \n"\
" \n"\
" if (ray_is_active(&myRay)) \n"\
" if (ray_is_active(&my_ray)) \n"\
" { \n"\
" __local uint lds_stack[GROUP_SIZE * LDS_STACK_SIZE]; \n"\
" \n"\
" const float3 invDir = safe_invdir(myRay); \n"\
" const float3 oxInvDir = -myRay.o.xyz * invDir; \n"\
" const float3 invDir = safe_invdir(my_ray); \n"\
" const float3 oxInvDir = -my_ray.o.xyz * invDir; \n"\
" \n"\
" // Intersection parametric distance \n"\
" float closest_t = myRay.o.w; \n"\
" float closest_t = my_ray.o.w; \n"\
" \n"\
" // Current node address \n"\
" uint addr = 0; \n"\
Expand Down Expand Up @@ -2770,7 +2770,7 @@ static const char g_intersect_bvh2_lds_opencl[]= \
" else \n"\
" { \n"\
" float t = fast_intersect_triangle( \n"\
" myRay, \n"\
" my_ray, \n"\
" node.aabb_left_min_or_v0_and_addr_left.xyz, \n"\
" node.aabb_left_max_or_v1_and_mesh_id.xyz, \n"\
" node.aabb_right_min_or_v2_and_addr_right.xyz, \n"\
Expand Down Expand Up @@ -3201,19 +3201,19 @@ static const char g_intersect_bvh2_lds_fp16_opencl[]= \
" // Handle only working subset \n"\
" if (index < *num_rays) \n"\
" { \n"\
" const ray myRay = rays[index]; \n"\
" const ray my_ray = rays[index]; \n"\
" \n"\
" if (ray_is_active(&myRay)) \n"\
" if (ray_is_active(&my_ray)) \n"\
" { \n"\
" __local uint lds_stack[GROUP_SIZE * LDS_STACK_SIZE]; \n"\
" \n"\
" // Precompute inverse direction and origin / dir for bbox testing \n"\
" const float3 invDir32 = safe_invdir2(myRay); \n"\
" const float3 invDir32 = safe_invdir2(my_ray); \n"\
" const half3 invDir = convert_half3(invDir32); \n"\
" const half3 oxInvDir = convert_half3(-myRay.o.xyz * invDir32); \n"\
" const half3 oxInvDir = convert_half3(-my_ray.o.xyz * invDir32); \n"\
" \n"\
" // Intersection parametric distance \n"\
" float closest_t = myRay.o.w; \n"\
" float closest_t = my_ray.o.w; \n"\
" \n"\
" // Current node address \n"\
" uint addr = 0; \n"\
Expand Down Expand Up @@ -3304,7 +3304,7 @@ static const char g_intersect_bvh2_lds_fp16_opencl[]= \
" else \n"\
" { \n"\
" float t = fast_intersect_triangle( \n"\
" myRay, \n"\
" my_ray, \n"\
" as_float3(node.aabb01_min_or_v0_and_addr0.xyz), \n"\
" as_float3(node.aabb01_max_or_v1_and_addr1_or_mesh_id.xyz), \n"\
" as_float3(node.aabb23_min_or_v2_and_addr2_or_prim_id.xyz), \n"\
Expand Down Expand Up @@ -3337,7 +3337,7 @@ static const char g_intersect_bvh2_lds_fp16_opencl[]= \
" { \n"\
" // Calculate hit position \n"\
" const bvh_node node = nodes[closest_addr]; \n"\
" const float3 p = myRay.o.xyz + closest_t * myRay.d.xyz; \n"\
" const float3 p = my_ray.o.xyz + closest_t * my_ray.d.xyz; \n"\
" \n"\
" // Calculate barycentric coordinates \n"\
" const float2 uv = triangle_calculate_barycentrics( \n"\
Expand Down Expand Up @@ -3380,19 +3380,19 @@ static const char g_intersect_bvh2_lds_fp16_opencl[]= \
" // Handle only working subset \n"\
" if (index < *num_rays) \n"\
" { \n"\
" const ray myRay = rays[index]; \n"\
" const ray my_ray = rays[index]; \n"\
" \n"\
" if (ray_is_active(&myRay)) \n"\
" if (ray_is_active(&my_ray)) \n"\
" { \n"\
" __local uint lds_stack[GROUP_SIZE * LDS_STACK_SIZE]; \n"\
" \n"\
" // Precompute inverse direction and origin / dir for bbox testing \n"\
" const float3 invDir32 = safe_invdir2(myRay); \n"\
" const float3 invDir32 = safe_invdir2(my_ray); \n"\
" const half3 invDir = convert_half3(invDir32); \n"\
" const half3 oxInvDir = convert_half3(-myRay.o.xyz * invDir32); \n"\
" const half3 oxInvDir = convert_half3(-my_ray.o.xyz * invDir32); \n"\
" \n"\
" // Intersection parametric distance \n"\
" float closest_t = myRay.o.w; \n"\
" float closest_t = my_ray.o.w; \n"\
" \n"\
" // Current node address \n"\
" uint addr = 0; \n"\
Expand Down Expand Up @@ -3483,7 +3483,7 @@ static const char g_intersect_bvh2_lds_fp16_opencl[]= \
" else \n"\
" { \n"\
" float t = fast_intersect_triangle( \n"\
" myRay, \n"\
" my_ray, \n"\
" as_float3(node.aabb01_min_or_v0_and_addr0.xyz), \n"\
" as_float3(node.aabb01_max_or_v1_and_addr1_or_mesh_id.xyz), \n"\
" as_float3(node.aabb23_min_or_v2_and_addr2_or_prim_id.xyz), \n"\
Expand Down
Loading

0 comments on commit ffe35a2

Please sign in to comment.