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 <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Erik Faye-Lund 6 years ago committed by Dave Airlie
parent ba349a176e
commit 510325e216
  1. 9
      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;

Loading…
Cancel
Save