This patch adds a new device implementation to Cycles which uses NVIDIA OptiX to support hardware accelerated ray tracing on NVIDIA RTX GPUs.
The diff also includes a few other optimizations tailored towards OptiX:
- The kernel code was rearranged in some places to avoid conditional trace calls (by evaluating the condition separate from the trace itself), since currently those tend to hurt code generation in OptiX. This should not affect other APIs negatively.
- It also has some variables initialized to zero to help the compiler, as it generated more spills otherwise.
- Most functions were inlined to avoid call overhead in OptiX (but were left as before for other APIs).
- The SVM decode_node_uchar4 function was split up, since doing so caused the compiler to generate better code.
- The BVH class was modified slightly to allow it to access the device class. OptiX acceleration structure building requires access to the OptiX context, so it must be piped through the device.
- An old CUDA workaround was removed in scene_intersect, since I couldn't reproduce a bug here and it caused worse code generation.
- Some missing kernel feature checks were added as it failed to compile with those disabled.
- You first need to install the CUDA 10.1 toolkit and OptiX SDK 7.0 to the default location (or set the OPTIX_INCLUDE_DIR CMake variable manually in the following steps). The download page may require you to register a developer account at NVIDIA.
- Set up a Blender build environment as usual but download and apply this patch to the Git repository (Download Raw Diff on the right via Save Link As and then run git apply D5363.diff with the downloaded file in your local repository after syncing to latest master branch).
- Continue following the usual Blender build instructions (run make full). It will build with OptiX by default (see also the WITH_CYCLES_DEVICE_OPTIX CMake variable).
- Download and install the NVIDIA Driver 435 Pre-Release (you'll need that specific version for now). Again, the download page may require you to register a developer account.
- Launch the Blender executable you built previously and head over to the preferences (Edit > Preferences > System > Cycles Render Devices) to enable OptiX. Then select one or more of the supported GPUs in your system in the list below that option (only RTX GPUs are supported at this point and they will only show up with the driver from above installed).
- Everything is now set up. Next time you start a render in Cycles, and you have a supported GPU, it will be accelerated using OptiX (provided that the scene has the Device type set to GPU Compute in its render settings). Note: The very first start may take a minute or two longer, since OptiX must compile and cache the render kernels once.
In case you run into issues, starting Blender with --debug-cycles will turn on log output from OptiX which can help troubleshooting.