Add Chromium-only Blender WebEngine parity work
This commit is contained in:
123
blender-5.2.0/intern/cycles/device/optix/device.cpp
Normal file
123
blender-5.2.0/intern/cycles/device/optix/device.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/* SPDX-FileCopyrightText: 2019 NVIDIA Corporation
|
||||
* SPDX-FileCopyrightText: 2019-2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
#include "device/optix/device.h"
|
||||
#include "device/cuda/device.h"
|
||||
#include "device/device.h"
|
||||
|
||||
#ifdef WITH_OSL
|
||||
# include <OSL/oslconfig.h>
|
||||
# include <OSL/oslversion.h>
|
||||
#endif
|
||||
|
||||
#ifdef WITH_OPTIX
|
||||
# include "device/optix/device_impl.h"
|
||||
|
||||
# include "integrator/denoiser_oidn_gpu.h" // IWYU pragma: keep
|
||||
|
||||
# include <optix_function_table_definition.h>
|
||||
#endif
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
#ifndef OPTIX_FUNCTION_TABLE_SYMBOL
|
||||
# define OPTIX_FUNCTION_TABLE_SYMBOL g_optixFunctionTable
|
||||
#endif
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
bool device_optix_init()
|
||||
{
|
||||
#ifdef WITH_OPTIX
|
||||
if (OPTIX_FUNCTION_TABLE_SYMBOL.optixDeviceContextCreate != nullptr) {
|
||||
/* Already initialized function table. */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Need to initialize CUDA as well. */
|
||||
if (!device_cuda_init()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const OptixResult result = optixInit();
|
||||
|
||||
if (result == OPTIX_ERROR_UNSUPPORTED_ABI_VERSION) {
|
||||
LOG_WARNING << "OptiX initialization failed because the installed NVIDIA driver is too old. "
|
||||
"Please update to the latest driver first!";
|
||||
return false;
|
||||
}
|
||||
if (result != OPTIX_SUCCESS) {
|
||||
LOG_WARNING << "OptiX initialization failed with error code " << (unsigned int)result;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Loaded OptiX successfully! */
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void device_optix_info(const vector<DeviceInfo> &cuda_devices, vector<DeviceInfo> &devices)
|
||||
{
|
||||
#ifdef WITH_OPTIX
|
||||
devices.reserve(cuda_devices.size());
|
||||
|
||||
/* Simply add all supported CUDA devices as OptiX devices again. */
|
||||
for (DeviceInfo info : cuda_devices) {
|
||||
assert(info.type == DEVICE_CUDA);
|
||||
|
||||
int major;
|
||||
cuDeviceGetAttribute(&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, info.num);
|
||||
if (major < 5) {
|
||||
/* Only Maxwell and up are supported by OptiX. */
|
||||
continue;
|
||||
}
|
||||
|
||||
info.type = DEVICE_OPTIX;
|
||||
info.id += "_OptiX";
|
||||
# if defined(WITH_OSL) && defined(OSL_USE_OPTIX) && \
|
||||
(OSL_VERSION_MINOR >= 13 || OSL_VERSION_MAJOR > 1)
|
||||
info.has_osl = true;
|
||||
# endif
|
||||
info.denoisers |= DENOISER_OPTIX;
|
||||
# if defined(WITH_OPENIMAGEDENOISE)
|
||||
# if OIDN_VERSION >= 20300
|
||||
if (oidnIsCUDADeviceSupported(info.num)) {
|
||||
# else
|
||||
if (OIDNDenoiserGPU::is_device_supported(info)) {
|
||||
# endif
|
||||
info.denoisers |= DENOISER_OPENIMAGEDENOISE;
|
||||
}
|
||||
# endif
|
||||
|
||||
devices.push_back(info);
|
||||
}
|
||||
#else
|
||||
(void)cuda_devices;
|
||||
(void)devices;
|
||||
#endif
|
||||
}
|
||||
|
||||
unique_ptr<Device> device_optix_create(const DeviceInfo &info,
|
||||
Stats &stats,
|
||||
Profiler &profiler,
|
||||
bool headless)
|
||||
{
|
||||
#ifdef WITH_OPTIX
|
||||
return make_unique<OptiXDevice>(info, stats, profiler, headless);
|
||||
#else
|
||||
(void)info;
|
||||
(void)stats;
|
||||
(void)profiler;
|
||||
(void)headless;
|
||||
|
||||
LOG_FATAL << "Request to create OptiX device without compiled-in support. Should never happen.";
|
||||
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
26
blender-5.2.0/intern/cycles/device/optix/device.h
Normal file
26
blender-5.2.0/intern/cycles/device/optix/device.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "util/unique_ptr.h"
|
||||
#include "util/vector.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
class Device;
|
||||
class DeviceInfo;
|
||||
class Profiler;
|
||||
class Stats;
|
||||
|
||||
bool device_optix_init();
|
||||
|
||||
unique_ptr<Device> device_optix_create(const DeviceInfo &info,
|
||||
Stats &stats,
|
||||
Profiler &profiler,
|
||||
bool headless);
|
||||
|
||||
void device_optix_info(const vector<DeviceInfo> &cuda_devices, vector<DeviceInfo> &devices);
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
1995
blender-5.2.0/intern/cycles/device/optix/device_impl.cpp
Normal file
1995
blender-5.2.0/intern/cycles/device/optix/device_impl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
164
blender-5.2.0/intern/cycles/device/optix/device_impl.h
Normal file
164
blender-5.2.0/intern/cycles/device/optix/device_impl.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/* SPDX-FileCopyrightText: 2019 NVIDIA Corporation
|
||||
* SPDX-FileCopyrightText: 2019-2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef WITH_OPTIX
|
||||
|
||||
# include "device/cuda/device_impl.h"
|
||||
# include "device/optix/util.h" // IWYU pragma: keep
|
||||
# include "kernel/osl/globals.h"
|
||||
|
||||
# include "util/task.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
class BVHOptiX;
|
||||
struct KernelParamsOptiX;
|
||||
|
||||
/* List of OptiX program groups. */
|
||||
enum {
|
||||
/* Ray generation */
|
||||
PG_RGEN_INTERSECT_CLOSEST,
|
||||
PG_RGEN_INTERSECT_SHADOW,
|
||||
PG_RGEN_INTERSECT_SUBSURFACE,
|
||||
PG_RGEN_INTERSECT_VOLUME_STACK,
|
||||
PG_RGEN_INTERSECT_DEDICATED_LIGHT,
|
||||
PG_RGEN_INTERSECT_MNEE,
|
||||
PG_RGEN_SHADE_BACKGROUND,
|
||||
PG_RGEN_SHADE_LIGHT_NEE,
|
||||
PG_RGEN_SHADE_LIGHT_FORWARD,
|
||||
PG_RGEN_SHADE_SURFACE,
|
||||
PG_RGEN_SHADE_SURFACE_RAYTRACE,
|
||||
PG_RGEN_SHADE_VOLUME,
|
||||
PG_RGEN_SHADE_VOLUME_RAY_MARCHING,
|
||||
PG_RGEN_SHADE_SHADOW,
|
||||
PG_RGEN_SHADE_DEDICATED_LIGHT,
|
||||
PG_RGEN_EVAL_DISPLACE,
|
||||
PG_RGEN_EVAL_BACKGROUND,
|
||||
PG_RGEN_EVAL_CURVE_SHADOW_TRANSPARENCY,
|
||||
PG_RGEN_INIT_FROM_CAMERA,
|
||||
PG_RGEN_EVAL_VOLUME_DENSITY,
|
||||
|
||||
/* Miss */
|
||||
PG_MISS,
|
||||
|
||||
/* Hit */
|
||||
PG_HITD, /* Default hit group. */
|
||||
PG_HITS, /* __SHADOW_RECORD_ALL__ hit group. */
|
||||
PG_HITL, /* __BVH_LOCAL__ hit group (only used for triangles). */
|
||||
PG_HITV, /* __VOLUME__ hit group. */
|
||||
PG_HITD_MOTION,
|
||||
PG_HITS_MOTION,
|
||||
PG_HITL_MOTION,
|
||||
PG_HITV_MOTION,
|
||||
PG_HITD_CURVE_LINEAR,
|
||||
PG_HITS_CURVE_LINEAR,
|
||||
PG_HITV_CURVE_LINEAR,
|
||||
PG_HITL_CURVE_LINEAR,
|
||||
PG_HITD_CURVE_LINEAR_MOTION,
|
||||
PG_HITS_CURVE_LINEAR_MOTION,
|
||||
PG_HITV_CURVE_LINEAR_MOTION,
|
||||
PG_HITL_CURVE_LINEAR_MOTION,
|
||||
PG_HITD_CURVE_RIBBON,
|
||||
PG_HITS_CURVE_RIBBON,
|
||||
PG_HITV_CURVE_RIBBON,
|
||||
PG_HITL_CURVE_RIBBON,
|
||||
PG_HITD_POINTCLOUD,
|
||||
PG_HITS_POINTCLOUD,
|
||||
PG_HITV_POINTCLOUD,
|
||||
PG_HITL_POINTCLOUD,
|
||||
|
||||
/* Callable */
|
||||
PG_CALL_SVM_AO,
|
||||
PG_CALL_SVM_BEVEL,
|
||||
|
||||
NUM_PROGRAM_GROUPS
|
||||
};
|
||||
|
||||
static const int MISS_PROGRAM_GROUP_OFFSET = PG_MISS;
|
||||
static const int NUM_MISS_PROGRAM_GROUPS = 1;
|
||||
static const int HIT_PROGAM_GROUP_OFFSET = PG_HITD;
|
||||
static const int NUM_HIT_PROGRAM_GROUPS = 24;
|
||||
static const int CALLABLE_PROGRAM_GROUPS_BASE = PG_CALL_SVM_AO;
|
||||
static const int NUM_CALLABLE_PROGRAM_GROUPS = 2;
|
||||
|
||||
/* List of OptiX pipelines. */
|
||||
enum { PIP_SHADE, PIP_INTERSECT, NUM_PIPELINES };
|
||||
|
||||
/* A single shader binding table entry. */
|
||||
struct SbtRecord {
|
||||
char header[OPTIX_SBT_RECORD_HEADER_SIZE];
|
||||
};
|
||||
|
||||
class OptiXDevice : public CUDADevice {
|
||||
public:
|
||||
OptixDeviceContext context = nullptr;
|
||||
|
||||
OptixModule optix_module = nullptr;
|
||||
OptixModule mnee_module = nullptr;
|
||||
OptixModule shader_raytrace_module = nullptr;
|
||||
OptixModule builtin_modules[4] = {};
|
||||
OptixPipeline pipelines[NUM_PIPELINES] = {};
|
||||
OptixProgramGroup groups[NUM_PROGRAM_GROUPS] = {};
|
||||
OptixPipelineCompileOptions pipeline_options = {};
|
||||
|
||||
# ifdef WITH_OSL
|
||||
OSLGlobals osl_globals;
|
||||
vector<OptixModule> osl_modules;
|
||||
vector<OptixProgramGroup> osl_groups;
|
||||
OptixModule osl_camera_module = nullptr;
|
||||
OptixModule osl_volume_module = nullptr;
|
||||
device_vector<uint8_t> osl_colorsystem;
|
||||
# endif
|
||||
|
||||
device_vector<SbtRecord> sbt_data;
|
||||
device_only_memory<KernelParamsOptiX> launch_params;
|
||||
|
||||
private:
|
||||
OptixTraversableHandle tlas_handle = 0;
|
||||
vector<unique_ptr<device_only_memory<char>>> delayed_free_bvh_memory;
|
||||
thread_mutex delayed_free_bvh_mutex;
|
||||
|
||||
public:
|
||||
OptiXDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler, bool headless);
|
||||
~OptiXDevice() override;
|
||||
|
||||
BVHLayoutMask get_bvh_layout_mask(uint /*kernel_features*/) const override;
|
||||
|
||||
string compile_kernel_get_common_cflags(const uint kernel_features);
|
||||
|
||||
void create_optix_module(TaskPool &pool,
|
||||
OptixModuleCompileOptions &module_options,
|
||||
string &ptx_data,
|
||||
OptixModule &module,
|
||||
OptixResult &failure_reason);
|
||||
|
||||
bool load_kernels(const uint kernel_features) override;
|
||||
|
||||
bool load_osl_kernels() override;
|
||||
|
||||
bool build_optix_bvh(BVHOptiX *bvh,
|
||||
OptixBuildOperation operation,
|
||||
const OptixBuildInput &build_input,
|
||||
uint16_t num_motion_steps);
|
||||
|
||||
void build_bvh(BVH *bvh, Progress &progress, bool refit) override;
|
||||
|
||||
void release_bvh(BVH *bvh) override;
|
||||
void free_bvh_memory_delayed();
|
||||
|
||||
void const_copy_to(const char *name, void *host, const size_t size) override;
|
||||
|
||||
void update_launch_params(const size_t offset, void *data, const size_t data_size);
|
||||
|
||||
unique_ptr<DeviceQueue> gpu_queue_create() override;
|
||||
|
||||
OSLGlobals *get_cpu_osl_memory() override;
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* WITH_OPTIX */
|
||||
231
blender-5.2.0/intern/cycles/device/optix/queue.cpp
Normal file
231
blender-5.2.0/intern/cycles/device/optix/queue.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
#ifdef WITH_OPTIX
|
||||
|
||||
# include "device/optix/queue.h"
|
||||
# include "device/optix/device_impl.h"
|
||||
|
||||
# define __KERNEL_OPTIX__
|
||||
# include "kernel/device/optix/globals.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* CUDADeviceQueue */
|
||||
|
||||
OptiXDeviceQueue::OptiXDeviceQueue(OptiXDevice *device) : CUDADeviceQueue(device) {}
|
||||
|
||||
void OptiXDeviceQueue::init_execution()
|
||||
{
|
||||
CUDADeviceQueue::init_execution();
|
||||
}
|
||||
|
||||
static bool is_optix_specific_kernel(DeviceKernel kernel, bool osl_shading, bool osl_camera)
|
||||
{
|
||||
# ifdef WITH_OSL
|
||||
/* OSL uses direct callables to execute, so shading needs to be done in OptiX if OSL is used. */
|
||||
if (osl_shading && device_kernel_has_shading(kernel)) {
|
||||
return true;
|
||||
}
|
||||
if (osl_camera && kernel == DEVICE_KERNEL_INTEGRATOR_INIT_FROM_CAMERA) {
|
||||
return true;
|
||||
}
|
||||
# else
|
||||
(void)osl_shading;
|
||||
(void)osl_camera;
|
||||
# endif
|
||||
|
||||
return device_kernel_has_intersection(kernel);
|
||||
}
|
||||
|
||||
bool OptiXDeviceQueue::enqueue(DeviceKernel kernel,
|
||||
const int work_size,
|
||||
const DeviceKernelArguments &args)
|
||||
{
|
||||
OptiXDevice *const optix_device = static_cast<OptiXDevice *>(cuda_device_);
|
||||
|
||||
# ifdef WITH_OSL
|
||||
const OSLGlobals *og = static_cast<const OSLGlobals *>(optix_device->get_cpu_osl_memory());
|
||||
const bool osl_shading = og->use_shading;
|
||||
const bool osl_camera = og->use_camera;
|
||||
# else
|
||||
const bool osl_shading = false;
|
||||
const bool osl_camera = false;
|
||||
# endif
|
||||
|
||||
if (!is_optix_specific_kernel(kernel, osl_shading, osl_camera)) {
|
||||
return CUDADeviceQueue::enqueue(kernel, work_size, args);
|
||||
}
|
||||
|
||||
if (cuda_device_->have_error()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
debug_enqueue_begin(kernel, work_size);
|
||||
|
||||
const CUDAContextScope scope(cuda_device_);
|
||||
|
||||
const device_ptr sbt_data_ptr = optix_device->sbt_data.device_pointer;
|
||||
const device_ptr launch_params_ptr = optix_device->launch_params.device_pointer;
|
||||
|
||||
auto set_launch_param = [&](size_t offset, size_t size, int arg) {
|
||||
cuda_device_assert(
|
||||
cuda_device_,
|
||||
cuMemcpyHtoDAsync(launch_params_ptr + offset, args.values[arg], size, cuda_stream_));
|
||||
};
|
||||
|
||||
set_launch_param(offsetof(KernelParamsOptiX, path_index_array), sizeof(device_ptr), 0);
|
||||
|
||||
if (kernel == DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST || device_kernel_has_shading(kernel)) {
|
||||
set_launch_param(offsetof(KernelParamsOptiX, render_buffer), sizeof(device_ptr), 1);
|
||||
}
|
||||
if (kernel == DEVICE_KERNEL_SHADER_EVAL_DISPLACE ||
|
||||
kernel == DEVICE_KERNEL_SHADER_EVAL_BACKGROUND ||
|
||||
kernel == DEVICE_KERNEL_SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY ||
|
||||
kernel == DEVICE_KERNEL_SHADER_EVAL_VOLUME_DENSITY)
|
||||
{
|
||||
set_launch_param(offsetof(KernelParamsOptiX, shader_eval_cache_miss), sizeof(device_ptr), 2);
|
||||
set_launch_param(offsetof(KernelParamsOptiX, shader_eval_offset), sizeof(int32_t), 3);
|
||||
}
|
||||
|
||||
if (kernel == DEVICE_KERNEL_INTEGRATOR_INIT_FROM_CAMERA) {
|
||||
set_launch_param(offsetof(KernelParamsOptiX, num_tiles), sizeof(int32_t), 1);
|
||||
set_launch_param(offsetof(KernelParamsOptiX, render_buffer), sizeof(device_ptr), 2);
|
||||
set_launch_param(offsetof(KernelParamsOptiX, max_tile_work_size), sizeof(int32_t), 3);
|
||||
}
|
||||
|
||||
cuda_device_assert(cuda_device_, cuStreamSynchronize(cuda_stream_));
|
||||
|
||||
OptixPipeline pipeline = nullptr;
|
||||
OptixShaderBindingTable sbt_params = {};
|
||||
|
||||
switch (kernel) {
|
||||
case DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_BACKGROUND * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_SHADE_LIGHT_NEE:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_LIGHT_NEE * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_SHADE_LIGHT_FORWARD:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_LIGHT_FORWARD * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_SURFACE * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_SURFACE_RAYTRACE * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_INTERSECT_MNEE:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INTERSECT_MNEE * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_SHADE_VOLUME:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_VOLUME * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_SHADE_VOLUME_RAY_MARCHING:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr +
|
||||
PG_RGEN_SHADE_VOLUME_RAY_MARCHING * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_SHADOW * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_SHADE_DEDICATED_LIGHT:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_DEDICATED_LIGHT * sizeof(SbtRecord);
|
||||
break;
|
||||
|
||||
case DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST:
|
||||
pipeline = optix_device->pipelines[PIP_INTERSECT];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INTERSECT_CLOSEST * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_INTERSECT_SHADOW:
|
||||
pipeline = optix_device->pipelines[PIP_INTERSECT];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INTERSECT_SHADOW * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_INTERSECT_SUBSURFACE:
|
||||
pipeline = optix_device->pipelines[PIP_INTERSECT];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INTERSECT_SUBSURFACE * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK:
|
||||
pipeline = optix_device->pipelines[PIP_INTERSECT];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INTERSECT_VOLUME_STACK * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_INTEGRATOR_INTERSECT_DEDICATED_LIGHT:
|
||||
pipeline = optix_device->pipelines[PIP_INTERSECT];
|
||||
sbt_params.raygenRecord = sbt_data_ptr +
|
||||
PG_RGEN_INTERSECT_DEDICATED_LIGHT * sizeof(SbtRecord);
|
||||
break;
|
||||
|
||||
case DEVICE_KERNEL_SHADER_EVAL_DISPLACE:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_EVAL_DISPLACE * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_SHADER_EVAL_BACKGROUND:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_EVAL_BACKGROUND * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr +
|
||||
PG_RGEN_EVAL_CURVE_SHADOW_TRANSPARENCY * sizeof(SbtRecord);
|
||||
break;
|
||||
case DEVICE_KERNEL_SHADER_EVAL_VOLUME_DENSITY:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_EVAL_VOLUME_DENSITY * sizeof(SbtRecord);
|
||||
break;
|
||||
|
||||
case DEVICE_KERNEL_INTEGRATOR_INIT_FROM_CAMERA:
|
||||
pipeline = optix_device->pipelines[PIP_SHADE];
|
||||
sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INIT_FROM_CAMERA * sizeof(SbtRecord);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR << "Invalid kernel " << device_kernel_as_string(kernel)
|
||||
<< " is attempted to be enqueued.";
|
||||
return false;
|
||||
}
|
||||
|
||||
sbt_params.missRecordBase = sbt_data_ptr + MISS_PROGRAM_GROUP_OFFSET * sizeof(SbtRecord);
|
||||
sbt_params.missRecordStrideInBytes = sizeof(SbtRecord);
|
||||
sbt_params.missRecordCount = NUM_MISS_PROGRAM_GROUPS;
|
||||
sbt_params.hitgroupRecordBase = sbt_data_ptr + HIT_PROGAM_GROUP_OFFSET * sizeof(SbtRecord);
|
||||
sbt_params.hitgroupRecordStrideInBytes = sizeof(SbtRecord);
|
||||
sbt_params.hitgroupRecordCount = NUM_HIT_PROGRAM_GROUPS;
|
||||
sbt_params.callablesRecordBase = sbt_data_ptr + CALLABLE_PROGRAM_GROUPS_BASE * sizeof(SbtRecord);
|
||||
sbt_params.callablesRecordCount = NUM_CALLABLE_PROGRAM_GROUPS;
|
||||
sbt_params.callablesRecordStrideInBytes = sizeof(SbtRecord);
|
||||
|
||||
# ifdef WITH_OSL
|
||||
if (osl_shading || osl_camera) {
|
||||
sbt_params.callablesRecordCount += static_cast<unsigned int>(optix_device->osl_groups.size());
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Launch the ray generation program. */
|
||||
optix_device_assert(optix_device,
|
||||
optixLaunch(pipeline,
|
||||
cuda_stream_,
|
||||
launch_params_ptr,
|
||||
optix_device->launch_params.data_elements,
|
||||
&sbt_params,
|
||||
work_size,
|
||||
1,
|
||||
1));
|
||||
|
||||
debug_enqueue_end();
|
||||
|
||||
return !(optix_device->have_error());
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* WITH_OPTIX */
|
||||
29
blender-5.2.0/intern/cycles/device/optix/queue.h
Normal file
29
blender-5.2.0/intern/cycles/device/optix/queue.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef WITH_OPTIX
|
||||
|
||||
# include "device/cuda/queue.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
class OptiXDevice;
|
||||
|
||||
/* Base class for CUDA queues. */
|
||||
class OptiXDeviceQueue : public CUDADeviceQueue {
|
||||
public:
|
||||
OptiXDeviceQueue(OptiXDevice *device);
|
||||
|
||||
void init_execution() override;
|
||||
|
||||
bool enqueue(DeviceKernel kernel,
|
||||
const int work_size,
|
||||
const DeviceKernelArguments &args) override;
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* WITH_OPTIX */
|
||||
33
blender-5.2.0/intern/cycles/device/optix/util.h
Normal file
33
blender-5.2.0/intern/cycles/device/optix/util.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef WITH_OPTIX
|
||||
|
||||
# include "device/cuda/util.h"
|
||||
|
||||
# ifdef WITH_CUDA_DYNLOAD
|
||||
# include <cuew.h> // IWYU pragma: export
|
||||
// Do not use CUDA SDK headers when using CUEW
|
||||
# define OPTIX_DONT_INCLUDE_CUDA
|
||||
# endif
|
||||
|
||||
# include <optix_stubs.h> // IWYU pragma: export
|
||||
|
||||
/* Utility for checking return values of OptiX function calls. */
|
||||
# define optix_device_assert(optix_device, stmt) \
|
||||
{ \
|
||||
OptixResult result = stmt; \
|
||||
if (result != OPTIX_SUCCESS) { \
|
||||
const char *name = optixGetErrorName(result); \
|
||||
optix_device->set_error( \
|
||||
string_printf("%s in %s (%s:%d)", name, #stmt, __FILE__, __LINE__)); \
|
||||
} \
|
||||
} \
|
||||
(void)0
|
||||
|
||||
# define optix_assert(stmt) optix_device_assert(this, stmt)
|
||||
|
||||
#endif /* WITH_OPTIX */
|
||||
Reference in New Issue
Block a user