[Mesa-dev] [PATCH 2/4] st/dri: consolidate image extension logic
gurchetansingh at chromium.org
gurchetansingh at chromium.org
Fri Jun 9 00:27:38 UTC 2017
From: Gurchetan Singh <gurchetansingh at chromium.org>
We can stop exposing functions needed to initialize the image
extension by creating a helper function.
---
src/gallium/state_trackers/dri/dri2.c | 33 ++-----------------------
src/gallium/state_trackers/dri/dri_extensions.c | 33 +++++++++++++++++++++++--
src/gallium/state_trackers/dri/dri_extensions.h | 17 ++-----------
3 files changed, 35 insertions(+), 48 deletions(-)
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index b68d93bdaa..45b20eb1e4 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -644,21 +644,6 @@ dri2_update_tex_buffer(struct dri_drawable *drawable,
/* no-op */
}
-static __DRIimage *
-dri2_lookup_egl_image(struct dri_screen *screen, void *handle)
-{
- const __DRIimageLookupExtension *loader = screen->sPriv->dri2.image;
- __DRIimage *img;
-
- if (!loader->lookupEGLImage)
- return NULL;
-
- img = loader->lookupEGLImage(screen->sPriv,
- handle, screen->sPriv->loaderPrivate);
-
- return img;
-}
-
static const __DRIrobustnessExtension dri2Robustness = {
.base = { __DRI2_ROBUSTNESS, 1 }
};
@@ -1057,13 +1042,7 @@ dri2_init_screen(__DRIscreen * sPriv)
}
if (dmabuf_ret && dmabuf_ret->val.val_bool) {
- uint64_t cap;
-
- if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
- (cap & DRM_PRIME_CAP_IMPORT)) {
- dri2ImageExtension.createImageFromFds = dri2_from_fds;
- dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
- }
+ dri2_init_image_extension(screen);
}
if (pscreen->get_param(pscreen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) {
@@ -1080,7 +1059,6 @@ dri2_init_screen(__DRIscreen * sPriv)
screen->can_share_buffer = true;
screen->auto_fake_front = dri_with_format(sPriv);
screen->broken_invalidate = !sPriv->dri2.useInvalidate;
- screen->lookup_egl_image = dri2_lookup_egl_image;
return configs;
@@ -1110,7 +1088,6 @@ dri_kms_init_screen(__DRIscreen * sPriv)
const __DRIconfig **configs;
struct dri_screen *screen;
struct pipe_screen *pscreen = NULL;
- uint64_t cap;
int fd;
screen = CALLOC_STRUCT(dri_screen);
@@ -1131,12 +1108,6 @@ dri_kms_init_screen(__DRIscreen * sPriv)
if (!pscreen)
goto release_pipe;
- if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
- (cap & DRM_PRIME_CAP_IMPORT)) {
- dri2ImageExtension.createImageFromFds = dri2_from_fds;
- dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
- }
-
sPriv->extensions = dri_screen_extensions;
configs = dri_init_screen_helper(screen, pscreen, "swrast");
@@ -1146,7 +1117,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
screen->can_share_buffer = false;
screen->auto_fake_front = dri_with_format(sPriv);
screen->broken_invalidate = !sPriv->dri2.useInvalidate;
- screen->lookup_egl_image = dri2_lookup_egl_image;
+ dri2_init_image_extension(screen);
return configs;
diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c
index c3daca1762..29bf43c3ac 100644
--- a/src/gallium/state_trackers/dri/dri_extensions.c
+++ b/src/gallium/state_trackers/dri/dri_extensions.c
@@ -20,6 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <xf86drm.h>
#include <dlfcn.h>
#include "util/u_memory.h"
#include "util/u_inlines.h"
@@ -357,6 +358,21 @@ const __DRI2fenceExtension dri2FenceExtension = {
};
static __DRIimage *
+dri2_lookup_egl_image(struct dri_screen *screen, void *handle)
+{
+ const __DRIimageLookupExtension *loader = screen->sPriv->dri2.image;
+ __DRIimage *img;
+
+ if (!loader->lookupEGLImage)
+ return NULL;
+
+ img = loader->lookupEGLImage(screen->sPriv,
+ handle, screen->sPriv->loaderPrivate);
+
+ return img;
+}
+
+static __DRIimage *
dri2_create_image_from_winsys(__DRIscreen *_screen,
int width, int height, int format,
int num_handles, struct winsys_handle *whandle,
@@ -819,7 +835,7 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
return img;
}
-__DRIimage *
+static __DRIimage *
dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
int *fds, int num_fds, int *strides, int *offsets,
void *loaderPrivate)
@@ -837,7 +853,7 @@ dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
return img;
}
-__DRIimage *
+static __DRIimage *
dri2_from_dma_bufs(__DRIscreen *screen,
int width, int height, int fourcc,
int *fds, int num_fds,
@@ -991,4 +1007,17 @@ __DRIimageExtension dri2ImageExtension = {
.unmapImage = dri2_unmap_image,
};
+void
+dri2_init_image_extension(struct dri_screen *screen)
+{
+ uint64_t cap;
+ if (drmGetCap(screen->fd, DRM_CAP_PRIME, &cap) == 0 &&
+ (cap & DRM_PRIME_CAP_IMPORT)) {
+ dri2ImageExtension.createImageFromFds = dri2_from_fds;
+ dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
+ }
+
+ screen->lookup_egl_image = dri2_lookup_egl_image;
+}
+
/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/dri_extensions.h b/src/gallium/state_trackers/dri/dri_extensions.h
index 6c19ccac75..3dac8e6d28 100644
--- a/src/gallium/state_trackers/dri/dri_extensions.h
+++ b/src/gallium/state_trackers/dri/dri_extensions.h
@@ -26,22 +26,9 @@
extern const __DRI2fenceExtension dri2FenceExtension;
extern __DRIimageExtension dri2ImageExtension;
-__DRIimage *
-dri2_from_dma_bufs(__DRIscreen *screen,
- int width, int height, int fourcc,
- int *fds, int num_fds,
- int *strides, int *offsets,
- enum __DRIYUVColorSpace yuv_color_space,
- enum __DRISampleRange sample_range,
- enum __DRIChromaSiting horizontal_siting,
- enum __DRIChromaSiting vertical_siting,
- unsigned *error,
- void *loaderPrivate);
+void
+dri2_init_image_extension(struct dri_screen *screen);
-__DRIimage *
-dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
- int *fds, int num_fds, int *strides, int *offsets,
- void *loaderPrivate);
#endif
/* vim: set sw=3 ts=8 sts=3 expandtab: */
--
2.12.2
More information about the mesa-dev
mailing list