mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
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
5c34161a3f
commit
ddff3680e2
2 changed files with 12 additions and 1 deletions
|
|
@ -46,6 +46,7 @@ class MetalDevice : public Device {
|
|||
MetalGPUVendor device_vendor;
|
||||
|
||||
uint kernel_features;
|
||||
bool using_nanovdb = false;
|
||||
MTLResourceOptions default_storage_mode;
|
||||
int max_threads_per_threadgroup;
|
||||
|
||||
|
|
|
|||
|
|
@ -345,7 +345,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
|
||||
|
|
@ -1079,6 +1081,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…
Add table
Add a link
Reference in a new issue