Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2390)

Issue 7139055: Avoid splitting of loops with many iterations when using shader model 3.

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 3 months ago by apatrick1
Modified:
11 years, 2 months ago
Reviewers:
kbr1, dgkoch, nicolas
CC:
angleproject-review_googlegroups.com
Base URL:
http://angleproject.googlecode.com/svn/trunk/
Visibility:
Public.

Description

Avoid splitting of loops with many iterations when using shader model 3. This is only necessary for shader model 2 and it can take the D3DX shader compiler a long time to unroll all the resulting loops. The D3DX compiler does not emit an error if a loop has more than 256 iterations with shader model 3. Also, fix issue where loop discontinuity detection was being performed for vertex shaders. This is not necessary because vertex shaders do not have gradient operations.

Patch Set 1 : #

Patch Set 2 : #

Total comments: 2

Patch Set 3 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+18 lines, -3 lines) Patch
M include/GLSLANG/ShaderLang.h View 1 2 1 chunk +5 lines, -1 line 0 comments Download
M src/compiler/OutputHLSL.cpp View 1 2 1 chunk +5 lines, -2 lines 0 comments Download
M src/libGLESv2/Shader.cpp View 1 2 1 chunk +8 lines, -0 lines 0 comments Download

Messages

Total messages: 5
apatrick1
PTAL. This drastically improves the compile time of some shaders that have loops with many ...
11 years, 3 months ago (2013-01-18 19:53:11 UTC) #1
kbr1
LGTM
11 years, 3 months ago (2013-01-18 21:14:47 UTC) #2
apatrick1
https://codereview.appspot.com/7139055/diff/1007/src/compiler/OutputHLSL.cpp File src/compiler/OutputHLSL.cpp (right): https://codereview.appspot.com/7139055/diff/1007/src/compiler/OutputHLSL.cpp#newcode102 src/compiler/OutputHLSL.cpp:102: mContainsLoopDiscontinuity = mContext.shaderType == SH_FRAGMENT_SHADER && containsLoopDiscontinuity(mContext.treeRoot); Sorry, this... ...
11 years, 3 months ago (2013-01-18 21:18:04 UTC) #3
nicolas
When disabling loop splitting of a 2000 iteration loop with simple arithmetic, I get the ...
11 years, 3 months ago (2013-01-21 21:55:25 UTC) #4
kbr1
11 years, 2 months ago (2013-01-22 20:32:03 UTC) #5
Could you email us your test case offline?

Recently two shaders were brought to our attention which worked fine on SM3 with
loop splitting disabled, but either failed to compile, or took too long to
compile, with it turned on. One was turned into a conformance test:
https://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/large-...
. Do you think that that test is reasonable?

It seems that either with high iteration counts or a lot of work being done in
loops without a very high iteration count, loop splitting is causing the D3D
shader compiler to take a very long time.

Do you have other suggestions? What about, on SM3, attempting the compile with
loop splitting disabled, and turning it on and re-translating and re-compiling
if that fails?


On 2013/01/21 21:55:25, nicolas wrote:
> When disabling loop splitting of a 2000 iteration loop with simple arithmetic,
I
> get the following HLSL compiler warning and error:
> 
> warning X3569: loop executes for more than 255 iterations (maximum for this
> shader target), forcing loop to unroll
> error X3511: unable to unroll loop, loop does not appear to terminate in a
> timely manner (1024 iterations)
> 
> This is with Direct3D 9 and Shader Model 3. So it appears that the HLSL
compiler
> won't unroll a loop for more than 1024 iterations. If I reduce the loop count
to
> 1000, it compiles correctly. What's more, the assembly actually shows a loop
of
> 1000 iterations, but I still get warning X3569.
> 
> However, when disabling loop splitting the acos and asin tests from the
Khronos
> GTF fail because they do cause loop unrolling and this in turn causes it to
use
> more than the available number of constant registers.
> 
> So supporting high loop iteration counts is very hard to achieve with Shader
> Model 3. I'm afraid this might require adjusting people's expectations. ES2
> demands loops to be unrollable, and compilation may fail due to running out of
> hardware resources.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b