Commit 85244d74 by steve-lunarg

HLSL: Enable component-wise vector comparisons from operators

This PR only changes a few lines of code, but is subtle. In HLSL, comparison operators (<,>,<=,>=,==,!=) operate component-wise when given a vector operand. If a whole vector equality or inequality is desired, then all() or any() can be used on the resulting bool vector. This PR enables this change. Existing shape conversion is used when one of the two arguments is a vector and one is a scalar. Some existing HLSL tests had assumed == and != meant vector-wise instead of component-wise comparisons. These tests have been changed to add an explicit any() or all() to the test source. This verifably does not change the final SPIR-V binary relative to the old behavior for == and !=. The AST does change for the (now explicit, formerly implicit) any() and all(). Also, a few tests changes where they previously had the return type wrong, e.g, from a vec < vec comparison in hlsl.shapeConv.frag. Promotion of comparison opcodes to vector forms (EOpEqual->EOpVectorEqual) is handled in promoteBinary(), as is setting the proper vector type of the result. EOpVectorEqual and EOpVectorNotEqual are now accepted as either aggregate or binary nodes, similar to how the other operators are handled. Partial support already existed for this: it has been fleshed out in the printing functions in intermOut.cpp. There is an existing defect around shape conversion with 1-vectors, but that is orthogonal to this PR and not addressed by it.
parent 0d628c17
...@@ -18,7 +18,8 @@ gl_FragCoord origin is upper left ...@@ -18,7 +18,8 @@ gl_FragCoord origin is upper left
0:4 No loop body 0:4 No loop body
0:5 Loop with condition not tested first 0:5 Loop with condition not tested first
0:5 Loop Condition 0:5 Loop Condition
0:5 Compare Equal (temp bool) 0:5 all (global bool)
0:5 Equal (temp 4-component vector of bool)
0:5 'input' (layout(location=0 ) in 4-component vector of float) 0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 'input' (layout(location=0 ) in 4-component vector of float) 0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 Loop Body 0:5 Loop Body
...@@ -54,7 +55,8 @@ gl_FragCoord origin is upper left ...@@ -54,7 +55,8 @@ gl_FragCoord origin is upper left
0:4 No loop body 0:4 No loop body
0:5 Loop with condition not tested first 0:5 Loop with condition not tested first
0:5 Loop Condition 0:5 Loop Condition
0:5 Compare Equal (temp bool) 0:5 all (global bool)
0:5 Equal (temp 4-component vector of bool)
0:5 'input' (layout(location=0 ) in 4-component vector of float) 0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 'input' (layout(location=0 ) in 4-component vector of float) 0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 Loop Body 0:5 Loop Body
......
...@@ -19,14 +19,16 @@ gl_FragCoord origin is upper left ...@@ -19,14 +19,16 @@ gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:5 Loop with condition tested first 0:5 Loop with condition tested first
0:5 Loop Condition 0:5 Loop Condition
0:5 Compare Not Equal (temp bool) 0:5 any (global bool)
0:5 NotEqual (temp 4-component vector of bool)
0:5 'input' (layout(location=0 ) in 4-component vector of float) 0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 'input' (layout(location=0 ) in 4-component vector of float) 0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 No loop body 0:5 No loop body
0:? Sequence 0:? Sequence
0:6 Loop with condition tested first 0:6 Loop with condition tested first
0:6 Loop Condition 0:6 Loop Condition
0:6 Compare Not Equal (temp bool) 0:6 any (global bool)
0:6 NotEqual (temp 4-component vector of bool)
0:6 'input' (layout(location=0 ) in 4-component vector of float) 0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 'input' (layout(location=0 ) in 4-component vector of float) 0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 Loop Body 0:6 Loop Body
...@@ -42,7 +44,8 @@ gl_FragCoord origin is upper left ...@@ -42,7 +44,8 @@ gl_FragCoord origin is upper left
0:7 'input' (layout(location=0 ) in 4-component vector of float) 0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 Loop with condition tested first 0:7 Loop with condition tested first
0:7 Loop Condition 0:7 Loop Condition
0:7 Compare Not Equal (temp bool) 0:7 any (global bool)
0:7 NotEqual (temp 4-component vector of bool)
0:7 'input' (layout(location=0 ) in 4-component vector of float) 0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float) 0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 Loop Body 0:7 Loop Body
...@@ -141,14 +144,16 @@ gl_FragCoord origin is upper left ...@@ -141,14 +144,16 @@ gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:5 Loop with condition tested first 0:5 Loop with condition tested first
0:5 Loop Condition 0:5 Loop Condition
0:5 Compare Not Equal (temp bool) 0:5 any (global bool)
0:5 NotEqual (temp 4-component vector of bool)
0:5 'input' (layout(location=0 ) in 4-component vector of float) 0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 'input' (layout(location=0 ) in 4-component vector of float) 0:5 'input' (layout(location=0 ) in 4-component vector of float)
0:5 No loop body 0:5 No loop body
0:? Sequence 0:? Sequence
0:6 Loop with condition tested first 0:6 Loop with condition tested first
0:6 Loop Condition 0:6 Loop Condition
0:6 Compare Not Equal (temp bool) 0:6 any (global bool)
0:6 NotEqual (temp 4-component vector of bool)
0:6 'input' (layout(location=0 ) in 4-component vector of float) 0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 'input' (layout(location=0 ) in 4-component vector of float) 0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 Loop Body 0:6 Loop Body
...@@ -164,7 +169,8 @@ gl_FragCoord origin is upper left ...@@ -164,7 +169,8 @@ gl_FragCoord origin is upper left
0:7 'input' (layout(location=0 ) in 4-component vector of float) 0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 Loop with condition tested first 0:7 Loop with condition tested first
0:7 Loop Condition 0:7 Loop Condition
0:7 Compare Not Equal (temp bool) 0:7 any (global bool)
0:7 NotEqual (temp 4-component vector of bool)
0:7 'input' (layout(location=0 ) in 4-component vector of float) 0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 'input' (layout(location=0 ) in 4-component vector of float) 0:7 'input' (layout(location=0 ) in 4-component vector of float)
0:7 Loop Body 0:7 Loop Body
......
...@@ -8,7 +8,8 @@ gl_FragCoord origin is upper left ...@@ -8,7 +8,8 @@ gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:3 Test condition and select (temp void) 0:3 Test condition and select (temp void)
0:3 Condition 0:3 Condition
0:3 Compare Equal (temp bool) 0:3 all (global bool)
0:3 Equal (temp 4-component vector of bool)
0:3 'input' (layout(location=0 ) in 4-component vector of float) 0:3 'input' (layout(location=0 ) in 4-component vector of float)
0:3 'input' (layout(location=0 ) in 4-component vector of float) 0:3 'input' (layout(location=0 ) in 4-component vector of float)
0:3 true case 0:3 true case
...@@ -19,7 +20,8 @@ gl_FragCoord origin is upper left ...@@ -19,7 +20,8 @@ gl_FragCoord origin is upper left
0:4 Branch: Return 0:4 Branch: Return
0:6 Test condition and select (temp void) 0:6 Test condition and select (temp void)
0:6 Condition 0:6 Condition
0:6 Compare Equal (temp bool) 0:6 all (global bool)
0:6 Equal (temp 4-component vector of bool)
0:6 'input' (layout(location=0 ) in 4-component vector of float) 0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 'input' (layout(location=0 ) in 4-component vector of float) 0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 true case 0:6 true case
...@@ -37,19 +39,22 @@ gl_FragCoord origin is upper left ...@@ -37,19 +39,22 @@ gl_FragCoord origin is upper left
0:9 Branch: Return 0:9 Branch: Return
0:11 Test condition and select (temp void) 0:11 Test condition and select (temp void)
0:11 Condition 0:11 Condition
0:11 Compare Equal (temp bool) 0:11 all (global bool)
0:11 Equal (temp 4-component vector of bool)
0:11 'input' (layout(location=0 ) in 4-component vector of float) 0:11 'input' (layout(location=0 ) in 4-component vector of float)
0:11 'input' (layout(location=0 ) in 4-component vector of float) 0:11 'input' (layout(location=0 ) in 4-component vector of float)
0:11 true case is null 0:11 true case is null
0:14 Test condition and select (temp void) 0:14 Test condition and select (temp void)
0:14 Condition 0:14 Condition
0:14 Compare Equal (temp bool) 0:14 all (global bool)
0:14 Equal (temp 4-component vector of bool)
0:14 'input' (layout(location=0 ) in 4-component vector of float) 0:14 'input' (layout(location=0 ) in 4-component vector of float)
0:14 'input' (layout(location=0 ) in 4-component vector of float) 0:14 'input' (layout(location=0 ) in 4-component vector of float)
0:14 true case is null 0:14 true case is null
0:19 Test condition and select (temp void) 0:19 Test condition and select (temp void)
0:19 Condition 0:19 Condition
0:19 Compare Equal (temp bool) 0:19 all (global bool)
0:19 Equal (temp 4-component vector of bool)
0:19 'input' (layout(location=0 ) in 4-component vector of float) 0:19 'input' (layout(location=0 ) in 4-component vector of float)
0:19 'input' (layout(location=0 ) in 4-component vector of float) 0:19 'input' (layout(location=0 ) in 4-component vector of float)
0:19 true case 0:19 true case
...@@ -61,7 +66,8 @@ gl_FragCoord origin is upper left ...@@ -61,7 +66,8 @@ gl_FragCoord origin is upper left
0:20 Branch: Return 0:20 Branch: Return
0:23 Test condition and select (temp void) 0:23 Test condition and select (temp void)
0:23 Condition 0:23 Condition
0:23 Compare Equal (temp bool) 0:23 all (global bool)
0:23 Equal (temp 4-component vector of bool)
0:23 'input' (layout(location=0 ) in 4-component vector of float) 0:23 'input' (layout(location=0 ) in 4-component vector of float)
0:23 'input' (layout(location=0 ) in 4-component vector of float) 0:23 'input' (layout(location=0 ) in 4-component vector of float)
0:23 true case 0:23 true case
...@@ -109,7 +115,8 @@ gl_FragCoord origin is upper left ...@@ -109,7 +115,8 @@ gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:3 Test condition and select (temp void) 0:3 Test condition and select (temp void)
0:3 Condition 0:3 Condition
0:3 Compare Equal (temp bool) 0:3 all (global bool)
0:3 Equal (temp 4-component vector of bool)
0:3 'input' (layout(location=0 ) in 4-component vector of float) 0:3 'input' (layout(location=0 ) in 4-component vector of float)
0:3 'input' (layout(location=0 ) in 4-component vector of float) 0:3 'input' (layout(location=0 ) in 4-component vector of float)
0:3 true case 0:3 true case
...@@ -120,7 +127,8 @@ gl_FragCoord origin is upper left ...@@ -120,7 +127,8 @@ gl_FragCoord origin is upper left
0:4 Branch: Return 0:4 Branch: Return
0:6 Test condition and select (temp void) 0:6 Test condition and select (temp void)
0:6 Condition 0:6 Condition
0:6 Compare Equal (temp bool) 0:6 all (global bool)
0:6 Equal (temp 4-component vector of bool)
0:6 'input' (layout(location=0 ) in 4-component vector of float) 0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 'input' (layout(location=0 ) in 4-component vector of float) 0:6 'input' (layout(location=0 ) in 4-component vector of float)
0:6 true case 0:6 true case
...@@ -138,19 +146,22 @@ gl_FragCoord origin is upper left ...@@ -138,19 +146,22 @@ gl_FragCoord origin is upper left
0:9 Branch: Return 0:9 Branch: Return
0:11 Test condition and select (temp void) 0:11 Test condition and select (temp void)
0:11 Condition 0:11 Condition
0:11 Compare Equal (temp bool) 0:11 all (global bool)
0:11 Equal (temp 4-component vector of bool)
0:11 'input' (layout(location=0 ) in 4-component vector of float) 0:11 'input' (layout(location=0 ) in 4-component vector of float)
0:11 'input' (layout(location=0 ) in 4-component vector of float) 0:11 'input' (layout(location=0 ) in 4-component vector of float)
0:11 true case is null 0:11 true case is null
0:14 Test condition and select (temp void) 0:14 Test condition and select (temp void)
0:14 Condition 0:14 Condition
0:14 Compare Equal (temp bool) 0:14 all (global bool)
0:14 Equal (temp 4-component vector of bool)
0:14 'input' (layout(location=0 ) in 4-component vector of float) 0:14 'input' (layout(location=0 ) in 4-component vector of float)
0:14 'input' (layout(location=0 ) in 4-component vector of float) 0:14 'input' (layout(location=0 ) in 4-component vector of float)
0:14 true case is null 0:14 true case is null
0:19 Test condition and select (temp void) 0:19 Test condition and select (temp void)
0:19 Condition 0:19 Condition
0:19 Compare Equal (temp bool) 0:19 all (global bool)
0:19 Equal (temp 4-component vector of bool)
0:19 'input' (layout(location=0 ) in 4-component vector of float) 0:19 'input' (layout(location=0 ) in 4-component vector of float)
0:19 'input' (layout(location=0 ) in 4-component vector of float) 0:19 'input' (layout(location=0 ) in 4-component vector of float)
0:19 true case 0:19 true case
...@@ -162,7 +173,8 @@ gl_FragCoord origin is upper left ...@@ -162,7 +173,8 @@ gl_FragCoord origin is upper left
0:20 Branch: Return 0:20 Branch: Return
0:23 Test condition and select (temp void) 0:23 Test condition and select (temp void)
0:23 Condition 0:23 Condition
0:23 Compare Equal (temp bool) 0:23 all (global bool)
0:23 Equal (temp 4-component vector of bool)
0:23 'input' (layout(location=0 ) in 4-component vector of float) 0:23 'input' (layout(location=0 ) in 4-component vector of float)
0:23 'input' (layout(location=0 ) in 4-component vector of float) 0:23 'input' (layout(location=0 ) in 4-component vector of float)
0:23 true case 0:23 true case
......
...@@ -58,38 +58,40 @@ gl_FragCoord origin is upper left ...@@ -58,38 +58,40 @@ gl_FragCoord origin is upper left
0:13 'MyVal' (temp 3-component vector of float) 0:13 'MyVal' (temp 3-component vector of float)
0:13 Construct vec3 (temp 3-component vector of float) 0:13 Construct vec3 (temp 3-component vector of float)
0:13 'V' (temp float) 0:13 'V' (temp float)
0:16 Compare Greater Than (temp bool) 0:16 Compare Greater Than (temp 3-component vector of bool)
0:16 'foo' (temp 3-component vector of float) 0:16 'foo' (temp 3-component vector of float)
0:16 Constant: 0:16 Constant:
0:16 4.000000 0:16 4.000000
0:16 4.000000 0:16 4.000000
0:16 4.000000 0:16 4.000000
0:17 Compare Greater Than or Equal (temp bool) 0:17 Compare Greater Than or Equal (temp 3-component vector of bool)
0:17 'foo' (temp 3-component vector of float) 0:17 'foo' (temp 3-component vector of float)
0:17 Constant: 0:17 Constant:
0:17 5.000000 0:17 5.000000
0:17 5.000000 0:17 5.000000
0:17 5.000000 0:17 5.000000
0:18 Compare Less Than (temp bool) 0:18 Compare Less Than (temp 3-component vector of bool)
0:18 Constant: 0:18 Constant:
0:18 6.000000 0:18 6.000000
0:18 6.000000 0:18 6.000000
0:18 6.000000 0:18 6.000000
0:18 'foo' (temp 3-component vector of float) 0:18 'foo' (temp 3-component vector of float)
0:19 Compare Less Than or Equal (temp bool) 0:19 Compare Less Than or Equal (temp 3-component vector of bool)
0:19 Constant: 0:19 Constant:
0:19 7.000000 0:19 7.000000
0:19 7.000000 0:19 7.000000
0:19 7.000000 0:19 7.000000
0:19 'foo' (temp 3-component vector of float) 0:19 'foo' (temp 3-component vector of float)
0:21 Compare Equal (temp bool) 0:21 all (global bool)
0:21 Equal (temp 4-component vector of bool)
0:21 Construct vec4 (temp 4-component vector of float) 0:21 Construct vec4 (temp 4-component vector of float)
0:21 direct index (temp float) 0:21 direct index (temp float)
0:21 'v' (temp 4-component vector of float) 0:21 'v' (temp 4-component vector of float)
0:21 Constant: 0:21 Constant:
0:21 0 (const int) 0:21 0 (const int)
0:21 'v' (temp 4-component vector of float) 0:21 'v' (temp 4-component vector of float)
0:22 Compare Not Equal (temp bool) 0:22 any (global bool)
0:22 NotEqual (temp 4-component vector of bool)
0:22 Construct vec4 (temp 4-component vector of float) 0:22 Construct vec4 (temp 4-component vector of float)
0:22 'f' (in float) 0:22 'f' (in float)
0:22 'v' (temp 4-component vector of float) 0:22 'v' (temp 4-component vector of float)
...@@ -173,38 +175,40 @@ gl_FragCoord origin is upper left ...@@ -173,38 +175,40 @@ gl_FragCoord origin is upper left
0:13 'MyVal' (temp 3-component vector of float) 0:13 'MyVal' (temp 3-component vector of float)
0:13 Construct vec3 (temp 3-component vector of float) 0:13 Construct vec3 (temp 3-component vector of float)
0:13 'V' (temp float) 0:13 'V' (temp float)
0:16 Compare Greater Than (temp bool) 0:16 Compare Greater Than (temp 3-component vector of bool)
0:16 'foo' (temp 3-component vector of float) 0:16 'foo' (temp 3-component vector of float)
0:16 Constant: 0:16 Constant:
0:16 4.000000 0:16 4.000000
0:16 4.000000 0:16 4.000000
0:16 4.000000 0:16 4.000000
0:17 Compare Greater Than or Equal (temp bool) 0:17 Compare Greater Than or Equal (temp 3-component vector of bool)
0:17 'foo' (temp 3-component vector of float) 0:17 'foo' (temp 3-component vector of float)
0:17 Constant: 0:17 Constant:
0:17 5.000000 0:17 5.000000
0:17 5.000000 0:17 5.000000
0:17 5.000000 0:17 5.000000
0:18 Compare Less Than (temp bool) 0:18 Compare Less Than (temp 3-component vector of bool)
0:18 Constant: 0:18 Constant:
0:18 6.000000 0:18 6.000000
0:18 6.000000 0:18 6.000000
0:18 6.000000 0:18 6.000000
0:18 'foo' (temp 3-component vector of float) 0:18 'foo' (temp 3-component vector of float)
0:19 Compare Less Than or Equal (temp bool) 0:19 Compare Less Than or Equal (temp 3-component vector of bool)
0:19 Constant: 0:19 Constant:
0:19 7.000000 0:19 7.000000
0:19 7.000000 0:19 7.000000
0:19 7.000000 0:19 7.000000
0:19 'foo' (temp 3-component vector of float) 0:19 'foo' (temp 3-component vector of float)
0:21 Compare Equal (temp bool) 0:21 all (global bool)
0:21 Equal (temp 4-component vector of bool)
0:21 Construct vec4 (temp 4-component vector of float) 0:21 Construct vec4 (temp 4-component vector of float)
0:21 direct index (temp float) 0:21 direct index (temp float)
0:21 'v' (temp 4-component vector of float) 0:21 'v' (temp 4-component vector of float)
0:21 Constant: 0:21 Constant:
0:21 0 (const int) 0:21 0 (const int)
0:21 'v' (temp 4-component vector of float) 0:21 'v' (temp 4-component vector of float)
0:22 Compare Not Equal (temp bool) 0:22 any (global bool)
0:22 NotEqual (temp 4-component vector of bool)
0:22 Construct vec4 (temp 4-component vector of float) 0:22 Construct vec4 (temp 4-component vector of float)
0:22 'f' (in float) 0:22 'f' (in float)
0:22 'v' (temp 4-component vector of float) 0:22 'v' (temp 4-component vector of float)
...@@ -227,7 +231,7 @@ gl_FragCoord origin is upper left ...@@ -227,7 +231,7 @@ 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 84 // Id's are bound by 85
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
...@@ -244,7 +248,7 @@ gl_FragCoord origin is upper left ...@@ -244,7 +248,7 @@ gl_FragCoord origin is upper left
Name 33 "V" Name 33 "V"
Name 34 "MyVal" Name 34 "MyVal"
Name 37 "foo" Name 37 "foo"
Name 69 "f1" Name 70 "f1"
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
...@@ -266,15 +270,16 @@ gl_FragCoord origin is upper left ...@@ -266,15 +270,16 @@ gl_FragCoord origin is upper left
39: 6(float) Constant 1082130432 39: 6(float) Constant 1082130432
40: 22(fvec3) ConstantComposite 39 39 39 40: 22(fvec3) ConstantComposite 39 39 39
41: TypeBool 41: TypeBool
44: 6(float) Constant 1084227584 42: TypeVector 41(bool) 3
45: 22(fvec3) ConstantComposite 44 44 44 45: 6(float) Constant 1084227584
47: 6(float) Constant 1086324736 46: 22(fvec3) ConstantComposite 45 45 45
48: 22(fvec3) ConstantComposite 47 47 47 48: 6(float) Constant 1086324736
51: 6(float) Constant 1088421888 49: 22(fvec3) ConstantComposite 48 48 48
52: 22(fvec3) ConstantComposite 51 51 51 52: 6(float) Constant 1088421888
55: TypeInt 32 0 53: 22(fvec3) ConstantComposite 52 52 52
56: 55(int) Constant 0 56: TypeInt 32 0
61: TypeVector 41(bool) 4 57: 56(int) Constant 0
62: TypeVector 41(bool) 4
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
FunctionEnd FunctionEnd
...@@ -288,7 +293,7 @@ gl_FragCoord origin is upper left ...@@ -288,7 +293,7 @@ gl_FragCoord origin is upper left
33(V): 9(ptr) Variable Function 33(V): 9(ptr) Variable Function
34(MyVal): 23(ptr) Variable Function 34(MyVal): 23(ptr) Variable Function
37(foo): 23(ptr) Variable Function 37(foo): 23(ptr) Variable Function
69(f1): 9(ptr) Variable Function 70(f1): 9(ptr) Variable Function
Store 15(v) 17 Store 15(v) 17
Store 15(v) 19 Store 15(v) 19
20: 6(float) Load 12(f) 20: 6(float) Load 12(f)
...@@ -305,35 +310,35 @@ gl_FragCoord origin is upper left ...@@ -305,35 +310,35 @@ gl_FragCoord origin is upper left
36: 22(fvec3) CompositeConstruct 35 35 35 36: 22(fvec3) CompositeConstruct 35 35 35
Store 34(MyVal) 36 Store 34(MyVal) 36
38: 22(fvec3) Load 37(foo) 38: 22(fvec3) Load 37(foo)
42: 41(bool) FOrdGreaterThan 38 40 43: 42(bvec3) FOrdGreaterThan 38 40
43: 22(fvec3) Load 37(foo) 44: 22(fvec3) Load 37(foo)
46: 41(bool) FOrdGreaterThanEqual 43 45 47: 42(bvec3) FOrdGreaterThanEqual 44 46
49: 22(fvec3) Load 37(foo) 50: 22(fvec3) Load 37(foo)
50: 41(bool) FOrdLessThan 48 49 51: 42(bvec3) FOrdLessThan 49 50
53: 22(fvec3) Load 37(foo) 54: 22(fvec3) Load 37(foo)
54: 41(bool) FOrdLessThanEqual 52 53 55: 42(bvec3) FOrdLessThanEqual 53 54
57: 9(ptr) AccessChain 15(v) 56 58: 9(ptr) AccessChain 15(v) 57
58: 6(float) Load 57 59: 6(float) Load 58
59: 7(fvec4) CompositeConstruct 58 58 58 58 60: 7(fvec4) CompositeConstruct 59 59 59 59
60: 7(fvec4) Load 15(v) 61: 7(fvec4) Load 15(v)
62: 61(bvec4) FOrdEqual 59 60 63: 62(bvec4) FOrdEqual 60 61
63: 41(bool) All 62 64: 41(bool) All 63
64: 6(float) Load 12(f) 65: 6(float) Load 12(f)
65: 7(fvec4) CompositeConstruct 64 64 64 64 66: 7(fvec4) CompositeConstruct 65 65 65 65
66: 7(fvec4) Load 15(v) 67: 7(fvec4) Load 15(v)
67: 61(bvec4) FOrdNotEqual 65 66 68: 62(bvec4) FOrdNotEqual 66 67
68: 41(bool) Any 67 69: 41(bool) Any 68
70: 6(float) Load 69(f1) 71: 6(float) Load 70(f1)
71: 7(fvec4) Load 15(v) 72: 7(fvec4) Load 15(v)
72: 6(float) CompositeExtract 71 0 73: 6(float) CompositeExtract 72 0
73: 41(bool) FOrdEqual 70 72 74: 41(bool) FOrdEqual 71 73
74: 7(fvec4) Load 15(v) 75: 7(fvec4) Load 15(v)
75: 6(float) CompositeExtract 74 0 76: 6(float) CompositeExtract 75 0
76: 6(float) Load 69(f1) 77: 6(float) Load 70(f1)
77: 41(bool) FOrdLessThan 75 76 78: 41(bool) FOrdLessThan 76 77
78: 6(float) Load 69(f1) 79: 6(float) Load 70(f1)
79: 6(float) Load 69(f1) 80: 6(float) Load 70(f1)
80: 22(fvec3) CompositeConstruct 79 79 79 81: 22(fvec3) CompositeConstruct 80 80 80
81: 7(fvec4) Load 11(input) 82: 7(fvec4) Load 11(input)
ReturnValue 81 ReturnValue 82
FunctionEnd FunctionEnd
...@@ -8,7 +8,8 @@ gl_FragCoord origin is upper left ...@@ -8,7 +8,8 @@ gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:3 Loop with condition tested first 0:3 Loop with condition tested first
0:3 Loop Condition 0:3 Loop Condition
0:3 Compare Not Equal (temp bool) 0:3 any (global bool)
0:3 NotEqual (temp 4-component vector of bool)
0:3 'input' (layout(location=0 ) in 4-component vector of float) 0:3 'input' (layout(location=0 ) in 4-component vector of float)
0:3 'input' (layout(location=0 ) in 4-component vector of float) 0:3 'input' (layout(location=0 ) in 4-component vector of float)
0:3 Loop Body 0:3 Loop Body
...@@ -50,7 +51,8 @@ gl_FragCoord origin is upper left ...@@ -50,7 +51,8 @@ gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:3 Loop with condition tested first 0:3 Loop with condition tested first
0:3 Loop Condition 0:3 Loop Condition
0:3 Compare Not Equal (temp bool) 0:3 any (global bool)
0:3 NotEqual (temp 4-component vector of bool)
0:3 'input' (layout(location=0 ) in 4-component vector of float) 0:3 'input' (layout(location=0 ) in 4-component vector of float)
0:3 'input' (layout(location=0 ) in 4-component vector of float) 0:3 'input' (layout(location=0 ) in 4-component vector of float)
0:3 Loop Body 0:3 Loop Body
......
uniform float4 uf4;
void Bug1( float4 a )
{
float4 v04 = float4( 0.0, 0.0, 0.0, 0.0 );
float v01 = 0.0;
bool4 r00 = a == v04;
bool4 r01 = a != v04;
bool4 r02 = a < v04;
bool4 r03 = a > v04;
bool4 r10 = a == v01;
bool4 r11 = a != v01;
bool4 r12 = a < v01;
bool4 r13 = a > v01;
bool4 r20 = v01 == a;
bool4 r21 = v01 != a;
bool4 r22 = v01 < a;
bool4 r23 = v01 > a;
}
struct PS_OUTPUT
{
float4 Color : SV_Target0;
};
PS_OUTPUT main()
{
PS_OUTPUT psout;
psout.Color = 0;
return psout;
}
...@@ -2,5 +2,5 @@ float4 PixelShaderFunction(float4 input) : COLOR0 ...@@ -2,5 +2,5 @@ float4 PixelShaderFunction(float4 input) : COLOR0
{ {
[unroll] do {} while (false); [unroll] do {} while (false);
[unroll] do {;} while (false); [unroll] do {;} while (false);
do { return input; } while (input == input); do { return input; } while (all(input == input));
} }
...@@ -2,9 +2,9 @@ float4 PixelShaderFunction(float4 input) : COLOR0 ...@@ -2,9 +2,9 @@ float4 PixelShaderFunction(float4 input) : COLOR0
{ {
for (;;) ; for (;;) ;
for (++input; ; ) ; for (++input; ; ) ;
[unroll] for (; input != input; ) {} [unroll] for (; any(input != input); ) {}
for (; input != input; ) { return -input; } for (; any(input != input); ) { return -input; }
for (--input; input != input; input += 2) { return -input; } for (--input; any(input != input); input += 2) { return -input; }
for (;;) if (input.x > 2.0) break; for (;;) if (input.x > 2.0) break;
for (;;) if (input.x > 2.0) continue; for (;;) if (input.x > 2.0) continue;
float ii; float ii;
......
float4 PixelShaderFunction(float4 input) : COLOR0 float4 PixelShaderFunction(float4 input) : COLOR0
{ {
if (input == input) if (all(input == input))
return input; return input;
if (input == input) if (all(input == input))
return input; return input;
else else
return -input; return -input;
if (input == input) if (all(input == input))
; ;
if (input == input) if (all(input == input))
; ;
else else
; ;
[flatten] if (input == input) { [flatten] if (all(input == input)) {
return input; return input;
} }
if (input == input) { if (all(input == input)) {
return input; return input;
} else { } else {
return -input; return -input;
......
...@@ -18,8 +18,8 @@ float4 PixelShaderFunction(float4 input, float f) : COLOR0 ...@@ -18,8 +18,8 @@ float4 PixelShaderFunction(float4 input, float f) : COLOR0
6.0 < foo; 6.0 < foo;
7.0 <= foo; 7.0 <= foo;
v.x == v; all(v.x == v);
f != v; any(f != v);
float1 f1; float1 f1;
......
float4 PixelShaderFunction(float4 input) : COLOR0 float4 PixelShaderFunction(float4 input) : COLOR0
{ {
while (input != input) { return input; } while (any(input != input)) { return input; }
while (false) ; while (false) ;
[unroll] while (false) { } [unroll] while (false) { }
while ((false)) { } while ((false)) { }
......
...@@ -1892,13 +1892,26 @@ bool TIntermediate::promoteBinary(TIntermBinary& node) ...@@ -1892,13 +1892,26 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
// Relational comparisons need numeric types and will promote to scalar Boolean. // Relational comparisons need numeric types and will promote to scalar Boolean.
if (left->getBasicType() == EbtBool) if (left->getBasicType() == EbtBool)
return false; return false;
node.setType(TType(EbtBool));
node.setType(TType(EbtBool, EvqTemporary, left->getVectorSize()));
break; break;
case EOpEqual: case EOpEqual:
case EOpNotEqual: case EOpNotEqual:
if (getSource() == EShSourceHlsl) {
const int resultWidth = std::max(left->getVectorSize(), right->getVectorSize());
// In HLSL, == or != on vectors means component-wise comparison.
if (resultWidth > 1) {
op = (op == EOpEqual) ? EOpVectorEqual : EOpVectorNotEqual;
node.setOp(op);
}
node.setType(TType(EbtBool, EvqTemporary, resultWidth));
} else {
// All the above comparisons result in a bool (but not the vector compares) // All the above comparisons result in a bool (but not the vector compares)
node.setType(TType(EbtBool)); node.setType(TType(EbtBool));
}
break; break;
case EOpLogicalAnd: case EOpLogicalAnd:
...@@ -1973,6 +1986,8 @@ bool TIntermediate::promoteBinary(TIntermBinary& node) ...@@ -1973,6 +1986,8 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
case EOpEqual: case EOpEqual:
case EOpNotEqual: case EOpNotEqual:
case EOpVectorEqual:
case EOpVectorNotEqual:
case EOpLogicalAnd: case EOpLogicalAnd:
case EOpLogicalOr: case EOpLogicalOr:
......
...@@ -163,6 +163,8 @@ bool TOutputTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node) ...@@ -163,6 +163,8 @@ bool TOutputTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node)
case EOpGreaterThan: out.debug << "Compare Greater Than"; break; case EOpGreaterThan: out.debug << "Compare Greater Than"; break;
case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break; case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;
case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break; case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
case EOpVectorEqual: out.debug << "Equal"; break;
case EOpVectorNotEqual: out.debug << "NotEqual"; break;
case EOpVectorTimesScalar: out.debug << "vector-scale"; break; case EOpVectorTimesScalar: out.debug << "vector-scale"; break;
case EOpVectorTimesMatrix: out.debug << "vector-times-matrix"; break; case EOpVectorTimesMatrix: out.debug << "vector-times-matrix"; break;
......
...@@ -91,6 +91,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -91,6 +91,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.calculatelod.dx10.frag", "main"}, {"hlsl.calculatelod.dx10.frag", "main"},
{"hlsl.calculatelodunclamped.dx10.frag", "main"}, {"hlsl.calculatelodunclamped.dx10.frag", "main"},
{"hlsl.cast.frag", "PixelShaderFunction"}, {"hlsl.cast.frag", "PixelShaderFunction"},
{"hlsl.comparison.vec.frag", "main"},
{"hlsl.conditional.frag", "PixelShaderFunction"}, {"hlsl.conditional.frag", "PixelShaderFunction"},
{"hlsl.constructexpr.frag", "main"}, {"hlsl.constructexpr.frag", "main"},
{"hlsl.depthGreater.frag", "PixelShaderFunction"}, {"hlsl.depthGreater.frag", "PixelShaderFunction"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment