Page 1 of 1

OpenCL

Posted: Thu Oct 11, 2018 9:17 pm
by B.Y.O.B.
Some questions:
  • I have fixed what I believe was a copy-paste mistake in the subtract texture:
    https://github.com/LuxCoreRender/LuxCor ... 396ea99f28
    I noticed that the subtract and add textures are declared OPENCL_FORCE_INLINE, while the scale texture is declared OPENCL_FORCE_NOT_INLINE. Why is that? Aren't they all doing the same thing, just with different operators? Is there something I'm not seeing?
  • It seems like the OpenCL code clamps some colors implicitly, for example the matte material "kd". This creates a difference between CPU renders and OpenCL renders because this clamping does not happen in C++ code. See attached example image. Why the inconsistency?

Re: OpenCL

Posted: Fri Oct 12, 2018 10:45 am
by Dade
B.Y.O.B. wrote: Thu Oct 11, 2018 9:17 pm Some questions:
  • I have fixed what I believe was a copy-paste mistake in the subtract texture:
    https://github.com/LuxCoreRender/LuxCor ... 396ea99f28
    I noticed that the subtract and add textures are declared OPENCL_FORCE_INLINE, while the scale texture is declared OPENCL_FORCE_NOT_INLINE. Why is that? Aren't they all doing the same thing, just with different operators? Is there something I'm not seeing?
It is the work around to NVIDIA OpenCL compiler problems. It is more the result of Voodoo magic than some rational action. I would use OPENCL_FORCE_NOT_INLINE also for subtract and add (i.e. better safe than sorry).
B.Y.O.B. wrote: Thu Oct 11, 2018 9:17 pm
  • It seems like the OpenCL code clamps some colors implicitly, for example the matte material "kd". This creates a difference between CPU renders and OpenCL renders because this clamping does not happen in C++ code. See attached example image. Why the inconsistency?
Colors are clamped both in C++ and OpenCL. The problem arise from the different default values of Spectrum::Clamp(min, max), it is [0.f, 1.f] in OpenCL and [0.f, INFINITY] in C++. The C++ version is quite misleading but it comes from when the same code was used inside old Lux. I should have fixed all C++ Clamp() call now.

Re: OpenCL

Posted: Fri Oct 12, 2018 10:49 am
by B.Y.O.B.
Dade wrote: Fri Oct 12, 2018 10:45 am I would use OPENCL_FORCE_NOT_INLINE also for subtract and add (i.e. better safe than sorry).
Ok, should we implement this in the master branch or in my new_math_textures branch?
My plan was to implement OpenCL support for the Remap texture and the ObjectID textures, then apply for first merge of the new_math_textures branch into master. (More math textures can be implemented later)
If I do this in the next days, do you think we can include it in v2.1?