Intel® Embree Ray Tracing Kernels
Discussion forum on the open source ray tracing kernels for fast photo-realistic rendering on Intel® CPUs.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

rtcCommit(Threads) callback

Igor_Igor
Beginner
154 Views

Hello

Building bvh takes a noticeable time with large geometry, thus users ask for showing progress and cancelling. How to implement this?

Thx

 

0 Kudos
4 Replies
SvenW_Intel
Moderator
154 Views

Search for numGeneratedPrims in kernels/xeon/bvh4/bvh4_builder_hair.cpp for an example implementation of showing progress. You have to duplicate that implementation also in bvh4_builder.cpp bvh8_builder.cpp.

How large are the models that cause problems? Does the machine have suficient memory to complete the build without swapping?

One simply way to implement cancelling is to add some cancel flag to your applications, and test if the flag is set in the createLeaf functions of the builders. If the flag is set just throw an exception. This will terminate Embree and should allow you to restart Embree through rtcInit again.

Igor_Igor
Beginner
154 Views

Thx for the essential answer. A some delay/pause occurs with millions of polys, it's normal, building large data takes some time, just users want to see "what's going on". 

One detail: both rtcCommit and rtcCommitThread use threads to build bvh, correct? If I'm interested in TaskScheduler for building only, should I use rtcCommit?

Thx


 

SvenW_Intel
Moderator
154 Views

Yes, both functions use multiple threads to build the BVH. The rtcCommit function will automatically use all thread available in the system, thus best use that function. 

Igor_Igor
Beginner
154 Views

Unfortunately, not all is so simple.

1. Throwing exception is caight in thread and forces exit from app (not from rtcCommit)

  void TaskScheduler::threadFunction(void* ptr) try
  {
    Thread thread = *(Thread*) ptr;
    delete (Thread*) ptr;

    thread.scheduler->run(thread.threadIndex,thread.threadCount);
  }
  catch (const std::exception& e) {
    std::cout << "Error: " << e.what() << std::endl;
    exit(1);
  }

2. I can update UI from only main thread (not from any Embree work thread). Thus I need to create a task, post it to main thread, terminate threads (if cancelled) etc.  It's a lot of changes that I should repeat for any new Embree build. If there is a better way - please suggest

Thx

 

Reply