vkd3d-shader: Introduce shader_sm4_error() for reporting via vkd3d_shader_verror().

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Conor McCarthy 2021-07-02 13:12:48 +10:00 committed by Alexandre Julliard
parent 219bd1fc07
commit 57faa09dc0
3 changed files with 24 additions and 3 deletions

View File

@ -489,6 +489,8 @@ struct vkd3d_sm4_data
struct list src_free; struct list src_free;
struct list src; struct list src;
struct vkd3d_shader_immediate_constant_buffer icb; struct vkd3d_shader_immediate_constant_buffer icb;
struct vkd3d_shader_message_context *message_context;
}; };
struct vkd3d_sm4_opcode_info struct vkd3d_sm4_opcode_info
@ -561,6 +563,16 @@ static bool shader_is_sm_5_1(const struct vkd3d_sm4_data *priv)
return version->major >= 5 && version->minor >= 1; return version->major >= 5 && version->minor >= 1;
} }
static void VKD3D_PRINTF_FUNC(3, 4) shader_sm4_error(struct vkd3d_sm4_data *priv,
enum vkd3d_shader_error error, const char *format, ...)
{
va_list args;
va_start(args, format);
vkd3d_shader_verror(priv->message_context, NULL, error, format, args);
va_end(args);
}
static bool shader_sm4_read_src_param(struct vkd3d_sm4_data *priv, const DWORD **ptr, const DWORD *end, static bool shader_sm4_read_src_param(struct vkd3d_sm4_data *priv, const DWORD **ptr, const DWORD *end,
enum vkd3d_data_type data_type, struct vkd3d_shader_src_param *src_param); enum vkd3d_data_type data_type, struct vkd3d_shader_src_param *src_param);
static bool shader_sm4_read_dst_param(struct vkd3d_sm4_data *priv, const DWORD **ptr, const DWORD *end, static bool shader_sm4_read_dst_param(struct vkd3d_sm4_data *priv, const DWORD **ptr, const DWORD *end,
@ -628,7 +640,11 @@ static void shader_sm4_set_descriptor_register_range(struct vkd3d_sm4_data *priv
range->first = reg->idx[shader_is_sm_5_1(priv) ? 1 : 0].offset; range->first = reg->idx[shader_is_sm_5_1(priv) ? 1 : 0].offset;
range->last = reg->idx[shader_is_sm_5_1(priv) ? 2 : 0].offset; range->last = reg->idx[shader_is_sm_5_1(priv) ? 2 : 0].offset;
if (range->last < range->first) if (range->last < range->first)
{
FIXME("Invalid register range [%u:%u].\n", range->first, range->last); FIXME("Invalid register range [%u:%u].\n", range->first, range->last);
shader_sm4_error(priv, VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_RANGE,
"Last register %u must not be less than first register %u in range.\n", range->last, range->first);
}
} }
static void shader_sm4_read_dcl_resource(struct vkd3d_shader_instruction *ins, static void shader_sm4_read_dcl_resource(struct vkd3d_shader_instruction *ins,
@ -1343,7 +1359,7 @@ static enum vkd3d_data_type map_data_type(char t)
} }
void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size, void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
const struct vkd3d_shader_signature *output_signature) const struct vkd3d_shader_signature *output_signature, struct vkd3d_shader_message_context *message_context)
{ {
DWORD version_token, token_count; DWORD version_token, token_count;
struct vkd3d_sm4_data *priv; struct vkd3d_sm4_data *priv;
@ -1424,6 +1440,8 @@ void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
list_init(&priv->src_free); list_init(&priv->src_free);
list_init(&priv->src); list_init(&priv->src);
priv->message_context = message_context;
return priv; return priv;
} }

View File

@ -344,7 +344,7 @@ static int vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
} }
if (!(parser->data = shader_sm4_init(shader_desc->byte_code, if (!(parser->data = shader_sm4_init(shader_desc->byte_code,
shader_desc->byte_code_size, &shader_desc->output_signature))) shader_desc->byte_code_size, &shader_desc->output_signature, message_context)))
{ {
WARN("Failed to initialize shader parser.\n"); WARN("Failed to initialize shader parser.\n");
free_shader_desc(shader_desc); free_shader_desc(shader_desc);

View File

@ -69,6 +69,7 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_SIZE = 6, VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_SIZE = 6,
VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF = 1000, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF = 1000,
VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_RANGE = 1001,
VKD3D_SHADER_ERROR_SPV_DESCRIPTOR_BINDING_NOT_FOUND = 2000, VKD3D_SHADER_ERROR_SPV_DESCRIPTOR_BINDING_NOT_FOUND = 2000,
VKD3D_SHADER_ERROR_SPV_INVALID_REGISTER_TYPE = 2001, VKD3D_SHADER_ERROR_SPV_INVALID_REGISTER_TYPE = 2001,
@ -861,8 +862,10 @@ void vkd3d_shader_trace(void *data) DECLSPEC_HIDDEN;
const char *shader_get_type_prefix(enum vkd3d_shader_type type) DECLSPEC_HIDDEN; const char *shader_get_type_prefix(enum vkd3d_shader_type type) DECLSPEC_HIDDEN;
struct vkd3d_shader_message_context;
void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size, void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
const struct vkd3d_shader_signature *output_signature) DECLSPEC_HIDDEN; const struct vkd3d_shader_signature *output_signature, struct vkd3d_shader_message_context *message_context) DECLSPEC_HIDDEN;
void shader_sm4_free(void *data) DECLSPEC_HIDDEN; void shader_sm4_free(void *data) DECLSPEC_HIDDEN;
void shader_sm4_read_header(void *data, const DWORD **ptr, void shader_sm4_read_header(void *data, const DWORD **ptr,
struct vkd3d_shader_version *shader_version) DECLSPEC_HIDDEN; struct vkd3d_shader_version *shader_version) DECLSPEC_HIDDEN;