vkd3d-shader: Report error messages from vkd3d_shader_parse_input_signature().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2020-07-30 14:59:56 +04:30 committed by Alexandre Julliard
parent 11f82d985c
commit d135b4687b
6 changed files with 25 additions and 14 deletions

View File

@ -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); 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, 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( struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
const struct vkd3d_shader_signature *signature, const char *semantic_name, const struct vkd3d_shader_signature *signature, const char *semantic_name,
unsigned int semantic_index, unsigned int stream_index); 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); struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);
typedef int (*PFN_vkd3d_shader_parse_input_signature)(const struct vkd3d_shader_code *dxbc, 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)( typedef struct vkd3d_shader_signature_element * (*PFN_vkd3d_shader_find_signature_element)(
const struct vkd3d_shader_signature *signature, const char *semantic_name, const struct vkd3d_shader_signature *signature, const char *semantic_name,
unsigned int semantic_index, unsigned int stream_index); unsigned int semantic_index, unsigned int stream_index);

View File

@ -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, 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; int ret;
memset(signature, 0, sizeof(*signature)); memset(signature, 0, sizeof(*signature));
if (!vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_NONE, NULL)) if ((ret = parse_dxbc(dxbc, dxbc_length, message_context, isgn_handler, signature)) < 0)
return VKD3D_ERROR;
if ((ret = parse_dxbc(dxbc, dxbc_length, &message_context, isgn_handler, signature)) < 0)
ERR("Failed to parse input signature.\n"); ERR("Failed to parse input signature.\n");
vkd3d_shader_message_context_cleanup(&message_context);
return ret; return ret;
} }

View File

@ -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, 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;
return shader_parse_input_signature(dxbc->code, dxbc->size, signature); 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;
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( struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(

View File

@ -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; void free_shader_desc(struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
int shader_parse_input_signature(const void *dxbc, size_t dxbc_length, 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; struct vkd3d_dxbc_compiler;

View File

@ -2316,7 +2316,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
switch (shader_stages[i].stage) switch (shader_stages[i].stage)
{ {
case VK_SHADER_STAGE_VERTEX_BIT: 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); hr = hresult_from_vkd3d_result(ret);
goto fail; goto fail;

View File

@ -134,7 +134,7 @@ static void test_vkd3d_shader_pfns(void)
pfn_vkd3d_shader_free_root_signature(&root_signature_desc); pfn_vkd3d_shader_free_root_signature(&root_signature_desc);
pfn_vkd3d_shader_free_shader_code(&dxbc); 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); ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc);
element = pfn_vkd3d_shader_find_signature_element(&signature, "position", 0, 0); element = pfn_vkd3d_shader_find_signature_element(&signature, "position", 0, 0);
ok(element, "Could not find shader signature element.\n"); ok(element, "Could not find shader signature element.\n");