vkd3d/tests/hlsl/function-cast.shader_test
Conor McCarthy 57280673e5 tests/shader-runner: Test shaders with dxcompiler.
The location of dxcompiler should be set during configuration with
'DXCOMPILER_LIBS=-L/path/to/dxcompiler', and then at runtime with
LD_LIBRARY_PATH, WINEPATH or PATH as applicable.

A new 'fail(sm<6)' decoration is needed on many shader declarations
because dxcompiler succeeds on many shaders which fail with fxc. The
opposite case is less common and is flagged with 'fail(sm>=6)'. A few
tests cause dxcompiler to crash or hang, so these are avoided using
[require], which now skips tests until reset instead of exiting. Also,
'todo(sm<6)' and 'todo(sm>=6)' are used to separate checking of results.
2023-10-11 22:21:14 +02:00

94 lines
1.3 KiB
Plaintext

% Test implicit and explicit casts on function output parameters.
[pixel shader todo]
uniform float4 f;
void func(out float4 o)
{
o = f;
}
float4 main() : sv_target
{
int4 x;
func(x);
return x;
}
[test]
uniform 0 float4 -1.9 -1.0 2.9 4.0
todo draw quad
probe all rgba (-1.0, -1.0, 2.0, 4.0)
% As above, but cast "x" to float4 first.
% In SM 6 a cast seems to implicitly promote the type to const,
% so it fails to match the parameter of func().
[pixel shader todo fail(sm>=6)]
uniform float4 f;
void func(out float4 o)
{
o = f;
}
float4 main() : sv_target
{
int4 x;
func((float4)x);
return x;
}
[test]
uniform 0 float4 -1.9 -1.0 2.9 4.0
todo draw quad
probe all rgba (-1.0, -1.0, 2.0, 4.0)
% As above, but declare "x" as float4 and cast it to int4.
[pixel shader todo fail(sm>=6)]
uniform float4 f;
void func(out float4 o)
{
o = f;
}
float4 main() : sv_target
{
float4 x;
func((int4)x);
return x;
}
[test]
uniform 0 float4 -1.9 -1.0 2.9 4.0
todo draw quad
probe all rgba (-1.0, -1.0, 2.0, 4.0)
[require]
shader model >= 4.0
[pixel shader todo]
uniform int4 i;
void func(inout float4 a)
{
a += 0.1;
}
float4 main() : sv_target
{
int4 x = i;
func(x);
return x;
}
[test]
uniform 0 int4 -2 0 1 -3000000
todo draw quad
probe all rgba (-1.0, 0.0, 1.0, -3000000.0)