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 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * DRI software rasterizer
25 * This is the mesa swrast module packaged into a DRI driver structure.
27 * The front-buffer is allocated by the loader. The loader provides read/write
28 * callbacks for access to the front-buffer. The driver uses a scratch row for
29 * front-buffer rendering to avoid repeated calls to the loader.
31 * The back-buffer is allocated by the driver and is private.
34 #include "main/api_exec.h"
35 #include "main/context.h"
36 #include "main/extensions.h"
37 #include "main/formats.h"
38 #include "main/framebuffer.h"
39 #include "main/imports.h"
40 #include "main/renderbuffer.h"
41 #include "main/version.h"
42 #include "main/vtxfmt.h"
43 #include "swrast/swrast.h"
44 #include "swrast/s_renderbuffer.h"
45 #include "swrast_setup/swrast_setup.h"
47 #include "tnl/t_context.h"
48 #include "tnl/t_pipeline.h"
50 #include "drivers/common/driverfuncs.h"
51 #include "drivers/common/meta.h"
54 #include "main/teximage.h"
55 #include "main/texformat.h"
56 #include "main/texstate.h"
58 #include "swrast_priv.h"
59 #include "swrast/s_context.h"
63 * Screen and config-related functions
66 static void swrastSetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
,
67 GLint texture_format
, __DRIdrawable
*dPriv
)
69 struct dri_context
*dri_ctx
;
71 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
72 struct gl_texture_unit
*texUnit
;
73 struct gl_texture_object
*texObj
;
74 struct gl_texture_image
*texImage
;
75 struct swrast_texture_image
*swImage
;
76 uint32_t internalFormat
;
79 dri_ctx
= pDRICtx
->driverPrivate
;
81 internalFormat
= (texture_format
== __DRI_TEXTURE_FORMAT_RGB
? 3 : 4);
83 texUnit
= _mesa_get_current_tex_unit(&dri_ctx
->Base
);
84 texObj
= _mesa_select_tex_object(&dri_ctx
->Base
, texUnit
, target
);
85 texImage
= _mesa_get_tex_image(&dri_ctx
->Base
, texObj
, target
, 0);
86 swImage
= swrast_texture_image(texImage
);
88 _mesa_lock_texture(&dri_ctx
->Base
, texObj
);
90 sPriv
->swrast_loader
->getDrawableInfo(dPriv
, &x
, &y
, &w
, &h
, dPriv
->loaderPrivate
);
92 if (texture_format
== __DRI_TEXTURE_FORMAT_RGB
)
93 texFormat
= MESA_FORMAT_XRGB8888
;
95 texFormat
= MESA_FORMAT_ARGB8888
;
97 _mesa_init_teximage_fields(&dri_ctx
->Base
, texImage
,
98 w
, h
, 1, 0, internalFormat
, texFormat
);
100 sPriv
->swrast_loader
->getImage(dPriv
, x
, y
, w
, h
, (char *)swImage
->Buffer
,
101 dPriv
->loaderPrivate
);
103 _mesa_unlock_texture(&dri_ctx
->Base
, texObj
);
106 static void swrastSetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
,
107 __DRIdrawable
*dPriv
)
109 swrastSetTexBuffer2(pDRICtx
, target
, __DRI_TEXTURE_FORMAT_RGBA
, dPriv
);
112 static const __DRItexBufferExtension swrastTexBufferExtension
= {
113 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
118 static const __DRIextension
*dri_screen_extensions
[] = {
119 &swrastTexBufferExtension
.base
,
123 static __DRIconfig
**
124 swrastFillInModes(__DRIscreen
*psp
,
125 unsigned pixel_bits
, unsigned depth_bits
,
126 unsigned stencil_bits
, GLboolean have_back_buffer
)
128 __DRIconfig
**configs
;
129 unsigned depth_buffer_factor
;
130 unsigned back_buffer_factor
;
133 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
134 * support pageflipping at all.
136 static const GLenum back_buffer_modes
[] = {
137 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
140 uint8_t depth_bits_array
[4];
141 uint8_t stencil_bits_array
[4];
142 uint8_t msaa_samples_array
[1];
145 (void) have_back_buffer
;
147 depth_bits_array
[0] = 0;
148 depth_bits_array
[1] = 0;
149 depth_bits_array
[2] = depth_bits
;
150 depth_bits_array
[3] = depth_bits
;
152 /* Just like with the accumulation buffer, always provide some modes
153 * with a stencil buffer.
155 stencil_bits_array
[0] = 0;
156 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
157 stencil_bits_array
[2] = 0;
158 stencil_bits_array
[3] = (stencil_bits
== 0) ? 8 : stencil_bits
;
160 msaa_samples_array
[0] = 0;
162 depth_buffer_factor
= 4;
163 back_buffer_factor
= 2;
165 switch (pixel_bits
) {
167 format
= MESA_FORMAT_RGB565
;
170 format
= MESA_FORMAT_XRGB8888
;
173 format
= MESA_FORMAT_ARGB8888
;
176 fprintf(stderr
, "[%s:%u] bad depth %d\n", __func__
, __LINE__
,
181 configs
= driCreateConfigs(format
,
182 depth_bits_array
, stencil_bits_array
,
183 depth_buffer_factor
, back_buffer_modes
,
184 back_buffer_factor
, msaa_samples_array
, 1,
186 if (configs
== NULL
) {
187 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
195 static const __DRIconfig
**
196 dri_init_screen(__DRIscreen
* psp
)
198 __DRIconfig
**configs16
, **configs24
, **configs32
;
202 psp
->extensions
= dri_screen_extensions
;
204 configs16
= swrastFillInModes(psp
, 16, 16, 0, 1);
205 configs24
= swrastFillInModes(psp
, 24, 24, 8, 1);
206 configs32
= swrastFillInModes(psp
, 32, 24, 8, 1);
208 configs24
= driConcatConfigs(configs16
, configs24
);
209 configs32
= driConcatConfigs(configs24
, configs32
);
211 return (const __DRIconfig
**)configs32
;
215 dri_destroy_screen(__DRIscreen
* sPriv
)
223 * Framebuffer and renderbuffer-related functions.
227 choose_pixel_format(const struct gl_config
*v
)
229 int depth
= v
->rgbBits
;
232 && v
->redMask
== 0xff0000
233 && v
->greenMask
== 0x00ff00
234 && v
->blueMask
== 0x0000ff)
237 && v
->redMask
== 0xff0000
238 && v
->greenMask
== 0x00ff00
239 && v
->blueMask
== 0x0000ff)
242 && v
->redMask
== 0xf800
243 && v
->greenMask
== 0x07e0
244 && v
->blueMask
== 0x001f)
247 && v
->redMask
== 0x07
248 && v
->greenMask
== 0x38
249 && v
->blueMask
== 0xc0)
252 _mesa_problem( NULL
, "unexpected format in %s", __FUNCTION__
);
257 swrast_delete_renderbuffer(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
)
259 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
263 free(xrb
->Base
.Buffer
);
264 _mesa_delete_renderbuffer(ctx
, rb
);
267 /* see bytes_per_line in libGL */
269 bytes_per_line(unsigned pitch_bits
, unsigned mul
)
271 unsigned mask
= mul
- 1;
273 return ((pitch_bits
+ mask
) & ~mask
) / 8;
277 swrast_alloc_front_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
278 GLenum internalFormat
, GLuint width
, GLuint height
)
280 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
285 (void) internalFormat
;
287 xrb
->Base
.Buffer
= NULL
;
290 xrb
->pitch
= bytes_per_line(width
* xrb
->bpp
, 32);
296 swrast_alloc_back_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
297 GLenum internalFormat
, GLuint width
, GLuint height
)
299 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
303 free(xrb
->Base
.Buffer
);
305 swrast_alloc_front_storage(ctx
, rb
, internalFormat
, width
, height
);
307 xrb
->Base
.Buffer
= malloc(height
* xrb
->pitch
);
312 static struct dri_swrast_renderbuffer
*
313 swrast_new_renderbuffer(const struct gl_config
*visual
, __DRIdrawable
*dPriv
,
316 struct dri_swrast_renderbuffer
*xrb
= calloc(1, sizeof *xrb
);
317 struct gl_renderbuffer
*rb
;
325 rb
= &xrb
->Base
.Base
;
327 _mesa_init_renderbuffer(rb
, 0);
329 pixel_format
= choose_pixel_format(visual
);
332 xrb
->Base
.Base
.Delete
= swrast_delete_renderbuffer
;
334 rb
->AllocStorage
= swrast_alloc_front_storage
;
337 rb
->AllocStorage
= swrast_alloc_back_storage
;
340 switch (pixel_format
) {
342 rb
->Format
= MESA_FORMAT_ARGB8888
;
343 rb
->InternalFormat
= GL_RGBA
;
344 rb
->_BaseFormat
= GL_RGBA
;
348 rb
->Format
= MESA_FORMAT_ARGB8888
; /* XXX */
349 rb
->InternalFormat
= GL_RGB
;
350 rb
->_BaseFormat
= GL_RGB
;
354 rb
->Format
= MESA_FORMAT_RGB565
;
355 rb
->InternalFormat
= GL_RGB
;
356 rb
->_BaseFormat
= GL_RGB
;
360 rb
->Format
= MESA_FORMAT_RGB332
;
361 rb
->InternalFormat
= GL_RGB
;
362 rb
->_BaseFormat
= GL_RGB
;
374 swrast_map_renderbuffer(struct gl_context
*ctx
,
375 struct gl_renderbuffer
*rb
,
376 GLuint x
, GLuint y
, GLuint w
, GLuint h
,
381 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
382 GLubyte
*map
= xrb
->Base
.Buffer
;
383 int cpp
= _mesa_get_format_bytes(rb
->Format
);
384 int stride
= rb
->Width
* cpp
;
386 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
387 __DRIdrawable
*dPriv
= xrb
->dPriv
;
388 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
390 xrb
->map_mode
= mode
;
397 xrb
->Base
.Buffer
= malloc(h
* stride
);
399 sPriv
->swrast_loader
->getImage(dPriv
, x
, y
, w
, h
,
400 (char *) xrb
->Base
.Buffer
,
401 dPriv
->loaderPrivate
);
403 *out_map
= xrb
->Base
.Buffer
;
404 *out_stride
= stride
;
408 ASSERT(xrb
->Base
.Buffer
);
410 if (rb
->AllocStorage
== swrast_alloc_back_storage
) {
411 map
+= (rb
->Height
- 1) * stride
;
415 map
+= (GLsizei
)y
* stride
;
416 map
+= (GLsizei
)x
* cpp
;
419 *out_stride
= stride
;
423 swrast_unmap_renderbuffer(struct gl_context
*ctx
,
424 struct gl_renderbuffer
*rb
)
426 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
428 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
429 __DRIdrawable
*dPriv
= xrb
->dPriv
;
430 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
432 if (xrb
->map_mode
& GL_MAP_WRITE_BIT
) {
433 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_DRAW
,
434 xrb
->map_x
, xrb
->map_y
,
435 xrb
->map_w
, xrb
->map_h
,
436 (char *) xrb
->Base
.Buffer
,
437 dPriv
->loaderPrivate
);
440 free(xrb
->Base
.Buffer
);
441 xrb
->Base
.Buffer
= NULL
;
446 dri_create_buffer(__DRIscreen
* sPriv
,
447 __DRIdrawable
* dPriv
,
448 const struct gl_config
* visual
, GLboolean isPixmap
)
450 struct dri_drawable
*drawable
= NULL
;
451 struct gl_framebuffer
*fb
;
452 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
459 drawable
= CALLOC_STRUCT(dri_drawable
);
460 if (drawable
== NULL
)
463 dPriv
->driverPrivate
= drawable
;
464 drawable
->dPriv
= dPriv
;
466 drawable
->row
= malloc(SWRAST_MAX_WIDTH
* 4);
467 if (drawable
->row
== NULL
)
470 fb
= &drawable
->Base
;
472 /* basic framebuffer setup */
473 _mesa_initialize_window_framebuffer(fb
, visual
);
475 /* add front renderbuffer */
476 frontrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_TRUE
);
477 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &frontrb
->Base
.Base
);
479 /* add back renderbuffer */
480 if (visual
->doubleBufferMode
) {
481 backrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_FALSE
);
482 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &backrb
->Base
.Base
);
485 /* add software renderbuffers */
486 _swrast_add_soft_renderbuffers(fb
,
487 GL_FALSE
, /* color */
488 visual
->haveDepthBuffer
,
489 visual
->haveStencilBuffer
,
490 visual
->haveAccumBuffer
,
491 GL_FALSE
, /* alpha */
492 GL_FALSE
/* aux bufs */);
507 dri_destroy_buffer(__DRIdrawable
* dPriv
)
512 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
513 struct gl_framebuffer
*fb
;
517 fb
= &drawable
->Base
;
519 fb
->DeletePending
= GL_TRUE
;
520 _mesa_reference_framebuffer(&fb
, NULL
);
525 dri_swap_buffers(__DRIdrawable
* dPriv
)
527 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
529 GET_CURRENT_CONTEXT(ctx
);
531 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
532 struct gl_framebuffer
*fb
;
533 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
537 fb
= &drawable
->Base
;
540 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
542 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_BACK_LEFT
].Renderbuffer
);
544 /* check for signle-buffered */
548 /* check if swapping currently bound buffer */
549 if (ctx
&& ctx
->DrawBuffer
== fb
) {
550 /* flush pending rendering */
551 _mesa_notifySwapBuffers(ctx
);
554 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_SWAP
,
556 frontrb
->Base
.Base
.Width
,
557 frontrb
->Base
.Base
.Height
,
558 (char *) backrb
->Base
.Buffer
,
559 dPriv
->loaderPrivate
);
564 * General device driver functions.
568 get_window_size( struct gl_framebuffer
*fb
, GLsizei
*w
, GLsizei
*h
)
570 __DRIdrawable
*dPriv
= swrast_drawable(fb
)->dPriv
;
571 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
574 sPriv
->swrast_loader
->getDrawableInfo(dPriv
,
576 dPriv
->loaderPrivate
);
580 swrast_check_and_update_window_size( struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
582 GLsizei width
, height
;
584 get_window_size(fb
, &width
, &height
);
585 if (fb
->Width
!= width
|| fb
->Height
!= height
) {
586 _mesa_resize_framebuffer(ctx
, fb
, width
, height
);
590 static const GLubyte
*
591 get_string(struct gl_context
*ctx
, GLenum pname
)
596 return (const GLubyte
*) "Mesa Project";
598 return (const GLubyte
*) "Software Rasterizer";
605 update_state( struct gl_context
*ctx
, GLuint new_state
)
607 /* not much to do here - pass it on */
608 _swrast_InvalidateState( ctx
, new_state
);
609 _swsetup_InvalidateState( ctx
, new_state
);
610 _vbo_InvalidateState( ctx
, new_state
);
611 _tnl_InvalidateState( ctx
, new_state
);
615 viewport(struct gl_context
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
617 struct gl_framebuffer
*draw
= ctx
->WinSysDrawBuffer
;
618 struct gl_framebuffer
*read
= ctx
->WinSysReadBuffer
;
624 swrast_check_and_update_window_size(ctx
, draw
);
625 swrast_check_and_update_window_size(ctx
, read
);
628 static gl_format
swrastChooseTextureFormat(struct gl_context
* ctx
,
630 GLint internalFormat
,
634 if (internalFormat
== GL_RGB
)
635 return MESA_FORMAT_XRGB8888
;
636 return _mesa_choose_tex_format(ctx
, target
, internalFormat
, format
, type
);
640 swrast_init_driver_functions(struct dd_function_table
*driver
)
642 driver
->GetString
= get_string
;
643 driver
->UpdateState
= update_state
;
644 driver
->GetBufferSize
= NULL
;
645 driver
->Viewport
= viewport
;
646 driver
->ChooseTextureFormat
= swrastChooseTextureFormat
;
647 driver
->MapRenderbuffer
= swrast_map_renderbuffer
;
648 driver
->UnmapRenderbuffer
= swrast_unmap_renderbuffer
;
651 static const char *es2_extensions
[] = {
652 /* Used by mesa internally (cf all_mesa_extensions in ../common/utils.c) */
653 "GL_EXT_blend_func_separate",
654 "GL_EXT_framebuffer_blit",
655 "GL_MESA_window_pos",
657 /* Required by GLES2 */
658 "GL_ARB_fragment_program",
659 "GL_ARB_fragment_shader",
660 "GL_ARB_shader_objects",
661 "GL_ARB_texture_cube_map",
662 "GL_ARB_texture_non_power_of_two",
663 "GL_ARB_vertex_shader",
664 "GL_EXT_blend_color",
665 "GL_EXT_blend_equation_separate",
666 "GL_EXT_blend_minmax",
669 "GL_ARB_framebuffer_object",
670 "GL_EXT_texture_filter_anisotropic",
671 "GL_ARB_depth_texture",
672 "GL_EXT_packed_depth_stencil",
673 "GL_EXT_framebuffer_object",
678 InitExtensionsES2(struct gl_context
*ctx
)
682 for (i
= 0; es2_extensions
[i
]; i
++)
683 _mesa_enable_extension(ctx
, es2_extensions
[i
]);
687 * Context-related functions.
691 dri_create_context(gl_api api
,
692 const struct gl_config
* visual
,
693 __DRIcontext
* cPriv
,
694 unsigned major_version
,
695 unsigned minor_version
,
698 void *sharedContextPrivate
)
700 struct dri_context
*ctx
= NULL
;
701 struct dri_context
*share
= (struct dri_context
*)sharedContextPrivate
;
702 struct gl_context
*mesaCtx
= NULL
;
703 struct gl_context
*sharedCtx
= NULL
;
704 struct dd_function_table functions
;
708 /* Flag filtering is handled in dri2CreateContextAttribs.
713 case API_OPENGL_COMPAT
:
714 if (major_version
> 2
715 || (major_version
== 2 && minor_version
> 1)) {
716 *error
= __DRI_CTX_ERROR_BAD_VERSION
;
723 case API_OPENGL_CORE
:
724 *error
= __DRI_CTX_ERROR_BAD_API
;
728 ctx
= CALLOC_STRUCT(dri_context
);
730 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
734 cPriv
->driverPrivate
= ctx
;
737 /* build table of device driver functions */
738 _mesa_init_driver_functions(&functions
);
739 swrast_init_driver_functions(&functions
);
742 sharedCtx
= &share
->Base
;
745 mesaCtx
= &ctx
->Base
;
747 /* basic context setup */
748 if (!_mesa_initialize_context(mesaCtx
, api
, visual
, sharedCtx
, &functions
)) {
749 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
753 /* do bounds checking to prevent segfaults and server crashes! */
754 mesaCtx
->Const
.CheckArrayBounds
= GL_TRUE
;
756 /* create module contexts */
757 _swrast_CreateContext( mesaCtx
);
758 _vbo_CreateContext( mesaCtx
);
759 _tnl_CreateContext( mesaCtx
);
760 _swsetup_CreateContext( mesaCtx
);
761 _swsetup_Wakeup( mesaCtx
);
763 /* use default TCL pipeline */
765 TNLcontext
*tnl
= TNL_CONTEXT(mesaCtx
);
766 tnl
->Driver
.RunPipeline
= _tnl_run_pipeline
;
769 _mesa_meta_init(mesaCtx
);
770 _mesa_enable_sw_extensions(mesaCtx
);
773 case API_OPENGL_CORE
:
774 /* XXX fix me, fall-through for now */
775 case API_OPENGL_COMPAT
:
776 _mesa_enable_1_3_extensions(mesaCtx
);
777 _mesa_enable_1_4_extensions(mesaCtx
);
778 _mesa_enable_1_5_extensions(mesaCtx
);
779 _mesa_enable_2_0_extensions(mesaCtx
);
780 _mesa_enable_2_1_extensions(mesaCtx
);
783 _mesa_enable_1_3_extensions(mesaCtx
);
784 _mesa_enable_1_4_extensions(mesaCtx
);
785 _mesa_enable_1_5_extensions(mesaCtx
);
789 InitExtensionsES2( mesaCtx
);
793 _mesa_compute_version(mesaCtx
);
795 _mesa_initialize_dispatch_tables(mesaCtx
);
796 _mesa_initialize_vbo_vtxfmt(mesaCtx
);
798 *error
= __DRI_CTX_ERROR_SUCCESS
;
809 dri_destroy_context(__DRIcontext
* cPriv
)
814 struct dri_context
*ctx
= dri_context(cPriv
);
815 struct gl_context
*mesaCtx
;
817 mesaCtx
= &ctx
->Base
;
819 _mesa_meta_free(mesaCtx
);
820 _swsetup_DestroyContext( mesaCtx
);
821 _swrast_DestroyContext( mesaCtx
);
822 _tnl_DestroyContext( mesaCtx
);
823 _vbo_DestroyContext( mesaCtx
);
824 _mesa_destroy_context( mesaCtx
);
829 dri_make_current(__DRIcontext
* cPriv
,
830 __DRIdrawable
* driDrawPriv
,
831 __DRIdrawable
* driReadPriv
)
833 struct gl_context
*mesaCtx
;
834 struct gl_framebuffer
*mesaDraw
;
835 struct gl_framebuffer
*mesaRead
;
839 struct dri_context
*ctx
= dri_context(cPriv
);
840 struct dri_drawable
*draw
;
841 struct dri_drawable
*read
;
843 if (!driDrawPriv
|| !driReadPriv
)
846 draw
= dri_drawable(driDrawPriv
);
847 read
= dri_drawable(driReadPriv
);
848 mesaCtx
= &ctx
->Base
;
849 mesaDraw
= &draw
->Base
;
850 mesaRead
= &read
->Base
;
852 /* check for same context and buffer */
853 if (mesaCtx
== _mesa_get_current_context()
854 && mesaCtx
->DrawBuffer
== mesaDraw
855 && mesaCtx
->ReadBuffer
== mesaRead
) {
859 _glapi_check_multithread();
861 swrast_check_and_update_window_size(mesaCtx
, mesaDraw
);
862 if (mesaRead
!= mesaDraw
)
863 swrast_check_and_update_window_size(mesaCtx
, mesaRead
);
865 _mesa_make_current( mesaCtx
,
871 _mesa_make_current( NULL
, NULL
, NULL
);
878 dri_unbind_context(__DRIcontext
* cPriv
)
883 /* Unset current context and dispath table */
884 _mesa_make_current(NULL
, NULL
, NULL
);
890 const struct __DriverAPIRec driDriverAPI
= {
891 .InitScreen
= dri_init_screen
,
892 .DestroyScreen
= dri_destroy_screen
,
893 .CreateContext
= dri_create_context
,
894 .DestroyContext
= dri_destroy_context
,
895 .CreateBuffer
= dri_create_buffer
,
896 .DestroyBuffer
= dri_destroy_buffer
,
897 .SwapBuffers
= dri_swap_buffers
,
898 .MakeCurrent
= dri_make_current
,
899 .UnbindContext
= dri_unbind_context
,
902 /* This is the table of extensions that the loader will dlsym() for. */
903 PUBLIC
const __DRIextension
*__driDriverExtensions
[] = {
904 &driCoreExtension
.base
,
905 &driSWRastExtension
.base
,