From 3e87ee63f7b102fcddf6f173acd254b3d4b0f489 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 28 Jan 2019 16:30:32 +0100 Subject: [PATCH] shader: When on GLES require EXT_clip_cull_distance for gl_ClipDistance This is needed for guest GL >= 3.0 on GLES. Signed-off-by: Gert Wollny Reviewed-by: Signed-off-by: Dave Airlie --- src/vrend_shader.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 824b6e3..6fc047e 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -65,6 +65,7 @@ #define SHADER_REQ_SHADER_CLOCK (1 << 20) #define SHADER_REQ_PSIZE (1 << 21) #define SHADER_REQ_IMAGE_ATOMIC (1 << 22) +#define SHADER_REQ_CLIP_DISTANCE (1 << 23) struct vrend_shader_io { unsigned name; @@ -867,12 +868,14 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->inputs[i].glsl_no_index = true; ctx->inputs[i].glsl_gl_block = true; ctx->num_in_clip_dist += 4; + ctx->shader_req_bits |= SHADER_REQ_CLIP_DISTANCE; break; } else if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { name_prefix = "gl_ClipDistance"; ctx->inputs[i].glsl_predefined_no_emit = true; ctx->inputs[i].glsl_no_index = true; ctx->num_in_clip_dist += 4; + ctx->shader_req_bits |= SHADER_REQ_CLIP_DISTANCE; break; } /* fallthrough */ @@ -1024,6 +1027,7 @@ iter_declaration(struct tgsi_iterate_context *iter, } break; case TGSI_SEMANTIC_CLIPDIST: + ctx->shader_req_bits |= SHADER_REQ_CLIP_DISTANCE; name_prefix = "gl_ClipDistance"; ctx->outputs[i].glsl_predefined_no_emit = true; ctx->outputs[i].glsl_no_index = true; @@ -1381,6 +1385,7 @@ iter_property(struct tgsi_iterate_context *iter, } if (prop->Property.PropertyName == TGSI_PROPERTY_NUM_CLIPDIST_ENABLED) { + ctx->shader_req_bits |= SHADER_REQ_CLIP_DISTANCE; ctx->num_clip_dist_prop = prop->u[0].Data; } @@ -3859,6 +3864,11 @@ static void emit_header(struct dump_ctx *ctx) PAD_GPU_MSINTERPOL(ctx); } + if ((ctx->shader_req_bits & SHADER_REQ_CLIP_DISTANCE)|| + (ctx->num_clip_dist == 0 && ctx->key->clip_plane_enable)) { + emit_ext(ctx, "EXT_clip_cull_distance", "require"); + } + if (ctx->shader_req_bits & SHADER_REQ_SAMPLER_MS) emit_ext(ctx, "OES_texture_storage_multisample_2d_array", "require");