Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-utils/vkd3d_utils_main.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c index f5cb5b5f..9b608f6b 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -176,6 +176,9 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen if (secondary_flags) FIXME("Ignoring secondary flags %#x.\n", secondary_flags);
+ if (messages_blob) + *messages_blob = NULL; + compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; compile_info.next = &preprocess_info; compile_info.source.code = data;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-utils/vkd3d_utils_main.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c index 9b608f6b..f799d0a2 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -268,6 +268,9 @@ HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename TRACE("data %p, size %lu, filename %s, macros %p, include %p, preprocessed_blob %p, messages_blob %p.\n", data, size, debugstr_a(filename), macros, include, preprocessed_blob, messages_blob);
+ if (messages_blob) + *messages_blob = NULL; + compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; compile_info.next = &preprocess_info; compile_info.source.code = data;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/vkd3d_shader_main.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 664110e7..6289a185 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -1152,5 +1152,8 @@ int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info { TRACE("compile_info %p, out %p, messages %p.\n", compile_info, out, messages);
+ if (messages) + *messages = NULL; + return VKD3D_ERROR_NOT_IMPLEMENTED; }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 + tests/preproc-if.shader_test | 126 +++++++++++++++++++++++++++++++++++ tests/shader_runner_d3d12.c | 31 +++++++++ 3 files changed, 159 insertions(+) create mode 100644 tests/preproc-if.shader_test
diff --git a/Makefile.am b/Makefile.am index 93289a23..60789f43 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/tests/preproc-if.shader_test b/tests/preproc-if.shader_test new file mode 100644 index 00000000..54ee94d6 --- /dev/null +++ b/tests/preproc-if.shader_test @@ -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 diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 787e90ad..39495fa2 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -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: {
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- No need to go and add my signoff if the patches are already committed and it would require more than trivial effort. This is mostly a try run for me...
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 + tests/preproc-ifdef.shader_test | 89 +++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 tests/preproc-ifdef.shader_test
diff --git a/Makefile.am b/Makefile.am index 60789f43..0ee7eda7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,6 +65,7 @@ vkd3d_shader_tests = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ tests/preproc-if.shader_test \ + tests/preproc-ifdef.shader_test \ tests/swizzle-0.shader_test \ tests/swizzle-1.shader_test \ tests/swizzle-2.shader_test \ @@ -208,6 +209,7 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ tests/preproc-if.shader_test \ + tests/preproc-ifdef.shader_test \ tests/swizzle-0.shader_test \ tests/swizzle-1.shader_test \ tests/swizzle-2.shader_test \ diff --git a/tests/preproc-ifdef.shader_test b/tests/preproc-ifdef.shader_test new file mode 100644 index 00000000..b31aeb9a --- /dev/null +++ b/tests/preproc-ifdef.shader_test @@ -0,0 +1,89 @@ +[preproc] +#define KEY +#ifdef KEY +pass +#endif + +[preproc] +#define KEY +#if defined(KEY) +pass +#endif + +[preproc] +#define KEY +#if defined KEY +pass +#endif + +[preproc] +#ifndef KEY +pass +#endif + +[preproc] +#if !defined(KEY) +pass +#endif + +[preproc] +#define KEY +#ifndef KEY +fail +#else +pass +#endif + +[preproc] +#ifdef KEY +fail +#else +pass +#endif + +[preproc] +#define KEY(a, b) +#ifdef KEY +pass +#endif + +[preproc] +#ifdef KEY +fail +#endif +#define KEY +pass + +[preproc] +#define KEY 0 +#ifdef KEY +pass +#endif + +[preproc] +#define KEY +#undef KEY +#ifndef KEY +pass +#endif + +[preproc] +#if KEY +fail +#else +pass +#endif + +[preproc] +#if KEY == 0 +pass +#else +fail +#endif + +[preproc] +#if KEY == 1 +fail +#else +pass +#endif
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com