Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- include/vkd3d_shader.h | 4 ++-- libs/vkd3d-shader/dxbc.c | 8 ++------ libs/vkd3d-shader/vkd3d_shader_main.c | 21 ++++++++++++++++++--- libs/vkd3d-shader/vkd3d_shader_private.h | 2 +- libs/vkd3d/state.c | 2 +- tests/vkd3d_shader_api.c | 2 +- 6 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 96d0545..0dd9829 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -767,7 +767,7 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char void vkd3d_shader_free_scan_descriptor_info(struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);
int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, - struct vkd3d_shader_signature *signature); + struct vkd3d_shader_signature *signature, char **messages); struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element( const struct vkd3d_shader_signature *signature, const char *semantic_name, unsigned int semantic_index, unsigned int stream_index); @@ -798,7 +798,7 @@ typedef void (*PFN_vkd3d_shader_free_scan_descriptor_info)( struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);
typedef int (*PFN_vkd3d_shader_parse_input_signature)(const struct vkd3d_shader_code *dxbc, - struct vkd3d_shader_signature *signature); + struct vkd3d_shader_signature *signature, char **messages); typedef struct vkd3d_shader_signature_element * (*PFN_vkd3d_shader_find_signature_element)( const struct vkd3d_shader_signature *signature, const char *semantic_name, unsigned int semantic_index, unsigned int stream_index); diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index f738abe..a00dbe9 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -2132,17 +2132,13 @@ static int isgn_handler(const char *data, DWORD data_size, DWORD tag, void *ctx) }
int shader_parse_input_signature(const void *dxbc, size_t dxbc_length, - struct vkd3d_shader_signature *signature) + struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_signature *signature) { - struct vkd3d_shader_message_context message_context; int ret;
memset(signature, 0, sizeof(*signature)); - if (!vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_NONE, NULL)) - return VKD3D_ERROR; - if ((ret = parse_dxbc(dxbc, dxbc_length, &message_context, isgn_handler, signature)) < 0) + if ((ret = parse_dxbc(dxbc, dxbc_length, message_context, isgn_handler, signature)) < 0) ERR("Failed to parse input signature.\n"); - vkd3d_shader_message_context_cleanup(&message_context);
return ret; } diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 5d50487..6511a89 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -971,11 +971,26 @@ void vkd3d_shader_free_root_signature(struct vkd3d_shader_versioned_root_signatu }
int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, - struct vkd3d_shader_signature *signature) + struct vkd3d_shader_signature *signature, char **messages) { - TRACE("dxbc {%p, %zu}, signature %p.\n", dxbc->code, dxbc->size, signature); + struct vkd3d_shader_message_context message_context; + int ret; + + TRACE("dxbc {%p, %zu}, signature %p, messages %p.\n", dxbc->code, dxbc->size, signature, messages); + + if (messages) + *messages = NULL; + if (!vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_INFO, NULL)) + return VKD3D_ERROR;
- return shader_parse_input_signature(dxbc->code, dxbc->size, signature); + ret = shader_parse_input_signature(dxbc->code, dxbc->size, &message_context, 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); + + return ret; }
struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element( diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index ae2f6c2..79056b3 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -840,7 +840,7 @@ int shader_extract_from_dxbc(const void *dxbc, size_t dxbc_length, void free_shader_desc(struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
int shader_parse_input_signature(const void *dxbc, size_t dxbc_length, - struct vkd3d_shader_signature *signature) DECLSPEC_HIDDEN; + struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_signature *signature) DECLSPEC_HIDDEN;
struct vkd3d_dxbc_compiler;
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 93f22ce..449f242 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -2316,7 +2316,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s switch (shader_stages[i].stage) { case VK_SHADER_STAGE_VERTEX_BIT: - if ((ret = vkd3d_shader_parse_input_signature(&dxbc, &input_signature)) < 0) + if ((ret = vkd3d_shader_parse_input_signature(&dxbc, &input_signature, NULL)) < 0) { hr = hresult_from_vkd3d_result(ret); goto fail; diff --git a/tests/vkd3d_shader_api.c b/tests/vkd3d_shader_api.c index be63b39..6977945 100644 --- a/tests/vkd3d_shader_api.c +++ b/tests/vkd3d_shader_api.c @@ -134,7 +134,7 @@ static void test_vkd3d_shader_pfns(void) pfn_vkd3d_shader_free_root_signature(&root_signature_desc); pfn_vkd3d_shader_free_shader_code(&dxbc);
- rc = pfn_vkd3d_shader_parse_input_signature(&vs, &signature); + rc = pfn_vkd3d_shader_parse_input_signature(&vs, &signature, NULL); ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc); element = pfn_vkd3d_shader_find_signature_element(&signature, "position", 0, 0); ok(element, "Could not find shader signature element.\n");