[virglrenderer-devel] [PATCH 05/16] vrend: Detect OpenGL ES being used

Jakob Bornecrantz jakob.bornecrantz at collabora.com
Fri Dec 22 18:57:45 UTC 2017


Detect OpenGL ES context being given to us. This is just the detection code,
it does not do any other fallback or work around. This is required for the
rest of the OpenGL ES code that follows. It is assumed that virgl will not
decide to use OpenGL ES and that is the hardware platform that forces this.

Signed-off-by: Jakob Bornecrantz <jakob.bornecrantz at collabora.com>
---
 src/vrend_renderer.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index e741434..7df9389 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -98,6 +98,7 @@ struct global_renderer_state {
    struct list_head waiting_query_list;
 
    bool inited;
+   bool use_gles;
    bool use_core_profile;
 
    bool have_debug_cb;
@@ -3830,6 +3831,7 @@ static void vrend_debug_cb(GLenum source, GLenum type, GLuint id,
 
 int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
 {
+   bool gles;
    int gl_ver;
    virgl_gl_context gl_context;
    struct virgl_gl_ctx_param ctx_params;
@@ -3856,9 +3858,18 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
       vrend_state.have_debug_cb = true;
    }
 
+   /* make sure you have the latest version of libepoxy */
+   gles = epoxy_is_desktop_gl() == 0;
+
    vrend_state.gl_major_ver = gl_ver / 10;
    vrend_state.gl_minor_ver = gl_ver % 10;
-   if (gl_ver > 30 && !epoxy_has_gl_extension("GL_ARB_compatibility")) {
+
+   if (gles) {
+      fprintf(stderr, "gl_version %d - es profile enabled\n", gl_ver);
+      vrend_state.use_gles = true;
+      /* for now, makes the rest of the code use the most GLES 3.x like path */
+      vrend_state.use_core_profile = 1;
+   } else if (gl_ver > 30 && !epoxy_has_gl_extension("GL_ARB_compatibility")) {
       fprintf(stderr, "gl_version %d - core profile enabled\n", gl_ver);
       vrend_state.use_core_profile = 1;
    } else {
-- 
2.11.0



More information about the virglrenderer-devel mailing list