Commit 1f29954d by alokp@chromium.org

Added API to enforce GLSL limitations mandated by WebGL.

BUG=48 Review URL: http://codereview.appspot.com/3005042 git-svn-id: https://angleproject.googlecode.com/svn/trunk@476 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 044a5cf8
...@@ -17,7 +17,7 @@ extern "C" { ...@@ -17,7 +17,7 @@ extern "C" {
// Version number for shader translation API. // Version number for shader translation API.
// It is incremented everytime the API changes. // It is incremented everytime the API changes.
#define SH_VERSION 101 #define SH_VERSION 102
// //
// The names of the following enums have been derived by replacing GL prefix // The names of the following enums have been derived by replacing GL prefix
...@@ -67,10 +67,12 @@ typedef enum { ...@@ -67,10 +67,12 @@ typedef enum {
// Compile options. // Compile options.
typedef enum { typedef enum {
SH_VALIDATE = 0, SH_VALIDATE = 0,
SH_INTERMEDIATE_TREE = 0x001, SH_VALIDATE_CONTROL_FLOW = 0x0001,
SH_OBJECT_CODE = 0x002, SH_VALIDATE_INDEXING = 0x0002,
SH_ATTRIBUTES_UNIFORMS = 0x004 SH_INTERMEDIATE_TREE = 0x0004,
SH_OBJECT_CODE = 0x0008,
SH_ATTRIBUTES_UNIFORMS = 0x0010
} ShCompileOptions; } ShCompileOptions;
// //
...@@ -142,7 +144,18 @@ void ShDestruct(ShHandle handle); ...@@ -142,7 +144,18 @@ void ShDestruct(ShHandle handle);
// containing the shader source code. // containing the shader source code.
// numStrings: Specifies the number of elements in shaderStrings array. // numStrings: Specifies the number of elements in shaderStrings array.
// compileOptions: A mask containing the following parameters: // compileOptions: A mask containing the following parameters:
// SH_VALIDATE: Performs validations only. // SH_VALIDATE: Validates shader to ensure that it conforms to the spec
// specified during compiler construction.
// SH_VALIDATE_CONTROL_FLOW: Validates control flow in the shader to ensure
// that they do not exceed the minimum functionality
// mandated in GLSL 1.0 spec, Appendix A, Section 4.
// There is no need to specify this parameter when
// compiling for WebGL - it is implied.
// SH_VALIDATE_INDEXING: Validates indexing of arrays, vectors, and matrices
// in the shader to ensure that they do not exceed the
// minimum functionality mandated in GLSL 1.0 spec,
// Appendix A, Section 5. There is no need to specify this
// parameter when compiling for WebGL - it is implied.
// SH_INTERMEDIATE_TREE: Writes intermediate tree to info log. // SH_INTERMEDIATE_TREE: Writes intermediate tree to info log.
// Can be queried by calling ShGetInfoLog(). // Can be queried by calling ShGetInfoLog().
// SH_OBJECT_CODE: Translates intermediate tree to glsl or hlsl shader. // SH_OBJECT_CODE: Translates intermediate tree to glsl or hlsl shader.
......
...@@ -78,6 +78,11 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -78,6 +78,11 @@ bool TCompiler::compile(const char* const shaderStrings[],
if (numStrings == 0) if (numStrings == 0)
return true; return true;
// If compiling for WebGL, validate control-flow and indexing as well.
if (shaderSpec == SH_WEBGL_SPEC) {
compileOptions |= SH_VALIDATE_CONTROL_FLOW | SH_VALIDATE_INDEXING;
}
TIntermediate intermediate(infoSink); TIntermediate intermediate(infoSink);
TParseContext parseContext(symbolTable, extensionBehavior, intermediate, TParseContext parseContext(symbolTable, extensionBehavior, intermediate,
shaderType, shaderSpec, infoSink); shaderType, shaderSpec, infoSink);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment