Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
| 3 | * Version: 7.1 |
| 4 | * |
| 5 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included |
| 15 | * in all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 21 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | /** |
| 26 | * \file xm_api.c |
| 27 | * |
| 28 | * All the XMesa* API functions. |
| 29 | * |
| 30 | * |
| 31 | * NOTES: |
| 32 | * |
| 33 | * The window coordinate system origin (0,0) is in the lower-left corner |
| 34 | * of the window. X11's window coordinate origin is in the upper-left |
| 35 | * corner of the window. Therefore, most drawing functions in this |
| 36 | * file have to flip Y coordinates. |
| 37 | * |
| 38 | * Define USE_XSHM in the Makefile with -DUSE_XSHM if you want to compile |
| 39 | * in support for the MIT Shared Memory extension. If enabled, when you |
| 40 | * use an Ximage for the back buffer in double buffered mode, the "swap" |
| 41 | * operation will be faster. You must also link with -lXext. |
| 42 | * |
| 43 | * Byte swapping: If the Mesa host and the X display use a different |
| 44 | * byte order then there's some trickiness to be aware of when using |
| 45 | * XImages. The byte ordering used for the XImage is that of the X |
| 46 | * display, not the Mesa host. |
| 47 | * The color-to-pixel encoding for True/DirectColor must be done |
| 48 | * according to the display's visual red_mask, green_mask, and blue_mask. |
| 49 | * If XPutPixel is used to put a pixel into an XImage then XPutPixel will |
| 50 | * do byte swapping if needed. If one wants to directly "poke" the pixel |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 51 | * into the XImage's buffer then the pixel must be byte swapped first. |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 52 | * |
| 53 | */ |
| 54 | |
| 55 | #ifdef __CYGWIN__ |
| 56 | #undef WIN32 |
| 57 | #undef __WIN32__ |
| 58 | #endif |
| 59 | |
| 60 | #include "glxheader.h" |
| 61 | #include "GL/xmesa.h" |
| 62 | #include "xmesaP.h" |
| 63 | #include "context.h" |
| 64 | #include "extensions.h" |
| 65 | #include "framebuffer.h" |
| 66 | #include "glthread.h" |
| 67 | #include "imports.h" |
| 68 | #include "macros.h" |
| 69 | #include "renderbuffer.h" |
| 70 | #include "teximage.h" |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 71 | #include "vbo/vbo.h" |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 72 | |
| 73 | #include "state_tracker/st_public.h" |
| 74 | #include "state_tracker/st_context.h" |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 75 | #include "pipe/p_defines.h" |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 76 | #include "pipe/p_context.h" |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 77 | |
Zack Rusin | c474f1f | 2007-12-11 07:19:11 -0500 | [diff] [blame^] | 78 | #include "xm_winsys_aub.h" |
| 79 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 80 | /** |
| 81 | * Global X driver lock |
| 82 | */ |
| 83 | _glthread_Mutex _xmesa_lock; |
| 84 | |
| 85 | |
Zack Rusin | c474f1f | 2007-12-11 07:19:11 -0500 | [diff] [blame^] | 86 | int xmesa_mode; |
| 87 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 88 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 89 | /**********************************************************************/ |
| 90 | /***** X Utility Functions *****/ |
| 91 | /**********************************************************************/ |
| 92 | |
| 93 | |
| 94 | /** |
| 95 | * Return the host's byte order as LSBFirst or MSBFirst ala X. |
| 96 | */ |
| 97 | #ifndef XFree86Server |
| 98 | static int host_byte_order( void ) |
| 99 | { |
| 100 | int i = 1; |
| 101 | char *cptr = (char *) &i; |
| 102 | return (*cptr==1) ? LSBFirst : MSBFirst; |
| 103 | } |
| 104 | #endif |
| 105 | |
| 106 | |
| 107 | /** |
| 108 | * Check if the X Shared Memory extension is available. |
| 109 | * Return: 0 = not available |
| 110 | * 1 = shared XImage support available |
| 111 | * 2 = shared Pixmap support available also |
| 112 | */ |
| 113 | static int check_for_xshm( XMesaDisplay *display ) |
| 114 | { |
| 115 | #if defined(USE_XSHM) && !defined(XFree86Server) |
| 116 | int major, minor, ignore; |
| 117 | Bool pixmaps; |
| 118 | |
| 119 | if (XQueryExtension( display, "MIT-SHM", &ignore, &ignore, &ignore )) { |
| 120 | if (XShmQueryVersion( display, &major, &minor, &pixmaps )==True) { |
| 121 | return (pixmaps==True) ? 2 : 1; |
| 122 | } |
| 123 | else { |
| 124 | return 0; |
| 125 | } |
| 126 | } |
| 127 | else { |
| 128 | return 0; |
| 129 | } |
| 130 | #else |
| 131 | /* No XSHM support */ |
| 132 | return 0; |
| 133 | #endif |
| 134 | } |
| 135 | |
| 136 | |
| 137 | /** |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 138 | * Return the true number of bits per pixel for XImages. |
| 139 | * For example, if we request a 24-bit deep visual we may actually need/get |
| 140 | * 32bpp XImages. This function returns the appropriate bpp. |
| 141 | * Input: dpy - the X display |
| 142 | * visinfo - desribes the visual to be used for XImages |
| 143 | * Return: true number of bits per pixel for XImages |
| 144 | */ |
| 145 | static int |
| 146 | bits_per_pixel( XMesaVisual xmv ) |
| 147 | { |
| 148 | #ifdef XFree86Server |
| 149 | const int depth = xmv->nplanes; |
| 150 | int i; |
| 151 | assert(depth > 0); |
| 152 | for (i = 0; i < screenInfo.numPixmapFormats; i++) { |
| 153 | if (screenInfo.formats[i].depth == depth) |
| 154 | return screenInfo.formats[i].bitsPerPixel; |
| 155 | } |
| 156 | return depth; /* should never get here, but this should be safe */ |
| 157 | #else |
| 158 | XMesaDisplay *dpy = xmv->display; |
| 159 | XMesaVisualInfo visinfo = xmv->visinfo; |
| 160 | XMesaImage *img; |
| 161 | int bitsPerPixel; |
| 162 | /* Create a temporary XImage */ |
| 163 | img = XCreateImage( dpy, visinfo->visual, visinfo->depth, |
| 164 | ZPixmap, 0, /*format, offset*/ |
| 165 | (char*) MALLOC(8), /*data*/ |
| 166 | 1, 1, /*width, height*/ |
| 167 | 32, /*bitmap_pad*/ |
| 168 | 0 /*bytes_per_line*/ |
| 169 | ); |
| 170 | assert(img); |
| 171 | /* grab the bits/pixel value */ |
| 172 | bitsPerPixel = img->bits_per_pixel; |
| 173 | /* free the XImage */ |
| 174 | _mesa_free( img->data ); |
| 175 | img->data = NULL; |
| 176 | XMesaDestroyImage( img ); |
| 177 | return bitsPerPixel; |
| 178 | #endif |
| 179 | } |
| 180 | |
| 181 | |
| 182 | |
| 183 | /* |
| 184 | * Determine if a given X window ID is valid (window exists). |
| 185 | * Do this by calling XGetWindowAttributes() for the window and |
| 186 | * checking if we catch an X error. |
| 187 | * Input: dpy - the display |
| 188 | * win - the window to check for existance |
| 189 | * Return: GL_TRUE - window exists |
| 190 | * GL_FALSE - window doesn't exist |
| 191 | */ |
| 192 | #ifndef XFree86Server |
| 193 | static GLboolean WindowExistsFlag; |
| 194 | |
| 195 | static int window_exists_err_handler( XMesaDisplay* dpy, XErrorEvent* xerr ) |
| 196 | { |
| 197 | (void) dpy; |
| 198 | if (xerr->error_code == BadWindow) { |
| 199 | WindowExistsFlag = GL_FALSE; |
| 200 | } |
| 201 | return 0; |
| 202 | } |
| 203 | |
| 204 | static GLboolean window_exists( XMesaDisplay *dpy, Window win ) |
| 205 | { |
| 206 | XWindowAttributes wa; |
| 207 | int (*old_handler)( XMesaDisplay*, XErrorEvent* ); |
| 208 | WindowExistsFlag = GL_TRUE; |
| 209 | old_handler = XSetErrorHandler(window_exists_err_handler); |
| 210 | XGetWindowAttributes( dpy, win, &wa ); /* dummy request */ |
| 211 | XSetErrorHandler(old_handler); |
| 212 | return WindowExistsFlag; |
| 213 | } |
| 214 | |
| 215 | static Status |
| 216 | get_drawable_size( XMesaDisplay *dpy, Drawable d, GLuint *width, GLuint *height ) |
| 217 | { |
| 218 | Window root; |
| 219 | Status stat; |
| 220 | int xpos, ypos; |
| 221 | unsigned int w, h, bw, depth; |
| 222 | stat = XGetGeometry(dpy, d, &root, &xpos, &ypos, &w, &h, &bw, &depth); |
| 223 | *width = w; |
| 224 | *height = h; |
| 225 | return stat; |
| 226 | } |
| 227 | #endif |
| 228 | |
| 229 | |
| 230 | /** |
| 231 | * Return the size of the window (or pixmap) that corresponds to the |
| 232 | * given XMesaBuffer. |
| 233 | * \param width returns width in pixels |
| 234 | * \param height returns height in pixels |
| 235 | */ |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 236 | static void |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 237 | xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b, |
| 238 | GLuint *width, GLuint *height) |
| 239 | { |
| 240 | #ifdef XFree86Server |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 241 | *width = MIN2(b->drawable->width, MAX_WIDTH); |
| 242 | *height = MIN2(b->drawable->height, MAX_HEIGHT); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 243 | #else |
| 244 | Status stat; |
| 245 | |
| 246 | _glthread_LOCK_MUTEX(_xmesa_lock); |
| 247 | XSync(b->xm_visual->display, 0); /* added for Chromium */ |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 248 | stat = get_drawable_size(dpy, b->drawable, width, height); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 249 | _glthread_UNLOCK_MUTEX(_xmesa_lock); |
| 250 | |
| 251 | if (!stat) { |
| 252 | /* probably querying a window that's recently been destroyed */ |
| 253 | _mesa_warning(NULL, "XGetGeometry failed!\n"); |
| 254 | *width = *height = 1; |
| 255 | } |
| 256 | #endif |
| 257 | } |
| 258 | |
| 259 | |
| 260 | |
| 261 | /**********************************************************************/ |
| 262 | /***** Linked list of XMesaBuffers *****/ |
| 263 | /**********************************************************************/ |
| 264 | |
| 265 | XMesaBuffer XMesaBufferList = NULL; |
| 266 | |
| 267 | |
| 268 | /** |
| 269 | * Allocate a new XMesaBuffer object which corresponds to the given drawable. |
| 270 | * Note that XMesaBuffer is derived from GLframebuffer. |
| 271 | * The new XMesaBuffer will not have any size (Width=Height=0). |
| 272 | * |
| 273 | * \param d the corresponding X drawable (window or pixmap) |
| 274 | * \param type either WINDOW, PIXMAP or PBUFFER, describing d |
| 275 | * \param vis the buffer's visual |
| 276 | * \param cmap the window's colormap, if known. |
| 277 | * \return new XMesaBuffer or NULL if any problem |
| 278 | */ |
| 279 | static XMesaBuffer |
| 280 | create_xmesa_buffer(XMesaDrawable d, BufferType type, |
| 281 | XMesaVisual vis, XMesaColormap cmap) |
| 282 | { |
| 283 | XMesaBuffer b; |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 284 | GLframebuffer *fb; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 285 | |
| 286 | ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER); |
| 287 | |
| 288 | b = (XMesaBuffer) CALLOC_STRUCT(xmesa_buffer); |
| 289 | if (!b) |
| 290 | return NULL; |
| 291 | |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 292 | b->drawable = d; |
| 293 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 294 | b->xm_visual = vis; |
| 295 | b->type = type; |
| 296 | b->cmap = cmap; |
| 297 | |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 298 | /* |
| 299 | * Create framebuffer, but we'll plug in our own renderbuffers below. |
| 300 | */ |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 301 | b->stfb = st_create_framebuffer(&vis->mesa_visual, GL_TRUE, (void *) b); |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 302 | fb = &b->stfb->Base; |
| 303 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 304 | /* |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 305 | * Create scratch XImage for xmesa_display_surface() |
Brian | b761177 | 2007-10-31 19:00:23 -0600 | [diff] [blame] | 306 | */ |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 307 | b->tempImage = XCreateImage(vis->display, |
| 308 | vis->visinfo->visual, |
| 309 | vis->visinfo->depth, |
| 310 | ZPixmap, 0, /* format, offset */ |
| 311 | NULL, /* data */ |
| 312 | 0, 0, /* size */ |
| 313 | 32, /* bitmap_pad */ |
| 314 | 0); /* bytes_per_line */ |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 315 | |
| 316 | /* GLX_EXT_texture_from_pixmap */ |
| 317 | b->TextureTarget = 0; |
| 318 | b->TextureFormat = GLX_TEXTURE_FORMAT_NONE_EXT; |
| 319 | b->TextureMipmap = 0; |
| 320 | |
| 321 | /* insert buffer into linked list */ |
| 322 | b->Next = XMesaBufferList; |
| 323 | XMesaBufferList = b; |
| 324 | |
| 325 | return b; |
| 326 | } |
| 327 | |
| 328 | |
| 329 | /** |
| 330 | * Find an XMesaBuffer by matching X display and colormap but NOT matching |
| 331 | * the notThis buffer. |
| 332 | */ |
| 333 | XMesaBuffer |
| 334 | xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis) |
| 335 | { |
| 336 | XMesaBuffer b; |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 337 | for (b = XMesaBufferList; b; b = b->Next) { |
| 338 | if (b->xm_visual->display == dpy && |
| 339 | b->cmap == cmap && |
| 340 | b != notThis) { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 341 | return b; |
| 342 | } |
| 343 | } |
| 344 | return NULL; |
| 345 | } |
| 346 | |
| 347 | |
| 348 | /** |
| 349 | * Remove buffer from linked list, delete if no longer referenced. |
| 350 | */ |
| 351 | static void |
| 352 | xmesa_free_buffer(XMesaBuffer buffer) |
| 353 | { |
| 354 | XMesaBuffer prev = NULL, b; |
| 355 | |
| 356 | for (b = XMesaBufferList; b; b = b->Next) { |
| 357 | if (b == buffer) { |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 358 | struct gl_framebuffer *fb = &buffer->stfb->Base; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 359 | |
| 360 | /* unlink buffer from list */ |
| 361 | if (prev) |
| 362 | prev->Next = buffer->Next; |
| 363 | else |
| 364 | XMesaBufferList = buffer->Next; |
| 365 | |
| 366 | /* mark as delete pending */ |
| 367 | fb->DeletePending = GL_TRUE; |
| 368 | |
| 369 | /* Since the X window for the XMesaBuffer is going away, we don't |
| 370 | * want to dereference this pointer in the future. |
| 371 | */ |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 372 | b->drawable = 0; |
| 373 | |
| 374 | buffer->tempImage->data = NULL; |
| 375 | XDestroyImage(buffer->tempImage); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 376 | |
| 377 | /* Unreference. If count = zero we'll really delete the buffer */ |
| 378 | _mesa_unreference_framebuffer(&fb); |
| 379 | |
| 380 | return; |
| 381 | } |
| 382 | /* continue search */ |
| 383 | prev = b; |
| 384 | } |
| 385 | /* buffer not found in XMesaBufferList */ |
| 386 | _mesa_problem(NULL,"xmesa_free_buffer() - buffer not found\n"); |
| 387 | } |
| 388 | |
| 389 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 390 | |
| 391 | /**********************************************************************/ |
| 392 | /***** Misc Private Functions *****/ |
| 393 | /**********************************************************************/ |
| 394 | |
| 395 | |
| 396 | /** |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 397 | * Choose the pixel format for the given visual. |
| 398 | * This will tell the gallium driver how to pack pixel data into |
| 399 | * drawing surfaces. |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 400 | */ |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 401 | static GLuint |
| 402 | choose_pixel_format(XMesaVisual v) |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 403 | { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 404 | if ( GET_REDMASK(v) == 0x0000ff |
| 405 | && GET_GREENMASK(v) == 0x00ff00 |
| 406 | && GET_BLUEMASK(v) == 0xff0000 |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 407 | && v->BitsPerPixel == 32) { |
Brian | 0d1669f | 2007-12-07 08:24:56 -0700 | [diff] [blame] | 408 | if (CHECK_BYTE_ORDER(v)) { |
| 409 | /* no byteswapping needed */ |
| 410 | return 0 /* PIXEL_FORMAT_U_A8_B8_G8_R8 */; |
| 411 | } |
| 412 | else { |
Brian | 2067eed | 2007-12-07 16:01:31 -0700 | [diff] [blame] | 413 | return PIPE_FORMAT_R8G8B8A8_UNORM; |
Brian | 0d1669f | 2007-12-07 08:24:56 -0700 | [diff] [blame] | 414 | } |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 415 | } |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 416 | else if ( GET_REDMASK(v) == 0xff0000 |
| 417 | && GET_GREENMASK(v) == 0x00ff00 |
| 418 | && GET_BLUEMASK(v) == 0x0000ff |
Brian | 0d1669f | 2007-12-07 08:24:56 -0700 | [diff] [blame] | 419 | && v->BitsPerPixel == 32) { |
| 420 | if (CHECK_BYTE_ORDER(v)) { |
| 421 | /* no byteswapping needed */ |
Brian | 2067eed | 2007-12-07 16:01:31 -0700 | [diff] [blame] | 422 | return PIPE_FORMAT_A8R8G8B8_UNORM; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 423 | } |
Brian | 0d1669f | 2007-12-07 08:24:56 -0700 | [diff] [blame] | 424 | else { |
Brian | 2067eed | 2007-12-07 16:01:31 -0700 | [diff] [blame] | 425 | return PIPE_FORMAT_B8G8R8A8_UNORM; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 426 | } |
| 427 | } |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 428 | else if ( GET_REDMASK(v) == 0xf800 |
| 429 | && GET_GREENMASK(v) == 0x07e0 |
| 430 | && GET_BLUEMASK(v) == 0x001f |
| 431 | && CHECK_BYTE_ORDER(v) |
| 432 | && v->BitsPerPixel == 16) { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 433 | /* 5-6-5 RGB */ |
Brian | 2067eed | 2007-12-07 16:01:31 -0700 | [diff] [blame] | 434 | return PIPE_FORMAT_R5G6B5_UNORM; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 435 | } |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 436 | |
| 437 | assert(0); |
| 438 | return 0; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 442 | /** |
| 443 | * When a context is bound for the first time, we can finally finish |
| 444 | * initializing the context's visual and buffer information. |
| 445 | * \param v the XMesaVisual to initialize |
| 446 | * \param b the XMesaBuffer to initialize (may be NULL) |
| 447 | * \param rgb_flag TRUE = RGBA mode, FALSE = color index mode |
| 448 | * \param window the window/pixmap we're rendering into |
| 449 | * \param cmap the colormap associated with the window/pixmap |
| 450 | * \return GL_TRUE=success, GL_FALSE=failure |
| 451 | */ |
| 452 | static GLboolean |
| 453 | initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, |
| 454 | GLboolean rgb_flag, XMesaDrawable window, |
| 455 | XMesaColormap cmap) |
| 456 | { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 457 | #ifdef XFree86Server |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 458 | int client = (window) ? CLIENT_ID(window->id) : 0; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 459 | #endif |
| 460 | |
| 461 | ASSERT(!b || b->xm_visual == v); |
| 462 | |
| 463 | /* Save true bits/pixel */ |
| 464 | v->BitsPerPixel = bits_per_pixel(v); |
| 465 | assert(v->BitsPerPixel > 0); |
| 466 | |
| 467 | if (rgb_flag == GL_FALSE) { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 468 | /* COLOR-INDEXED WINDOW: not supported*/ |
| 469 | return GL_FALSE; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 470 | } |
| 471 | else { |
| 472 | /* RGB WINDOW: |
| 473 | * We support RGB rendering into almost any kind of visual. |
| 474 | */ |
| 475 | const int xclass = v->mesa_visual.visualType; |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 476 | if (xclass != GLX_TRUE_COLOR && xclass == !GLX_DIRECT_COLOR) { |
| 477 | _mesa_warning(NULL, |
| 478 | "XMesa: RGB mode rendering not supported in given visual.\n"); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 479 | return GL_FALSE; |
| 480 | } |
| 481 | v->mesa_visual.indexBits = 0; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 482 | } |
| 483 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 484 | /* |
| 485 | * If MESA_INFO env var is set print out some debugging info |
| 486 | * which can help Brian figure out what's going on when a user |
| 487 | * reports bugs. |
| 488 | */ |
| 489 | if (_mesa_getenv("MESA_INFO")) { |
| 490 | _mesa_printf("X/Mesa visual = %p\n", (void *) v); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 491 | _mesa_printf("X/Mesa level = %d\n", v->mesa_visual.level); |
| 492 | _mesa_printf("X/Mesa depth = %d\n", GET_VISUAL_DEPTH(v)); |
| 493 | _mesa_printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel); |
| 494 | } |
| 495 | |
| 496 | if (b && window) { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 497 | /* these should have been set in create_xmesa_buffer */ |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 498 | ASSERT(b->drawable == window); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 499 | |
| 500 | /* Setup for single/double buffering */ |
| 501 | if (v->mesa_visual.doubleBufferMode) { |
| 502 | /* Double buffered */ |
| 503 | b->shm = check_for_xshm( v->display ); |
| 504 | } |
| 505 | |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 506 | /* X11 graphics context */ |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 507 | #ifdef XFree86Server |
| 508 | b->gc = CreateScratchGC(v->display, window->depth); |
| 509 | #else |
| 510 | b->gc = XCreateGC( v->display, window, 0, NULL ); |
| 511 | #endif |
| 512 | XMesaSetFunction( v->display, b->gc, GXcopy ); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | return GL_TRUE; |
| 516 | } |
| 517 | |
| 518 | |
| 519 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 520 | #define NUM_VISUAL_TYPES 6 |
| 521 | |
| 522 | /** |
| 523 | * Convert an X visual type to a GLX visual type. |
| 524 | * |
| 525 | * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.) |
| 526 | * to be converted. |
| 527 | * \return If \c visualType is a valid X visual type, a GLX visual type will |
| 528 | * be returned. Otherwise \c GLX_NONE will be returned. |
| 529 | * |
| 530 | * \note |
| 531 | * This code was lifted directly from lib/GL/glx/glcontextmodes.c in the |
| 532 | * DRI CVS tree. |
| 533 | */ |
| 534 | static GLint |
| 535 | xmesa_convert_from_x_visual_type( int visualType ) |
| 536 | { |
| 537 | static const int glx_visual_types[ NUM_VISUAL_TYPES ] = { |
| 538 | GLX_STATIC_GRAY, GLX_GRAY_SCALE, |
| 539 | GLX_STATIC_COLOR, GLX_PSEUDO_COLOR, |
| 540 | GLX_TRUE_COLOR, GLX_DIRECT_COLOR |
| 541 | }; |
| 542 | |
| 543 | return ( (unsigned) visualType < NUM_VISUAL_TYPES ) |
| 544 | ? glx_visual_types[ visualType ] : GLX_NONE; |
| 545 | } |
| 546 | |
| 547 | |
| 548 | /**********************************************************************/ |
| 549 | /***** Public Functions *****/ |
| 550 | /**********************************************************************/ |
| 551 | |
| 552 | |
| 553 | /* |
| 554 | * Create a new X/Mesa visual. |
| 555 | * Input: display - X11 display |
| 556 | * visinfo - an XVisualInfo pointer |
| 557 | * rgb_flag - GL_TRUE = RGB mode, |
| 558 | * GL_FALSE = color index mode |
| 559 | * alpha_flag - alpha buffer requested? |
| 560 | * db_flag - GL_TRUE = double-buffered, |
| 561 | * GL_FALSE = single buffered |
| 562 | * stereo_flag - stereo visual? |
| 563 | * ximage_flag - GL_TRUE = use an XImage for back buffer, |
| 564 | * GL_FALSE = use an off-screen pixmap for back buffer |
| 565 | * depth_size - requested bits/depth values, or zero |
| 566 | * stencil_size - requested bits/stencil values, or zero |
| 567 | * accum_red_size - requested bits/red accum values, or zero |
| 568 | * accum_green_size - requested bits/green accum values, or zero |
| 569 | * accum_blue_size - requested bits/blue accum values, or zero |
| 570 | * accum_alpha_size - requested bits/alpha accum values, or zero |
| 571 | * num_samples - number of samples/pixel if multisampling, or zero |
| 572 | * level - visual level, usually 0 |
| 573 | * visualCaveat - ala the GLX extension, usually GLX_NONE |
| 574 | * Return; a new XMesaVisual or 0 if error. |
| 575 | */ |
| 576 | PUBLIC |
| 577 | XMesaVisual XMesaCreateVisual( XMesaDisplay *display, |
| 578 | XMesaVisualInfo visinfo, |
| 579 | GLboolean rgb_flag, |
| 580 | GLboolean alpha_flag, |
| 581 | GLboolean db_flag, |
| 582 | GLboolean stereo_flag, |
| 583 | GLboolean ximage_flag, |
| 584 | GLint depth_size, |
| 585 | GLint stencil_size, |
| 586 | GLint accum_red_size, |
| 587 | GLint accum_green_size, |
| 588 | GLint accum_blue_size, |
| 589 | GLint accum_alpha_size, |
| 590 | GLint num_samples, |
| 591 | GLint level, |
| 592 | GLint visualCaveat ) |
| 593 | { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 594 | XMesaVisual v; |
| 595 | GLint red_bits, green_bits, blue_bits, alpha_bits; |
| 596 | |
| 597 | #ifndef XFree86Server |
| 598 | /* For debugging only */ |
| 599 | if (_mesa_getenv("MESA_XSYNC")) { |
| 600 | /* This makes debugging X easier. |
| 601 | * In your debugger, set a breakpoint on _XError to stop when an |
| 602 | * X protocol error is generated. |
| 603 | */ |
| 604 | XSynchronize( display, 1 ); |
| 605 | } |
| 606 | #endif |
| 607 | |
| 608 | v = (XMesaVisual) CALLOC_STRUCT(xmesa_visual); |
| 609 | if (!v) { |
| 610 | return NULL; |
| 611 | } |
| 612 | |
| 613 | v->display = display; |
| 614 | |
| 615 | /* Save a copy of the XVisualInfo struct because the user may X_mesa_free() |
| 616 | * the struct but we may need some of the information contained in it |
| 617 | * at a later time. |
| 618 | */ |
| 619 | #ifndef XFree86Server |
| 620 | v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo)); |
| 621 | if(!v->visinfo) { |
| 622 | _mesa_free(v); |
| 623 | return NULL; |
| 624 | } |
| 625 | MEMCPY(v->visinfo, visinfo, sizeof(*visinfo)); |
| 626 | #endif |
| 627 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 628 | v->ximage_flag = ximage_flag; |
| 629 | |
| 630 | #ifdef XFree86Server |
| 631 | /* We could calculate these values by ourselves. nplanes is either the sum |
| 632 | * of the red, green, and blue bits or the number index bits. |
| 633 | * ColormapEntries is either (1U << index_bits) or |
| 634 | * (1U << max(redBits, greenBits, blueBits)). |
| 635 | */ |
| 636 | assert(visinfo->nplanes > 0); |
| 637 | v->nplanes = visinfo->nplanes; |
| 638 | v->ColormapEntries = visinfo->ColormapEntries; |
| 639 | |
| 640 | v->mesa_visual.redMask = visinfo->redMask; |
| 641 | v->mesa_visual.greenMask = visinfo->greenMask; |
| 642 | v->mesa_visual.blueMask = visinfo->blueMask; |
| 643 | v->mesa_visual.visualID = visinfo->vid; |
| 644 | v->mesa_visual.screen = 0; /* FIXME: What should be done here? */ |
| 645 | #else |
| 646 | v->mesa_visual.redMask = visinfo->red_mask; |
| 647 | v->mesa_visual.greenMask = visinfo->green_mask; |
| 648 | v->mesa_visual.blueMask = visinfo->blue_mask; |
| 649 | v->mesa_visual.visualID = visinfo->visualid; |
| 650 | v->mesa_visual.screen = visinfo->screen; |
| 651 | #endif |
| 652 | |
| 653 | #if defined(XFree86Server) || !(defined(__cplusplus) || defined(c_plusplus)) |
| 654 | v->mesa_visual.visualType = xmesa_convert_from_x_visual_type(visinfo->class); |
| 655 | #else |
| 656 | v->mesa_visual.visualType = xmesa_convert_from_x_visual_type(visinfo->c_class); |
| 657 | #endif |
| 658 | |
| 659 | v->mesa_visual.visualRating = visualCaveat; |
| 660 | |
| 661 | if (alpha_flag) |
| 662 | v->mesa_visual.alphaBits = 8; |
| 663 | |
| 664 | (void) initialize_visual_and_buffer( v, NULL, rgb_flag, 0, 0 ); |
| 665 | |
| 666 | { |
| 667 | const int xclass = v->mesa_visual.visualType; |
| 668 | if (xclass == GLX_TRUE_COLOR || xclass == GLX_DIRECT_COLOR) { |
| 669 | red_bits = _mesa_bitcount(GET_REDMASK(v)); |
| 670 | green_bits = _mesa_bitcount(GET_GREENMASK(v)); |
| 671 | blue_bits = _mesa_bitcount(GET_BLUEMASK(v)); |
| 672 | } |
| 673 | else { |
| 674 | /* this is an approximation */ |
| 675 | int depth; |
| 676 | depth = GET_VISUAL_DEPTH(v); |
| 677 | red_bits = depth / 3; |
| 678 | depth -= red_bits; |
| 679 | green_bits = depth / 2; |
| 680 | depth -= green_bits; |
| 681 | blue_bits = depth; |
| 682 | alpha_bits = 0; |
| 683 | assert( red_bits + green_bits + blue_bits == GET_VISUAL_DEPTH(v) ); |
| 684 | } |
| 685 | alpha_bits = v->mesa_visual.alphaBits; |
| 686 | } |
| 687 | |
| 688 | _mesa_initialize_visual( &v->mesa_visual, |
| 689 | rgb_flag, db_flag, stereo_flag, |
| 690 | red_bits, green_bits, |
| 691 | blue_bits, alpha_bits, |
| 692 | v->mesa_visual.indexBits, |
| 693 | depth_size, |
| 694 | stencil_size, |
| 695 | accum_red_size, accum_green_size, |
| 696 | accum_blue_size, accum_alpha_size, |
| 697 | 0 ); |
| 698 | |
| 699 | /* XXX minor hack */ |
| 700 | v->mesa_visual.level = level; |
| 701 | return v; |
| 702 | } |
| 703 | |
| 704 | |
| 705 | PUBLIC |
| 706 | void XMesaDestroyVisual( XMesaVisual v ) |
| 707 | { |
| 708 | #ifndef XFree86Server |
| 709 | _mesa_free(v->visinfo); |
| 710 | #endif |
| 711 | _mesa_free(v); |
| 712 | } |
| 713 | |
| 714 | |
| 715 | |
| 716 | /** |
| 717 | * Create a new XMesaContext. |
| 718 | * \param v the XMesaVisual |
| 719 | * \param share_list another XMesaContext with which to share display |
| 720 | * lists or NULL if no sharing is wanted. |
| 721 | * \return an XMesaContext or NULL if error. |
| 722 | */ |
| 723 | PUBLIC |
| 724 | XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) |
| 725 | { |
| 726 | static GLboolean firstTime = GL_TRUE; |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 727 | struct pipe_context *pipe; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 728 | XMesaContext c; |
| 729 | GLcontext *mesaCtx; |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 730 | uint pf; |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 731 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 732 | if (firstTime) { |
| 733 | _glthread_INIT_MUTEX(_xmesa_lock); |
| 734 | firstTime = GL_FALSE; |
| 735 | } |
| 736 | |
| 737 | /* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */ |
| 738 | c = (XMesaContext) CALLOC_STRUCT(xmesa_context); |
| 739 | if (!c) |
| 740 | return NULL; |
| 741 | |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 742 | pf = choose_pixel_format(v); |
Brian | 0d1669f | 2007-12-07 08:24:56 -0700 | [diff] [blame] | 743 | assert(pf); |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 744 | |
Zack Rusin | c474f1f | 2007-12-11 07:19:11 -0500 | [diff] [blame^] | 745 | if (!getenv("XM_AUB")) { |
| 746 | xmesa_mode = XMESA_SOFTPIPE; |
| 747 | pipe = xmesa_create_pipe_context( c, pf ); |
| 748 | } |
| 749 | else { |
| 750 | xmesa_mode = XMESA_AUB; |
| 751 | pipe = xmesa_create_i965simple( xmesa_get_pipe_winsys_aub() ); |
| 752 | } |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 753 | |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 754 | c->st = st_create_context(pipe, &v->mesa_visual, |
| 755 | share_list ? share_list->st : NULL); |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 756 | mesaCtx = c->st->ctx; |
| 757 | c->st->ctx->DriverCtx = c; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 758 | |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 759 | #if 00 |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 760 | _mesa_enable_sw_extensions(mesaCtx); |
| 761 | _mesa_enable_1_3_extensions(mesaCtx); |
| 762 | _mesa_enable_1_4_extensions(mesaCtx); |
| 763 | _mesa_enable_1_5_extensions(mesaCtx); |
| 764 | _mesa_enable_2_0_extensions(mesaCtx); |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 765 | #endif |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 766 | |
| 767 | #ifdef XFree86Server |
| 768 | /* If we're running in the X server, do bounds checking to prevent |
| 769 | * segfaults and server crashes! |
| 770 | */ |
| 771 | mesaCtx->Const.CheckArrayBounds = GL_TRUE; |
| 772 | #endif |
| 773 | |
| 774 | /* finish up xmesa context initializations */ |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 775 | c->xm_visual = v; |
| 776 | c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */ |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 777 | |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 778 | c->st->haveFramebufferSurfaces = GL_TRUE; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 779 | |
| 780 | return c; |
| 781 | } |
| 782 | |
| 783 | |
| 784 | |
| 785 | PUBLIC |
| 786 | void XMesaDestroyContext( XMesaContext c ) |
| 787 | { |
Brian | 91564ee | 2007-11-05 16:15:43 -0700 | [diff] [blame] | 788 | st_destroy_context(c->st); |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 789 | _mesa_free(c); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | |
| 793 | |
| 794 | /** |
| 795 | * Private function for creating an XMesaBuffer which corresponds to an |
| 796 | * X window or pixmap. |
| 797 | * \param v the window's XMesaVisual |
| 798 | * \param w the window we're wrapping |
| 799 | * \return new XMesaBuffer or NULL if error |
| 800 | */ |
| 801 | PUBLIC XMesaBuffer |
| 802 | XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w) |
| 803 | { |
| 804 | #ifndef XFree86Server |
| 805 | XWindowAttributes attr; |
| 806 | #endif |
| 807 | XMesaBuffer b; |
| 808 | XMesaColormap cmap; |
| 809 | int depth; |
| 810 | |
| 811 | assert(v); |
| 812 | assert(w); |
| 813 | |
| 814 | /* Check that window depth matches visual depth */ |
| 815 | #ifdef XFree86Server |
| 816 | depth = ((XMesaDrawable)w)->depth; |
| 817 | #else |
| 818 | XGetWindowAttributes( v->display, w, &attr ); |
| 819 | depth = attr.depth; |
| 820 | #endif |
| 821 | if (GET_VISUAL_DEPTH(v) != depth) { |
| 822 | _mesa_warning(NULL, "XMesaCreateWindowBuffer: depth mismatch between visual (%d) and window (%d)!\n", |
| 823 | GET_VISUAL_DEPTH(v), depth); |
| 824 | return NULL; |
| 825 | } |
| 826 | |
| 827 | /* Find colormap */ |
| 828 | #ifdef XFree86Server |
| 829 | cmap = (ColormapPtr)LookupIDByType(wColormap(w), RT_COLORMAP); |
| 830 | #else |
| 831 | if (attr.colormap) { |
| 832 | cmap = attr.colormap; |
| 833 | } |
| 834 | else { |
| 835 | _mesa_warning(NULL, "Window %u has no colormap!\n", (unsigned int) w); |
| 836 | /* this is weird, a window w/out a colormap!? */ |
| 837 | /* OK, let's just allocate a new one and hope for the best */ |
| 838 | cmap = XCreateColormap(v->display, w, attr.visual, AllocNone); |
| 839 | } |
| 840 | #endif |
| 841 | |
| 842 | b = create_xmesa_buffer((XMesaDrawable) w, WINDOW, v, cmap); |
| 843 | if (!b) |
| 844 | return NULL; |
| 845 | |
| 846 | if (!initialize_visual_and_buffer( v, b, v->mesa_visual.rgbMode, |
| 847 | (XMesaDrawable) w, cmap )) { |
| 848 | xmesa_free_buffer(b); |
| 849 | return NULL; |
| 850 | } |
| 851 | |
| 852 | return b; |
| 853 | } |
| 854 | |
| 855 | |
| 856 | |
| 857 | /** |
| 858 | * Create a new XMesaBuffer from an X pixmap. |
| 859 | * |
| 860 | * \param v the XMesaVisual |
| 861 | * \param p the pixmap |
| 862 | * \param cmap the colormap, may be 0 if using a \c GLX_TRUE_COLOR or |
| 863 | * \c GLX_DIRECT_COLOR visual for the pixmap |
| 864 | * \returns new XMesaBuffer or NULL if error |
| 865 | */ |
| 866 | PUBLIC XMesaBuffer |
| 867 | XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, XMesaColormap cmap) |
| 868 | { |
| 869 | XMesaBuffer b; |
| 870 | |
| 871 | assert(v); |
| 872 | |
| 873 | b = create_xmesa_buffer((XMesaDrawable) p, PIXMAP, v, cmap); |
| 874 | if (!b) |
| 875 | return NULL; |
| 876 | |
| 877 | if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode, |
| 878 | (XMesaDrawable) p, cmap)) { |
| 879 | xmesa_free_buffer(b); |
| 880 | return NULL; |
| 881 | } |
| 882 | |
| 883 | return b; |
| 884 | } |
| 885 | |
| 886 | |
| 887 | /** |
| 888 | * For GLX_EXT_texture_from_pixmap |
| 889 | */ |
| 890 | XMesaBuffer |
| 891 | XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p, |
| 892 | XMesaColormap cmap, |
| 893 | int format, int target, int mipmap) |
| 894 | { |
| 895 | GET_CURRENT_CONTEXT(ctx); |
| 896 | XMesaBuffer b; |
| 897 | GLuint width, height; |
| 898 | |
| 899 | assert(v); |
| 900 | |
| 901 | b = create_xmesa_buffer((XMesaDrawable) p, PIXMAP, v, cmap); |
| 902 | if (!b) |
| 903 | return NULL; |
| 904 | |
| 905 | /* get pixmap size, update framebuffer/renderbuffer dims */ |
| 906 | xmesa_get_window_size(v->display, b, &width, &height); |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 907 | _mesa_resize_framebuffer(NULL, &(b->stfb->Base), width, height); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 908 | |
| 909 | if (target == 0) { |
| 910 | /* examine dims */ |
| 911 | if (ctx->Extensions.ARB_texture_non_power_of_two) { |
| 912 | target = GLX_TEXTURE_2D_EXT; |
| 913 | } |
| 914 | else if ( _mesa_bitcount(width) == 1 |
| 915 | && _mesa_bitcount(height) == 1) { |
| 916 | /* power of two size */ |
| 917 | if (height == 1) { |
| 918 | target = GLX_TEXTURE_1D_EXT; |
| 919 | } |
| 920 | else { |
| 921 | target = GLX_TEXTURE_2D_EXT; |
| 922 | } |
| 923 | } |
| 924 | else if (ctx->Extensions.NV_texture_rectangle) { |
| 925 | target = GLX_TEXTURE_RECTANGLE_EXT; |
| 926 | } |
| 927 | else { |
| 928 | /* non power of two textures not supported */ |
| 929 | XMesaDestroyBuffer(b); |
| 930 | return 0; |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | b->TextureTarget = target; |
| 935 | b->TextureFormat = format; |
| 936 | b->TextureMipmap = mipmap; |
| 937 | |
| 938 | if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode, |
| 939 | (XMesaDrawable) p, cmap)) { |
| 940 | xmesa_free_buffer(b); |
| 941 | return NULL; |
| 942 | } |
| 943 | |
| 944 | return b; |
| 945 | } |
| 946 | |
| 947 | |
| 948 | |
| 949 | XMesaBuffer |
| 950 | XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap, |
| 951 | unsigned int width, unsigned int height) |
| 952 | { |
| 953 | #ifndef XFree86Server |
| 954 | XMesaWindow root; |
| 955 | XMesaDrawable drawable; /* X Pixmap Drawable */ |
| 956 | XMesaBuffer b; |
| 957 | |
| 958 | /* allocate pixmap for front buffer */ |
| 959 | root = RootWindow( v->display, v->visinfo->screen ); |
| 960 | drawable = XCreatePixmap(v->display, root, width, height, |
| 961 | v->visinfo->depth); |
| 962 | if (!drawable) |
| 963 | return NULL; |
| 964 | |
| 965 | b = create_xmesa_buffer(drawable, PBUFFER, v, cmap); |
| 966 | if (!b) |
| 967 | return NULL; |
| 968 | |
| 969 | if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode, |
| 970 | drawable, cmap)) { |
| 971 | xmesa_free_buffer(b); |
| 972 | return NULL; |
| 973 | } |
| 974 | |
| 975 | return b; |
| 976 | #else |
| 977 | return 0; |
| 978 | #endif |
| 979 | } |
| 980 | |
| 981 | |
| 982 | |
| 983 | /* |
| 984 | * Deallocate an XMesaBuffer structure and all related info. |
| 985 | */ |
| 986 | PUBLIC void |
| 987 | XMesaDestroyBuffer(XMesaBuffer b) |
| 988 | { |
| 989 | xmesa_free_buffer(b); |
| 990 | } |
| 991 | |
| 992 | |
| 993 | /** |
| 994 | * Query the current window size and update the corresponding GLframebuffer |
| 995 | * and all attached renderbuffers. |
| 996 | * Called when: |
| 997 | * 1. the first time a buffer is bound to a context. |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 998 | * 2. from the XMesaResizeBuffers() API function. |
| 999 | * 3. SwapBuffers. XXX probabaly from xm_flush_frontbuffer() too... |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1000 | * Note: it's possible (and legal) for xmctx to be NULL. That can happen |
| 1001 | * when resizing a buffer when no rendering context is bound. |
| 1002 | */ |
| 1003 | void |
| 1004 | xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer) |
| 1005 | { |
| 1006 | GLuint width, height; |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1007 | xmesa_get_window_size(drawBuffer->xm_visual->display, drawBuffer, &width, &height); |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 1008 | st_resize_framebuffer(drawBuffer->stfb, width, height); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1009 | } |
| 1010 | |
| 1011 | |
| 1012 | /* |
| 1013 | * Bind buffer b to context c and make c the current rendering context. |
| 1014 | */ |
| 1015 | GLboolean XMesaMakeCurrent( XMesaContext c, XMesaBuffer b ) |
| 1016 | { |
| 1017 | return XMesaMakeCurrent2( c, b, b ); |
| 1018 | } |
| 1019 | |
| 1020 | |
| 1021 | /* |
| 1022 | * Bind buffer b to context c and make c the current rendering context. |
| 1023 | */ |
| 1024 | PUBLIC |
| 1025 | GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, |
| 1026 | XMesaBuffer readBuffer ) |
| 1027 | { |
| 1028 | if (c) { |
| 1029 | if (!drawBuffer || !readBuffer) |
| 1030 | return GL_FALSE; /* must specify buffers! */ |
| 1031 | |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 1032 | #if 0 |
| 1033 | /* XXX restore this optimization */ |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1034 | if (&(c->mesa) == _mesa_get_current_context() |
| 1035 | && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer |
| 1036 | && c->mesa.ReadBuffer == &readBuffer->mesa_buffer |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1037 | && xmesa_buffer(c->mesa.DrawBuffer)->wasCurrent) { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1038 | /* same context and buffer, do nothing */ |
| 1039 | return GL_TRUE; |
| 1040 | } |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 1041 | #endif |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1042 | |
| 1043 | c->xm_buffer = drawBuffer; |
| 1044 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1045 | /* Call this periodically to detect when the user has begun using |
| 1046 | * GL rendering from multiple threads. |
| 1047 | */ |
| 1048 | _glapi_check_multithread(); |
| 1049 | |
| 1050 | xmesa_check_and_update_buffer_size(c, drawBuffer); |
| 1051 | if (readBuffer != drawBuffer) |
| 1052 | xmesa_check_and_update_buffer_size(c, readBuffer); |
| 1053 | |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 1054 | st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1055 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1056 | /* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */ |
| 1057 | drawBuffer->wasCurrent = GL_TRUE; |
| 1058 | } |
| 1059 | else { |
| 1060 | /* Detach */ |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 1061 | st_make_current( NULL, NULL, NULL ); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1062 | } |
| 1063 | return GL_TRUE; |
| 1064 | } |
| 1065 | |
| 1066 | |
| 1067 | /* |
| 1068 | * Unbind the context c from its buffer. |
| 1069 | */ |
| 1070 | GLboolean XMesaUnbindContext( XMesaContext c ) |
| 1071 | { |
| 1072 | /* A no-op for XFree86 integration purposes */ |
| 1073 | return GL_TRUE; |
| 1074 | } |
| 1075 | |
| 1076 | |
| 1077 | XMesaContext XMesaGetCurrentContext( void ) |
| 1078 | { |
| 1079 | GET_CURRENT_CONTEXT(ctx); |
| 1080 | if (ctx) { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1081 | XMesaContext xmesa = xmesa_context(ctx); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1082 | return xmesa; |
| 1083 | } |
| 1084 | else { |
| 1085 | return 0; |
| 1086 | } |
| 1087 | } |
| 1088 | |
| 1089 | |
| 1090 | XMesaBuffer XMesaGetCurrentBuffer( void ) |
| 1091 | { |
| 1092 | GET_CURRENT_CONTEXT(ctx); |
| 1093 | if (ctx) { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1094 | XMesaBuffer xmbuf = xmesa_buffer(ctx->DrawBuffer); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1095 | return xmbuf; |
| 1096 | } |
| 1097 | else { |
| 1098 | return 0; |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | |
| 1103 | /* New in Mesa 3.1 */ |
| 1104 | XMesaBuffer XMesaGetCurrentReadBuffer( void ) |
| 1105 | { |
| 1106 | GET_CURRENT_CONTEXT(ctx); |
| 1107 | if (ctx) { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1108 | return xmesa_buffer(ctx->ReadBuffer); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1109 | } |
| 1110 | else { |
| 1111 | return 0; |
| 1112 | } |
| 1113 | } |
| 1114 | |
| 1115 | |
| 1116 | #ifdef XFree86Server |
| 1117 | PUBLIC |
| 1118 | GLboolean XMesaForceCurrent(XMesaContext c) |
| 1119 | { |
| 1120 | if (c) { |
| 1121 | _glapi_set_dispatch(c->mesa.CurrentDispatch); |
| 1122 | |
| 1123 | if (&(c->mesa) != _mesa_get_current_context()) { |
| 1124 | _mesa_make_current(&c->mesa, c->mesa.DrawBuffer, c->mesa.ReadBuffer); |
| 1125 | } |
| 1126 | } |
| 1127 | else { |
| 1128 | _mesa_make_current(NULL, NULL, NULL); |
| 1129 | } |
| 1130 | return GL_TRUE; |
| 1131 | } |
| 1132 | |
| 1133 | |
| 1134 | PUBLIC |
| 1135 | GLboolean XMesaLoseCurrent(XMesaContext c) |
| 1136 | { |
| 1137 | (void) c; |
| 1138 | _mesa_make_current(NULL, NULL, NULL); |
| 1139 | return GL_TRUE; |
| 1140 | } |
| 1141 | |
| 1142 | |
| 1143 | PUBLIC |
| 1144 | GLboolean XMesaCopyContext( XMesaContext xm_src, XMesaContext xm_dst, GLuint mask ) |
| 1145 | { |
| 1146 | _mesa_copy_context(&xm_src->mesa, &xm_dst->mesa, mask); |
| 1147 | return GL_TRUE; |
| 1148 | } |
| 1149 | #endif /* XFree86Server */ |
| 1150 | |
| 1151 | |
| 1152 | #ifndef FX |
| 1153 | GLboolean XMesaSetFXmode( GLint mode ) |
| 1154 | { |
| 1155 | (void) mode; |
| 1156 | return GL_FALSE; |
| 1157 | } |
| 1158 | #endif |
| 1159 | |
| 1160 | |
| 1161 | |
| 1162 | /* |
| 1163 | * Copy the back buffer to the front buffer. If there's no back buffer |
| 1164 | * this is a no-op. |
| 1165 | */ |
| 1166 | PUBLIC |
| 1167 | void XMesaSwapBuffers( XMesaBuffer b ) |
| 1168 | { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1169 | struct pipe_surface *surf; |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1170 | |
| 1171 | /* If we're swapping the buffer associated with the current context |
| 1172 | * we have to flush any pending rendering commands first. |
| 1173 | */ |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 1174 | st_notify_swapbuffers(b->stfb); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1175 | |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1176 | surf = st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT); |
| 1177 | if (surf) { |
Zack Rusin | c474f1f | 2007-12-11 07:19:11 -0500 | [diff] [blame^] | 1178 | if (xmesa_mode == XMESA_AUB) |
| 1179 | xmesa_display_aub( surf ); |
| 1180 | else |
| 1181 | xmesa_display_surface(b, surf); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1182 | } |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1183 | |
| 1184 | xmesa_check_and_update_buffer_size(NULL, b); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | |
| 1188 | |
| 1189 | /* |
| 1190 | * Copy sub-region of back buffer to front buffer |
| 1191 | */ |
| 1192 | void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height ) |
| 1193 | { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1194 | struct pipe_surface *surf_front |
| 1195 | = st_get_framebuffer_surface(b->stfb, ST_SURFACE_FRONT_LEFT); |
| 1196 | struct pipe_surface *surf_back |
| 1197 | = st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT); |
| 1198 | struct pipe_context *pipe = NULL; /* XXX fix */ |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1199 | |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1200 | if (!surf_front || !surf_back) |
| 1201 | return; |
Brian | e39f1b4 | 2007-11-05 15:59:55 -0700 | [diff] [blame] | 1202 | |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1203 | pipe->surface_copy(pipe, |
| 1204 | surf_front, x, y, /* dest */ |
| 1205 | surf_back, x, y, /* src */ |
| 1206 | width, height); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1207 | } |
| 1208 | |
| 1209 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1210 | |
| 1211 | /* |
| 1212 | * Return the depth buffer associated with an XMesaBuffer. |
| 1213 | * Input: b - the XMesa buffer handle |
| 1214 | * Output: width, height - size of buffer in pixels |
| 1215 | * bytesPerValue - bytes per depth value (2 or 4) |
| 1216 | * buffer - pointer to depth buffer values |
| 1217 | * Return: GL_TRUE or GL_FALSE to indicate success or failure. |
| 1218 | */ |
| 1219 | GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height, |
| 1220 | GLint *bytesPerValue, void **buffer ) |
| 1221 | { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1222 | struct pipe_surface *surf |
| 1223 | = st_get_framebuffer_surface(b->stfb, ST_SURFACE_DEPTH); |
| 1224 | if (surf) { |
| 1225 | *width = surf->width; |
| 1226 | *height = surf->pitch; |
| 1227 | *bytesPerValue = surf->cpp; |
| 1228 | *buffer = surf->map; |
| 1229 | return GL_TRUE; |
| 1230 | } |
| 1231 | else { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1232 | *width = 0; |
| 1233 | *height = 0; |
| 1234 | *bytesPerValue = 0; |
| 1235 | *buffer = 0; |
| 1236 | return GL_FALSE; |
| 1237 | } |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | |
| 1241 | void XMesaFlush( XMesaContext c ) |
| 1242 | { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1243 | if (c && c->xm_visual->display) { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1244 | #ifdef XFree86Server |
| 1245 | /* NOT_NEEDED */ |
| 1246 | #else |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1247 | XSync( c->xm_visual->display, False ); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1248 | #endif |
| 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | |
| 1253 | |
| 1254 | const char *XMesaGetString( XMesaContext c, int name ) |
| 1255 | { |
| 1256 | (void) c; |
| 1257 | if (name==XMESA_VERSION) { |
| 1258 | return "5.0"; |
| 1259 | } |
| 1260 | else if (name==XMESA_EXTENSIONS) { |
| 1261 | return ""; |
| 1262 | } |
| 1263 | else { |
| 1264 | return NULL; |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | |
| 1269 | |
| 1270 | XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy, XMesaDrawable d ) |
| 1271 | { |
| 1272 | XMesaBuffer b; |
| 1273 | for (b=XMesaBufferList; b; b=b->Next) { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1274 | if (b->drawable == d && b->xm_visual->display == dpy) { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1275 | return b; |
| 1276 | } |
| 1277 | } |
| 1278 | return NULL; |
| 1279 | } |
| 1280 | |
| 1281 | |
| 1282 | /** |
| 1283 | * Free/destroy all XMesaBuffers associated with given display. |
| 1284 | */ |
| 1285 | void xmesa_destroy_buffers_on_display(XMesaDisplay *dpy) |
| 1286 | { |
| 1287 | XMesaBuffer b, next; |
| 1288 | for (b = XMesaBufferList; b; b = next) { |
| 1289 | next = b->Next; |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1290 | if (b->xm_visual->display == dpy) { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1291 | xmesa_free_buffer(b); |
| 1292 | } |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | |
| 1297 | /* |
| 1298 | * Look for XMesaBuffers whose X window has been destroyed. |
| 1299 | * Deallocate any such XMesaBuffers. |
| 1300 | */ |
| 1301 | void XMesaGarbageCollect( void ) |
| 1302 | { |
| 1303 | XMesaBuffer b, next; |
| 1304 | for (b=XMesaBufferList; b; b=next) { |
| 1305 | next = b->Next; |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1306 | if (b->xm_visual && |
| 1307 | b->xm_visual->display && |
| 1308 | b->drawable && |
| 1309 | b->type == WINDOW) { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1310 | #ifdef XFree86Server |
| 1311 | /* NOT_NEEDED */ |
| 1312 | #else |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1313 | XSync(b->xm_visual->display, False); |
| 1314 | if (!window_exists( b->xm_visual->display, b->drawable )) { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1315 | /* found a dead window, free the ancillary info */ |
| 1316 | XMesaDestroyBuffer( b ); |
| 1317 | } |
| 1318 | #endif |
| 1319 | } |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | |
| 1324 | unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y, |
| 1325 | GLfloat red, GLfloat green, |
| 1326 | GLfloat blue, GLfloat alpha ) |
| 1327 | { |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1328 | /* no longer supported */ |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1329 | return 0; |
| 1330 | } |
| 1331 | |
| 1332 | |
| 1333 | /* |
| 1334 | * This is typically called when the window size changes and we need |
| 1335 | * to reallocate the buffer's back/depth/stencil/accum buffers. |
| 1336 | */ |
| 1337 | PUBLIC void |
| 1338 | XMesaResizeBuffers( XMesaBuffer b ) |
| 1339 | { |
| 1340 | GET_CURRENT_CONTEXT(ctx); |
Brian | 749d723 | 2007-12-07 07:57:54 -0700 | [diff] [blame] | 1341 | XMesaContext xmctx = xmesa_context(ctx); |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1342 | if (!xmctx) |
| 1343 | return; |
| 1344 | xmesa_check_and_update_buffer_size(xmctx, b); |
| 1345 | } |
| 1346 | |
| 1347 | |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1348 | |
| 1349 | |
| 1350 | PUBLIC void |
| 1351 | XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer, |
| 1352 | const int *attrib_list) |
| 1353 | { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1354 | } |
| 1355 | |
| 1356 | |
| 1357 | |
| 1358 | PUBLIC void |
| 1359 | XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer) |
| 1360 | { |
Brian | ef25c49 | 2007-10-31 14:19:09 -0600 | [diff] [blame] | 1361 | } |
| 1362 | |