diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2014-06-15 13:49:49 +0200 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2014-07-30 16:33:09 +0100 |
commit | 8430af5ebe1ee8119e14ae8fe00ec98fda40c57f (patch) | |
tree | 35f176fff5d576f546a359e15884df58e59518b4 /src/gbm/backends/dri/gbm_driint.h | |
parent | e3a3dbe9407bdbf9693349900936d5349cb8bb75 (diff) | |
download | external_mesa3d-8430af5ebe1ee8119e14ae8fe00ec98fda40c57f.zip external_mesa3d-8430af5ebe1ee8119e14ae8fe00ec98fda40c57f.tar.gz external_mesa3d-8430af5ebe1ee8119e14ae8fe00ec98fda40c57f.tar.bz2 |
Add support for swrast to the DRM EGL platform
Turn GBM into a swrast loader (providing putimage/getimage backed
by a dumb KMS buffer). This allows to run KMS+DRM GL applications
(such as weston or mutter-wayland) unmodified on cards that don't
have any client side HW acceleration component but that can do
modeset (examples include simpledrm and qxl)
[Emil Velikov]
- Fix make check.
- Split dri_open_driver() from dri_load_driver().
- Don't try to bind the swrast extensions when using dri.
- Handle swrast->CreateNewScreen() failure.
- strdup the driver_name, as it's free'd at destruction.
- s/LIBGL_ALWAYS_SOFTWARE/GBM_ALWAYS_SOFTWARE/
- Move gbm_dri_bo_map/unmap to gbm_driiint.h.
- Correct swrast fallback logic.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'src/gbm/backends/dri/gbm_driint.h')
-rw-r--r-- | src/gbm/backends/dri/gbm_driint.h | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h index 9c4392d..3f46eff 100644 --- a/src/gbm/backends/dri/gbm_driint.h +++ b/src/gbm/backends/dri/gbm_driint.h @@ -28,6 +28,7 @@ #ifndef _GBM_DRI_INTERNAL_H_ #define _GBM_DRI_INTERNAL_H_ +#include <sys/mman.h> #include "gbmint.h" #include "common_drm.h" @@ -36,6 +37,7 @@ #include "GL/internal/dri_interface.h" struct gbm_dri_surface; +struct gbm_dri_bo; struct gbm_dri_device { struct gbm_drm_device base; @@ -47,6 +49,7 @@ struct gbm_dri_device { const __DRIcoreExtension *core; const __DRIdri2Extension *dri2; const __DRIimageExtension *image; + const __DRIswrastExtension *swrast; const __DRI2flushExtension *flush; const __DRIdri2LoaderExtension *loader; @@ -72,6 +75,22 @@ struct gbm_dri_device { void *loaderPrivate, uint32_t buffer_mask, struct __DRIimageList *buffers); + void (*swrast_put_image2)(__DRIdrawable *driDrawable, + int op, + int x, + int y, + int width, + int height, + int stride, + char *data, + void *loaderPrivate); + void (*swrast_get_image)(__DRIdrawable *driDrawable, + int x, + int y, + int width, + int height, + char *data, + void *loaderPrivate); struct wl_drm *wl_drm; }; @@ -81,7 +100,7 @@ struct gbm_dri_bo { __DRIimage *image; - /* Only used for cursors */ + /* Used for cursors and the swrast front BO */ uint32_t handle, size; void *map; }; @@ -110,4 +129,40 @@ gbm_dri_surface(struct gbm_surface *surface) return (struct gbm_dri_surface *) surface; } +static inline void * +gbm_dri_bo_map(struct gbm_dri_bo *bo) +{ + struct drm_mode_map_dumb map_arg; + int ret; + + if (bo->image != NULL) + return NULL; + + if (bo->map != NULL) + return bo->map; + + memset(&map_arg, 0, sizeof(map_arg)); + map_arg.handle = bo->handle; + + ret = drmIoctl(bo->base.base.gbm->fd, DRM_IOCTL_MODE_MAP_DUMB, &map_arg); + if (ret) + return NULL; + + bo->map = mmap(0, bo->size, PROT_WRITE, + MAP_SHARED, bo->base.base.gbm->fd, map_arg.offset); + if (bo->map == MAP_FAILED) { + bo->map = NULL; + return NULL; + } + + return bo->map; +} + +static inline void +gbm_dri_bo_unmap(struct gbm_dri_bo *bo) +{ + munmap(bo->map, bo->size); + bo->map = NULL; +} + #endif |