From 5dc1aaef5a9b32e19f42eca382091f74fec67bc1 Mon Sep 17 00:00:00 2001 From: Elie Tournier Date: Fri, 22 May 2020 11:51:19 +0100 Subject: [PATCH] blitter: Move linking outside of vrend_renderer_blit_gl Signed-off-by: Elie Tournier Reviewed-by: Gert Wollny --- src/vrend_blitter.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/vrend_blitter.c b/src/vrend_blitter.c index 83a7c0d..0e18da0 100644 --- a/src/vrend_blitter.c +++ b/src/vrend_blitter.c @@ -100,6 +100,24 @@ static GLint build_and_check(GLenum shader_type, const char *buf) return id; } +static bool link_and_check(GLuint prog_id) +{ + GLint lret; + + glLinkProgram(prog_id); + glGetProgramiv(prog_id, GL_LINK_STATUS, &lret); + if (lret == GL_FALSE) { + char infolog[65536]; + int len; + glGetProgramInfoLog(prog_id, 65536, &len, infolog); + vrend_printf("got error linking\n%s\n", infolog); + /* dump shaders */ + glDeleteProgram(prog_id); + return false; + } + return true; +} + static void create_dest_swizzle_snippet(const uint8_t swizzle[4], char snippet[DEST_SWIZZLE_SNIPPET_SIZE]) { @@ -629,7 +647,6 @@ void vrend_renderer_blit_gl(MAYBE_UNUSED struct vrend_context *ctx, GLuint buffers; GLuint prog_id; GLuint fs_id; - GLint lret; GLuint pos_loc, tc_loc; bool has_depth, has_stencil; bool blit_stencil, blit_depth; @@ -692,17 +709,8 @@ void vrend_renderer_blit_gl(MAYBE_UNUSED struct vrend_context *ctx, } glAttachShader(prog_id, fs_id); - glLinkProgram(prog_id); - glGetProgramiv(prog_id, GL_LINK_STATUS, &lret); - if (lret == GL_FALSE) { - char infolog[65536]; - int len; - glGetProgramInfoLog(prog_id, 65536, &len, infolog); - vrend_printf("got error linking\n%s\n", infolog); - /* dump shaders */ - glDeleteProgram(prog_id); + if(!link_and_check(prog_id)) return; - } glUseProgram(prog_id);