Generate correctly structured do-while loops.
The loop test is always emitted before the loop body. For do-while loops, use a phi node to track whether we're on the first loop iteration, and only check the loop test on the second and subsequent iterations. For do-while loops, the loop test branch no longer occurs at the top of the loop, so it must get its own selection merge instruction. A block can't be the target of more than one merge instruction. So when the loop test executes after the body (as in do-while in GLSL) we need to introduce a dummy block to be the target of the selection merge just before the loop test conditional branch. The other arm of the branch exits the loop and hence is the "break block" exception in the structured control flow rules.
This commit is contained in:
@@ -5,7 +5,7 @@ Linked fragment stage:
|
||||
|
||||
// Module Version 99
|
||||
// Generated by (magic number): 51a00bb
|
||||
// Id's are bound by 34
|
||||
// Id's are bound by 38
|
||||
|
||||
Source GLSL 110
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
@@ -14,11 +14,11 @@ Linked fragment stage:
|
||||
Name 4 "main"
|
||||
Name 10 "color"
|
||||
Name 12 "BaseColor"
|
||||
Name 19 "bigColor"
|
||||
Name 26 "d"
|
||||
Name 32 "gl_FragColor"
|
||||
Name 25 "d"
|
||||
Name 30 "bigColor"
|
||||
Name 36 "gl_FragColor"
|
||||
Decorate 12(BaseColor) Smooth
|
||||
Decorate 32(gl_FragColor) BuiltIn FragColor
|
||||
Decorate 36(gl_FragColor) BuiltIn FragColor
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
7: TypeFloat 32
|
||||
@@ -26,13 +26,15 @@ Linked fragment stage:
|
||||
9: TypePointer Function 8(fvec4)
|
||||
11: TypePointer Input 8(fvec4)
|
||||
12(BaseColor): 11(ptr) Variable Input
|
||||
18: TypePointer UniformConstant 8(fvec4)
|
||||
19(bigColor): 18(ptr) Variable UniformConstant
|
||||
25: TypePointer UniformConstant 7(float)
|
||||
26(d): 25(ptr) Variable UniformConstant
|
||||
28: TypeBool
|
||||
31: TypePointer Output 8(fvec4)
|
||||
32(gl_FragColor): 31(ptr) Variable Output
|
||||
17: TypeBool
|
||||
18: 17(bool) ConstantTrue
|
||||
24: TypePointer UniformConstant 7(float)
|
||||
25(d): 24(ptr) Variable UniformConstant
|
||||
29: TypePointer UniformConstant 8(fvec4)
|
||||
30(bigColor): 29(ptr) Variable UniformConstant
|
||||
34: 17(bool) ConstantFalse
|
||||
35: TypePointer Output 8(fvec4)
|
||||
36(gl_FragColor): 35(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
10(color): 9(ptr) Variable Function
|
||||
@@ -40,25 +42,30 @@ Linked fragment stage:
|
||||
Store 10(color) 13
|
||||
Branch 14
|
||||
14: Label
|
||||
16: 17(bool) Phi 18 5 34 20
|
||||
LoopMerge 15 None
|
||||
Branch 16
|
||||
16: Label
|
||||
20: 8(fvec4) Load 19(bigColor)
|
||||
21: 8(fvec4) Load 10(color)
|
||||
22: 8(fvec4) FAdd 21 20
|
||||
Store 10(color) 22
|
||||
Branch 17
|
||||
17: Label
|
||||
23: 8(fvec4) Load 10(color)
|
||||
24: 7(float) CompositeExtract 23 0
|
||||
27: 7(float) Load 26(d)
|
||||
29: 28(bool) FOrdLessThan 24 27
|
||||
BranchConditional 29 30 15
|
||||
30: Label
|
||||
Branch 14
|
||||
Branch 19
|
||||
19: Label
|
||||
SelectionMerge 20 None
|
||||
BranchConditional 16 20 21
|
||||
21: Label
|
||||
22: 8(fvec4) Load 10(color)
|
||||
23: 7(float) CompositeExtract 22 0
|
||||
26: 7(float) Load 25(d)
|
||||
27: 17(bool) FOrdLessThan 23 26
|
||||
SelectionMerge 28 None
|
||||
BranchConditional 27 28 15
|
||||
28: Label
|
||||
Branch 20
|
||||
20: Label
|
||||
31: 8(fvec4) Load 30(bigColor)
|
||||
32: 8(fvec4) Load 10(color)
|
||||
33: 8(fvec4) FAdd 32 31
|
||||
Store 10(color) 33
|
||||
Branch 14
|
||||
15: Label
|
||||
33: 8(fvec4) Load 10(color)
|
||||
Store 32(gl_FragColor) 33
|
||||
37: 8(fvec4) Load 10(color)
|
||||
Store 36(gl_FragColor) 37
|
||||
Branch 6
|
||||
6: Label
|
||||
Return
|
||||
|
||||
Reference in New Issue
Block a user