diff options
author | Patrick Mours <pmours@nvidia.com> | 2020-02-17 15:35:31 +0300 |
---|---|---|
committer | Patrick Mours <pmours@nvidia.com> | 2020-02-17 16:27:44 +0300 |
commit | 2278aa0da9d6a046ff014fab4b0cc6156394b0d1 (patch) | |
tree | 7c9e494c59875fb5f0004bfc40c9fa29521b365b /intern/cycles/device/device_optix.cpp | |
parent | 12b6ddaf953056e36f1e86d7d79537cb8b3dbe4e (diff) |
Cycles: Add support for adaptive kernel compilation to OptiX device
This modifies the common CUDA implementation for adaptive kernel compilation slightly to support both CUBIN and PTX output (the latter which is then used in the OptiX device). It also fixes adaptive kernel compilation on Windows.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D6851
Diffstat (limited to 'intern/cycles/device/device_optix.cpp')
-rw-r--r-- | intern/cycles/device/device_optix.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/intern/cycles/device/device_optix.cpp b/intern/cycles/device/device_optix.cpp index 39110cc0959..2ce8bed3783 100644 --- a/intern/cycles/device/device_optix.cpp +++ b/intern/cycles/device/device_optix.cpp @@ -293,6 +293,23 @@ class OptiXDevice : public CUDADevice { return BVH_LAYOUT_OPTIX; } + string compile_kernel_get_common_cflags(const DeviceRequestedFeatures &requested_features, + bool filter, + bool /*split*/) override + { + // Split kernel is not supported in OptiX + string common_cflags = CUDADevice::compile_kernel_get_common_cflags( + requested_features, filter, false); + + // Add OptiX SDK include directory to include paths + const char *optix_sdk_path = getenv("OPTIX_ROOT_DIR"); + if (optix_sdk_path) { + common_cflags += string_printf(" -I\"%s/include\"", optix_sdk_path); + } + + return common_cflags; + } + bool load_kernels(const DeviceRequestedFeatures &requested_features) override { if (have_error()) { @@ -367,9 +384,11 @@ class OptiXDevice : public CUDADevice { } { // Load and compile PTX module with OptiX kernels - string ptx_data; - const string ptx_filename = "lib/kernel_optix.ptx"; - if (!path_read_text(path_get(ptx_filename), ptx_data)) { + string ptx_data, ptx_filename = path_get("lib/kernel_optix.ptx"); + if (use_adaptive_compilation()) { + ptx_filename = compile_kernel(requested_features, "kernel_optix", "optix", true); + } + if (ptx_filename.empty() || !path_read_text(ptx_filename, ptx_data)) { set_error("Failed loading OptiX kernel " + ptx_filename + "."); return false; } |