Bug 126411

Summary: [WebGL] Correct symbol lookup logic to handle 1-element arrays
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: WebGLAssignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, buildbot, commit-queue, dino, esprehn+autocc, gyuyoung.kim, kondapallykalyan, rniwa, roger_fong
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 122607    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from webkit-ews-16 for mac-mountainlion-wk2
none
Patch
none
Patch (with Test Case)
none
Patch dino: review+

Description Brent Fulgham 2014-01-02 16:27:54 PST
The optimization made in Bug 122607 introduced a bug when dealing with array types.  As documented in the ANGLEWebKitBridge.cpp file, ANGLE identifies arrays by affixing "[0]" to the name.

The new logic incorrectly assumed arrays would always have sizes > 1, and deleted the "[0]" characters at the end of the name. However, there are a number of cases where single-element arrays are used, and the new logic prevented WebKit from finding them in its symbol store.

The attached patch corrects the problem so that the following three.js examples work properly:

http://threejs.org/examples/#webgl_lights_hemisphere
http://threejs.org/examples/#webgl_materials2
Comment 1 Brent Fulgham 2014-01-02 16:28:01 PST
<rdar://problem/15394564>
Comment 2 Brent Fulgham 2014-01-02 16:30:15 PST
Created attachment 220266 [details]
Patch
Comment 3 WebKit Commit Bot 2014-01-02 16:32:04 PST
Attachment 220266 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/html/canvas/WebGLRenderingContext.cpp', '--commit-queue']" exit_code: 1
ERROR: Source/WebCore/ChangeLog:9:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Dean Jackson 2014-01-02 16:43:04 PST
Comment on attachment 220266 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=220266&action=review

> Source/WebCore/html/canvas/WebGLRenderingContext.cpp:3179
> +                String arrayBrackets = "[" + String::number(index) + "]";
> +                String uniformName = info.name + arrayBrackets;

I guess we could do this in one line, although I always forget the optimisation rules for string building.
Comment 5 Roger Fong 2014-01-02 17:12:44 PST
I think this'll fail if we have a size 1 array, say soo int foo[1] or something, but then try to getUniformLocation of foo[0].
Comment 6 Brent Fulgham 2014-01-02 17:14:45 PST
Committed r161242: <http://trac.webkit.org/changeset/161242>
Comment 7 Brent Fulgham 2014-01-02 17:24:47 PST
Roger pointed out that we might do the wrong thing now if we try to access the zeroeth element of an array, because we always strip off the "[0]" bracket and only test for "[x]" when we have an array size greater than 1.
Comment 8 Build Bot 2014-01-02 17:28:29 PST
Comment on attachment 220266 [details]
Patch

Attachment 220266 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/4513015000989696

New failing tests:
webgl/1.0.2/conformance/glsl/misc/shader-with-array-of-structs-containing-arrays.html
webgl/1.0.2/conformance/glsl/misc/shader-with-similar-uniform-array-names.html
Comment 9 Build Bot 2014-01-02 17:28:31 PST
Created attachment 220270 [details]
Archive of layout-test-results from webkit-ews-16 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-16  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 10 Brent Fulgham 2014-01-02 17:33:41 PST
Created attachment 220271 [details]
Patch
Comment 11 Brent Fulgham 2014-01-02 17:34:53 PST
(In reply to comment #8)
> (From update of attachment 220266 [details])
> Attachment 220266 [details] did not pass mac-wk2-ews (mac-wk2):
> Output: http://webkit-queues.appspot.com/results/4513015000989696
> 
> New failing tests:
> webgl/1.0.2/conformance/glsl/misc/shader-with-array-of-structs-containing-arrays.html
> webgl/1.0.2/conformance/glsl/misc/shader-with-similar-uniform-array-names.html

This may have been caused by the 0-th element case Roger pointed out.
Comment 12 Brent Fulgham 2014-01-02 17:49:08 PST
Created attachment 220274 [details]
Patch (with Test Case)
Comment 13 Brent Fulgham 2014-01-02 18:08:13 PST
Committed r161247: <http://trac.webkit.org/changeset/161247>
Comment 14 Darin Adler 2014-01-06 11:57:55 PST
Comment on attachment 220266 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=220266&action=review

>> Source/WebCore/html/canvas/WebGLRenderingContext.cpp:3179
>> +                String arrayBrackets = "[" + String::number(index) + "]";
>> +                String uniformName = info.name + arrayBrackets;
> 
> I guess we could do this in one line, although I always forget the optimisation rules for string building.

This needs to be done in one line. It will do less memory allocation.

    String uniformName = info.name + "[" + String::number(index) + "]";
Comment 15 Brent Fulgham 2014-01-06 15:12:10 PST
Reopen to incorporate Darin's suggestion.
Comment 16 Brent Fulgham 2014-01-06 15:16:18 PST
Created attachment 220460 [details]
Patch
Comment 17 Brent Fulgham 2014-01-06 15:19:36 PST
Committed r161378: <http://trac.webkit.org/changeset/161378>