Ok. That requires to have the parser available in `struct vsir_cfg`, maybe at some point it should be clarified what's the target relationship between a program, a parser and VSIR passes.
Well, if you have a struct vkd3d_shader_message_context, you can just call vkd3d_shader_error(). Note that the location from header->begin->location is likely to be a fair bit more accurate than whatever is in cfg->parser->location.
And perhaps that's good enough. I.e., we store the message context in struct vsir_cfg and similar IR pass structures, and then use vkd3d_shader_error(), vkd3d_shader_warning(), etc.
We could conceivably also do something like this: ```c struct vsir_pass { struct vkd3d_shader_message_context *message_context; struct vsir_program *program; struct vkd3d_shader_instruction *current; bool failed; ... };
void VKD3D_PRINTF_FUNC(3, 4) vsir_pass_error(struct vsir_pass *pass, enum vkd3d_shader_error error, const char *format, ...) { va_list args;
va_start(args, format); vkd3d_shader_verror(pass->message_context, &pass->current->location, error, format, args); va_end(args);
pass->failed = true; } ```
I'm not too set on the naming; you could probably make a compelling argument for calling this something like struct vsir_compiler/vsir_compiler_error() as well.
As for struct vkd3d_shader_parser, to the extent that it's still useful now that the backends have been decoupled from the frontends, it should be confined to the actual parsers. I.e., I think we'd want something like compile_dxbc_tpf() to work roughly like this:
```c static int vsir_program_compile(struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_code *out) { ...
switch (compile_info->target_type) { ... case VKD3D_SHADER_TARGET_SPIRV_BINARY: case VKD3D_SHADER_TARGET_SPIRV_TEXT: return spirv_compile(program, compile_info, message_context, ..., out); ... } ... }
static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_code *out) { struct vsir_program program; int ret;
if ((ret = vkd3d_shader_parse_dxbc_tpf(compile_info, message_context, &program)) < 0) { WARN("Failed to parse shader.\n"); return ret; }
ret = vsir_program_compile(program, compile_info, message_context, out);
vsir_program_cleanup(&program); return ret; } ```