Cycles: Disable NanoVDB if not needed when specialising Metal PSOs
This patch adds a check to see whether we're actually using NanoVDB textures, and if not, removes `#define WITH_NANOVDB` when generating the scene-optimised kernels. This results in marginally faster render times (maybe 2 or 3%) for scenes that do not use NanoVDB. The generic kernels are unaffected, so this will not impact responsiveness on first render. Pull Request: https://projects.blender.org/blender/blender/pulls/112822
This commit is contained in:
parent
166f7c7a98
commit
b8833a7f8c
@ -47,6 +47,7 @@ class MetalDevice : public Device {
|
||||
MetalGPUVendor device_vendor;
|
||||
|
||||
uint kernel_features;
|
||||
bool using_nanovdb = false;
|
||||
MTLResourceOptions default_storage_mode;
|
||||
int max_threads_per_threadgroup;
|
||||
|
||||
|
@ -347,7 +347,9 @@ string MetalDevice::preprocess_source(MetalPipelineType pso_type,
|
||||
case METAL_GPU_APPLE:
|
||||
global_defines += "#define __KERNEL_METAL_APPLE__\n";
|
||||
# ifdef WITH_NANOVDB
|
||||
if (DebugFlags().metal.use_nanovdb) {
|
||||
/* Compiling in NanoVDB results in a marginal drop in render perf, so disable it for
|
||||
* specialized PSOs when no textures are using it. */
|
||||
if ((pso_type == PSO_GENERIC || using_nanovdb) && DebugFlags().metal.use_nanovdb) {
|
||||
global_defines += "#define WITH_NANOVDB\n";
|
||||
}
|
||||
# endif
|
||||
@ -1088,6 +1090,14 @@ void MetalDevice::tex_alloc_as_buffer(device_texture &mem)
|
||||
texture_info[slot].data = *(uint64_t *)((uint64_t)buffer_bindings_1d.contents + offset);
|
||||
texture_slot_map[slot] = nil;
|
||||
need_texture_info = true;
|
||||
|
||||
if (mem.info.data_type == IMAGE_DATA_TYPE_NANOVDB_FLOAT ||
|
||||
mem.info.data_type == IMAGE_DATA_TYPE_NANOVDB_FLOAT3 ||
|
||||
mem.info.data_type == IMAGE_DATA_TYPE_NANOVDB_FPN ||
|
||||
mem.info.data_type == IMAGE_DATA_TYPE_NANOVDB_FP16)
|
||||
{
|
||||
using_nanovdb = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MetalDevice::tex_alloc(device_texture &mem)
|
||||
|
Loading…
Reference in New Issue
Block a user