Blender V5.0
osl/globals.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#ifdef WITH_OSL
8
9# include <OSL/oslexec.h>
10
11# include "util/map.h"
12# include "util/param.h"
13# include "util/vector.h"
14
15# include "kernel/types.h"
16
17# include "kernel/osl/compat.h"
18# include "kernel/osl/types.h"
19
20# ifndef WIN32
21using std::isfinite;
22# endif
23
25
27class ColorSpaceProcessor;
29
30/* OSL Globals
31 *
32 * Data needed by OSL render services, that is global to a rendering session.
33 * This includes all OSL shaders, name to attribute mapping and texture handles.
34 */
35
36struct OSLGlobals {
37 OSLGlobals()
38 {
39 ss = nullptr;
40 ts = nullptr;
41 services = nullptr;
42 use_shading = false;
43 use_camera = false;
44 }
45
46 bool use_shading;
47 bool use_camera;
48
49 /* shading system */
50 OSL::ShadingSystem *ss;
51 OSL::TextureSystem *ts;
52 OSLRenderServices *services;
53
54 /* shader states */
55 vector<OSL::ShaderGroupRef> surface_state;
56 vector<OSL::ShaderGroupRef> volume_state;
57 vector<OSL::ShaderGroupRef> displacement_state;
58 vector<OSL::ShaderGroupRef> bump_state;
59 OSL::ShaderGroupRef background_state;
60 OSL::ShaderGroupRef camera_state;
61
62 /* attributes */
63 using ObjectNameMap = unordered_map<OSLUStringHash, int>;
64
65 ObjectNameMap object_name_map;
66 vector<ustring> object_names;
67};
68
69/* trace() call result */
70struct OSLTraceData {
71 Ray ray;
72 Intersection isect;
73 ShaderData sd;
74 bool setup;
75 bool init;
76 bool hit;
77};
78
79/* thread key for thread specific data lookup */
80struct OSLThreadData {
81 /* Global Data */
82 OSLGlobals *globals = nullptr;
83 OSL::ShadingSystem *ss = nullptr;
84
85 /* Per-thread data. */
86 int thread_index = -1;
87
88 mutable ShaderGlobals shader_globals;
89 mutable OSLTraceData tracedata;
90
91 OSL::PerThreadInfo *osl_thread_info = nullptr;
92 OSL::ShadingContext *context = nullptr;
93 OIIO::TextureSystem::Perthread *oiio_thread_info = nullptr;
94
95 OSLThreadData(OSLGlobals *globals, const int thread_index);
96 ~OSLThreadData();
97
98 OSLThreadData(OSLThreadData &other) = delete;
99 OSLThreadData(OSLThreadData &&other) noexcept;
100 OSLThreadData &operator=(const OSLThreadData &other) = delete;
101 OSLThreadData &operator=(OSLThreadData &&other) = delete;
102};
103
105
106#endif
void init()
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
#define CCL_NAMESPACE_END
int context(const bContext *C, const char *member, bContextDataResult *result)