Am 04.05.2017 um 18:33 schrieb Emil Velikov:
From: Emil Velikov <emil.veli...@collabora.com>

Provide a dummy stub when the user has opted w/o said platform, thus
we can build the binaries without unnecessarily requiring X11/other
headers.

In order to avoid build and link-time issues, we remove the HAVE_DRI3
guards in the VA and VDPAU state-trackers.

With this change st/va will return VA_STATUS_ERROR_ALLOCATION_FAILED
instead of VA_STATUS_ERROR_UNIMPLEMENTED. That is fine since upstream
users of libva such as vlc and mpv do little error checking, let
alone distinguish between the two.

Cc: Leo Liu <leo....@amd.com>
Cc: "Guttula, Suresh" <suresh.gutt...@amd.com>
Cc: mesa-sta...@lists.freedesktop.org
Cc: Christian König <christian.koe...@amd.com>
Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
Christian, others
How do you feel about the ALLOCATION_FAILED vs UNIMPLEMENTED situation?
Doing the latter is doable, albeit it will make the code a bit ugly.

I don't think that matters much, but resulting in UNIMPLEMENTED return code when X backends are not compiled in indeed sounds cleaner.

So price question is how much hassle would it be? Apart from that the changes look good to me.

Regards,
Christian.

---
  src/gallium/auxiliary/Makefile.am         | 19 ++++++++++---------
  src/gallium/auxiliary/Makefile.sources    | 10 +++++++---
  src/gallium/auxiliary/vl/vl_winsys.h      | 21 ++++++++++++++++++---
  src/gallium/state_trackers/va/context.c   |  2 --
  src/gallium/state_trackers/vdpau/device.c |  2 --
  5 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile.am 
b/src/gallium/auxiliary/Makefile.am
index e25e31b89ea..a64ead28e32 100644
--- a/src/gallium/auxiliary/Makefile.am
+++ b/src/gallium/auxiliary/Makefile.am
@@ -88,23 +88,24 @@ if NEED_GALLIUM_VL_WINSYS
noinst_LTLIBRARIES += libgalliumvlwinsys.la -libgalliumvlwinsys_la_CFLAGS = \
-       $(COMMON_VL_CFLAGS)
+libgalliumvlwinsys_la_CFLAGS = $(COMMON_VL_CFLAGS)
+libgalliumvlwinsys_la_SOURCES = $(VL_WINSYS_SOURCES)
-libgalliumvlwinsys_la_SOURCES = \
-       $(VL_WINSYS_SOURCES)
+if HAVE_PLATFORM_X11
+libgalliumvlwinsys_la_SOURCES += $(VL_WINSYS_DRI2_SOURCES)
if HAVE_DRI3
-
-libgalliumvlwinsys_la_SOURCES += \
-       $(VL_WINSYS_DRI3_SOURCES)
-
+libgalliumvlwinsys_la_SOURCES += $(VL_WINSYS_DRI3_SOURCES)
  endif
-
  endif
+if HAVE_PLATFORM_DRM
+libgalliumvlwinsys_la_SOURCES += $(VL_WINSYS_DRM_SOURCES)
  endif
+endif # NEED_GALLIUM_VL_WINSYS
+endif # NEED_GALLIUM_VL
+
  EXTRA_DIST = \
        SConscript \
        indices/u_indices.c \
diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index dbdb3ca8152..a7dec6054d6 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -343,18 +343,22 @@ VL_SOURCES := \
        vl/vl_video_buffer.c \
        vl/vl_video_buffer.h \
        vl/vl_vlc.h \
-       vl/vl_winsys.h \
        vl/vl_zscan.c \
        vl/vl_zscan.h
# XXX: Nuke this as our dri targets no longer depend on VL.
  VL_WINSYS_SOURCES := \
-       vl/vl_winsys_dri.c \
-       vl/vl_winsys_drm.c
+       vl/vl_winsys.h
+
+VL_WINSYS_DRI2_SOURCES := \
+       vl/vl_winsys_dri.c
VL_WINSYS_DRI3_SOURCES := \
        vl/vl_winsys_dri3.c
+VL_WINSYS_DRM_SOURCES := \
+       vl/vl_winsys_drm.c
+
  VL_STUB_SOURCES := \
        vl/vl_stubs.c
diff --git a/src/gallium/auxiliary/vl/vl_winsys.h b/src/gallium/auxiliary/vl/vl_winsys.h
index e1f9b274fcc..77277cefe8b 100644
--- a/src/gallium/auxiliary/vl/vl_winsys.h
+++ b/src/gallium/auxiliary/vl/vl_winsys.h
@@ -32,7 +32,9 @@
  #ifndef vl_winsys_h
  #define vl_winsys_h
+#ifdef HAVE_X11_PLATFORM
  #include <X11/Xlib.h>
+#endif
  #include "pipe/p_defines.h"
  #include "pipe/p_format.h"
@@ -68,15 +70,28 @@ struct vl_screen
     struct pipe_loader_device *dev;
  };
+#ifdef HAVE_X11_PLATFORM
  struct vl_screen *
  vl_dri2_screen_create(Display *display, int screen);
+#else
+static inline struct vl_screen *
+vl_dri2_screen_create(void *display, int screen) { return NULL; };
+#endif
+#if defined(HAVE_X11_PLATFORM) && defined(HAVE_DRI3)
  struct vl_screen *
-vl_drm_screen_create(int fd);
+vl_dri3_screen_create(Display *display, int screen);
+#else
+static inline struct vl_screen *
+vl_dri3_screen_create(void *display, int screen) { return NULL; };
+#endif
-#if defined(HAVE_DRI3)
+#ifdef HAVE_DRM_PLATFORM
  struct vl_screen *
-vl_dri3_screen_create(Display *display, int screen);
+vl_drm_screen_create(int fd);
+#else
+static inline struct vl_screen *
+vl_drm_screen_create(int fd) { return NULL; };
  #endif
#endif
diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index 4224ed7f048..5159fceac91 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -118,9 +118,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
        return VA_STATUS_ERROR_UNIMPLEMENTED;
     case VA_DISPLAY_GLX:
     case VA_DISPLAY_X11:
-#if defined(HAVE_DRI3)
        drv->vscreen = vl_dri3_screen_create(ctx->native_dpy, ctx->x11_screen);
-#endif
        if (!drv->vscreen)
           drv->vscreen = vl_dri2_screen_create(ctx->native_dpy, 
ctx->x11_screen);
        if (!drv->vscreen)
diff --git a/src/gallium/state_trackers/vdpau/device.c 
b/src/gallium/state_trackers/vdpau/device.c
index 3ae3da3be1d..eae9f04ee10 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -63,9 +63,7 @@ vdp_imp_device_create_x11(Display *display, int screen, 
VdpDevice *device,
pipe_reference_init(&dev->reference, 1); -#if defined(HAVE_DRI3)
     dev->vscreen = vl_dri3_screen_create(display, screen);
-#endif
     if (!dev->vscreen)
        dev->vscreen = vl_dri2_screen_create(display, screen);
     if (!dev->vscreen) {


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to