HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RE_ShaderRegistry.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RE_ShaderRegistry.h (RE Library, C++)
7  *
8  * COMMENTS:
9  * RE_ShaderRegistry encapsulates a container for a family of shaders that
10  * can be classified using a number of tags encoded as a bit masks.
11  * In the registry, each shader is associated with the sets of tags that
12  * uniquely identify it and can be looked up using the same set of tags.
13  *
14  * It is essential that the tags are set up and assigned to shaders in a
15  * way that can ensure distinct masks for all registered shaders. When
16  * registering a shader, a warning is printed to stderr and the shader is
17  * dropped if its mask is already in use by another shader in the registry.
18  */
19 
20 
21 #ifndef RE_SHADERREGISTRY_H_
22 #define RE_SHADERREGISTRY_H_
23 
24 #include "RE_API.h"
25 #include <UT/UT_Map.h>
26 #include <iostream>
27 #include "RE_ShaderHandle.h"
28 
30 {
31 public:
33  myLastLookupShader(NULL),
34  myLastLookupTags(0),
35  myLastLookupTagsValid(false)
36  {}
37 
39 
40  int registerShader(const char *program_files,
41  const char *defines,
42  exint tags);
43 
44  int registerShader(RE_ShaderHandle *sh, exint tags);
45  RE_ShaderHandle *lookupShader(exint tags) const;
46 
47  static void dumpShaderInfo(RE_ShaderHandle *sh, std::ostream &os);
48 
49 private:
50  typedef UT_Map<exint, RE_ShaderHandle *> ShaderMapT;
51 
52  ShaderMapT myShaderMap;
54  mutable RE_ShaderHandle *myLastLookupShader;
55  mutable exint myLastLookupTags;
56  mutable bool myLastLookupTagsValid;
57 };
58 
59 #endif /* RE_SHADERREGISTRY_H_ */
#define RE_API
Definition: RE_API.h:10
int64 exint
Definition: SYS_Types.h:109
Simple interface to building a shader from a .prog file.