glslang/Test/hlsl.shapeConv.frag
steve-lunarg 85244d7486 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.
2016-10-26 08:50:10 -06:00

33 lines
440 B
GLSL

float4 PixelShaderFunction(float4 input, float f) : COLOR0
{
float4 v;
v = 1;
v = 2.0;
v = f;
float3 u;
u = float(1);
u = float(2.0);
u = float(f);
float2 w = 2.0;
float V = 1;
float3 MyVal = V;
float3 foo;
foo > 4.0;
foo >= 5.0;
6.0 < foo;
7.0 <= foo;
all(v.x == v);
any(f != v);
float1 f1;
f1 == v;
v < f1;
f1.x;
f1.xxx;
return input;
}