drisw: use putImageShm if available
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Wed, 10 Jun 2015 15:34:15 +0000 (17:34 +0200)
committerDave Airlie <airlied@redhat.com>
Tue, 29 May 2018 23:11:53 +0000 (09:11 +1000)
If the DRIswrastLoaderExtension implements putImageShm, bind it to
drisw_loader_funcs.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
src/gallium/include/state_tracker/drisw_api.h
src/gallium/state_trackers/dri/drisw.c

index 03d5ee405a4d04a6989362a08620be0851328677..36bef087a4f6855379c6479bdbe97a416a86c3ab 100644 (file)
@@ -18,6 +18,9 @@ struct drisw_loader_funcs
                       void *data, unsigned width, unsigned height);
    void (*put_image2) (struct dri_drawable *dri_drawable,
                        void *data, int x, int y, unsigned width, unsigned height, unsigned stride);
+   void (*put_image_shm) (struct dri_drawable *dri_drawable,
+                          int shmid, char *shmaddr, unsigned offset,
+                          int x, int y, unsigned width, unsigned height, unsigned stride);
 };
 
 #endif
index eb5752386dc3c3a63a536062fcb6cb36db333a2f..40cbca54940831d60194a860f8fdedf0ca6d83fd 100644 (file)
  *
  **************************************************************************/
 
-/* TODO:
- *
- * xshm / EGLImage:
- *
- * Allow the loaders to use the XSHM extension. It probably requires callbacks
- * for createImage/destroyImage similar to DRI2 getBuffers.
- */
-
 #include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
@@ -86,6 +78,19 @@ put_image2(__DRIdrawable *dPriv, void *data, int x, int y,
                      data, dPriv->loaderPrivate);
 }
 
+static inline void
+put_image_shm(__DRIdrawable *dPriv, int shmid, char *shmaddr,
+              unsigned offset, int x, int y,
+              unsigned width, unsigned height, unsigned stride)
+{
+   __DRIscreen *sPriv = dPriv->driScreenPriv;
+   const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader;
+
+   loader->putImageShm(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP,
+                       x, y, width, height, stride,
+                       shmid, shmaddr, offset, dPriv->loaderPrivate);
+}
+
 static inline void
 get_image(__DRIdrawable *dPriv, int x, int y, int width, int height, void *data)
 {
@@ -152,6 +157,17 @@ drisw_put_image2(struct dri_drawable *drawable,
    put_image2(dPriv, data, x, y, width, height, stride);
 }
 
+static inline void
+drisw_put_image_shm(struct dri_drawable *drawable,
+                    int shmid, char *shmaddr, unsigned offset,
+                    int x, int y, unsigned width, unsigned height,
+                    unsigned stride)
+{
+   __DRIdrawable *dPriv = drawable->dPriv;
+
+   put_image_shm(dPriv, shmid, shmaddr, offset, x, y, width, height, stride);
+}
+
 static inline void
 drisw_present_texture(__DRIdrawable *dPriv,
                       struct pipe_resource *ptex, struct pipe_box *sub_box)
@@ -394,6 +410,7 @@ static struct drisw_loader_funcs drisw_lf = {
 static const __DRIconfig **
 drisw_init_screen(__DRIscreen * sPriv)
 {
+   const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader;
    const __DRIconfig **configs;
    struct dri_screen *screen;
    struct pipe_screen *pscreen = NULL;
@@ -409,6 +426,10 @@ drisw_init_screen(__DRIscreen * sPriv)
 
    sPriv->driverPrivate = (void *)screen;
    sPriv->extensions = drisw_screen_extensions;
+   if (loader->base.version >= 4) {
+      if (loader->putImageShm)
+         drisw_lf.put_image_shm = drisw_put_image_shm;
+   }
 
    if (pipe_loader_sw_probe_dri(&screen->dev, &drisw_lf)) {
       dri_init_options(screen);