summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-11-05 15:59:55 -0700
committerBrian <brian.paul@tungstengraphics.com>2007-11-05 15:59:55 -0700
commite39f1b4cbea6d41dc09430bd3d811cb7bbdea5f8 (patch)
tree82f76d36cbde01e22b58a257971ec52d414a06d1 /src
parent9a563d5e696a7c8fc09f7da5a0d33a9675b00e4c (diff)
Update xlib driver to use newer state tracker context/framebuffer functions.
XMesaContext has an st_context * which contains a mesa context.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_screen.c2
-rw-r--r--src/mesa/pipe/xlib/fakeglx.c17
-rw-r--r--src/mesa/pipe/xlib/xm_api.c160
-rw-r--r--src/mesa/pipe/xlib/xmesaP.h31
-rw-r--r--src/mesa/state_tracker/st_context.c7
-rw-r--r--src/mesa/state_tracker/st_context.h3
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c84
-rw-r--r--src/mesa/state_tracker/st_public.h9
8 files changed, 170 insertions, 143 deletions
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_screen.c b/src/mesa/drivers/dri/intel_winsys/intel_screen.c
index fa5c19ecd7..899988340e 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_screen.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_screen.c
@@ -283,7 +283,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
if (!intelfb)
return GL_FALSE;
- intelfb->stfb = st_create_framebuffer(mesaVis);
+ intelfb->stfb = st_create_framebuffer(mesaVis, GL_TRUE, (void*) intelfb);
if (!intelfb->stfb) {
free(intelfb);
return GL_FALSE;
diff --git a/src/mesa/pipe/xlib/fakeglx.c b/src/mesa/pipe/xlib/fakeglx.c
index 7a170b4d3d..d7e7b292d1 100644
--- a/src/mesa/pipe/xlib/fakeglx.c
+++ b/src/mesa/pipe/xlib/fakeglx.c
@@ -51,6 +51,9 @@
#include "version.h"
#include "xfonts.h"
#include "xmesaP.h"
+#include "state_tracker/st_context.h"
+#include "state_tracker/st_public.h"
+
#ifdef __VMS
#define _mesa_sprintf sprintf
@@ -1617,7 +1620,7 @@ Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
if (MakeCurrent_PrevContext == src) {
_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,
switch (attribute) {
case GLX_WIDTH:
- *value = xmbuf->mesa_buffer.Width;
+ *value = xmesa_buffer_width(xmbuf);
break;
case GLX_HEIGHT:
- *value = xmbuf->mesa_buffer.Height;
+ *value = xmesa_buffer_width(xmbuf);
break;
case GLX_PRESERVED_CONTENTS:
*value = True;
break;
case GLX_LARGEST_PBUFFER:
- *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
+ *value = xmesa_buffer_width(xmbuf) * xmesa_buffer_height(xmbuf);
break;
case GLX_FBCONFIG_ID:
*value = xmbuf->xm_visual->visinfo->visualid;
@@ -2762,13 +2765,13 @@ Fake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, un
*value = True;
break;
case GLX_LARGEST_PBUFFER_SGIX:
- *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
+ *value = xmesa_buffer_width(xmbuf) * xmesa_buffer_height(xmbuf);
break;
case GLX_WIDTH_SGIX:
- *value = xmbuf->mesa_buffer.Width;
+ *value = xmesa_buffer_width(xmbuf);
break;
case GLX_HEIGHT_SGIX:
- *value = xmbuf->mesa_buffer.Height;
+ *value = xmesa_buffer_height(xmbuf);
break;
case GLX_EVENT_MASK_SGIX:
*value = 0; /* XXX might be wrong */
diff --git a/src/mesa/pipe/xlib/xm_api.c b/src/mesa/pipe/xlib/xm_api.c
index 7f144a5d32..abd0b4f292 100644
--- a/src/mesa/pipe/xlib/xm_api.c
+++ b/src/mesa/pipe/xlib/xm_api.c
@@ -300,6 +300,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
XMesaVisual vis, XMesaColormap cmap)
{
XMesaBuffer b;
+ GLframebuffer *fb;
ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER);
@@ -312,8 +313,13 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
b->type = type;
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.
@@ -330,8 +336,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
b->frontxrb->Parent = b;
b->frontxrb->drawable = d;
b->frontxrb->pixmap = (XMesaPixmap) d;
- _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_FRONT_LEFT,
- &b->frontxrb->St.Base);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &b->frontxrb->St.Base);
#if 0 /* sketch... */
{
struct pipe_surface *front_surf;
@@ -339,8 +344,6 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
}
#endif
-
-
/*
* Back renderbuffer
*/
@@ -355,8 +358,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
/* determine back buffer implementation */
b->db_mode = vis->ximage_flag ? BACK_XIMAGE : BACK_PIXMAP;
- _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_BACK_LEFT,
- &b->backxrb->St.Base);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &b->backxrb->St.Base);
}
/*
@@ -379,34 +381,34 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
/* combined depth/stencil */
struct gl_renderbuffer *rb
= st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
- _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_DEPTH, rb);
- _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_STENCIL, rb);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
}
else {
if (vis->mesa_visual.depthBits > 0) {
struct gl_renderbuffer *rb
= 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) {
struct gl_renderbuffer *rb
= 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) {
struct gl_renderbuffer *rb
= 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)
*/
- _mesa_add_soft_renderbuffers(&b->mesa_buffer,
+ _mesa_add_soft_renderbuffers(fb,
GL_FALSE, /* color */
GL_FALSE, /*vis->mesa_visual.haveDepthBuffer,*/
GL_FALSE, /* stencil */
@@ -454,7 +456,7 @@ xmesa_free_buffer(XMesaBuffer buffer)
for (b = XMesaBufferList; b; b = b->Next) {
if (b == buffer) {
- struct gl_framebuffer *fb = &buffer->mesa_buffer;
+ struct gl_framebuffer *fb = &buffer->stfb->Base;
/* unlink buffer from list */
if (prev)
@@ -1112,11 +1114,12 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
* Convert an RGBA color to a pixel value.
*/
unsigned long
-xmesa_color_to_pixel(GLcontext *ctx,
+xmesa_color_to_pixel(XMesaContext xmesa,
GLubyte r, GLubyte g, GLubyte b, GLubyte a,
GLuint pixelFormat)
{
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GLcontext *ctx = xmesa->st->ctx;
+
switch (pixelFormat) {
case PF_Index:
return 0;
@@ -1444,9 +1447,11 @@ PUBLIC
XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
{
static GLboolean firstTime = GL_TRUE;
+ struct pipe_context *pipe;
XMesaContext c;
GLcontext *mesaCtx;
- struct dd_function_table functions;
+
+ (void) xmesa_init_driver_functions;
if (firstTime) {
_glthread_INIT_MUTEX(_xmesa_lock);
@@ -1458,29 +1463,20 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
if (!c)
return NULL;
- mesaCtx = &(c->mesa);
-
- /* 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);
+ pipe = xmesa_create_softpipe( c );
- if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual,
- share_list ? &(share_list->mesa) : (GLcontext *) NULL,
- &functions, (void *) c)) {
- _mesa_free(c);
- return NULL;
- }
+ c->st = st_create_context2(pipe, &v->mesa_visual,
+ share_list ? share_list->st : NULL);
+ mesaCtx = c->st->ctx;
+ c->st->ctx->DriverCtx = c;
+#if 00
_mesa_enable_sw_extensions(mesaCtx);
_mesa_enable_1_3_extensions(mesaCtx);
_mesa_enable_1_4_extensions(mesaCtx);
_mesa_enable_1_5_extensions(mesaCtx);
_mesa_enable_2_0_extensions(mesaCtx);
+#endif
#ifdef XFree86Server
/* If we're running in the X server, do bounds checking to prevent
@@ -1496,25 +1492,18 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
c->display = v->display;
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
* the softpipe driver.
*/
-#if 0
- mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc;
- mesaCtx->st->pipe->is_format_supported = xmesa_is_format_supported;
-#endif
- 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;
+ pipe->get_tile = xmesa_get_tile;
+ pipe->put_tile = xmesa_put_tile;
+ pipe->get_tile_rgba = xmesa_get_tile_rgba;
+ pipe->put_tile_rgba = xmesa_put_tile_rgba;
- mesaCtx->st->haveFramebufferRegions = GL_FALSE;
+ c->st->haveFramebufferRegions = GL_FALSE;
/* special pipe->clear function */
- mesaCtx->st->pipe->clear = xmesa_clear;
+ pipe->clear = xmesa_clear;
return c;
}
@@ -1524,10 +1513,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
PUBLIC
void XMesaDestroyContext( XMesaContext c )
{
- GLcontext *mesaCtx = &c->mesa;
-
- _mesa_free_context_data( mesaCtx );
- _mesa_free( c );
+ st_destroy_context2(c->st);
+ _mesa_free(c);
}
@@ -1645,7 +1632,7 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
/* get pixmap size, update framebuffer/renderbuffer dims */
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) {
/* examine dims */
@@ -1746,12 +1733,7 @@ xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer)
{
GLuint width, height;
xmesa_get_window_size(drawBuffer->display, drawBuffer, &width, &height);
- if (drawBuffer->mesa_buffer.Width != width ||
- 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? */
+ st_resize_framebuffer(drawBuffer->stfb, width, height);
}
@@ -1775,6 +1757,8 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
if (!drawBuffer || !readBuffer)
return GL_FALSE; /* must specify buffers! */
+#if 0
+ /* XXX restore this optimization */
if (&(c->mesa) == _mesa_get_current_context()
&& c->mesa.DrawBuffer == &drawBuffer->mesa_buffer
&& c->mesa.ReadBuffer == &readBuffer->mesa_buffer
@@ -1782,6 +1766,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
/* same context and buffer, do nothing */
return GL_TRUE;
}
+#endif
c->xm_buffer = drawBuffer;
@@ -1794,16 +1779,15 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
if (readBuffer != drawBuffer)
xmesa_check_and_update_buffer_size(c, readBuffer);
- _mesa_make_current(&(c->mesa),
- &drawBuffer->mesa_buffer,
- &readBuffer->mesa_buffer);
+ st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb);
+#if 0
if (c->xm_visual->mesa_visual.rgbMode) {
/*
* Must recompute and set these pixel values because colormap
* 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[1],
c->clearcolor[2],
@@ -1811,13 +1795,14 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
c->xm_visual->undithered_pf);
XMesaSetForeground(c->display, drawBuffer->cleargc, c->clearpixel);
}
+#endif
/* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */
drawBuffer->wasCurrent = GL_TRUE;
}
else {
/* Detach */
- _mesa_make_current( NULL, NULL, NULL );
+ st_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
}
@@ -1925,8 +1910,6 @@ GLboolean XMesaSetFXmode( GLint mode )
PUBLIC
void XMesaSwapBuffers( XMesaBuffer b )
{
- GET_CURRENT_CONTEXT(ctx);
-
if (!b->backxrb) {
/* single buffered */
return;
@@ -1935,8 +1918,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
/* 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);
+ st_notify_swapbuffers(b->stfb);
if (b->db_mode) {
if (b->backxrb->ximage) {
@@ -1947,7 +1929,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
XShmPutImage( b->xm_visual->display, b->frontxrb->drawable,
b->swapgc,
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 );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
@@ -1958,7 +1940,8 @@ void XMesaSwapBuffers( XMesaBuffer b )
XMesaPutImage( b->xm_visual->display, b->frontxrb->drawable,
b->swapgc,
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);*/
}
}
@@ -1969,14 +1952,16 @@ void XMesaSwapBuffers( XMesaBuffer b )
b->backxrb->pixmap, /* source drawable */
b->frontxrb->drawable, /* dest. drawable */
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 */
);
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
- if (b->swAlpha)
- _mesa_copy_soft_alpha_renderbuffers(ctx, &b->mesa_buffer);
+ if (b->swAlpha) {
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_copy_soft_alpha_renderbuffers(ctx, &b->stfb->Base);
+ }
}
#if !defined(XFree86Server)
XSync( b->xm_visual->display, False );
@@ -1990,21 +1975,18 @@ void XMesaSwapBuffers( XMesaBuffer b )
*/
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) {
/* single buffered */
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) {
- int yTop = b->mesa_buffer.Height - y - height;
+ int yTop = xmesa_buffer_height(b) - y - height;
if (b->backxrb->ximage) {
/* Copy Ximage from host's memory to server's window */
#if defined(USE_XSHM) && !defined(XFree86Server)
@@ -2082,7 +2064,7 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
GLint *bytesPerValue, void **buffer )
{
struct gl_renderbuffer *rb
- = b->mesa_buffer.Attachment[BUFFER_DEPTH].Renderbuffer;
+ = b->stfb->Base.Attachment[BUFFER_DEPTH].Renderbuffer;
if (!rb || !rb->Data) {
*width = 0;
*height = 0;
@@ -2091,9 +2073,9 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
return GL_FALSE;
}
else {
- *width = b->mesa_buffer.Width;
- *height = b->mesa_buffer.Height;
- *bytesPerValue = b->mesa_buffer.Visual.depthBits <= 16
+ *width = xmesa_buffer_width(b);
+ *height = xmesa_buffer_height(b);
+ *bytesPerValue = b->stfb->Base.Visual.depthBits <= 16
? sizeof(GLushort) : sizeof(GLuint);
*buffer = rb->Data;
return GL_TRUE;
@@ -2103,11 +2085,11 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
void XMesaFlush( XMesaContext c )
{
- if (c && c->xm_visual) {
+ if (c && c->display) {
#ifdef XFree86Server
/* NOT_NEEDED */
#else
- XSync( c->xm_visual->display, False );
+ XSync( c->display, False );
#endif
}
}
@@ -2185,7 +2167,7 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
GLfloat red, GLfloat green,
GLfloat blue, GLfloat alpha )
{
- GLcontext *ctx = &xmesa->mesa;
+ GLcontext *ctx = xmesa->st->ctx;
GLint r = (GLint) (red * 255.0F);
GLint g = (GLint) (green * 255.0F);
GLint b = (GLint) (blue * 255.0F);
@@ -2311,7 +2293,7 @@ XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer,
if (drawable->TextureFormat == GLX_TEXTURE_FORMAT_NONE_EXT)
return; /* BadMatch error */
- rb = drawable->mesa_buffer.Attachment[b].Renderbuffer;
+ rb = drawable->stfb->Base.Attachment[b].Renderbuffer;
if (!rb) {
/* invalid buffer */
return;
diff --git a/src/mesa/pipe/xlib/xmesaP.h b/src/mesa/pipe/xlib/xmesaP.h
index 506db859bb..f1ca2a8fe8 100644
--- a/src/mesa/pipe/xlib/xmesaP.h
+++ b/src/mesa/pipe/xlib/xmesaP.h
@@ -33,6 +33,8 @@
#include "xm_image.h"
#endif
#include "state_tracker/st_cb_fbo.h"
+#include "state_tracker/st_context.h"
+#include "state_tracker/st_public.h"
#include "pipe/softpipe/sp_context.h"
#include "pipe/softpipe/sp_surface.h"
@@ -116,7 +118,8 @@ struct xmesa_visual {
* Basically corresponds to a GLXContext.
*/
struct xmesa_context {
- GLcontext mesa; /* the core library context (containment) */
+ struct st_context *st;
+
XMesaVisual xm_visual; /* Describes the buffers */
XMesaBuffer xm_buffer; /* current span/point/line/triangle buffer */
@@ -187,8 +190,8 @@ struct xmesa_renderbuffer
* Basically corresponds to a GLXDrawable.
*/
struct xmesa_buffer {
- GLframebuffer mesa_buffer; /* depth, stencil, accum, etc buffers */
- /* This MUST BE FIRST! */
+ struct st_framebuffer *stfb;
+
GLboolean wasCurrent; /* was ever the current buffer? */
XMesaVisual xm_visual; /* the X/Mesa visual */
@@ -458,7 +461,7 @@ extern XMesaBuffer
xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis);
extern unsigned long
-xmesa_color_to_pixel( GLcontext *ctx,
+xmesa_color_to_pixel( XMesaContext xmesa,
GLubyte r, GLubyte g, GLubyte b, GLubyte a,
GLuint pixelFormat );
@@ -492,7 +495,7 @@ xmesa_renderbuffer(struct gl_renderbuffer *rb)
static INLINE XMesaContext
XMESA_CONTEXT(GLcontext *ctx)
{
- return (XMesaContext) ctx;
+ return (XMesaContext) ctx->DriverCtx;
}
@@ -502,9 +505,10 @@ XMESA_CONTEXT(GLcontext *ctx)
* XXX should use inlined function for better type safety.
*/
static INLINE XMesaBuffer
-XMESA_BUFFER(GLframebuffer *b)
+XMESA_BUFFER(GLframebuffer *fb)
{
- return (XMesaBuffer) b;
+ struct st_framebuffer *stfb = (struct st_framebuffer *) fb;
+ return (XMesaBuffer) st_framebuffer_private(stfb);
}
@@ -564,4 +568,17 @@ xmesa_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps,
extern struct pipe_surface *
xmesa_create_front_surface(XMesaVisual vis, Window win);
+static INLINE GLuint
+xmesa_buffer_width(XMesaBuffer b)
+{
+ return b->stfb->Base.Width;
+}
+
+static INLINE GLuint
+xmesa_buffer_height(XMesaBuffer b)
+{
+ return b->stfb->Base.Height;
+}
+
+
#endif
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index a8cc618d77..138f18aa99 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -174,6 +174,13 @@ void st_make_current(struct st_context *st,
}
+void st_copy_context_state(struct st_context *dst,
+ struct st_context *src,
+ uint mask)
+{
+ _mesa_copy_context(dst->ctx, src->ctx, mask);
+}
+
void st_init_driver_functions(struct dd_function_table *functions)
{
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 9b232827f4..30407768b9 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -168,12 +168,13 @@ static INLINE struct st_context *st_context(GLcontext *ctx)
/**
- * Wrapper for GLframebuffer, nothing extra for now.
+ * Wrapper for GLframebuffer.
* This is an opaque type to the outside world.
*/
struct st_framebuffer
{
GLframebuffer Base;
+ void *Private;
};
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index 2e7687d9c9..ec120ba39a 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -35,7 +35,9 @@
#include "st_cb_fbo.h"
-struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual )
+struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
+ boolean createRenderbuffers,
+ void *private)
{
struct st_framebuffer *stfb
= CALLOC_STRUCT(st_framebuffer);
@@ -46,46 +48,48 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual )
_mesa_initialize_framebuffer(&stfb->Base, visual);
- {
- /* fake frontbuffer */
- /* XXX allocation should only happen in the unusual case
- it's actually needed */
- struct gl_renderbuffer *rb = st_new_renderbuffer_fb(rgbFormat);
- _mesa_add_renderbuffer(&stfb->Base, BUFFER_FRONT_LEFT, rb);
+ if (createRenderbuffers) {
+ {
+ /* fake frontbuffer */
+ /* XXX allocation should only happen in the unusual case
+ it's actually needed */
+ struct gl_renderbuffer *rb = st_new_renderbuffer_fb(rgbFormat);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_FRONT_LEFT, rb);
+ }
+
+ if (visual->doubleBufferMode) {
+ struct gl_renderbuffer *rb = st_new_renderbuffer_fb(rgbFormat);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
+ }
+
+ if (visual->depthBits == 24 && visual->stencilBits == 8) {
+ /* combined depth/stencil buffer */
+ struct gl_renderbuffer *depthStencilRb
+ = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
+ /* note: bind RB to two attachment points */
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthStencilRb);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL,depthStencilRb);
+ }
+ else if (visual->depthBits == 16) {
+ /* just 16-bit depth buffer, no hw stencil */
+ struct gl_renderbuffer *depthRb
+ = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT16);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
+ }
+
+
+ /* now add any/all software-based renderbuffers we may need */
+ _mesa_add_soft_renderbuffers(&stfb->Base,
+ GL_FALSE, /* never sw color */
+ GL_FALSE, /* never sw depth */
+ swStencil, visual->accumRedBits > 0,
+ GL_FALSE, /* never sw alpha */
+ GL_FALSE /* never sw aux */ );
}
- if (visual->doubleBufferMode) {
- struct gl_renderbuffer *rb = st_new_renderbuffer_fb(rgbFormat);
- _mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
- }
-
- if (visual->depthBits == 24 && visual->stencilBits == 8) {
- /* combined depth/stencil buffer */
- struct gl_renderbuffer *depthStencilRb
- = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
- /* note: bind RB to two attachment points */
- _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthStencilRb);
- _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL,depthStencilRb);
- }
- else if (visual->depthBits == 16) {
- /* just 16-bit depth buffer, no hw stencil */
- struct gl_renderbuffer *depthRb
- = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT16);
- _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
- }
-
-
- /* now add any/all software-based renderbuffers we may need */
- _mesa_add_soft_renderbuffers(&stfb->Base,
- GL_FALSE, /* never sw color */
- GL_FALSE, /* never sw depth */
- swStencil, visual->accumRedBits > 0,
- GL_FALSE, /* never sw alpha */
- GL_FALSE /* never sw aux */ );
-
-
stfb->Base.Initialized = GL_TRUE;
+ stfb->Private = private;
}
return stfb;
}
@@ -149,3 +153,9 @@ st_notify_swapbuffers(struct st_framebuffer *stfb)
}
}
+
+void *st_framebuffer_private( struct st_framebuffer *stfb )
+{
+ return stfb->Private;
+}
+
diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h
index 8162ceeffa..c94e8d32c8 100644
--- a/src/mesa/state_tracker/st_public.h
+++ b/src/mesa/state_tracker/st_public.h
@@ -53,7 +53,12 @@ void st_destroy_context( struct st_context *st );
void st_destroy_context2( struct st_context *st );
-struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual );
+void st_copy_context_state(struct st_context *dst, struct st_context *src,
+ uint mask);
+
+struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
+ GLboolean createRenderbuffers,
+ void *privateData);
void st_resize_framebuffer( struct st_framebuffer *stfb,
GLuint width, GLuint height );
@@ -61,6 +66,8 @@ void st_resize_framebuffer( struct st_framebuffer *stfb,
struct pipe_surface *st_get_framebuffer_surface(struct st_framebuffer *stfb,
uint surfIndex);
+void *st_framebuffer_private( struct st_framebuffer *stfb );
+
void st_unreference_framebuffer( struct st_framebuffer **stfb );
void st_make_current(struct st_context *st,