Blender V5.3
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 services = nullptr;
41 use_shading = false;
42 use_camera = false;
43 }
44
45 bool use_shading;
46 bool use_camera;
47
48 /* shading system */
49 OSL::ShadingSystem *ss;
50 OSLRenderServices *services;
51
52 /* shader states */
53 vector<OSL::ShaderGroupRef> surface_state;
54 vector<OSL::ShaderGroupRef> volume_state;
55 vector<OSL::ShaderGroupRef> displacement_state;
56 vector<OSL::ShaderGroupRef> bump_state;
57 OSL::ShaderGroupRef background_state;
58 OSL::ShaderGroupRef camera_state;
59
60 /* attributes */
61 using ObjectNameMap = unordered_map<OSLUStringHash, int>;
62
63 ObjectNameMap object_name_map;
64 vector<ustring> object_names;
65};
66
67/* trace() call result */
68struct OSLTraceData {
69 Ray ray;
70 Intersection isect;
71 ShaderData sd;
72 bool setup;
73 bool init;
74 bool hit;
75 bool self_hit;
76};
77
78/* thread key for thread specific data lookup */
79struct OSLThreadData {
80 /* Global Data */
81 OSLGlobals *globals = nullptr;
82 OSL::ShadingSystem *ss = nullptr;
83
84 /* Per-thread data. */
85 int thread_index = -1;
86
87 mutable ShaderGlobals shader_globals;
88 mutable OSLTraceData tracedata;
89
90 OSL::PerThreadInfo *osl_thread_info = nullptr;
91 OSL::ShadingContext *context = nullptr;
92
93 OSLThreadData(OSLGlobals *globals, const int thread_index);
94 ~OSLThreadData();
95
96 OSLThreadData(OSLThreadData &other) = delete;
97 OSLThreadData(OSLThreadData &&other) noexcept;
98 OSLThreadData &operator=(const OSLThreadData &other) = delete;
99 OSLThreadData &operator=(OSLThreadData &&other) = delete;
100};
101
103
104#endif
void init()
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
#define CCL_NAMESPACE_END
int context(const bContext *C, const char *member, bContextDataResult *result)
PipelineCompute setup(setup_main)