[Bf-blender-cvs] [956f318fd6d] cycles-x: Cycles X: make OptiX 7.3 the minimum required SDK version
Brecht Van Lommel
noreply at git.blender.org
Wed Jul 14 17:50:47 CEST 2021
Commit: 956f318fd6d580d298600582c605c33eb4728df5
Author: Brecht Van Lommel
Date: Fri Jul 9 15:29:53 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB956f318fd6d580d298600582c605c33eb4728df5
Cycles X: make OptiX 7.3 the minimum required SDK version
This ensure the new faster builtin curve intersection is used, and lets us
simplify the code a bit.
Differential Revision: https://developer.blender.org/D11866
===================================================================
M build_files/cmake/Modules/FindOptiX.cmake
M build_files/config/pipeline_config.json
M intern/cycles/CMakeLists.txt
M intern/cycles/device/optix/device_impl.cpp
M intern/cycles/device/optix/device_impl.h
M intern/cycles/kernel/device/optix/kernel.cu
===================================================================
diff --git a/build_files/cmake/Modules/FindOptiX.cmake b/build_files/cmake/Modules/FindOptiX.cmake
index cfcdd9cd23b..67106740f57 100644
--- a/build_files/cmake/Modules/FindOptiX.cmake
+++ b/build_files/cmake/Modules/FindOptiX.cmake
@@ -33,11 +33,23 @@ FIND_PATH(OPTIX_INCLUDE_DIR
include
)
+IF(EXISTS "${OPTIX_INCLUDE_DIR}/optix.h")
+ FILE(STRINGS "${OPTIX_INCLUDE_DIR}/optix.h" _optix_version REGEX "^#define OPTIX_VERSION[ \t].*$")
+ STRING(REGEX MATCHALL "[0-9]+" _optix_version ${_optix_version})
+
+ MATH(EXPR _optix_version_major "${_optix_version} / 10000")
+ MATH(EXPR _optix_version_minor "(${_optix_version} % 10000) / 100")
+ MATH(EXPR _optix_version_patch "${_optix_version} % 100")
+
+ SET(OPTIX_VERSION "${_optix_version_major}.${_optix_version_minor}.${_optix_version_patch}")
+ENDIF()
+
# handle the QUIETLY and REQUIRED arguments and set OPTIX_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(OptiX DEFAULT_MSG
- OPTIX_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OptiX
+ REQUIRED_VARS OPTIX_INCLUDE_DIR
+ VERSION_VAR OPTIX_VERSION)
IF(OPTIX_FOUND)
SET(OPTIX_INCLUDE_DIRS ${OPTIX_INCLUDE_DIR})
@@ -45,6 +57,7 @@ ENDIF()
MARK_AS_ADVANCED(
OPTIX_INCLUDE_DIR
+ OPTIX_VERSION
)
UNSET(_optix_SEARCH_DIRS)
diff --git a/build_files/config/pipeline_config.json b/build_files/config/pipeline_config.json
index c9a5e25eaaf..a353d35bd6c 100644
--- a/build_files/config/pipeline_config.json
+++ b/build_files/config/pipeline_config.json
@@ -33,7 +33,7 @@
{
"optix":
{
- "version": "7.1.0"
+ "version": "7.3.0"
},
"cuda10":
{
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 2994b623ce5..6d10c2be7d3 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -247,7 +247,7 @@ if(WITH_CYCLES_OSL)
endif()
if(WITH_CYCLES_DEVICE_OPTIX)
- find_package(OptiX)
+ find_package(OptiX 7.3.0)
if(OPTIX_FOUND)
add_definitions(-DWITH_OPTIX)
diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp
index 5c9ffa0ece2..5b9d99dd463 100644
--- a/intern/cycles/device/optix/device_impl.cpp
+++ b/intern/cycles/device/optix/device_impl.cpp
@@ -89,11 +89,9 @@ OptiXDevice::OptiXDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
}
};
# endif
-# if OPTIX_ABI_VERSION >= 41
if (DebugFlags().optix.use_debug) {
options.validationMode = OPTIX_DEVICE_CONTEXT_VALIDATION_MODE_ALL;
}
-# endif
optix_assert(optixDeviceContextCreate(cuContext, &options, &context));
# ifdef WITH_CYCLES_LOGGING
optix_assert(optixDeviceContextSetLogCallback(
@@ -214,10 +212,8 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
}
-# if OPTIX_ABI_VERSION >= 41
module_options.boundValues = nullptr;
module_options.numBoundValues = 0;
-# endif
OptixPipelineCompileOptions pipeline_options = {};
/* Default to no motion blur and two-level graph, since it is the fastest option. */
@@ -229,18 +225,14 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
pipeline_options.exceptionFlags = OPTIX_EXCEPTION_FLAG_NONE;
pipeline_options.pipelineLaunchParamsVariableName = "__params"; /* See globals.h */
-# if OPTIX_ABI_VERSION >= 36
pipeline_options.usesPrimitiveTypeFlags = OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE;
if (kernel_features & KERNEL_FEATURE_HAIR) {
-# if OPTIX_ABI_VERSION >= 47
if (kernel_features & KERNEL_FEATURE_HAIR_THICK) {
pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_CUBIC_BSPLINE;
}
else
-# endif
pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_CUSTOM;
}
-# endif
/* Keep track of whether motion blur is enabled, so to enable/disable motion in BVH builds
* This is necessary since objects may be reported to have motion if the Vector pass is
@@ -325,23 +317,8 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
group_descs[PG_HITS].hitgroup.entryFunctionNameAH = "__anyhit__kernel_optix_shadow_all_hit";
if (kernel_features & KERNEL_FEATURE_HAIR) {
- group_descs[PG_HITD].hitgroup.moduleIS = optix_module;
- group_descs[PG_HITS].hitgroup.moduleIS = optix_module;
-
- /* Add curve intersection programs. */
- if (kernel_features & KERNEL_FEATURE_HAIR_THICK) {
- /* Slower programs for thick hair since that also slows down ribbons.
- * Ideally this should not be needed. */
- group_descs[PG_HITD].hitgroup.entryFunctionNameIS = "__intersection__curve_all";
- group_descs[PG_HITS].hitgroup.entryFunctionNameIS = "__intersection__curve_all";
- }
- else {
- group_descs[PG_HITD].hitgroup.entryFunctionNameIS = "__intersection__curve_ribbon";
- group_descs[PG_HITS].hitgroup.entryFunctionNameIS = "__intersection__curve_ribbon";
- }
-
-# if OPTIX_ABI_VERSION >= 47
if (kernel_features & KERNEL_FEATURE_HAIR_THICK) {
+ /* Built-in thick curve intersection. */
OptixBuiltinISOptions builtin_options = {};
builtin_options.builtinISModuleType = OPTIX_PRIMITIVE_TYPE_ROUND_CUBIC_BSPLINE;
builtin_options.usesMotionBlur = false;
@@ -366,7 +343,13 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
group_descs[PG_HITS_MOTION].hitgroup.moduleIS = builtin_modules[1];
}
}
-# endif
+ else {
+ /* Custom ribbon intersection. */
+ group_descs[PG_HITD].hitgroup.moduleIS = optix_module;
+ group_descs[PG_HITS].hitgroup.moduleIS = optix_module;
+ group_descs[PG_HITD].hitgroup.entryFunctionNameIS = "__intersection__curve_ribbon";
+ group_descs[PG_HITS].hitgroup.entryFunctionNameIS = "__intersection__curve_ribbon";
+ }
}
if (kernel_features & (KERNEL_FEATURE_SUBSURFACE | KERNEL_FEATURE_NODE_RAYTRACE)) {
@@ -414,12 +397,10 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
trace_css = std::max(trace_css, stack_size[PG_HITD].cssIS + stack_size[PG_HITD].cssAH);
trace_css = std::max(trace_css, stack_size[PG_HITS].cssIS + stack_size[PG_HITS].cssAH);
trace_css = std::max(trace_css, stack_size[PG_HITL].cssIS + stack_size[PG_HITL].cssAH);
-# if OPTIX_ABI_VERSION >= 47
trace_css = std::max(trace_css,
stack_size[PG_HITD_MOTION].cssIS + stack_size[PG_HITD_MOTION].cssAH);
trace_css = std::max(trace_css,
stack_size[PG_HITS_MOTION].cssIS + stack_size[PG_HITS_MOTION].cssAH);
-# endif
OptixPipelineLinkOptions link_options = {};
link_options.maxTraceDepth = 1;
@@ -431,10 +412,6 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
link_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
}
-# if OPTIX_ABI_VERSION < 24
- link_options.overrideUsesMotionBlur = motion_blur;
-# endif
-
if (kernel_features & KERNEL_FEATURE_NODE_RAYTRACE) {
/* Create shader raytracing pipeline. */
vector<OptixProgramGroup> pipeline_groups;
@@ -444,12 +421,10 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
pipeline_groups.push_back(groups[PG_HITD]);
pipeline_groups.push_back(groups[PG_HITS]);
pipeline_groups.push_back(groups[PG_HITL]);
-# if OPTIX_ABI_VERSION >= 47
if (motion_blur) {
pipeline_groups.push_back(groups[PG_HITD_MOTION]);
pipeline_groups.push_back(groups[PG_HITS_MOTION]);
}
-# endif
pipeline_groups.push_back(groups[PG_CALL_SVM_AO]);
pipeline_groups.push_back(groups[PG_CALL_SVM_BEVEL]);
@@ -484,12 +459,10 @@ bool OptiXDevice::load_kernels(const uint kernel_features)
pipeline_groups.push_back(groups[PG_HITD]);
pipeline_groups.push_back(groups[PG_HITS]);
pipeline_groups.push_back(groups[PG_HITL]);
-# if OPTIX_ABI_VERSION >= 47
if (motion_blur) {
pipeline_groups.push_back(groups[PG_HITD_MOTION]);
pipeline_groups.push_back(groups[PG_HITS_MOTION]);
}
-# endif
optix_assert(optixPipelineCreate(context,
&pipeline_options,
@@ -859,32 +832,16 @@ bool OptiXDevice::denoise_create_if_needed(DenoiseContext &context)
/* Create OptiX denoiser handle on demand when it is first used. */
OptixDenoiserOptions denoiser_options = {};
-# if OPTIX_ABI_VERSION >= 47
denoiser_options.guideAlbedo = context.use_pass_albedo;
denoiser_options.guideNormal = context.use_pass_normal;
const OptixResult result = optixDenoiserCreate(
this->context, OPTIX_DENOISER_MODEL_KIND_HDR, &denoiser_options, &denoiser_.optix_denoiser);
-# else
- denoiser_options.inputKind = static_cast<OptixDenoiserInputKind>(OPTIX_DENOISER_INPUT_RGB +
- (context.num_input_passes - 1));
-# if OPTIX_ABI_VERSION < 28
- denoiser_options.pixelFormat = OPTIX_PIXEL_FORMAT_FLOAT3;
-# endif
-
- const OptixResult result = optixDenoiserCreate(
- this->context, &denoiser_options, &denoiser_.optix_denoiser);
-# endif
if (result != OPTIX_SUCCESS) {
set_error("Failed to create OptiX denoiser");
return false;
}
-# if OPTIX_ABI_VERSION < 47
- optix_assert(
- optixDenoiserSetModel(denoiser_.optix_denoiser, OPTIX_DENOISER_MODEL_KIND_HDR, nullptr, 0));
-# endif
-
/* OptiX denoiser handle was created with the requested number of input passes. */
denoiser_.use_pass_albedo = context.use_pass_albedo;
denoiser_.use_pass_normal = context.use_pass_normal;
@@ -908,11 +865,7 @@ bool OptiXDevice::denoise_configure_if_needed(DenoiseContext &context)
optix_assert(optixDenoiserComputeMemoryResources(
denoiser_.optix_denoiser, buffer_params.width, buffer_params.height, &sizes));
-# if OPTIX_ABI_VERSION < 28
- denoiser_.scratch_size = sizes.recommendedScratchSizeInBytes;
-# else
denoiser_.scratch_size = sizes.withOverlapScratchSizeInBytes;
-# endif
denoiser_.scratch_offset = sizes.stateSizeInBytes;
/* Allocate denoiser state if tile size has changed since last setup. */
@@ -999,7 +952,6 @@ bool OptiXDevice::denoise
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list