From 8a60814476b1b05ef72ae78e9ded80d4c03c3b1a Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 17 Nov 2023 07:06:11 +0100 Subject: [PATCH] vkd3d-shader/glsl: Generate comments for unhandled instructions. Mostly for debugging purposes; we'll fail compilation, but will still trace the shader that would have been generated. --- libs/vkd3d-shader/glsl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index 2971f577..23ea89c4 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -39,6 +39,13 @@ static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_glsl_compiler_error( generator->failed = true; } +static void shader_glsl_unhandled(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins) +{ + vkd3d_string_buffer_printf(&gen->buffer, "/* */\n", ins->handler_idx); + vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, + "Internal compiler error: Unhandled instruction %#x.", ins->handler_idx); +} + static void shader_glsl_ret(struct vkd3d_glsl_generator *generator, const struct vkd3d_shader_instruction *ins) { @@ -69,9 +76,7 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *generator shader_glsl_ret(generator, instruction); break; default: - vkd3d_glsl_compiler_error(generator, - VKD3D_SHADER_ERROR_GLSL_INTERNAL, - "Unhandled instruction %#x", instruction->handler_idx); + shader_glsl_unhandled(generator, instruction); break; } }