1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#pragma once
CCL_NAMESPACE_BEGIN
struct DeviceString {
#if defined(__KERNEL_GPU__)
/* Strings are represented by their hashes in CUDA and OptiX. */
size_t str_;
ccl_device_inline_method uint64_t hash() const
{
return str_;
}
#elif defined(OPENIMAGEIO_USTRING_H)
ustring str_;
ccl_device_inline_method uint64_t hash() const
{
return str_.hash();
}
#else
const char *str_;
#endif
ccl_device_inline_method bool operator==(DeviceString b) const
{
return str_ == b.str_;
}
ccl_device_inline_method bool operator!=(DeviceString b) const
{
return str_ != b.str_;
}
};
ccl_device_inline DeviceString make_string(const char *str, size_t hash)
{
#if defined(__KERNEL_GPU__)
(void)str;
return {hash};
#elif defined(OPENIMAGEIO_USTRING_H)
(void)hash;
return {ustring(str)};
#else
(void)hash;
return {str};
#endif
}
/* Closure */
enum OSLClosureType {
OSL_CLOSURE_MUL_ID = -1,
OSL_CLOSURE_ADD_ID = -2,
OSL_CLOSURE_NONE_ID = 0,
#define OSL_CLOSURE_STRUCT_BEGIN(Upper, lower) OSL_CLOSURE_##Upper##_ID,
#include "closures_template.h"
};
struct OSLClosure {
OSLClosureType id;
};
struct ccl_align(8) OSLClosureMul : public OSLClosure
{
packed_float3 weight;
ccl_private const OSLClosure *closure;
};
struct ccl_align(8) OSLClosureAdd : public OSLClosure
{
ccl_private const OSLClosure *closureA;
ccl_private const OSLClosure *closureB;
};
struct ccl_align(8) OSLClosureComponent : public OSLClosure
{
packed_float3 weight;
};
/* Globals */
struct ShaderGlobals {
packed_float3 P, dPdx, dPdy;
packed_float3 dPdz;
packed_float3 I, dIdx, dIdy;
packed_float3 N;
packed_float3 Ng;
float u, dudx, dudy;
float v, dvdx, dvdy;
packed_float3 dPdu, dPdv;
float time;
float dtime;
packed_float3 dPdtime;
packed_float3 Ps, dPsdx, dPsdy;
ccl_private void *renderstate;
ccl_private void *tracedata;
ccl_private void *objdata;
void *context;
void *renderer;
ccl_private void *object2common;
ccl_private void *shader2common;
ccl_private OSLClosure *Ci;
float surfacearea;
int raytype;
int flipHandedness;
int backfacing;
};
struct OSLNoiseOptions {
};
struct OSLTextureOptions {
};
CCL_NAMESPACE_END
|