OptiX intersection

Discussion related to the LuxCore functionality, implementations and API.
Post Reply
User avatar
chuchur
Posts: 27
Joined: Tue Sep 15, 2020 8:44 am

OptiX intersection

Post by chuchur »

Hi all,

I just wonder which engines uses OptiX intersection acceleration?

I've made a couple of breakpoints in OptiX initialization code (optixaccel and optixaccelhw) and it stops only for OpenCl engines. Do CPU engines using OptiX intersection?

The other question: how OpenCl code and OptiX are working together? I have no experience with OpenCl, i've used only CUDA, so I would be grateful for an explanation.

Thanks in advance!
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: OptiX intersection

Post by Dade »

chuchur wrote: Wed Jun 23, 2021 8:09 am I just wonder which engines uses OptiX intersection acceleration?
PATHOCL and TILEPATHOCL when using a LuxRays CUDA hardware device (https://github.com/LuxCoreRender/LuxCor ... hw.cpp#L52)
chuchur wrote: Wed Jun 23, 2021 8:09 am I've made a couple of breakpoints in OptiX initialization code (optixaccel and optixaccelhw) and it stops only for OpenCl engines. Do CPU engines using OptiX intersection?

The other question: how OpenCl code and OptiX are working together?
We had OpenCL only support before. I have than added an abstraction layer under the name of generic LuxRays hardware device so the CPU code was able to use OpenCL or CUDA devices. I have also modified the GPU kernel code to be just generic C so it was possible to compile the same sources both with OpenCL and CUDA.

This made possible to run thousand of lines of existing code both with OpenCL or CUDA.

However I have not updated the terminology used (for compatibility with the past): PATHOCL has still the same name but it works with CUDA (and Optix) too. Now everywhere you see "OpenCL", it means OpenCL or CUDA. Outside LuxRays hardware device code where real OpenCL or CUDA API are used:

https://github.com/LuxCoreRender/LuxCor ... e.cpp#L106
https://github.com/LuxCoreRender/LuxCor ... e.cpp#L148

LuxCore auto-detect OpenCL, CUDA and Optix and uses the best combination available by default.
chuchur wrote: Wed Jun 23, 2021 8:09 am Do CPU engines using OptiX intersection?
Nope. We use Intel Embree: https://github.com/LuxCoreRender/LuxCor ... eaccel.cpp
Support LuxCoreRender project with salts and bounties
User avatar
chuchur
Posts: 27
Joined: Tue Sep 15, 2020 8:44 am

Re: OptiX intersection

Post by chuchur »

Wow, thanks for the clear explanation!

I just wonder how do you combine rays emission/intersection/shading/shadowing on GPU side? Is it something like Wavefront Path Tracing used in PBRT (https://research.nvidia.com/sites/defau ... _paper.pdf) or Megakernel approach?

In the case of Megakernel how do you plug OptiX intersection call into it? Do you use OptiX only for intersection calculations?

Thanks for answering!
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: OptiX intersection

Post by Dade »

chuchur wrote: Wed Jun 23, 2021 9:32 am I just wonder how do you combine rays emission/intersection/shading/shadowing on GPU side? Is it something like Wavefront Path Tracing used in PBRT (https://research.nvidia.com/sites/defau ... _paper.pdf) or Megakernel approach?
Each GPU thread is a state machine iterating over various states (https://github.com/LuxCoreRender/LuxCor ... pes.cl#L42).

I run, in a loop, a set of kernels executing each machine state:

https://github.com/LuxCoreRender/LuxCor ... d.cpp#L183
https://github.com/LuxCoreRender/LuxCor ... s.cpp#L514

Indeed, the state machine compute a sample with path tracing and add it to the film.

I developed this solution on my own and improved it in 2014 with micro-kernels: https://twitter.com/Dade916/status/528214623993212930

Yes, you can call it "Wavefront Path Tracing". The principle is the same but I think I developed it before the paper was published.
chuchur wrote: Wed Jun 23, 2021 9:32 am Do you use OptiX only for intersection calculations?
Yes, one of the state is just "trace rays", it takes an array of rays and returns an array of ray hits: https://github.com/LuxCoreRender/LuxCor ... ixaccel.cl

This is simply the perfect scenario for Optix and GPUs. You are not going to find something that can trace rays faster.

P.S. Mega-kernels are rubbish, dinosaurs.
Support LuxCoreRender project with salts and bounties
User avatar
chuchur
Posts: 27
Joined: Tue Sep 15, 2020 8:44 am

Re: OptiX intersection

Post by chuchur »

Hey Dade, thank you for the explanation.

I hope, I could help a bit with luxcorerender development (I've done something like an illuminance sensor for old good lux render, but never try to push it into the repository). I'll put my note into "LuxCoreRender Project wants you!" topic :)
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: OptiX intersection

Post by Dade »

Sure, you are welcome. Just try to pick a small topic to start with: it is a lot of code to look at if you consider the full spectrum of features (CPUs, GPUs, OpenCL, CUDA, Optix, etc.).
Support LuxCoreRender project with salts and bounties
User avatar
Sharlybg
Donor
Donor
Posts: 3101
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: OptiX intersection

Post by Sharlybg »

chuchur wrote: Wed Jun 23, 2021 11:15 am Hey Dade, thank you for the explanation.

I hope, I could help a bit with luxcorerender development (I've done something like an illuminance sensor for old good lux render, but never try to push it into the repository). I'll put my note into "LuxCoreRender Project wants you!" topic :)
Hi Chuchur !
Can only say welcome to you an good luck with this intiative. Sure it is well apreciated ;)
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA
Post Reply