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:
280
Test/baseResults/hlsl.promote.binary.frag.out
Normal file
280
Test/baseResults/hlsl.promote.binary.frag.out
Normal file
@@ -0,0 +1,280 @@
|
||||
hlsl.promote.binary.frag
|
||||
Shader version: 450
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:14 Function Definition: main( (temp structure{temp 4-component vector of float Color})
|
||||
0:14 Function Parameters:
|
||||
0:? Sequence
|
||||
0:15 mod (temp float)
|
||||
0:15 Convert int to float (temp float)
|
||||
0:15 ival: direct index for structure (layout(offset=32 ) uniform int)
|
||||
0:15 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:15 Constant:
|
||||
0:15 2 (const uint)
|
||||
0:15 fval: direct index for structure (layout(offset=64 ) uniform float)
|
||||
0:15 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:15 Constant:
|
||||
0:15 4 (const uint)
|
||||
0:16 mod (temp 4-component vector of float)
|
||||
0:16 Convert int to float (temp 4-component vector of float)
|
||||
0:16 ival4: direct index for structure (layout(offset=48 ) uniform 4-component vector of int)
|
||||
0:16 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:16 Constant:
|
||||
0:16 3 (const uint)
|
||||
0:16 fval4: direct index for structure (layout(offset=80 ) uniform 4-component vector of float)
|
||||
0:16 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:16 Constant:
|
||||
0:16 5 (const uint)
|
||||
0:18 mod (temp float)
|
||||
0:18 Convert bool to float (temp float)
|
||||
0:18 bval: direct index for structure (layout(offset=0 ) uniform bool)
|
||||
0:18 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:18 Constant:
|
||||
0:18 0 (const uint)
|
||||
0:18 fval: direct index for structure (layout(offset=64 ) uniform float)
|
||||
0:18 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:18 Constant:
|
||||
0:18 4 (const uint)
|
||||
0:19 mod (temp 4-component vector of float)
|
||||
0:19 Convert bool to float (temp 4-component vector of float)
|
||||
0:19 bval4: direct index for structure (layout(offset=16 ) uniform 4-component vector of bool)
|
||||
0:19 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:19 Constant:
|
||||
0:19 1 (const uint)
|
||||
0:19 fval4: direct index for structure (layout(offset=80 ) uniform 4-component vector of float)
|
||||
0:19 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:19 Constant:
|
||||
0:19 5 (const uint)
|
||||
0:21 Sequence
|
||||
0:21 move second child to first child (temp int)
|
||||
0:21 'l_int' (temp int)
|
||||
0:21 Constant:
|
||||
0:21 1 (const int)
|
||||
0:22 mod second child into first child (temp int)
|
||||
0:22 'l_int' (temp int)
|
||||
0:22 Convert float to int (temp int)
|
||||
0:22 fval: direct index for structure (layout(offset=64 ) uniform float)
|
||||
0:22 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:22 Constant:
|
||||
0:22 4 (const uint)
|
||||
0:25 move second child to first child (temp 4-component vector of float)
|
||||
0:25 Color: direct index for structure (temp 4-component vector of float)
|
||||
0:25 'psout' (temp structure{temp 4-component vector of float Color})
|
||||
0:25 Constant:
|
||||
0:25 0 (const int)
|
||||
0:25 Constant:
|
||||
0:25 0.000000
|
||||
0:25 0.000000
|
||||
0:25 0.000000
|
||||
0:25 0.000000
|
||||
0:26 Sequence
|
||||
0:26 Sequence
|
||||
0:26 move second child to first child (temp 4-component vector of float)
|
||||
0:? 'Color' (layout(location=0 ) out 4-component vector of float)
|
||||
0:26 Color: direct index for structure (temp 4-component vector of float)
|
||||
0:26 'psout' (temp structure{temp 4-component vector of float Color})
|
||||
0:26 Constant:
|
||||
0:26 0 (const int)
|
||||
0:26 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 bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
|
||||
|
||||
Shader version: 450
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:14 Function Definition: main( (temp structure{temp 4-component vector of float Color})
|
||||
0:14 Function Parameters:
|
||||
0:? Sequence
|
||||
0:15 mod (temp float)
|
||||
0:15 Convert int to float (temp float)
|
||||
0:15 ival: direct index for structure (layout(offset=32 ) uniform int)
|
||||
0:15 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:15 Constant:
|
||||
0:15 2 (const uint)
|
||||
0:15 fval: direct index for structure (layout(offset=64 ) uniform float)
|
||||
0:15 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:15 Constant:
|
||||
0:15 4 (const uint)
|
||||
0:16 mod (temp 4-component vector of float)
|
||||
0:16 Convert int to float (temp 4-component vector of float)
|
||||
0:16 ival4: direct index for structure (layout(offset=48 ) uniform 4-component vector of int)
|
||||
0:16 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:16 Constant:
|
||||
0:16 3 (const uint)
|
||||
0:16 fval4: direct index for structure (layout(offset=80 ) uniform 4-component vector of float)
|
||||
0:16 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:16 Constant:
|
||||
0:16 5 (const uint)
|
||||
0:18 mod (temp float)
|
||||
0:18 Convert bool to float (temp float)
|
||||
0:18 bval: direct index for structure (layout(offset=0 ) uniform bool)
|
||||
0:18 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:18 Constant:
|
||||
0:18 0 (const uint)
|
||||
0:18 fval: direct index for structure (layout(offset=64 ) uniform float)
|
||||
0:18 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:18 Constant:
|
||||
0:18 4 (const uint)
|
||||
0:19 mod (temp 4-component vector of float)
|
||||
0:19 Convert bool to float (temp 4-component vector of float)
|
||||
0:19 bval4: direct index for structure (layout(offset=16 ) uniform 4-component vector of bool)
|
||||
0:19 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:19 Constant:
|
||||
0:19 1 (const uint)
|
||||
0:19 fval4: direct index for structure (layout(offset=80 ) uniform 4-component vector of float)
|
||||
0:19 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:19 Constant:
|
||||
0:19 5 (const uint)
|
||||
0:21 Sequence
|
||||
0:21 move second child to first child (temp int)
|
||||
0:21 'l_int' (temp int)
|
||||
0:21 Constant:
|
||||
0:21 1 (const int)
|
||||
0:22 mod second child into first child (temp int)
|
||||
0:22 'l_int' (temp int)
|
||||
0:22 Convert float to int (temp int)
|
||||
0:22 fval: direct index for structure (layout(offset=64 ) uniform float)
|
||||
0:22 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
0:22 Constant:
|
||||
0:22 4 (const uint)
|
||||
0:25 move second child to first child (temp 4-component vector of float)
|
||||
0:25 Color: direct index for structure (temp 4-component vector of float)
|
||||
0:25 'psout' (temp structure{temp 4-component vector of float Color})
|
||||
0:25 Constant:
|
||||
0:25 0 (const int)
|
||||
0:25 Constant:
|
||||
0:25 0.000000
|
||||
0:25 0.000000
|
||||
0:25 0.000000
|
||||
0:25 0.000000
|
||||
0:26 Sequence
|
||||
0:26 Sequence
|
||||
0:26 move second child to first child (temp 4-component vector of float)
|
||||
0:? 'Color' (layout(location=0 ) out 4-component vector of float)
|
||||
0:26 Color: direct index for structure (temp 4-component vector of float)
|
||||
0:26 'psout' (temp structure{temp 4-component vector of float Color})
|
||||
0:26 Constant:
|
||||
0:26 0 (const int)
|
||||
0:26 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 bool bval, layout(offset=16 ) uniform 4-component vector of bool bval4, layout(offset=32 ) uniform int ival, layout(offset=48 ) uniform 4-component vector of int ival4, layout(offset=64 ) uniform float fval, layout(offset=80 ) uniform 4-component vector of float fval4})
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 78
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 74
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Name 4 "main"
|
||||
Name 12 "$Global"
|
||||
MemberName 12($Global) 0 "bval"
|
||||
MemberName 12($Global) 1 "bval4"
|
||||
MemberName 12($Global) 2 "ival"
|
||||
MemberName 12($Global) 3 "ival4"
|
||||
MemberName 12($Global) 4 "fval"
|
||||
MemberName 12($Global) 5 "fval4"
|
||||
Name 14 ""
|
||||
Name 62 "l_int"
|
||||
Name 68 "PS_OUTPUT"
|
||||
MemberName 68(PS_OUTPUT) 0 "Color"
|
||||
Name 70 "psout"
|
||||
Name 74 "Color"
|
||||
MemberDecorate 12($Global) 0 Offset 0
|
||||
MemberDecorate 12($Global) 1 Offset 16
|
||||
MemberDecorate 12($Global) 2 Offset 32
|
||||
MemberDecorate 12($Global) 3 Offset 48
|
||||
MemberDecorate 12($Global) 4 Offset 64
|
||||
MemberDecorate 12($Global) 5 Offset 80
|
||||
Decorate 12($Global) Block
|
||||
Decorate 14 DescriptorSet 0
|
||||
Decorate 74(Color) Location 0
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeInt 32 0
|
||||
7: TypeVector 6(int) 4
|
||||
8: TypeInt 32 1
|
||||
9: TypeVector 8(int) 4
|
||||
10: TypeFloat 32
|
||||
11: TypeVector 10(float) 4
|
||||
12($Global): TypeStruct 6(int) 7(ivec4) 8(int) 9(ivec4) 10(float) 11(fvec4)
|
||||
13: TypePointer Uniform 12($Global)
|
||||
14: 13(ptr) Variable Uniform
|
||||
15: 8(int) Constant 2
|
||||
16: TypePointer Uniform 8(int)
|
||||
20: 8(int) Constant 4
|
||||
21: TypePointer Uniform 10(float)
|
||||
25: 8(int) Constant 3
|
||||
26: TypePointer Uniform 9(ivec4)
|
||||
30: 8(int) Constant 5
|
||||
31: TypePointer Uniform 11(fvec4)
|
||||
35: 8(int) Constant 0
|
||||
36: TypePointer Uniform 6(int)
|
||||
39: TypeBool
|
||||
40: 6(int) Constant 0
|
||||
42: 10(float) Constant 0
|
||||
43: 10(float) Constant 1065353216
|
||||
48: 8(int) Constant 1
|
||||
49: TypePointer Uniform 7(ivec4)
|
||||
52: TypeVector 39(bool) 4
|
||||
53: 7(ivec4) ConstantComposite 40 40 40 40
|
||||
55: 11(fvec4) ConstantComposite 42 42 42 42
|
||||
56: 11(fvec4) ConstantComposite 43 43 43 43
|
||||
61: TypePointer Function 8(int)
|
||||
68(PS_OUTPUT): TypeStruct 11(fvec4)
|
||||
69: TypePointer Function 68(PS_OUTPUT)
|
||||
71: TypePointer Function 11(fvec4)
|
||||
73: TypePointer Output 11(fvec4)
|
||||
74(Color): 73(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
62(l_int): 61(ptr) Variable Function
|
||||
70(psout): 69(ptr) Variable Function
|
||||
17: 16(ptr) AccessChain 14 15
|
||||
18: 8(int) Load 17
|
||||
19: 10(float) ConvertSToF 18
|
||||
22: 21(ptr) AccessChain 14 20
|
||||
23: 10(float) Load 22
|
||||
24: 10(float) FMod 19 23
|
||||
27: 26(ptr) AccessChain 14 25
|
||||
28: 9(ivec4) Load 27
|
||||
29: 11(fvec4) ConvertSToF 28
|
||||
32: 31(ptr) AccessChain 14 30
|
||||
33: 11(fvec4) Load 32
|
||||
34: 11(fvec4) FMod 29 33
|
||||
37: 36(ptr) AccessChain 14 35
|
||||
38: 6(int) Load 37
|
||||
41: 39(bool) INotEqual 38 40
|
||||
44: 10(float) Select 41 43 42
|
||||
45: 21(ptr) AccessChain 14 20
|
||||
46: 10(float) Load 45
|
||||
47: 10(float) FMod 44 46
|
||||
50: 49(ptr) AccessChain 14 48
|
||||
51: 7(ivec4) Load 50
|
||||
54: 52(bvec4) INotEqual 51 53
|
||||
57: 11(fvec4) Select 54 56 55
|
||||
58: 31(ptr) AccessChain 14 30
|
||||
59: 11(fvec4) Load 58
|
||||
60: 11(fvec4) FMod 57 59
|
||||
Store 62(l_int) 48
|
||||
63: 21(ptr) AccessChain 14 20
|
||||
64: 10(float) Load 63
|
||||
65: 8(int) ConvertFToS 64
|
||||
66: 8(int) Load 62(l_int)
|
||||
67: 8(int) SMod 66 65
|
||||
Store 62(l_int) 67
|
||||
72: 71(ptr) AccessChain 70(psout) 35
|
||||
Store 72 55
|
||||
75: 71(ptr) AccessChain 70(psout) 35
|
||||
76: 11(fvec4) Load 75
|
||||
Store 74(Color) 76
|
||||
Return
|
||||
FunctionEnd
|
||||
Reference in New Issue
Block a user