From 33eb944bf425a1fe21cf9b54daa299092fe730b1 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 30 Jul 2020 14:59:57 +0430 Subject: [PATCH] vkd3d-shader: Report error messages from vkd3d_shader_parse_root_signature(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- include/vkd3d_shader.h | 4 ++-- libs/vkd3d-shader/dxbc.c | 13 ++++++++++--- libs/vkd3d-shader/vkd3d_shader_main.c | 6 ++---- libs/vkd3d-shader/vkd3d_shader_private.h | 5 +++++ libs/vkd3d/vkd3d_main.c | 4 ++-- tests/vkd3d_shader_api.c | 2 +- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 0dd9829d..8ee67243 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -753,7 +753,7 @@ void vkd3d_shader_free_messages(char *messages); void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code); int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, - struct vkd3d_shader_versioned_root_signature_desc *root_signature); + struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages); void vkd3d_shader_free_root_signature(struct vkd3d_shader_versioned_root_signature_desc *root_signature); /* FIXME: Add support for returning error messages (ID3DBlob). */ @@ -784,7 +784,7 @@ typedef void (*PFN_vkd3d_shader_free_messages)(char *messages); typedef void (*PFN_vkd3d_shader_free_shader_code)(struct vkd3d_shader_code *code); typedef int (*PFN_vkd3d_shader_parse_root_signature)(const struct vkd3d_shader_code *dxbc, - struct vkd3d_shader_versioned_root_signature_desc *root_signature); + struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages); typedef void (*PFN_vkd3d_shader_free_root_signature)(struct vkd3d_shader_versioned_root_signature_desc *root_signature); typedef int (*PFN_vkd3d_shader_serialize_root_signature)( diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index a00dbe99..28159a92 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -2679,17 +2679,24 @@ static int rts0_handler(const char *data, DWORD data_size, DWORD tag, void *cont } int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, - struct vkd3d_shader_versioned_root_signature_desc *root_signature) + struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages) { struct vkd3d_shader_message_context message_context; int ret; - TRACE("dxbc {%p, %zu}, root_signature %p.\n", dxbc->code, dxbc->size, root_signature); + TRACE("dxbc {%p, %zu}, root_signature %p, messages %p.\n", dxbc->code, dxbc->size, root_signature, messages); memset(root_signature, 0, sizeof(*root_signature)); - if (!vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_NONE, NULL)) + if (messages) + *messages = NULL; + if (!vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_INFO, NULL)) return VKD3D_ERROR; + ret = parse_dxbc(dxbc->code, dxbc->size, &message_context, rts0_handler, root_signature); + vkd3d_shader_message_context_trace_messages(&message_context); + if (messages && !(*messages = vkd3d_shader_message_context_copy_messages(&message_context))) + ret = VKD3D_ERROR_OUT_OF_MEMORY; + vkd3d_shader_message_context_cleanup(&message_context); if (ret < 0) vkd3d_shader_free_root_signature(root_signature); diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 6511a89d..0785c145 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -133,15 +133,13 @@ void vkd3d_shader_message_context_cleanup(struct vkd3d_shader_message_context *c vkd3d_string_buffer_cleanup(&context->messages); } -#define vkd3d_shader_message_context_trace_messages(context) \ - vkd3d_shader_message_context_trace_messages_(context, __FUNCTION__) -static void vkd3d_shader_message_context_trace_messages_(const struct vkd3d_shader_message_context *context, +void vkd3d_shader_message_context_trace_messages_(const struct vkd3d_shader_message_context *context, const char *function) { vkd3d_string_buffer_trace_(&context->messages, function); } -static char *vkd3d_shader_message_context_copy_messages(struct vkd3d_shader_message_context *context) +char *vkd3d_shader_message_context_copy_messages(struct vkd3d_shader_message_context *context) { char *messages; diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 79056b38..3161087e 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -830,8 +830,13 @@ struct vkd3d_shader_message_context }; void vkd3d_shader_message_context_cleanup(struct vkd3d_shader_message_context *context) DECLSPEC_HIDDEN; +char *vkd3d_shader_message_context_copy_messages(struct vkd3d_shader_message_context *context) DECLSPEC_HIDDEN; bool vkd3d_shader_message_context_init(struct vkd3d_shader_message_context *context, enum vkd3d_shader_log_level log_level, const char *source_name) DECLSPEC_HIDDEN; +void vkd3d_shader_message_context_trace_messages_(const struct vkd3d_shader_message_context *context, + const char *function) DECLSPEC_HIDDEN; +#define vkd3d_shader_message_context_trace_messages(context) \ + vkd3d_shader_message_context_trace_messages_(context, __FUNCTION__) void vkd3d_shader_error(struct vkd3d_shader_message_context *context, enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN; diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index 5d7c71e1..3fd9c1b0 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -174,7 +174,7 @@ int vkd3d_parse_root_signature_v_1_0(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_versioned_root_signature_desc desc, converted_desc; int ret; - if ((ret = vkd3d_shader_parse_root_signature(dxbc, &desc)) < 0) + if ((ret = vkd3d_shader_parse_root_signature(dxbc, &desc, NULL)) < 0) { WARN("Failed to parse root signature, vkd3d result %d.\n", ret); return ret; @@ -389,7 +389,7 @@ static HRESULT d3d12_versioned_root_signature_deserializer_init(struct d3d12_ver deserializer->ID3D12VersionedRootSignatureDeserializer_iface.lpVtbl = &d3d12_versioned_root_signature_deserializer_vtbl; deserializer->refcount = 1; - if ((ret = vkd3d_shader_parse_root_signature(dxbc, &deserializer->desc.vkd3d)) < 0) + if ((ret = vkd3d_shader_parse_root_signature(dxbc, &deserializer->desc.vkd3d, NULL)) < 0) { WARN("Failed to parse root signature, vkd3d result %d.\n", ret); return hresult_from_vkd3d_result(ret); diff --git a/tests/vkd3d_shader_api.c b/tests/vkd3d_shader_api.c index 69779450..a730c864 100644 --- a/tests/vkd3d_shader_api.c +++ b/tests/vkd3d_shader_api.c @@ -129,7 +129,7 @@ static void test_vkd3d_shader_pfns(void) rc = pfn_vkd3d_shader_serialize_root_signature(&empty_rs_desc, &dxbc); ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc); - rc = pfn_vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc); + rc = pfn_vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc, NULL); ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc); pfn_vkd3d_shader_free_root_signature(&root_signature_desc); pfn_vkd3d_shader_free_shader_code(&dxbc);