From d61fc12340939dc3c15a2519f6e58ab427792a61 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Sun, 16 Dec 2018 16:29:00 +0100 Subject: [PATCH] shader: Emit winsys_adjust_y only once per FS shader If more then one input variable is tagged as requiring winsys_adjust_y then this variable would be declared more then once and consequently compiling the shader would fail. Keep track of whether the variable was already declared to make sure it is emitted only once. Closes: #72 Signed-off-by: Gert Wollny Signed-off-by: Dave Airlie --- src/vrend_renderer.c | 1 + src/vrend_shader.c | 2 ++ src/vrend_shader.h | 1 + 3 files changed, 4 insertions(+) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index a325f9e..2103f66 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -2804,6 +2804,7 @@ static inline void vrend_fill_shader_key(struct vrend_context *ctx, } key->invert_fs_origin = !ctx->sub->inverted_fbo_content; key->coord_replace = ctx->sub->rs_state.point_quad_rasterization ? ctx->sub->rs_state.sprite_coord_enable : 0; + key->winsys_adjust_y_emitted = false; if (ctx->sub->shaders[PIPE_SHADER_GEOMETRY]) key->gs_present = true; diff --git a/src/vrend_shader.c b/src/vrend_shader.c index a3e3b01..08053b9 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -4613,8 +4613,10 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr) } if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT && ctx->cfg->use_gles && + !ctx->key->winsys_adjust_y_emitted && (ctx->key->coord_replace & (1 << ctx->inputs[i].sid))) { snprintf(buf, 255, "uniform float winsys_adjust_y;\n"); + ctx->key->winsys_adjust_y_emitted = true; STRCAT_WITH_RET(glsl_hdr, buf); } } diff --git a/src/vrend_shader.h b/src/vrend_shader.h index fbcdf63..cb928e6 100644 --- a/src/vrend_shader.h +++ b/src/vrend_shader.h @@ -82,6 +82,7 @@ struct vrend_shader_info { struct vrend_shader_key { uint32_t coord_replace; + bool winsys_adjust_y_emitted; bool invert_fs_origin; bool pstipple_tex; bool add_alpha_test;