Blender V5.0
convert.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "kernel/svm/util.h"
8
10
12
13/* Conversion Nodes */
14
16 KernelGlobals kg, ccl_private float *stack, const uint type, const uint from, const uint to)
17{
18 switch ((NodeConvert)type) {
19 case NODE_CONVERT_FI: {
20 const float f = stack_load_float(stack, from);
21 stack_store_int(stack, to, float_to_int(f));
22 break;
23 }
24 case NODE_CONVERT_FV: {
25 const float f = stack_load_float(stack, from);
26 stack_store_float3(stack, to, make_float3(f, f, f));
27 break;
28 }
29 case NODE_CONVERT_CF: {
30 const float3 f = stack_load_float3(stack, from);
31 const float g = linear_rgb_to_gray(kg, f);
32 stack_store_float(stack, to, g);
33 break;
34 }
35 case NODE_CONVERT_CI: {
36 const float3 f = stack_load_float3(stack, from);
37 const int i = (int)linear_rgb_to_gray(kg, f);
38 stack_store_int(stack, to, i);
39 break;
40 }
41 case NODE_CONVERT_VF: {
42 const float3 f = stack_load_float3(stack, from);
43 const float g = average(f);
44 stack_store_float(stack, to, g);
45 break;
46 }
47 case NODE_CONVERT_VI: {
48 const float3 f = stack_load_float3(stack, from);
49 const int i = (int)average(f);
50 stack_store_int(stack, to, i);
51 break;
52 }
53 case NODE_CONVERT_IF: {
54 const float f = (float)stack_load_int(stack, from);
55 stack_store_float(stack, to, f);
56 break;
57 }
58 case NODE_CONVERT_IV: {
59 const float f = (float)stack_load_int(stack, from);
60 stack_store_float3(stack, to, make_float3(f, f, f));
61 break;
62 }
63 }
64}
65
unsigned int uint
nullptr float
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_convert(KernelGlobals kg, ccl_private float *stack, const uint type, const uint from, const uint to)
Definition convert.h:15
ccl_device_inline float stack_load_float(const ccl_private float *stack, const uint a)
ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
ccl_device_inline int stack_load_int(const ccl_private float *stack, const uint a)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
ccl_device_inline void stack_store_int(ccl_private float *stack, const uint a, const int i)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(const ccl_private float *stack, const uint a)
#define ccl_private
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
NodeConvert
@ NODE_CONVERT_IF
@ NODE_CONVERT_CI
@ NODE_CONVERT_CF
@ NODE_CONVERT_VF
@ NODE_CONVERT_VI
@ NODE_CONVERT_FI
@ NODE_CONVERT_IV
@ NODE_CONVERT_FV
ccl_device float linear_rgb_to_gray(KernelGlobals kg, const float3 c)
ccl_device_inline int float_to_int(const float f)
Definition math_base.h:407
float average(point a)
Definition node_math.h:144
i
Definition text_draw.cc:230