HLSL: Fix unary and binary operator type conversion issues
This fixes defects as follows: 1. handleLvalue could be called on a non-L-value, and it shouldn't be. 2. HLSL allows unary negation on non-bool values. TUnaryOperator::promote can now promote other types (e.g, int, float) to bool for this op. 3. HLSL allows binary logical operations (&&, ||) on arbitrary types, similar (2). 4. HLSL allows mod operation on arbitrary types, which will be promoted. E.g, int % float -> float % float.
This commit is contained in:
220
Test/baseResults/hlsl.logical.binary.frag.out
Normal file
220
Test/baseResults/hlsl.logical.binary.frag.out
Normal file
@@ -0,0 +1,220 @@
|
||||
hlsl.logical.binary.frag
|
||||
Shader version: 450
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:12 Function Definition: main( (temp structure{temp 4-component vector of float Color})
|
||||
0:12 Function Parameters:
|
||||
0:? Sequence
|
||||
0:13 Test condition and select (temp void)
|
||||
0:13 Condition
|
||||
0:13 logical-and (temp bool)
|
||||
0:13 Convert int to bool (temp bool)
|
||||
0:13 ival: direct index for structure (layout(offset=0 ) uniform int)
|
||||
0:13 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
0:13 Constant:
|
||||
0:13 0 (const uint)
|
||||
0:13 Convert int to bool (temp bool)
|
||||
0:13 Convert float to int (temp int)
|
||||
0:13 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:13 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
0:13 Constant:
|
||||
0:13 2 (const uint)
|
||||
0:13 true case is null
|
||||
0:14 Test condition and select (temp void)
|
||||
0:14 Condition
|
||||
0:14 logical-or (temp bool)
|
||||
0:14 Convert int to bool (temp bool)
|
||||
0:14 ival: direct index for structure (layout(offset=0 ) uniform int)
|
||||
0:14 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
0:14 Constant:
|
||||
0:14 0 (const uint)
|
||||
0:14 Convert int to bool (temp bool)
|
||||
0:14 Convert float to int (temp int)
|
||||
0:14 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:14 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
0:14 Constant:
|
||||
0:14 2 (const uint)
|
||||
0:14 true case is null
|
||||
0:17 move second child to first child (temp 4-component vector of float)
|
||||
0:17 Color: direct index for structure (temp 4-component vector of float)
|
||||
0:17 'psout' (temp structure{temp 4-component vector of float Color})
|
||||
0:17 Constant:
|
||||
0:17 0 (const int)
|
||||
0:17 Constant:
|
||||
0:17 1.000000
|
||||
0:17 1.000000
|
||||
0:17 1.000000
|
||||
0:17 1.000000
|
||||
0:18 Sequence
|
||||
0:18 Sequence
|
||||
0:18 move second child to first child (temp 4-component vector of float)
|
||||
0:? 'Color' (layout(location=0 ) out 4-component vector of float)
|
||||
0:18 Color: direct index for structure (temp 4-component vector of float)
|
||||
0:18 'psout' (temp structure{temp 4-component vector of float Color})
|
||||
0:18 Constant:
|
||||
0:18 0 (const int)
|
||||
0:18 Branch: Return
|
||||
0:? Linker Objects
|
||||
0:? 'Color' (layout(location=0 ) out 4-component vector of float)
|
||||
0:? 'anon@0' (uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
|
||||
|
||||
Shader version: 450
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:12 Function Definition: main( (temp structure{temp 4-component vector of float Color})
|
||||
0:12 Function Parameters:
|
||||
0:? Sequence
|
||||
0:13 Test condition and select (temp void)
|
||||
0:13 Condition
|
||||
0:13 logical-and (temp bool)
|
||||
0:13 Convert int to bool (temp bool)
|
||||
0:13 ival: direct index for structure (layout(offset=0 ) uniform int)
|
||||
0:13 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
0:13 Constant:
|
||||
0:13 0 (const uint)
|
||||
0:13 Convert int to bool (temp bool)
|
||||
0:13 Convert float to int (temp int)
|
||||
0:13 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:13 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
0:13 Constant:
|
||||
0:13 2 (const uint)
|
||||
0:13 true case is null
|
||||
0:14 Test condition and select (temp void)
|
||||
0:14 Condition
|
||||
0:14 logical-or (temp bool)
|
||||
0:14 Convert int to bool (temp bool)
|
||||
0:14 ival: direct index for structure (layout(offset=0 ) uniform int)
|
||||
0:14 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
0:14 Constant:
|
||||
0:14 0 (const uint)
|
||||
0:14 Convert int to bool (temp bool)
|
||||
0:14 Convert float to int (temp int)
|
||||
0:14 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:14 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
0:14 Constant:
|
||||
0:14 2 (const uint)
|
||||
0:14 true case is null
|
||||
0:17 move second child to first child (temp 4-component vector of float)
|
||||
0:17 Color: direct index for structure (temp 4-component vector of float)
|
||||
0:17 'psout' (temp structure{temp 4-component vector of float Color})
|
||||
0:17 Constant:
|
||||
0:17 0 (const int)
|
||||
0:17 Constant:
|
||||
0:17 1.000000
|
||||
0:17 1.000000
|
||||
0:17 1.000000
|
||||
0:17 1.000000
|
||||
0:18 Sequence
|
||||
0:18 Sequence
|
||||
0:18 move second child to first child (temp 4-component vector of float)
|
||||
0:? 'Color' (layout(location=0 ) out 4-component vector of float)
|
||||
0:18 Color: direct index for structure (temp 4-component vector of float)
|
||||
0:18 'psout' (temp structure{temp 4-component vector of float Color})
|
||||
0:18 Constant:
|
||||
0:18 0 (const int)
|
||||
0:18 Branch: Return
|
||||
0:? Linker Objects
|
||||
0:? 'Color' (layout(location=0 ) out 4-component vector of float)
|
||||
0:? 'anon@0' (uniform block{layout(offset=0 ) uniform int ival, layout(offset=16 ) uniform 4-component vector of int ival4, layout(offset=32 ) uniform float fval, layout(offset=48 ) uniform 4-component vector of float fval4})
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 57
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 53
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Name 4 "main"
|
||||
Name 11 "$Global"
|
||||
MemberName 11($Global) 0 "ival"
|
||||
MemberName 11($Global) 1 "ival4"
|
||||
MemberName 11($Global) 2 "fval"
|
||||
MemberName 11($Global) 3 "fval4"
|
||||
Name 13 ""
|
||||
Name 45 "PS_OUTPUT"
|
||||
MemberName 45(PS_OUTPUT) 0 "Color"
|
||||
Name 47 "psout"
|
||||
Name 53 "Color"
|
||||
MemberDecorate 11($Global) 0 Offset 0
|
||||
MemberDecorate 11($Global) 1 Offset 16
|
||||
MemberDecorate 11($Global) 2 Offset 32
|
||||
MemberDecorate 11($Global) 3 Offset 48
|
||||
Decorate 11($Global) Block
|
||||
Decorate 13 DescriptorSet 0
|
||||
Decorate 53(Color) Location 0
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeBool
|
||||
7: TypeInt 32 1
|
||||
8: TypeVector 7(int) 4
|
||||
9: TypeFloat 32
|
||||
10: TypeVector 9(float) 4
|
||||
11($Global): TypeStruct 7(int) 8(ivec4) 9(float) 10(fvec4)
|
||||
12: TypePointer Uniform 11($Global)
|
||||
13: 12(ptr) Variable Uniform
|
||||
14: 7(int) Constant 0
|
||||
15: TypePointer Uniform 7(int)
|
||||
18: TypeInt 32 0
|
||||
19: 18(int) Constant 0
|
||||
23: 7(int) Constant 2
|
||||
24: TypePointer Uniform 9(float)
|
||||
45(PS_OUTPUT): TypeStruct 10(fvec4)
|
||||
46: TypePointer Function 45(PS_OUTPUT)
|
||||
48: 9(float) Constant 1065353216
|
||||
49: 10(fvec4) ConstantComposite 48 48 48 48
|
||||
50: TypePointer Function 10(fvec4)
|
||||
52: TypePointer Output 10(fvec4)
|
||||
53(Color): 52(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
47(psout): 46(ptr) Variable Function
|
||||
16: 15(ptr) AccessChain 13 14
|
||||
17: 7(int) Load 16
|
||||
20: 6(bool) INotEqual 17 19
|
||||
SelectionMerge 22 None
|
||||
BranchConditional 20 21 22
|
||||
21: Label
|
||||
25: 24(ptr) AccessChain 13 23
|
||||
26: 9(float) Load 25
|
||||
27: 7(int) ConvertFToS 26
|
||||
28: 6(bool) INotEqual 27 19
|
||||
Branch 22
|
||||
22: Label
|
||||
29: 6(bool) Phi 20 5 28 21
|
||||
SelectionMerge 31 None
|
||||
BranchConditional 29 30 31
|
||||
30: Label
|
||||
Branch 31
|
||||
31: Label
|
||||
32: 15(ptr) AccessChain 13 14
|
||||
33: 7(int) Load 32
|
||||
34: 6(bool) INotEqual 33 19
|
||||
35: 6(bool) LogicalNot 34
|
||||
SelectionMerge 37 None
|
||||
BranchConditional 35 36 37
|
||||
36: Label
|
||||
38: 24(ptr) AccessChain 13 23
|
||||
39: 9(float) Load 38
|
||||
40: 7(int) ConvertFToS 39
|
||||
41: 6(bool) INotEqual 40 19
|
||||
Branch 37
|
||||
37: Label
|
||||
42: 6(bool) Phi 34 31 41 36
|
||||
SelectionMerge 44 None
|
||||
BranchConditional 42 43 44
|
||||
43: Label
|
||||
Branch 44
|
||||
44: Label
|
||||
51: 50(ptr) AccessChain 47(psout) 14
|
||||
Store 51 49
|
||||
54: 50(ptr) AccessChain 47(psout) 14
|
||||
55: 10(fvec4) Load 54
|
||||
Store 53(Color) 55
|
||||
Return
|
||||
FunctionEnd
|
||||
Reference in New Issue
Block a user