[virglrenderer-devel] [PATCH] vrend: don't hardcode context version

Dave Airlie airlied at gmail.com
Fri Feb 16 02:25:17 UTC 2018


On 16 February 2018 at 11:18, Gurchetan Singh
<gurchetansingh at chromium.org> wrote:
> Currently, we always try to create an OpenGL 3.1 context. Some
> dEQP tests require an OpenGL 3.2 context (specifically, ones
> that use glGetInteger64v). Let's try to create the highest
> version context we can, and iterate to lower versions, i.e:
>
> https://developer.android.com/guide/topics/graphics/opengl.html#version-check

This comes down to what I think is a different in the nvidia and mesa
drivers in that when you ask
for a specifc context nvidia returns the context, mesa returns the
latest context available
the spec allows both behaviours I think, at least CTS never tests any other way,

It does seem like this is most compatible with both.

I'll apply it and we can see if it has any bad side effects.

It does seems like if the host only exposes GL3.1 then we need to
restrict the guest to GL3.1
somehow, and we should only do those queries on the host side on gl3.2 or above.

Dave.

>
> The return code for (*create_gl_context) is a little unclear.
> This patch assumes NULL is returned on failure. This should work
> for GLX and EGL.
>
> GLX:
>
> "On failure glXCreateContextAttribsARB returns NULL and generates
> an X error with extended error information"
>
> https://www.khronos.org/registry/OpenGL/extensions/ARB/GLX_ARB_create_context.txt
>
> EGL:
>
> "#define EGL_NO_CONTEXT ((EGLContext)0)"
>
> https://www.khronos.org/registry/EGL/api/1.1/EGL/egl.h
>
> The semantics of rcbs->create_gl_context may be different, though.
>
> Fixes:
>    dEQP-GLES3.functional.state_query.integers.max_vertex_output_components_getinteger64
>    dEQP-GLES3.functional.state_query.integers.max_vertex_output_components_getfloat
> ---
>  src/vrend_blitter.c  | 11 ++++++++---
>  src/vrend_renderer.c | 11 ++++++++---
>  src/vrend_renderer.h | 10 ++++++++--
>  3 files changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/src/vrend_blitter.c b/src/vrend_blitter.c
> index 0b4112a..bac82d3 100644
> --- a/src/vrend_blitter.c
> +++ b/src/vrend_blitter.c
> @@ -363,9 +363,14 @@ static void vrend_renderer_init_blit_ctx(struct vrend_blitter_ctx *blit_ctx)
>
>     blit_ctx->initialised = true;
>     ctx_params.shared = true;
> -   ctx_params.major_ver = VREND_GL_VER_MAJOR;
> -   ctx_params.minor_ver = VREND_GL_VER_MINOR;
> -   blit_ctx->gl_context = vrend_clicbs->create_gl_context(0, &ctx_params);
> +   for (uint32_t i = 0; i < ARRAY_SIZE(gl_versions); i++) {
> +      ctx_params.major_ver = gl_versions[i].major;
> +      ctx_params.minor_ver = gl_versions[i].minor;
> +
> +      blit_ctx->gl_context = vrend_clicbs->create_gl_context(0, &ctx_params);
> +      if (blit_ctx->gl_context)
> +         break;
> +   }
>
>     vrend_clicbs->make_current(0, blit_ctx->gl_context);
>     glGenVertexArrays(1, &blit_ctx->vaoid);
> diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> index 0d078cc..91a39d3 100644
> --- a/src/vrend_renderer.c
> +++ b/src/vrend_renderer.c
> @@ -3984,10 +3984,15 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
>     }
>
>     ctx_params.shared = false;
> -   ctx_params.major_ver = VREND_GL_VER_MAJOR;
> -   ctx_params.minor_ver = VREND_GL_VER_MINOR;
> +   for (uint32_t i = 0; i < ARRAY_SIZE(gl_versions); i++) {
> +      ctx_params.major_ver = gl_versions[i].major;
> +      ctx_params.minor_ver = gl_versions[i].minor;
> +
> +      gl_context = vrend_clicbs->create_gl_context(0, &ctx_params);
> +      if (gl_context)
> +         break;
> +   }
>
> -   gl_context = vrend_clicbs->create_gl_context(0, &ctx_params);
>     vrend_clicbs->make_current(0, gl_context);
>     gl_ver = epoxy_gl_version();
>
> diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h
> index 71d14c4..715729c 100644
> --- a/src/vrend_renderer.h
> +++ b/src/vrend_renderer.h
> @@ -376,8 +376,14 @@ void vrend_renderer_blit_gl(struct vrend_context *ctx,
>  void vrend_renderer_reset(void);
>  int vrend_renderer_get_poll_fd(void);
>  void vrend_decode_reset(bool ctx_0_only);
> -#define VREND_GL_VER_MAJOR 3
> -#define VREND_GL_VER_MINOR 1
> +
> +struct gl_version {
> +   uint32_t major;
> +   uint32_t minor;
> +};
> +
> +static const struct gl_version gl_versions[] = { {4,5}, {4,4}, {4,3}, {4,2}, {4,1}, {4,0},
> +                                                 {3,3}, {3,2}, {3,1}, {3,0} };
>
>  extern struct vrend_if_cbs *vrend_clicbs;
>  #endif
> --
> 2.16.1.291.g4437f3f132-goog
>
> _______________________________________________
> virglrenderer-devel mailing list
> virglrenderer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel


More information about the virglrenderer-devel mailing list