From fb4f7577f7ef538984a4bcbe16277692f78475f8 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 16 Oct 2018 17:34:39 +0200 Subject: [PATCH] virgl,egl: add check for EGL_KHR_gl_colorspace This is needed to properly support EXT_sRGB_write_control v2: Make return value of virgl_has_egl_khr_gl_colorspace a bool (Gurchetan) Reviewed-by: Gurchetan Singh Signed-off-by: Gert Wollny Signed-off-by: Jakob Bornecrantz --- src/virgl_egl.h | 1 + src/virgl_egl_context.c | 9 +++++++++ src/virglrenderer.c | 7 +++++++ src/vrend_renderer.h | 2 ++ 4 files changed, 19 insertions(+) diff --git a/src/virgl_egl.h b/src/virgl_egl.h index 9a6369e..018357a 100644 --- a/src/virgl_egl.h +++ b/src/virgl_egl.h @@ -35,6 +35,7 @@ void virgl_egl_destroy_context(struct virgl_egl *ve, virgl_renderer_gl_context v int virgl_egl_make_context_current(struct virgl_egl *ve, virgl_renderer_gl_context virglctx); virgl_renderer_gl_context virgl_egl_get_current_context(struct virgl_egl *ve); +bool virgl_has_egl_khr_gl_colorspace(struct virgl_egl *ve); int virgl_egl_get_fourcc_for_texture(struct virgl_egl *ve, uint32_t tex_id, uint32_t format, int *fourcc); int virgl_egl_get_fd_for_texture(struct virgl_egl *ve, uint32_t tex_id, int *fd); int virgl_egl_get_fd_for_texture2(struct virgl_egl *ve, uint32_t tex_id, int *fd, int *stride, int *offset); diff --git a/src/virgl_egl_context.c b/src/virgl_egl_context.c index 48774de..01db9bb 100644 --- a/src/virgl_egl_context.c +++ b/src/virgl_egl_context.c @@ -54,6 +54,7 @@ struct virgl_egl { EGLContext egl_ctx; bool have_mesa_drm_image; bool have_mesa_dma_buf_img_export; + bool have_egl_khr_gl_colorspace; }; static int egl_rendernode_open(void) @@ -240,6 +241,9 @@ struct virgl_egl *virgl_egl_init(int fd, bool surfaceless, bool gles) goto fail; } + d->have_egl_khr_gl_colorspace = + virgl_egl_has_extension_in_string(extension_list, "EGL_KHR_gl_colorspace"); + if (gles) api = EGL_OPENGL_ES_API; else @@ -417,6 +421,11 @@ int virgl_egl_get_fd_for_texture(struct virgl_egl *ve, uint32_t tex_id, int *fd) return ret; } +bool virgl_has_egl_khr_gl_colorspace(struct virgl_egl *ve) +{ + return ve->have_egl_khr_gl_colorspace; +} + uint32_t virgl_egl_get_gbm_format(uint32_t format) { switch (format) { diff --git a/src/virglrenderer.c b/src/virglrenderer.c index dd3253c..ec8c853 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -201,6 +201,13 @@ int virgl_renderer_resource_get_info(int res_handle, return ret; } +int virgl_has_gl_colorspace(void) +{ + return use_context == CONTEXT_GLX || + (use_context == CONTEXT_EGL && + virgl_has_egl_khr_gl_colorspace(egl_info)); +} + void virgl_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver, uint32_t *max_size) { diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 6075aea..fdb02fb 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -418,6 +418,8 @@ unsigned vrend_context_has_debug_flag(struct vrend_context *ctx, unsigned vrend_renderer_query_multisample_caps(unsigned max_samples, struct virgl_caps_v2 *caps); +int virgl_has_gl_colorspace(void); + struct gl_version { uint32_t major; uint32_t minor;