glslang/Test/hlsl.scalar2matrix.frag
LoopDawg e2713125b9 HLSL: fix several issues in mat construction from scalars
This fixes:

1. A compilation error when assigning scalars to matricies

2. A semantic error in matrix construction from scalars.  This was
initializing the diagonal, where HLSL semantics require the scalar be
replicated to every matrix element.

3. Functions accepting mats can be called with scalars, which will
be shape-converted to the matrix type.  This was previously failing
to match the function signature.

NOTE: this does not yet handle complex scalars (a function call,
say) used to construct matricies.  That'll be added when the
node replicator service is available.  For now, there's an assert.

There's one new test (hlsl.scalar2matrix.frag).  An existing test
lsl.type.half.frag changes, because of (2) above, and a negative
test error message changes due to (3) above.

Fixes #923.
2017-06-14 14:11:18 -06:00

29 lines
783 B
GLSL

void Fn1(float4x4 p) { }
float4 main() : SV_TARGET
{
const float4x4 mat1c = 0.20;
const float4x4 mat2c = {2, 2.1, 2.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const float4x4 mat3c = (float4x4)float1(0.1);
float4x4 mat1 = 0.25;
float4x4 mat2 = {3, 3.1, 3.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float4x4 mat3 = (float4x4)0.375;
// float4x4 mat5 = (float4x4)Fn2(); // TODO: enable when compex rvalue handling is in place
float4x4 mat4;
mat4 = 0.75;
mat4 = float4x4(4, 4.1, 4.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
mat4 = (float4x4)0.5;
mat4 *= 0.75;
mat4 += 0.75;
mat4 -= 0.5;
mat4 /= 2.0;
Fn1(5.0); // test calling fn accepting matrix with scalar type
return mat1c[0] + mat3c[0] + mat1[1] + mat4[2];
}