Title: [131952] trunk/Source/WebCore
Revision
131952
Author
commit-qu...@webkit.org
Date
2012-10-19 15:54:46 -0700 (Fri, 19 Oct 2012)

Log Message

[WebGL] getUniformLocation fails for uniform array name without array brackets
https://bugs.webkit.org/show_bug.cgi?id=99854

Patch by Max Vujovic <mvujo...@adobe.com> on 2012-10-19
Reviewed by Dean Jackson.

Before this patch, gl.getUniformLocation(program, "array[0]") would return the array
location, but gl.getUniformLocation(program, "array") would not. Now, the latter also
returns the array location.

In the process of adding a check to the following Khronos WebGL conformance test:
conformance/glsl/misc/glsl-long-variable-names.html

* platform/graphics/ANGLEWebKitBridge.cpp:
(WebCore::getSymbolInfo):
    Before, we used to check that the symbol size was greater than one to determine that the
    symbol was an array. However, this doesn't identify arrays of length one. Now, we check
    if the symbol name ends in "[0]", since ANGLE appends this suffix to array symbol
    names.
    If the symbol is an array, we strip off the "[0]" and add a symbol with just the base
    name. We set the isArray flag on the symbol, so we don't lose the information that it is
    an array.
    Then, we create symbols for each array element like before. However, instead of
    replacing the "0" in array[0]" with each index, we take the base name "array" and
    append array brackets containing each index (e.g. "array" + "[7]").
* platform/graphics/ANGLEWebKitBridge.h:
(ANGLEShaderSymbol):
    Add isArray boolean to ANGLEShaderSymbol. Since array symbols don't end in "[0]"
    anymore, this is the only way to identify arrays.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (131951 => 131952)


--- trunk/Source/WebCore/ChangeLog	2012-10-19 22:25:14 UTC (rev 131951)
+++ trunk/Source/WebCore/ChangeLog	2012-10-19 22:54:46 UTC (rev 131952)
@@ -1,3 +1,34 @@
+2012-10-19  Max Vujovic  <mvujo...@adobe.com>
+
+        [WebGL] getUniformLocation fails for uniform array name without array brackets
+        https://bugs.webkit.org/show_bug.cgi?id=99854
+
+        Reviewed by Dean Jackson.
+
+        Before this patch, gl.getUniformLocation(program, "array[0]") would return the array
+        location, but gl.getUniformLocation(program, "array") would not. Now, the latter also
+        returns the array location.
+
+        In the process of adding a check to the following Khronos WebGL conformance test:
+        conformance/glsl/misc/glsl-long-variable-names.html
+
+        * platform/graphics/ANGLEWebKitBridge.cpp:
+        (WebCore::getSymbolInfo):
+            Before, we used to check that the symbol size was greater than one to determine that the
+            symbol was an array. However, this doesn't identify arrays of length one. Now, we check
+            if the symbol name ends in "[0]", since ANGLE appends this suffix to array symbol
+            names.
+            If the symbol is an array, we strip off the "[0]" and add a symbol with just the base
+            name. We set the isArray flag on the symbol, so we don't lose the information that it is
+            an array.
+            Then, we create symbols for each array element like before. However, instead of
+            replacing the "0" in array[0]" with each index, we take the base name "array" and
+            append array brackets containing each index (e.g. "array" + "[7]").
+        * platform/graphics/ANGLEWebKitBridge.h:
+        (ANGLEShaderSymbol):
+            Add isArray boolean to ANGLEShaderSymbol. Since array symbols don't end in "[0]"
+            anymore, this is the only way to identify arrays.
+
 2012-10-19  Csaba Osztrogonác  <o...@webkit.org>
 
         Unreviewed, rolling out r131915.

Modified: trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp (131951 => 131952)


--- trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp	2012-10-19 22:25:14 UTC (rev 131951)
+++ trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp	2012-10-19 22:54:46 UTC (rev 131952)
@@ -95,21 +95,32 @@
         // is a subset of Latin-1 as specified by the OpenGL ES Shading Language, Section 3.1 and
         // WebGL, Section "Characters Outside the GLSL Source Character Set".
 
-        // If the variable is an array, add symbols for each array element
-        if (symbol.size > 1) {
+        String name = String(nameBuffer.data());
+        String mappedName = String(mappedNameBuffer.data());
+        
+        // ANGLE returns array names in the format "array[0]".
+        // The only way to know if a symbol is an array is to check if it ends with "[0]".
+        // We can't check the size because regular symbols and arrays of length 1 both have a size of 1.
+        symbol.isArray = name.endsWith("[0]") && mappedName.endsWith("[0]");
+        if (symbol.isArray) {
+            // Add a symbol for the array name without the "[0]" suffix.
+            name.truncate(name.length() - 3);
+            mappedName.truncate(mappedName.length() - 3);
+        }
+
+        symbol.name = name;
+        symbol.mappedName = mappedName;
+        symbols.append(symbol);
+    
+        if (symbol.isArray) {
+            // Add symbols for each array element.
+            symbol.isArray = false;
             for (int i = 0; i < symbol.size; i++) {
-                String name = nameBuffer.data();
-                String mappedName = mappedNameBuffer.data();
-                name.replace(name.length() - 2, 1, String::number(i));
-                mappedName.replace(mappedName.length() - 2, 1, String::number(i));
-                symbol.name = name;
-                symbol.mappedName = mappedName;
+                String arrayBrackets = "[" + String::number(i) + "]";
+                symbol.name = name + arrayBrackets;
+                symbol.mappedName = mappedName + arrayBrackets;
                 symbols.append(symbol);
             }
-        } else {
-            symbol.name = String(nameBuffer.data());
-            symbol.mappedName = String(mappedNameBuffer.data());
-            symbols.append(symbol);
         }
     }
     return true;

Modified: trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h (131951 => 131952)


--- trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h	2012-10-19 22:25:14 UTC (rev 131951)
+++ trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h	2012-10-19 22:54:46 UTC (rev 131952)
@@ -53,6 +53,7 @@
     String mappedName;
     ShDataType dataType;
     int size;
+    bool isArray;
 
     bool isSampler() const
     {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to