Title: [173527] trunk
Revision
173527
Author
[email protected]
Date
2014-09-11 12:22:06 -0700 (Thu, 11 Sep 2014)

Log Message

Check for varying packing restrictions per program instead of per shader.
https://bugs.webkit.org/show_bug.cgi?id=136585.
<rdar://problem/16308409>.

Reviewed by Dean Jackson.

Covered by webgl/1.0.2/conformance/ogles/GL/build/build_009_to_016.html.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::linkProgram): 
Check for varying packing restrictions when linking the program.

* platform/graphics/GraphicsContext3D.h:
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::checkVaryingsPacking): 
Checks varyings shared by both vertex and fragment shaders and makes sure
they satisfy packing restrictions.

Remove varying packing restrictions checks from ANGLE.
* src/compiler/translator/Compiler.cpp:
(TCompiler::compile):
(TCompiler::enforcePackingRestrictions):
* src/compiler/translator/ShHandle.h:

* platform/mac/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (173526 => 173527)


--- trunk/LayoutTests/ChangeLog	2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/LayoutTests/ChangeLog	2014-09-11 19:22:06 UTC (rev 173527)
@@ -1,3 +1,13 @@
+2014-09-10  Roger Fong  <[email protected]>
+
+        Check for varying packing restrictions per program instead of per shader.
+        https://bugs.webkit.org/show_bug.cgi?id=136585.
+        <rdar://problem/16308409>.
+
+        Reviewed by Dean Jackson.
+
+        * platform/mac/TestExpectations:
+
 2014-09-11  Beth Dakin  <[email protected]>
 
         Support rubber-banding in sub-frames

Modified: trunk/LayoutTests/platform/mac/TestExpectations (173526 => 173527)


--- trunk/LayoutTests/platform/mac/TestExpectations	2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2014-09-11 19:22:06 UTC (rev 173527)
@@ -550,7 +550,6 @@
 webgl/1.0.1/conformance/glsl/samplers/glsl-function-texture2dproj.html [ Failure ]
 webgl/1.0.1/conformance/textures/origin-clean-conformance.html [ Skip ]
 webgl/1.0.1/conformance/context/context-lost-restored.html [ Failure ]
-webgl/1.0.2/conformance/ogles/GL/build/build_009_to_016.html [ Failure ]
 webgl/1.0.2/conformance/context/context-creation-and-destruction.html [ Failure Timeout ]
 webgl/1.0.2/conformance/rendering/multisample-corruption.html [ Failure Timeout ]
 http/tests/webgl/1.0.2/origin-clean-conformance.html [ Skip ]

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (173526 => 173527)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2014-09-11 19:22:06 UTC (rev 173527)
@@ -1,3 +1,17 @@
+2014-09-10  Roger Fong  <[email protected]>
+
+        Check for varying packing restrictions per program instead of per shader.
+        https://bugs.webkit.org/show_bug.cgi?id=136585.
+        <rdar://problem/16308409>.
+
+        Reviewed by Dean Jackson.
+
+        Remove varying packing restrictions checks from ANGLE.
+        * src/compiler/translator/Compiler.cpp:
+        (TCompiler::compile):
+        (TCompiler::enforcePackingRestrictions):
+        * src/compiler/translator/ShHandle.h:
+
 2014-09-06  Darin Adler  <[email protected]>
 
         Make updates suggested by new version of Xcode

Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp (173526 => 173527)


--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp	2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp	2014-09-11 19:22:06 UTC (rev 173527)
@@ -239,8 +239,15 @@
         if (success && (compileOptions & SH_VARIABLES))
         {
             collectVariables(root);
-            if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
+            if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS) {
                 success = enforcePackingRestrictions();
+                if (!success) {
+                    infoSink.info.prefix(EPrefixError);
+                    infoSink.info << "too many uniforms";
+                    return false;
+                }
+            }
+
             if (success && shaderType == SH_VERTEX_SHADER &&
                 (compileOptions & SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
                 initializeVaryingsWithoutStaticUse(root);
@@ -453,21 +460,7 @@
 bool TCompiler::enforcePackingRestrictions()
 {
     VariablePacker packer;
-    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;
+    return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
 }
 
 void TCompiler::initializeGLPosition(TIntermNode* root)

Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShHandle.h (173526 => 173527)


--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShHandle.h	2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShHandle.h	2014-09-11 19:22:06 UTC (rev 173527)
@@ -95,7 +95,7 @@
     // Translate to object code.
     virtual void translate(TIntermNode* root) = 0;
     // Returns true if, after applying the packing rules in the GLSL 1.017 spec
-    // Appendix A, section 7, the shader does not use too many uniforms or varyings.
+    // Appendix A, section 7, the shader does not use too many uniforms
     bool enforcePackingRestrictions();
     // Insert statements to initialize varyings without static use in the beginning
     // of main(). It is to work around a Mac driver where such varyings in a vertex

Modified: trunk/Source/WebCore/ChangeLog (173526 => 173527)


--- trunk/Source/WebCore/ChangeLog	2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/Source/WebCore/ChangeLog	2014-09-11 19:22:06 UTC (rev 173527)
@@ -1,3 +1,23 @@
+2014-09-10  Roger Fong  <[email protected]>
+
+        Check for varying packing restrictions per program instead of per shader.
+        https://bugs.webkit.org/show_bug.cgi?id=136585.
+        <rdar://problem/16308409>.
+
+        Reviewed by Dean Jackson.
+
+        Covered by webgl/1.0.2/conformance/ogles/GL/build/build_009_to_016.html.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::linkProgram): 
+        Check for varying packing restrictions when linking the program.
+
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::checkVaryingsPacking): 
+        Checks varyings shared by both vertex and fragment shaders and makes sure
+        they satisfy packing restrictions.
+
 2014-09-11  Beth Dakin  <[email protected]>
 
         Support rubber-banding in sub-frames

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (173526 => 173527)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2014-09-11 19:22:06 UTC (rev 173527)
@@ -3453,7 +3453,7 @@
     if (!isGLES2Compliant()) {
         WebGLShader* vertexShader = program->getAttachedShader(GraphicsContext3D::VERTEX_SHADER);
         WebGLShader* fragmentShader = program->getAttachedShader(GraphicsContext3D::FRAGMENT_SHADER);
-        if (!vertexShader || !vertexShader->isValid() || !fragmentShader || !fragmentShader->isValid() || !m_context->precisionsMatch(objectOrZero(vertexShader), objectOrZero(fragmentShader))) {
+        if (!vertexShader || !vertexShader->isValid() || !fragmentShader || !fragmentShader->isValid() || !m_context->precisionsMatch(objectOrZero(vertexShader), objectOrZero(fragmentShader)) || !m_context->checkVaryingsPacking(objectOrZero(vertexShader), objectOrZero(fragmentShader))) {
             program->setLinkStatus(false);
             return;
         }

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (173526 => 173527)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2014-09-11 19:22:06 UTC (rev 173527)
@@ -809,6 +809,7 @@
 
     void useProgram(Platform3DObject);
     void validateProgram(Platform3DObject);
+    bool checkVaryingsPacking(Platform3DObject vertexShader, Platform3DObject fragmentShader) const;
     bool precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const;
 
     void vertexAttrib1f(GC3Duint index, GC3Dfloat x);

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (173526 => 173527)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2014-09-11 19:22:06 UTC (rev 173527)
@@ -40,6 +40,7 @@
 #else
 #include "Extensions3DOpenGL.h"
 #endif
+#include "ANGLEWebKitBridge.h"
 #include "GraphicsContext.h"
 #include "ImageBuffer.h"
 #include "ImageData.h"
@@ -334,7 +335,54 @@
     ::glFlush();
 }
 
+bool GraphicsContext3D::checkVaryingsPacking(Platform3DObject vertexShader, Platform3DObject fragmentShader) const
+{
+    ASSERT(m_shaderSourceMap.contains(vertexShader));
+    ASSERT(m_shaderSourceMap.contains(fragmentShader));
+    const auto& vertexEntry = m_shaderSourceMap.find(vertexShader)->value;
+    const auto& fragmentEntry = m_shaderSourceMap.find(fragmentShader)->value;
 
+    HashMap<String, ShVariableInfo> combinedVaryings;
+    for (const auto& vertexSymbol : vertexEntry.varyingMap) {
+        const String& symbolName = vertexSymbol.key;
+        // The varying map includes variables for each index of an array variable.
+        // We only want a single variable to represent the array.
+        if (symbolName.endsWith("]"))
+            continue;
+
+        // Don't count built in varyings.
+        if (symbolName == "gl_FragCoord" || symbolName == "gl_FrontFacing" || symbolName == "gl_PointCoord")
+            continue;
+
+        const auto& fragmentSymbol = fragmentEntry.varyingMap.find(symbolName);
+        if (fragmentSymbol != fragmentEntry.varyingMap.end()) {
+            ShVariableInfo symbolInfo;
+            symbolInfo.type = static_cast<ShDataType>((fragmentSymbol->value).type);
+            // The arrays are already split up.
+            symbolInfo.size = (fragmentSymbol->value).size;
+            combinedVaryings.add(symbolName, symbolInfo);
+        }
+    }
+
+    size_t numVaryings = combinedVaryings.size();
+    if (!numVaryings)
+        return true;
+
+    ShVariableInfo* variables = new ShVariableInfo[numVaryings];
+    int index = 0;
+    for (const auto& varyingSymbol : combinedVaryings) {
+        variables[index] = varyingSymbol.value;
+        index++;
+    }
+    
+    GC3Dint maxVaryingFloats = 0;
+    ::glGetIntegerv(GL_MAX_VARYING_FLOATS, &maxVaryingFloats);
+    int result = ShCheckVariablesWithinPackingLimits(maxVaryingFloats / 4, variables, numVaryings);
+
+    delete[] variables;
+    return result;
+}
+
 bool GraphicsContext3D::precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const
 {
     ASSERT(m_shaderSourceMap.contains(vertexShader));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to