mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests: Add some basic tests for #if and related preprocessor directives.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
52f844d2dc
commit
ca28ac17fb
@ -64,6 +64,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl-vector-indexing.shader_test \
|
||||
tests/hlsl-vector-indexing-uniform.shader_test \
|
||||
tests/math.shader_test \
|
||||
tests/preproc-if.shader_test \
|
||||
tests/swizzle-0.shader_test \
|
||||
tests/swizzle-1.shader_test \
|
||||
tests/swizzle-2.shader_test \
|
||||
@ -206,6 +207,7 @@ XFAIL_TESTS = \
|
||||
tests/hlsl-vector-indexing.shader_test \
|
||||
tests/hlsl-vector-indexing-uniform.shader_test \
|
||||
tests/math.shader_test \
|
||||
tests/preproc-if.shader_test \
|
||||
tests/swizzle-0.shader_test \
|
||||
tests/swizzle-1.shader_test \
|
||||
tests/swizzle-2.shader_test \
|
||||
|
126
tests/preproc-if.shader_test
Normal file
126
tests/preproc-if.shader_test
Normal file
@ -0,0 +1,126 @@
|
||||
[preproc]
|
||||
#if 1
|
||||
pass
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
#if 1
|
||||
pass
|
||||
|
||||
[preproc]
|
||||
pass
|
||||
#if 0
|
||||
fail
|
||||
|
||||
[preproc]
|
||||
#if 1
|
||||
pass
|
||||
#else
|
||||
fail
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
#if 0
|
||||
fail
|
||||
#else
|
||||
pass
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
#if 0
|
||||
fail
|
||||
#else
|
||||
pass
|
||||
|
||||
[preproc]
|
||||
#if 0
|
||||
fail
|
||||
#elif 1
|
||||
pass
|
||||
#else
|
||||
fail
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
#if 1
|
||||
pass
|
||||
#elif 1
|
||||
fail
|
||||
#else
|
||||
fail
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
#if 0
|
||||
fail
|
||||
#elif 0
|
||||
fail
|
||||
#else
|
||||
pass
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
#if 0
|
||||
#if 1
|
||||
fail
|
||||
#endif
|
||||
#else
|
||||
#if 0
|
||||
fail
|
||||
#else
|
||||
pass
|
||||
#endif
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
#if 0
|
||||
fail
|
||||
#endif
|
||||
pass
|
||||
|
||||
[preproc]
|
||||
#endif
|
||||
pass
|
||||
|
||||
[preproc]
|
||||
/* The #elif is effectively ignored here. */
|
||||
#if 0
|
||||
fail
|
||||
#else
|
||||
pass
|
||||
#elif 0
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
#if 0
|
||||
fail
|
||||
#else
|
||||
#elif 0
|
||||
pass
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
/* Similarly, the second #else is effectively ignored here. */
|
||||
#if 0
|
||||
fail
|
||||
#else
|
||||
pass
|
||||
#else
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
/* Similarly, the second #else is effectively ignored here. */
|
||||
#if 0
|
||||
fail
|
||||
#else
|
||||
#else
|
||||
pass
|
||||
#endif
|
||||
|
||||
[preproc]
|
||||
#if 0
|
||||
#define KEY fail
|
||||
#else
|
||||
#define KEY pass
|
||||
#endif
|
||||
KEY
|
@ -102,6 +102,7 @@ static ID3D10Blob *compile_shader(const char *source, const char *target)
|
||||
enum parse_state
|
||||
{
|
||||
STATE_NONE,
|
||||
STATE_PREPROC,
|
||||
STATE_SHADER_INVALID_PIXEL,
|
||||
STATE_SHADER_PIXEL,
|
||||
STATE_TEST,
|
||||
@ -345,6 +346,33 @@ START_TEST(shader_runner_d3d12)
|
||||
shader_source_len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_PREPROC:
|
||||
{
|
||||
ID3D10Blob *blob = NULL, *errors = NULL;
|
||||
HRESULT hr;
|
||||
char *text;
|
||||
|
||||
hr = D3DPreprocess(shader_source, strlen(shader_source), NULL, NULL, NULL, &blob, &errors);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
if (errors)
|
||||
{
|
||||
if (vkd3d_test_state.debug_level)
|
||||
trace("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors));
|
||||
ID3D10Blob_Release(errors);
|
||||
}
|
||||
|
||||
text = ID3D10Blob_GetBufferPointer(blob);
|
||||
ok(strstr(text, "pass"), "'pass' not found in preprocessed shader.\n");
|
||||
ok(!strstr(text, "fail"), "'fail' found in preprocessed shader.\n");
|
||||
ID3D10Blob_Release(blob);
|
||||
}
|
||||
|
||||
shader_source_len = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,6 +387,8 @@ START_TEST(shader_runner_d3d12)
|
||||
state = STATE_SHADER_INVALID_PIXEL;
|
||||
else if (!strcmp(line, "[test]\n"))
|
||||
state = STATE_TEST;
|
||||
else if (!strcmp(line, "[preproc]\n"))
|
||||
state = STATE_PREPROC;
|
||||
|
||||
vkd3d_test_set_context("Section %.*s, line %u", strlen(line) - 1, line, line_number);
|
||||
}
|
||||
@ -371,6 +401,7 @@ START_TEST(shader_runner_d3d12)
|
||||
fprintf(stderr, "Ignoring line '%s' in %s.\n", line, argv[1]);
|
||||
break;
|
||||
|
||||
case STATE_PREPROC:
|
||||
case STATE_SHADER_INVALID_PIXEL:
|
||||
case STATE_SHADER_PIXEL:
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user