1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSHADERCACHE_H_
40 #define _OSGSHADERCACHE_H_
46 //#define OSG_SHC_USE_REF 1
47 //#define OSG_SHC_REF_CLEANUP 1
48 //#define OSG_ASSERT_TREE 1
50 #include "OSGShaderCacheTree.h"
54 /*! \ingroup GrpSystemShaderBase
55 \ingroup GrpLibOSGSystem
59 class OSG_SYSTEM_DLLMAPPING ShaderCache
61 /*========================== PUBLIC =================================*/
65 typedef ActiveShaderExeTree ShaderExeTree
;
66 typedef ActiveShaderVarTree ShaderVarTree
;
68 typedef ShaderExeTree::IdStore IdStore
;
70 #ifdef OSG_SHC_USE_REF
71 typedef std::pair
<IdStore
,
72 ShaderExecutableChunkUnrecPtr
> StoreElement
;
73 typedef std::pair
<IdStore
,
74 ShaderExecutableVarChunkUnrecPtr
> StoreVarElement
;
76 typedef std::vector
<StoreElement
> ShaderStore
;
77 typedef std::vector
<StoreVarElement
> ShaderVarStore
;
80 /*---------------------------------------------------------------------*/
81 /*! \name Statistic */
85 /*---------------------------------------------------------------------*/
89 ShaderExecutableChunk
*findShader (const IdStore
&vIds
);
90 ShaderExecutableVarChunk
*findShaderVar(const IdStore
&vIds
);
93 /*---------------------------------------------------------------------*/
97 void addShader (const IdStore
&vIds
,
98 ShaderExecutableChunk
*pShader
);
100 void addShaderVar(const IdStore
&vIds
,
101 ShaderExecutableVarChunk
*pVar
);
106 /*---------------------------------------------------------------------*/
113 /*---------------------------------------------------------------------*/
118 /*---------------------------------------------------------------------*/
119 /*! \name Constructors */
123 /*---------------------------------------------------------------------*/
124 /*! \name Constructors */
128 /*---------------------------------------------------------------------*/
129 /*! \name Constructors */
133 /*---------------------------------------------------------------------*/
134 /*! \name Constructors */
138 /*---------------------------------------------------------------------*/
139 /*! \name Constructors */
145 /*---------------------------------------------------------------------*/
146 /*! \name Destructor */
149 virtual ~ShaderCache(void);
152 /*========================= PROTECTED ===============================*/
156 /*---------------------------------------------------------------------*/
160 #ifdef OSG_SHC_USE_REF
161 ShaderStore _vShaderStore
;
162 ShaderVarStore _vShaderVarStore
;
165 ShaderExeTree _oExeTree
;
166 ShaderVarTree _oVarTree
;
169 /*---------------------------------------------------------------------*/
170 /*! \name Destructor */
173 void updateRemoveCallback (ShaderExecutableChunk
*pShader
);
174 void clearShRemoveCallback (ShaderExecutableChunk
*pShader
);
176 void updateRemoveCallback (ShaderExecutableVarChunk
*pVar
);
177 void clearVaRemoveCallback (ShaderExecutableVarChunk
*pVar
);
179 void removeShaderProgram (FieldContainer
*pContainer
,
180 ConstFieldMaskArg whichField
);
182 void removeShaderVar (FieldContainer
*pContainer
,
183 ConstFieldMaskArg whichField
);
186 /*========================== PRIVATE ================================*/
190 /*! \brief prohibit default function (move to 'public' if needed) */
191 ShaderCache(const ShaderCache
&source
);
192 /*! \brief prohibit default function (move to 'public' if needed) */
193 void operator =(const ShaderCache
&source
);
198 #include "OSGShaderCache.inl"
200 #endif /* _OSGSHADERCACHE_H_ */