*
**************************************************************************/
-/* 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"
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)
{
data, dPriv->loaderPrivate);
}
+static inline bool
+get_image_shm(__DRIdrawable *dPriv, int x, int y, int width, int height,
+ struct pipe_resource *res)
+{
+ __DRIscreen *sPriv = dPriv->driScreenPriv;
+ const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader;
+ struct winsys_handle whandle;
+
+ whandle.type = WINSYS_HANDLE_TYPE_SHMID;
+
+ if (loader->base.version < 4 || !loader->getImageShm)
+ return FALSE;
+
+ if (!res->screen->resource_get_handle(res->screen, NULL, res, &whandle, PIPE_HANDLE_USAGE_WRITE))
+ return FALSE;
+
+ loader->getImageShm(dPriv, x, y, width, height, whandle.handle, dPriv->loaderPrivate);
+ return TRUE;
+}
+
static void
drisw_update_drawable_info(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)
x, y, w, h, &transfer);
/* Copy the Drawable content to the mapped texture buffer */
- get_image(dPriv, x, y, w, h, map);
+ if (!get_image_shm(dPriv, x, y, w, h, res))
+ get_image(dPriv, x, y, w, h, map);
/* The pipe transfer has a pitch rounded up to the nearest 64 pixels.
get_image() has a pitch rounded up to 4 bytes. */
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;
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);