drisw: make stride issue profound
This commit is contained in:
parent
02ee7c2950
commit
f4e561ce12
|
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue