aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2018-08-06 19:19:28 +0200
committerDave Airlie <airlied@redhat.com>2018-08-13 15:45:45 +1000
commitba349a176ecbb15c701c7401930d4f4fe545c999 (patch)
tree70c9ce21c9789550b560f5a4a706f5514d025d8d
parentf97bec17994825352103e0527a46925941e2c94f (diff)
downloadvirglrenderer-ba349a176ecbb15c701c7401930d4f4fe545c999.tar.gz
shader: emit readonly-images
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@collabora.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--src/vrend_shader.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 2984e8e5..6e7a45c0 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -4284,12 +4284,17 @@ 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 *writeonly = image->decl.Format ? "" : "writeonly ";
+ const char *access = "";
formatstr = get_internalformat_string(image->decl.Format, &itype);
ptc = vrend_shader_samplerreturnconv(itype);
sname = tgsi_proc_to_prefix(ctx->prog_type);
stc = vrend_shader_samplertypeconv(image->decl.Resource, &is_shad);
+ if (!image->decl.Writable)
+ access = "readonly ";
+ else if (!image->decl.Format)
+ access = "writeonly ";
+
if (ctx->cfg->use_gles) { /* TODO: enable on OpenGL 4.2 and up also */
snprintf(buf, 255, "layout(binding=%d%s%s) ",
i, formatstr[0] != '\0' ? ", " : "", formatstr);
@@ -4301,10 +4306,10 @@ 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",
- writeonly, volatile_str, ptc, stc, sname, i, range);
+ access, volatile_str, ptc, stc, sname, i, range);
else
snprintf(buf, 255, "%s%suniform %cimage%s %simg%d;\n",
- writeonly, volatile_str, ptc, stc, sname, i);
+ access, volatile_str, ptc, stc, sname, i);
STRCAT_WITH_RET(glsl_hdr, buf);
return glsl_hdr;