Commit e39f1b4c authored by Brian's avatar Brian

Update xlib driver to use newer state tracker context/framebuffer functions.

XMesaContext has an st_context * which contains a mesa context.
parent 9a563d5e
...@@ -283,7 +283,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, ...@@ -283,7 +283,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
if (!intelfb) if (!intelfb)
return GL_FALSE; return GL_FALSE;
intelfb->stfb = st_create_framebuffer(mesaVis); intelfb->stfb = st_create_framebuffer(mesaVis, GL_TRUE, (void*) intelfb);
if (!intelfb->stfb) { if (!intelfb->stfb) {
free(intelfb); free(intelfb);
return GL_FALSE; return GL_FALSE;
......
...@@ -51,6 +51,9 @@ ...@@ -51,6 +51,9 @@
#include "version.h" #include "version.h"
#include "xfonts.h" #include "xfonts.h"
#include "xmesaP.h" #include "xmesaP.h"
#include "state_tracker/st_context.h"
#include "state_tracker/st_public.h"
#ifdef __VMS #ifdef __VMS
#define _mesa_sprintf sprintf #define _mesa_sprintf sprintf
...@@ -1617,7 +1620,7 @@ Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, ...@@ -1617,7 +1620,7 @@ Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
if (MakeCurrent_PrevContext == src) { if (MakeCurrent_PrevContext == src) {
_mesa_Flush(); _mesa_Flush();
} }
_mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask ); st_copy_context_state( xm_src->st, xm_dst->st, (GLuint) mask );
} }
...@@ -2383,16 +2386,16 @@ Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, ...@@ -2383,16 +2386,16 @@ Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
switch (attribute) { switch (attribute) {
case GLX_WIDTH: case GLX_WIDTH:
*value = xmbuf->mesa_buffer.Width; *value = xmesa_buffer_width(xmbuf);
break; break;
case GLX_HEIGHT: case GLX_HEIGHT:
*value = xmbuf->mesa_buffer.Height; *value = xmesa_buffer_width(xmbuf);
break; break;
case GLX_PRESERVED_CONTENTS: case GLX_PRESERVED_CONTENTS:
*value = True; *value = True;
break; break;
case GLX_LARGEST_PBUFFER: case GLX_LARGEST_PBUFFER:
*value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height; *value = xmesa_buffer_width(xmbuf) * xmesa_buffer_height(xmbuf);
break; break;
case GLX_FBCONFIG_ID: case GLX_FBCONFIG_ID:
*value = xmbuf->xm_visual->visinfo->visualid; *value = xmbuf->xm_visual->visinfo->visualid;
...@@ -2762,13 +2765,13 @@ Fake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, un ...@@ -2762,13 +2765,13 @@ Fake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, un
*value = True; *value = True;
break; break;
case GLX_LARGEST_PBUFFER_SGIX: case GLX_LARGEST_PBUFFER_SGIX:
*value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height; *value = xmesa_buffer_width(xmbuf) * xmesa_buffer_height(xmbuf);
break; break;
case GLX_WIDTH_SGIX: case GLX_WIDTH_SGIX:
*value = xmbuf->mesa_buffer.Width; *value = xmesa_buffer_width(xmbuf);
break; break;
case GLX_HEIGHT_SGIX: case GLX_HEIGHT_SGIX:
*value = xmbuf->mesa_buffer.Height; *value = xmesa_buffer_height(xmbuf);
break; break;
case GLX_EVENT_MASK_SGIX: case GLX_EVENT_MASK_SGIX:
*value = 0; /* XXX might be wrong */ *value = 0; /* XXX might be wrong */
......
...@@ -300,6 +300,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, ...@@ -300,6 +300,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
XMesaVisual vis, XMesaColormap cmap) XMesaVisual vis, XMesaColormap cmap)
{ {
XMesaBuffer b; XMesaBuffer b;
GLframebuffer *fb;
ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER); ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER);
...@@ -312,8 +313,13 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, ...@@ -312,8 +313,13 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
b->type = type; b->type = type;
b->cmap = cmap; b->cmap = cmap;
_mesa_initialize_framebuffer(&b->mesa_buffer, &vis->mesa_visual); /*
b->mesa_buffer.Delete = xmesa_delete_framebuffer; * Create framebuffer, but we'll plug in our own renderbuffers below.
*/
b->stfb = st_create_framebuffer(&vis->mesa_visual, GL_FALSE, (void *) b);
fb = &b->stfb->Base;
fb->Delete = xmesa_delete_framebuffer;
/* /*
* XXX we want to create surfaces for pipe, not renderbuffers for Mesa. * XXX we want to create surfaces for pipe, not renderbuffers for Mesa.
...@@ -330,8 +336,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, ...@@ -330,8 +336,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
b->frontxrb->Parent = b; b->frontxrb->Parent = b;
b->frontxrb->drawable = d; b->frontxrb->drawable = d;
b->frontxrb->pixmap = (XMesaPixmap) d; b->frontxrb->pixmap = (XMesaPixmap) d;
_mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_FRONT_LEFT, _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &b->frontxrb->St.Base);
&b->frontxrb->St.Base);
#if 0 /* sketch... */ #if 0 /* sketch... */
{ {
struct pipe_surface *front_surf; struct pipe_surface *front_surf;
...@@ -339,8 +344,6 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, ...@@ -339,8 +344,6 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
} }
#endif #endif
/* /*
* Back renderbuffer * Back renderbuffer
*/ */
...@@ -355,8 +358,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, ...@@ -355,8 +358,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
/* determine back buffer implementation */ /* determine back buffer implementation */
b->db_mode = vis->ximage_flag ? BACK_XIMAGE : BACK_PIXMAP; b->db_mode = vis->ximage_flag ? BACK_XIMAGE : BACK_PIXMAP;
_mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_BACK_LEFT, _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &b->backxrb->St.Base);
&b->backxrb->St.Base);
} }
/* /*
...@@ -379,34 +381,34 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, ...@@ -379,34 +381,34 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
/* combined depth/stencil */ /* combined depth/stencil */
struct gl_renderbuffer *rb struct gl_renderbuffer *rb
= st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT); = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
_mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_DEPTH, rb); _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
_mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_STENCIL, rb); _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
} }
else { else {
if (vis->mesa_visual.depthBits > 0) { if (vis->mesa_visual.depthBits > 0) {
struct gl_renderbuffer *rb struct gl_renderbuffer *rb
= st_new_renderbuffer_fb(GL_DEPTH_COMPONENT32); = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT32);
_mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_DEPTH, rb); _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
} }
if (vis->mesa_visual.stencilBits > 0) { if (vis->mesa_visual.stencilBits > 0) {
struct gl_renderbuffer *rb struct gl_renderbuffer *rb
= st_new_renderbuffer_fb(GL_STENCIL_INDEX8_EXT); = st_new_renderbuffer_fb(GL_STENCIL_INDEX8_EXT);
_mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_STENCIL, rb); _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
} }
} }
if (vis->mesa_visual.accumRedBits > 0) { if (vis->mesa_visual.accumRedBits > 0) {
struct gl_renderbuffer *rb struct gl_renderbuffer *rb
= st_new_renderbuffer_fb(GL_RGBA16); = st_new_renderbuffer_fb(GL_RGBA16);
_mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_ACCUM, rb); _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb);
} }
/* /*
* Other renderbuffer (depth, stencil, etc) * Other renderbuffer (depth, stencil, etc)
*/ */
_mesa_add_soft_renderbuffers(&b->mesa_buffer, _mesa_add_soft_renderbuffers(fb,
GL_FALSE, /* color */ GL_FALSE, /* color */
GL_FALSE, /*vis->mesa_visual.haveDepthBuffer,*/ GL_FALSE, /*vis->mesa_visual.haveDepthBuffer,*/
GL_FALSE, /* stencil */ GL_FALSE, /* stencil */
...@@ -454,7 +456,7 @@ xmesa_free_buffer(XMesaBuffer buffer) ...@@ -454,7 +456,7 @@ xmesa_free_buffer(XMesaBuffer buffer)
for (b = XMesaBufferList; b; b = b->Next) { for (b = XMesaBufferList; b; b = b->Next) {
if (b == buffer) { if (b == buffer) {
struct gl_framebuffer *fb = &buffer->mesa_buffer; struct gl_framebuffer *fb = &buffer->stfb->Base;
/* unlink buffer from list */ /* unlink buffer from list */
if (prev) if (prev)
...@@ -1112,11 +1114,12 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, ...@@ -1112,11 +1114,12 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
* Convert an RGBA color to a pixel value. * Convert an RGBA color to a pixel value.
*/ */
unsigned long unsigned long
xmesa_color_to_pixel(GLcontext *ctx, xmesa_color_to_pixel(XMesaContext xmesa,
GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLubyte r, GLubyte g, GLubyte b, GLubyte a,
GLuint pixelFormat) GLuint pixelFormat)
{ {
XMesaContext xmesa = XMESA_CONTEXT(ctx); GLcontext *ctx = xmesa->st->ctx;
switch (pixelFormat) { switch (pixelFormat) {
case PF_Index: case PF_Index:
return 0; return 0;
...@@ -1444,9 +1447,11 @@ PUBLIC ...@@ -1444,9 +1447,11 @@ PUBLIC
XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
{ {
static GLboolean firstTime = GL_TRUE; static GLboolean firstTime = GL_TRUE;
struct pipe_context *pipe;
XMesaContext c; XMesaContext c;
GLcontext *mesaCtx; GLcontext *mesaCtx;
struct dd_function_table functions;
(void) xmesa_init_driver_functions;
if (firstTime) { if (firstTime) {
_glthread_INIT_MUTEX(_xmesa_lock); _glthread_INIT_MUTEX(_xmesa_lock);
...@@ -1458,29 +1463,20 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) ...@@ -1458,29 +1463,20 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
if (!c) if (!c)
return NULL; return NULL;
mesaCtx = &(c->mesa); pipe = xmesa_create_softpipe( c );
/* initialize with default driver functions, then plug in XMesa funcs */
#if 0
_mesa_init_driver_functions(&functions);
#else
memset(&functions, 0, sizeof(functions));
#endif
xmesa_init_driver_functions(v, &functions);
st_init_driver_functions(&functions);
if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual, c->st = st_create_context2(pipe, &v->mesa_visual,
share_list ? &(share_list->mesa) : (GLcontext *) NULL, share_list ? share_list->st : NULL);
&functions, (void *) c)) { mesaCtx = c->st->ctx;
_mesa_free(c); c->st->ctx->DriverCtx = c;
return NULL;
}
#if 00
_mesa_enable_sw_extensions(mesaCtx); _mesa_enable_sw_extensions(mesaCtx);
_mesa_enable_1_3_extensions(mesaCtx); _mesa_enable_1_3_extensions(mesaCtx);
_mesa_enable_1_4_extensions(mesaCtx); _mesa_enable_1_4_extensions(mesaCtx);
_mesa_enable_1_5_extensions(mesaCtx); _mesa_enable_1_5_extensions(mesaCtx);
_mesa_enable_2_0_extensions(mesaCtx); _mesa_enable_2_0_extensions(mesaCtx);
#endif
#ifdef XFree86Server #ifdef XFree86Server
/* If we're running in the X server, do bounds checking to prevent /* If we're running in the X server, do bounds checking to prevent
...@@ -1496,25 +1492,18 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) ...@@ -1496,25 +1492,18 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
c->display = v->display; c->display = v->display;
c->pixelformat = v->dithered_pf; /* Dithering is enabled by default */ c->pixelformat = v->dithered_pf; /* Dithering is enabled by default */
st_create_context( mesaCtx,
xmesa_create_softpipe( c ) );
/* override these functions, as if the xlib driver were derived from /* override these functions, as if the xlib driver were derived from
* the softpipe driver. * the softpipe driver.
*/ */
#if 0 pipe->get_tile = xmesa_get_tile;
mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc; pipe->put_tile = xmesa_put_tile;
mesaCtx->st->pipe->is_format_supported = xmesa_is_format_supported; pipe->get_tile_rgba = xmesa_get_tile_rgba;
#endif pipe->put_tile_rgba = xmesa_put_tile_rgba;
mesaCtx->st->pipe->get_tile = xmesa_get_tile;
mesaCtx->st->pipe->put_tile = xmesa_put_tile;
mesaCtx->st->pipe->get_tile_rgba = xmesa_get_tile_rgba;
mesaCtx->st->pipe->put_tile_rgba = xmesa_put_tile_rgba;
mesaCtx->st->haveFramebufferRegions = GL_FALSE; c->st->haveFramebufferRegions = GL_FALSE;
/* special pipe->clear function */ /* special pipe->clear function */
mesaCtx->st->pipe->clear = xmesa_clear; pipe->clear = xmesa_clear;
return c; return c;
} }
...@@ -1524,10 +1513,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) ...@@ -1524,10 +1513,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
PUBLIC PUBLIC
void XMesaDestroyContext( XMesaContext c ) void XMesaDestroyContext( XMesaContext c )
{ {
GLcontext *mesaCtx = &c->mesa; st_destroy_context2(c->st);
_mesa_free(c);
_mesa_free_context_data( mesaCtx );
_mesa_free( c );
} }
...@@ -1645,7 +1632,7 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p, ...@@ -1645,7 +1632,7 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
/* get pixmap size, update framebuffer/renderbuffer dims */ /* get pixmap size, update framebuffer/renderbuffer dims */
xmesa_get_window_size(v->display, b, &width, &height); xmesa_get_window_size(v->display, b, &width, &height);
_mesa_resize_framebuffer(NULL, &(b->mesa_buffer), width, height); _mesa_resize_framebuffer(NULL, &(b->stfb->Base), width, height);
if (target == 0) { if (target == 0) {
/* examine dims */ /* examine dims */
...@@ -1746,12 +1733,7 @@ xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer) ...@@ -1746,12 +1733,7 @@ xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer)
{ {
GLuint width, height; GLuint width, height;
xmesa_get_window_size(drawBuffer->display, drawBuffer, &width, &height); xmesa_get_window_size(drawBuffer->display, drawBuffer, &width, &height);
if (drawBuffer->mesa_buffer.Width != width || st_resize_framebuffer(drawBuffer->stfb, width, height);
drawBuffer->mesa_buffer.Height != height) {
GLcontext *ctx = xmctx ? &xmctx->mesa : NULL;
_mesa_resize_framebuffer(ctx, &(drawBuffer->mesa_buffer), width, height);
}
drawBuffer->mesa_buffer.Initialized = GL_TRUE; /* XXX TEMPORARY? */
} }
...@@ -1775,6 +1757,8 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, ...@@ -1775,6 +1757,8 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
if (!drawBuffer || !readBuffer) if (!drawBuffer || !readBuffer)
return GL_FALSE; /* must specify buffers! */ return GL_FALSE; /* must specify buffers! */
#if 0
/* XXX restore this optimization */
if (&(c->mesa) == _mesa_get_current_context() if (&(c->mesa) == _mesa_get_current_context()
&& c->mesa.DrawBuffer == &drawBuffer->mesa_buffer && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer
&& c->mesa.ReadBuffer == &readBuffer->mesa_buffer && c->mesa.ReadBuffer == &readBuffer->mesa_buffer
...@@ -1782,6 +1766,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, ...@@ -1782,6 +1766,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
/* same context and buffer, do nothing */ /* same context and buffer, do nothing */
return GL_TRUE; return GL_TRUE;
} }
#endif
c->xm_buffer = drawBuffer; c->xm_buffer = drawBuffer;
...@@ -1794,16 +1779,15 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, ...@@ -1794,16 +1779,15 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
if (readBuffer != drawBuffer) if (readBuffer != drawBuffer)
xmesa_check_and_update_buffer_size(c, readBuffer); xmesa_check_and_update_buffer_size(c, readBuffer);
_mesa_make_current(&(c->mesa), st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb);
&drawBuffer->mesa_buffer,
&readBuffer->mesa_buffer);
#if 0
if (c->xm_visual->mesa_visual.rgbMode) { if (c->xm_visual->mesa_visual.rgbMode) {
/* /*
* Must recompute and set these pixel values because colormap * Must recompute and set these pixel values because colormap
* can be different for different windows. * can be different for different windows.
*/ */
c->clearpixel = xmesa_color_to_pixel( &c->mesa, c->clearpixel = xmesa_color_to_pixel( c,
c->clearcolor[0], c->clearcolor[0],
c->clearcolor[1], c->clearcolor[1],
c->clearcolor[2], c->clearcolor[2],
...@@ -1811,13 +1795,14 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, ...@@ -1811,13 +1795,14 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
c->xm_visual->undithered_pf); c->xm_visual->undithered_pf);
XMesaSetForeground(c->display, drawBuffer->cleargc, c->clearpixel); XMesaSetForeground(c->display, drawBuffer->cleargc, c->clearpixel);
} }
#endif
/* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */ /* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */
drawBuffer->wasCurrent = GL_TRUE; drawBuffer->wasCurrent = GL_TRUE;
} }
else { else {
/* Detach */ /* Detach */
_mesa_make_current( NULL, NULL, NULL ); st_make_current( NULL, NULL, NULL );
} }
return GL_TRUE; return GL_TRUE;
} }
...@@ -1925,8 +1910,6 @@ GLboolean XMesaSetFXmode( GLint mode ) ...@@ -1925,8 +1910,6 @@ GLboolean XMesaSetFXmode( GLint mode )
PUBLIC PUBLIC
void XMesaSwapBuffers( XMesaBuffer b ) void XMesaSwapBuffers( XMesaBuffer b )
{ {
GET_CURRENT_CONTEXT(ctx);
if (!b->backxrb) { if (!b->backxrb) {
/* single buffered */ /* single buffered */
return; return;
...@@ -1935,8 +1918,7 @@ void XMesaSwapBuffers( XMesaBuffer b ) ...@@ -1935,8 +1918,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
/* If we're swapping the buffer associated with the current context /* If we're swapping the buffer associated with the current context
* we have to flush any pending rendering commands first. * we have to flush any pending rendering commands first.
*/ */
if (ctx && ctx->DrawBuffer == &(b->mesa_buffer)) st_notify_swapbuffers(b->stfb);
_mesa_notifySwapBuffers(ctx);
if (b->db_mode) { if (b->db_mode) {
if (b->backxrb->ximage) { if (b->backxrb->ximage) {
...@@ -1947,7 +1929,7 @@ void XMesaSwapBuffers( XMesaBuffer b ) ...@@ -1947,7 +1929,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
XShmPutImage( b->xm_visual->display, b->frontxrb->drawable, XShmPutImage( b->xm_visual->display, b->frontxrb->drawable,
b->swapgc, b->swapgc,
b->backxrb->ximage, 0, 0, b->backxrb->ximage, 0, 0,
0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height, 0, 0, xmesa_buffer_width(b), xmesa_buffer_height(b),
False ); False );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/ /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
} }
...@@ -1958,7 +1940,8 @@ void XMesaSwapBuffers( XMesaBuffer b ) ...@@ -1958,7 +1940,8 @@ void XMesaSwapBuffers( XMesaBuffer b )
XMesaPutImage( b->xm_visual->display, b->frontxrb->drawable, XMesaPutImage( b->xm_visual->display, b->frontxrb->drawable,
b->swapgc, b->swapgc,
b->backxrb->ximage, 0, 0, b->backxrb->ximage, 0, 0,
0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height ); 0, 0,
xmesa_buffer_width(b), xmesa_buffer_height(b));
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/ /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
} }
} }
...@@ -1969,14 +1952,16 @@ void XMesaSwapBuffers( XMesaBuffer b ) ...@@ -1969,14 +1952,16 @@ void XMesaSwapBuffers( XMesaBuffer b )
b->backxrb->pixmap, /* source drawable */ b->backxrb->pixmap, /* source drawable */
b->frontxrb->drawable, /* dest. drawable */ b->frontxrb->drawable, /* dest. drawable */
b->swapgc, b->swapgc,
0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height, 0, 0, xmesa_buffer_width(b), xmesa_buffer_height(b),
0, 0 /* dest region */ 0, 0 /* dest region */
); );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/ /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
} }
if (b->swAlpha) if (b->swAlpha) {
_mesa_copy_soft_alpha_renderbuffers(ctx, &b->mesa_buffer); GET_CURRENT_CONTEXT(ctx);
_mesa_copy_soft_alpha_renderbuffers(ctx, &b->stfb->Base);
}
} }
#if !defined(XFree86Server) #if !defined(XFree86Server)
XSync( b->xm_visual->display, False ); XSync( b->xm_visual->display, False );
...@@ -1990,21 +1975,18 @@ void XMesaSwapBuffers( XMesaBuffer b ) ...@@ -1990,21 +1975,18 @@ void XMesaSwapBuffers( XMesaBuffer b )
*/ */
void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height ) void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
{ {
GET_CURRENT_CONTEXT(ctx);
/* If we're swapping the buffer associated with the current context
* we have to flush any pending rendering commands first.
*/
if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
_mesa_notifySwapBuffers(ctx);
if (!b->backxrb) { if (!b->backxrb) {
/* single buffered */ /* single buffered */
return; return;
} }
/* If we're swapping the buffer associated with the current context
* we have to flush any pending rendering commands first.
*/
st_notify_swapbuffers(b->stfb);
if (b->db_mode) { if (b->db_mode) {
int yTop = b->mesa_buffer.Height - y - height; int yTop = xmesa_buffer_height(b) - y - height;
if (b->backxrb->ximage) { if (b->backxrb->ximage) {
/* Copy Ximage from host's memory to server's window */ /* Copy Ximage from host's memory to server's window */
#if defined(USE_XSHM) && !defined(XFree86Server)