summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/GL/internal/dri_interface.h12
-rw-r--r--src/gallium/state_trackers/dri/sw/drisw.c10
-rw-r--r--src/gallium/winsys/sw/dri/dri_sw_winsys.c6
-rw-r--r--src/glx/drisw_glx.c92
-rw-r--r--src/mesa/drivers/dri/swrast/swrast.c18
-rw-r--r--src/mesa/drivers/dri/swrast/swrast_priv.h8
6 files changed, 88 insertions, 58 deletions
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index aa56eb45d79..fa9b7c4bf21 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -416,15 +416,15 @@ struct __DRIswrastLoaderExtensionRec {
* Put image to drawable
*/
void (*putImage)(__DRIdrawable *drawable, int op,
- int x, int y, int width, int height, char *data,
- void *loaderPrivate);
+ int x, int y, int width, int height,
+ char *data, void *loaderPrivate);
/**
- * Get image from drawable
+ * Get image from readable
*/
- void (*getImage)(__DRIdrawable *drawable,
- int x, int y, int width, int height, char *data,
- void *loaderPrivate);
+ void (*getImage)(__DRIdrawable *readable,
+ int x, int y, int width, int height,
+ char *data, void *loaderPrivate);
};
/**
diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c
index 745941d5501..a75fdf17899 100644
--- a/src/gallium/state_trackers/dri/sw/drisw.c
+++ b/src/gallium/state_trackers/dri/sw/drisw.c
@@ -38,16 +38,16 @@
*
* drisw_api:
*
- * Define drisw_api similarly to dri_api and use it to call the loader. This is
- * predicated on support for calling the loader from the winsys, which has to
- * grow for DRI2 as well.
+ * Define drisw_api similarly to dri1_api and use it to call the loader. This
+ * is predicated on support for calling the loader from the winsys, which has
+ * to grow for DRI2 as well.
*
- * xshm:
+ * xshm / texture_from_pixmap / EGLImage:
*
* Allow the loaders to use the XSHM extension. It probably requires callbacks
* for createImage/destroyImage similar to DRI2 getBuffers. Probably not worth
* it, given the scope of DRISW, unless it falls naturally from properly
- * solving the above two issues.
+ * solving the other issues.
*/
#include "util/u_memory.h"
diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
index 5549e152ee8..9e8c31282d4 100644
--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
@@ -63,11 +63,11 @@ xm_is_displaytarget_format_supported( struct sw_winsys *ws,
}
static INLINE int
-bytes_per_line(unsigned stride, unsigned mul)
+bytes_per_line(unsigned pitch_bits, unsigned mul)
{
unsigned mask = mul - 1;
- return ((stride * 8 + mask) & ~mask) / 8;
+ return ((pitch_bits + mask) & ~mask) / 8;
}
/* pipe_screen::texture_create DISPLAY_TARGET / SCANOUT / SHARED */
@@ -88,7 +88,7 @@ xm_displaytarget_create(struct sw_winsys *winsys,
format_stride = util_format_get_stride(format, width);
xm_stride = align(format_stride, alignment);
- loader_stride = bytes_per_line(format_stride, 32);
+ loader_stride = bytes_per_line(format_stride * 8, 32);
nblocksy = util_format_get_nblocksy(format, height);
size = xm_stride * nblocksy;
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index 99f8f2cbf06..ca85ae3a313 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -53,7 +53,6 @@ struct __GLXDRIdrawablePrivateRec
XVisualInfo *visinfo;
XImage *ximage;
- int bpp;
};
/**
@@ -90,13 +89,10 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp,
pdp->visinfo->depth,
ZPixmap, 0, /* format, offset */
NULL, /* data */
- 0, 0, /* size */
- 32, /* bitmap_pad */
+ 0, 0, /* width, height */
+ 8, /* bitmap_pad */
0); /* bytes_per_line */
- /* get the true number of bits per pixel */
- pdp->bpp = pdp->ximage->bits_per_pixel;
-
return True;
}
@@ -112,7 +108,8 @@ XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable)
static void
swrastGetDrawableInfo(__DRIdrawable * draw,
- int *x, int *y, int *w, int *h, void *loaderPrivate)
+ int *x, int *y, int *w, int *h,
+ void *loaderPrivate)
{
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);
@@ -121,26 +118,20 @@ swrastGetDrawableInfo(__DRIdrawable * draw,
Window root;
Status stat;
- unsigned int bw, depth;
+ unsigned uw, uh, bw, depth;
drawable = pdraw->xDrawable;
stat = XGetGeometry(dpy, drawable, &root,
- x, y, (unsigned int *) w, (unsigned int *) h,
- &bw, &depth);
-}
-
-static inline int
-bytes_per_line(int w, int bpp, unsigned mul)
-{
- unsigned mask = mul - 1;
-
- return ((w * bpp + mask) & ~mask) / 8;
+ x, y, &uw, &uh, &bw, &depth);
+ *w = uw;
+ *h = uh;
}
static void
-swrastPutImage(__DRIdrawable * draw, int op,
- int x, int y, int w, int h, char *data, void *loaderPrivate)
+swrastPutImage2(__DRIdrawable * draw, int op,
+ int x, int y, int w, int h,
+ char *data, int pitch, void *loaderPrivate)
{
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);
@@ -166,7 +157,7 @@ swrastPutImage(__DRIdrawable * draw, int op,
ximage->data = data;
ximage->width = w;
ximage->height = h;
- ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
+ ximage->bytes_per_line = pitch;
XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
@@ -174,28 +165,67 @@ swrastPutImage(__DRIdrawable * draw, int op,
}
static void
-swrastGetImage(__DRIdrawable * draw,
- int x, int y, int w, int h, char *data, void *loaderPrivate)
+swrastGetImage2(__DRIdrawable * read,
+ int x, int y, int w, int h,
+ char *data, int pitch, void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *pdp = loaderPrivate;
- __GLXDRIdrawable *pdraw = &(pdp->base);
- Display *dpy = pdraw->psc->dpy;
- Drawable drawable;
+ __GLXDRIdrawablePrivate *prp = loaderPrivate;
+ __GLXDRIdrawable *pread = &(prp->base);
+ Display *dpy = pread->psc->dpy;
+ Drawable readable;
XImage *ximage;
- drawable = pdraw->xDrawable;
+ readable = pread->xDrawable;
- ximage = pdp->ximage;
+ ximage = prp->ximage;
ximage->data = data;
ximage->width = w;
ximage->height = h;
- ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
+ ximage->bytes_per_line = pitch;
- XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
+ XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
ximage->data = NULL;
}
+static inline int
+bytes_per_line(unsigned pitch_bits, unsigned mul)
+{
+ unsigned mask = mul - 1;
+
+ return ((pitch_bits + mask) & ~mask) / 8;
+}
+
+static void
+swrastPutImage(__DRIdrawable * draw, int op,
+ int x, int y, int w, int h,
+ char *data, void *loaderPrivate)
+{
+ __GLXDRIdrawablePrivate *pdp = loaderPrivate;
+ int bpp, pitch;
+
+ bpp = pdp->ximage->bits_per_pixel;
+
+ pitch = bytes_per_line(w * bpp, 32);
+
+ swrastPutImage2(draw, op, x, y, w, h, data, pitch, loaderPrivate);
+}
+
+static void
+swrastGetImage(__DRIdrawable * read,
+ int x, int y, int w, int h,
+ char *data, void *loaderPrivate)
+{
+ __GLXDRIdrawablePrivate *prp = loaderPrivate;
+ int bpp, pitch;
+
+ bpp = prp->ximage->bits_per_pixel;
+
+ pitch = bytes_per_line(w * bpp, 32);
+
+ swrastGetImage2(read, x, y, w, h, data, pitch, loaderPrivate);
+}
+
static const __DRIswrastLoaderExtension swrastLoaderExtension = {
{__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION},
swrastGetDrawableInfo,
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index e9ca99a86f0..e8df26f3d06 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -206,12 +206,19 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb)
free(rb);
}
+static INLINE int
+bytes_per_line(unsigned pitch_bits, unsigned mul)
+{
+ unsigned mask = mul - 1;
+
+ return ((pitch_bits + mask) & ~mask) / 8;
+}
+
static GLboolean
swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat, GLuint width, GLuint height)
{
struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
- unsigned mask = PITCH_ALIGN_BITS - 1;
TRACE;
@@ -219,8 +226,7 @@ swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->Width = width;
rb->Height = height;
- /* always pad to PITCH_ALIGN_BITS */
- xrb->pitch = ((width * xrb->bpp + mask) & ~mask) / 8;
+ xrb->pitch = bytes_per_line(width * xrb->bpp, 32);
return GL_TRUE;
}
@@ -394,8 +400,10 @@ dri_swap_buffers(__DRIdrawable * dPriv)
fb = &drawable->Base;
- frontrb = swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
- backrb = swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+ frontrb =
+ swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+ backrb =
+ swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
/* check for signle-buffered */
if (backrb == NULL)
diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h
index 007642be95f..6679061a983 100644
--- a/src/mesa/drivers/dri/swrast/swrast_priv.h
+++ b/src/mesa/drivers/dri/swrast/swrast_priv.h
@@ -124,14 +124,6 @@ swrast_renderbuffer(struct gl_renderbuffer *rb)
#define PF_R3G3B2 3 /**< 8bpp TrueColor: 3-R, 3-G, 2-B bits */
#define PF_X8R8G8B8 4 /**< 32bpp TrueColor: 8-R, 8-G, 8-B bits */
-/**
- * Renderbuffer pitch alignment (in bits).
- *
- * The xorg loader requires padding images to 32 bits. However, this should
- * become a screen/drawable parameter XXX
- */
-#define PITCH_ALIGN_BITS 32
-
/* swrast_span.c */