MCPcopy Create free account
hub / github.com/RenderKit/embree / rebuild_instances

Function rebuild_instances

tutorials/forest/forest_device.cpp:293–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293void rebuild_instances(size_t old_num_trees)
294{
295 if (instances) {
296 alignedFree(instances);
297 instances = nullptr;
298 g_memory_consumed -= old_num_trees * sizeof(RTCGeometry);
299 }
300
301 if (g_use_instance_array)
302 {
303#if defined(EMBREE_SYCL_TUTORIAL)
304 void* tree_ids_device = data.tree_ids_device;
305 void* tree_transforms_device = data.tree_transforms_device;
306#else
307 void* tree_ids_device = nullptr;
308 void* tree_transforms_device = nullptr;
309#endif
310 instance_array = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_INSTANCE_ARRAY);
311 rtcSetGeometryInstancedScenes(instance_array,(RTCScene*)scene_trees_selected,6);
312 rtcSetSharedGeometryBufferHostDevice(instance_array, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, (void*)data.tree_ids_host, tree_ids_device, 0, sizeof(unsigned int), num_trees);
313 rtcSetSharedGeometryBufferHostDevice(instance_array, RTC_BUFFER_TYPE_TRANSFORM, 0, RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR, (void*)data.tree_transforms_host, tree_transforms_device, 0, sizeof(AffineSpace3fa), num_trees);
314 rtcAttachGeometry(data.g_scene,instance_array);
315 rtcReleaseGeometry(instance_array);
316 rtcCommitGeometry(instance_array);
317 }
318 else
319 {
320 instances = (RTCGeometry*) alignedMalloc((num_trees)*sizeof(RTCGeometry),16);
321 g_memory_consumed += num_trees * sizeof(RTCGeometry);
322 for (unsigned int i = 0; i < num_trees; ++i) {
323 instances[i] = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_INSTANCE);
324 rtcSetGeometryInstancedScene(instances[i],scene_trees_selected[data.tree_ids_host[i]]);
325 rtcSetGeometryTransform(instances[i],0,RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,(float*)&data.tree_transforms_host[i]);
326 rtcAttachGeometry(data.g_scene,instances[i]);
327 rtcReleaseGeometry(instances[i]);
328 rtcCommitGeometry(instances[i]);
329 }
330 }
331}
332
333/* task that renders a single screen tile */
334void renderPixelStandard(const TutorialData& data,

Callers 1

device_renderFunction · 0.85

Calls 9

alignedFreeFunction · 0.85
rtcAttachGeometryFunction · 0.85
rtcReleaseGeometryFunction · 0.85
rtcCommitGeometryFunction · 0.85
alignedMallocFunction · 0.85
rtcSetGeometryTransformFunction · 0.85

Tested by

no test coverage detected