Blender  V3.3
osl/globals.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifndef __OSL_GLOBALS_H__
5 #define __OSL_GLOBALS_H__
6 
7 #ifdef WITH_OSL
8 
9 # include <OSL/oslexec.h>
10 
11 # include <OpenImageIO/refcnt.h>
12 # include <OpenImageIO/unordered_map_concurrent.h>
13 
14 # include "util/map.h"
15 # include "util/param.h"
16 # include "util/thread.h"
17 # include "util/unique_ptr.h"
18 # include "util/vector.h"
19 
20 # ifndef WIN32
21 using std::isfinite;
22 # endif
23 
25 
26 class OSLRenderServices;
27 class ColorSpaceProcessor;
28 
29 /* OSL Globals
30  *
31  * Data needed by OSL render services, that is global to a rendering session.
32  * This includes all OSL shaders, name to attribute mapping and texture handles.
33  */
34 
35 struct OSLGlobals {
36  OSLGlobals()
37  {
38  ss = NULL;
39  ts = NULL;
40  services = NULL;
41  use = false;
42  }
43 
44  bool use;
45 
46  /* shading system */
48  OSL::TextureSystem *ts;
49  OSLRenderServices *services;
50 
51  /* shader states */
52  vector<OSL::ShaderGroupRef> surface_state;
53  vector<OSL::ShaderGroupRef> volume_state;
54  vector<OSL::ShaderGroupRef> displacement_state;
55  vector<OSL::ShaderGroupRef> bump_state;
56  OSL::ShaderGroupRef background_state;
57 
58  /* attributes */
59  struct Attribute {
60  TypeDesc type;
62  ParamValue value;
63  };
64 
65  typedef unordered_map<ustring, Attribute, ustringHash> AttributeMap;
66  typedef unordered_map<ustring, int, ustringHash> ObjectNameMap;
67 
68  vector<AttributeMap> attribute_map;
69  ObjectNameMap object_name_map;
70  vector<ustring> object_names;
71 };
72 
73 /* trace() call result */
74 struct OSLTraceData {
75  Ray ray;
76  Intersection isect;
77  ShaderData sd;
78  bool setup;
79  bool init;
80  bool hit;
81 };
82 
83 /* thread key for thread specific data lookup */
84 struct OSLThreadData {
85  OSL::ShaderGlobals globals;
86  OSL::PerThreadInfo *osl_thread_info;
87  OSLTraceData tracedata;
88  OSL::ShadingContext *context;
89  OIIO::TextureSystem::Perthread *oiio_thread_info;
90 };
91 
93 
94 #endif
95 
96 #endif /* __OSL_GLOBALS_H__ */
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
struct AttributeMap AttributeMap
ShaderData
Definition: kernel/types.h:925
bool isfinite(uchar)
Definition: scene/image.cpp:31
ShadingSystem
Definition: scene/shader.h:34