Blender  V2.93
osl_globals.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __OSL_GLOBALS_H__
18 #define __OSL_GLOBALS_H__
19 
20 #ifdef WITH_OSL
21 
22 # include <OSL/oslexec.h>
23 
24 # include <OpenImageIO/refcnt.h>
25 # include <OpenImageIO/unordered_map_concurrent.h>
26 
27 # include "util/util_map.h"
28 # include "util/util_param.h"
29 # include "util/util_thread.h"
30 # include "util/util_unique_ptr.h"
31 # include "util/util_vector.h"
32 
33 # ifndef WIN32
34 using std::isfinite;
35 # endif
36 
38 
39 class OSLRenderServices;
40 class ColorSpaceProcessor;
41 
42 /* OSL Globals
43  *
44  * Data needed by OSL render services, that is global to a rendering session.
45  * This includes all OSL shaders, name to attribute mapping and texture handles.
46  */
47 
48 struct OSLGlobals {
49  OSLGlobals()
50  {
51  ss = NULL;
52  ts = NULL;
53  services = NULL;
54  use = false;
55  }
56 
57  bool use;
58 
59  /* shading system */
61  OSL::TextureSystem *ts;
62  OSLRenderServices *services;
63 
64  /* shader states */
65  vector<OSL::ShaderGroupRef> surface_state;
66  vector<OSL::ShaderGroupRef> volume_state;
67  vector<OSL::ShaderGroupRef> displacement_state;
68  vector<OSL::ShaderGroupRef> bump_state;
69  OSL::ShaderGroupRef background_state;
70 
71  /* attributes */
72  struct Attribute {
73  TypeDesc type;
75  ParamValue value;
76  };
77 
78  typedef unordered_map<ustring, Attribute, ustringHash> AttributeMap;
79  typedef unordered_map<ustring, int, ustringHash> ObjectNameMap;
80 
81  vector<AttributeMap> attribute_map;
82  ObjectNameMap object_name_map;
83  vector<ustring> object_names;
84 };
85 
86 /* trace() call result */
87 struct OSLTraceData {
88  Ray ray;
89  Intersection isect;
90  ShaderData sd;
91  bool setup;
92  bool init;
93  bool hit;
94 };
95 
96 /* thread key for thread specific data lookup */
97 struct OSLThreadData {
98  OSL::ShaderGlobals globals;
99  OSL::PerThreadInfo *osl_thread_info;
100  OSLTraceData tracedata;
101  OSL::ShadingContext *context;
102  OIIO::TextureSystem::Perthread *oiio_thread_info;
103 };
104 
106 
107 #endif
108 
109 #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
ShaderData
bool isfinite(uchar)
Definition: image.cpp:44
struct SELECTID_Context context
Definition: select_engine.c:47
ShadingSystem
Definition: shader.h:48