diff options
author | Dave Airlie <[email protected]> | 2013-11-28 11:08:11 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2013-12-13 14:37:01 +1000 |
commit | ba00f2f6f54cbc5ffdb0f0b94bcd672d147cdc36 (patch) | |
tree | 93cec2b58156f3fb87cbc425a7680253bb1fe82f /src/glx | |
parent | 40070e72d4f27797d03986a68b1540339eb2b496 (diff) |
swrast* (gallium, classic): add MESA_copy_sub_buffer support (v3)
This patches add MESA_copy_sub_buffer support to the dri sw loader and
then to gallium state tracker, llvmpipe, softpipe and other bits.
It reuses the dri1 driver extension interface, and it updates the swrast
loader interface for a new putimage which can take a stride.
I've tested this with gnome-shell with a cogl hacked to reenable sub copies
for llvmpipe and the one piglit test.
I could probably split this patch up as well.
v2: pass a pipe_box, to reduce the entrypoints, as per Jose's review,
add to p_screen doc comments.
v3: finish off winsys interfaces, add swrast classic support as well.
Reviewed-by: Jose Fonseca <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
swrast: add support for copy_sub_buffer
Diffstat (limited to 'src/glx')
-rw-r--r-- | src/glx/drisw_glx.c | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index cb1d650b5c1..13a4b96a1fb 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -49,6 +49,7 @@ struct drisw_screen const __DRIcoreExtension *core; const __DRIswrastExtension *swrast; const __DRItexBufferExtension *texBuffer; + const __DRIcopySubBufferExtension *copySubBuffer; const __DRIconfig **driver_configs; @@ -171,9 +172,9 @@ bytes_per_line(unsigned pitch_bits, unsigned mul) } 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, int stride, + char *data, void *loaderPrivate) { struct drisw_drawable *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); @@ -199,7 +200,7 @@ swrastPutImage(__DRIdrawable * draw, int op, ximage->data = data; ximage->width = w; ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32); + ximage->bytes_per_line = stride ? stride : bytes_per_line(w * ximage->bits_per_pixel, 32); XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h); @@ -207,6 +208,14 @@ swrastPutImage(__DRIdrawable * draw, int op, } static void +swrastPutImage(__DRIdrawable * draw, int op, + int x, int y, int w, int h, + char *data, void *loaderPrivate) +{ + swrastPutImage2(draw, op, x, y, w, h, 0, data, loaderPrivate); +} + +static void swrastGetImage(__DRIdrawable * read, int x, int y, int w, int h, char *data, void *loaderPrivate) @@ -234,7 +243,8 @@ static const __DRIswrastLoaderExtension swrastLoaderExtension = { {__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION}, swrastGetDrawableInfo, swrastPutImage, - swrastGetImage + swrastGetImage, + swrastPutImage2, }; static const __DRIextension *loader_extensions[] = { @@ -585,6 +595,21 @@ driswSwapBuffers(__GLXDRIdrawable * pdraw, } static void +driswCopySubBuffer(__GLXDRIdrawable * pdraw, + int x, int y, int width, int height, Bool flush) +{ + struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw; + struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc; + + if (flush) { + glFlush(); + } + + (*psc->copySubBuffer->copySubBuffer) (pdp->driDrawable, + x, y, width, height); +} + +static void driswDestroyScreen(struct glx_screen *base) { struct drisw_screen *psc = (struct drisw_screen *) base; @@ -632,6 +657,9 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions) "GLX_EXT_create_context_es2_profile"); } + if (psc->copySubBuffer) + __glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer"); + /* FIXME: Figure out what other extensions can be ported here from dri2. */ for (i = 0; extensions[i]; i++) { if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) { @@ -673,6 +701,8 @@ driswCreateScreen(int screen, struct glx_display *priv) psc->core = (__DRIcoreExtension *) extensions[i]; if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0) psc->swrast = (__DRIswrastExtension *) extensions[i]; + if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) + psc->copySubBuffer = (__DRIcopySubBufferExtension *) extensions[i]; } if (psc->core == NULL || psc->swrast == NULL) { @@ -718,6 +748,9 @@ driswCreateScreen(int screen, struct glx_display *priv) psp->createDrawable = driswCreateDrawable; psp->swapBuffers = driswSwapBuffers; + if (psc->copySubBuffer) + psp->copySubBuffer = driswCopySubBuffer; + return &psc->base; handle_error: |