[Mesa-dev] [PATCH 3/3] gallium: use put image shm2 path
Dave Airlie
airlied at gmail.com
Thu Dec 27 05:02:31 UTC 2018
From: Dave Airlie <airlied at redhat.com>
This fixes the drisw paths to use the new shm2 interface, so that
we don't trigger the X server overflow checks when the x offset is non-zero.
This just hides the versioning in drisw, and either passes the src_x
or adds the offset fixup for the fallback path.
---
src/gallium/include/state_tracker/drisw_api.h | 2 +-
src/gallium/state_trackers/dri/drisw.c | 20 +++++++++++++++-----
src/gallium/winsys/sw/dri/dri_sw_winsys.c | 13 +++++++++----
3 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/src/gallium/include/state_tracker/drisw_api.h b/src/gallium/include/state_tracker/drisw_api.h
index e365ab8..4b5d36c 100644
--- a/src/gallium/include/state_tracker/drisw_api.h
+++ b/src/gallium/include/state_tracker/drisw_api.h
@@ -20,7 +20,7 @@ struct drisw_loader_funcs
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 shmid, char *shmaddr, unsigned offset, unsigned offset_x,
int x, int y, unsigned width, unsigned height, unsigned stride);
};
diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c
index 5a0d2e1..5651c95 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -79,15 +79,24 @@ put_image2(__DRIdrawable *dPriv, void *data, int x, int y,
static inline void
put_image_shm(__DRIdrawable *dPriv, int shmid, char *shmaddr,
- unsigned offset, int x, int y,
+ unsigned offset, unsigned offset_x, 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);
+ /* If we have the newer put image shm interface send the x coords
+ * as a src coord as well, else fallback to the broken case of
+ * adding the offset_x to the offset.
+ */
+ if (loader->base.version > 4)
+ loader->putImageShm2(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP,
+ x, 0, x, y, width, height, stride,
+ shmid, shmaddr, offset, dPriv->loaderPrivate);
+ else
+ loader->putImageShm(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP,
+ x, y, width, height, stride,
+ shmid, shmaddr, offset + offset_x, dPriv->loaderPrivate);
}
static inline void
@@ -179,12 +188,13 @@ drisw_put_image2(struct dri_drawable *drawable,
static inline void
drisw_put_image_shm(struct dri_drawable *drawable,
int shmid, char *shmaddr, unsigned offset,
+ unsigned offset_x,
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);
+ put_image_shm(dPriv, shmid, shmaddr, offset, offset_x, x, y, width, height, stride);
}
static inline void
diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
index cd44b03..c0200f9 100644
--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
@@ -244,15 +244,20 @@ dri_sw_displaytarget_display(struct sw_winsys *ws,
unsigned width, height, x = 0, y = 0;
unsigned blsize = util_format_get_blocksize(dri_sw_dt->format);
unsigned offset = 0;
+ unsigned offset_x = 0;
char *data = dri_sw_dt->data;
-
+ bool is_shm = dri_sw_dt->shmid != -1;
/* Set the width to 'stride / cpp'.
*
* PutImage correctly clips to the width of the dst drawable.
*/
if (box) {
- offset = (dri_sw_dt->stride * box->y) + box->x * blsize;
+ offset = dri_sw_dt->stride * box->y;
+ offset_x = box->x * blsize;
data += offset;
+ /* don't add x offset for shm, the put_image_shm will deal with it */
+ if (!is_shm)
+ data += offset_x;
x = box->x;
y = box->y;
width = box->width;
@@ -262,8 +267,8 @@ dri_sw_displaytarget_display(struct sw_winsys *ws,
height = dri_sw_dt->height;
}
- if (dri_sw_dt->shmid != -1) {
- dri_sw_ws->lf->put_image_shm(dri_drawable, dri_sw_dt->shmid, dri_sw_dt->data, offset,
+ if (is_shm) {
+ dri_sw_ws->lf->put_image_shm(dri_drawable, dri_sw_dt->shmid, dri_sw_dt->data, offset, offset_x,
x, y, width, height, dri_sw_dt->stride);
return;
}
--
1.8.3.1
More information about the mesa-dev
mailing list