[virglrenderer-devel] [PATCH 4/4] vrend_shader: emit precision for images on GLSL

Erik Faye-Lund erik.faye-lund at collabora.com
Mon Aug 6 18:38:12 UTC 2018


In 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.

image-Signed-off-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
---
 src/vrend_shader.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 898a245..b567b8f 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -4680,6 +4680,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
          const char *volatile_str = (ctx->images[idx].vflag) ? "volatile " : "";
          const char *access = "";
          const char *formatstr;
+         const char *precision = ctx->cfg->use_gles ? "highp " : "";
          enum tgsi_return_type itype;
          formatstr = get_internalformat_string(ctx->images[idx].decl.Format, &itype);
          ptc = vrend_shader_samplerreturnconv(itype);
@@ -4689,7 +4690,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
             access = "readonly ";
          else if (!ctx->images[idx].decl.Format)
             access = "writeonly ";
-         snprintf(buf, 255, "layout(binding=%d%s) %s%suniform %cimage%s %simg%d[%d];\n", idx, formatstr, access, volatile_str, ptc, stc, sname, idx, ctx->image_arrays[i].array_size);
+         snprintf(buf, 255, "layout(binding=%d%s) %s%suniform %s%cimage%s %simg%d[%d];\n", idx, formatstr, access, volatile_str, precision, ptc, stc, sname, idx, ctx->image_arrays[i].array_size);
          STRCAT_WITH_RET(glsl_hdr, buf);
       }
    } else {
@@ -4703,6 +4704,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
          const char *volatile_str = (ctx->images[i].vflag) ? "volatile " : "";
          const char *access = "";
          const char *formatstr;
+         const char *precision = ctx->cfg->use_gles ? "highp " : "";
          enum tgsi_return_type itype;
          formatstr = get_internalformat_string(ctx->images[i].decl.Format, &itype);
          ptc = vrend_shader_samplerreturnconv(itype);
@@ -4712,7 +4714,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
             access = "readonly ";
          else if (!ctx->images[i].decl.Format)
             access = "writeonly ";
-         snprintf(buf, 255, "layout(binding=%d%s) %s%suniform %cimage%s %simg%d;\n", i, formatstr, access, volatile_str, ptc, stc, sname, i);
+         snprintf(buf, 255, "layout(binding=%d%s) %s%suniform %s%cimage%s %simg%d;\n", i, formatstr, access, volatile_str, precision, ptc, stc, sname, i);
          STRCAT_WITH_RET(glsl_hdr, buf);
       }
    }
-- 
2.18.0



More information about the virglrenderer-devel mailing list