WebGL2 TransformFeedback: shader link error on Windows, not on OSX |
||||||||||
Issue descriptionThe 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).
,
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); }
,
Sep 29 2016
CC ANGLE folks
,
Sep 29 2016
,
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.
,
Sep 29 2016
,
Sep 30 2016
I'll take a look.
,
Sep 30 2016
,
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.
,
Oct 1 2016
Second archive didn't work because of missing files, here's the new one (.html is in the asmjs subdirectory)
,
Oct 3 2016
Stealing this.
,
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
,
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.
,
Oct 4 2016
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.
,
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
,
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
,
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
,
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?
,
Oct 5 2016
Yeah, I'll make it an action item to add WebGL tests for these two bugs.
,
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 :)
,
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
,
Oct 6 2016
Great! WebGL test additions underway, shouldn't be long.
,
Oct 27 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
,
Nov 4 2016
[Automated comment] removing mislabelled merge-merged-2840 |
||||||||||
►
Sign in to add a comment |
||||||||||
Comment 1 by flo...@gmail.com
, Sep 29 2016