Blender V4.3
kernel/osl/types.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#if !defined(__KERNEL_GPU__)
8# include <OSL/oslversion.h>
9#endif
10
12
13#if defined(__KERNEL_GPU__)
14/* Strings are represented by their hashes on the GPU. */
15typedef size_t DeviceString;
16#elif defined(OPENIMAGEIO_USTRING_H)
17typedef ustring DeviceString;
18#else
19typedef const char *DeviceString;
20#endif
21
23{
24#if defined(__KERNEL_GPU__)
25 (void)str;
26 return hash;
27#elif defined(OPENIMAGEIO_USTRING_H)
28 (void)hash; /* Ignored in release builds. */
29 const DeviceString result = ustring(str);
30 kernel_assert(result.hash() == hash);
31 return result;
32#else
33 (void)hash;
34 return str;
35#endif
36}
37
38/* Closure */
39
43
45
46#define OSL_CLOSURE_STRUCT_BEGIN(Upper, lower) OSL_CLOSURE_##Upper##_ID,
47#include "closures_template.h"
49};
50
54
55struct ccl_align(8) OSLClosureMul : public OSLClosure
56{
57 packed_float3 weight;
58 ccl_private const OSLClosure *closure;
59};
60
61struct ccl_align(8) OSLClosureAdd : public OSLClosure
62{
63 ccl_private const OSLClosure *closureA;
64 ccl_private const OSLClosure *closureB;
65};
66
67struct ccl_align(8) OSLClosureComponent : public OSLClosure
68{
69 packed_float3 weight;
70};
71
72/* Globals */
73
105
107
109
110#define OSL_TEXTURE_HANDLE_TYPE_IES ((uintptr_t)0x2 << 30)
111#define OSL_TEXTURE_HANDLE_TYPE_SVM ((uintptr_t)0x1 << 30)
112#define OSL_TEXTURE_HANDLE_TYPE_AO_OR_BEVEL ((uintptr_t)0x3 << 30)
113
114#define OSL_TEXTURE_HANDLE_TYPE(handle) \
115 ((unsigned int)((uintptr_t)(handle) & ((uintptr_t)0x3 << 30)))
116#define OSL_TEXTURE_HANDLE_SLOT(handle) \
117 ((unsigned int)((uintptr_t)(handle) & ((uintptr_t)0x3FFFFFFF)))
118
#define kernel_assert(cond)
#define ccl_private
#define ccl_device_inline
#define CCL_NAMESPACE_END
#define ccl_align(n)
#define str(s)
CCL_NAMESPACE_BEGIN typedef const char * DeviceString
OSLClosureType
@ OSL_CLOSURE_NONE_ID
@ OSL_CLOSURE_MUL_ID
@ OSL_CLOSURE_LAYER_ID
@ OSL_CLOSURE_ADD_ID
ccl_device_inline DeviceString make_string(const char *str, size_t hash)
#define hash
Definition noise.c:154
OSLClosureType id
ccl_private void * renderstate
ccl_private void * tracedata
packed_float3 dIdx
packed_float3 dPdu
packed_float3 dIdy
packed_float3 Ng
ccl_private void * object2common
packed_float3 dPsdx
packed_float3 dPdv
packed_float3 dPdz
ccl_private OSLClosure * Ci
ccl_private void * shader2common
packed_float3 dPdtime
packed_float3 dPsdy
packed_float3 dPdx
packed_float3 I
packed_float3 Ps
packed_float3 N
ccl_private void * objdata
packed_float3 dPdy
packed_float3 P