Blender V2.61 - r43446

osl_globals.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2011, Blender Foundation.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #ifndef __OSL_GLOBALS_H__
00020 #define __OSL_GLOBALS_H__
00021 
00022 #ifdef WITH_OSL
00023 
00024 #include <OSL/oslexec.h>
00025 
00026 #include "util_map.h"
00027 #include "util_param.h"
00028 #include "util_thread.h"
00029 #include "util_vector.h"
00030 
00031 CCL_NAMESPACE_BEGIN
00032 
00033 struct OSLGlobals {
00034     /* use */
00035     bool use;
00036 
00037     /* shading system */ 
00038     OSL::ShadingSystem *ss;
00039 
00040     /* shader states */
00041     vector<OSL::ShadingAttribStateRef> surface_state;
00042     vector<OSL::ShadingAttribStateRef> volume_state;
00043     vector<OSL::ShadingAttribStateRef> displacement_state;
00044     OSL::ShadingAttribStateRef background_state;
00045 
00046     /* attributes */
00047     struct Attribute {
00048         TypeDesc type;
00049         AttributeElement elem;
00050         int offset;
00051         ParamValue value;
00052     };
00053 
00054     typedef unordered_map<ustring, Attribute, ustringHash> AttributeMap;
00055     typedef unordered_map<ustring, int, ustringHash> ObjectNameMap;
00056 
00057     vector<AttributeMap> attribute_map;
00058     ObjectNameMap object_name_map;
00059 
00060     /* thread key for thread specific data lookup */
00061     struct ThreadData {
00062         OSL::ShaderGlobals globals;
00063         void *thread_info;
00064     };
00065 
00066     static tls_ptr(ThreadData, thread_data);
00067 };
00068 
00069 CCL_NAMESPACE_END
00070 
00071 #endif
00072 
00073 #endif /* __OSL_GLOBALS_H__ */
00074