From ba349a176ecbb15c701c7401930d4f4fe545c999 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 6 Aug 2018 19:19:28 +0200 Subject: [PATCH] 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 Reviewed-by: Gurchetan Singh Signed-off-by: Dave Airlie --- src/vrend_shader.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 2984e8e..6e7a45c 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;