From c162f33d5f30146ead05afe51ae6af8d13763e44 Mon Sep 17 00:00:00 2001 From: Lepton Wu Date: Tue, 10 Dec 2019 06:06:07 +0000 Subject: [PATCH] Only require minimum gbm version when needed. We only need a recent version of gbm when enable_gbm_allocation gets set. Close #134 Reviewed-by: Gert Wollny Signed-off-by: Lepton Wu --- configure.ac | 7 ++++++- meson.build | 15 +++++++++------ src/virgl_egl_context.c | 2 ++ src/virgl_gbm.c | 25 ++++++++++++++----------- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index d31d1df..dbcd229 100644 --- a/configure.ac +++ b/configure.ac @@ -137,7 +137,12 @@ AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"]) AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes"]) LIBDRM_REQUIRED=2.4.50 -LIBGBM_REQUIRED=18.0.0 + +if test "x$enable_gbm_allocation" = xyes; then + LIBGBM_REQUIRED=18.0.0 +else + LIBGBM_REQUIRED=0.0.0 +fi if test "x$os_win32" = xno && test "x$enable_egl" != "xno"; then PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED]) diff --git a/meson.build b/meson.build index 8833ec1..5177a68 100644 --- a/meson.build +++ b/meson.build @@ -96,9 +96,17 @@ with_glx = require_glx or auto_egl_glx have_egl = false have_glx = false +with_gbm_allocation = get_option('gbm_allocation') +if with_gbm_allocation + conf_data.set('ENABLE_GBM_ALLOCATION', 1) + _gbm_ver = '18.0.0' +else + _gbm_ver = '0.0.0' +endif + if with_egl if cc.has_header('epoxy/egl.h') and epoxy_dep.get_pkgconfig_variable('epoxy_has_egl') == '1' - gbm_dep = dependency('gbm', version: '>= 18.0.0', required: require_egl) + gbm_dep = dependency('gbm', version: '>= ' + _gbm_ver, required: require_egl) have_egl = gbm_dep.found() conf_data.set('HAVE_EPOXY_EGL_H', 1) else @@ -122,11 +130,6 @@ if cc.compiles('void __attribute__((hidden)) func() {}') conf_data.set('HAVE_FUNC_ATTRIBUTE_VISIBILITY', 1) endif -with_gbm_allocation = get_option('gbm_allocation') -if with_gbm_allocation - conf_data.set('ENABLE_GBM_ALLOCATION', 1) -endif - configure_file(input : 'config.h.meson', output : 'config.h', configuration : conf_data) diff --git a/src/virgl_egl_context.c b/src/virgl_egl_context.c index 2310464..36f74b3 100644 --- a/src/virgl_egl_context.c +++ b/src/virgl_egl_context.c @@ -397,6 +397,7 @@ bool virgl_has_egl_khr_gl_colorspace(struct virgl_egl *egl) return has_bit(egl->extension_bits, EGL_KHR_GL_COLORSPACE); } +#ifdef ENABLE_GBM_ALLOCATION void *virgl_egl_image_from_dmabuf(struct virgl_egl *egl, struct gbm_bo *bo) { int ret; @@ -510,6 +511,7 @@ void virgl_egl_image_destroy(struct virgl_egl *egl, void *image) { eglDestroyImageKHR(egl->egl_display, image); } +#endif bool virgl_egl_need_fence_and_wait_external(struct virgl_egl *egl) { diff --git a/src/virgl_gbm.c b/src/virgl_gbm.c index 84ae529..20597b6 100644 --- a/src/virgl_gbm.c +++ b/src/virgl_gbm.c @@ -306,6 +306,7 @@ int virgl_gbm_convert_format(uint32_t *virgl_format, uint32_t *gbm_format) return -1; } +#ifdef ENABLE_GBM_ALLOCATION int virgl_gbm_transfer(struct gbm_bo *bo, uint32_t direction, struct iovec *iovecs, uint32_t num_iovecs, const struct vrend_transfer_info *info) { @@ -391,17 +392,6 @@ uint32_t virgl_gbm_convert_flags(uint32_t virgl_bind_flags) return flags; } -int virgl_gbm_export_fd(struct gbm_device *gbm, uint32_t handle, int32_t *out_fd) -{ - int ret; - ret = drmPrimeHandleToFD(gbm_device_get_fd(gbm), handle, DRM_CLOEXEC | DRM_RDWR, out_fd); - // Kernels with older DRM core versions block DRM_RDWR but give a - // read/write mapping anyway. - if (ret) - ret = drmPrimeHandleToFD(gbm_device_get_fd(gbm), handle, DRM_CLOEXEC, out_fd); - - return ret; -} int virgl_gbm_export_query(struct gbm_bo *bo, struct virgl_renderer_export_query *query) { @@ -461,6 +451,19 @@ err_close: query->out_num_fds = 0; return ret; } +#endif + +int virgl_gbm_export_fd(struct gbm_device *gbm, uint32_t handle, int32_t *out_fd) +{ + int ret; + ret = drmPrimeHandleToFD(gbm_device_get_fd(gbm), handle, DRM_CLOEXEC | DRM_RDWR, out_fd); + // Kernels with older DRM core versions block DRM_RDWR but give a + // read/write mapping anyway. + if (ret) + ret = drmPrimeHandleToFD(gbm_device_get_fd(gbm), handle, DRM_CLOEXEC, out_fd); + + return ret; +} int virgl_gbm_get_plane_width(struct gbm_bo *bo, int plane) { uint32_t format = gbm_bo_get_format(bo);