vkd3d-shader/glsl: Update the current source location in vkd3d_glsl_generator_generate().

Since the introduction of instruction arrays, the parser location no
longer matches the location of the current instruction. Ultimately we'll
likely want to add some kind of explicit location information to struct
vkd3d_shader_instruction_array, because we might do transformations that
change the order of the original instructions.
This commit is contained in:
Henri Verbeet 2023-02-26 04:04:58 +01:00 committed by Alexandre Julliard
parent 685abf9c2d
commit 0a73c75db8
Notes: Alexandre Julliard 2023-03-13 22:21:53 +01:00
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/123

View File

@ -22,7 +22,7 @@ struct vkd3d_glsl_generator
{
struct vkd3d_shader_version version;
struct vkd3d_string_buffer buffer;
const struct vkd3d_shader_location *location;
struct vkd3d_shader_location location;
struct vkd3d_shader_message_context *message_context;
bool failed;
};
@ -38,7 +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 = location;
generator->location = *location;
generator->message_context = message_context;
return generator;
}
@ -50,7 +50,7 @@ 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;
}
@ -99,8 +99,10 @@ int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator,
vkd3d_string_buffer_printf(&generator->buffer, "#version 440\n\n");
vkd3d_string_buffer_printf(&generator->buffer, "void main()\n{\n");
generator->location.column = 0;
for (i = 0; i < parser->instructions.count; ++i)
{
generator->location.line = i + 1;
vkd3d_glsl_handle_instruction(generator, &parser->instructions.elements[i]);
}