RetroArch
ShHandle.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions
7 // are met:
8 //
9 // Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 // POSSIBILITY OF SUCH DAMAGE.
33 //
34 
35 #ifndef _SHHANDLE_INCLUDED_
36 #define _SHHANDLE_INCLUDED_
37 
38 //
39 // Machine independent part of the compiler private objects
40 // sent as ShHandle to the driver.
41 //
42 // This should not be included by driver code.
43 //
44 
45 #define SH_EXPORTING
46 #include "../Public/ShaderLang.h"
47 #include "../MachineIndependent/Versions.h"
48 #include "InfoSink.h"
49 
50 class TCompiler;
51 class TLinker;
52 class TUniformMap;
53 
54 //
55 // The base class used to back handles returned to the driver.
56 //
58 public:
60  virtual ~TShHandleBase() { delete pool; }
61  virtual TCompiler* getAsCompiler() { return 0; }
62  virtual TLinker* getAsLinker() { return 0; }
63  virtual TUniformMap* getAsUniformMap() { return 0; }
64  virtual glslang::TPoolAllocator* getPool() const { return pool; }
65 private:
67 };
68 
69 //
70 // The base class for the machine dependent linker to derive from
71 // for managing where uniforms live.
72 //
73 class TUniformMap : public TShHandleBase {
74 public:
76  virtual ~TUniformMap() { }
77  virtual TUniformMap* getAsUniformMap() { return this; }
78  virtual int getLocation(const char* name) = 0;
79  virtual TInfoSink& getInfoSink() { return infoSink; }
81 };
82 
83 class TIntermNode;
84 
85 //
86 // The base class for the machine dependent compiler to derive from
87 // for managing object code from the compile.
88 //
89 class TCompiler : public TShHandleBase {
90 public:
92  virtual ~TCompiler() { }
94  virtual TInfoSink& getInfoSink() { return infoSink; }
95 
96  virtual bool compile(TIntermNode* root, int version = 0, EProfile profile = ENoProfile) = 0;
97 
98  virtual TCompiler* getAsCompiler() { return this; }
99  virtual bool linkable() { return haveValidObjectCode; }
100 
102 protected:
104 
107 };
108 
109 //
110 // Link operations are based on a list of compile results...
111 //
114 
115 //
116 // The base class for the machine dependent linker to derive from
117 // to manage the resulting executable.
118 //
119 
120 class TLinker : public TShHandleBase {
121 public:
123  infoSink(iSink),
124  executable(e),
129  excludedCount(0),
130  uniformBindings(0) { }
131  virtual TLinker* getAsLinker() { return this; }
132  virtual ~TLinker() { }
133  virtual bool link(TCompilerList&, TUniformMap*) = 0;
134  virtual bool link(THandleList&) { return false; }
137  virtual void getAttributeBindings(ShBindingTable const **t) const = 0;
139  virtual ShBindingTable* getUniformBindings() const { return uniformBindings; }
140  virtual const void* getObjectCode() const { return 0; } // a real compiler would be returning object code here
141  virtual TInfoSink& getInfoSink() { return infoSink; }
143 protected:
146  bool haveReturnableObjectCode; // true when objectCode is acceptable to send to driver
147 
150  const int* excludedAttributes;
152  ShBindingTable* uniformBindings; // created by the linker
153 };
154 
155 //
156 // This is the interface between the machine independent code
157 // and the machine dependent code.
158 //
159 // The machine dependent code should derive from the classes
160 // above. Then Construct*() and Delete*() will create and
161 // destroy the machine dependent objects, which contain the
162 // above machine independent information.
163 //
165 
169 void DeleteBindingList(TShHandleBase* bindingList);
170 
173 
175 
176 #endif // _SHHANDLE_INCLUDED_
EShExecutable executable
Definition: ShHandle.h:145
virtual TInfoSink & getInfoSink()
Definition: ShHandle.h:94
virtual const void * getObjectCode() const
Definition: ShHandle.h:140
GLuint const GLchar * name
Definition: glext.h:6671
virtual TInfoSink & getInfoSink()
Definition: ShHandle.h:79
virtual void setExcludedAttributes(const int *attributes, int count)
Definition: ShHandle.h:138
EShLanguage language
Definition: ShHandle.h:105
Definition: Versions.h:53
TCompiler(EShLanguage l, TInfoSink &sink)
Definition: ShHandle.h:91
virtual int getLocation(const char *name)=0
Definition: ShHandle.h:57
Definition: InfoSink.h:138
EShLanguage
Definition: ShaderLang.h:90
const ShBindingTable * appAttributeBindings
Definition: ShHandle.h:148
TShHandleBase * ConstructLinker(EShExecutable, int)
Definition: Link.cpp:63
virtual TLinker * getAsLinker()
Definition: ShHandle.h:131
TInfoSink infoSink
Definition: ShHandle.h:80
GLdouble GLdouble t
Definition: glext.h:6398
glslang::TVector< TShHandleBase * > THandleList
Definition: ShHandle.h:113
virtual ~TCompiler()
Definition: ShHandle.h:92
bool haveValidObjectCode
Definition: ShHandle.h:106
Definition: ShHandle.h:89
virtual ~TUniformMap()
Definition: ShHandle.h:76
TLinker(EShExecutable e, TInfoSink &iSink)
Definition: ShHandle.h:122
TCompiler & operator=(TCompiler &)
TShHandleBase()
Definition: ShHandle.h:59
void DeleteLinker(TShHandleBase *)
Definition: Link.cpp:68
virtual void setAppAttributeBindings(const ShBindingTable *t)
Definition: ShHandle.h:135
const int * excludedAttributes
Definition: ShHandle.h:150
TCompiler * ConstructCompiler(EShLanguage, int)
Definition: CodeGen.cpp:55
GLuint GLuint GLsizei count
Definition: glext.h:6292
virtual void getAttributeBindings(ShBindingTable const **t) const =0
Definition: ShHandle.h:73
Definition: intermediate.h:988
static GX2AttribVar attributes[]
Definition: bokeh.c:713
virtual bool link(TCompilerList &, TUniformMap *)=0
virtual TCompiler * getAsCompiler()
Definition: ShHandle.h:98
TUniformMap()
Definition: ShHandle.h:75
GLsizei GLenum GLboolean sink
Definition: glext.h:6324
TInfoSink & infoSink
Definition: ShHandle.h:101
TUniformMap * ConstructUniformMap()
Definition: Link.cpp:73
bool l
Definition: connect_wiiupro.c:37
EProfile
Definition: Versions.h:51
int excludedCount
Definition: ShHandle.h:151
Definition: ShaderLang.h:230
version
Definition: setup.py:6
void DeleteCompiler(TCompiler *)
Definition: CodeGen.cpp:63
virtual TCompiler * getAsCompiler()
Definition: ShHandle.h:61
TShHandleBase * ConstructBindings()
Definition: Link.cpp:83
virtual TUniformMap * getAsUniformMap()
Definition: ShHandle.h:77
virtual TInfoSink & getInfoSink()
Definition: ShHandle.h:141
virtual TLinker * getAsLinker()
Definition: ShHandle.h:62
glslang::TVector< TCompiler * > TCompilerList
Definition: ShHandle.h:112
TLinker & operator=(TLinker &)
virtual ShBindingTable * getUniformBindings() const
Definition: ShHandle.h:139
virtual ~TLinker()
Definition: ShHandle.h:132
const ShBindingTable * fixedAttributeBindings
Definition: ShHandle.h:149
void DeleteUniformMap(TUniformMap *)
Definition: Link.cpp:78
Definition: PoolAlloc.h:147
void DeleteBindingList(TShHandleBase *bindingList)
Definition: Link.cpp:88
virtual bool linkable()
Definition: ShHandle.h:99
virtual ~TShHandleBase()
Definition: ShHandle.h:60
ShBindingTable * uniformBindings
Definition: ShHandle.h:152
EShLanguage getLanguage()
Definition: ShHandle.h:93
bool haveReturnableObjectCode
Definition: ShHandle.h:146
virtual glslang::TPoolAllocator * getPool() const
Definition: ShHandle.h:64
virtual TUniformMap * getAsUniformMap()
Definition: ShHandle.h:63
#define false
Definition: ordinals.h:83
Definition: Common.h:175
Definition: ShHandle.h:120
TInfoSink & infoSink
Definition: ShHandle.h:142
glslang::TPoolAllocator * pool
Definition: ShHandle.h:66
virtual void setFixedAttributeBindings(const ShBindingTable *t)
Definition: ShHandle.h:136
virtual bool compile(TIntermNode *root, int version=0, EProfile profile=ENoProfile)=0
EShExecutable
Definition: ShaderLang.h:178
virtual bool link(THandleList &)
Definition: ShHandle.h:134