From 510325e216760370d137cba9b45534ea2a3e1052 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 6 Aug 2018 19:47:40 +0200 Subject: [PATCH] shader: emit precision for images on GLSL When using OpenGL ES 3.1, we either need to emit a precision qualifier, or set a default precision. Since it's not unthinkable that we'd want to forward lowp/mediump in the future, let's use the precision qualifier so it's easier to get this right later on. This gets rid of a shader compile error. Signed-off-by: Erik Faye-Lund Reviewed-by: Gurchetan Singh Signed-off-by: Dave Airlie --- src/vrend_shader.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 6e7a45c..c794cc4 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -4284,6 +4284,7 @@ static void *emit_image_decl(const struct dump_ctx *ctx, char *glsl_hdr, const char *sname, *stc, *formatstr; enum tgsi_return_type itype; const char *volatile_str = image->vflag ? "volatile " : ""; + const char *precision = ctx->cfg->use_gles ? "highp " : ""; const char *access = ""; formatstr = get_internalformat_string(image->decl.Format, &itype); ptc = vrend_shader_samplerreturnconv(itype); @@ -4305,11 +4306,11 @@ static void *emit_image_decl(const struct dump_ctx *ctx, char *glsl_hdr, } if (range) - snprintf(buf, 255, "%s%suniform %cimage%s %simg%d[%d];\n", - access, volatile_str, ptc, stc, sname, i, range); + snprintf(buf, 255, "%s%suniform %s%cimage%s %simg%d[%d];\n", + access, volatile_str, precision, ptc, stc, sname, i, range); else - snprintf(buf, 255, "%s%suniform %cimage%s %simg%d;\n", - access, volatile_str, ptc, stc, sname, i); + snprintf(buf, 255, "%s%suniform %s%cimage%s %simg%d;\n", + access, volatile_str, precision, ptc, stc, sname, i); STRCAT_WITH_RET(glsl_hdr, buf); return glsl_hdr;