New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 651493 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

WebGL2 TransformFeedback: shader link error on Windows, not on OSX

Project Member Reported by flo...@gmail.com, Sep 29 2016

Issue description

The following WebGL2 transform-feedback demo works as expected on OSX in Canary (and FF Nightly), but produces a shader linker error on Windows (also both in Canary and FF) (don't forget to enable WebGL2 in Canary, if every thing works as expected the gray point cube should turn into a colorful whirling point cloud when moving the mouse over it):

http://floooh.github.io/oryol-sticky-tests/VertexCapture.html

Firefox provides a useful error message in the JS console:

"Transform feedback varying webgl_**** does not exist in the vertex shader"

The natively compiled demo also works as expected on desktop GL implementations (although I haven't tested yet on GLES3 platforms).

Sources for vertex and fragment shader, and the transform-feedback varyings are pasted below. My guess is that ANGLE detects that the captured vertex shader outputs are not used in the fragment shader code, and "optimizes them away" in the fragment shader input and all the way to the vertex shader outputs, so that the transform-feedback-varying is not found in the vertex shader output when the shader is linked.

Here's the vertex shader source (output of my shader source code generator, thus a bit messy-looking). Note that the vertex shader has 2 outputs, 'pos' and 'vel':

#version 300 es
#define _position gl_Position
#define mul(m,v) (m*v)
layout (std140) uniform captureParams {
  vec3 centerOfGravity;
  float _pad_centerOfGravity;
};
in vec3 position;
in vec3 normal;
out vec3 pos;
out vec3 vel;
void main() {
  vec3 dir = centerOfGravity - position;
  float dist = (length(dir) + 0.0001);
  float i = min(1.0 / (dist * dist), 20.0);
  vel = 0.995 * (normal + normalize(dir) * i);
  pos = position + vel * 0.0001;
  _position = vec4(0.0);
}

And here's the fragment shader, since I'm only interested in the transform feedback result, it's basically just a discard, but it still defines two inputs (pos and vel). I did this primarily because my shader-code-generator enforces that the vertex shader output has to match the fragment shader input (this is also necessary on other 3D-APIs):

#version 300 es
precision mediump float;
#define _color _FragColor
in vec3 pos;
in vec3 vel;
out vec4 _FragColor;
void main() {
  discard;
  _color = vec4(0.0);
}

Before glLinkProgram(), glTransformFeedbackVaryings() is called with the two strings "pos" and "vel".

Next thing I'll try is to use the "pos" and "vel" inputs in the fragment shader, hoping that ANGLE won't drop the vertex shader outputs since they are used in the fragment shader, but even if this works I think that Windows and OSX should behave the same (either both should work, or both should fail).

Oh, and another interesting thing:

On an older Firefox Nightly, the demo actually worked at first, only after I updated to the very latest Nightly it broke. I can't say how old the previous version was, but I think it wasn't older than a few weeks, so I guess the change in ANGLE must be quite recent (or at least Firefox must have updated to a newer ANGLE quite recently).
 

Comment 1 by flo...@gmail.com, Sep 29 2016

Link to mirror ticket in the FF issue tracker: https://bugzilla.mozilla.org/show_bug.cgi?id=1306380

Comment 2 by flo...@gmail.com, Sep 29 2016

Here's a different version that uses the 2 fragment inputs 'pos' and 'vel' in the fragment shader program, so that they are not dropped by ANGLE. This works in Firefox Nightly on Windows, but Chrome still has an error (unfortunately the JS console doesn't  give much useful info).

Try this in in Firefox Nightly on Windows, it should work: https://floooh.github.io/oryol-webgl2/asmjs/VertexCapture.html

On Chrome Canary I'm getting an error on the JS console which doesn't make a lot of sense to me:

[.Offscreen-For-WebGL-xxxxx ERROR :GL_OUT_OF_MEMORY : glTexImage2D: <- error from previous GL command]


The only difference to the above is that the fragment shader now looks like this (not the "pos+vel"):

#version 300 es
precision mediump float;
#define _color _FragColor
in vec3 pos;
in vec3 vel;
out vec4 _FragColor;
void main() {
  discard;
  _color = vec4(pos+vel, 1.0);
}

Comment 3 by zmo@chromium.org, Sep 29 2016

Cc: -zmo@google.com -kbr@google.com kbr@chromium.org zmo@chromium.org cwallez@chromium.org geoffl...@chromium.org jmad...@chromium.org
Labels: -Pri-3 Pri-2
CC ANGLE folks

Comment 4 by kbr@chromium.org, Sep 29 2016

Components: Internals>GPU>ANGLE Blink>WebGL

Comment 5 by kbr@chromium.org, Sep 29 2016

Floh: could you instrument your code using webgl-debug.js from https://github.com/KhronosGroup/WebGLDeveloperTools (note, it might need updates for WebGL 2.0) and use it to try to track down the source of the GL_OUT_OF_MEMORY error? Hopefully it's a call your app is making, rather than something internal to Chrome.

Also, if it's possible for you to attach a zip archive of your test case, that would help in the case that your links change.

Comment 6 by kbr@chromium.org, Sep 29 2016

Status: Available (was: Untriaged)
Owner: geoffl...@chromium.org
I'll take a look.

Comment 8 by kbr@chromium.org, Sep 30 2016

Status: Assigned (was: Available)

Comment 9 by flo...@gmail.com, Oct 1 2016

Attached are 2 archives, the original one with the shader linker error, and another with the fragment-shader workaround. I'll start looking into out-of-memory error happening on Chrome now with the fragment-shader-workaround, but that might take a few days since I don't have access to a Windows machine over the weekend.

VertexCapture_link_error.zip
173 KB Download

Comment 10 by flo...@gmail.com, Oct 1 2016

Second archive didn't work because of missing files, here's the new one (.html is in the asmjs subdirectory)
VertexCapture_link_ok.zip
139 KB Download
Owner: jmad...@chromium.org
Status: Started (was: Assigned)
Stealing this.
Project Member

Comment 12 by bugdroid1@chromium.org, Oct 3 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/angle/angle/+/c4431804c3d4ed1b175044d01dfcdee623a480a3

commit c4431804c3d4ed1b175044d01dfcdee623a480a3
Author: Jamie Madill <jmadill@chromium.org>
Date: Mon Oct 03 19:41:38 2016

D3D11: Fix Buffer11::copyFromStorage and UBOs.

The change to initialize a constant buffer immediately after
calling BufferData in D3D11 led to a bug where we would map
the UBO for writing with the wrong map bits. Fix this by
using the same map method as the rest of the code.

The D3D11 runtime seems to allow arbitrarily large constant buffers
on Windows 10, but not Windows 7. Thus this CL also fixes a bug in
our constant buffer size clamping to not copy more than the available
buffer size for uniform buffers.

BUG= chromium:651493 

Change-Id: I876767691d02db90ecb08a8fa78199f03339a35e
Reviewed-on: https://chromium-review.googlesource.com/391167
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>

[modify] https://crrev.com/c4431804c3d4ed1b175044d01dfcdee623a480a3/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp
[modify] https://crrev.com/c4431804c3d4ed1b175044d01dfcdee623a480a3/src/tests/gl_tests/UniformBufferTest.cpp

Comment 13 by flo...@gmail.com, Oct 4 2016

Interesting... does this change fix the out-of-memory error that happens in the second 'workaround-version'? If yes I don't need to investigate this :) Also since this is a uniform buffer change, is it somehow related to the known issue of uniform buffers on Intel GPUs mentioned in this ticket: https://bugs.chromium.org/p/chromium/issues/detail?id=642304#c15 ?

Thanks!
-Floh.
Floh, the change above should fix the second workaround version. It is related to Intel UBOs - I landed a partial workaround for Intel UBO problems in  issue 593024  (there are still some cases that don't work properly) but my CL had a bug. The above change in comment 12 fixes the bug, but still some uses of UBOs on Intel aren't fully supported. I have some ideas on how to fix them, but haven't had the time to address them yet.

The fix for transform feedback is in progress and should land soon.
Project Member

Comment 15 by bugdroid1@chromium.org, Oct 4 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/angle/angle/+/4c655248b8830cbb3a6873c2096fd8f15b9962c9

commit 4c655248b8830cbb3a6873c2096fd8f15b9962c9
Author: Jamie Madill <jmadill@chromium.org>
Date: Tue Oct 04 14:27:21 2016

D3D11: Fix unreferenced XFB vars getting dropped.

Our for-loop logic was confused so that some unreferenced
transform feedback varyings might get dropped.

BUG= chromium:651493 

Change-Id: Id283230da0a47fc647b2a3862da60be5538e439e
Reviewed-on: https://chromium-review.googlesource.com/391945
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>

[modify] https://crrev.com/4c655248b8830cbb3a6873c2096fd8f15b9962c9/src/tests/gl_tests/TransformFeedbackTest.cpp
[modify] https://crrev.com/4c655248b8830cbb3a6873c2096fd8f15b9962c9/util/Vector.cpp
[modify] https://crrev.com/4c655248b8830cbb3a6873c2096fd8f15b9962c9/util/Vector.h
[modify] https://crrev.com/4c655248b8830cbb3a6873c2096fd8f15b9962c9/src/libANGLE/renderer/d3d/VaryingPacking.cpp

Project Member

Comment 16 by bugdroid1@chromium.org, Oct 4 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/angle/angle/+/4c655248b8830cbb3a6873c2096fd8f15b9962c9

commit 4c655248b8830cbb3a6873c2096fd8f15b9962c9
Author: Jamie Madill <jmadill@chromium.org>
Date: Tue Oct 04 14:27:21 2016

D3D11: Fix unreferenced XFB vars getting dropped.

Our for-loop logic was confused so that some unreferenced
transform feedback varyings might get dropped.

BUG= chromium:651493 

Change-Id: Id283230da0a47fc647b2a3862da60be5538e439e
Reviewed-on: https://chromium-review.googlesource.com/391945
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>

[modify] https://crrev.com/4c655248b8830cbb3a6873c2096fd8f15b9962c9/src/tests/gl_tests/TransformFeedbackTest.cpp
[modify] https://crrev.com/4c655248b8830cbb3a6873c2096fd8f15b9962c9/util/Vector.cpp
[modify] https://crrev.com/4c655248b8830cbb3a6873c2096fd8f15b9962c9/util/Vector.h
[modify] https://crrev.com/4c655248b8830cbb3a6873c2096fd8f15b9962c9/src/libANGLE/renderer/d3d/VaryingPacking.cpp

Project Member

Comment 17 by bugdroid1@chromium.org, Oct 4 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2ae51c4ea3e7b08e143df3a97017519bd3e2ca11

commit 2ae51c4ea3e7b08e143df3a97017519bd3e2ca11
Author: jmadill <jmadill@chromium.org>
Date: Tue Oct 04 17:15:21 2016

Roll ANGLE 886de36..4c65524

https://chromium.googlesource.com/angle/angle.git/+log/886de36..4c65524

BUG= chromium:651493 , 651101 , chromium:618464 

TBR=geofflang@chromium.org

TEST=bots

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.win:win_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2393613002
Cr-Commit-Position: refs/heads/master@{#422837}

[modify] https://crrev.com/2ae51c4ea3e7b08e143df3a97017519bd3e2ca11/DEPS

Comment 18 by kbr@chromium.org, Oct 4 2016

These fixes are great. Are there additional WebGL 2.0 conformance tests that could be added which would act as regression tests?

Yeah, I'll make it an action item to add WebGL tests for these two bugs.

Comment 20 by flo...@gmail.com, Oct 6 2016

Looks like the fixes are already in Canary. On my Win10 machine, both demos now work fine. Thanks for the quick fixes :)

Project Member

Comment 21 by bugdroid1@chromium.org, Oct 6 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9859aac71e6b077f66c37da16896971a81c02e08

commit 9859aac71e6b077f66c37da16896971a81c02e08
Author: jmadill <jmadill@chromium.org>
Date: Thu Oct 06 20:11:14 2016

Roll ANGLE d08f3b3..873d00f

https://chromium.googlesource.com/angle/angle.git/+log/d08f3b3..873d00f

BUG= chromium:653274 , chromium:651493 , chromium:653276 , chromium:593024 , chromium:634525 

TBR=geofflang@chromium.org

TEST=bots

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.win:win_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2399933002
Cr-Commit-Position: refs/heads/master@{#423643}

[modify] https://crrev.com/9859aac71e6b077f66c37da16896971a81c02e08/DEPS

Status: Fixed (was: Started)
Great! WebGL test additions underway, shouldn't be long.
Project Member

Comment 23 by bugdroid1@chromium.org, Oct 27 2016

Labels: merge-merged-2840
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9859aac71e6b077f66c37da16896971a81c02e08

commit 9859aac71e6b077f66c37da16896971a81c02e08
Author: jmadill <jmadill@chromium.org>
Date: Thu Oct 06 20:11:14 2016

Roll ANGLE d08f3b3..873d00f

https://chromium.googlesource.com/angle/angle.git/+log/d08f3b3..873d00f

BUG= chromium:653274 , chromium:651493 , chromium:653276 , chromium:593024 , chromium:634525 

TBR=geofflang@chromium.org

TEST=bots

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.win:win_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2399933002
Cr-Commit-Position: refs/heads/master@{#423643}

[modify] https://crrev.com/9859aac71e6b077f66c37da16896971a81c02e08/DEPS

Comment 24 by dimu@google.com, Nov 4 2016

Labels: -merge-merged-2840
[Automated comment] removing mislabelled merge-merged-2840

Sign in to add a comment