vkd3d-shader/glsl: Use the instruction array interface in vkd3d_glsl_generator_generate().

This commit is contained in:
Conor McCarthy 2023-01-20 12:24:20 +10:00 committed by Alexandre Julliard
parent 2559d622de
commit 2d3f05184f
Notes: Alexandre Julliard 2023-01-24 22:28:12 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/60

View File

@ -93,28 +93,18 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *generator
int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator,
struct vkd3d_shader_parser *parser, struct vkd3d_shader_code *out)
{
unsigned int i;
void *code;
struct vkd3d_shader_instruction ins;
vkd3d_string_buffer_printf(&generator->buffer, "#version 440\n\n");
vkd3d_string_buffer_printf(&generator->buffer, "void main()\n{\n");
while (!vkd3d_shader_parser_is_end(parser))
for (i = 0; i < parser->instructions.count; ++i)
{
vkd3d_shader_parser_read_instruction(parser, &ins);
if (ins.handler_idx == VKD3DSIH_INVALID)
{
vkd3d_glsl_compiler_error(generator,
VKD3D_SHADER_ERROR_GLSL_INTERNAL,
"Encountered unrecognized or invalid instruction.");
break;
}
vkd3d_glsl_handle_instruction(generator, &ins);
vkd3d_glsl_handle_instruction(generator, &parser->instructions.elements[i]);
}
if (parser->failed || generator->failed)
if (generator->failed)
return VKD3D_ERROR_INVALID_SHADER;
vkd3d_string_buffer_printf(&generator->buffer, "}\n");