vkd3d-shader: Move location tracking out of the vkd3d_shader_message_context structure.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-12-15 11:01:32 -06:00 committed by Alexandre Julliard
parent e34213d0d5
commit cdfca2fab7
4 changed files with 83 additions and 66 deletions

View File

@ -2021,9 +2021,11 @@ static const char *shader_get_string(const char *data, size_t data_size, DWORD o
return data + offset;
}
static int parse_dxbc(const char *data, size_t data_size, struct vkd3d_shader_message_context *message_context,
static int parse_dxbc(const char *data, size_t data_size,
struct vkd3d_shader_message_context *message_context, const char *source_name,
int (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx)
{
const struct vkd3d_shader_location location = {.source_name = source_name};
uint32_t checksum[4], calculated_checksum[4];
const char *ptr = data;
int ret = VKD3D_OK;
@ -2036,7 +2038,7 @@ static int parse_dxbc(const char *data, size_t data_size, struct vkd3d_shader_me
if (data_size < VKD3D_DXBC_HEADER_SIZE)
{
WARN("Invalid data size %zu.\n", data_size);
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_DXBC_INVALID_SIZE,
vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXBC_INVALID_SIZE,
"DXBC size %zu is smaller than the DXBC header size.", data_size);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -2047,7 +2049,7 @@ static int parse_dxbc(const char *data, size_t data_size, struct vkd3d_shader_me
if (tag != TAG_DXBC)
{
WARN("Wrong tag.\n");
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_DXBC_INVALID_MAGIC, "Invalid DXBC magic.");
vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXBC_INVALID_MAGIC, "Invalid DXBC magic.");
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -2063,7 +2065,8 @@ static int parse_dxbc(const char *data, size_t data_size, struct vkd3d_shader_me
checksum[0], checksum[1], checksum[2], checksum[3],
calculated_checksum[0], calculated_checksum[1],
calculated_checksum[2], calculated_checksum[3]);
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_DXBC_INVALID_CHECKSUM, "Invalid DXBC checksum.");
vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXBC_INVALID_CHECKSUM,
"Invalid DXBC checksum.");
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -2072,7 +2075,7 @@ static int parse_dxbc(const char *data, size_t data_size, struct vkd3d_shader_me
if (version != 0x00000001)
{
WARN("Got unexpected DXBC version %#x.\n", version);
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_DXBC_INVALID_VERSION,
vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXBC_INVALID_VERSION,
"DXBC version %#x is not supported.", version);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -2095,7 +2098,7 @@ static int parse_dxbc(const char *data, size_t data_size, struct vkd3d_shader_me
if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size))
{
WARN("Invalid chunk offset %#x (data size %zu).\n", chunk_offset, data_size);
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_OFFSET,
vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_OFFSET,
"DXBC chunk %u has invalid offset %#x (data size %#zx).", i, chunk_offset, data_size);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -2109,7 +2112,7 @@ static int parse_dxbc(const char *data, size_t data_size, struct vkd3d_shader_me
{
WARN("Invalid chunk size %#x (data size %zu, chunk offset %#x).\n",
chunk_size, data_size, chunk_offset);
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_SIZE,
vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_SIZE,
"DXBC chunk %u has invalid size %#x (data size %#zx, chunk offset %#x).",
i, chunk_offset, data_size, chunk_offset);
return VKD3D_ERROR_INVALID_ARGUMENT;
@ -2229,7 +2232,7 @@ int shader_parse_input_signature(const void *dxbc, size_t dxbc_length,
int ret;
memset(signature, 0, sizeof(*signature));
if ((ret = parse_dxbc(dxbc, dxbc_length, message_context, isgn_handler, signature)) < 0)
if ((ret = parse_dxbc(dxbc, dxbc_length, message_context, NULL, isgn_handler, signature)) < 0)
ERR("Failed to parse input signature.\n");
return ret;
@ -2304,7 +2307,7 @@ void free_shader_desc(struct vkd3d_shader_desc *desc)
}
int shader_extract_from_dxbc(const void *dxbc, size_t dxbc_length,
struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_desc *desc)
struct vkd3d_shader_message_context *message_context, const char *source_name, struct vkd3d_shader_desc *desc)
{
int ret;
@ -2314,7 +2317,7 @@ int shader_extract_from_dxbc(const void *dxbc, size_t dxbc_length,
memset(&desc->output_signature, 0, sizeof(desc->output_signature));
memset(&desc->patch_constant_signature, 0, sizeof(desc->patch_constant_signature));
ret = parse_dxbc(dxbc, dxbc_length, message_context, shdr_handler, desc);
ret = parse_dxbc(dxbc, dxbc_length, message_context, source_name, shdr_handler, desc);
if (!desc->byte_code)
ret = VKD3D_ERROR_INVALID_ARGUMENT;
@ -2781,9 +2784,9 @@ int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
memset(root_signature, 0, sizeof(*root_signature));
if (messages)
*messages = NULL;
vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_INFO, NULL);
vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_INFO);
ret = parse_dxbc(dxbc->code, dxbc->size, &message_context, rts0_handler, root_signature);
ret = parse_dxbc(dxbc->code, dxbc->size, &message_context, NULL, rts0_handler, root_signature);
vkd3d_shader_message_context_trace_messages(&message_context);
if (!vkd3d_shader_message_context_copy_messages(&message_context, messages))
ret = VKD3D_ERROR_OUT_OF_MEMORY;
@ -2935,7 +2938,7 @@ static int shader_write_root_signature_header(struct root_signature_writer_conte
return VKD3D_OK;
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature header.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -2963,7 +2966,7 @@ static int shader_write_descriptor_ranges(struct root_signature_writer_context *
return VKD3D_OK;
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature descriptor ranges.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -2993,7 +2996,7 @@ static int shader_write_descriptor_ranges1(struct root_signature_writer_context
return VKD3D_OK;
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature descriptor ranges.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -3009,7 +3012,7 @@ static int shader_write_descriptor_table(struct root_signature_writer_context *c
return shader_write_descriptor_ranges(context, table);
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature root descriptor table.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -3025,7 +3028,7 @@ static int shader_write_descriptor_table1(struct root_signature_writer_context *
return shader_write_descriptor_ranges1(context, table);
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature root descriptor table.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -3043,7 +3046,7 @@ static int shader_write_root_constants(struct root_signature_writer_context *con
return VKD3D_OK;
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature root constants.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -3059,7 +3062,7 @@ static int shader_write_root_descriptor(struct root_signature_writer_context *co
return VKD3D_OK;
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature root descriptor.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -3077,7 +3080,7 @@ static int shader_write_root_descriptor1(struct root_signature_writer_context *c
return VKD3D_OK;
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature root descriptor.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -3126,7 +3129,7 @@ static int shader_write_root_parameters(struct root_signature_writer_context *co
break;
default:
FIXME("Unrecognized type %#x.\n", versioned_root_signature_get_parameter_type(desc, i));
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_INVALID_ROOT_PARAMETER_TYPE,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_INVALID_ROOT_PARAMETER_TYPE,
"Invalid/unrecognised root signature root parameter type %#x.",
versioned_root_signature_get_parameter_type(desc, i));
return VKD3D_ERROR_INVALID_ARGUMENT;
@ -3139,7 +3142,7 @@ static int shader_write_root_parameters(struct root_signature_writer_context *co
return VKD3D_OK;
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature root parameters.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -3183,7 +3186,7 @@ static int shader_write_static_samplers(struct root_signature_writer_context *co
return VKD3D_OK;
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature static samplers.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -3218,7 +3221,7 @@ static int shader_write_root_signature(struct root_signature_writer_context *con
return shader_write_static_samplers(context, desc);
fail:
vkd3d_shader_error(&context->message_context, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,
"Out of memory while writing root signature.");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
@ -3247,7 +3250,7 @@ static int validate_descriptor_table_v_1_0(const struct vkd3d_shader_root_descri
else
{
WARN("Invalid descriptor range type %#x.\n", r->range_type);
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_RS_INVALID_DESCRIPTOR_RANGE_TYPE,
vkd3d_shader_error(message_context, NULL, VKD3D_SHADER_ERROR_RS_INVALID_DESCRIPTOR_RANGE_TYPE,
"Invalid root signature descriptor range type %#x.", r->range_type);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -3256,7 +3259,7 @@ static int validate_descriptor_table_v_1_0(const struct vkd3d_shader_root_descri
if (have_srv_uav_cbv && have_sampler)
{
WARN("Samplers cannot be mixed with CBVs/SRVs/UAVs in descriptor tables.\n");
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_RS_MIXED_DESCRIPTOR_RANGE_TYPES,
vkd3d_shader_error(message_context, NULL, VKD3D_SHADER_ERROR_RS_MIXED_DESCRIPTOR_RANGE_TYPES,
"Encountered both CBV/SRV/UAV and sampler descriptor ranges in the same root descriptor table.");
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -3288,7 +3291,7 @@ static int validate_descriptor_table_v_1_1(const struct vkd3d_shader_root_descri
else
{
WARN("Invalid descriptor range type %#x.\n", r->range_type);
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_RS_INVALID_DESCRIPTOR_RANGE_TYPE,
vkd3d_shader_error(message_context, NULL, VKD3D_SHADER_ERROR_RS_INVALID_DESCRIPTOR_RANGE_TYPE,
"Invalid root signature descriptor range type %#x.", r->range_type);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -3297,7 +3300,7 @@ static int validate_descriptor_table_v_1_1(const struct vkd3d_shader_root_descri
if (have_srv_uav_cbv && have_sampler)
{
WARN("Samplers cannot be mixed with CBVs/SRVs/UAVs in descriptor tables.\n");
vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_RS_MIXED_DESCRIPTOR_RANGE_TYPES,
vkd3d_shader_error(message_context, NULL, VKD3D_SHADER_ERROR_RS_MIXED_DESCRIPTOR_RANGE_TYPES,
"Encountered both CBV/SRV/UAV and sampler descriptor ranges in the same root descriptor table.");
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -3345,14 +3348,14 @@ int vkd3d_shader_serialize_root_signature(const struct vkd3d_shader_versioned_ro
*messages = NULL;
memset(&context, 0, sizeof(context));
vkd3d_shader_message_context_init(&context.message_context, VKD3D_SHADER_LOG_INFO, NULL);
vkd3d_shader_message_context_init(&context.message_context, VKD3D_SHADER_LOG_INFO);
if (root_signature->version != VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_0
&& root_signature->version != VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_1)
{
ret = VKD3D_ERROR_INVALID_ARGUMENT;
WARN("Root signature version %#x not supported.\n", root_signature->version);
vkd3d_shader_error(&context.message_context, VKD3D_SHADER_ERROR_RS_INVALID_VERSION,
vkd3d_shader_error(&context.message_context, NULL, VKD3D_SHADER_ERROR_RS_INVALID_VERSION,
"Root signature version %#x is not supported.", root_signature->version);
goto done;
}

View File

@ -2155,6 +2155,7 @@ struct vkd3d_dxbc_compiler
struct vkd3d_spirv_builder spirv_builder;
struct vkd3d_shader_message_context *message_context;
struct vkd3d_shader_location location;
bool failed;
bool strip_debug;
@ -2245,6 +2246,8 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader
memset(compiler, 0, sizeof(*compiler));
compiler->message_context = message_context;
compiler->location.source_name = compile_info->source_name;
compiler->location.line = 2; /* Line 1 is the version token. */
if ((target_info = vkd3d_find_struct(compile_info->next, SPIRV_TARGET_INFO)))
{
@ -2452,7 +2455,7 @@ static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_dxbc_compiler_error(struct vkd3d_dxbc_
va_list args;
va_start(args, format);
vkd3d_shader_verror(compiler->message_context, error, format, args);
vkd3d_shader_verror(compiler->message_context, &compiler->location, error, format, args);
va_end(args);
compiler->failed = true;
}
@ -9194,6 +9197,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler,
FIXME("Unhandled instruction %#x.\n", instruction->handler_idx);
}
++compiler->location.line;
return ret;
}

View File

@ -108,13 +108,9 @@ void vkd3d_string_buffer_trace_(const struct vkd3d_string_buffer *buffer, const
}
void vkd3d_shader_message_context_init(struct vkd3d_shader_message_context *context,
enum vkd3d_shader_log_level log_level, const char *source_name)
enum vkd3d_shader_log_level log_level)
{
context->log_level = log_level;
context->source_name = source_name ? source_name : "<anonymous>";
context->line = 0;
context->column = 0;
vkd3d_string_buffer_init(&context->messages);
}
@ -148,28 +144,37 @@ bool vkd3d_shader_message_context_copy_messages(struct vkd3d_shader_message_cont
return true;
}
void vkd3d_shader_verror(struct vkd3d_shader_message_context *context,
void vkd3d_shader_verror(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location,
enum vkd3d_shader_error error, const char *format, va_list args)
{
if (context->log_level < VKD3D_SHADER_LOG_ERROR)
return;
if (context->line)
vkd3d_string_buffer_printf(&context->messages, "%s:%u:%u: E%04u: ",
context->source_name, context->line, context->column, error);
if (location)
{
const char *source_name = location->source_name ? location->source_name : "<anonymous>";
if (location->line)
vkd3d_string_buffer_printf(&context->messages, "%s:%u:%u: E%04u: ",
source_name, location->line, location->column, error);
else
vkd3d_string_buffer_printf(&context->messages, "%s: E%04u: ", source_name, error);
}
else
vkd3d_string_buffer_printf(&context->messages, "%s: E%04u: ", context->source_name, error);
{
vkd3d_string_buffer_printf(&context->messages, "E%04u: ", error);
}
vkd3d_string_buffer_vprintf(&context->messages, format, args);
vkd3d_string_buffer_printf(&context->messages, "\n");
}
void vkd3d_shader_error(struct vkd3d_shader_message_context *context,
void vkd3d_shader_error(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location,
enum vkd3d_shader_error error, const char *format, ...)
{
va_list args;
va_start(args, format);
vkd3d_shader_verror(context, error, format, args);
vkd3d_shader_verror(context, location, error, format, args);
va_end(args);
}
@ -222,12 +227,13 @@ struct vkd3d_shader_parser
};
static int vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_message_context *message_context)
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
{
struct vkd3d_shader_desc *shader_desc = &parser->shader_desc;
int ret;
if ((ret = shader_extract_from_dxbc(dxbc->code, dxbc->size, message_context, shader_desc)) < 0)
if ((ret = shader_extract_from_dxbc(compile_info->source.code, compile_info->source.size,
message_context, compile_info->source_name, shader_desc)) < 0)
{
WARN("Failed to extract shader, vkd3d result %d.\n", ret);
return ret;
@ -307,6 +313,7 @@ struct vkd3d_shader_scan_context
size_t descriptors_size;
struct vkd3d_shader_message_context *message_context;
struct vkd3d_shader_location location;
struct vkd3d_shader_cf_info
{
@ -332,12 +339,15 @@ struct vkd3d_shader_scan_context
};
static void vkd3d_shader_scan_context_init(struct vkd3d_shader_scan_context *context,
const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info,
struct vkd3d_shader_message_context *message_context)
{
memset(context, 0, sizeof(*context));
context->scan_descriptor_info = scan_descriptor_info;
context->message_context = message_context;
context->location.source_name = compile_info->source_name;
context->location.line = 2; /* Line 1 is the version token. */
}
static void vkd3d_shader_scan_context_cleanup(struct vkd3d_shader_scan_context *context)
@ -606,7 +616,7 @@ static void vkd3d_shader_scan_error(struct vkd3d_shader_scan_context *context,
va_list args;
va_start(args, format);
vkd3d_shader_verror(context->message_context, error, format, args);
vkd3d_shader_verror(context->message_context, &context->location, error, format, args);
va_end(args);
}
@ -774,6 +784,7 @@ static int vkd3d_shader_scan_instruction(struct vkd3d_shader_scan_context *conte
if (vkd3d_shader_instruction_is_uav_counter(instruction))
vkd3d_shader_scan_record_uav_counter(context, &instruction->src[0].reg);
++context->location.line;
return VKD3D_OK;
}
@ -792,9 +803,9 @@ static int scan_dxbc(const struct vkd3d_shader_compile_info *compile_info,
scan_descriptor_info->descriptor_count = 0;
}
vkd3d_shader_scan_context_init(&context, scan_descriptor_info, message_context);
vkd3d_shader_scan_context_init(&context, compile_info, scan_descriptor_info, message_context);
if ((ret = vkd3d_shader_parser_init(&parser, &compile_info->source, message_context)) < 0)
if ((ret = vkd3d_shader_parser_init(&parser, compile_info, message_context)) < 0)
{
vkd3d_shader_scan_context_cleanup(&context);
return ret;
@ -803,8 +814,6 @@ static int scan_dxbc(const struct vkd3d_shader_compile_info *compile_info,
if (TRACE_ON())
vkd3d_shader_trace(parser.data);
message_context->line = 2; /* Line 1 is the version token. */
message_context->column = 1;
while (!shader_sm4_is_end(parser.data, &parser.ptr))
{
shader_sm4_read_instruction(parser.data, &parser.ptr, &instruction);
@ -824,7 +833,6 @@ static int scan_dxbc(const struct vkd3d_shader_compile_info *compile_info,
vkd3d_shader_free_scan_descriptor_info(scan_descriptor_info);
goto done;
}
++message_context->line;
}
ret = VKD3D_OK;
@ -848,7 +856,7 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char
if ((ret = vkd3d_shader_validate_compile_info(compile_info, true)) < 0)
return ret;
vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name);
vkd3d_shader_message_context_init(&message_context, compile_info->log_level);
ret = scan_dxbc(compile_info, &message_context);
@ -877,7 +885,7 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
if ((ret = scan_dxbc(&scan_info, message_context)) < 0)
return ret;
if ((ret = vkd3d_shader_parser_init(&parser, &compile_info->source, message_context)) < 0)
if ((ret = vkd3d_shader_parser_init(&parser, compile_info, message_context)) < 0)
{
vkd3d_shader_free_scan_descriptor_info(&scan_descriptor_info);
return ret;
@ -902,8 +910,6 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
return VKD3D_ERROR;
}
message_context->line = 2; /* Line 1 is the version token. */
message_context->column = 1;
while (!shader_sm4_is_end(parser.data, &parser.ptr))
{
shader_sm4_read_instruction(parser.data, &parser.ptr, &instruction);
@ -917,7 +923,6 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
if ((ret = vkd3d_dxbc_compiler_handle_instruction(spirv_compiler, &instruction)) < 0)
break;
++message_context->line;
}
if (ret >= 0)
@ -949,7 +954,7 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
if ((ret = vkd3d_shader_validate_compile_info(compile_info, true)) < 0)
return ret;
vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name);
vkd3d_shader_message_context_init(&message_context, compile_info->log_level);
switch (compile_info->source_type)
{
@ -1051,7 +1056,7 @@ int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
if (messages)
*messages = NULL;
vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_INFO, NULL);
vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_INFO);
ret = shader_parse_input_signature(dxbc->code, dxbc->size, &message_context, signature);
vkd3d_shader_message_context_trace_messages(&message_context);
@ -1174,7 +1179,7 @@ int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info
if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0)
return ret;
vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name);
vkd3d_shader_message_context_init(&message_context, compile_info->log_level);
ret = preproc_lexer_parse(compile_info, out, &message_context);

View File

@ -844,11 +844,15 @@ int vkd3d_string_buffer_printf(struct vkd3d_string_buffer *buffer,
void vkd3d_string_buffer_trace_(const struct vkd3d_string_buffer *buffer, const char *function) DECLSPEC_HIDDEN;
int vkd3d_string_buffer_vprintf(struct vkd3d_string_buffer *buffer, const char *format, va_list args) DECLSPEC_HIDDEN;
struct vkd3d_shader_location
{
const char *source_name;
unsigned int line, column;
};
struct vkd3d_shader_message_context
{
enum vkd3d_shader_log_level log_level;
const char *source_name;
unsigned int line, column;
struct vkd3d_string_buffer messages;
};
@ -856,18 +860,19 @@ void vkd3d_shader_message_context_cleanup(struct vkd3d_shader_message_context *c
bool vkd3d_shader_message_context_copy_messages(struct vkd3d_shader_message_context *context,
char **out) DECLSPEC_HIDDEN;
void vkd3d_shader_message_context_init(struct vkd3d_shader_message_context *context,
enum vkd3d_shader_log_level log_level, const char *source_name) DECLSPEC_HIDDEN;
enum vkd3d_shader_log_level log_level) 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;
void vkd3d_shader_verror(struct vkd3d_shader_message_context *context,
void vkd3d_shader_error(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location,
enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
void vkd3d_shader_verror(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location,
enum vkd3d_shader_error error, const char *format, va_list args) DECLSPEC_HIDDEN;
int shader_extract_from_dxbc(const void *dxbc, size_t dxbc_length,
struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
struct vkd3d_shader_message_context *message_context, const char *source_name,
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,