From 4a4f04827cb78afba6814bd686d15b58be164ab3 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 15 Apr 2019 16:10:50 +0200 Subject: [PATCH] vrend: Lie yet a bit more about the GLSL feature level on GLES hosts To properly use compute shaders in the guest when running on a GL ES host it is better to advertice GLSL level 430, because otherwise compute shaders that don't explicitely add the extension ARB_compute_shaders to the shader will not compile. Fixes #99 v2: Add comment about why we want to advertise this feature level (Gurchetan) v3: Don't bypass checks for level 400 Signed-off-by: Gert Wollny Reviewed-by: Gurchetan Singh --- src/vrend_renderer.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index e0dcd40..399edbb 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -8557,13 +8557,29 @@ static void vrend_fill_caps_glsl_version(int gl_ver, int gles_ver, if (caps->v1.glsl_level < 400) { if (has_feature(feat_tessellation) && has_feature(feat_geometry_shader) && - has_feature(feat_gpu_shader5)) + has_feature(feat_gpu_shader5)) { /* This is probably a lie, but Gallium enables * OES_geometry_shader and ARB_gpu_shader5 * based on this value, apart from that it doesn't * seem to be a crucial value */ - caps->v1.glsl_level = has_feature(feat_separate_shader_objects) ? 410 : 400; + caps->v1.glsl_level = 400; + + /* Let's lie a bit more */ + if (has_feature(feat_separate_shader_objects)) { + caps->v1.glsl_level = 410; + + /* Compute shaders require GLSL 4.30 unless the shader explicitely + * specifies GL_ARB_compute_shader as required. However, on OpenGL ES + * they are already supported with version 3.10, so if we already + * advertise a feature level of 410, just lie a bit more to make + * compute shaders available to GL programs that don't specify the + * extension within the shaders. */ + if (has_feature(feat_compute_shader)) + caps->v1.glsl_level = 430; + } + } } + vrend_printf("GLSL feature level %d\n", caps->v1.glsl_level); } static void set_format_bit(struct virgl_supported_format_mask *mask, enum virgl_formats fmt)