2 * Copyright 2008, 2010 George Sapountzis <gsapountzis@gmail.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
24 * DRI software rasterizer
26 * This is the mesa swrast module packaged into a DRI driver structure.
28 * The front-buffer is allocated by the loader. The loader provides read/write
29 * callbacks for access to the front-buffer. The driver uses a scratch row for
30 * front-buffer rendering to avoid repeated calls to the loader.
32 * The back-buffer is allocated by the driver and is private.
35 #include "main/api_exec.h"
36 #include "main/context.h"
37 #include "main/extensions.h"
38 #include "main/formats.h"
39 #include "main/framebuffer.h"
40 #include "main/imports.h"
41 #include "main/renderbuffer.h"
42 #include "main/version.h"
43 #include "main/vtxfmt.h"
44 #include "swrast/swrast.h"
45 #include "swrast/s_renderbuffer.h"
46 #include "swrast_setup/swrast_setup.h"
48 #include "tnl/t_context.h"
49 #include "tnl/t_pipeline.h"
51 #include "drivers/common/driverfuncs.h"
52 #include "drivers/common/meta.h"
55 #include "main/teximage.h"
56 #include "main/texformat.h"
57 #include "main/texstate.h"
59 #include "swrast_priv.h"
60 #include "swrast/s_context.h"
64 * Screen and config-related functions
67 static void swrastSetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
,
68 GLint texture_format
, __DRIdrawable
*dPriv
)
70 struct dri_context
*dri_ctx
;
72 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
73 struct gl_texture_unit
*texUnit
;
74 struct gl_texture_object
*texObj
;
75 struct gl_texture_image
*texImage
;
76 struct swrast_texture_image
*swImage
;
77 uint32_t internalFormat
;
80 dri_ctx
= pDRICtx
->driverPrivate
;
82 internalFormat
= (texture_format
== __DRI_TEXTURE_FORMAT_RGB
? 3 : 4);
84 texUnit
= _mesa_get_current_tex_unit(&dri_ctx
->Base
);
85 texObj
= _mesa_select_tex_object(&dri_ctx
->Base
, texUnit
, target
);
86 texImage
= _mesa_get_tex_image(&dri_ctx
->Base
, texObj
, target
, 0);
87 swImage
= swrast_texture_image(texImage
);
89 _mesa_lock_texture(&dri_ctx
->Base
, texObj
);
91 sPriv
->swrast_loader
->getDrawableInfo(dPriv
, &x
, &y
, &w
, &h
, dPriv
->loaderPrivate
);
93 if (texture_format
== __DRI_TEXTURE_FORMAT_RGB
)
94 texFormat
= MESA_FORMAT_XRGB8888
;
96 texFormat
= MESA_FORMAT_ARGB8888
;
98 _mesa_init_teximage_fields(&dri_ctx
->Base
, texImage
,
99 w
, h
, 1, 0, internalFormat
, texFormat
);
101 sPriv
->swrast_loader
->getImage(dPriv
, x
, y
, w
, h
, (char *)swImage
->Buffer
,
102 dPriv
->loaderPrivate
);
104 _mesa_unlock_texture(&dri_ctx
->Base
, texObj
);
107 static void swrastSetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
,
108 __DRIdrawable
*dPriv
)
110 swrastSetTexBuffer2(pDRICtx
, target
, __DRI_TEXTURE_FORMAT_RGBA
, dPriv
);
113 static const __DRItexBufferExtension swrastTexBufferExtension
= {
114 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
119 static const __DRIextension
*dri_screen_extensions
[] = {
120 &swrastTexBufferExtension
.base
,
124 static __DRIconfig
**
125 swrastFillInModes(__DRIscreen
*psp
,
126 unsigned pixel_bits
, unsigned depth_bits
,
127 unsigned stencil_bits
, GLboolean have_back_buffer
)
129 __DRIconfig
**configs
;
130 unsigned depth_buffer_factor
;
131 unsigned back_buffer_factor
;
134 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
135 * support pageflipping at all.
137 static const GLenum back_buffer_modes
[] = {
138 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
141 uint8_t depth_bits_array
[4];
142 uint8_t stencil_bits_array
[4];
143 uint8_t msaa_samples_array
[1];
146 (void) have_back_buffer
;
148 depth_bits_array
[0] = 0;
149 depth_bits_array
[1] = 0;
150 depth_bits_array
[2] = depth_bits
;
151 depth_bits_array
[3] = depth_bits
;
153 /* Just like with the accumulation buffer, always provide some modes
154 * with a stencil buffer.
156 stencil_bits_array
[0] = 0;
157 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
158 stencil_bits_array
[2] = 0;
159 stencil_bits_array
[3] = (stencil_bits
== 0) ? 8 : stencil_bits
;
161 msaa_samples_array
[0] = 0;
163 depth_buffer_factor
= 4;
164 back_buffer_factor
= 2;
166 switch (pixel_bits
) {
168 format
= MESA_FORMAT_RGB565
;
171 format
= MESA_FORMAT_XRGB8888
;
174 format
= MESA_FORMAT_ARGB8888
;
177 fprintf(stderr
, "[%s:%u] bad depth %d\n", __func__
, __LINE__
,
182 configs
= driCreateConfigs(format
,
183 depth_bits_array
, stencil_bits_array
,
184 depth_buffer_factor
, back_buffer_modes
,
185 back_buffer_factor
, msaa_samples_array
, 1,
187 if (configs
== NULL
) {
188 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
196 static const __DRIconfig
**
197 dri_init_screen(__DRIscreen
* psp
)
199 __DRIconfig
**configs16
, **configs24
, **configs32
;
203 psp
->extensions
= dri_screen_extensions
;
205 configs16
= swrastFillInModes(psp
, 16, 16, 0, 1);
206 configs24
= swrastFillInModes(psp
, 24, 24, 8, 1);
207 configs32
= swrastFillInModes(psp
, 32, 24, 8, 1);
209 configs24
= driConcatConfigs(configs16
, configs24
);
210 configs32
= driConcatConfigs(configs24
, configs32
);
212 return (const __DRIconfig
**)configs32
;
216 dri_destroy_screen(__DRIscreen
* sPriv
)
224 * Framebuffer and renderbuffer-related functions.
228 choose_pixel_format(const struct gl_config
*v
)
230 int depth
= v
->rgbBits
;
233 && v
->redMask
== 0xff0000
234 && v
->greenMask
== 0x00ff00
235 && v
->blueMask
== 0x0000ff)
238 && v
->redMask
== 0xff0000
239 && v
->greenMask
== 0x00ff00
240 && v
->blueMask
== 0x0000ff)
243 && v
->redMask
== 0xf800
244 && v
->greenMask
== 0x07e0
245 && v
->blueMask
== 0x001f)
248 && v
->redMask
== 0x07
249 && v
->greenMask
== 0x38
250 && v
->blueMask
== 0xc0)
253 _mesa_problem( NULL
, "unexpected format in %s", __FUNCTION__
);
258 swrast_delete_renderbuffer(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
)
260 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
264 free(xrb
->Base
.Buffer
);
265 _mesa_delete_renderbuffer(ctx
, rb
);
268 /* see bytes_per_line in libGL */
270 bytes_per_line(unsigned pitch_bits
, unsigned mul
)
272 unsigned mask
= mul
- 1;
274 return ((pitch_bits
+ mask
) & ~mask
) / 8;
278 swrast_alloc_front_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
279 GLenum internalFormat
, GLuint width
, GLuint height
)
281 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
286 (void) internalFormat
;
288 xrb
->Base
.Buffer
= NULL
;
291 xrb
->pitch
= bytes_per_line(width
* xrb
->bpp
, 32);
297 swrast_alloc_back_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
298 GLenum internalFormat
, GLuint width
, GLuint height
)
300 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
304 free(xrb
->Base
.Buffer
);
306 swrast_alloc_front_storage(ctx
, rb
, internalFormat
, width
, height
);
308 xrb
->Base
.Buffer
= malloc(height
* xrb
->pitch
);
313 static struct dri_swrast_renderbuffer
*
314 swrast_new_renderbuffer(const struct gl_config
*visual
, __DRIdrawable
*dPriv
,
317 struct dri_swrast_renderbuffer
*xrb
= calloc(1, sizeof *xrb
);
318 struct gl_renderbuffer
*rb
;
326 rb
= &xrb
->Base
.Base
;
328 _mesa_init_renderbuffer(rb
, 0);
330 pixel_format
= choose_pixel_format(visual
);
333 xrb
->Base
.Base
.Delete
= swrast_delete_renderbuffer
;
335 rb
->AllocStorage
= swrast_alloc_front_storage
;
338 rb
->AllocStorage
= swrast_alloc_back_storage
;
341 switch (pixel_format
) {
343 rb
->Format
= MESA_FORMAT_ARGB8888
;
344 rb
->InternalFormat
= GL_RGBA
;
345 rb
->_BaseFormat
= GL_RGBA
;
349 rb
->Format
= MESA_FORMAT_ARGB8888
; /* XXX */
350 rb
->InternalFormat
= GL_RGB
;
351 rb
->_BaseFormat
= GL_RGB
;
355 rb
->Format
= MESA_FORMAT_RGB565
;
356 rb
->InternalFormat
= GL_RGB
;
357 rb
->_BaseFormat
= GL_RGB
;
361 rb
->Format
= MESA_FORMAT_RGB332
;
362 rb
->InternalFormat
= GL_RGB
;
363 rb
->_BaseFormat
= GL_RGB
;
375 swrast_map_renderbuffer(struct gl_context
*ctx
,
376 struct gl_renderbuffer
*rb
,
377 GLuint x
, GLuint y
, GLuint w
, GLuint h
,
382 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
383 GLubyte
*map
= xrb
->Base
.Buffer
;
384 int cpp
= _mesa_get_format_bytes(rb
->Format
);
385 int stride
= rb
->Width
* cpp
;
387 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
388 __DRIdrawable
*dPriv
= xrb
->dPriv
;
389 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
391 xrb
->map_mode
= mode
;
398 xrb
->Base
.Buffer
= malloc(h
* stride
);
400 sPriv
->swrast_loader
->getImage(dPriv
, x
, y
, w
, h
,
401 (char *) xrb
->Base
.Buffer
,
402 dPriv
->loaderPrivate
);
404 *out_map
= xrb
->Base
.Buffer
;
405 *out_stride
= stride
;
409 ASSERT(xrb
->Base
.Buffer
);
411 if (rb
->AllocStorage
== swrast_alloc_back_storage
) {
412 map
+= (rb
->Height
- 1) * stride
;
416 map
+= (GLsizei
)y
* stride
;
417 map
+= (GLsizei
)x
* cpp
;
420 *out_stride
= stride
;
424 swrast_unmap_renderbuffer(struct gl_context
*ctx
,
425 struct gl_renderbuffer
*rb
)
427 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
429 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
430 __DRIdrawable
*dPriv
= xrb
->dPriv
;
431 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
433 if (xrb
->map_mode
& GL_MAP_WRITE_BIT
) {
434 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_DRAW
,
435 xrb
->map_x
, xrb
->map_y
,
436 xrb
->map_w
, xrb
->map_h
,
437 (char *) xrb
->Base
.Buffer
,
438 dPriv
->loaderPrivate
);
441 free(xrb
->Base
.Buffer
);
442 xrb
->Base
.Buffer
= NULL
;
447 dri_create_buffer(__DRIscreen
* sPriv
,
448 __DRIdrawable
* dPriv
,
449 const struct gl_config
* visual
, GLboolean isPixmap
)
451 struct dri_drawable
*drawable
= NULL
;
452 struct gl_framebuffer
*fb
;
453 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
460 drawable
= CALLOC_STRUCT(dri_drawable
);
461 if (drawable
== NULL
)
464 dPriv
->driverPrivate
= drawable
;
465 drawable
->dPriv
= dPriv
;
467 drawable
->row
= malloc(SWRAST_MAX_WIDTH
* 4);
468 if (drawable
->row
== NULL
)
471 fb
= &drawable
->Base
;
473 /* basic framebuffer setup */
474 _mesa_initialize_window_framebuffer(fb
, visual
);
476 /* add front renderbuffer */
477 frontrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_TRUE
);
478 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &frontrb
->Base
.Base
);
480 /* add back renderbuffer */
481 if (visual
->doubleBufferMode
) {
482 backrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_FALSE
);
483 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &backrb
->Base
.Base
);
486 /* add software renderbuffers */
487 _swrast_add_soft_renderbuffers(fb
,
488 GL_FALSE
, /* color */
489 visual
->haveDepthBuffer
,
490 visual
->haveStencilBuffer
,
491 visual
->haveAccumBuffer
,
492 GL_FALSE
, /* alpha */
493 GL_FALSE
/* aux bufs */);
508 dri_destroy_buffer(__DRIdrawable
* dPriv
)
513 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
514 struct gl_framebuffer
*fb
;
518 fb
= &drawable
->Base
;
520 fb
->DeletePending
= GL_TRUE
;
521 _mesa_reference_framebuffer(&fb
, NULL
);
526 dri_swap_buffers(__DRIdrawable
* dPriv
)
528 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
530 GET_CURRENT_CONTEXT(ctx
);
532 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
533 struct gl_framebuffer
*fb
;
534 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
538 fb
= &drawable
->Base
;
541 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
543 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_BACK_LEFT
].Renderbuffer
);
545 /* check for signle-buffered */
549 /* check if swapping currently bound buffer */
550 if (ctx
&& ctx
->DrawBuffer
== fb
) {
551 /* flush pending rendering */
552 _mesa_notifySwapBuffers(ctx
);
555 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_SWAP
,
557 frontrb
->Base
.Base
.Width
,
558 frontrb
->Base
.Base
.Height
,
559 (char *) backrb
->Base
.Buffer
,
560 dPriv
->loaderPrivate
);
565 * General device driver functions.
569 get_window_size( struct gl_framebuffer
*fb
, GLsizei
*w
, GLsizei
*h
)
571 __DRIdrawable
*dPriv
= swrast_drawable(fb
)->dPriv
;
572 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
575 sPriv
->swrast_loader
->getDrawableInfo(dPriv
,
577 dPriv
->loaderPrivate
);
581 swrast_check_and_update_window_size( struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
583 GLsizei width
, height
;
585 get_window_size(fb
, &width
, &height
);
586 if (fb
->Width
!= width
|| fb
->Height
!= height
) {
587 _mesa_resize_framebuffer(ctx
, fb
, width
, height
);
591 static const GLubyte
*
592 get_string(struct gl_context
*ctx
, GLenum pname
)
597 return (const GLubyte
*) "Mesa Project";
599 return (const GLubyte
*) "Software Rasterizer";
606 update_state( struct gl_context
*ctx
, GLuint new_state
)
608 /* not much to do here - pass it on */
609 _swrast_InvalidateState( ctx
, new_state
);
610 _swsetup_InvalidateState( ctx
, new_state
);
611 _vbo_InvalidateState( ctx
, new_state
);
612 _tnl_InvalidateState( ctx
, new_state
);
616 viewport(struct gl_context
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
618 struct gl_framebuffer
*draw
= ctx
->WinSysDrawBuffer
;
619 struct gl_framebuffer
*read
= ctx
->WinSysReadBuffer
;
625 swrast_check_and_update_window_size(ctx
, draw
);
626 swrast_check_and_update_window_size(ctx
, read
);
629 static gl_format
swrastChooseTextureFormat(struct gl_context
* ctx
,
631 GLint internalFormat
,
635 if (internalFormat
== GL_RGB
)
636 return MESA_FORMAT_XRGB8888
;
637 return _mesa_choose_tex_format(ctx
, target
, internalFormat
, format
, type
);
641 swrast_init_driver_functions(struct dd_function_table
*driver
)
643 driver
->GetString
= get_string
;
644 driver
->UpdateState
= update_state
;
645 driver
->GetBufferSize
= NULL
;
646 driver
->Viewport
= viewport
;
647 driver
->ChooseTextureFormat
= swrastChooseTextureFormat
;
648 driver
->MapRenderbuffer
= swrast_map_renderbuffer
;
649 driver
->UnmapRenderbuffer
= swrast_unmap_renderbuffer
;
652 static const char *es2_extensions
[] = {
653 /* Used by mesa internally (cf all_mesa_extensions in ../common/utils.c) */
654 "GL_EXT_blend_func_separate",
655 "GL_EXT_framebuffer_blit",
656 "GL_MESA_window_pos",
658 /* Required by GLES2 */
659 "GL_ARB_fragment_program",
660 "GL_ARB_fragment_shader",
661 "GL_ARB_shader_objects",
662 "GL_ARB_texture_cube_map",
663 "GL_ARB_texture_non_power_of_two",
664 "GL_ARB_vertex_shader",
665 "GL_EXT_blend_color",
666 "GL_EXT_blend_equation_separate",
667 "GL_EXT_blend_minmax",
670 "GL_ARB_framebuffer_object",
671 "GL_EXT_texture_filter_anisotropic",
672 "GL_ARB_depth_texture",
673 "GL_EXT_packed_depth_stencil",
674 "GL_EXT_framebuffer_object",
679 InitExtensionsES2(struct gl_context
*ctx
)
683 for (i
= 0; es2_extensions
[i
]; i
++)
684 _mesa_enable_extension(ctx
, es2_extensions
[i
]);
688 * Context-related functions.
692 dri_create_context(gl_api api
,
693 const struct gl_config
* visual
,
694 __DRIcontext
* cPriv
,
695 unsigned major_version
,
696 unsigned minor_version
,
699 void *sharedContextPrivate
)
701 struct dri_context
*ctx
= NULL
;
702 struct dri_context
*share
= (struct dri_context
*)sharedContextPrivate
;
703 struct gl_context
*mesaCtx
= NULL
;
704 struct gl_context
*sharedCtx
= NULL
;
705 struct dd_function_table functions
;
709 /* Flag filtering is handled in dri2CreateContextAttribs.
714 case API_OPENGL_COMPAT
:
715 if (major_version
> 2
716 || (major_version
== 2 && minor_version
> 1)) {
717 *error
= __DRI_CTX_ERROR_BAD_VERSION
;
724 case API_OPENGL_CORE
:
725 *error
= __DRI_CTX_ERROR_BAD_API
;
729 ctx
= CALLOC_STRUCT(dri_context
);
731 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
735 cPriv
->driverPrivate
= ctx
;
738 /* build table of device driver functions */
739 _mesa_init_driver_functions(&functions
);
740 swrast_init_driver_functions(&functions
);
743 sharedCtx
= &share
->Base
;
746 mesaCtx
= &ctx
->Base
;
748 /* basic context setup */
749 if (!_mesa_initialize_context(mesaCtx
, api
, visual
, sharedCtx
, &functions
)) {
750 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
754 /* do bounds checking to prevent segfaults and server crashes! */
755 mesaCtx
->Const
.CheckArrayBounds
= GL_TRUE
;
757 /* create module contexts */
758 _swrast_CreateContext( mesaCtx
);
759 _vbo_CreateContext( mesaCtx
);
760 _tnl_CreateContext( mesaCtx
);
761 _swsetup_CreateContext( mesaCtx
);
762 _swsetup_Wakeup( mesaCtx
);
764 /* use default TCL pipeline */
766 TNLcontext
*tnl
= TNL_CONTEXT(mesaCtx
);
767 tnl
->Driver
.RunPipeline
= _tnl_run_pipeline
;
770 _mesa_meta_init(mesaCtx
);
771 _mesa_enable_sw_extensions(mesaCtx
);
774 case API_OPENGL_CORE
:
775 /* XXX fix me, fall-through for now */
776 case API_OPENGL_COMPAT
:
777 _mesa_enable_1_3_extensions(mesaCtx
);
778 _mesa_enable_1_4_extensions(mesaCtx
);
779 _mesa_enable_1_5_extensions(mesaCtx
);
780 _mesa_enable_2_0_extensions(mesaCtx
);
781 _mesa_enable_2_1_extensions(mesaCtx
);
784 _mesa_enable_1_3_extensions(mesaCtx
);
785 _mesa_enable_1_4_extensions(mesaCtx
);
786 _mesa_enable_1_5_extensions(mesaCtx
);
790 InitExtensionsES2( mesaCtx
);
794 _mesa_compute_version(mesaCtx
);
796 _mesa_initialize_dispatch_tables(mesaCtx
);
797 _mesa_initialize_vbo_vtxfmt(mesaCtx
);
799 *error
= __DRI_CTX_ERROR_SUCCESS
;
810 dri_destroy_context(__DRIcontext
* cPriv
)
815 struct dri_context
*ctx
= dri_context(cPriv
);
816 struct gl_context
*mesaCtx
;
818 mesaCtx
= &ctx
->Base
;
820 _mesa_meta_free(mesaCtx
);
821 _swsetup_DestroyContext( mesaCtx
);
822 _swrast_DestroyContext( mesaCtx
);
823 _tnl_DestroyContext( mesaCtx
);
824 _vbo_DestroyContext( mesaCtx
);
825 _mesa_destroy_context( mesaCtx
);
830 dri_make_current(__DRIcontext
* cPriv
,
831 __DRIdrawable
* driDrawPriv
,
832 __DRIdrawable
* driReadPriv
)
834 struct gl_context
*mesaCtx
;
835 struct gl_framebuffer
*mesaDraw
;
836 struct gl_framebuffer
*mesaRead
;
840 struct dri_context
*ctx
= dri_context(cPriv
);
841 struct dri_drawable
*draw
;
842 struct dri_drawable
*read
;
844 if (!driDrawPriv
|| !driReadPriv
)
847 draw
= dri_drawable(driDrawPriv
);
848 read
= dri_drawable(driReadPriv
);
849 mesaCtx
= &ctx
->Base
;
850 mesaDraw
= &draw
->Base
;
851 mesaRead
= &read
->Base
;
853 /* check for same context and buffer */
854 if (mesaCtx
== _mesa_get_current_context()
855 && mesaCtx
->DrawBuffer
== mesaDraw
856 && mesaCtx
->ReadBuffer
== mesaRead
) {
860 _glapi_check_multithread();
862 swrast_check_and_update_window_size(mesaCtx
, mesaDraw
);
863 if (mesaRead
!= mesaDraw
)
864 swrast_check_and_update_window_size(mesaCtx
, mesaRead
);
866 _mesa_make_current( mesaCtx
,
872 _mesa_make_current( NULL
, NULL
, NULL
);
879 dri_unbind_context(__DRIcontext
* cPriv
)
884 /* Unset current context and dispath table */
885 _mesa_make_current(NULL
, NULL
, NULL
);
891 const struct __DriverAPIRec driDriverAPI
= {
892 .InitScreen
= dri_init_screen
,
893 .DestroyScreen
= dri_destroy_screen
,
894 .CreateContext
= dri_create_context
,
895 .DestroyContext
= dri_destroy_context
,
896 .CreateBuffer
= dri_create_buffer
,
897 .DestroyBuffer
= dri_destroy_buffer
,
898 .SwapBuffers
= dri_swap_buffers
,
899 .MakeCurrent
= dri_make_current
,
900 .UnbindContext
= dri_unbind_context
,
903 /* This is the table of extensions that the loader will dlsym() for. */
904 PUBLIC
const __DRIextension
*__driDriverExtensions
[] = {
905 &driCoreExtension
.base
,
906 &driSWRastExtension
.base
,