HLSL: Don't do logical short-circuits when the operands are bool-vectors.
This seems a bit ill-defined, and was generating code that made OpPhi of two operands that were Boolean vectors result in a scalar bool.
This commit is contained in:
@@ -5356,13 +5356,19 @@ bool TGlslangToSpvTraverser::isTrivialLeaf(const glslang::TIntermTyped* node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A node is trivial if it is a single operation with no side effects.
|
// A node is trivial if it is a single operation with no side effects.
|
||||||
// Error on the side of saying non-trivial.
|
// Vector results seem ill-defined, currently classifying them as trivial too,
|
||||||
|
// to avoid scalar bool-based control-flow logic.
|
||||||
|
// Otherwise, error on the side of saying non-trivial.
|
||||||
// Return true if trivial.
|
// Return true if trivial.
|
||||||
bool TGlslangToSpvTraverser::isTrivial(const glslang::TIntermTyped* node)
|
bool TGlslangToSpvTraverser::isTrivial(const glslang::TIntermTyped* node)
|
||||||
{
|
{
|
||||||
if (node == nullptr)
|
if (node == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// count vectors as trivial
|
||||||
|
if (node->getType().isVector())
|
||||||
|
return true;
|
||||||
|
|
||||||
// symbols and constants are trivial
|
// symbols and constants are trivial
|
||||||
if (isTrivialLeaf(node))
|
if (isTrivialLeaf(node))
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -173,12 +173,12 @@ gl_FragCoord origin is upper left
|
|||||||
|
|
||||||
// Module Version 10000
|
// Module Version 10000
|
||||||
// Generated by (magic number): 80001
|
// Generated by (magic number): 80001
|
||||||
// Id's are bound by 95
|
// Id's are bound by 91
|
||||||
|
|
||||||
Capability Shader
|
Capability Shader
|
||||||
1: ExtInstImport "GLSL.std.450"
|
1: ExtInstImport "GLSL.std.450"
|
||||||
MemoryModel Logical GLSL450
|
MemoryModel Logical GLSL450
|
||||||
EntryPoint Fragment 4 "main" 93
|
EntryPoint Fragment 4 "main" 89
|
||||||
ExecutionMode 4 OriginUpperLeft
|
ExecutionMode 4 OriginUpperLeft
|
||||||
Source HLSL 500
|
Source HLSL 500
|
||||||
Name 4 "main"
|
Name 4 "main"
|
||||||
@@ -193,14 +193,14 @@ gl_FragCoord origin is upper left
|
|||||||
MemberName 39($Global) 2 "f3"
|
MemberName 39($Global) 2 "f3"
|
||||||
Name 41 ""
|
Name 41 ""
|
||||||
Name 57 "@finitetmp"
|
Name 57 "@finitetmp"
|
||||||
Name 73 "@finitetmp"
|
Name 71 "@finitetmp"
|
||||||
Name 93 "@entryPointOutput"
|
Name 89 "@entryPointOutput"
|
||||||
MemberDecorate 39($Global) 0 Offset 0
|
MemberDecorate 39($Global) 0 Offset 0
|
||||||
MemberDecorate 39($Global) 1 Offset 4
|
MemberDecorate 39($Global) 1 Offset 4
|
||||||
MemberDecorate 39($Global) 2 Offset 16
|
MemberDecorate 39($Global) 2 Offset 16
|
||||||
Decorate 39($Global) Block
|
Decorate 39($Global) Block
|
||||||
Decorate 41 DescriptorSet 0
|
Decorate 41 DescriptorSet 0
|
||||||
Decorate 93(@entryPointOutput) Location 0
|
Decorate 89(@entryPointOutput) Location 0
|
||||||
2: TypeVoid
|
2: TypeVoid
|
||||||
3: TypeFunction 2
|
3: TypeFunction 2
|
||||||
6: TypeFloat 32
|
6: TypeFloat 32
|
||||||
@@ -221,18 +221,18 @@ gl_FragCoord origin is upper left
|
|||||||
58: 42(int) Constant 1
|
58: 42(int) Constant 1
|
||||||
59: TypePointer Uniform 37(fvec2)
|
59: TypePointer Uniform 37(fvec2)
|
||||||
63: TypeVector 8(bool) 2
|
63: TypeVector 8(bool) 2
|
||||||
72: TypePointer Function 38(fvec3)
|
70: TypePointer Function 38(fvec3)
|
||||||
74: 42(int) Constant 2
|
72: 42(int) Constant 2
|
||||||
75: TypePointer Uniform 38(fvec3)
|
73: TypePointer Uniform 38(fvec3)
|
||||||
79: TypeVector 8(bool) 3
|
77: TypeVector 8(bool) 3
|
||||||
88: 6(float) Constant 0
|
84: 6(float) Constant 0
|
||||||
89: 13(fvec4) ConstantComposite 88 88 88 88
|
85: 13(fvec4) ConstantComposite 84 84 84 84
|
||||||
92: TypePointer Output 13(fvec4)
|
88: TypePointer Output 13(fvec4)
|
||||||
93(@entryPointOutput): 92(ptr) Variable Output
|
89(@entryPointOutput): 88(ptr) Variable Output
|
||||||
4(main): 2 Function None 3
|
4(main): 2 Function None 3
|
||||||
5: Label
|
5: Label
|
||||||
94: 13(fvec4) FunctionCall 15(@main()
|
90: 13(fvec4) FunctionCall 15(@main()
|
||||||
Store 93(@entryPointOutput) 94
|
Store 89(@entryPointOutput) 90
|
||||||
Return
|
Return
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
11(test1(f1;): 8(bool) Function None 9
|
11(test1(f1;): 8(bool) Function None 9
|
||||||
@@ -268,7 +268,7 @@ gl_FragCoord origin is upper left
|
|||||||
16: Label
|
16: Label
|
||||||
36(@finitetmp): 7(ptr) Variable Function
|
36(@finitetmp): 7(ptr) Variable Function
|
||||||
57(@finitetmp): 56(ptr) Variable Function
|
57(@finitetmp): 56(ptr) Variable Function
|
||||||
73(@finitetmp): 72(ptr) Variable Function
|
71(@finitetmp): 70(ptr) Variable Function
|
||||||
45: 44(ptr) AccessChain 41 43
|
45: 44(ptr) AccessChain 41 43
|
||||||
46: 6(float) Load 45
|
46: 6(float) Load 45
|
||||||
Store 36(@finitetmp) 46
|
Store 36(@finitetmp) 46
|
||||||
@@ -290,29 +290,19 @@ gl_FragCoord origin is upper left
|
|||||||
62: 37(fvec2) Load 57(@finitetmp)
|
62: 37(fvec2) Load 57(@finitetmp)
|
||||||
64: 63(bvec2) IsNan 62
|
64: 63(bvec2) IsNan 62
|
||||||
65: 63(bvec2) LogicalNot 64
|
65: 63(bvec2) LogicalNot 64
|
||||||
SelectionMerge 67 None
|
66: 37(fvec2) Load 57(@finitetmp)
|
||||||
BranchConditional 65 66 67
|
67: 63(bvec2) IsInf 66
|
||||||
66: Label
|
68: 63(bvec2) LogicalNot 67
|
||||||
68: 37(fvec2) Load 57(@finitetmp)
|
69: 63(bvec2) LogicalAnd 65 68
|
||||||
69: 63(bvec2) IsInf 68
|
74: 73(ptr) AccessChain 41 72
|
||||||
70: 63(bvec2) LogicalNot 69
|
75: 38(fvec3) Load 74
|
||||||
Branch 67
|
Store 71(@finitetmp) 75
|
||||||
67: Label
|
76: 38(fvec3) Load 71(@finitetmp)
|
||||||
71: 8(bool) Phi 65 51 70 66
|
78: 77(bvec3) IsNan 76
|
||||||
76: 75(ptr) AccessChain 41 74
|
79: 77(bvec3) LogicalNot 78
|
||||||
77: 38(fvec3) Load 76
|
80: 38(fvec3) Load 71(@finitetmp)
|
||||||
Store 73(@finitetmp) 77
|
81: 77(bvec3) IsInf 80
|
||||||
78: 38(fvec3) Load 73(@finitetmp)
|
82: 77(bvec3) LogicalNot 81
|
||||||
80: 79(bvec3) IsNan 78
|
83: 77(bvec3) LogicalAnd 79 82
|
||||||
81: 79(bvec3) LogicalNot 80
|
ReturnValue 85
|
||||||
SelectionMerge 83 None
|
|
||||||
BranchConditional 81 82 83
|
|
||||||
82: Label
|
|
||||||
84: 38(fvec3) Load 73(@finitetmp)
|
|
||||||
85: 79(bvec3) IsInf 84
|
|
||||||
86: 79(bvec3) LogicalNot 85
|
|
||||||
Branch 83
|
|
||||||
83: Label
|
|
||||||
87: 8(bool) Phi 81 67 86 82
|
|
||||||
ReturnValue 89
|
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|||||||
@@ -255,12 +255,12 @@ gl_FragCoord origin is upper left
|
|||||||
|
|
||||||
// Module Version 10000
|
// Module Version 10000
|
||||||
// Generated by (magic number): 80001
|
// Generated by (magic number): 80001
|
||||||
// Id's are bound by 120
|
// Id's are bound by 115
|
||||||
|
|
||||||
Capability Shader
|
Capability Shader
|
||||||
1: ExtInstImport "GLSL.std.450"
|
1: ExtInstImport "GLSL.std.450"
|
||||||
MemoryModel Logical GLSL450
|
MemoryModel Logical GLSL450
|
||||||
EntryPoint Fragment 4 "main" 117
|
EntryPoint Fragment 4 "main" 112
|
||||||
ExecutionMode 4 OriginUpperLeft
|
ExecutionMode 4 OriginUpperLeft
|
||||||
Source HLSL 500
|
Source HLSL 500
|
||||||
Name 4 "main"
|
Name 4 "main"
|
||||||
@@ -279,16 +279,16 @@ gl_FragCoord origin is upper left
|
|||||||
Name 47 "r10"
|
Name 47 "r10"
|
||||||
Name 58 "r11"
|
Name 58 "r11"
|
||||||
Name 67 "r20"
|
Name 67 "r20"
|
||||||
Name 79 "r21"
|
Name 77 "r21"
|
||||||
Name 92 "psout"
|
Name 87 "psout"
|
||||||
Name 117 "Color"
|
Name 112 "Color"
|
||||||
MemberDecorate 18($Global) 0 Offset 0
|
MemberDecorate 18($Global) 0 Offset 0
|
||||||
MemberDecorate 18($Global) 1 Offset 16
|
MemberDecorate 18($Global) 1 Offset 16
|
||||||
MemberDecorate 18($Global) 2 Offset 32
|
MemberDecorate 18($Global) 2 Offset 32
|
||||||
MemberDecorate 18($Global) 3 Offset 36
|
MemberDecorate 18($Global) 3 Offset 36
|
||||||
Decorate 18($Global) Block
|
Decorate 18($Global) Block
|
||||||
Decorate 20 DescriptorSet 0
|
Decorate 20 DescriptorSet 0
|
||||||
Decorate 117(Color) Location 0
|
Decorate 112(Color) Location 0
|
||||||
2: TypeVoid
|
2: TypeVoid
|
||||||
3: TypeFunction 2
|
3: TypeFunction 2
|
||||||
6: TypeFloat 32
|
6: TypeFloat 32
|
||||||
@@ -311,20 +311,20 @@ gl_FragCoord origin is upper left
|
|||||||
34: 21(int) Constant 1
|
34: 21(int) Constant 1
|
||||||
48: 21(int) Constant 2
|
48: 21(int) Constant 2
|
||||||
49: TypePointer Uniform 16(int)
|
49: TypePointer Uniform 16(int)
|
||||||
73: 21(int) Constant 3
|
71: 21(int) Constant 3
|
||||||
91: TypePointer Function 8(PS_OUTPUT)
|
86: TypePointer Function 8(PS_OUTPUT)
|
||||||
106: 6(float) Constant 0
|
101: 6(float) Constant 0
|
||||||
107: 6(float) Constant 1065353216
|
102: 6(float) Constant 1065353216
|
||||||
108: 7(fvec4) ConstantComposite 106 106 106 106
|
103: 7(fvec4) ConstantComposite 101 101 101 101
|
||||||
109: 7(fvec4) ConstantComposite 107 107 107 107
|
104: 7(fvec4) ConstantComposite 102 102 102 102
|
||||||
111: TypePointer Function 7(fvec4)
|
106: TypePointer Function 7(fvec4)
|
||||||
116: TypePointer Output 7(fvec4)
|
111: TypePointer Output 7(fvec4)
|
||||||
117(Color): 116(ptr) Variable Output
|
112(Color): 111(ptr) Variable Output
|
||||||
4(main): 2 Function None 3
|
4(main): 2 Function None 3
|
||||||
5: Label
|
5: Label
|
||||||
118:8(PS_OUTPUT) FunctionCall 10(@main()
|
113:8(PS_OUTPUT) FunctionCall 10(@main()
|
||||||
119: 7(fvec4) CompositeExtract 118 0
|
114: 7(fvec4) CompositeExtract 113 0
|
||||||
Store 117(Color) 119
|
Store 112(Color) 114
|
||||||
Return
|
Return
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
10(@main():8(PS_OUTPUT) Function None 9
|
10(@main():8(PS_OUTPUT) Function None 9
|
||||||
@@ -335,8 +335,8 @@ gl_FragCoord origin is upper left
|
|||||||
47(r10): 14(ptr) Variable Function
|
47(r10): 14(ptr) Variable Function
|
||||||
58(r11): 14(ptr) Variable Function
|
58(r11): 14(ptr) Variable Function
|
||||||
67(r20): 14(ptr) Variable Function
|
67(r20): 14(ptr) Variable Function
|
||||||
79(r21): 14(ptr) Variable Function
|
77(r21): 14(ptr) Variable Function
|
||||||
92(psout): 91(ptr) Variable Function
|
87(psout): 86(ptr) Variable Function
|
||||||
24: 23(ptr) AccessChain 20 22
|
24: 23(ptr) AccessChain 20 22
|
||||||
25: 17(ivec4) Load 24
|
25: 17(ivec4) Load 24
|
||||||
28: 13(bvec4) INotEqual 25 27
|
28: 13(bvec4) INotEqual 25 27
|
||||||
@@ -379,48 +379,37 @@ gl_FragCoord origin is upper left
|
|||||||
68: 23(ptr) AccessChain 20 22
|
68: 23(ptr) AccessChain 20 22
|
||||||
69: 17(ivec4) Load 68
|
69: 17(ivec4) Load 68
|
||||||
70: 13(bvec4) INotEqual 69 27
|
70: 13(bvec4) INotEqual 69 27
|
||||||
SelectionMerge 72 None
|
72: 49(ptr) AccessChain 20 71
|
||||||
BranchConditional 70 71 72
|
73: 16(int) Load 72
|
||||||
71: Label
|
74: 12(bool) INotEqual 73 26
|
||||||
74: 49(ptr) AccessChain 20 73
|
75: 13(bvec4) CompositeConstruct 74 74 74 74
|
||||||
75: 16(int) Load 74
|
76: 13(bvec4) LogicalAnd 70 75
|
||||||
76: 12(bool) INotEqual 75 26
|
Store 67(r20) 76
|
||||||
77: 13(bvec4) CompositeConstruct 76 76 76 76
|
78: 23(ptr) AccessChain 20 22
|
||||||
Branch 72
|
79: 17(ivec4) Load 78
|
||||||
72: Label
|
80: 13(bvec4) INotEqual 79 27
|
||||||
78: 12(bool) Phi 70 11 77 71
|
81: 49(ptr) AccessChain 20 71
|
||||||
Store 67(r20) 78
|
82: 16(int) Load 81
|
||||||
80: 23(ptr) AccessChain 20 22
|
83: 12(bool) INotEqual 82 26
|
||||||
81: 17(ivec4) Load 80
|
84: 13(bvec4) CompositeConstruct 83 83 83 83
|
||||||
82: 13(bvec4) INotEqual 81 27
|
85: 13(bvec4) LogicalOr 80 84
|
||||||
83: 12(bool) LogicalNot 82
|
Store 77(r21) 85
|
||||||
SelectionMerge 85 None
|
88: 13(bvec4) Load 15(r00)
|
||||||
BranchConditional 83 84 85
|
89: 13(bvec4) Load 30(r01)
|
||||||
84: Label
|
90: 13(bvec4) LogicalOr 88 89
|
||||||
86: 49(ptr) AccessChain 20 73
|
91: 13(bvec4) Load 39(r02)
|
||||||
87: 16(int) Load 86
|
92: 13(bvec4) LogicalOr 90 91
|
||||||
88: 12(bool) INotEqual 87 26
|
93: 13(bvec4) Load 47(r10)
|
||||||
89: 13(bvec4) CompositeConstruct 88 88 88 88
|
94: 13(bvec4) LogicalOr 92 93
|
||||||
Branch 85
|
95: 13(bvec4) Load 58(r11)
|
||||||
85: Label
|
96: 13(bvec4) LogicalOr 94 95
|
||||||
90: 12(bool) Phi 82 72 89 84
|
97: 13(bvec4) Load 67(r20)
|
||||||
Store 79(r21) 90
|
98: 13(bvec4) LogicalOr 96 97
|
||||||
93: 13(bvec4) Load 15(r00)
|
99: 13(bvec4) Load 77(r21)
|
||||||
94: 13(bvec4) Load 30(r01)
|
100: 13(bvec4) LogicalOr 98 99
|
||||||
95: 13(bvec4) LogicalOr 93 94
|
105: 7(fvec4) Select 100 104 103
|
||||||
96: 13(bvec4) Load 39(r02)
|
107: 106(ptr) AccessChain 87(psout) 22
|
||||||
97: 13(bvec4) LogicalOr 95 96
|
Store 107 105
|
||||||
98: 13(bvec4) Load 47(r10)
|
108:8(PS_OUTPUT) Load 87(psout)
|
||||||
99: 13(bvec4) LogicalOr 97 98
|
ReturnValue 108
|
||||||
100: 13(bvec4) Load 58(r11)
|
|
||||||
101: 13(bvec4) LogicalOr 99 100
|
|
||||||
102: 13(bvec4) Load 67(r20)
|
|
||||||
103: 13(bvec4) LogicalOr 101 102
|
|
||||||
104: 13(bvec4) Load 79(r21)
|
|
||||||
105: 13(bvec4) LogicalOr 103 104
|
|
||||||
110: 7(fvec4) Select 105 109 108
|
|
||||||
112: 111(ptr) AccessChain 92(psout) 22
|
|
||||||
Store 112 110
|
|
||||||
113:8(PS_OUTPUT) Load 92(psout)
|
|
||||||
ReturnValue 113
|
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|||||||
Reference in New Issue
Block a user