blender/intern/cycles/kernel/svm/aov.h
Sergey Sharybin a70b34065d Refactor: Cycles: Make kernel_features 64bit
This change adds 32 more bit to store kernel features.

While for a short term it might be possible to make a space for one or
two extra bits, it seems going 64bit is inevitable.

Expanding the field to 64bit might introduce some slowdown due to less
optimal cache, but so is consolidation of existing flags could also
lead to performance drop in certain configurations.

The main tricky part of the change is Metal where function constants
are used to store kernel_features, and 64bit constants are only
available on macOS 12. There is a runtime check for it. On older macOS
versions the flags are stored as a pair of 32bit values. It is slower,
but there are unlikely to be many Cycles users on macOS 11.

Ref #159470

Pull Request: https://projects.blender.org/blender/blender/pulls/162737
2026-08-18 10:41:27 +02:00

62 lines
2.2 KiB
C++

/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#pragma once
#include "kernel/film/aov_passes.h"
#include "kernel/svm/node_types.h"
#include "kernel/svm/util.h"
CCL_NAMESPACE_BEGIN
ccl_device_inline bool svm_node_aov_check(const uint32_t path_flag,
const ccl_global float *render_buffer)
{
const bool is_primary = (path_flag & PATH_RAY_TRANSPARENT_BACKGROUND) &&
(!(path_flag & PATH_RAY_SINGLE_PASS_DONE));
return ((render_buffer != nullptr) && is_primary);
}
template<uint64_t node_feature_mask, typename ConstIntegratorGenericState>
ccl_device void svm_node_aov_color(KernelGlobals kg,
ccl_private ShaderData *sd,
ConstIntegratorGenericState state,
ccl_private float *ccl_restrict stack,
const ccl_global SVMNodeAOVColor &ccl_restrict node,
ccl_global float *render_buffer)
{
IF_KERNEL_NODES_FEATURE(AOV)
{
/* Don't write AOV on texture cache miss, we'll try again when the texture exists. */
if (sd->runtime_flag & SR_CACHE_MISS) {
return;
}
const float3 val = stack_load(stack, node.color);
film_write_aov_pass_color(kg, state, render_buffer, node.aov_offset, val);
}
}
template<uint64_t node_feature_mask, typename ConstIntegratorGenericState>
ccl_device void svm_node_aov_value(KernelGlobals kg,
ccl_private ShaderData *sd,
ConstIntegratorGenericState state,
ccl_private float *ccl_restrict stack,
const ccl_global SVMNodeAOVValue &ccl_restrict node,
ccl_global float *render_buffer)
{
IF_KERNEL_NODES_FEATURE(AOV)
{
/* Don't write AOV on texture cache miss, we'll try again when the texture exists. */
if (sd->runtime_flag & SR_CACHE_MISS) {
return;
}
const float val = stack_load(stack, node.value);
film_write_aov_pass_value(kg, state, render_buffer, node.aov_offset, val);
}
}
CCL_NAMESPACE_END