2727
2828#include " KHR/khrplatform.h"
2929
30+ #include < map>
31+ #include < string>
32+ #include < vector>
33+
3034//
3135// This is the platform independent interface between an OGL driver
3236// and the shading language compiler.
@@ -42,18 +46,17 @@ typedef unsigned int GLenum;
4246// Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h
4347#include " ShaderVars.h"
4448
45- #ifdef __cplusplus
46- extern " C" {
47- #endif
48-
4949// Version number for shader translation API.
5050// It is incremented every time the API changes.
51- #define ANGLE_SH_VERSION 130
51+ #define ANGLE_SH_VERSION 132
5252
5353typedef enum {
5454 SH_GLES2_SPEC = 0x8B40 ,
5555 SH_WEBGL_SPEC = 0x8B41 ,
5656
57+ SH_GLES3_SPEC = 0x8B86 ,
58+ SH_WEBGL2_SPEC = 0x8B87 ,
59+
5760 // The CSS Shaders spec is a subset of the WebGL spec.
5861 //
5962 // In both CSS vertex and fragment shaders, ANGLE:
@@ -85,31 +88,6 @@ typedef enum {
8588 SH_HLSL11_OUTPUT = 0x8B48
8689} ShShaderOutput;
8790
88- typedef enum {
89- SH_PRECISION_HIGHP = 0x5001 ,
90- SH_PRECISION_MEDIUMP = 0x5002 ,
91- SH_PRECISION_LOWP = 0x5003 ,
92- SH_PRECISION_UNDEFINED = 0
93- } ShPrecisionType;
94-
95- typedef enum {
96- SH_INFO_LOG_LENGTH = 0x8B84 ,
97- SH_OBJECT_CODE_LENGTH = 0x8B88 , // GL_SHADER_SOURCE_LENGTH
98- SH_ACTIVE_UNIFORMS = 0x8B86 ,
99- SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87 ,
100- SH_ACTIVE_ATTRIBUTES = 0x8B89 ,
101- SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A ,
102- SH_VARYINGS = 0x8BBB ,
103- SH_VARYING_MAX_LENGTH = 0x8BBC ,
104- SH_MAPPED_NAME_MAX_LENGTH = 0x6000 ,
105- SH_NAME_MAX_LENGTH = 0x6001 ,
106- SH_HASHED_NAME_MAX_LENGTH = 0x6002 ,
107- SH_HASHED_NAMES_COUNT = 0x6003 ,
108- SH_SHADER_VERSION = 0x6004 ,
109- SH_RESOURCES_STRING_LENGTH = 0x6005 ,
110- SH_OUTPUT_TYPE = 0x6006
111- } ShShaderInfo;
112-
11391// Compile options.
11492typedef enum {
11593 SH_VALIDATE = 0 ,
@@ -208,14 +186,14 @@ typedef enum {
208186//
209187// Driver must call this first, once, before doing any other
210188// compiler operations.
211- // If the function succeeds, the return value is nonzero , else zero .
189+ // If the function succeeds, the return value is true , else false .
212190//
213- COMPILER_EXPORT int ShInitialize ();
191+ COMPILER_EXPORT bool ShInitialize ();
214192//
215193// Driver should call this at shutdown.
216- // If the function succeeds, the return value is nonzero , else zero .
194+ // If the function succeeds, the return value is true , else false .
217195//
218- COMPILER_EXPORT int ShFinalize ();
196+ COMPILER_EXPORT bool ShFinalize ();
219197
220198// The 64 bits hash function. The first parameter is the input string; the
221199// second parameter is the string length.
@@ -246,6 +224,12 @@ typedef struct
246224 int EXT_frag_depth;
247225 int EXT_shader_texture_lod;
248226
227+ // Set to 1 to enable replacing GL_EXT_draw_buffers #extension directives
228+ // with GL_NV_draw_buffers in ESSL output. This flag can be used to emulate
229+ // EXT_draw_buffers by using it in combination with GLES3.0 glDrawBuffers
230+ // function. This applies to Tegra K1 devices.
231+ int NV_draw_buffers;
232+
249233 // Set to 1 if highp precision is supported in the fragment language.
250234 // Default is 0.
251235 int FragmentPrecisionHigh;
@@ -274,8 +258,10 @@ typedef struct
274258
275259//
276260// Initialize built-in resources with minimum expected values.
261+ // Parameters:
262+ // resources: The object to initialize. Will be comparable with memcmp.
277263//
278- COMPILER_EXPORT void ShInitBuiltInResources (ShBuiltInResources* resources);
264+ COMPILER_EXPORT void ShInitBuiltInResources (ShBuiltInResources * resources);
279265
280266//
281267// ShHandle held by but opaque to the driver. It is allocated,
@@ -284,18 +270,15 @@ COMPILER_EXPORT void ShInitBuiltInResources(ShBuiltInResources* resources);
284270//
285271// If handle creation fails, 0 will be returned.
286272//
287- typedef void * ShHandle;
273+ typedef void * ShHandle;
288274
289275//
290- // Returns the a concatenated list of the items in ShBuiltInResources as a string.
276+ // Returns the a concatenated list of the items in ShBuiltInResources as a
277+ // null-terminated string.
291278// This function must be updated whenever ShBuiltInResources is changed.
292279// Parameters:
293280// handle: Specifies the handle of the compiler to be used.
294- // outStringLen: Specifies the size of the buffer, in number of characters. The size
295- // of the buffer required to store the resources string can be obtained
296- // by calling ShGetInfo with SH_RESOURCES_STRING_LENGTH.
297- // outStr: Returns a null-terminated string representing all the built-in resources.
298- COMPILER_EXPORT void ShGetBuiltInResourcesString (const ShHandle handle, size_t outStringLen, char *outStr);
281+ COMPILER_EXPORT const std::string &ShGetBuiltInResourcesString (const ShHandle handle);
299282
300283//
301284// Driver calls these to create and destroy compiler objects.
@@ -313,12 +296,12 @@ COMPILER_EXPORT ShHandle ShConstructCompiler(
313296 sh::GLenum type,
314297 ShShaderSpec spec,
315298 ShShaderOutput output,
316- const ShBuiltInResources* resources);
299+ const ShBuiltInResources * resources);
317300COMPILER_EXPORT void ShDestruct (ShHandle handle);
318301
319302//
320303// Compiles the given shader source.
321- // If the function succeeds, the return value is nonzero , else zero .
304+ // If the function succeeds, the return value is true , else false .
322305// Parameters:
323306// handle: Specifies the handle of compiler to be used.
324307// shaderStrings: Specifies an array of pointers to null-terminated strings
@@ -340,123 +323,36 @@ COMPILER_EXPORT void ShDestruct(ShHandle handle);
340323// SH_VARIABLES: Extracts attributes, uniforms, and varyings.
341324// Can be queried by calling ShGetVariableInfo().
342325//
343- COMPILER_EXPORT int ShCompile (
326+ COMPILER_EXPORT bool ShCompile (
344327 const ShHandle handle,
345- const char * const shaderStrings[],
328+ const char * const shaderStrings[],
346329 size_t numStrings,
347- int compileOptions
348- );
330+ int compileOptions);
349331
350- // Returns a parameter from a compiled shader.
351- // Parameters:
352- // handle: Specifies the compiler
353- // pname: Specifies the parameter to query.
354- // The following parameters are defined:
355- // SH_INFO_LOG_LENGTH: the number of characters in the information log
356- // including the null termination character.
357- // SH_OBJECT_CODE_LENGTH: the number of characters in the object code
358- // including the null termination character.
359- // SH_ACTIVE_ATTRIBUTES: the number of active attribute variables.
360- // SH_ACTIVE_ATTRIBUTE_MAX_LENGTH: the length of the longest active attribute
361- // variable name including the null
362- // termination character.
363- // SH_ACTIVE_UNIFORMS: the number of active uniform variables.
364- // SH_ACTIVE_UNIFORM_MAX_LENGTH: the length of the longest active uniform
365- // variable name including the null
366- // termination character.
367- // SH_VARYINGS: the number of varying variables.
368- // SH_VARYING_MAX_LENGTH: the length of the longest varying variable name
369- // including the null termination character.
370- // SH_MAPPED_NAME_MAX_LENGTH: the length of the mapped variable name including
371- // the null termination character.
372- // SH_NAME_MAX_LENGTH: the max length of a user-defined name including the
373- // null termination character.
374- // SH_HASHED_NAME_MAX_LENGTH: the max length of a hashed name including the
375- // null termination character.
376- // SH_HASHED_NAMES_COUNT: the number of hashed names from the latest compile.
377- // SH_SHADER_VERSION: the version of the shader language
378- // SH_OUTPUT_TYPE: the currently set language output type
379- //
380- // params: Requested parameter
381- COMPILER_EXPORT void ShGetInfo (const ShHandle handle,
382- ShShaderInfo pname,
383- size_t * params);
332+ // Return the version of the shader language.
333+ COMPILER_EXPORT int ShGetShaderVersion (const ShHandle handle);
384334
385- // Returns nul-terminated information log for a compiled shader.
335+ // Return the currently set language output type.
336+ COMPILER_EXPORT ShShaderOutput ShGetShaderOutputType (
337+ const ShHandle handle);
338+
339+ // Returns null-terminated information log for a compiled shader.
386340// Parameters:
387341// handle: Specifies the compiler
388- // infoLog: Specifies an array of characters that is used to return
389- // the information log. It is assumed that infoLog has enough memory
390- // to accomodate the information log. The size of the buffer required
391- // to store the returned information log can be obtained by calling
392- // ShGetInfo with SH_INFO_LOG_LENGTH.
393- COMPILER_EXPORT void ShGetInfoLog (const ShHandle handle, char * infoLog);
342+ COMPILER_EXPORT const std::string &ShGetInfoLog (const ShHandle handle);
394343
395344// Returns null-terminated object code for a compiled shader.
396345// Parameters:
397346// handle: Specifies the compiler
398- // infoLog: Specifies an array of characters that is used to return
399- // the object code. It is assumed that infoLog has enough memory to
400- // accomodate the object code. The size of the buffer required to
401- // store the returned object code can be obtained by calling
402- // ShGetInfo with SH_OBJECT_CODE_LENGTH.
403- COMPILER_EXPORT void ShGetObjectCode (const ShHandle handle, char * objCode);
404-
405- // Returns information about a shader variable.
406- // Parameters:
407- // handle: Specifies the compiler
408- // variableType: Specifies the variable type; options include
409- // SH_ACTIVE_ATTRIBUTES, SH_ACTIVE_UNIFORMS, SH_VARYINGS.
410- // index: Specifies the index of the variable to be queried.
411- // length: Returns the number of characters actually written in the string
412- // indicated by name (excluding the null terminator) if a value other
413- // than NULL is passed.
414- // size: Returns the size of the variable.
415- // type: Returns the data type of the variable.
416- // precision: Returns the precision of the variable.
417- // staticUse: Returns 1 if the variable is accessed in a statement after
418- // pre-processing, whether or not run-time flow of control will
419- // cause that statement to be executed.
420- // Returns 0 otherwise.
421- // name: Returns a null terminated string containing the name of the
422- // variable. It is assumed that name has enough memory to accormodate
423- // the variable name. The size of the buffer required to store the
424- // variable name can be obtained by calling ShGetInfo with
425- // SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, SH_ACTIVE_UNIFORM_MAX_LENGTH,
426- // SH_VARYING_MAX_LENGTH.
427- // mappedName: Returns a null terminated string containing the mapped name of
428- // the variable, It is assumed that mappedName has enough memory
429- // (SH_MAPPED_NAME_MAX_LENGTH), or NULL if don't care about the
430- // mapped name. If the name is not mapped, then name and mappedName
431- // are the same.
432- COMPILER_EXPORT void ShGetVariableInfo (const ShHandle handle,
433- ShShaderInfo variableType,
434- int index,
435- size_t * length,
436- int * size,
437- sh::GLenum* type,
438- ShPrecisionType* precision,
439- int * staticUse,
440- char * name,
441- char * mappedName);
442-
443- // Returns information about a name hashing entry from the latest compile.
347+ COMPILER_EXPORT const std::string &ShGetObjectCode (const ShHandle handle);
348+
349+ // Returns a (original_name, hash) map containing all the user defined
350+ // names in the shader, including variable names, function names, struct
351+ // names, and struct field names.
444352// Parameters:
445353// handle: Specifies the compiler
446- // index: Specifies the index of the name hashing entry to be queried.
447- // name: Returns a null terminated string containing the user defined name.
448- // It is assumed that name has enough memory to accomodate the name.
449- // The size of the buffer required to store the user defined name can
450- // be obtained by calling ShGetInfo with SH_NAME_MAX_LENGTH.
451- // hashedName: Returns a null terminated string containing the hashed name of
452- // the uniform variable, It is assumed that hashedName has enough
453- // memory to accomodate the name. The size of the buffer required
454- // to store the name can be obtained by calling ShGetInfo with
455- // SH_HASHED_NAME_MAX_LENGTH.
456- COMPILER_EXPORT void ShGetNameHashingEntry (const ShHandle handle,
457- int index,
458- char * name,
459- char * hashedName);
354+ COMPILER_EXPORT const std::map<std::string, std::string> *ShGetNameHashingMap (
355+ const ShHandle handle);
460356
461357// Shader variable inspection.
462358// Returns a pointer to a list of variables of the designated type.
@@ -476,17 +372,17 @@ typedef struct
476372 int size;
477373} ShVariableInfo;
478374
479- // Returns 1 if the passed in variables pack in maxVectors following
375+ // Returns true if the passed in variables pack in maxVectors following
480376// the packing rules from the GLSL 1.017 spec, Appendix A, section 7.
481- // Returns 0 otherwise. Also look at the SH_ENFORCE_PACKING_RESTRICTIONS
377+ // Returns false otherwise. Also look at the SH_ENFORCE_PACKING_RESTRICTIONS
482378// flag above.
483379// Parameters:
484380// maxVectors: the available rows of registers.
485381// varInfoArray: an array of variable info (types and sizes).
486382// varInfoArraySize: the size of the variable array.
487- COMPILER_EXPORT int ShCheckVariablesWithinPackingLimits (
383+ COMPILER_EXPORT bool ShCheckVariablesWithinPackingLimits (
488384 int maxVectors,
489- ShVariableInfo* varInfoArray,
385+ ShVariableInfo * varInfoArray,
490386 size_t varInfoArraySize);
491387
492388// Gives the compiler-assigned register for an interface block.
@@ -497,7 +393,7 @@ COMPILER_EXPORT int ShCheckVariablesWithinPackingLimits(
497393// interfaceBlockName: Specifies the interface block
498394// indexOut: output variable that stores the assigned register
499395COMPILER_EXPORT bool ShGetInterfaceBlockRegister (const ShHandle handle,
500- const char * interfaceBlockName,
396+ const std::string & interfaceBlockName,
501397 unsigned int *indexOut);
502398
503399// Gives the compiler-assigned register for uniforms in the default
@@ -509,11 +405,7 @@ COMPILER_EXPORT bool ShGetInterfaceBlockRegister(const ShHandle handle,
509405// interfaceBlockName: Specifies the uniform
510406// indexOut: output variable that stores the assigned register
511407COMPILER_EXPORT bool ShGetUniformRegister (const ShHandle handle,
512- const char * uniformName,
408+ const std::string & uniformName,
513409 unsigned int *indexOut);
514410
515- #ifdef __cplusplus
516- }
517- #endif
518-
519411#endif // _COMPILER_INTERFACE_INCLUDED_
0 commit comments