2 //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
5 //Redistribution and use in source and binary forms, with or without
6 //modification, are permitted provided that the following conditions
9 // Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
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.
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.
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.
34 #ifndef _COMPILER_INTERFACE_INCLUDED_
35 #define _COMPILER_INTERFACE_INCLUDED_
37 #include "../Include/ResourceLimits.h"
40 #define C_DECL __cdecl
42 #define SH_IMPORT_EXPORT __declspec(dllexport)
44 #define SH_IMPORT_EXPORT __declspec(dllimport)
46 /* disable DLL linking */
47 #define SH_IMPORT_EXPORT
49 #define SH_IMPORT_EXPORT
55 // This is the platform independent interface between an OGL driver
56 // and the shading language compiler/linker.
64 // Driver must call this first, once, before doing any other
65 // compiler/linker operations.
67 SH_IMPORT_EXPORT
int ShInitialize();
69 // Driver should call this at shutdown.
71 SH_IMPORT_EXPORT
int __fastcall
ShFinalize();
74 // Types of languages the compiler can consume.
85 // Types of output the linker will create.
95 // Optimization level for the compiler.
100 EShOptSimple
, /* Optimizations that can be done quickly */
101 EShOptFull
/* Optimizations that will take more time */
102 } EShOptimizationLevel
;
105 // Build a table for bindings. This can be used for locating
106 // attributes, uniforms, globals, etc., as needed.
115 ShBinding
* bindings
; /* array of bindings */
119 // ShHandle held by but opaque to the driver. It is allocated,
120 // managed, and de-allocated by the compiler/linker. It's contents
121 // are defined by and used by the compiler and linker. For example,
122 // symbol table information and object code passed from the compiler
123 // to the linker can be stored where ShHandle points.
125 // If handle creation fails, 0 will be returned.
127 typedef void* ShHandle
;
130 // Driver calls these to create and destroy compiler/linker
133 SH_IMPORT_EXPORT ShHandle
ShConstructCompiler(const EShLanguage
, int debugOptions
); /* one per shader */
134 SH_IMPORT_EXPORT ShHandle
ShConstructLinker(const EShExecutable
, int debugOptions
); /* one per shader pair */
135 SH_IMPORT_EXPORT ShHandle
ShConstructUniformMap(); /* one per uniform namespace (currently entire program object) */
136 SH_IMPORT_EXPORT
void ShDestruct(ShHandle
);
139 // The return value of ShCompile is boolean, indicating
140 // success or failure.
142 // The info-log should be written by ShCompile into
143 // ShHandle, so it can answer future queries.
145 SH_IMPORT_EXPORT
int ShCompile(
147 const char* const shaderStrings
[],
148 const int numStrings
,
149 const EShOptimizationLevel
,
150 const TBuiltInResource
*resources
,
156 // Similar to ShCompile, but accepts an opaque handle to an
157 // intermediate language structure.
159 SH_IMPORT_EXPORT
int ShCompileIntermediate(
161 ShHandle intermediate
,
162 const EShOptimizationLevel
,
163 int debuggable
/* boolean */
166 SH_IMPORT_EXPORT
int ShLink(
167 const ShHandle
, /* linker object */
168 const ShHandle h
[], /* compiler objects to link together */
169 const int numHandles
,
170 ShHandle uniformMap
, /* updated with new uniforms */
171 short int** uniformsAccessed
, /* returned with indexes of uniforms accessed */
172 int* numUniformsAccessed
);
175 // ShSetEncrpytionMethod is a place-holder for specifying
176 // how source code is encrypted.
178 SH_IMPORT_EXPORT
void ShSetEncryptionMethod(ShHandle
);
181 // All the following return 0 if the information is not
182 // available in the object passed down, or the object is bad.
184 SH_IMPORT_EXPORT
const char* ShGetInfoLog(const ShHandle
);
185 SH_IMPORT_EXPORT
const void* ShGetExecutable(const ShHandle
);
186 SH_IMPORT_EXPORT
int ShSetVirtualAttributeBindings(const ShHandle
, const ShBindingTable
*); /* to detect user aliasing */
187 SH_IMPORT_EXPORT
int ShSetFixedAttributeBindings(const ShHandle
, const ShBindingTable
*); /* to force any physical mappings */
188 SH_IMPORT_EXPORT
int ShGetPhysicalAttributeBindings(const ShHandle
, const ShBindingTable
**); /* for all attributes */
190 // Tell the linker to never assign a vertex attribute to this list of physical attributes
192 SH_IMPORT_EXPORT
int ShExcludeAttributes(const ShHandle
, int *attributes
, int count
);
195 // Returns the location ID of the named uniform.
196 // Returns -1 if error.
198 SH_IMPORT_EXPORT
int ShGetUniformLocation(const ShHandle uniformMap
, const char* name
);
201 EDebugOpNone
= 0x000,
202 EDebugOpIntermediate
= 0x001,
203 EDebugOpAssembly
= 0x002,
204 EDebugOpObjectCode
= 0x004,
205 EDebugOpLinkMaps
= 0x008
212 #endif /* _COMPILER_INTERFACE_INCLUDED_ */