X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fx11%2Fxm_dd.c;h=3319d1181423035b70d3a89c8ce7510e6b961ffa;hb=56f0c00f125ee75caeadc1c9e8cab8a488635e5e;hp=a27d7045abe56cc79e9e2102c7add85f255c7e90;hpb=48302e9b309c7ce218de2e522c91bdc87e61cdbc;p=mesa.git diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index a27d7045abe..3319d118142 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -41,6 +41,7 @@ #include "main/image.h" #include "main/imports.h" #include "main/mtypes.h" +#include "main/pbo.h" #include "main/state.h" #include "main/texobj.h" #include "main/teximage.h" @@ -91,35 +92,19 @@ const int xmesa_kernel1[16] = { static void -finish_or_flush( GLcontext *ctx ) +finish_or_flush( struct gl_context *ctx ) { -#ifdef XFree86Server - /* NOT_NEEDED */ -#else const XMesaContext xmesa = XMESA_CONTEXT(ctx); if (xmesa) { _glthread_LOCK_MUTEX(_xmesa_lock); XSync( xmesa->display, False ); _glthread_UNLOCK_MUTEX(_xmesa_lock); } -#endif -} - - -static void -clear_index( GLcontext *ctx, GLuint index ) -{ - if (ctx->DrawBuffer->Name == 0) { - const XMesaContext xmesa = XMESA_CONTEXT(ctx); - XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); - xmesa->clearpixel = (unsigned long) index; - XMesaSetForeground( xmesa->display, xmbuf->cleargc, (unsigned long) index ); - } } static void -clear_color( GLcontext *ctx, const GLfloat color[4] ) +clear_color( struct gl_context *ctx, const GLfloat color[4] ) { if (ctx->DrawBuffer->Name == 0) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -144,34 +129,14 @@ clear_color( GLcontext *ctx, const GLfloat color[4] ) -/* Set index mask ala glIndexMask */ -static void -index_mask( GLcontext *ctx, GLuint mask ) -{ - const XMesaContext xmesa = XMESA_CONTEXT(ctx); - XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); - /* not sure this conditional is really needed */ - if (xmbuf->backxrb && xmbuf->backxrb->pixmap) { - unsigned long m; - if (mask==0xffffffff) { - m = ((unsigned long)~0L); - } - else { - m = (unsigned long) mask; - } - XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m ); - } -} - - /* Implements glColorMask() */ static void -color_mask(GLcontext *ctx, +color_mask(struct gl_context *ctx, GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); XMesaBuffer xmbuf; - const int xclass = xmesa->xm_visual->mesa_visual.visualType; + const int xclass = xmesa->xm_visual->visualType; (void) amask; if (ctx->DrawBuffer->Name != 0) @@ -205,7 +170,7 @@ color_mask(GLcontext *ctx, * Clear the front or back color buffer, if it's implemented with a pixmap. */ static void -clear_pixmap(GLcontext *ctx, struct xmesa_renderbuffer *xrb, +clear_pixmap(struct gl_context *ctx, struct xmesa_renderbuffer *xrb, GLint x, GLint y, GLint width, GLint height) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -225,20 +190,20 @@ clear_pixmap(GLcontext *ctx, struct xmesa_renderbuffer *xrb, static void -clear_8bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb, +clear_8bit_ximage( struct gl_context *ctx, struct xmesa_renderbuffer *xrb, GLint x, GLint y, GLint width, GLint height ) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); GLint i; for (i = 0; i < height; i++) { GLubyte *ptr = PIXEL_ADDR1(xrb, x, y + i); - MEMSET( ptr, xmesa->clearpixel, width ); + memset( ptr, xmesa->clearpixel, width ); } } static void -clear_HPCR_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb, +clear_HPCR_ximage( struct gl_context *ctx, struct xmesa_renderbuffer *xrb, GLint x, GLint y, GLint width, GLint height ) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -259,7 +224,7 @@ clear_HPCR_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb, static void -clear_16bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb, +clear_16bit_ximage( struct gl_context *ctx, struct xmesa_renderbuffer *xrb, GLint x, GLint y, GLint width, GLint height) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -281,7 +246,7 @@ clear_16bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb, /* Optimized code provided by Nozomi Ytow */ static void -clear_24bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, +clear_24bit_ximage(struct gl_context *ctx, struct xmesa_renderbuffer *xrb, GLint x, GLint y, GLint width, GLint height) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -294,7 +259,7 @@ clear_24bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, GLint j; for (j = 0; j < height; j++) { bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j); - MEMSET(ptr3, r, 3 * width); + memset(ptr3, r, 3 * width); } } else { @@ -314,7 +279,7 @@ clear_24bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, static void -clear_32bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, +clear_32bit_ximage(struct gl_context *ctx, struct xmesa_renderbuffer *xrb, GLint x, GLint y, GLint width, GLint height) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -336,7 +301,7 @@ clear_32bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, GLuint *ptr4 = (GLuint *) xrb->ximage->data; if (pixel == 0) { /* common case */ - _mesa_memset(ptr4, pixel, 4 * n); + memset(ptr4, pixel, 4 * n); } else { GLuint i; @@ -358,7 +323,7 @@ clear_32bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, static void -clear_nbit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, +clear_nbit_ximage(struct gl_context *ctx, struct xmesa_renderbuffer *xrb, GLint x, GLint y, GLint width, GLint height) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -377,11 +342,11 @@ clear_nbit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, static void -clear_buffers(GLcontext *ctx, GLbitfield buffers) +clear_buffers(struct gl_context *ctx, GLbitfield buffers) { if (ctx->DrawBuffer->Name == 0) { /* this is a window system framebuffer */ - const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask; + const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0]; XMesaBuffer b = XMESA_BUFFER(ctx->DrawBuffer); const GLint x = ctx->DrawBuffer->_Xmin; const GLint y = ctx->DrawBuffer->_Ymin; @@ -420,7 +385,6 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers) } -#ifndef XFree86Server /* XXX these functions haven't been tested in the Xserver environment */ @@ -428,7 +392,7 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers) * Check if we can do an optimized glDrawPixels into an 8R8G8B visual. */ static GLboolean -can_do_DrawPixels_8R8G8B(GLcontext *ctx, GLenum format, GLenum type) +can_do_DrawPixels_8R8G8B(struct gl_context *ctx, GLenum format, GLenum type) { if (format == GL_BGRA && type == GL_UNSIGNED_BYTE && @@ -464,7 +428,7 @@ can_do_DrawPixels_8R8G8B(GLcontext *ctx, GLenum format, GLenum type) * The image format must be GL_BGRA to match the PF_8R8G8B pixel format. */ static void -xmesa_DrawPixels_8R8G8B( GLcontext *ctx, +xmesa_DrawPixels_8R8G8B( struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, @@ -481,11 +445,11 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx, if (swrast->NewState) _swrast_validate_derived( ctx ); - if (unpack->BufferObj->Name) { + if (_mesa_is_bufferobj(unpack->BufferObj)) { /* unpack from PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, - format, type, pixels)) { + format, type, INT_MAX, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(invalid PBO access)"); return; @@ -524,7 +488,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx, * been in the OpenGL bottom-to-top orientation. X is top-to-bottom * so we have to carefully compute the Y coordinates/addresses here. */ - MEMSET(&ximage, 0, sizeof(XMesaImage)); + memset(&ximage, 0, sizeof(XMesaImage)); ximage.width = width; ximage.height = height; ximage.format = ZPixmap; @@ -543,9 +507,8 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx, XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h); } - if (unpack->BufferObj->Name) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); + if (_mesa_is_bufferobj(unpack->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj); } } else { @@ -561,7 +524,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx, * Check if we can do an optimized glDrawPixels into an 5R6G5B visual. */ static GLboolean -can_do_DrawPixels_5R6G5B(GLcontext *ctx, GLenum format, GLenum type) +can_do_DrawPixels_5R6G5B(struct gl_context *ctx, GLenum format, GLenum type) { if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 && @@ -599,7 +562,7 @@ can_do_DrawPixels_5R6G5B(GLcontext *ctx, GLenum format, GLenum type) * match the PF_5R6G5B pixel format. */ static void -xmesa_DrawPixels_5R6G5B( GLcontext *ctx, +xmesa_DrawPixels_5R6G5B( struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, @@ -616,11 +579,11 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx, if (swrast->NewState) _swrast_validate_derived( ctx ); - if (unpack->BufferObj->Name) { + if (_mesa_is_bufferobj(unpack->BufferObj)) { /* unpack from PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, - format, type, pixels)) { + format, type, INT_MAX, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(invalid PBO access)"); return; @@ -658,7 +621,7 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx, * been in the OpenGL bottom-to-top orientation. X is top-to-bottom * so we have to carefully compute the Y coordinates/addresses here. */ - MEMSET(&ximage, 0, sizeof(XMesaImage)); + memset(&ximage, 0, sizeof(XMesaImage)); ximage.width = width; ximage.height = height; ximage.format = ZPixmap; @@ -678,8 +641,7 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx, } if (unpack->BufferObj->Name) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); + ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj); } } else { @@ -694,7 +656,7 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx, * Determine if we can do an optimized glCopyPixels. */ static GLboolean -can_do_CopyPixels(GLcontext *ctx, GLenum type) +can_do_CopyPixels(struct gl_context *ctx, GLenum type) { if (type == GL_COLOR && ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */ @@ -733,7 +695,7 @@ can_do_CopyPixels(GLcontext *ctx, GLenum type) * We do support copying from one window to another, ala glXMakeCurrentRead. */ static void -xmesa_CopyPixels( GLcontext *ctx, +xmesa_CopyPixels( struct gl_context *ctx, GLint srcx, GLint srcy, GLsizei width, GLsizei height, GLint destx, GLint desty, GLenum type ) { @@ -763,7 +725,6 @@ xmesa_CopyPixels( GLcontext *ctx, } } -#endif /* XFree86Server */ @@ -772,22 +733,14 @@ xmesa_CopyPixels( GLcontext *ctx, * return a meaningful GL_RENDERER string. */ static const GLubyte * -get_string( GLcontext *ctx, GLenum name ) +get_string( struct gl_context *ctx, GLenum name ) { (void) ctx; switch (name) { case GL_RENDERER: -#ifdef XFree86Server - return (const GLubyte *) "Mesa GLX Indirect"; -#else return (const GLubyte *) "Mesa X11"; -#endif case GL_VENDOR: -#ifdef XFree86Server - return (const GLubyte *) "Mesa project: www.mesa3d.org"; -#else return NULL; -#endif default: return NULL; } @@ -799,7 +752,7 @@ get_string( GLcontext *ctx, GLenum name ) * dither enable/disable. */ static void -enable( GLcontext *ctx, GLenum pname, GLboolean state ) +enable( struct gl_context *ctx, GLenum pname, GLboolean state ) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -817,7 +770,7 @@ enable( GLcontext *ctx, GLenum pname, GLboolean state ) static void -clear_color_HPCR_ximage( GLcontext *ctx, const GLfloat color[4] ) +clear_color_HPCR_ximage( struct gl_context *ctx, const GLfloat color[4] ) { int i; const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -829,7 +782,7 @@ clear_color_HPCR_ximage( GLcontext *ctx, const GLfloat color[4] ) if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) { /* black is black */ - MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 , + memset( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 , sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern)); } else { @@ -851,7 +804,7 @@ clear_color_HPCR_ximage( GLcontext *ctx, const GLfloat color[4] ) static void -clear_color_HPCR_pixmap( GLcontext *ctx, const GLfloat color[4] ) +clear_color_HPCR_pixmap( struct gl_context *ctx, const GLfloat color[4] ) { int i; const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -895,7 +848,7 @@ clear_color_HPCR_pixmap( GLcontext *ctx, const GLfloat color[4] ) * flags. */ void -xmesa_update_state( GLcontext *ctx, GLbitfield new_state ) +xmesa_update_state( struct gl_context *ctx, GLbitfield new_state ) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); @@ -979,48 +932,11 @@ xmesa_update_state( GLcontext *ctx, GLbitfield new_state ) -/** - * Called via ctx->Driver.TestProxyTeximage(). Normally, we'd just use - * the _mesa_test_proxy_teximage() fallback function, but we're going to - * special-case the 3D texture case to allow textures up to 512x512x32 - * texels. - */ -static GLboolean -test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, GLenum format, GLenum type, - GLint width, GLint height, GLint depth, GLint border) -{ - if (target == GL_PROXY_TEXTURE_3D) { - /* special case for 3D textures */ - if (width * height * depth > 512 * 512 * 64 || - width < 2 * border || - (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(width - 2 * border) != 1) || - height < 2 * border || - (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(height - 2 * border) != 1) || - depth < 2 * border || - (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(depth - 2 * border) != 1)) { - /* Bad size, or too many texels */ - return GL_FALSE; - } - return GL_TRUE; - } - else { - /* use the fallback routine for 1D, 2D, cube and rect targets */ - return _mesa_test_proxy_teximage(ctx, target, level, internalFormat, - format, type, width, height, depth, - border); - } -} - - /** * In SW, we don't really compress GL_COMPRESSED_RGB[A] textures! */ static gl_format -choose_tex_format( GLcontext *ctx, GLint internalFormat, +choose_tex_format( struct gl_context *ctx, GLint internalFormat, GLenum format, GLenum type ) { switch (internalFormat) { @@ -1046,7 +962,7 @@ choose_tex_format( GLcontext *ctx, GLint internalFormat, * That problem led to the GLX_MESA_resize_buffers extension. */ static void -xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) +xmesa_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h) { XMesaContext xmctx = XMESA_CONTEXT(ctx); XMesaBuffer xmdrawbuf = XMESA_BUFFER(ctx->WinSysDrawBuffer); @@ -1076,7 +992,7 @@ struct xmesa_query_object static struct gl_query_object * -xmesa_new_query_object(GLcontext *ctx, GLuint id) +xmesa_new_query_object(struct gl_context *ctx, GLuint id) { struct xmesa_query_object *q = CALLOC_STRUCT(xmesa_query_object); if (q) { @@ -1088,7 +1004,7 @@ xmesa_new_query_object(GLcontext *ctx, GLuint id) static void -xmesa_begin_query(GLcontext *ctx, struct gl_query_object *q) +xmesa_begin_query(struct gl_context *ctx, struct gl_query_object *q) { if (q->Target == GL_TIME_ELAPSED_EXT) { struct xmesa_query_object *xq = (struct xmesa_query_object *) q; @@ -1115,7 +1031,7 @@ time_diff(const struct timeval *t0, const struct timeval *t1) static void -xmesa_end_query(GLcontext *ctx, struct gl_query_object *q) +xmesa_end_query(struct gl_context *ctx, struct gl_query_object *q) { if (q->Target == GL_TIME_ELAPSED_EXT) { struct xmesa_query_object *xq = (struct xmesa_query_object *) q; @@ -1143,9 +1059,7 @@ xmesa_init_driver_functions( XMesaVisual xmvisual, driver->GetBufferSize = NULL; /* OBSOLETE */ driver->Flush = finish_or_flush; driver->Finish = finish_or_flush; - driver->ClearIndex = clear_index; driver->ClearColor = clear_color; - driver->IndexMask = index_mask; driver->ColorMask = color_mask; driver->Enable = enable; driver->Viewport = xmesa_viewport; @@ -1158,7 +1072,6 @@ xmesa_init_driver_functions( XMesaVisual xmvisual, } else { driver->Clear = clear_buffers; -#ifndef XFree86Server driver->CopyPixels = xmesa_CopyPixels; if (xmvisual->undithered_pf == PF_8R8G8B && xmvisual->dithered_pf == PF_8R8G8B && @@ -1168,9 +1081,8 @@ xmesa_init_driver_functions( XMesaVisual xmvisual, else if (xmvisual->undithered_pf == PF_5R6G5B) { driver->DrawPixels = xmesa_DrawPixels_5R6G5B; } -#endif } - driver->TestProxyTexImage = test_proxy_teximage; + #if ENABLE_EXT_texure_compression_s3tc driver->ChooseTextureFormat = choose_tex_format; #else @@ -1209,7 +1121,7 @@ xmesa_init_driver_functions( XMesaVisual xmvisual, * functions. * Called during context creation only. */ -void xmesa_register_swrast_functions( GLcontext *ctx ) +void xmesa_register_swrast_functions( struct gl_context *ctx ) { SWcontext *swrast = SWRAST_CONTEXT( ctx );