BBBsmoke / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

check packing restrictions for varyings #637

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This checks to see if packing restrictions for varyings are satisfied when 
checking the validity of a WebGL program. This fixes a failing test in WebKit.  
See http://trac.webkit.org/browser/trunk/Source/ThirdParty/ANGLE/changes.diff

diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h
index 7970bfa..b716c6f 100644
--- a/include/GLSLANG/ShaderLang.h
+++ b/include/GLSLANG/ShaderLang.h
@@ -423,8 +423,8 @@ COMPILER_EXPORT void ShGetInfoLog(const ShHandle handle, 
char* infoLog);
 // Returns null-terminated object code for a compiled shader.
 // Parameters:
 // handle: Specifies the compiler
-// infoLog: Specifies an array of characters that is used to return
-//          the object code. It is assumed that infoLog has enough memory to
+// objCode: Specifies an array of characters that is used to return
+//          the object code. It is assumed that objCode has enough memory to
 //          accomodate the object code. The size of the buffer required to
 //          store the returned object code can be obtained by calling
 //          ShGetInfo with SH_OBJECT_CODE_LENGTH.
diff --git a/src/compiler/translator/Compiler.cpp 
b/src/compiler/translator/Compiler.cpp
index 1864cd8..c3111c1 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -96,6 +96,7 @@ TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
     : shaderType(type),
       shaderSpec(spec),
       maxUniformVectors(0),
+      maxVaryingVectors(0),
       maxExpressionComplexity(0),
       maxCallStackDepth(0),
       fragmentPrecisionHigh(false),
@@ -114,6 +115,7 @@ bool TCompiler::Init(const ShBuiltInResources& resources)
     maxUniformVectors = (shaderType == SH_VERTEX_SHADER) ?
         resources.MaxVertexUniformVectors :
         resources.MaxFragmentUniformVectors;
+    maxVaryingVectors = resources.MaxVaryingVectors;
     maxExpressionComplexity = resources.MaxExpressionComplexity;
     maxCallStackDepth = resources.MaxCallStackDepth;

@@ -238,14 +240,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
         {
             collectVariables(root);
             if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
-            {
                 success = enforcePackingRestrictions();
-                if (!success)
-                {
-                    infoSink.info.prefix(EPrefixError);
-                    infoSink.info << "too many uniforms";
-                }
-            }
             if (success && shaderType == SH_VERTEX_SHADER &&
                 (compileOptions & SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
                 initializeVaryingsWithoutStaticUse(root);
@@ -458,7 +453,21 @@ void TCompiler::collectVariables(TIntermNode* root)
 bool TCompiler::enforcePackingRestrictions()
 {
     VariablePacker packer;
-    return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, 
uniforms);
+    bool success = packer.CheckVariablesWithinPackingLimits(maxUniformVectors, 
uniforms);
+    if (!success) {
+        infoSink.info.prefix(EPrefixError);
+        infoSink.info << "too many uniforms";
+        return false;
+    }
+
+    success = packer.CheckVariablesWithinPackingLimits(maxVaryingVectors, 
varyings);
+
+    if (!success) {
+        infoSink.info.prefix(EPrefixError);
+        infoSink.info << "too many varyings";
+        return false;
+    }
+    return true;
 }

 void TCompiler::initializeGLPosition(TIntermNode* root)

Original issue reported on code.google.com by achriste...@gmail.com on 2 May 2014 at 8:30

GoogleCodeExporter commented 9 years ago
https://chromium-review.googlesource.com/#/c/198183

Original comment by jmad...@chromium.org on 5 May 2014 at 2:35

GoogleCodeExporter commented 9 years ago

Original comment by jmad...@chromium.org on 5 May 2014 at 2:38