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:
292
Test/baseResults/hlsl.logical.unary.frag.out
Normal file
292
Test/baseResults/hlsl.logical.unary.frag.out
Normal file
@@ -0,0 +1,292 @@
|
||||
hlsl.logical.unary.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 Negate conditional (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:14 Negate conditional (temp 4-component vector of bool)
|
||||
0:14 Convert int to bool (temp 4-component vector of bool)
|
||||
0:14 ival4: direct index for structure (layout(offset=16 ) uniform 4-component vector of 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 1 (const uint)
|
||||
0:16 Negate conditional (temp bool)
|
||||
0:16 Convert float to bool (temp bool)
|
||||
0:16 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:16 '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:16 Constant:
|
||||
0:16 2 (const uint)
|
||||
0:17 Negate conditional (temp 4-component vector of bool)
|
||||
0:17 Convert float to bool (temp 4-component vector of bool)
|
||||
0:17 fval4: direct index for structure (layout(offset=48 ) uniform 4-component vector of float)
|
||||
0:17 '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:17 Constant:
|
||||
0:17 3 (const uint)
|
||||
0:19 Test condition and select (temp void)
|
||||
0:19 Condition
|
||||
0:19 ival: direct index for structure (layout(offset=0 ) uniform int)
|
||||
0:19 '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:19 Constant:
|
||||
0:19 0 (const uint)
|
||||
0:19 true case is null
|
||||
0:20 Test condition and select (temp void)
|
||||
0:20 Condition
|
||||
0:20 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:20 '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:20 Constant:
|
||||
0:20 2 (const uint)
|
||||
0:20 true case is null
|
||||
0:21 Test condition and select (temp void)
|
||||
0:21 Condition
|
||||
0:21 Negate conditional (temp bool)
|
||||
0:21 Convert int to bool (temp bool)
|
||||
0:21 ival: direct index for structure (layout(offset=0 ) uniform int)
|
||||
0:21 '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:21 Constant:
|
||||
0:21 0 (const uint)
|
||||
0:21 true case is null
|
||||
0:22 Test condition and select (temp void)
|
||||
0:22 Condition
|
||||
0:22 Negate conditional (temp bool)
|
||||
0:22 Convert float to bool (temp bool)
|
||||
0:22 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:22 '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:22 Constant:
|
||||
0:22 2 (const uint)
|
||||
0:22 true case is null
|
||||
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 1.000000
|
||||
0:25 1.000000
|
||||
0:25 1.000000
|
||||
0:25 1.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 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 Negate conditional (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:14 Negate conditional (temp 4-component vector of bool)
|
||||
0:14 Convert int to bool (temp 4-component vector of bool)
|
||||
0:14 ival4: direct index for structure (layout(offset=16 ) uniform 4-component vector of 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 1 (const uint)
|
||||
0:16 Negate conditional (temp bool)
|
||||
0:16 Convert float to bool (temp bool)
|
||||
0:16 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:16 '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:16 Constant:
|
||||
0:16 2 (const uint)
|
||||
0:17 Negate conditional (temp 4-component vector of bool)
|
||||
0:17 Convert float to bool (temp 4-component vector of bool)
|
||||
0:17 fval4: direct index for structure (layout(offset=48 ) uniform 4-component vector of float)
|
||||
0:17 '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:17 Constant:
|
||||
0:17 3 (const uint)
|
||||
0:19 Test condition and select (temp void)
|
||||
0:19 Condition
|
||||
0:19 ival: direct index for structure (layout(offset=0 ) uniform int)
|
||||
0:19 '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:19 Constant:
|
||||
0:19 0 (const uint)
|
||||
0:19 true case is null
|
||||
0:20 Test condition and select (temp void)
|
||||
0:20 Condition
|
||||
0:20 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:20 '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:20 Constant:
|
||||
0:20 2 (const uint)
|
||||
0:20 true case is null
|
||||
0:21 Test condition and select (temp void)
|
||||
0:21 Condition
|
||||
0:21 Negate conditional (temp bool)
|
||||
0:21 Convert int to bool (temp bool)
|
||||
0:21 ival: direct index for structure (layout(offset=0 ) uniform int)
|
||||
0:21 '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:21 Constant:
|
||||
0:21 0 (const uint)
|
||||
0:21 true case is null
|
||||
0:22 Test condition and select (temp void)
|
||||
0:22 Condition
|
||||
0:22 Negate conditional (temp bool)
|
||||
0:22 Convert float to bool (temp bool)
|
||||
0:22 fval: direct index for structure (layout(offset=32 ) uniform float)
|
||||
0:22 '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:22 Constant:
|
||||
0:22 2 (const uint)
|
||||
0:22 true case is null
|
||||
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 1.000000
|
||||
0:25 1.000000
|
||||
0:25 1.000000
|
||||
0:25 1.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 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 77
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 73
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Name 4 "main"
|
||||
Name 10 "$Global"
|
||||
MemberName 10($Global) 0 "ival"
|
||||
MemberName 10($Global) 1 "ival4"
|
||||
MemberName 10($Global) 2 "fval"
|
||||
MemberName 10($Global) 3 "fval4"
|
||||
Name 12 ""
|
||||
Name 65 "PS_OUTPUT"
|
||||
MemberName 65(PS_OUTPUT) 0 "Color"
|
||||
Name 67 "psout"
|
||||
Name 73 "Color"
|
||||
MemberDecorate 10($Global) 0 Offset 0
|
||||
MemberDecorate 10($Global) 1 Offset 16
|
||||
MemberDecorate 10($Global) 2 Offset 32
|
||||
MemberDecorate 10($Global) 3 Offset 48
|
||||
Decorate 10($Global) Block
|
||||
Decorate 12 DescriptorSet 0
|
||||
Decorate 73(Color) Location 0
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeInt 32 1
|
||||
7: TypeVector 6(int) 4
|
||||
8: TypeFloat 32
|
||||
9: TypeVector 8(float) 4
|
||||
10($Global): TypeStruct 6(int) 7(ivec4) 8(float) 9(fvec4)
|
||||
11: TypePointer Uniform 10($Global)
|
||||
12: 11(ptr) Variable Uniform
|
||||
13: 6(int) Constant 0
|
||||
14: TypePointer Uniform 6(int)
|
||||
17: TypeBool
|
||||
18: TypeInt 32 0
|
||||
19: 18(int) Constant 0
|
||||
22: 6(int) Constant 1
|
||||
23: TypePointer Uniform 7(ivec4)
|
||||
26: TypeVector 17(bool) 4
|
||||
27: TypeVector 18(int) 4
|
||||
28: 27(ivec4) ConstantComposite 19 19 19 19
|
||||
31: 6(int) Constant 2
|
||||
32: TypePointer Uniform 8(float)
|
||||
35: 8(float) Constant 0
|
||||
38: 6(int) Constant 3
|
||||
39: TypePointer Uniform 9(fvec4)
|
||||
42: 9(fvec4) ConstantComposite 35 35 35 35
|
||||
65(PS_OUTPUT): TypeStruct 9(fvec4)
|
||||
66: TypePointer Function 65(PS_OUTPUT)
|
||||
68: 8(float) Constant 1065353216
|
||||
69: 9(fvec4) ConstantComposite 68 68 68 68
|
||||
70: TypePointer Function 9(fvec4)
|
||||
72: TypePointer Output 9(fvec4)
|
||||
73(Color): 72(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
67(psout): 66(ptr) Variable Function
|
||||
15: 14(ptr) AccessChain 12 13
|
||||
16: 6(int) Load 15
|
||||
20: 17(bool) INotEqual 16 19
|
||||
21: 17(bool) LogicalNot 20
|
||||
24: 23(ptr) AccessChain 12 22
|
||||
25: 7(ivec4) Load 24
|
||||
29: 26(bvec4) INotEqual 25 28
|
||||
30: 26(bvec4) LogicalNot 29
|
||||
33: 32(ptr) AccessChain 12 31
|
||||
34: 8(float) Load 33
|
||||
36: 17(bool) FOrdNotEqual 34 35
|
||||
37: 17(bool) LogicalNot 36
|
||||
40: 39(ptr) AccessChain 12 38
|
||||
41: 9(fvec4) Load 40
|
||||
43: 26(bvec4) FOrdNotEqual 41 42
|
||||
44: 26(bvec4) LogicalNot 43
|
||||
45: 14(ptr) AccessChain 12 13
|
||||
46: 6(int) Load 45
|
||||
SelectionMerge 48 None
|
||||
BranchConditional 46 47 48
|
||||
47: Label
|
||||
Branch 48
|
||||
48: Label
|
||||
49: 32(ptr) AccessChain 12 31
|
||||
50: 8(float) Load 49
|
||||
SelectionMerge 52 None
|
||||
BranchConditional 50 51 52
|
||||
51: Label
|
||||
Branch 52
|
||||
52: Label
|
||||
53: 14(ptr) AccessChain 12 13
|
||||
54: 6(int) Load 53
|
||||
55: 17(bool) INotEqual 54 19
|
||||
56: 17(bool) LogicalNot 55
|
||||
SelectionMerge 58 None
|
||||
BranchConditional 56 57 58
|
||||
57: Label
|
||||
Branch 58
|
||||
58: Label
|
||||
59: 32(ptr) AccessChain 12 31
|
||||
60: 8(float) Load 59
|
||||
61: 17(bool) FOrdNotEqual 60 35
|
||||
62: 17(bool) LogicalNot 61
|
||||
SelectionMerge 64 None
|
||||
BranchConditional 62 63 64
|
||||
63: Label
|
||||
Branch 64
|
||||
64: Label
|
||||
71: 70(ptr) AccessChain 67(psout) 13
|
||||
Store 71 69
|
||||
74: 70(ptr) AccessChain 67(psout) 13
|
||||
75: 9(fvec4) Load 74
|
||||
Store 73(Color) 75
|
||||
Return
|
||||
FunctionEnd
|
||||
Reference in New Issue
Block a user