mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/glsl: Use location information from the current instruction.
This commit is contained in:
parent
dff22c9ed7
commit
038764985a
Notes:
Alexandre Julliard
2024-03-11 23:07:46 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/702
@ -28,7 +28,7 @@ struct vkd3d_glsl_generator
|
||||
};
|
||||
|
||||
struct vkd3d_glsl_generator *vkd3d_glsl_generator_create(const struct vkd3d_shader_version *version,
|
||||
struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_location *location)
|
||||
struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
struct vkd3d_glsl_generator *generator;
|
||||
|
||||
@ -38,7 +38,6 @@ 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->message_context = message_context;
|
||||
return generator;
|
||||
}
|
||||
@ -73,6 +72,8 @@ static void shader_glsl_ret(struct vkd3d_glsl_generator *generator,
|
||||
static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *generator,
|
||||
const struct vkd3d_shader_instruction *instruction)
|
||||
{
|
||||
generator->location = instruction->location;
|
||||
|
||||
switch (instruction->handler_idx)
|
||||
{
|
||||
case VKD3DSIH_DCL_INPUT:
|
||||
@ -101,10 +102,8 @@ 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 < program->instructions.count; ++i)
|
||||
{
|
||||
generator->location.line = i + 1;
|
||||
vkd3d_glsl_handle_instruction(generator, &program->instructions.elements[i]);
|
||||
}
|
||||
|
||||
|
@ -1553,6 +1553,7 @@ static int vkd3d_shader_parser_compile(struct vkd3d_shader_parser *parser,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
struct vkd3d_shader_scan_descriptor_info1 scan_descriptor_info;
|
||||
struct vsir_program *program = &parser->program;
|
||||
struct vkd3d_glsl_generator *glsl_generator;
|
||||
struct vkd3d_shader_compile_info scan_info;
|
||||
int ret;
|
||||
@ -1562,22 +1563,20 @@ static int vkd3d_shader_parser_compile(struct vkd3d_shader_parser *parser,
|
||||
switch (compile_info->target_type)
|
||||
{
|
||||
case VKD3D_SHADER_TARGET_D3D_ASM:
|
||||
ret = vkd3d_dxbc_binary_to_text(&parser->program, &parser->shader_desc,
|
||||
compile_info, out, VSIR_ASM_FLAG_NONE);
|
||||
ret = vkd3d_dxbc_binary_to_text(program, &parser->shader_desc, compile_info, out, VSIR_ASM_FLAG_NONE);
|
||||
break;
|
||||
|
||||
case VKD3D_SHADER_TARGET_GLSL:
|
||||
if ((ret = scan_with_parser(&scan_info, message_context, &scan_descriptor_info, parser)) < 0)
|
||||
return ret;
|
||||
if (!(glsl_generator = vkd3d_glsl_generator_create(&parser->program.shader_version,
|
||||
message_context, &parser->location)))
|
||||
if (!(glsl_generator = vkd3d_glsl_generator_create(&program->shader_version, message_context)))
|
||||
{
|
||||
ERR("Failed to create GLSL generator.\n");
|
||||
vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
|
||||
return VKD3D_ERROR;
|
||||
}
|
||||
|
||||
ret = vkd3d_glsl_generator_generate(glsl_generator, &parser->program, out);
|
||||
ret = vkd3d_glsl_generator_generate(glsl_generator, program, out);
|
||||
vkd3d_glsl_generator_destroy(glsl_generator);
|
||||
vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
|
||||
break;
|
||||
|
@ -1506,7 +1506,7 @@ int shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
|
||||
struct vkd3d_glsl_generator;
|
||||
|
||||
struct vkd3d_glsl_generator *vkd3d_glsl_generator_create(const struct vkd3d_shader_version *version,
|
||||
struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_location *location);
|
||||
struct vkd3d_shader_message_context *message_context);
|
||||
int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator,
|
||||
struct vsir_program *program, struct vkd3d_shader_code *out);
|
||||
void vkd3d_glsl_generator_destroy(struct vkd3d_glsl_generator *generator);
|
||||
|
Loading…
Reference in New Issue
Block a user