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

Function renderFrameStandard

tutorials/next_hit/next_hit_device.cpp:467–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467extern "C" void renderFrameStandard (int* pixels,
468 const unsigned int width,
469 const unsigned int height,
470 const float time,
471 const ISPCCamera& camera)
472{
473#if defined(EMBREE_SYCL_TUTORIAL) && !defined(EMBREE_SYCL_RT_SIMULATION)
474 TutorialData ldata = data;
475
476#if defined(USE_SPECIALIZATION_CONSTANTS)
477 sycl::event event = global_gpu_queue->submit([=](sycl::handler& cgh) {
478 cgh.set_specialization_constant<spec_feature_mask>(g_feature_mask);
479 const sycl::nd_range<2> nd_range = make_nd_range(height,width);
480 cgh.parallel_for(nd_range,[=](sycl::nd_item<2> item, sycl::kernel_handler kh) {
481 const unsigned int x = item.get_global_id(1); if (x >= width ) return;
482 const unsigned int y = item.get_global_id(0); if (y >= height) return;
483 RayStats stats;
484 const RTCFeatureFlags feature_mask = kh.get_specialization_constant<spec_feature_mask>();
485 renderPixelStandard(ldata,x,y,pixels,width,height,time,camera,stats,feature_mask);
486 });
487 });
488 global_gpu_queue->wait_and_throw();
489#else
490 sycl::event event = global_gpu_queue->submit([=](sycl::handler& cgh) {
491 const sycl::nd_range<2> nd_range = make_nd_range(height,width);
492 cgh.parallel_for(nd_range,[=](sycl::nd_item<2> item) {
493 const unsigned int x = item.get_global_id(1); if (x >= width ) return;
494 const unsigned int y = item.get_global_id(0); if (y >= height) return;
495 RayStats stats;
496 const RTCFeatureFlags feature_mask = RTC_FEATURE_FLAG_ALL;
497 renderPixelStandard(ldata,x,y,pixels,width,height,time,camera,stats,feature_mask);
498 });
499 });
500 global_gpu_queue->wait_and_throw();
501#endif
502
503 const auto t0 = event.template get_profiling_info<sycl::info::event_profiling::command_start>();
504 const auto t1 = event.template get_profiling_info<sycl::info::event_profiling::command_end>();
505 const double dt = (t1-t0)*1E-9;
506 ((ISPCCamera*)&camera)->render_time = dt;
507
508#else
509 /* render image */
510 const int numTilesX = (width +TILE_SIZE_X-1)/TILE_SIZE_X;
511 const int numTilesY = (height+TILE_SIZE_Y-1)/TILE_SIZE_Y;
512 parallel_for(size_t(0),size_t(numTilesX*numTilesY),[&](const range<size_t>& range) {
513 const int threadIndex = (int)TaskScheduler::threadIndex();
514 for (size_t i=range.begin(); i<range.end(); i++)
515 renderTileTask((int)i,threadIndex,pixels,width,height,time,camera,numTilesX,numTilesY);
516 });
517#endif
518
519 if (!data.visualize_errors)
520 {
521 for (size_t y=0; y<height; y++) {
522 for (size_t x=0; x<width; x++) {
523 if (pixels[y*width+x] == 0xFF) { // red indicates an error
524 embree_cout << "error at (" << int(x) << int(y) << ")" << embree_endl;

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