Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 20 +++++++++++++++++++- libs/vkd3d-shader/vkd3d_shader_main.c | 2 +- libs/vkd3d-shader/vkd3d_shader_private.h | 6 +++++- 3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index ce4cecff..e3a8351e 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -489,6 +489,8 @@ struct vkd3d_sm4_data struct list src_free; struct list src; struct vkd3d_shader_immediate_constant_buffer icb; + + struct vkd3d_shader_message_context *message_context; };
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; }
+static void VKD3D_PRINTF_FUNC(3, 4) shader_read_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, 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, @@ -629,7 +641,11 @@ static void shader_sm4_read_descriptor_register_range(struct vkd3d_sm4_data *pri 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; if (range->last < range->first) + { FIXME("Invalid register range [%u:%u].\n", range->first, range->last); + shader_read_error(priv, VKD3D_SHADER_ERROR_SPV_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, @@ -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, - 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; 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);
+ priv->message_context = message_context; + return priv; }
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 40d55b70..54654f3f 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -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, - 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"); free_shader_desc(shader_desc); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index c61b3773..5e107a6b 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -73,6 +73,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_SPV_DESCRIPTOR_BINDING_NOT_FOUND = 2000, VKD3D_SHADER_ERROR_SPV_INVALID_REGISTER_TYPE = 2001, VKD3D_SHADER_ERROR_SPV_INVALID_DESCRIPTOR_BINDING = 2002, + VKD3D_SHADER_ERROR_SPV_INVALID_REGISTER_RANGE = 2003,
VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY = 3000, VKD3D_SHADER_ERROR_RS_INVALID_VERSION = 3001, @@ -861,8 +862,11 @@ void vkd3d_shader_trace(void *data) 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, - 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_read_header(void *data, const DWORD **ptr, struct vkd3d_shader_version *shader_version) DECLSPEC_HIDDEN;