tests: Import vector indexing tests from Wine.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-09-30 21:01:22 -05:00 committed by Alexandre Julliard
parent b64b304061
commit fd9a568b8a
4 changed files with 51 additions and 0 deletions

View File

@ -50,6 +50,9 @@ vkd3d_shader_runners = \
tests/shader_runner_d3d12
vkd3d_shader_tests = \
tests/conditional.shader_test \
tests/hlsl-vector-indexing.shader_test \
tests/hlsl-vector-indexing-uniform.shader_test \
tests/math.shader_test \
tests/swizzle-0.shader_test \
tests/swizzle-1.shader_test \
@ -178,6 +181,9 @@ tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la
SHADER_TEST_LOG_COMPILER = tests/shader_runner_d3d12
XFAIL_TESTS = \
tests/conditional.shader_test \
tests/hlsl-vector-indexing.shader_test \
tests/hlsl-vector-indexing-uniform.shader_test \
tests/math.shader_test \
tests/swizzle-0.shader_test \
tests/swizzle-1.shader_test \

View File

@ -0,0 +1,16 @@
# Use a uniform to prevent the compiler from optimizing.
[pixel shader]
uniform int i;
float4 main() : SV_TARGET
{
float4 color = float4(0.5, 0.4, 0.3, 0.2);
color.g = color[i];
color.b = 0.8;
return color;
}
[test]
uniform 0 uint 2
draw quad
probe all rgba (0.5, 0.3, 0.8, 0.2)

View File

@ -0,0 +1,14 @@
[pixel shader]
float4 main() : SV_TARGET
{
float4 color;
color[0] = 0.020;
color[1] = 0.245;
color[2] = 0.351;
color[3] = 1.0;
return color;
}
[test]
draw quad
probe all rgba (0.02, 0.245, 0.351, 1.0)

View File

@ -211,6 +211,18 @@ static void parse_test_directive(struct shader_context *context, const char *lin
}
memcpy(context->uniforms + offset, &v, sizeof(v));
}
else if (match_string(line, "uint", &line))
{
unsigned int u;
sscanf(line, "%u", &u);
if (offset + 1 > context->uniform_count)
{
context->uniform_count = offset + 1;
context->uniforms = realloc(context->uniforms, context->uniform_count * sizeof(*context->uniforms));
}
memcpy(context->uniforms + offset, &u, sizeof(u));
}
}
else
{
@ -271,6 +283,9 @@ START_TEST(shader_runner_d3d12)
while (fgets(line, sizeof(line), f))
{
if (line[0] == '\n')
continue;
if (line[0] == '[')
{
switch (state)