Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 11 +++++++---- libs/vkd3d-shader/glsl.c | 14 ++++---------- libs/vkd3d-shader/spirv.c | 10 ++++------ libs/vkd3d-shader/vkd3d_shader_main.c | 13 +++++++++---- libs/vkd3d-shader/vkd3d_shader_private.h | 21 +++++++++++---------- 5 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index cc5b1b8d..f6d99ea6 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -970,8 +970,9 @@ static enum vkd3d_data_type map_data_type(char t) } }
-static bool shader_sm4_init(struct vkd3d_shader_sm4_parser *sm4, const uint32_t *byte_code, size_t byte_code_size, - const struct vkd3d_shader_signature *output_signature, struct vkd3d_shader_message_context *message_context) +static bool shader_sm4_init(struct vkd3d_shader_sm4_parser *sm4, const uint32_t *byte_code, + size_t byte_code_size, const char *source_name, const struct vkd3d_shader_signature *output_signature, + struct vkd3d_shader_message_context *message_context) { struct vkd3d_shader_version version; uint32_t version_token, token_count; @@ -1029,7 +1030,7 @@ static bool shader_sm4_init(struct vkd3d_shader_sm4_parser *sm4, const uint32_t version.major = VKD3D_SM4_VERSION_MAJOR(version_token); version.minor = VKD3D_SM4_VERSION_MINOR(version_token);
- vkd3d_shader_parser_init(&sm4->p, message_context, &version); + vkd3d_shader_parser_init(&sm4->p, message_context, source_name, &version); sm4->p.ptr = sm4->start;
memset(sm4->output_map, 0xff, sizeof(sm4->output_map)); @@ -1550,6 +1551,8 @@ void shader_sm4_read_instruction(struct vkd3d_shader_parser *parser, struct vkd3 } remaining = sm4->end - *ptr;
+ ++parser->location.line; + opcode_token = *(*ptr)++; opcode = opcode_token & VKD3D_SM4_OPCODE_MASK;
@@ -1687,7 +1690,7 @@ int vkd3d_shader_sm4_parser_create(const struct vkd3d_shader_compile_info *compi }
if (!shader_sm4_init(sm4, shader_desc->byte_code, shader_desc->byte_code_size, - &shader_desc->output_signature, message_context)) + compile_info->source_name, &shader_desc->output_signature, message_context)) { WARN("Failed to initialise shader parser.\n"); free_shader_desc(shader_desc); diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index 7e028d23..9858098b 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -22,14 +22,13 @@ struct vkd3d_glsl_generator { struct vkd3d_shader_version version; struct vkd3d_string_buffer buffer; - struct vkd3d_shader_location location; + const struct vkd3d_shader_location *location; struct vkd3d_shader_message_context *message_context; bool failed; };
struct vkd3d_glsl_generator *vkd3d_glsl_generator_create(const struct vkd3d_shader_version *version, - const struct vkd3d_shader_compile_info *compile_info, - struct vkd3d_shader_message_context *message_context) + struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_location *location) { struct vkd3d_glsl_generator *generator;
@@ -39,8 +38,7 @@ struct vkd3d_glsl_generator *vkd3d_glsl_generator_create(const struct vkd3d_shad memset(generator, 0, sizeof(*generator)); generator->version = *version; vkd3d_string_buffer_init(&generator->buffer); - generator->location.source_name = compile_info->source_name; - generator->location.line = 2; /* Line 1 is the version token. */ + generator->location = location; generator->message_context = message_context; return generator; } @@ -52,10 +50,9 @@ static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_glsl_compiler_error( va_list args;
va_start(args, fmt); - vkd3d_shader_verror(generator->message_context, &generator->location, error, fmt, args); + vkd3d_shader_verror(generator->message_context, generator->location, error, fmt, args); va_end(args); generator->failed = true; - return; }
static void shader_glsl_ret(struct vkd3d_glsl_generator *generator, @@ -91,9 +88,6 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *generator "Unhandled instruction %#x", instruction->handler_idx); break; } - - ++generator->location.line; - return; }
int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator, diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index f604b8ef..0be17e39 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2208,7 +2208,7 @@ struct vkd3d_dxbc_compiler struct vkd3d_spirv_builder spirv_builder;
struct vkd3d_shader_message_context *message_context; - struct vkd3d_shader_location location; + const struct vkd3d_shader_location *location; bool failed;
bool strip_debug; @@ -2286,7 +2286,7 @@ static const char *vkd3d_dxbc_compiler_get_entry_point_name(const struct vkd3d_d struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader_version *shader_version, const struct vkd3d_shader_desc *shader_desc, const struct vkd3d_shader_compile_info *compile_info, const struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info, - struct vkd3d_shader_message_context *message_context) + struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_location *location) { const struct vkd3d_shader_signature *patch_constant_signature = &shader_desc->patch_constant_signature; const struct vkd3d_shader_signature *output_signature = &shader_desc->output_signature; @@ -2301,8 +2301,7 @@ 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. */ + compiler->location = location;
if ((target_info = vkd3d_find_struct(compile_info->next, SPIRV_TARGET_INFO))) { @@ -2518,7 +2517,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, &compiler->location, error, format, args); + vkd3d_shader_verror(compiler->message_context, compiler->location, error, format, args); va_end(args); compiler->failed = true; } @@ -9747,7 +9746,6 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, FIXME("Unhandled instruction %#x.\n", instruction->handler_idx); }
- ++compiler->location.line; return ret; }
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index ef3ed955..c566ac3d 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -373,9 +373,13 @@ void vkd3d_shader_dump_shader(enum vkd3d_shader_source_type source_type, }
void vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser, - struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_version *version) + struct vkd3d_shader_message_context *message_context, const char *source_name, + const struct vkd3d_shader_version *version) { parser->message_context = message_context; + parser->location.source_name = source_name; + parser->location.line = 1; + parser->location.column = 0; parser->shader_version = *version; }
@@ -1049,7 +1053,8 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info { struct vkd3d_glsl_generator *glsl_generator;
- if (!(glsl_generator = vkd3d_glsl_generator_create(&parser->shader_version, compile_info, message_context))) + if (!(glsl_generator = vkd3d_glsl_generator_create(&parser->shader_version, + message_context, &parser->location))) { ERR("Failed to create GLSL generator.\n"); vkd3d_shader_parser_destroy(parser); @@ -1065,8 +1070,8 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info return ret; }
- if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser->shader_version, - &parser->shader_desc, compile_info, &scan_descriptor_info, message_context))) + if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser->shader_version, &parser->shader_desc, + compile_info, &scan_descriptor_info, message_context, &parser->location))) { ERR("Failed to create DXBC compiler.\n"); vkd3d_shader_parser_destroy(parser); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 87d21381..0f1967bf 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -887,9 +887,16 @@ static inline bool vkd3d_shader_register_is_output(const struct vkd3d_shader_reg return reg->type == VKD3DSPR_OUTPUT || reg->type == VKD3DSPR_COLOROUT; }
+struct vkd3d_shader_location +{ + const char *source_name; + unsigned int line, column; +}; + struct vkd3d_shader_parser { struct vkd3d_shader_message_context *message_context; + struct vkd3d_shader_location location;
struct vkd3d_shader_desc shader_desc; struct vkd3d_shader_version shader_version; @@ -897,7 +904,8 @@ struct vkd3d_shader_parser };
void vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser, - struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_version *version); + struct vkd3d_shader_message_context *message_context, const char *source_name, + const struct vkd3d_shader_version *version);
void vkd3d_shader_trace(struct vkd3d_shader_parser *parser);
@@ -967,12 +975,6 @@ static inline size_t bytecode_get_size(struct vkd3d_bytecode_buffer *buffer) return buffer->size; }
-struct vkd3d_shader_location -{ - const char *source_name; - unsigned int line, column; -}; - struct vkd3d_shader_message_context { enum vkd3d_shader_log_level log_level; @@ -1015,8 +1017,7 @@ int shader_parse_input_signature(const void *dxbc, size_t dxbc_length, struct vkd3d_glsl_generator;
struct vkd3d_glsl_generator *vkd3d_glsl_generator_create(const struct vkd3d_shader_version *version, - const struct vkd3d_shader_compile_info *compile_info, - struct vkd3d_shader_message_context *message_context); + struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_location *location); int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator, struct vkd3d_shader_parser *parser, struct vkd3d_shader_code *out); void vkd3d_glsl_generator_destroy(struct vkd3d_glsl_generator *generator); @@ -1026,7 +1027,7 @@ struct vkd3d_dxbc_compiler; struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader_version *shader_version, const struct vkd3d_shader_desc *shader_desc, const struct vkd3d_shader_compile_info *compile_info, const struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info, - struct vkd3d_shader_message_context *message_context); + struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_location *location); int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction); int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,