@@ -37,34 +37,55 @@ namespace RadeonRays
37
37
38
38
struct IntersectorLDS ::GpuData
39
39
{
40
+ struct Program
41
+ {
42
+ Program (Calc::Device *device)
43
+ : device(device)
44
+ , executable(nullptr )
45
+ , isect_func(nullptr )
46
+ , occlude_func(nullptr )
47
+ {
48
+ }
49
+
50
+ ~Program ()
51
+ {
52
+ executable->DeleteFunction (isect_func);
53
+ executable->DeleteFunction (occlude_func);
54
+ device->DeleteExecutable (executable);
55
+ }
56
+
57
+ Calc::Device *device;
58
+
59
+ Calc::Executable *executable;
60
+ Calc::Function *isect_func;
61
+ Calc::Function *occlude_func;
62
+ };
63
+
40
64
// Device
41
65
Calc::Device *device;
42
66
// BVH nodes
43
67
Calc::Buffer *bvh;
44
68
// Traversal stack
45
69
Calc::Buffer *stack;
46
70
47
- Calc::Executable *executable ;
48
- Calc::Function *isect_func ;
49
- Calc::Function *occlude_func ;
71
+ Program *prog ;
72
+ Program bvh_prog ;
73
+ Program qbvh_prog ;
50
74
51
75
GpuData (Calc::Device *device)
52
76
: device(device)
53
77
, bvh(nullptr )
54
78
, stack(nullptr )
55
- , executable (nullptr )
56
- , isect_func( nullptr )
57
- , occlude_func( nullptr )
79
+ , prog (nullptr )
80
+ , bvh_prog(device )
81
+ , qbvh_prog(device )
58
82
{
59
83
}
60
84
61
85
~GpuData ()
62
86
{
63
87
device->DeleteBuffer (bvh);
64
88
device->DeleteBuffer (stack);
65
- executable->DeleteFunction (isect_func);
66
- executable->DeleteFunction (occlude_func);
67
- device->DeleteExecutable (executable);
68
89
}
69
90
};
70
91
@@ -87,32 +108,40 @@ namespace RadeonRays
87
108
88
109
int numheaders = sizeof (headers) / sizeof (const char *);
89
110
90
- m_gpuData->executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/CL/intersect_bvh2_lds.cl" , headers, numheaders, buildopts.c_str ());
111
+ 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 ());
91
113
}
92
114
else
93
115
{
94
116
// TODO: implement (gboisse)
95
117
assert (device->GetPlatform () == Calc::Platform::kVulkan );
96
- m_gpuData->executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/GLSL/bvh2.comp" , nullptr , 0 , buildopts.c_str ());
118
+ m_gpuData->bvh_prog .executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/GLSL/bvh2.comp" , nullptr , 0 , buildopts.c_str ());
119
+ m_gpuData->qbvh_prog .executable = m_device->CompileExecutable (" ../RadeonRays/src/kernels/GLSL/bvh2_fp16.comp" , nullptr , 0 , buildopts.c_str ());
97
120
}
98
121
#else
99
122
#if USE_OPENCL
100
123
if (device->GetPlatform () == Calc::Platform::kOpenCL )
101
124
{
102
- m_gpuData->executable = m_device->CompileExecutable (g_intersect_bvh2_lds_opencl, std::strlen (g_intersect_bvh2_lds_opencl), buildopts.c_str ());
125
+ m_gpuData->bvh_prog .executable = m_device->CompileExecutable (g_intersect_bvh2_lds_opencl, std::strlen (g_intersect_bvh2_lds_opencl), buildopts.c_str ());
126
+ m_gpuData->qbvh_prog .executable = m_device->CompileExecutable (g_intersect_bvh2_lds_fp16_opencl, std::strlen (g_intersect_bvh2_lds_opencl), buildopts.c_str ());
103
127
}
104
128
#endif
105
129
#if USE_VULKAN
106
- if (m_gpudata-> executable == nullptr && device->GetPlatform () == Calc::Platform::kVulkan )
130
+ if (device->GetPlatform () == Calc::Platform::kVulkan )
107
131
{
108
132
// TODO: implement (gboisse)
109
- m_gpuData->executable = m_device->CompileExecutable (g_bvh2_vulkan, std::strlen (g_bvh2_vulkan), buildopts.c_str ());
133
+ if (m_gpudata->bvh_prog .executable == nullptr )
134
+ m_gpuData->executable = m_device->CompileExecutable (g_bvh2_vulkan, std::strlen (g_bvh2_vulkan), buildopts.c_str ());
135
+ if (m_gpuData->qbvh_prog .executable == nullptr )
136
+ m_gpuData->executable = m_device->CompileExecutable (g_bvh2_fp16_vulkan, std::strlen (g_bvh2_fp16_vulkan), buildopts.c_str ());
110
137
}
111
138
#endif
112
139
#endif
113
140
114
- m_gpuData->isect_func = m_gpuData->executable ->CreateFunction (" intersect_main" );
115
- m_gpuData->occlude_func = m_gpuData->executable ->CreateFunction (" occluded_main" );
141
+ m_gpuData->bvh_prog .isect_func = m_gpuData->bvh_prog .executable ->CreateFunction (" intersect_main" );
142
+ m_gpuData->qbvh_prog .isect_func = m_gpuData->qbvh_prog .executable ->CreateFunction (" intersect_main" );
143
+ m_gpuData->bvh_prog .occlude_func = m_gpuData->bvh_prog .executable ->CreateFunction (" occluded_main" );
144
+ m_gpuData->qbvh_prog .occlude_func = m_gpuData->qbvh_prog .executable ->CreateFunction (" occluded_main" );
116
145
}
117
146
118
147
void IntersectorLDS::Process (const World &world)
@@ -185,6 +214,9 @@ namespace RadeonRays
185
214
186
215
e->Wait ();
187
216
m_device->DeleteEvent (e);
217
+
218
+ // Select intersection program
219
+ m_gpuData->prog = &m_gpuData->bvh_prog ;
188
220
}
189
221
else
190
222
{
@@ -214,6 +246,9 @@ namespace RadeonRays
214
246
215
247
e->Wait ();
216
248
m_device->DeleteEvent (e);
249
+
250
+ // Select intersection program
251
+ m_gpuData->prog = &m_gpuData->qbvh_prog ;
217
252
}
218
253
219
254
// Make sure everything is committed
@@ -234,7 +269,8 @@ namespace RadeonRays
234
269
m_gpuData->stack = m_device->CreateBuffer (stack_size, Calc::BufferType::kWrite );
235
270
}
236
271
237
- auto &func = m_gpuData->isect_func ;
272
+ assert (m_gpuData->prog );
273
+ auto &func = m_gpuData->prog ->isect_func ;
238
274
239
275
// Set args
240
276
int arg = 0 ;
@@ -264,7 +300,8 @@ namespace RadeonRays
264
300
m_gpuData->stack = m_device->CreateBuffer (stack_size, Calc::BufferType::kWrite );
265
301
}
266
302
267
- auto &func = m_gpuData->occlude_func ;
303
+ assert (m_gpuData->prog );
304
+ auto &func = m_gpuData->prog ->occlude_func ;
268
305
269
306
// Set args
270
307
int arg = 0 ;
0 commit comments