Skip to content

Commit eb50268

Browse files
committed
2 parents a432446 + 6687a22 commit eb50268

17 files changed

+90
-30
lines changed

CLW/CLW.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ project "CLW"
1414

1515
configuration {}
1616

17+
if _OPTIONS["allow_cpu_devices"] then
18+
defines {"RR_ALLOW_CPU_DEVICES=1"}
19+
end
20+
1721
-- we rely on RadeonRays to do the actual embedding for us
1822
if _OPTIONS["embed_kernels"] then
1923
defines {"RR_EMBED_KERNELS=1"}

CLW/CLWParallelPrimitives.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ THE SOFTWARE.
3030

3131
#ifdef RR_EMBED_KERNELS
3232
#if USE_OPENCL
33-
# include <CLW/kernelcache/clwkernels_cl.h>
33+
#include "CLW/kernelcache/clwkernels_cl.h"
3434
#endif
3535
#endif // RR_EMBED_KERNELS
3636

@@ -952,4 +952,4 @@ CLWEvent CLWParallelPrimitives::Copy(unsigned int deviceIdx, CLWBuffer<cl_int> i
952952
copyKernel.SetArg(2, output);
953953

954954
return context_.Launch1D(0, NUM_BLOCKS * WG_SIZE, WG_SIZE, copyKernel);
955-
}
955+
}

CLW/CLWPlatform.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ void CLWPlatform::CreateAllPlatforms(std::vector<CLWPlatform>& platforms)
4848
status = clGetPlatformIDs(numPlatforms, &platformIds[0], nullptr);
4949
ThrowIf(status != CL_SUCCESS, status, "clGetPlatformIDs failed");
5050

51-
cl_device_type type = CL_DEVICE_TYPE_ALL;
51+
52+
#ifdef RR_ALLOW_CPU_DEVICES
53+
cl_device_type type = CL_DEVICE_TYPE_ALL;
54+
#else
55+
cl_device_type type = CL_DEVICE_TYPE_GPU;
56+
#endif
5257

5358
// TODO: this is a workaround for nasty Apple's OpenCL runtime
5459
// which doesn't allow to have work group sizes > 1 on CPU devices
@@ -70,8 +75,8 @@ void CLWPlatform::CreateAllPlatforms(std::vector<CLWPlatform>& platforms)
7075

7176
std::string versionstr(version.begin(), version.end());
7277

73-
if (versionstr.find("1.0") != std::string::npos ||
74-
versionstr.find("1.1") != std::string::npos)
78+
if (versionstr.find("OpenCL 1.0 ") != std::string::npos ||
79+
versionstr.find("OpenCL 1.1") != std::string::npos)
7580
{
7681
continue;
7782
}

Calc/src/device_clw.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,6 @@ namespace Calc
459459
""
460460
#endif
461461
);
462-
#ifdef USE_SAFE_MATH
463-
buildopts.append("-D USE_SAFE_MATH");
464-
#endif
465462

466463
return new ExecutableClw(
467464
CLWProgram::CreateFromFile(filename, headernames, numheaders, buildopts.c_str(), m_context)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ The app only supports loading of pure triangle .obj meshes. The list of supporte
144144
- dds (limited support)
145145
- tga
146146

147+
## Run unit tests
148+
They need to be run from the <Radeon Rays_SDK path>/UnitTest path.
149+
Premake should be runned with the `--safe_math` option.
147150

148151
# Hardware support
149152

RadeonRays/RadeonRays.lua

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ project "RadeonRays"
1111

1212
if _OPTIONS["shared_calc"] then
1313
defines {"CALC_IMPORT_API"};
14-
links {"dl"}
14+
if os.is("windows") then
15+
characterset ("MBCS")
16+
else
17+
links {"dl"}
18+
end
1519
else
16-
defines {"CALC_STATIC_LIBRARY"}
20+
defines {"CALC_STATIC_LIBRARY"}
1721
links {"Calc"}
18-
if _OPTIONS["use_opencl"] then
22+
if _OPTIONS["use_opencl"] then
1923
links {"CLW"}
20-
end
24+
end
2125
end
2226

2327
if _OPTIONS["enable_raymask"] then
@@ -108,8 +112,13 @@ project "RadeonRays"
108112
end
109113

110114
if _OPTIONS["enable_raymask"] then
111-
configuration {}
112-
defines {"RR_RAY_MASK"}
115+
configuration {}
116+
defines {"RR_RAY_MASK"}
117+
end
118+
119+
if _OPTIONS["safe_math"] then
120+
configuration {}
121+
defines { "USE_SAFE_MATH" }
113122
end
114123

115124
if _OPTIONS["use_vulkan"] then

RadeonRays/include/math/matrix.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,13 @@ namespace RadeonRays
179179
return res*=c;
180180
}
181181

182-
inline float3 operator * (matrix const& m, float3 const& v)
182+
inline float4 operator * (matrix const& m, float4 const& v)
183183
{
184-
float3 res;
184+
float4 res(0, 0, 0, 0);
185185

186-
for (int i=0;i<3;++i)
187-
{
188-
res[i] = 0.f;
189-
for (int j=0;j<3;++j)
186+
for (int i = 0; i < 4; ++i) {
187+
//res[i] = 0.f;
188+
for (int j = 0; j < 4; ++j)
190189
res[i] += m.m[i][j] * v[j];
191190
}
192191

RadeonRays/include/radeon_rays.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ THE SOFTWARE.
2828
#include "math/matrix.h"
2929
#include "math/ray.h"
3030
#include "math/mathutils.h"
31+
#include <cstdint>
3132

3233
#define RADEONRAYS_API_VERSION 2.0
3334

RadeonRays/src/device/embree_intersection_device.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ namespace RadeonRays
116116
if (result != RTC_NO_ERROR)
117117
std::cout << "Failed to create embree rtcDevice: " << result << std::endl;
118118

119-
m_scene = rtcDeviceNewScene(m_device, RTC_SCENE_STATIC, RTC_INTERSECT1 | RTC_INTERSECT4 | RTC_INTERSECT8 | RTC_INTERSECT16 | RTC_INTERSECTN);
119+
m_scene = rtcDeviceNewScene(m_device, RTC_SCENE_STATIC, RTC_INTERSECT1 | RTC_INTERSECT4 | RTC_INTERSECT8 | RTC_INTERSECT16 );
120120
result = rtcDeviceGetError(m_device);
121121
if (result != RTC_NO_ERROR)
122122
std::cout << "Failed to create embree scene: " << result << std::endl;
@@ -171,7 +171,7 @@ namespace RadeonRays
171171
}
172172
m_instances.clear();
173173
rtcDeleteScene(m_scene); CheckEmbreeError();
174-
m_scene = rtcDeviceNewScene(m_device, RTC_SCENE_STATIC, RTC_INTERSECT1 | RTC_INTERSECT4 | RTC_INTERSECT8 | RTC_INTERSECT16 | RTC_INTERSECTN); CheckEmbreeError();
174+
m_scene = rtcDeviceNewScene(m_device, RTC_SCENE_STATIC, RTC_INTERSECT1 | RTC_INTERSECT4 | RTC_INTERSECT8 | RTC_INTERSECT16 ); CheckEmbreeError();
175175

176176
for (auto i : world.shapes_)
177177
{
@@ -500,7 +500,7 @@ namespace RadeonRays
500500
{
501501
if (m_meshes.count(mesh))
502502
return m_meshes[mesh].scene;
503-
RTCScene result = rtcDeviceNewScene(m_device, RTC_SCENE_STATIC, RTC_INTERSECT1 | RTC_INTERSECT4 | RTC_INTERSECT8 | RTC_INTERSECT16 | RTC_INTERSECTN);
503+
RTCScene result = rtcDeviceNewScene(m_device, RTC_SCENE_STATIC, RTC_INTERSECT1 | RTC_INTERSECT4 | RTC_INTERSECT8 | RTC_INTERSECT16 );
504504
CheckEmbreeError();
505505
ThrowIf(!mesh->puretriangle(), "Only triangle meshes supported by now.");
506506

RadeonRays/src/intersector/intersector_2level.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,14 @@ namespace RadeonRays
130130
{
131131
std::string buildopts =
132132
#ifdef RR_RAY_MASK
133-
"-D RR_RAY_MASK";
133+
"-D RR_RAY_MASK ";
134134
#else
135135
"";
136136
#endif
137+
138+
#ifdef USE_SAFE_MATH
139+
buildopts.append("-D USE_SAFE_MATH ");
140+
#endif
137141

138142
#ifndef RR_EMBED_KERNELS
139143
if ( device->GetPlatform() == Calc::Platform::kOpenCL )

0 commit comments

Comments
 (0)