@@ -49,9 +49,12 @@ namespace RadeonRays
49
49
50
50
~Program ()
51
51
{
52
- executable->DeleteFunction (isect_func);
53
- executable->DeleteFunction (occlude_func);
54
- device->DeleteExecutable (executable);
52
+ if (executable)
53
+ {
54
+ executable->DeleteFunction (isect_func);
55
+ executable->DeleteFunction (occlude_func);
56
+ device->DeleteExecutable (executable);
57
+ }
55
58
}
56
59
57
60
Calc::Device *device;
@@ -101,6 +104,9 @@ namespace RadeonRays
101
104
buildopts.append (" -D USE_SAFE_MATH " );
102
105
#endif
103
106
107
+ Calc::DeviceSpec spec;
108
+ m_device->GetSpec (spec);
109
+
104
110
#ifndef RR_EMBED_KERNELS
105
111
if (device->GetPlatform () == Calc::Platform::kOpenCL )
106
112
{
@@ -109,37 +115,44 @@ namespace RadeonRays
109
115
int numheaders = sizeof (headers) / sizeof (const char *);
110
116
111
117
m_gpudata->bvh_prog .executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/CL/intersect_bvh2_lds.cl" , headers, numheaders, buildopts.c_str ());
112
- m_gpudata->qbvh_prog .executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/CL/intersect_bvh2_lds_fp16.cl" , headers, numheaders, buildopts.c_str ());
118
+ if (spec.has_fp16 )
119
+ m_gpudata->qbvh_prog .executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/CL/intersect_bvh2_lds_fp16.cl" , headers, numheaders, buildopts.c_str ());
113
120
}
114
121
else
115
122
{
116
123
assert (device->GetPlatform () == Calc::Platform::kVulkan );
117
124
m_gpudata->bvh_prog .executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/GLSL/bvh2.comp" , nullptr , 0 , buildopts.c_str ());
118
- m_gpudata->qbvh_prog .executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/GLSL/bvh2_fp16.comp" , nullptr , 0 , buildopts.c_str ());
125
+ if (spec.has_fp16 )
126
+ m_gpudata->qbvh_prog .executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/GLSL/bvh2_fp16.comp" , nullptr , 0 , buildopts.c_str ());
119
127
}
120
128
#else
121
129
#if USE_OPENCL
122
130
if (device->GetPlatform () == Calc::Platform::kOpenCL )
123
131
{
124
132
m_gpudata->bvh_prog .executable = m_device->CompileExecutable (g_intersect_bvh2_lds_opencl, std::strlen (g_intersect_bvh2_lds_opencl), buildopts.c_str ());
125
- 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 ());
133
+ if (spec.has_fp16 )
134
+ 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 ());
126
135
}
127
136
#endif
128
137
#if USE_VULKAN
129
138
if (device->GetPlatform () == Calc::Platform::kVulkan )
130
139
{
131
140
if (m_gpudata->bvh_prog .executable == nullptr )
132
141
m_gpudata->bvh_prog .executable = m_device->CompileExecutable (g_bvh2_vulkan, std::strlen (g_bvh2_vulkan), buildopts.c_str ());
133
- if (m_gpudata->qbvh_prog .executable == nullptr )
142
+ if (m_gpudata->qbvh_prog .executable == nullptr && spec. has_fp16 )
134
143
m_gpudata->qbvh_prog .executable = m_device->CompileExecutable (g_bvh2_fp16_vulkan, std::strlen (g_bvh2_fp16_vulkan), buildopts.c_str ());
135
144
}
136
145
#endif
137
146
#endif
138
147
139
148
m_gpudata->bvh_prog .isect_func = m_gpudata->bvh_prog .executable ->CreateFunction (" intersect_main" );
140
- m_gpudata->qbvh_prog .isect_func = m_gpudata->qbvh_prog .executable ->CreateFunction (" intersect_main" );
141
149
m_gpudata->bvh_prog .occlude_func = m_gpudata->bvh_prog .executable ->CreateFunction (" occluded_main" );
142
- m_gpudata->qbvh_prog .occlude_func = m_gpudata->qbvh_prog .executable ->CreateFunction (" occluded_main" );
150
+
151
+ if (m_gpudata->qbvh_prog .executable )
152
+ {
153
+ m_gpudata->qbvh_prog .isect_func = m_gpudata->qbvh_prog .executable ->CreateFunction (" intersect_main" );
154
+ m_gpudata->qbvh_prog .occlude_func = m_gpudata->qbvh_prog .executable ->CreateFunction (" occluded_main" );
155
+ }
143
156
}
144
157
145
158
void IntersectorLDS::Process (const World &world)
@@ -166,7 +179,7 @@ namespace RadeonRays
166
179
#if 0
167
180
if (type && type->AsString() == "qbvh")
168
181
{
169
- use_qbvh = true ;
182
+ use_qbvh = (m_gpudata->qbvh_prog.executable != nullptr) ;
170
183
}
171
184
#endif
172
185
0 commit comments