Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- tests/shader_runner_d3d12.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index bf5c3e08..42218041 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -372,6 +372,7 @@ START_TEST(shader_runner_d3d12) case STATE_PREPROC: { ID3D10Blob *blob = NULL, *errors = NULL; + SIZE_T size; HRESULT hr; char *text;
@@ -387,8 +388,11 @@ START_TEST(shader_runner_d3d12) }
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"); + size = ID3D10Blob_GetBufferSize(blob); + ok(vkd3d_memmem(text, size, "pass", strlen("pass")), + "'pass' not found in preprocessed shader.\n"); + ok(!vkd3d_memmem(text, size, "fail", strlen("fail")), + "'fail' found in preprocessed shader.\n"); ID3D10Blob_Release(blob); }
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 f799d0a2..2bbedd8b 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -131,6 +131,9 @@ static int open_include(const char *filename, bool local, const char *parent_dat ID3DInclude *iface = context; unsigned int size;
+ if (!iface) + return VKD3D_ERROR; + if (FAILED(ID3DInclude_Open(iface, local ? D3D_INCLUDE_LOCAL : D3D_INCLUDE_SYSTEM, filename, parent_data, &code->code, &size))) return VKD3D_ERROR;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-utils/vkd3d_utils_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c index 2bbedd8b..9c968cc6 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -129,11 +129,12 @@ static int open_include(const char *filename, bool local, const char *parent_dat struct vkd3d_shader_code *code) { ID3DInclude *iface = context; - unsigned int size; + unsigned int size = 0;
if (!iface) return VKD3D_ERROR;
+ memset(code, 0, sizeof(*code)); if (FAILED(ID3DInclude_Open(iface, local ? D3D_INCLUDE_LOCAL : D3D_INCLUDE_SYSTEM, filename, parent_data, &code->code, &size))) return VKD3D_ERROR;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- tests/hlsl_d3d12.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c index 03a732ce..4f4cc37f 100644 --- a/tests/hlsl_d3d12.c +++ b/tests/hlsl_d3d12.c @@ -72,6 +72,14 @@ static const char test_include_file2[] = static const char test_include_file3[] = "#undef BRONTES";
+static const char test_include2_top[] = + "#define FUNC(a, b) a ## b\n" + "#include "file4"\n" + ",ss)"; + +static const char test_include2_file4[] = + "FUNC(pa"; + static unsigned int refcount_file1, refcount_file2, refcount_file3, include_count_file2;
static HRESULT WINAPI test_include_Open(ID3DInclude *iface, D3D_INCLUDE_TYPE type, @@ -106,6 +114,13 @@ static HRESULT WINAPI test_include_Open(ID3DInclude *iface, D3D_INCLUDE_TYPE typ *size = strlen(test_include_file3); ++refcount_file3; } + else if (!strcmp(filename, "file4")) + { + ok(type == D3D_INCLUDE_LOCAL, "Got type %#x.\n", type); + ok(!parent_data, "Got parent data %p.\n", parent_data); + *code = test_include2_file4; + *size = strlen(test_include2_file4); + } else { ok(0, "Unexpected filename "%s".\n", filename); @@ -390,6 +405,9 @@ static void test_preprocess(void) ok(!refcount_file3, "Got %d references to file1.\n", refcount_file3); todo ok(include_count_file2 == 2, "file2 was included %u times.\n", include_count_file2);
+ /* Macro invocation spread across multiple files. */ + check_preprocess(test_include2_top, NULL, &test_include, "pass", NULL); + blob = errors = (ID3D10Blob *)0xdeadbeef; hr = D3DPreprocess(test_include_top, strlen(test_include_top), NULL, NULL, &test_include_fail, &blob, &errors); todo ok(hr == E_FAIL, "Got hr %#x.\n", hr);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/vkd3d_shader_main.c | 33 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 6289a185..1cf1fb35 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -252,7 +252,8 @@ static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser) free_shader_desc(&parser->shader_desc); }
-static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info) +static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info, + bool validate_target_type) { const enum vkd3d_shader_source_type *source_types; const enum vkd3d_shader_target_type *target_types; @@ -276,16 +277,19 @@ static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_ return VKD3D_ERROR_INVALID_ARGUMENT; }
- target_types = vkd3d_shader_get_supported_target_types(compile_info->source_type, &count); - for (i = 0; i < count; ++i) + if (validate_target_type) { - if (target_types[i] == compile_info->target_type) - break; - } - if (i == count) - { - WARN("Invalid shader target type %#x.\n", compile_info->target_type); - return VKD3D_ERROR_INVALID_ARGUMENT; + target_types = vkd3d_shader_get_supported_target_types(compile_info->source_type, &count); + for (i = 0; i < count; ++i) + { + if (target_types[i] == compile_info->target_type) + break; + } + if (i == count) + { + WARN("Invalid shader target type %#x.\n", compile_info->target_type); + return VKD3D_ERROR_INVALID_ARGUMENT; + } }
return VKD3D_OK; @@ -832,7 +836,7 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char if (messages) *messages = NULL;
- if ((ret = vkd3d_shader_validate_compile_info(compile_info)) < 0) + if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0) return ret;
vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name); @@ -933,7 +937,7 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, if (messages) *messages = NULL;
- if ((ret = vkd3d_shader_validate_compile_info(compile_info)) < 0) + if ((ret = vkd3d_shader_validate_compile_info(compile_info, true)) < 0) return ret;
vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name); @@ -1150,10 +1154,15 @@ const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types( int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, char **messages) { + int ret; + TRACE("compile_info %p, out %p, messages %p.\n", compile_info, out, messages);
if (messages) *messages = NULL;
+ if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0) + return ret; + return VKD3D_ERROR_NOT_IMPLEMENTED; }
On Wed, 2 Dec 2020 at 06:21, Zebediah Figura zfigura@codeweavers.com wrote:
@@ -832,7 +836,7 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char if (messages) *messages = NULL;
- if ((ret = vkd3d_shader_validate_compile_info(compile_info)) < 0)
- if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0) return ret;
This makes vkd3d_shader_scan() ignore the target type. Maybe that's ok, but it probably deserves a bit more thought than being a side effect of this patch, as well as some updates to the API documentation.
On 12/2/20 8:32 AM, Henri Verbeet wrote:
On Wed, 2 Dec 2020 at 06:21, Zebediah Figura zfigura@codeweavers.com wrote:
@@ -832,7 +836,7 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char if (messages) *messages = NULL;
- if ((ret = vkd3d_shader_validate_compile_info(compile_info)) < 0)
- if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0) return ret;
This makes vkd3d_shader_scan() ignore the target type. Maybe that's ok, but it probably deserves a bit more thought than being a side effect of this patch, as well as some updates to the API documentation.
I figured it was sensible enough to be obvious, but that's fair enough.
On Wed, 2 Dec 2020 at 19:00, Zebediah Figura (she/her) zfigura@codeweavers.com wrote:
On 12/2/20 8:32 AM, Henri Verbeet wrote:
On Wed, 2 Dec 2020 at 06:21, Zebediah Figura zfigura@codeweavers.com wrote:
@@ -832,7 +836,7 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char if (messages) *messages = NULL;
- if ((ret = vkd3d_shader_validate_compile_info(compile_info)) < 0)
- if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0) return ret;
This makes vkd3d_shader_scan() ignore the target type. Maybe that's ok, but it probably deserves a bit more thought than being a side effect of this patch, as well as some updates to the API documentation.
I figured it was sensible enough to be obvious, but that's fair enough.
I can certainly see the argument for ignoring it, but there's somewhat of an open question about whether the target type can influence what vkd3d_shader_scan() returns for a particular shader, or whether that purely depends on the source type and (potentially) chained output structures.