mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests: Add tests for texture gather methods.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com> Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6de080088a
commit
d07d0d8eff
@ -68,6 +68,8 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl-duplicate-modifiers.shader_test \
|
||||
tests/hlsl-for.shader_test \
|
||||
tests/hlsl-function-overload.shader_test \
|
||||
tests/hlsl-gather-offset.shader_test \
|
||||
tests/hlsl-gather.shader_test \
|
||||
tests/hlsl-intrinsic-override.shader_test \
|
||||
tests/hlsl-invalid.shader_test \
|
||||
tests/hlsl-majority-pragma.shader_test \
|
||||
@ -294,6 +296,7 @@ XFAIL_TESTS = \
|
||||
tests/hlsl-duplicate-modifiers.shader_test \
|
||||
tests/hlsl-for.shader_test \
|
||||
tests/hlsl-function-overload.shader_test \
|
||||
tests/hlsl-gather.shader_test \
|
||||
tests/hlsl-intrinsic-override.shader_test \
|
||||
tests/hlsl-majority-pragma.shader_test \
|
||||
tests/hlsl-majority-typedef.shader_test \
|
||||
|
101
tests/hlsl-gather-offset.shader_test
Normal file
101
tests/hlsl-gather-offset.shader_test
Normal file
@ -0,0 +1,101 @@
|
||||
[require]
|
||||
shader model >= 4.1
|
||||
|
||||
|
||||
[sampler 0]
|
||||
filter linear linear linear
|
||||
address clamp clamp clamp
|
||||
|
||||
[texture 0]
|
||||
size (3, 3)
|
||||
0.0 0.0 0.0 0.4 0.1 0.0 0.5 0.0 0.2 0.0 0.0 0.4
|
||||
0.0 0.1 0.5 0.0 0.1 0.1 0.0 0.4 0.2 0.1 0.5 0.0
|
||||
0.0 0.2 0.0 0.4 0.1 0.2 0.5 0.0 0.2 0.2 0.0 0.4
|
||||
|
||||
|
||||
[pixel shader]
|
||||
sampler s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.Gather(s, float2(0.2, 0.2), int2(1, 0));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.1, 0.2, 0.2, 0.1)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
sampler s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherRed(s, float2(0.6, 0.6), int2(-1, 0));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.0, 0.1, 0.1, 0.0)
|
||||
|
||||
|
||||
[require]
|
||||
shader model >= 5.0
|
||||
|
||||
|
||||
[pixel shader]
|
||||
SamplerState s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherGreen(s, float2(0.2, 0.2), int2(0, 1));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.2, 0.2, 0.1, 0.1)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
SamplerState s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherGreen(s, float2(0.8, 0.8), int2(-1, -1));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.1, 0.1, 0.0, 0.0)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
SamplerState s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherBlue(s, float2(0.2, 0.8), int2(1, 0));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.5, 0.0, 0.5, 0.0)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
SamplerState s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherAlpha(s, float2(0.2, 0.8), int2(0, -1));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.0, 0.4, 0.0, 0.4)
|
115
tests/hlsl-gather.shader_test
Normal file
115
tests/hlsl-gather.shader_test
Normal file
@ -0,0 +1,115 @@
|
||||
[require]
|
||||
shader model >= 4.1
|
||||
|
||||
|
||||
[sampler 0]
|
||||
filter linear linear linear
|
||||
address clamp clamp clamp
|
||||
|
||||
[texture 0]
|
||||
size (3, 3)
|
||||
0.0 0.0 0.0 0.4 0.1 0.0 0.5 0.0 0.2 0.0 0.0 0.4
|
||||
0.0 0.1 0.5 0.0 0.1 0.1 0.0 0.4 0.2 0.1 0.5 0.0
|
||||
0.0 0.2 0.0 0.4 0.1 0.2 0.5 0.0 0.2 0.2 0.0 0.4
|
||||
|
||||
|
||||
[pixel shader]
|
||||
sampler s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.Gather(s, float2(0.2, 0.2));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.0, 0.1, 0.1, 0.0)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
sampler s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherRed(s, float2(0.6, 0.6), int2(0, 0));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.1, 0.2, 0.2, 0.1)
|
||||
|
||||
|
||||
[require]
|
||||
shader model >= 5.0
|
||||
|
||||
|
||||
[pixel shader]
|
||||
SamplerState s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherGreen(s, float2(0.2, 0.2), int2(0, 0));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.1, 0.1, 0.0, 0.0)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
SamplerState s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherGreen(s, float2(0.8, 0.8));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.2, 0.2, 0.1, 0.1)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
SamplerState s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherGreen(s, float2(0.2, 0.2), int2(0, 0), int2(0, 0), int2(0, 0), int2(0, 0));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.1, 0.1, 0.0, 0.0)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
SamplerState s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherBlue(s, float2(0.2, 0.8), int2(0, 0));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.0, 0.5, 0.0, 0.5)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
SamplerState s;
|
||||
Texture2D t;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return t.GatherAlpha(s, float2(0.2, 0.8), int2(0, 0));
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe all rgba (0.4, 0.0, 0.4, 0.0)
|
@ -115,9 +115,18 @@ struct texture
|
||||
unsigned int root_index;
|
||||
};
|
||||
|
||||
enum shader_model
|
||||
{
|
||||
SHADER_MODEL_4_0 = 0,
|
||||
SHADER_MODEL_4_1,
|
||||
SHADER_MODEL_5_0,
|
||||
SHADER_MODEL_5_1,
|
||||
};
|
||||
|
||||
struct shader_context
|
||||
{
|
||||
struct test_context c;
|
||||
enum shader_model minimum_shader_model;
|
||||
|
||||
ID3D10Blob *ps_code;
|
||||
|
||||
@ -160,6 +169,7 @@ enum parse_state
|
||||
STATE_NONE,
|
||||
STATE_PREPROC,
|
||||
STATE_PREPROC_INVALID,
|
||||
STATE_REQUIRE,
|
||||
STATE_SAMPLER,
|
||||
STATE_SHADER_INVALID_PIXEL,
|
||||
STATE_SHADER_PIXEL,
|
||||
@ -182,6 +192,36 @@ static bool match_string(const char *line, const char *token, const char **const
|
||||
return true;
|
||||
}
|
||||
|
||||
static void parse_require_directive(struct shader_context *context, const char *line)
|
||||
{
|
||||
if (match_string(line, "shader model >=", &line))
|
||||
{
|
||||
static const char *const model_strings[] =
|
||||
{
|
||||
[SHADER_MODEL_4_0] = "4.0",
|
||||
[SHADER_MODEL_4_1] = "4.1",
|
||||
[SHADER_MODEL_5_0] = "5.0",
|
||||
[SHADER_MODEL_5_1] = "5.1",
|
||||
};
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(model_strings); ++i)
|
||||
{
|
||||
if (match_string(line, model_strings[i], &line))
|
||||
{
|
||||
context->minimum_shader_model = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fatal_error("Unknown shader model '%s'.\n", line);
|
||||
}
|
||||
else
|
||||
{
|
||||
fatal_error("Unknown require directive '%s'.\n", line);
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_texture_format(struct texture *texture, const char *line)
|
||||
{
|
||||
static const struct
|
||||
@ -662,16 +702,27 @@ START_TEST(shader_runner_d3d12)
|
||||
switch (state)
|
||||
{
|
||||
case STATE_NONE:
|
||||
case STATE_REQUIRE:
|
||||
case STATE_SAMPLER:
|
||||
case STATE_TEST:
|
||||
case STATE_TEXTURE:
|
||||
break;
|
||||
|
||||
case STATE_SHADER_PIXEL:
|
||||
if (!(context.ps_code = compile_shader(shader_source, "ps_4_0")))
|
||||
{
|
||||
static const char *const shader_models[] =
|
||||
{
|
||||
[SHADER_MODEL_4_0] = "ps_4_0",
|
||||
[SHADER_MODEL_4_1] = "ps_4_1",
|
||||
[SHADER_MODEL_5_0] = "ps_5_0",
|
||||
[SHADER_MODEL_5_1] = "ps_5_1",
|
||||
};
|
||||
|
||||
if (!(context.ps_code = compile_shader(shader_source, shader_models[context.minimum_shader_model])))
|
||||
return;
|
||||
shader_source_len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SHADER_INVALID_PIXEL:
|
||||
{
|
||||
@ -755,7 +806,11 @@ START_TEST(shader_runner_d3d12)
|
||||
{
|
||||
unsigned int index;
|
||||
|
||||
if (!strcmp(line, "[pixel shader]\n"))
|
||||
if (!strcmp(line, "[require]\n"))
|
||||
{
|
||||
state = STATE_REQUIRE;
|
||||
}
|
||||
else if (!strcmp(line, "[pixel shader]\n"))
|
||||
{
|
||||
state = STATE_SHADER_PIXEL;
|
||||
|
||||
@ -844,6 +899,10 @@ START_TEST(shader_runner_d3d12)
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_REQUIRE:
|
||||
parse_require_directive(&context, line);
|
||||
break;
|
||||
|
||||
case STATE_SAMPLER:
|
||||
parse_sampler_directive(current_sampler, line);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user