[virglrenderer-devel] [PATCH 3/4] vrend_shader: emit readonly-images

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


OpenGL ES 3.1 only supports writing to a few formats, while it can
read from all of them. So let's make sure we emit readonly, so the
OpenGL driver knows we'll only read.

This avoids a shader-compiler error on OpenGL ES 3.1.

Signed-off-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
---

This patch depends on a mesa-patch to work, because the Wriable flag
gets incorrectly set on these image-declarations.

 src/vrend_shader.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index ee92795..898a245 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -4678,14 +4678,18 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
          const char *stc;
          char ptc;
          const char *volatile_str = (ctx->images[idx].vflag) ? "volatile " : "";
-         const char *writeonly = (ctx->images[idx].decl.Format) ? "" : "writeonly ";
+         const char *access = "";
          const char *formatstr;
          enum tgsi_return_type itype;
          formatstr = get_internalformat_string(ctx->images[idx].decl.Format, &itype);
          ptc = vrend_shader_samplerreturnconv(itype);
          sname = tgsi_proc_to_prefix(ctx->prog_type);
          stc = vrend_shader_samplertypeconv(ctx->images[idx].decl.Resource, &is_shad);
-         snprintf(buf, 255, "layout(binding=%d%s) %s%suniform %cimage%s %simg%d[%d];\n", idx, formatstr, writeonly, volatile_str, ptc, stc, sname, idx, ctx->image_arrays[i].array_size);
+         if (!ctx->images[idx].decl.Writable)
+            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);
          STRCAT_WITH_RET(glsl_hdr, buf);
       }
    } else {
@@ -4697,14 +4701,18 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
 
          i = u_bit_scan(&mask);
          const char *volatile_str = (ctx->images[i].vflag) ? "volatile " : "";
-         const char *writeonly = (ctx->images[i].decl.Format) ? "" : "writeonly ";
+         const char *access = "";
          const char *formatstr;
          enum tgsi_return_type itype;
          formatstr = get_internalformat_string(ctx->images[i].decl.Format, &itype);
          ptc = vrend_shader_samplerreturnconv(itype);
          sname = tgsi_proc_to_prefix(ctx->prog_type);
          stc = vrend_shader_samplertypeconv(ctx->images[i].decl.Resource, &is_shad);
-         snprintf(buf, 255, "layout(binding=%d%s) %s%suniform %cimage%s %simg%d;\n", i, formatstr, writeonly, volatile_str, ptc, stc, sname, i);
+         if (!ctx->images[i].decl.Writable)
+            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);
          STRCAT_WITH_RET(glsl_hdr, buf);
       }
    }
-- 
2.18.0



More information about the virglrenderer-devel mailing list