diff options
Diffstat (limited to 'src/mesa/drivers/x11')
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 31 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_buffer.c | 102 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 9 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_span.c | 325 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_surface.c | 94 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xmesaP.h | 24 |
6 files changed, 369 insertions, 216 deletions
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 88e6bf8d6d..cea790dc60 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -84,6 +84,7 @@ #include "state_tracker/st_public.h" #include "state_tracker/st_context.h" #include "pipe/softpipe/sp_context.h" +#include "pipe/p_defines.h" /** * Global X driver lock @@ -385,7 +386,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, /* * Front renderbuffer */ - b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_FALSE); + b->frontxrb = xmesa_create_renderbuffer(NULL, 0, &vis->mesa_visual, GL_FALSE); if (!b->frontxrb) { _mesa_free(b); return NULL; @@ -394,13 +395,13 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, b->frontxrb->drawable = d; b->frontxrb->pixmap = (XMesaPixmap) d; _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_FRONT_LEFT, - &b->frontxrb->Base); + &b->frontxrb->St.Base); /* * Back renderbuffer */ if (vis->mesa_visual.doubleBufferMode) { - b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_TRUE); + b->backxrb = xmesa_create_renderbuffer(NULL, 0, &vis->mesa_visual, GL_TRUE); if (!b->backxrb) { /* XXX free front xrb too */ _mesa_free(b); @@ -411,7 +412,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, b->db_mode = vis->ximage_flag ? BACK_XIMAGE : BACK_PIXMAP; _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_BACK_LEFT, - &b->backxrb->Base); + &b->backxrb->St.Base); } /* @@ -429,12 +430,19 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, b->swAlpha = GL_FALSE; } + 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); + } + + /* * Other renderbuffer (depth, stencil, etc) */ _mesa_add_soft_renderbuffers(&b->mesa_buffer, GL_FALSE, /* color */ - vis->mesa_visual.haveDepthBuffer, + GL_FALSE,/*vis->mesa_visual.haveDepthBuffer,*/ vis->mesa_visual.haveStencilBuffer, vis->mesa_visual.haveAccumBuffer, b->swAlpha, @@ -1517,6 +1525,10 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) xmesa_init_driver_functions(v, &functions); st_init_driver_functions(&functions); + /* + functions.NewRenderbuffer = xmesa_new_renderbuffer; + */ + if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual, share_list ? &(share_list->mesa) : (GLcontext *) NULL, &functions, (void *) c)) { @@ -1576,10 +1588,15 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) st_create_context( mesaCtx, xmesa_create_softpipe( c ) ); + mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc; + mesaCtx->st->pipe->supported_formats = xmesa_supported_formats; + +#if 1 mesaCtx->Driver.Clear = xmesa_clear_buffers; - /* +#endif +#if 0 mesaCtx->st->pipe->clear = xmesa_clear; - */ +#endif return c; } diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 5bba52da48..fb6815ae1e 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -36,6 +36,8 @@ #include "framebuffer.h" #include "renderbuffer.h" #include "pipe/p_state.h" +#include "pipe/p_defines.h" +#include "state_tracker/st_context.h" #if defined(USE_XSHM) && !defined(XFree86Server) @@ -269,10 +271,10 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->Height = height; rb->InternalFormat = internalFormat; - if (!xrb->Base.surface) - xrb->Base.surface = xmesa_new_surface(ctx, xrb); - xrb->Base.surface->width = width; - xrb->Base.surface->height = height; + if (!xrb->St.surface) + xrb->St.surface = xmesa_new_surface(ctx, xrb); + xrb->St.surface->width = width; + xrb->St.surface->height = height; return GL_TRUE; } @@ -323,49 +325,101 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, xrb->origin4 = NULL; } - if (!xrb->Base.surface) - xrb->Base.surface = xmesa_new_surface(ctx, xrb); - xrb->Base.surface->width = width; - xrb->Base.surface->height = height; + if (!xrb->St.surface) + xrb->St.surface = xmesa_new_surface(ctx, xrb); + xrb->St.surface->width = width; + xrb->St.surface->height = height; return GL_TRUE; } +/** + * Called to create the front/back color renderbuffers, not user-created + * renderbuffers. + */ struct xmesa_renderbuffer * -xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, +xmesa_create_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, GLboolean backBuffer) { struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer); + struct pipe_context *pipe = NULL;/*ctx->st->pipe;*/ + if (xrb) { + GLuint name = 0; + GLuint pipeFormat = 0; + struct xmesa_surface *xms; + + _mesa_init_renderbuffer(&xrb->St.Base, name); + + xrb->St.Base.Delete = xmesa_delete_renderbuffer; + if (backBuffer) + xrb->St.Base.AllocStorage = xmesa_alloc_back_storage; + else + xrb->St.Base.AllocStorage = xmesa_alloc_front_storage; + + if (visual->rgbMode) { + xrb->St.Base.InternalFormat = GL_RGBA; + xrb->St.Base._BaseFormat = GL_RGBA; + xrb->St.Base.DataType = GL_UNSIGNED_BYTE; + xrb->St.Base.RedBits = visual->redBits; + xrb->St.Base.GreenBits = visual->greenBits; + xrb->St.Base.BlueBits = visual->blueBits; + xrb->St.Base.AlphaBits = visual->alphaBits; + pipeFormat = PIPE_FORMAT_U_A8_R8_G8_B8; + } + else { + xrb->St.Base.InternalFormat = GL_COLOR_INDEX; + xrb->St.Base._BaseFormat = GL_COLOR_INDEX; + xrb->St.Base.DataType = GL_UNSIGNED_INT; + xrb->St.Base.IndexBits = visual->indexBits; + } + /* only need to set Red/Green/EtcBits fields for user-created RBs */ + + xrb->St.surface = xmesa_surface_alloc(pipe, pipeFormat); + xms = (struct xmesa_surface *) xrb->St.surface; + xms->xrb = xrb; + + } + return xrb; +} + + +#if 0 +struct gl_renderbuffer * +xmesa_new_renderbuffer(GLcontext *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, GLuint width, GLuint height) +{ + struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer); if (xrb) { GLuint name = 0; - _mesa_init_renderbuffer(&xrb->Base, name); + _mesa_init_renderbuffer(&xrb->St.Base, name); - xrb->Base.Delete = xmesa_delete_renderbuffer; + xrb->St.Base.Delete = xmesa_delete_renderbuffer; if (backBuffer) - xrb->Base.AllocStorage = xmesa_alloc_back_storage; + xrb->St.Base.AllocStorage = xmesa_alloc_back_storage; else - xrb->Base.AllocStorage = xmesa_alloc_front_storage; + xrb->St.Base.AllocStorage = xmesa_alloc_front_storage; if (visual->rgbMode) { - xrb->Base.InternalFormat = GL_RGBA; - xrb->Base._BaseFormat = GL_RGBA; - xrb->Base.DataType = GL_UNSIGNED_BYTE; - xrb->Base.RedBits = visual->redBits; - xrb->Base.GreenBits = visual->greenBits; - xrb->Base.BlueBits = visual->blueBits; - xrb->Base.AlphaBits = visual->alphaBits; + xrb->St.Base.InternalFormat = GL_RGBA; + xrb->St.Base._BaseFormat = GL_RGBA; + xrb->St.Base.DataType = GL_UNSIGNED_BYTE; + xrb->St.Base.RedBits = visual->redBits; + xrb->St.Base.GreenBits = visual->greenBits; + xrb->St.Base.BlueBits = visual->blueBits; + xrb->St.Base.AlphaBits = visual->alphaBits; } else { - xrb->Base.InternalFormat = GL_COLOR_INDEX; - xrb->Base._BaseFormat = GL_COLOR_INDEX; - xrb->Base.DataType = GL_UNSIGNED_INT; - xrb->Base.IndexBits = visual->indexBits; + xrb->St.Base.InternalFormat = GL_COLOR_INDEX; + xrb->St.Base._BaseFormat = GL_COLOR_INDEX; + xrb->St.Base.DataType = GL_UNSIGNED_INT; + xrb->St.Base.IndexBits = visual->indexBits; } /* only need to set Red/Green/EtcBits fields for user-created RBs */ } return xrb; } +#endif /** diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index f64f8780cf..6eb6d32d19 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -224,7 +224,7 @@ clear_pixmap(GLcontext *ctx, struct xmesa_renderbuffer *xrb, assert(xmbuf->cleargc); XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc, - x, xrb->Base.Height - y - height, + x, xrb->St.Base.Height - y - height, width, height ); } @@ -335,9 +335,9 @@ clear_32bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, | ((pixel << 24) & 0xff000000); } - if (width == xrb->Base.Width && height == xrb->Base.Height) { + if (width == xrb->St.Base.Width && height == xrb->St.Base.Height) { /* clearing whole buffer */ - const GLuint n = xrb->Base.Width * xrb->Base.Height; + const GLuint n = xrb->St.Base.Width * xrb->St.Base.Height; GLuint *ptr4 = (GLuint *) xrb->ximage->data; if (pixel == 0) { /* common case */ @@ -490,7 +490,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx, ctx->Pixel.ZoomX == 1.0 && /* no zooming */ ctx->Pixel.ZoomY == 1.0 && xrb->pixmap && - xrb->Base.AlphaBits == 0) + xrb->St.Base.AlphaBits == 0) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); @@ -1134,6 +1134,7 @@ xmesa_init_driver_functions( XMesaVisual xmvisual, driver->BeginQuery = xmesa_begin_query; driver->EndQuery = xmesa_end_query; #endif + } diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c index 3776891e2e..ce54a18a27 100644 --- a/src/mesa/drivers/x11/xm_span.c +++ b/src/mesa/drivers/x11/xm_span.c @@ -4539,259 +4539,260 @@ xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb, enum pixel_format pixelformat, GLint depth) { const GLboolean pixmap = xrb->pixmap ? GL_TRUE : GL_FALSE; + struct gl_renderbuffer *rb = &xrb->St.Base; switch (pixelformat) { case PF_Index: - ASSERT(xrb->Base.DataType == GL_UNSIGNED_INT); + ASSERT(rb->DataType == GL_UNSIGNED_INT); if (pixmap) { - xrb->Base.PutRow = put_row_ci_pixmap; - xrb->Base.PutRowRGB = NULL; - xrb->Base.PutMonoRow = put_mono_row_ci_pixmap; - xrb->Base.PutValues = put_values_ci_pixmap; - xrb->Base.PutMonoValues = put_mono_values_ci_pixmap; + rb->PutRow = put_row_ci_pixmap; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ci_pixmap; + rb->PutValues = put_values_ci_pixmap; + rb->PutMonoValues = put_mono_values_ci_pixmap; } else { - xrb->Base.PutRow = put_row_ci_ximage; - xrb->Base.PutRowRGB = NULL; - xrb->Base.PutMonoRow = put_mono_row_ci_ximage; - xrb->Base.PutValues = put_values_ci_ximage; - xrb->Base.PutMonoValues = put_mono_values_ci_ximage; + rb->PutRow = put_row_ci_ximage; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ci_ximage; + rb->PutValues = put_values_ci_ximage; + rb->PutMonoValues = put_mono_values_ci_ximage; } break; case PF_Truecolor: if (pixmap) { - xrb->Base.PutRow = put_row_TRUECOLOR_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_TRUECOLOR_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_TRUECOLOR_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_TRUECOLOR_pixmap; + rb->PutRowRGB = put_row_rgb_TRUECOLOR_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_TRUECOLOR_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_TRUECOLOR_ximage; - xrb->Base.PutRowRGB = put_row_rgb_TRUECOLOR_ximage; - xrb->Base.PutMonoRow = put_mono_row_ximage; - xrb->Base.PutValues = put_values_TRUECOLOR_ximage; - xrb->Base.PutMonoValues = put_mono_values_ximage; + rb->PutRow = put_row_TRUECOLOR_ximage; + rb->PutRowRGB = put_row_rgb_TRUECOLOR_ximage; + rb->PutMonoRow = put_mono_row_ximage; + rb->PutValues = put_values_TRUECOLOR_ximage; + rb->PutMonoValues = put_mono_values_ximage; } break; case PF_Dither_True: if (pixmap) { - xrb->Base.PutRow = put_row_TRUEDITHER_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_TRUEDITHER_pixmap; - xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_pixmap; - xrb->Base.PutValues = put_values_TRUEDITHER_pixmap; - xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_pixmap; + rb->PutRow = put_row_TRUEDITHER_pixmap; + rb->PutRowRGB = put_row_rgb_TRUEDITHER_pixmap; + rb->PutMonoRow = put_mono_row_TRUEDITHER_pixmap; + rb->PutValues = put_values_TRUEDITHER_pixmap; + rb->PutMonoValues = put_mono_values_TRUEDITHER_pixmap; } else { - xrb->Base.PutRow = put_row_TRUEDITHER_ximage; - xrb->Base.PutRowRGB = put_row_rgb_TRUEDITHER_ximage; - xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_ximage; - xrb->Base.PutValues = put_values_TRUEDITHER_ximage; - xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_ximage; + rb->PutRow = put_row_TRUEDITHER_ximage; + rb->PutRowRGB = put_row_rgb_TRUEDITHER_ximage; + rb->PutMonoRow = put_mono_row_TRUEDITHER_ximage; + rb->PutValues = put_values_TRUEDITHER_ximage; + rb->PutMonoValues = put_mono_values_TRUEDITHER_ximage; } break; case PF_8A8B8G8R: if (pixmap) { - xrb->Base.PutRow = put_row_8A8B8G8R_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_8A8B8G8R_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_8A8B8G8R_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_8A8B8G8R_pixmap; + rb->PutRowRGB = put_row_rgb_8A8B8G8R_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_8A8B8G8R_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_8A8B8G8R_ximage; - xrb->Base.PutRowRGB = put_row_rgb_8A8B8G8R_ximage; - xrb->Base.PutMonoRow = put_mono_row_8A8B8G8R_ximage; - xrb->Base.PutValues = put_values_8A8B8G8R_ximage; - xrb->Base.PutMonoValues = put_mono_values_8A8B8G8R_ximage; - xrb->Base.GetPointer = get_pointer_4_ximage; + rb->PutRow = put_row_8A8B8G8R_ximage; + rb->PutRowRGB = put_row_rgb_8A8B8G8R_ximage; + rb->PutMonoRow = put_mono_row_8A8B8G8R_ximage; + rb->PutValues = put_values_8A8B8G8R_ximage; + rb->PutMonoValues = put_mono_values_8A8B8G8R_ximage; + rb->GetPointer = get_pointer_4_ximage; } break; case PF_8A8R8G8B: if (pixmap) { - xrb->Base.PutRow = put_row_8A8R8G8B_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_8A8R8G8B_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_8A8R8G8B_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_8A8R8G8B_pixmap; + rb->PutRowRGB = put_row_rgb_8A8R8G8B_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_8A8R8G8B_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_8A8R8G8B_ximage; - xrb->Base.PutRowRGB = put_row_rgb_8A8R8G8B_ximage; - xrb->Base.PutMonoRow = put_mono_row_8A8R8G8B_ximage; - xrb->Base.PutValues = put_values_8A8R8G8B_ximage; - xrb->Base.PutMonoValues = put_mono_values_8A8R8G8B_ximage; - xrb->Base.GetPointer = get_pointer_4_ximage; + rb->PutRow = put_row_8A8R8G8B_ximage; + rb->PutRowRGB = put_row_rgb_8A8R8G8B_ximage; + rb->PutMonoRow = put_mono_row_8A8R8G8B_ximage; + rb->PutValues = put_values_8A8R8G8B_ximage; + rb->PutMonoValues = put_mono_values_8A8R8G8B_ximage; + rb->GetPointer = get_pointer_4_ximage; } break; case PF_8R8G8B: if (pixmap) { - xrb->Base.PutRow = put_row_8R8G8B_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_8R8G8B_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_8R8G8B_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_8R8G8B_pixmap; + rb->PutRowRGB = put_row_rgb_8R8G8B_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_8R8G8B_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_8R8G8B_ximage; - xrb->Base.PutRowRGB = put_row_rgb_8R8G8B_ximage; - xrb->Base.PutMonoRow = put_mono_row_8R8G8B_ximage; - xrb->Base.PutValues = put_values_8R8G8B_ximage; - xrb->Base.PutMonoValues = put_mono_values_8R8G8B_ximage; + rb->PutRow = put_row_8R8G8B_ximage; + rb->PutRowRGB = put_row_rgb_8R8G8B_ximage; + rb->PutMonoRow = put_mono_row_8R8G8B_ximage; + rb->PutValues = put_values_8R8G8B_ximage; + rb->PutMonoValues = put_mono_values_8R8G8B_ximage; } break; case PF_8R8G8B24: if (pixmap) { - xrb->Base.PutRow = put_row_8R8G8B24_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_8R8G8B24_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_8R8G8B24_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_8R8G8B24_pixmap; + rb->PutRowRGB = put_row_rgb_8R8G8B24_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_8R8G8B24_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_8R8G8B24_ximage; - xrb->Base.PutRowRGB = put_row_rgb_8R8G8B24_ximage; - xrb->Base.PutMonoRow = put_mono_row_8R8G8B24_ximage; - xrb->Base.PutValues = put_values_8R8G8B24_ximage; - xrb->Base.PutMonoValues = put_mono_values_8R8G8B24_ximage; + rb->PutRow = put_row_8R8G8B24_ximage; + rb->PutRowRGB = put_row_rgb_8R8G8B24_ximage; + rb->PutMonoRow = put_mono_row_8R8G8B24_ximage; + rb->PutValues = put_values_8R8G8B24_ximage; + rb->PutMonoValues = put_mono_values_8R8G8B24_ximage; } break; case PF_5R6G5B: if (pixmap) { - xrb->Base.PutRow = put_row_5R6G5B_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_5R6G5B_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_5R6G5B_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_5R6G5B_pixmap; + rb->PutRowRGB = put_row_rgb_5R6G5B_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_5R6G5B_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_5R6G5B_ximage; - xrb->Base.PutRowRGB = put_row_rgb_5R6G5B_ximage; - xrb->Base.PutMonoRow = put_mono_row_ximage; - xrb->Base.PutValues = put_values_5R6G5B_ximage; - xrb->Base.PutMonoValues = put_mono_values_ximage; + rb->PutRow = put_row_5R6G5B_ximage; + rb->PutRowRGB = put_row_rgb_5R6G5B_ximage; + rb->PutMonoRow = put_mono_row_ximage; + rb->PutValues = put_values_5R6G5B_ximage; + rb->PutMonoValues = put_mono_values_ximage; } break; case PF_Dither_5R6G5B: if (pixmap) { - xrb->Base.PutRow = put_row_DITHER_5R6G5B_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_DITHER_5R6G5B_pixmap; - xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_pixmap; - xrb->Base.PutValues = put_values_DITHER_5R6G5B_pixmap; - xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_pixmap; + rb->PutRow = put_row_DITHER_5R6G5B_pixmap; + rb->PutRowRGB = put_row_rgb_DITHER_5R6G5B_pixmap; + rb->PutMonoRow = put_mono_row_TRUEDITHER_pixmap; + rb->PutValues = put_values_DITHER_5R6G5B_pixmap; + rb->PutMonoValues = put_mono_values_TRUEDITHER_pixmap; } else { - xrb->Base.PutRow = put_row_DITHER_5R6G5B_ximage; - xrb->Base.PutRowRGB = put_row_rgb_DITHER_5R6G5B_ximage; - xrb->Base.PutMonoRow = put_mono_row_DITHER_5R6G5B_ximage; - xrb->Base.PutValues = put_values_DITHER_5R6G5B_ximage; - xrb->Base.PutMonoValues = put_mono_values_DITHER_5R6G5B_ximage; + rb->PutRow = put_row_DITHER_5R6G5B_ximage; + rb->PutRowRGB = put_row_rgb_DITHER_5R6G5B_ximage; + rb->PutMonoRow = put_mono_row_DITHER_5R6G5B_ximage; + rb->PutValues = put_values_DITHER_5R6G5B_ximage; + rb->PutMonoValues = put_mono_values_DITHER_5R6G5B_ximage; } break; case PF_Dither: if (pixmap) { - xrb->Base.PutRow = put_row_DITHER_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_DITHER_pixmap; - xrb->Base.PutMonoRow = put_mono_row_DITHER_pixmap; - xrb->Base.PutValues = put_values_DITHER_pixmap; - xrb->Base.PutMonoValues = put_mono_values_DITHER_pixmap; + rb->PutRow = put_row_DITHER_pixmap; + rb->PutRowRGB = put_row_rgb_DITHER_pixmap; + rb->PutMonoRow = put_mono_row_DITHER_pixmap; + rb->PutValues = put_values_DITHER_pixmap; + rb->PutMonoValues = put_mono_values_DITHER_pixmap; } else { if (depth == 8) { - xrb->Base.PutRow = put_row_DITHER8_ximage; - xrb->Base.PutRowRGB = put_row_rgb_DITHER8_ximage; - xrb->Base.PutMonoRow = put_mono_row_DITHER8_ximage; - xrb->Base.PutValues = put_values_DITHER8_ximage; - xrb->Base.PutMonoValues = put_mono_values_DITHER8_ximage; + rb->PutRow = put_row_DITHER8_ximage; + rb->PutRowRGB = put_row_rgb_DITHER8_ximage; + rb->PutMonoRow = put_mono_row_DITHER8_ximage; + rb->PutValues = put_values_DITHER8_ximage; + rb->PutMonoValues = put_mono_values_DITHER8_ximage; } else { - xrb->Base.PutRow = put_row_DITHER_ximage; - xrb->Base.PutRowRGB = put_row_rgb_DITHER_ximage; - xrb->Base.PutMonoRow = put_mono_row_DITHER_ximage; - xrb->Base.PutValues = put_values_DITHER_ximage; - xrb->Base.PutMonoValues = put_mono_values_DITHER_ximage; + rb->PutRow = put_row_DITHER_ximage; + rb->PutRowRGB = put_row_rgb_DITHER_ximage; + rb->PutMonoRow = put_mono_row_DITHER_ximage; + rb->PutValues = put_values_DITHER_ximage; + rb->PutMonoValues = put_mono_values_DITHER_ximage; } } break; case PF_1Bit: if (pixmap) { - xrb->Base.PutRow = put_row_1BIT_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_1BIT_pixmap; - xrb->Base.PutMonoRow = put_mono_row_1BIT_pixmap; - xrb->Base.PutValues = put_values_1BIT_pixmap; - xrb->Base.PutMonoValues = put_mono_values_1BIT_pixmap; + rb->PutRow = put_row_1BIT_pixmap; + rb->PutRowRGB = put_row_rgb_1BIT_pixmap; + rb->PutMonoRow = put_mono_row_1BIT_pixmap; + rb->PutValues = put_values_1BIT_pixmap; + rb->PutMonoValues = put_mono_values_1BIT_pixmap; } else { - xrb->Base.PutRow = put_row_1BIT_ximage; - xrb->Base.PutRowRGB = put_row_rgb_1BIT_ximage; - xrb->Base.PutMonoRow = put_mono_row_1BIT_ximage; - xrb->Base.PutValues = put_values_1BIT_ximage; - xrb->Base.PutMonoValues = put_mono_values_1BIT_ximage; + rb->PutRow = put_row_1BIT_ximage; + rb->PutRowRGB = put_row_rgb_1BIT_ximage; + rb->PutMonoRow = put_mono_row_1BIT_ximage; + rb->PutValues = put_values_1BIT_ximage; + rb->PutMonoValues = put_mono_values_1BIT_ximage; } break; case PF_HPCR: if (pixmap) { - xrb->Base.PutRow = put_row_HPCR_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_HPCR_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_HPCR_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_HPCR_pixmap; + rb->PutRowRGB = put_row_rgb_HPCR_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_HPCR_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_HPCR_ximage; - xrb->Base.PutRowRGB = put_row_rgb_HPCR_ximage; - xrb->Base.PutMonoRow = put_mono_row_HPCR_ximage; - xrb->Base.PutValues = put_values_HPCR_ximage; - xrb->Base.PutMonoValues = put_mono_values_HPCR_ximage; + rb->PutRow = put_row_HPCR_ximage; + rb->PutRowRGB = put_row_rgb_HPCR_ximage; + rb->PutMonoRow = put_mono_row_HPCR_ximage; + rb->PutValues = put_values_HPCR_ximage; + rb->PutMonoValues = put_mono_values_HPCR_ximage; } break; case PF_Lookup: if (pixmap) { - xrb->Base.PutRow = put_row_LOOKUP_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_LOOKUP_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_LOOKUP_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_LOOKUP_pixmap; + rb->PutRowRGB = put_row_rgb_LOOKUP_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_LOOKUP_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { if (depth==8) { - xrb->Base.PutRow = put_row_LOOKUP8_ximage; - xrb->Base.PutRowRGB = put_row_rgb_LOOKUP8_ximage; - xrb->Base.PutMonoRow = put_mono_row_LOOKUP8_ximage; - xrb->Base.PutValues = put_values_LOOKUP8_ximage; - xrb->Base.PutMonoValues = put_mono_values_LOOKUP8_ximage; + rb->PutRow = put_row_LOOKUP8_ximage; + rb->PutRowRGB = put_row_rgb_LOOKUP8_ximage; + rb->PutMonoRow = put_mono_row_LOOKUP8_ximage; + rb->PutValues = put_values_LOOKUP8_ximage; + rb->PutMonoValues = put_mono_values_LOOKUP8_ximage; } else { - xrb->Base.PutRow = put_row_LOOKUP_ximage; - xrb->Base.PutRowRGB = put_row_rgb_LOOKUP_ximage; - xrb->Base.PutMonoRow = put_mono_row_ximage; - xrb->Base.PutValues = put_values_LOOKUP_ximage; - xrb->Base.PutMonoValues = put_mono_values_ximage; + rb->PutRow = put_row_LOOKUP_ximage; + rb->PutRowRGB = put_row_rgb_LOOKUP_ximage; + rb->PutMonoRow = put_mono_row_ximage; + rb->PutValues = put_values_LOOKUP_ximage; + rb->PutMonoValues = put_mono_values_ximage; } } break; case PF_Grayscale: if (pixmap) { - xrb->Base.PutRow = put_row_GRAYSCALE_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_GRAYSCALE_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_GRAYSCALE_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_GRAYSCALE_pixmap; + rb->PutRowRGB = put_row_rgb_GRAYSCALE_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_GRAYSCALE_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { if (depth == 8) { - xrb->Base.PutRow = put_row_GRAYSCALE8_ximage; - xrb->Base.PutRowRGB = put_row_rgb_GRAYSCALE8_ximage; - xrb->Base.PutMonoRow = put_mono_row_GRAYSCALE8_ximage; - xrb->Base.PutValues = put_values_GRAYSCALE8_ximage; - xrb->Base.PutMonoValues = put_mono_values_GRAYSCALE8_ximage; + rb->PutRow = put_row_GRAYSCALE8_ximage; + rb->PutRowRGB = put_row_rgb_GRAYSCALE8_ximage; + rb->PutMonoRow = put_mono_row_GRAYSCALE8_ximage; + rb->PutValues = put_values_GRAYSCALE8_ximage; + rb->PutMonoValues = put_mono_values_GRAYSCALE8_ximage; } else { - xrb->Base.PutRow = put_row_GRAYSCALE_ximage; - xrb->Base.PutRowRGB = put_row_rgb_GRAYSCALE_ximage; - xrb->Base.PutMonoRow = put_mono_row_ximage; - xrb->Base.PutValues = put_values_GRAYSCALE_ximage; - xrb->Base.PutMonoValues = put_mono_values_ximage; + rb->PutRow = put_row_GRAYSCALE_ximage; + rb->PutRowRGB = put_row_rgb_GRAYSCALE_ximage; + rb->PutMonoRow = put_mono_row_ximage; + rb->PutValues = put_values_GRAYSCALE_ximage; + rb->PutMonoValues = put_mono_values_ximage; } } break; @@ -4803,12 +4804,12 @@ xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb, /* Get functions */ if (pixelformat == PF_Index) { - xrb->Base.GetRow = get_row_ci; - xrb->Base.GetValues = get_values_ci; + rb->GetRow = get_row_ci; + rb->GetValues = get_values_ci; } else { - xrb->Base.GetRow = get_row_rgba; - xrb->Base.GetValues = get_values_rgba; + rb->GetRow = get_row_rgba; + rb->GetValues = get_values_rgba; } } diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 6b52b33bf2..9d7d25667e 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -45,14 +45,21 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/softpipe/sp_context.h" -#include "pipe/softpipe/sp_surface.h" #include "state_tracker/st_context.h" +static INLINE struct xmesa_surface * +xmesa_surf(struct softpipe_surface *sps) +{ + return (struct xmesa_surface *) sps; +} + + static INLINE struct xmesa_renderbuffer * xmesa_rb(struct softpipe_surface *sps) { - return (struct xmesa_renderbuffer *) sps->surface.rb; + struct xmesa_surface *xms = xmesa_surf(sps); + return xms->xrb; } @@ -66,13 +73,14 @@ static void read_quad_f(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rgba)[NUM_CHANNELS]) { + struct xmesa_surface *xms = xmesa_surf(sps); struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GLubyte temp[16]; GLfloat *dst = (GLfloat *) rgba; GLuint i; GET_CURRENT_CONTEXT(ctx); - xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, temp); - xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, temp + 8); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, temp); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8); for (i = 0; i < 16; i++) { dst[i] = UBYTE_TO_FLOAT(temp[i]); } @@ -82,13 +90,14 @@ static void read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { + struct xmesa_surface *xms = xmesa_surf(sps); struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GLubyte temp[16]; GLfloat *dst = (GLfloat *) rrrr; GLuint i, j; GET_CURRENT_CONTEXT(ctx); - xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, temp); - xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, temp + 8); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, temp); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { dst[j * 4 + i] = UBYTE_TO_FLOAT(temp[i * 4 + j]); @@ -108,8 +117,8 @@ write_quad_f(struct softpipe_surface *sps, GLint x, GLint y, for (i = 0; i < 16; i++) { UNCLAMPED_FLOAT_TO_UBYTE(temp[i], src[i]); } - xrb->Base.PutRow(ctx, &xrb->Base, 2, x, y, temp, NULL); - xrb->Base.PutRow(ctx, &xrb->Base, 2, x, y + 1, temp + 8, NULL); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y, temp, NULL); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8, NULL); } static void @@ -126,8 +135,8 @@ write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + i], src[i * 4 + j]); } } - xrb->Base.PutRow(ctx, &xrb->Base, 2, x, y, temp, NULL); - xrb->Base.PutRow(ctx, &xrb->Base, 2, x, y + 1, temp + 8, NULL); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y, temp, NULL); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8, NULL); } static void @@ -136,8 +145,8 @@ read_quad_ub(struct softpipe_surface *sps, GLint x, GLint y, { struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GET_CURRENT_CONTEXT(ctx); - xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, rgba); - xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, rgba + 2); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, rgba); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, rgba + 2); } static void @@ -146,8 +155,8 @@ write_quad_ub(struct softpipe_surface *sps, GLint x, GLint y, { struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GET_CURRENT_CONTEXT(ctx); - xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, rgba); - xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, rgba + 2); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, rgba); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, rgba + 2); } #if 0 @@ -157,7 +166,7 @@ write_mono_row_ub(struct softpipe_surface *sps, GLuint count, GLint x, GLint y, { struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GET_CURRENT_CONTEXT(ctx); - xrb->Base.PutMonoRow(ctx, &xrb->Base, count, x, y, rgba, NULL); + xrb->St.Base.PutMonoRow(ctx, &xrb->St.Base, count, x, y, rgba, NULL); } #endif @@ -177,9 +186,11 @@ xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb) if (!sps) return NULL; +#if 0 sps->surface.rb = xrb; /* XXX only needed for quad funcs above */ - sps->surface.width = xrb->Base.Width; - sps->surface.height = xrb->Base.Height; +#endif + sps->surface.width = xrb->St.Base.Width; + sps->surface.height = xrb->St.Base.Height; sps->read_quad_f = read_quad_f; sps->read_quad_f_swz = read_quad_f_swz; @@ -197,3 +208,52 @@ xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb) return &sps->surface; } + + +struct pipe_surface * +xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat) +{ + struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface); + + assert(pipeFormat); + + xms->surface.surface.format = pipeFormat; + + switch (pipeFormat) { + case PIPE_FORMAT_U_A8_R8_G8_B8: + xms->surface.read_quad_f_swz = read_quad_f; + xms->surface.read_quad_f = read_quad_f; + xms->surface.read_quad_f_swz = read_quad_f_swz; + xms->surface.read_quad_ub = read_quad_ub; + xms->surface.write_quad_f = write_quad_f; + xms->surface.write_quad_f_swz = write_quad_f_swz; + xms->surface.write_quad_ub = write_quad_ub; + break; + case PIPE_FORMAT_S8_Z24: + softpipe_init_surface_funcs(&xms->surface); + /* + xms->surface.read_quad_z = 1; + xms->surface.write_quad_z = 1; + */ + break; + default: + abort(); + } + + return &xms->surface.surface; +} + + +const GLuint * +xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats) +{ + static const GLuint formats[] = { + PIPE_FORMAT_U_A8_R8_G8_B8, + PIPE_FORMAT_S8_Z24 + }; + + *numFormats = 2; + + return formats; +} + diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 99c87da3c5..361c657354 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -36,6 +36,9 @@ #ifdef XFree86Server #include "xm_image.h" #endif +#include "state_tracker/st_cb_fbo.h" +#include "pipe/softpipe/sp_context.h" +#include "pipe/softpipe/sp_surface.h" extern _glthread_Mutex _xmesa_lock; @@ -177,7 +180,11 @@ typedef enum { */ struct xmesa_renderbuffer { +#if 0 struct gl_renderbuffer Base; /* Base class */ +#else + struct st_renderbuffer St; /**< Base class */ +#endif XMesaBuffer Parent; /**< The XMesaBuffer this renderbuffer belongs to */ XMesaDrawable drawable; /* Usually the X window ID */ @@ -493,8 +500,8 @@ extern const int xmesa_kernel1[16]; */ extern struct xmesa_renderbuffer * -xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, - GLboolean backBuffer); +xmesa_create_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, + GLboolean backBuffer); extern void xmesa_delete_framebuffer(struct gl_framebuffer *fb); @@ -589,6 +596,13 @@ extern void xmesa_register_swrast_functions( GLcontext *ctx ); struct pipe_surface; struct pipe_context; +struct xmesa_surface +{ + struct softpipe_surface surface; + struct xmesa_renderbuffer *xrb; +}; + + extern struct pipe_surface * xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb); @@ -601,5 +615,11 @@ xmesa_clear_buffers(GLcontext *ctx, GLbitfield buffers); extern struct pipe_context * xmesa_create_softpipe(XMesaContext xm); +extern struct pipe_surface * +xmesa_surface_alloc(struct pipe_context *pipe, GLuint format); + +extern const GLuint * +xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats); + #endif |