LuxCore: abstract API

Discussion related to the implementation of new features & algorithms to the Core Engine.

Moderators: Dade, jromang, tomb, zcott, coordinators

LuxCore: abstract API

Postby Dade » Mon Mar 13, 2017 3:10 am


LuxCore API was lacking of abstraction over some implementation detail (exposed in luxcore.h) and, more than anything else, it was forcing the application to use LuxRays API and Boost library. This kind of problems as be now solved: including luxcore.h and linking to the library are now the only two requirements. This step was a pre-requisite to be able to release a binary SDK.


LuxCore API now uses a factory pattern to hide the implementations details and to require to only include luxcore.h. To allocate a LuxCore object, instead of a:

Code: Select all
RenderSession *session = new RenderSession(config);

you have now to use:

Code: Select all
RenderSession *session = RenderSession::Create(config);

It should be quite easy to fix old code as you have only to replace "new" with static method "Create", nothing else.

LuxRays Property/Properties

Property/Properties classes are the only LuxRays objects still used in LuxCore API, they are now a stand alone header so it is now the only part of LuxRays required by LuxCore.


To avoid to force the usage of LuxRays, the method Scene::DefineMesh() taking a luxrays::ExtMesh as parameter has been removed. The other method Scene::DefineMesh() now uses generic type pointers (float, int, etc.) instead of LuxRays types (Point, Normal, Triangle, etc.):

Code: Select all
void DefineMesh(const std::string &meshName,
      const long plyNbVerts, const long plyNbTris,
      float *p, unsigned int *vi, float *n, float *uv,
      float *cols, float *alphas)

Note: to update an existing application using LuxCore, you have only to casting some pointer, like here => ... mo.cpp-145


To avoid to force the usage of LuxRays, Scene::UpdateObjectTransformation() doesn't uses luxrays::Transform object anymore:

Code: Select all
void UpdateObjectTransformation(const std::string &objName, const float *transMat)

It directly uses the 4x4 float matrix.


A new function has been added to the API to obtain some information about LuxCore features available (for instance, if it has been compiled for OpenCL or not):

Code: Select all
 * \brief Return a list of properties describing the features available. The
 * properties currently supported are:
 * - version.number\n
 *      The LuxCore version. As string with "major.minor" version format.
 *      true or false if the sources has been compiled with LUXRAYS_DISABLE_OPENCL and
 *      OpenCL rendering engines are available or not.
 *      true or false if the sources has been compiled with LUXCORE_DISABLE_EMBREE_BVH_BUILDER and
 *      Embree BVH builder is used for OpenCL or not.
CPP_EXPORT CPP_API luxrays::Properties GetPlatformDesc();


To avoid to force the usage of LuxRays, a new function has been added to the API to return the list of OpenCL devices available:

Code: Select all
 * \brief Return the list of OpenCL devices available. For instance:
 * - = "GeForce GTX 980"
 * - opencl.device.0.type = "OPENCL_GPU"
 * - opencl.device.0.units = 16
 * - opencl.device.0.nativevectorwidthfloat = 1
 * - opencl.device.0.maxmemory = 4294770688
 * - opencl.device.0.maxmemoryallocsize = 1073692672
 * - = "Hawaii"
 * - opencl.device.1.type = "OPENCL_GPU"
 * - opencl.device.1.units = 44
 * - opencl.device.1.nativevectorwidthfloat = 1
 * - opencl.device.1.maxmemory = 3888119808
 * - opencl.device.1.maxmemoryallocsize = 2847670272
 * - = "Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz"
 * - opencl.device.2.type = "OPENCL_CPU"
 * - opencl.device.2.units = 12
 * - opencl.device.2.nativevectorwidthfloat = 8
 * - opencl.device.2.maxmemory = 16765145088
 * - opencl.device.2.maxmemoryallocsize = 4191286272
luxrays::Properties GetOpenCLDeviceDescs()


All samples has been updated to not require LuxRays anymore (but they still use Boost for portability).

Python API

Nothing has changed for LuxCore Python API aside the fact that the 2 new functions are available there too.
User avatar
Posts: 8404
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Return to Architecture & Design

Who is online

Users browsing this forum: No registered users and 1 guest