Closed Bug 785848 Opened 12 years ago Closed 7 years ago

WebGL shader loop unroll issue via angle d3d with ps_3_0

Categories

(Core :: Graphics: CanvasWebGL, defect)

14 Branch
Unspecified
Windows
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: pyalot, Assigned: kvark)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.8 Safari/536.11

Steps to reproduce:

Run this code: http://codeflow.org/issues/unroll-problem/


Actual results:

Output indicated 2 minutes time to error and shown this error message:

"error X3511: unable to unroll loop, loop does not appear to terminate in a timely manner (9 iterations), use the [unroll(n)] attribute to force an exact higher number"

On the shader info log. CPU use was at 25% and the page/browser was non-responding.


Expected results:

Linux/OSX have no problem with this code and show an output of "Compile Time: 11ms".
Component: Untriaged → Canvas: WebGL
Product: Firefox → Core
Unable to repro on Linux x64 with FF 53.0a1, "Intel(R) HD Graphics 5500 (Broadwell GT2)"
You need to try on Windows since it's a Direct3D HLSL compiler related problem.
OS: Linux → Windows
Florian, I tested on Windows 7 with Radeon Rx 480, no issues either.
If you've merged in some angle fixes or updated the d3d runtime to dx11, the bug could be fixed by those. If you want to know when you incidentially "fixed" it you'll have to bisect FF versions all the way back to 2012 since apparently only now somebody got around to look at the bug.
Ah, apologies, that was OSX (sharing the monitor and input got me confused).
Loading on actual Windows gets FF stuck. Investigating...
Assignee: nobody → kvark
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Looks like Angle puts `[unroll]` on top of the loop, and then FXC is having problems actually doing it.
Related - https://codereview.appspot.com/7139055/
Attached file test.hlsl
Attaching HLSL produced by Angle
I think we're also unrolling loops always, when we don't always need to.
Attached file Output.txt
Attached the FXC output when compiling the Angle-produced HTML with targets ps_3_0, ps_4_0, ps_5_0:

ps_3_0 gives up after ~2 minutes, although reporting it stopped after 710 iterations (6 iterations per second?)
ps_4_0 and ps_5_0 succeed in 13 seconds

One possible solution is to submit a patch to Angle limiting the maximum loop unroll, similar to https://codereview.appspot.com/7139055/. Although, it doesn't seem straightforward that it will be merged, especially given the freely adjustable constant it would introduce.

Another solution is to force angle to work with D3D11 and HLSL 4.0 targets, if possible. Given that we are fading out WinXP, I don't see much value in supporting D3D9 anyway.
Attachment #8822528 - Flags: feedback?(jgilbert)
Florian, I accidentally had "webgl.angle.try-d3d11 == false" on that Windows machine. When I set it back to default (true), the page loads normally, reporting: "Compile Time: 2140ms". I suppose the issue only persists where d3d11 is not available or fails to activate. Could you check again and confirm if it's still a problem?
Flags: needinfo?(pyalot)
I currently can't test on a windows configuration, but I know that d3d11 helps some.

However, 2140ms is much too long to compile a shader. It takes 21ms to compile on Linux (and probably similar amounts on other OS'es).

Lengthy shader compile times have been a persistent problem for WebGL and should be eliminated.
Florian, I do agree that 2140ms is little outside of the comfort zone, and we should be doing something about it. However, this bug doesn't seem to be a proper medium, since the original report was about FXC running out of time after 2 minutes, which was a much more severe issue that is no longer a problem.

Jeff, do we have a general bug for tracking Angle's shader compiling performance?
Flags: needinfo?(jgilbert)
(In reply to Dzmitry Malyshau from comment #12)
> Florian, I do agree that 2140ms is little outside of the comfort zone, and
> we should be doing something about it. However, this bug doesn't seem to be
> a proper medium, since the original report was about FXC running out of time
> after 2 minutes, which was a much more severe issue that is no longer a
> problem.
> 
> Jeff, do we have a general bug for tracking Angle's shader compiling
> performance?

I don't think so. I made one: Bug 1326482
Flags: needinfo?(jgilbert)
Hardware: x86 → Unspecified
Attachment #8822528 - Flags: feedback?(jgilbert)
Ok, thanks Jeff! I consider this issue to be closed then.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Flags: needinfo?(pyalot)
Resolution: --- → FIXED
Resolution: FIXED → WONTFIX
Summary: WebGL shader loop unroll issue via angle d3d → WebGL shader loop unroll issue via angle d3d with ps_3_0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: