* for createImage/destroyImage similar to DRI2 getBuffers. Probably not worth
* it, given the scope of DRISW, unless it falls naturally from properly
* solving the other issues.
+ *
+ * fences:
+ *
+ * No fences are used, are they needed for llvmpipe / cell ?
*/
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
#include "pipe/p_context.h"
dPriv->loaderPrivate);
}
+/*
+ * Set the width to 'stride / cpp'. PutImage seems to correctly clip the width
+ * to the actual width of the dst drawable. Even if this is not specified but
+ * an implementation detail, it is the correct thing to do, so rely on it. XXX
+ */
static INLINE void
-put_image(__DRIdrawable *dPriv, void *data)
+put_image(__DRIdrawable *dPriv, void *data, unsigned width)
{
__DRIscreen *sPriv = dPriv->driScreenPriv;
const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader;
loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP,
- 0, 0, dPriv->w, dPriv->h,
+ 0, 0, width, dPriv->h,
data, dPriv->loaderPrivate);
}
struct pipe_surface *psurf;
struct pipe_transfer *ptrans;
void *pmap;
+ unsigned width;
pipe = dri1_get_pipe_context(screen);
psurf = dri1_get_pipe_surface(drawable, ptex);
PIPE_TRANSFER_READ,
0, 0, dPriv->w, dPriv->h);
+ width = ptrans->stride / util_format_get_blocksize(ptex->format);
+
pmap = pipe->transfer_map(pipe, ptrans);
assert(pmap);
- put_image(dPriv, pmap);
+ put_image(dPriv, pmap, width);
pipe->transfer_unmap(pipe, ptrans);
return TRUE;
}
-/* see bytes_per_line in libGL */
-static INLINE int
-bytes_per_line(unsigned pitch_bits, unsigned mul)
-{
- unsigned mask = mul - 1;
-
- return ((pitch_bits + mask) & ~mask) / 8;
-}
-
/* pipe_screen::texture_create DISPLAY_TARGET / SCANOUT / SHARED */
static struct sw_displaytarget *
xm_displaytarget_create(struct sw_winsys *winsys,
unsigned *stride)
{
struct xm_displaytarget *xm_dt;
- unsigned nblocksy, size, xm_stride, loader_stride, format_stride;
+ unsigned nblocksy, size, xm_stride, format_stride;
xm_dt = CALLOC_STRUCT(xm_displaytarget);
if(!xm_dt)
format_stride = util_format_get_stride(format, width);
xm_stride = align(format_stride, alignment);
- loader_stride = bytes_per_line(format_stride * 8, 32);
nblocksy = util_format_get_nblocksy(format, height);
size = xm_stride * nblocksy;
-#ifdef DEBUG
- debug_printf("swrast format stride: %8d\n", format_stride);
- debug_printf("swrast pipe stride : %8d\n", xm_stride);
- debug_printf("swrast loader stride: %8d\n", loader_stride);
-#endif
-
- /*
- * Allocate with the aligned stride required by the pipe but set the stride
- * to the one hardcoded in the loaders XXX
- */
-
xm_dt->data = align_malloc(size, alignment);
if(!xm_dt->data)
goto no_data;
- *stride = loader_stride;
+ *stride = xm_stride;
return (struct sw_displaytarget *)xm_dt;
no_data:
*h = uh;
}
+/**
+ * Align renderbuffer pitch.
+ *
+ * This should be chosen by the driver and the loader (libGL, xserver/glx)
+ * should use the driver provided pitch.
+ *
+ * It seems that the xorg loader (that is the xserver loading swrast_dri for
+ * indirect rendering, not client-side libGL) requires that the pitch is
+ * exactly the image width padded to 32 bits. XXX
+ *
+ * The above restriction can probably be overcome by using ScratchPixmap and
+ * CopyArea in the xserver, similar to ShmPutImage, and setting the width of
+ * the scratch pixmap to 'pitch / cpp'.
+ */
+static inline int
+bytes_per_line(unsigned pitch_bits, unsigned mul)
+{
+ unsigned mask = mul - 1;
+
+ return ((pitch_bits + mask) & ~mask) / 8;
+}
+
static void
-swrastPutImage2(__DRIdrawable * draw, int op,
- int x, int y, int w, int h,
- char *data, int pitch, void *loaderPrivate)
+swrastPutImage(__DRIdrawable * draw, int op,
+ int x, int y, int w, int h,
+ char *data, void *loaderPrivate)
{
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);
ximage->data = data;
ximage->width = w;
ximage->height = h;
- ximage->bytes_per_line = pitch;
+ ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
}
static void
-swrastGetImage2(__DRIdrawable * read,
- int x, int y, int w, int h,
- char *data, int pitch, void *loaderPrivate)
+swrastGetImage(__DRIdrawable * read,
+ int x, int y, int w, int h,
+ char *data, void *loaderPrivate)
{
__GLXDRIdrawablePrivate *prp = loaderPrivate;
__GLXDRIdrawable *pread = &(prp->base);
ximage->data = data;
ximage->width = w;
ximage->height = h;
- ximage->bytes_per_line = pitch;
+ ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
ximage->data = NULL;
}
-/**
- * Align renderbuffer pitch.
- *
- * This should be chosen by the driver and the loader (libGL, xserver/glx)
- * should use the driver provided pitch.
- *
- * It seems that the xorg loader (that is the xserver loading swrast_dri for
- * indirect rendering, not client-side libGL) requires that the pitch is
- * exactly the image width padded to 32 bits. XXX
- *
- * Is this a hard requirement that requires extra copies for different pitches
- * or can the xorg loader use the driver pitch without extra copies ?
- */
-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,