Page 1 of 4

New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 11:28 am
by Dade
Introduction

The new OpenCL code for evaluating textures and materials is finished. Its major feature is to not require dynamic kernel compilation anymore. So there is just one kernel compilation for each render engine and that is it.

For v2.4

The code is available on "for_v2.4" branch and will be included in v2.4 related releases.

Compile once

The OpenCL is now compiled once (for each render engine and for each new release) and cached. However it is a lot code to compile, it takes about 90secs with NVIDIA drivers and a AMD 3900x CPU. AMD GPU driver is likely to take more.

The most logic step would be compile the kernels at installation time. It is easy to do, it is just one LuxCore API call (KernelCacheFill()) however I have the impression Blender doesn't call anything after having installed a new plugin :?:

It may be done the first time you run the Blender with the plugin enabled :?:

The situation requires to be extra-careful because it will give the feeling at first-time users that everything is just frozen the moment they do the very first rendering: there must be some big informational note about what is going on.

RTPATHOCL

Thanks to this change, for the first time, it should be viable to use GPU rendering for view-port interactive rendering/editing.

P.S. can someone test this stuff with AMD GPUs. I don't have anymore an AMD GPU installed in my main PC.

Re: New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 11:52 am
by marcatore
Supernice!!
fantastic!!!

Eager to test it!!!!! :)

Re: New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 12:03 pm
by Sharlybg
:twisted: :twisted: :twisted: that is Glory days ! Well done Dade :D

Re: New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 12:04 pm
by B.Y.O.B.
A long-time dream comes true. Thanks Dade!
Dade wrote: Fri Feb 21, 2020 11:28 am The most logic step would be compile the kernels at installation time. It is easy to do, it is just one LuxCore API call (KernelCacheFill()) however I have the impression Blender doesn't call anything after having installed a new plugin :?:
There is no special handler.
The register() function of the addon is called, so we can run code, however it is also called whenever Blender is started (not only after the installation).

Is there a way to check if the call to KernelCacheFill() is necessary?
I think Cycles (and some other engines, like VRayRT) compile the OpenCL kernels during the start of the first render. We could do the same (it is also a place where we can show messages about it, I don't think that's possible during register()).

Re: New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 12:07 pm
by alpistinho
Sounds great =)

I have a RX 580 + Ryzen 3600 and can test on Windows (I and Linux OpenCL drivers share a mutual hate for each other).
Will compile it as soon as a stop in front of the computer

Re: New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 12:21 pm
by juangea
Wow this is going to be awesome!

Yesterday I was having a kernel compilation that lasted 15 minutes! I hope this solves everything :) I'm eager to test it!!!!

Re: New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 12:56 pm
by zuljin3d
Great news!!!! :o

Re: New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 1:04 pm
by juangea
Regarding the moment of kernel compile... Why not put a button in settings called "Compile Kernel" with a warning explaining that Blender will be frozen for some minutes.

After that if someone has not compiled the kernel and enable OpenCl a message could appear saying "Please compile kernel, Blender will froze for some minutes" and inside the message the same button to compile it.

That will give the user the consciousness that something is happening and that if Blender froze is normal and they have to wait, and at the same time the power to decide if they want to wait or not.

What do you think? :)

Re: New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 1:28 pm
by Dade
B.Y.O.B. wrote: Fri Feb 21, 2020 12:04 pm Is there a way to check if the call to KernelCacheFill() is necessary?
I could add a dedicated function (however calling KernelCacheFill() when the cache is already filled takes no time).
B.Y.O.B. wrote: Fri Feb 21, 2020 12:04 pm I think Cycles (and some other engines, like VRayRT) compile the OpenCL kernels during the start of the first render. We could do the same (it is also a place where we can show messages about it, I don't think that's possible during register()).
This is exactly how it works now however I'm a bit worried that a new user will not notice the little label "Compile OpenCL kernel" and it will assume everything is frozen.

Re: New OpenCL textures and materials evaluation code

Posted: Fri Feb 21, 2020 1:30 pm
by lacilaci
I wouldn't worry about first time compilation... just have addon give a message about the kernel compilation and that's it

it is how blender optix/rtx cycles does it, and also how vray rt does it. Each update of the renderer/plugin triggers this "first time run compilation". I think people should be used to this already