Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
84cc15f0
Commit
84cc15f0
authored
May 24, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Fix #903: Don't short-circuit && or ||.
parent
6e2295d3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
82 deletions
+70
-82
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+3
-4
hlsl.implicitBool.frag.out
Test/baseResults/hlsl.implicitBool.frag.out
+0
-0
hlsl.isfinite.frag.out
Test/baseResults/hlsl.isfinite.frag.out
+0
-0
hlsl.logical.binary.frag.out
Test/baseResults/hlsl.logical.binary.frag.out
+67
-78
No files found.
SPIRV/GlslangToSpv.cpp
View file @
84cc15f0
...
@@ -5361,8 +5361,7 @@ bool TGlslangToSpvTraverser::isTrivialLeaf(const glslang::TIntermTyped* node)
...
@@ -5361,8 +5361,7 @@ 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.
// Vector results seem ill-defined, currently classifying them as trivial too,
// HLSL (and/or vectors) are always trivial, as it does not short circuit.
// to avoid scalar bool-based control-flow logic.
// Otherwise, error on the side of saying non-trivial.
// 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
)
...
@@ -5370,8 +5369,8 @@ bool TGlslangToSpvTraverser::isTrivial(const glslang::TIntermTyped* node)
...
@@ -5370,8 +5369,8 @@ bool TGlslangToSpvTraverser::isTrivial(const glslang::TIntermTyped* node)
if
(
node
==
nullptr
)
if
(
node
==
nullptr
)
return
false
;
return
false
;
// count
vectors as trivial
// count
non scalars as trivial, as well as anything coming from HLSL
if
(
node
->
getType
().
isVector
()
)
if
(
!
node
->
getType
().
isScalarOrVec1
()
||
glslangIntermediate
->
getSource
()
==
glslang
::
EShSourceHlsl
)
return
true
;
return
true
;
// symbols and constants are trivial
// symbols and constants are trivial
...
...
Test/baseResults/hlsl.implicitBool.frag.out
View file @
84cc15f0
This diff is collapsed.
Click to expand it.
Test/baseResults/hlsl.isfinite.frag.out
View file @
84cc15f0
This diff is collapsed.
Click to expand it.
Test/baseResults/hlsl.logical.binary.frag.out
View file @
84cc15f0
...
@@ -129,106 +129,95 @@ gl_FragCoord origin is upper left
...
@@ -129,106 +129,95 @@ 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
62
// Id's are bound by
57
Capability Shader
Capability Shader
1: ExtInstImport "GLSL.std.450"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 5
9
EntryPoint Fragment 4 "main" 5
4
ExecutionMode 4 OriginUpperLeft
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Source HLSL 500
Name 4 "main"
Name 4 "main"
Name 8 "PS_OUTPUT"
Name 8 "PS_OUTPUT"
MemberName 8(PS_OUTPUT) 0 "Color"
MemberName 8(PS_OUTPUT) 0 "Color"
Name 10 "@main("
Name 10 "@main("
Name 1
5
"$Global"
Name 1
4
"$Global"
MemberName 1
5
($Global) 0 "ival"
MemberName 1
4
($Global) 0 "ival"
MemberName 1
5
($Global) 1 "ival4"
MemberName 1
4
($Global) 1 "ival4"
MemberName 1
5
($Global) 2 "fval"
MemberName 1
4
($Global) 2 "fval"
MemberName 1
5
($Global) 3 "fval4"
MemberName 1
4
($Global) 3 "fval4"
Name 1
7
""
Name 1
6
""
Name
50
"psout"
Name
45
"psout"
Name 5
9
"Color"
Name 5
4
"Color"
MemberDecorate 1
5
($Global) 0 Offset 0
MemberDecorate 1
4
($Global) 0 Offset 0
MemberDecorate 1
5
($Global) 1 Offset 16
MemberDecorate 1
4
($Global) 1 Offset 16
MemberDecorate 1
5
($Global) 2 Offset 32
MemberDecorate 1
4
($Global) 2 Offset 32
MemberDecorate 1
5
($Global) 3 Offset 48
MemberDecorate 1
4
($Global) 3 Offset 48
Decorate 1
5
($Global) Block
Decorate 1
4
($Global) Block
Decorate 1
7
DescriptorSet 0
Decorate 1
6
DescriptorSet 0
Decorate 5
9
(Color) Location 0
Decorate 5
4
(Color) Location 0
2: TypeVoid
2: TypeVoid
3: TypeFunction 2
3: TypeFunction 2
6: TypeFloat 32
6: TypeFloat 32
7: TypeVector 6(float) 4
7: TypeVector 6(float) 4
8(PS_OUTPUT): TypeStruct 7(fvec4)
8(PS_OUTPUT): TypeStruct 7(fvec4)
9: TypeFunction 8(PS_OUTPUT)
9: TypeFunction 8(PS_OUTPUT)
12: Type
Bool
12: Type
Int 32 1
13: Type
Int 32 1
13: Type
Vector 12(int) 4
14: TypeVector 13(int) 4
14($Global): TypeStruct 12(int) 13(ivec4) 6(float) 7(fvec4)
15($Global): TypeStruct 13(int) 14(ivec4) 6(float) 7(fvec4
)
15: TypePointer Uniform 14($Global
)
16:
TypePointer Uniform 15($Global)
16:
15(ptr) Variable Uniform
17: 1
6(ptr) Variable Uniform
17: 1
2(int) Constant 0
18:
13(int) Constant 0
18:
TypePointer Uniform 12(int)
19: TypePointer Uniform 13(int)
21: TypeBool
22: TypeInt 32 0
22: TypeInt 32 0
23: 22(int) Constant 0
23: 22(int) Constant 0
2
7: 13
(int) Constant 2
2
5: 12
(int) Constant 2
2
8
: TypePointer Uniform 6(float)
2
6
: TypePointer Uniform 6(float)
4
9
: TypePointer Function 8(PS_OUTPUT)
4
4
: TypePointer Function 8(PS_OUTPUT)
51
: 6(float) Constant 1065353216
46
: 6(float) Constant 1065353216
52: 7(fvec4) ConstantComposite 51 51 51 51
47: 7(fvec4) ConstantComposite 46 46 46 46
53
: TypePointer Function 7(fvec4)
48
: TypePointer Function 7(fvec4)
5
8
: TypePointer Output 7(fvec4)
5
3
: TypePointer Output 7(fvec4)
5
9(Color): 58
(ptr) Variable Output
5
4(Color): 53
(ptr) Variable Output
4(main): 2 Function None 3
4(main): 2 Function None 3
5: Label
5: Label
60
:8(PS_OUTPUT) FunctionCall 10(@main()
55
:8(PS_OUTPUT) FunctionCall 10(@main()
61: 7(fvec4) CompositeExtract 60
0
56: 7(fvec4) CompositeExtract 55
0
Store 5
9(Color) 61
Store 5
4(Color) 56
Return
Return
FunctionEnd
FunctionEnd
10(@main():8(PS_OUTPUT) Function None 9
10(@main():8(PS_OUTPUT) Function None 9
11: Label
11: Label
50(psout): 49(ptr) Variable Function
45(psout): 44(ptr) Variable Function
20: 19(ptr) AccessChain 17 18
19: 18(ptr) AccessChain 16 17
21: 13(int) Load 20
20: 12(int) Load 19
24: 12(bool) INotEqual 21 23
24: 21(bool) INotEqual 20 23
SelectionMerge 26 None
27: 26(ptr) AccessChain 16 25
BranchConditional 24 25 26
28: 6(float) Load 27
25: Label
29: 12(int) ConvertFToS 28
29: 28(ptr) AccessChain 17 27
30: 21(bool) INotEqual 29 23
30: 6(float) Load 29
31: 21(bool) LogicalAnd 24 30
31: 13(int) ConvertFToS 30
SelectionMerge 33 None
32: 12(bool) INotEqual 31 23
BranchConditional 31 32 33
Branch 26
32: Label
26: Label
Branch 33
33: 12(bool) Phi 24 11 32 25
33: Label
SelectionMerge 35 None
34: 18(ptr) AccessChain 16 17
BranchConditional 33 34 35
35: 12(int) Load 34
34: Label
36: 21(bool) INotEqual 35 23
Branch 35
37: 26(ptr) AccessChain 16 25
35: Label
38: 6(float) Load 37
36: 19(ptr) AccessChain 17 18
39: 12(int) ConvertFToS 38
37: 13(int) Load 36
40: 21(bool) INotEqual 39 23
38: 12(bool) INotEqual 37 23
41: 21(bool) LogicalOr 36 40
39: 12(bool) LogicalNot 38
SelectionMerge 43 None
SelectionMerge 41 None
BranchConditional 41 42 43
BranchConditional 39 40 41
42: Label
40: Label
Branch 43
42: 28(ptr) AccessChain 17 27
43: Label
43: 6(float) Load 42
49: 48(ptr) AccessChain 45(psout) 17
44: 13(int) ConvertFToS 43
Store 49 47
45: 12(bool) INotEqual 44 23
50:8(PS_OUTPUT) Load 45(psout)
Branch 41
ReturnValue 50
41: Label
46: 12(bool) Phi 38 35 45 40
SelectionMerge 48 None
BranchConditional 46 47 48
47: Label
Branch 48
48: Label
54: 53(ptr) AccessChain 50(psout) 18
Store 54 52
55:8(PS_OUTPUT) Load 50(psout)
ReturnValue 55
FunctionEnd
FunctionEnd
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment