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

Function renderFrameStandard

tutorials/viewer/viewer_device.cpp:316–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316extern "C" void renderFrameStandard (int* pixels,
317 const unsigned int width,
318 const unsigned int height,
319 const float time,
320 const ISPCCamera& camera)
321{
322#if defined(EMBREE_SYCL_TUTORIAL) && !defined(EMBREE_SYCL_RT_SIMULATION)
323 TutorialData ldata = data;
324
325#if defined(USE_SPECIALIZATION_CONSTANTS)
326 sycl::event event = global_gpu_queue->submit([=](sycl::handler& cgh) {
327 cgh.set_specialization_constant<spec_feature_mask>(g_feature_mask);
328 const sycl::nd_range<2> nd_range = make_nd_range(height,width);
329 cgh.parallel_for(nd_range,[=](sycl::nd_item<2> item, sycl::kernel_handler kh) {
330 const unsigned int x = item.get_global_id(1); if (x >= width ) return;
331 const unsigned int y = item.get_global_id(0); if (y >= height) return;
332 RayStats stats;
333 const RTCFeatureFlags feature_mask = kh.get_specialization_constant<spec_feature_mask>();
334 renderPixelStandard(ldata,x,y,pixels,width,height,time,camera,stats,feature_mask);
335 });
336 });
337 global_gpu_queue->wait_and_throw();
338#else
339 sycl::event event = global_gpu_queue->submit([=](sycl::handler& cgh) {
340 const sycl::nd_range<2> nd_range = make_nd_range(height,width);
341 cgh.parallel_for(nd_range,[=](sycl::nd_item<2> item) {
342 const unsigned int x = item.get_global_id(1); if (x >= width ) return;
343 const unsigned int y = item.get_global_id(0); if (y >= height) return;
344 RayStats stats;
345 const RTCFeatureFlags feature_mask = RTC_FEATURE_FLAG_ALL;
346 renderPixelStandard(ldata,x,y,pixels,width,height,time,camera,stats,feature_mask);
347 });
348 });
349 global_gpu_queue->wait_and_throw();
350#endif
351
352 const auto t0 = event.template get_profiling_info<sycl::info::event_profiling::command_start>();
353 const auto t1 = event.template get_profiling_info<sycl::info::event_profiling::command_end>();
354 const double dt = (t1-t0)*1E-9;
355 ((ISPCCamera*)&camera)->render_time = dt;
356
357#else
358 /* render image */
359 const int numTilesX = (width +TILE_SIZE_X-1)/TILE_SIZE_X;
360 const int numTilesY = (height+TILE_SIZE_Y-1)/TILE_SIZE_Y;
361 parallel_for(size_t(0),size_t(numTilesX*numTilesY),[&](const range<size_t>& range) {
362 const int threadIndex = (int)TaskScheduler::threadIndex();
363 for (size_t i=range.begin(); i<range.end(); i++)
364 renderTileTask((int)i,threadIndex,pixels,width,height,time,camera,numTilesX,numTilesY);
365 });
366#endif
367}
368
369/* called by the C++ code to render */
370extern "C" void device_render (int* pixels,

Callers

nothing calls this directly

Calls 6

make_nd_rangeFunction · 0.85
parallel_forFunction · 0.85
renderPixelStandardFunction · 0.70
renderTileTaskFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected