HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 "RE_ShaderHandle.h"
26 
27 #include <UT/UT_Map.h>
28 #include <UT/UT_NonCopyable.h>
29 
30 #include <iostream>
31 
32 class re_TagNode;
33 
35 {
36 public:
38  myLastLookupShader(nullptr),
39  myLastLookupTags(0),
40  myLastLookupTagsValid(false)
41  {}
42 
44 
46 
47  int registerShader(const char *program_files,
48  const char *defines,
49  exint tags);
50 
51  int registerShader(RE_ShaderHandle *sh, exint tags);
52  RE_ShaderHandle *lookupShader(exint tags) const;
53 
54  static void dumpShaderInfo(RE_ShaderHandle *sh, std::ostream &os);
55 
56  void setNameBit(const char *name, exint bit);
57 
58  void printTags(exint tags);
59 
60  bool generateProgramAtlas(const char *atlas_filename);
61  void generateProgramAtlas(std::ostream &os);
62 
63 private:
64  void printTagNode(std::ostream &os,
65  re_TagNode *node,
66  int indent, bool single);
67 
68  typedef UT_Map<exint, RE_ShaderHandle *> ShaderMapT;
69 
70  ShaderMapT myShaderMap;
71  UT_Array<RE_ShaderHandle *> myShaders;
72  mutable RE_ShaderHandle *myLastLookupShader;
73  mutable exint myLastLookupTags;
74  mutable bool myLastLookupTagsValid;
75  class re_TagInfo
76  {
77  public:
78  exint tag;
79  exint mask;
80  UT_StringHolder tagname;
81  };
82  UT_Array<re_TagInfo > myTags;
83 };
84 
85 #endif /* RE_SHADERREGISTRY_H_ */
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
Unsorted map container.
Definition: UT_Map.h:109
#define RE_API
Definition: RE_API.h:10
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:632
int64 exint
Definition: SYS_Types.h:125
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLint GLuint mask
Definition: glcorearb.h:124
GLuint const GLchar * name
Definition: glcorearb.h:786
Simple interface to building a shader from a .prog file.