<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[173527] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/173527">173527</a></dd>
<dt>Author</dt> <dd>roger_fong@apple.com</dd>
<dt>Date</dt> <dd>2014-09-11 12:22:06 -0700 (Thu, 11 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Check for varying packing restrictions per program instead of per shader.
https://bugs.webkit.org/show_bug.cgi?id=136585.
&lt;rdar://problem/16308409&gt;.

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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkSourceThirdPartyANGLEChangeLog">trunk/Source/ThirdParty/ANGLE/ChangeLog</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorCompilercpp">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrccompilertranslatorShHandleh">trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShHandle.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh">trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLCommoncpp">trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (173526 => 173527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-09-11 19:20:17 UTC (rev 173526)
+++ trunk/LayoutTests/ChangeLog        2014-09-11 19:22:06 UTC (rev 173527)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-09-10  Roger Fong  &lt;roger_fong@apple.com&gt;
+
+        Check for varying packing restrictions per program instead of per shader.
+        https://bugs.webkit.org/show_bug.cgi?id=136585.
+        &lt;rdar://problem/16308409&gt;.
+
+        Reviewed by Dean Jackson.
+
+        * platform/mac/TestExpectations:
+
</ins><span class="cx"> 2014-09-11  Beth Dakin  &lt;bdakin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Support rubber-banding in sub-frames
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (173526 => 173527)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -550,7 +550,6 @@
</span><span class="cx"> webgl/1.0.1/conformance/glsl/samplers/glsl-function-texture2dproj.html [ Failure ]
</span><span class="cx"> webgl/1.0.1/conformance/textures/origin-clean-conformance.html [ Skip ]
</span><span class="cx"> webgl/1.0.1/conformance/context/context-lost-restored.html [ Failure ]
</span><del>-webgl/1.0.2/conformance/ogles/GL/build/build_009_to_016.html [ Failure ]
</del><span class="cx"> webgl/1.0.2/conformance/context/context-creation-and-destruction.html [ Failure Timeout ]
</span><span class="cx"> webgl/1.0.2/conformance/rendering/multisample-corruption.html [ Failure Timeout ]
</span><span class="cx"> http/tests/webgl/1.0.2/origin-clean-conformance.html [ Skip ]
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (173526 => 173527)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2014-09-10  Roger Fong  &lt;roger_fong@apple.com&gt;
+
+        Check for varying packing restrictions per program instead of per shader.
+        https://bugs.webkit.org/show_bug.cgi?id=136585.
+        &lt;rdar://problem/16308409&gt;.
+
+        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:
+
</ins><span class="cx"> 2014-09-06  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make updates suggested by new version of Xcode
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp (173526 => 173527)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -239,8 +239,15 @@
</span><span class="cx">         if (success &amp;&amp; (compileOptions &amp; SH_VARIABLES))
</span><span class="cx">         {
</span><span class="cx">             collectVariables(root);
</span><del>-            if (compileOptions &amp; SH_ENFORCE_PACKING_RESTRICTIONS)
</del><ins>+            if (compileOptions &amp; SH_ENFORCE_PACKING_RESTRICTIONS) {
</ins><span class="cx">                 success = enforcePackingRestrictions();
</span><ins>+                if (!success) {
+                    infoSink.info.prefix(EPrefixError);
+                    infoSink.info &lt;&lt; &quot;too many uniforms&quot;;
+                    return false;
+                }
+            }
+
</ins><span class="cx">             if (success &amp;&amp; shaderType == SH_VERTEX_SHADER &amp;&amp;
</span><span class="cx">                 (compileOptions &amp; SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
</span><span class="cx">                 initializeVaryingsWithoutStaticUse(root);
</span><span class="lines">@@ -453,21 +460,7 @@
</span><span class="cx"> bool TCompiler::enforcePackingRestrictions()
</span><span class="cx"> {
</span><span class="cx">     VariablePacker packer;
</span><del>-    bool success = packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
-    if (!success) {
-        infoSink.info.prefix(EPrefixError);
-        infoSink.info &lt;&lt; &quot;too many uniforms&quot;;
-        return false;
-    }
-
-    success = packer.CheckVariablesWithinPackingLimits(maxVaryingVectors, varyings);
-
-    if (!success) {
-        infoSink.info.prefix(EPrefixError);
-        infoSink.info &lt;&lt; &quot;too many varyings&quot;;
-        return false;
-    }
-    return true;
</del><ins>+    return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TCompiler::initializeGLPosition(TIntermNode* root)
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrccompilertranslatorShHandleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShHandle.h (173526 => 173527)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -95,7 +95,7 @@
</span><span class="cx">     // Translate to object code.
</span><span class="cx">     virtual void translate(TIntermNode* root) = 0;
</span><span class="cx">     // Returns true if, after applying the packing rules in the GLSL 1.017 spec
</span><del>-    // Appendix A, section 7, the shader does not use too many uniforms or varyings.
</del><ins>+    // Appendix A, section 7, the shader does not use too many uniforms
</ins><span class="cx">     bool enforcePackingRestrictions();
</span><span class="cx">     // Insert statements to initialize varyings without static use in the beginning
</span><span class="cx">     // of main(). It is to work around a Mac driver where such varyings in a vertex
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173526 => 173527)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2014-09-10  Roger Fong  &lt;roger_fong@apple.com&gt;
+
+        Check for varying packing restrictions per program instead of per shader.
+        https://bugs.webkit.org/show_bug.cgi?id=136585.
+        &lt;rdar://problem/16308409&gt;.
+
+        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.
+
</ins><span class="cx"> 2014-09-11  Beth Dakin  &lt;bdakin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Support rubber-banding in sub-frames
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (173526 => 173527)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -3453,7 +3453,7 @@
</span><span class="cx">     if (!isGLES2Compliant()) {
</span><span class="cx">         WebGLShader* vertexShader = program-&gt;getAttachedShader(GraphicsContext3D::VERTEX_SHADER);
</span><span class="cx">         WebGLShader* fragmentShader = program-&gt;getAttachedShader(GraphicsContext3D::FRAGMENT_SHADER);
</span><del>-        if (!vertexShader || !vertexShader-&gt;isValid() || !fragmentShader || !fragmentShader-&gt;isValid() || !m_context-&gt;precisionsMatch(objectOrZero(vertexShader), objectOrZero(fragmentShader))) {
</del><ins>+        if (!vertexShader || !vertexShader-&gt;isValid() || !fragmentShader || !fragmentShader-&gt;isValid() || !m_context-&gt;precisionsMatch(objectOrZero(vertexShader), objectOrZero(fragmentShader)) || !m_context-&gt;checkVaryingsPacking(objectOrZero(vertexShader), objectOrZero(fragmentShader))) {
</ins><span class="cx">             program-&gt;setLinkStatus(false);
</span><span class="cx">             return;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (173526 => 173527)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -809,6 +809,7 @@
</span><span class="cx"> 
</span><span class="cx">     void useProgram(Platform3DObject);
</span><span class="cx">     void validateProgram(Platform3DObject);
</span><ins>+    bool checkVaryingsPacking(Platform3DObject vertexShader, Platform3DObject fragmentShader) const;
</ins><span class="cx">     bool precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const;
</span><span class="cx"> 
</span><span class="cx">     void vertexAttrib1f(GC3Duint index, GC3Dfloat x);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLCommoncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (173526 => 173527)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #else
</span><span class="cx"> #include &quot;Extensions3DOpenGL.h&quot;
</span><span class="cx"> #endif
</span><ins>+#include &quot;ANGLEWebKitBridge.h&quot;
</ins><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><span class="cx"> #include &quot;ImageBuffer.h&quot;
</span><span class="cx"> #include &quot;ImageData.h&quot;
</span><span class="lines">@@ -334,7 +335,54 @@
</span><span class="cx">     ::glFlush();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool GraphicsContext3D::checkVaryingsPacking(Platform3DObject vertexShader, Platform3DObject fragmentShader) const
+{
+    ASSERT(m_shaderSourceMap.contains(vertexShader));
+    ASSERT(m_shaderSourceMap.contains(fragmentShader));
+    const auto&amp; vertexEntry = m_shaderSourceMap.find(vertexShader)-&gt;value;
+    const auto&amp; fragmentEntry = m_shaderSourceMap.find(fragmentShader)-&gt;value;
</ins><span class="cx"> 
</span><ins>+    HashMap&lt;String, ShVariableInfo&gt; combinedVaryings;
+    for (const auto&amp; vertexSymbol : vertexEntry.varyingMap) {
+        const String&amp; 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(&quot;]&quot;))
+            continue;
+
+        // Don't count built in varyings.
+        if (symbolName == &quot;gl_FragCoord&quot; || symbolName == &quot;gl_FrontFacing&quot; || symbolName == &quot;gl_PointCoord&quot;)
+            continue;
+
+        const auto&amp; fragmentSymbol = fragmentEntry.varyingMap.find(symbolName);
+        if (fragmentSymbol != fragmentEntry.varyingMap.end()) {
+            ShVariableInfo symbolInfo;
+            symbolInfo.type = static_cast&lt;ShDataType&gt;((fragmentSymbol-&gt;value).type);
+            // The arrays are already split up.
+            symbolInfo.size = (fragmentSymbol-&gt;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&amp; varyingSymbol : combinedVaryings) {
+        variables[index] = varyingSymbol.value;
+        index++;
+    }
+    
+    GC3Dint maxVaryingFloats = 0;
+    ::glGetIntegerv(GL_MAX_VARYING_FLOATS, &amp;maxVaryingFloats);
+    int result = ShCheckVariablesWithinPackingLimits(maxVaryingFloats / 4, variables, numVaryings);
+
+    delete[] variables;
+    return result;
+}
+
</ins><span class="cx"> bool GraphicsContext3D::precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_shaderSourceMap.contains(vertexShader));
</span></span></pre>
</div>
</div>

</body>
</html>