From: Henri Verbeet hverbeet@codeweavers.com
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. --- libs/vkd3d-shader/glsl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index 1fe3f258..f8d68b5a 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -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]); }
From: Henri Verbeet hverbeet@codeweavers.com
--- libs/vkd3d-shader/spirv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index beee1548..982aabf9 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2223,7 +2223,7 @@ struct spirv_compiler struct vkd3d_spirv_builder spirv_builder;
struct vkd3d_shader_message_context *message_context; - const struct vkd3d_shader_location *location; + struct vkd3d_shader_location location; bool failed;
bool strip_debug; @@ -2323,7 +2323,7 @@ struct spirv_compiler *spirv_compiler_create(const struct vkd3d_shader_version *
memset(compiler, 0, sizeof(*compiler)); compiler->message_context = message_context; - compiler->location = location; + compiler->location = *location;
if ((target_info = vkd3d_find_struct(compile_info->next, SPIRV_TARGET_INFO))) { @@ -2566,7 +2566,7 @@ static void VKD3D_PRINTF_FUNC(3, 4) spirv_compiler_error(struct spirv_compiler * 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; } @@ -9959,8 +9959,10 @@ int spirv_compiler_generate_spirv(struct spirv_compiler *compiler, enum vkd3d_result result = VKD3D_OK; unsigned int i;
+ compiler->location.column = 0; for (i = 0; i < instructions->count; ++i) { + compiler->location.line = i + 1; if ((result = spirv_compiler_handle_instruction(compiler, &instructions->elements[i])) < 0) return result; }