2
// Copyright � 1997 - 2001, Paul C. Gregory
4
// Contact: pgregory@aqsis.com
5
// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public // License as published by the Free Software Foundation; either
6
// version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful,
7
// but WITHOUT ANY WARRANTY; without even the implied warranty of
8
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9
// General Public License for more details.
11
// You should have received a copy of the GNU General Public
12
// License along with this library; if not, write to the Free Software
13
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
\brief Classes and structures for supporting DSOs
18
\author Tristan Colgate <tristan@inuxtech.co.uk>
36
#include "ishaderdata.h"
37
#include "bitvector.h"
38
#include "shadervariable.h"
40
#include "ishaderdata.h"
42
#include "idsoshadeops.h"
45
START_NAMESPACE( Aqsis )
47
//---------------------------------------------------------------------
48
/** CqDSORepository: This class is responsible for searching for shader
49
* operations in extrnal shared libraries.
51
class CqDSORepository: public IqDSORepository, private CqPluginBase{
55
//---------------------------------------------------------------------
56
/** Mapping of type names and ID's that we can handle in DSO's. The type
57
* ID's are as presented from the SL compiler, the type names are those that
58
* may be used by DSO shadeop table function prototypes.
60
void BuildTypeMaps(void)
62
m_TypeNameMap["invalid"] = type_invalid;
63
m_TypeIdMap['@'] = type_invalid;
64
m_TypeNameMap["integer"] = type_integer;
65
m_TypeIdMap['i'] = type_integer;
66
m_TypeNameMap["float"] = type_float;
67
m_TypeIdMap['f'] = type_float;
68
m_TypeNameMap["point"] = type_point;
69
m_TypeIdMap['p'] = type_point;
70
m_TypeNameMap["string"] = type_string;
71
m_TypeIdMap['s'] = type_string;
72
m_TypeNameMap["color"] = type_color;
73
m_TypeIdMap['c'] = type_color;
74
m_TypeNameMap["triple"] = type_triple;
75
m_TypeIdMap['t'] = type_triple;
76
m_TypeNameMap["hpoint"] = type_hpoint;
77
m_TypeIdMap['h'] = type_hpoint;
78
m_TypeNameMap["normal"] = type_normal;
79
m_TypeIdMap['n'] = type_normal;
80
m_TypeNameMap["vector"] = type_vector;
81
m_TypeIdMap['v'] = type_vector;
82
m_TypeNameMap["void"] = type_void;
83
m_TypeIdMap['x'] = type_void;
84
m_TypeNameMap["matrix"] = type_matrix;
85
m_TypeIdMap['m'] = type_matrix;
86
m_TypeNameMap["hextuple"] = type_sixteentuple; // ??
87
m_TypeIdMap['w'] = type_sixteentuple;
91
virtual void SetDSOPath(const CqString*);
92
CqString strPrototype(CqString*, SqDSOExternalCall*);
94
CqDSORepository(CqString *searchpath): CqPluginBase()
97
SetDSOPath(searchpath);
100
CqDSORepository(): CqPluginBase()
106
//---------------------------------------------------------------------
107
/** The Destructor handles the calling of shutdown on any previously
108
* initialised DSO shadeops.
110
virtual ~CqDSORepository()
112
// We should call shutdown for all init'd functions
113
while( ( m_itActiveDSOMap = m_ActiveDSOMap.begin() ) != m_ActiveDSOMap.end()){
115
std::list<SqDSOExternalCall *> *list = (*m_itActiveDSOMap).second;
117
while( !list->empty() )
119
SqDSOExternalCall *item = list->front();
121
if(item->shutdown != NULL &&
123
item->shutdown(item->initData);
129
m_ActiveDSOMap.erase(m_itActiveDSOMap);
133
// Utility to provide a formatted function prototype
134
CqString strPtototype(SqDSOExternalCall*);
137
//A maps and iterators for the Type name/id mappings
138
std::map<CqString,EqVariableType> m_TypeNameMap ;
139
std::map<CqString,EqVariableType>::iterator m_itTypeNameMap ;
140
std::map<TqChar,EqVariableType> m_TypeIdMap ;
141
std::map<TqChar,EqVariableType>::iterator m_itTypeIdMap ;
143
// A list of files (possibly also directories in future) to be searched for shadeops
144
std::list<CqString*> m_pDSOPathList;
145
// This is a map of shadeop names to descriptors of shadeop implementations that we
146
// have already found, its for efficiency and to allow us to track initiliased shadeops
147
// to be shutdown later.
148
std::map<CqString,std::list<SqDSOExternalCall*> *> m_ActiveDSOMap;
149
std::map<CqString,std::list<SqDSOExternalCall*> *>::iterator m_itActiveDSOMap;
151
// Get Array of DSO entry points for a specific shadeop
152
std::list<SqDSOExternalCall*>* getShadeOpMethods(CqString*);
154
// Parse a single DSO SHADEOP_TABLE rntry
155
SqDSOExternalCall* parseShadeOpTableEntry(void*, SqShadeOp*);
158
END_NAMESPACE( Aqsis )
160
#endif // DSOSHADEOPS_H