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/context.h"
35 #include "main/extensions.h"
36 #include "main/formats.h"
37 #include "main/framebuffer.h"
38 #include "main/imports.h"
39 #include "main/renderbuffer.h"
40 #include "swrast/swrast.h"
41 #include "swrast/s_renderbuffer.h"
42 #include "swrast_setup/swrast_setup.h"
44 #include "tnl/t_context.h"
45 #include "tnl/t_pipeline.h"
47 #include "drivers/common/driverfuncs.h"
48 #include "drivers/common/meta.h"
51 #include "main/teximage.h"
52 #include "main/texformat.h"
53 #include "main/texstate.h"
55 #include "swrast_priv.h"
56 #include "swrast/s_context.h"
60 * Screen and config-related functions
63 static void swrastSetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
,
64 GLint texture_format
, __DRIdrawable
*dPriv
)
66 struct dri_context
*dri_ctx
;
68 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
69 struct gl_texture_unit
*texUnit
;
70 struct gl_texture_object
*texObj
;
71 struct gl_texture_image
*texImage
;
72 struct swrast_texture_image
*swImage
;
73 uint32_t internalFormat
;
76 dri_ctx
= pDRICtx
->driverPrivate
;
78 internalFormat
= (texture_format
== __DRI_TEXTURE_FORMAT_RGB
? 3 : 4);
80 texUnit
= _mesa_get_current_tex_unit(&dri_ctx
->Base
);
81 texObj
= _mesa_select_tex_object(&dri_ctx
->Base
, texUnit
, target
);
82 texImage
= _mesa_get_tex_image(&dri_ctx
->Base
, texObj
, target
, 0);
83 swImage
= swrast_texture_image(texImage
);
85 _mesa_lock_texture(&dri_ctx
->Base
, texObj
);
87 sPriv
->swrast_loader
->getDrawableInfo(dPriv
, &x
, &y
, &w
, &h
, dPriv
->loaderPrivate
);
89 if (texture_format
== __DRI_TEXTURE_FORMAT_RGB
)
90 texFormat
= MESA_FORMAT_XRGB8888
;
92 texFormat
= MESA_FORMAT_ARGB8888
;
94 _mesa_init_teximage_fields(&dri_ctx
->Base
, texImage
,
95 w
, h
, 1, 0, internalFormat
, texFormat
);
97 sPriv
->swrast_loader
->getImage(dPriv
, x
, y
, w
, h
, (char *)swImage
->Buffer
,
98 dPriv
->loaderPrivate
);
100 _mesa_unlock_texture(&dri_ctx
->Base
, texObj
);
103 static void swrastSetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
,
104 __DRIdrawable
*dPriv
)
106 swrastSetTexBuffer2(pDRICtx
, target
, __DRI_TEXTURE_FORMAT_RGBA
, dPriv
);
109 static const __DRItexBufferExtension swrastTexBufferExtension
= {
110 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
115 static const __DRIextension
*dri_screen_extensions
[] = {
116 &swrastTexBufferExtension
.base
,
120 static __DRIconfig
**
121 swrastFillInModes(__DRIscreen
*psp
,
122 unsigned pixel_bits
, unsigned depth_bits
,
123 unsigned stencil_bits
, GLboolean have_back_buffer
)
125 __DRIconfig
**configs
;
126 unsigned depth_buffer_factor
;
127 unsigned back_buffer_factor
;
131 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
132 * support pageflipping at all.
134 static const GLenum back_buffer_modes
[] = {
135 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
138 uint8_t depth_bits_array
[4];
139 uint8_t stencil_bits_array
[4];
140 uint8_t msaa_samples_array
[1];
143 (void) have_back_buffer
;
145 depth_bits_array
[0] = 0;
146 depth_bits_array
[1] = 0;
147 depth_bits_array
[2] = depth_bits
;
148 depth_bits_array
[3] = depth_bits
;
150 /* Just like with the accumulation buffer, always provide some modes
151 * with a stencil buffer.
153 stencil_bits_array
[0] = 0;
154 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
155 stencil_bits_array
[2] = 0;
156 stencil_bits_array
[3] = (stencil_bits
== 0) ? 8 : stencil_bits
;
158 msaa_samples_array
[0] = 0;
160 depth_buffer_factor
= 4;
161 back_buffer_factor
= 2;
163 switch (pixel_bits
) {
166 fb_type
= GL_UNSIGNED_SHORT_5_6_5
;
170 fb_type
= GL_UNSIGNED_INT_8_8_8_8_REV
;
174 fb_type
= GL_UNSIGNED_INT_8_8_8_8_REV
;
177 fprintf(stderr
, "[%s:%u] bad depth %d\n", __func__
, __LINE__
,
182 configs
= driCreateConfigs(fb_format
, fb_type
,
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
**configs8
, **configs16
, **configs24
, **configs32
;
203 psp
->extensions
= dri_screen_extensions
;
205 configs8
= swrastFillInModes(psp
, 8, 8, 0, 1);
206 configs16
= swrastFillInModes(psp
, 16, 16, 0, 1);
207 configs24
= swrastFillInModes(psp
, 24, 24, 8, 1);
208 configs32
= swrastFillInModes(psp
, 32, 24, 8, 1);
210 configs16
= driConcatConfigs(configs8
, configs16
);
211 configs24
= driConcatConfigs(configs16
, configs24
);
212 configs32
= driConcatConfigs(configs24
, configs32
);
214 return (const __DRIconfig
**)configs32
;
218 dri_destroy_screen(__DRIscreen
* sPriv
)
226 * Framebuffer and renderbuffer-related functions.
230 choose_pixel_format(const struct gl_config
*v
)
232 int depth
= v
->rgbBits
;
235 && v
->redMask
== 0xff0000
236 && v
->greenMask
== 0x00ff00
237 && v
->blueMask
== 0x0000ff)
240 && v
->redMask
== 0xff0000
241 && v
->greenMask
== 0x00ff00
242 && v
->blueMask
== 0x0000ff)
245 && v
->redMask
== 0xf800
246 && v
->greenMask
== 0x07e0
247 && v
->blueMask
== 0x001f)
250 && v
->redMask
== 0x07
251 && v
->greenMask
== 0x38
252 && v
->blueMask
== 0xc0)
255 _mesa_problem( NULL
, "unexpected format in %s", __FUNCTION__
);
260 swrast_delete_renderbuffer(struct gl_renderbuffer
*rb
)
262 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
266 free(xrb
->Base
.Buffer
);
267 _mesa_delete_renderbuffer(rb
);
270 /* see bytes_per_line in libGL */
272 bytes_per_line(unsigned pitch_bits
, unsigned mul
)
274 unsigned mask
= mul
- 1;
276 return ((pitch_bits
+ mask
) & ~mask
) / 8;
280 swrast_alloc_front_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
281 GLenum internalFormat
, GLuint width
, GLuint height
)
283 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
288 (void) internalFormat
;
290 xrb
->Base
.Buffer
= NULL
;
293 xrb
->pitch
= bytes_per_line(width
* xrb
->bpp
, 32);
299 swrast_alloc_back_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
300 GLenum internalFormat
, GLuint width
, GLuint height
)
302 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
306 free(xrb
->Base
.Buffer
);
308 swrast_alloc_front_storage(ctx
, rb
, internalFormat
, width
, height
);
310 xrb
->Base
.Buffer
= malloc(height
* xrb
->pitch
);
315 static struct dri_swrast_renderbuffer
*
316 swrast_new_renderbuffer(const struct gl_config
*visual
, __DRIdrawable
*dPriv
,
319 struct dri_swrast_renderbuffer
*xrb
= calloc(1, sizeof *xrb
);
320 struct gl_renderbuffer
*rb
;
328 rb
= &xrb
->Base
.Base
;
330 _mesa_init_renderbuffer(rb
, 0);
332 pixel_format
= choose_pixel_format(visual
);
335 xrb
->Base
.Base
.Delete
= swrast_delete_renderbuffer
;
337 rb
->AllocStorage
= swrast_alloc_front_storage
;
340 rb
->AllocStorage
= swrast_alloc_back_storage
;
343 switch (pixel_format
) {
345 rb
->Format
= MESA_FORMAT_ARGB8888
;
346 rb
->InternalFormat
= GL_RGBA
;
347 rb
->_BaseFormat
= GL_RGBA
;
351 rb
->Format
= MESA_FORMAT_ARGB8888
; /* XXX */
352 rb
->InternalFormat
= GL_RGB
;
353 rb
->_BaseFormat
= GL_RGB
;
357 rb
->Format
= MESA_FORMAT_RGB565
;
358 rb
->InternalFormat
= GL_RGB
;
359 rb
->_BaseFormat
= GL_RGB
;
363 rb
->Format
= MESA_FORMAT_RGB332
;
364 rb
->InternalFormat
= GL_RGB
;
365 rb
->_BaseFormat
= GL_RGB
;
376 swrast_map_renderbuffer(struct gl_context
*ctx
,
377 struct gl_renderbuffer
*rb
,
378 GLuint x
, GLuint y
, GLuint w
, GLuint h
,
383 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
384 GLubyte
*map
= xrb
->Base
.Buffer
;
385 int cpp
= _mesa_get_format_bytes(rb
->Format
);
386 int stride
= rb
->Width
* cpp
;
388 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
389 __DRIdrawable
*dPriv
= xrb
->dPriv
;
390 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
392 xrb
->map_mode
= mode
;
399 xrb
->Base
.Buffer
= malloc(h
* stride
);
401 sPriv
->swrast_loader
->getImage(dPriv
, x
, y
, w
, h
,
402 (char *) xrb
->Base
.Buffer
,
403 dPriv
->loaderPrivate
);
405 *out_map
= xrb
->Base
.Buffer
;
406 *out_stride
= stride
;
410 ASSERT(xrb
->Base
.Buffer
);
412 if (rb
->AllocStorage
== swrast_alloc_back_storage
) {
413 map
+= (rb
->Height
- 1) * stride
;
417 map
+= (GLsizei
)y
* stride
;
418 map
+= (GLsizei
)x
* cpp
;
421 *out_stride
= stride
;
425 swrast_unmap_renderbuffer(struct gl_context
*ctx
,
426 struct gl_renderbuffer
*rb
)
428 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
430 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
431 __DRIdrawable
*dPriv
= xrb
->dPriv
;
432 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
434 if (xrb
->map_mode
& GL_MAP_WRITE_BIT
) {
435 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_DRAW
,
436 xrb
->map_x
, xrb
->map_y
,
437 xrb
->map_w
, xrb
->map_h
,
438 (char *) xrb
->Base
.Buffer
,
439 dPriv
->loaderPrivate
);
442 free(xrb
->Base
.Buffer
);
443 xrb
->Base
.Buffer
= NULL
;
448 dri_create_buffer(__DRIscreen
* sPriv
,
449 __DRIdrawable
* dPriv
,
450 const struct gl_config
* visual
, GLboolean isPixmap
)
452 struct dri_drawable
*drawable
= NULL
;
453 struct gl_framebuffer
*fb
;
454 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
461 drawable
= CALLOC_STRUCT(dri_drawable
);
462 if (drawable
== NULL
)
465 dPriv
->driverPrivate
= drawable
;
466 drawable
->dPriv
= dPriv
;
468 drawable
->row
= malloc(SWRAST_MAX_WIDTH
* 4);
469 if (drawable
->row
== NULL
)
472 fb
= &drawable
->Base
;
474 /* basic framebuffer setup */
475 _mesa_initialize_window_framebuffer(fb
, visual
);
477 /* add front renderbuffer */
478 frontrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_TRUE
);
479 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &frontrb
->Base
.Base
);
481 /* add back renderbuffer */
482 if (visual
->doubleBufferMode
) {
483 backrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_FALSE
);
484 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &backrb
->Base
.Base
);
487 /* add software renderbuffers */
488 _swrast_add_soft_renderbuffers(fb
,
489 GL_FALSE
, /* color */
490 visual
->haveDepthBuffer
,
491 visual
->haveStencilBuffer
,
492 visual
->haveAccumBuffer
,
493 GL_FALSE
, /* alpha */
494 GL_FALSE
/* aux bufs */);
509 dri_destroy_buffer(__DRIdrawable
* dPriv
)
514 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
515 struct gl_framebuffer
*fb
;
519 fb
= &drawable
->Base
;
521 fb
->DeletePending
= GL_TRUE
;
522 _mesa_reference_framebuffer(&fb
, NULL
);
527 dri_swap_buffers(__DRIdrawable
* dPriv
)
529 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
531 GET_CURRENT_CONTEXT(ctx
);
533 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
534 struct gl_framebuffer
*fb
;
535 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
539 fb
= &drawable
->Base
;
542 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
544 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_BACK_LEFT
].Renderbuffer
);
546 /* check for signle-buffered */
550 /* check if swapping currently bound buffer */
551 if (ctx
&& ctx
->DrawBuffer
== fb
) {
552 /* flush pending rendering */
553 _mesa_notifySwapBuffers(ctx
);
556 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_SWAP
,
558 frontrb
->Base
.Base
.Width
,
559 frontrb
->Base
.Base
.Height
,
560 (char *) backrb
->Base
.Buffer
,
561 dPriv
->loaderPrivate
);
566 * General device driver functions.
570 get_window_size( struct gl_framebuffer
*fb
, GLsizei
*w
, GLsizei
*h
)
572 __DRIdrawable
*dPriv
= swrast_drawable(fb
)->dPriv
;
573 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
576 sPriv
->swrast_loader
->getDrawableInfo(dPriv
,
578 dPriv
->loaderPrivate
);
582 swrast_check_and_update_window_size( struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
584 GLsizei width
, height
;
586 get_window_size(fb
, &width
, &height
);
587 if (fb
->Width
!= width
|| fb
->Height
!= height
) {
588 _mesa_resize_framebuffer(ctx
, fb
, width
, height
);
592 static const GLubyte
*
593 get_string(struct gl_context
*ctx
, GLenum pname
)
598 return (const GLubyte
*) "Mesa Project";
600 return (const GLubyte
*) "Software Rasterizer";
607 update_state( struct gl_context
*ctx
, GLuint new_state
)
609 /* not much to do here - pass it on */
610 _swrast_InvalidateState( ctx
, new_state
);
611 _swsetup_InvalidateState( ctx
, new_state
);
612 _vbo_InvalidateState( ctx
, new_state
);
613 _tnl_InvalidateState( ctx
, new_state
);
617 viewport(struct gl_context
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
619 struct gl_framebuffer
*draw
= ctx
->WinSysDrawBuffer
;
620 struct gl_framebuffer
*read
= ctx
->WinSysReadBuffer
;
626 swrast_check_and_update_window_size(ctx
, draw
);
627 swrast_check_and_update_window_size(ctx
, read
);
630 static gl_format
swrastChooseTextureFormat(struct gl_context
* ctx
,
632 GLint internalFormat
,
636 if (internalFormat
== GL_RGB
)
637 return MESA_FORMAT_XRGB8888
;
638 return _mesa_choose_tex_format(ctx
, target
, internalFormat
, format
, type
);
642 swrast_init_driver_functions(struct dd_function_table
*driver
)
644 driver
->GetString
= get_string
;
645 driver
->UpdateState
= update_state
;
646 driver
->GetBufferSize
= NULL
;
647 driver
->Viewport
= viewport
;
648 driver
->ChooseTextureFormat
= swrastChooseTextureFormat
;
649 driver
->MapRenderbuffer
= swrast_map_renderbuffer
;
650 driver
->UnmapRenderbuffer
= swrast_unmap_renderbuffer
;
653 static const char *es2_extensions
[] = {
654 /* Used by mesa internally (cf all_mesa_extensions in ../common/utils.c) */
655 "GL_ARB_transpose_matrix",
657 "GL_EXT_blend_func_separate",
658 "GL_EXT_compiled_vertex_array",
659 "GL_EXT_framebuffer_blit",
660 "GL_IBM_multimode_draw_arrays",
661 "GL_MESA_window_pos",
663 /* Required by GLES2 */
664 "GL_ARB_fragment_program",
665 "GL_ARB_fragment_shader",
666 "GL_ARB_shader_objects",
667 "GL_ARB_texture_cube_map",
668 "GL_ARB_texture_non_power_of_two",
669 "GL_ARB_vertex_shader",
670 "GL_EXT_blend_color",
671 "GL_EXT_blend_equation_separate",
672 "GL_EXT_blend_minmax",
675 "GL_ARB_framebuffer_object",
676 "GL_EXT_texture_filter_anisotropic",
677 "GL_ARB_depth_texture",
678 "GL_EXT_packed_depth_stencil",
679 "GL_EXT_framebuffer_object",
684 InitExtensionsES2(struct gl_context
*ctx
)
688 for (i
= 0; es2_extensions
[i
]; i
++)
689 _mesa_enable_extension(ctx
, es2_extensions
[i
]);
693 * Context-related functions.
697 dri_create_context(gl_api api
,
698 const struct gl_config
* visual
,
699 __DRIcontext
* cPriv
,
700 unsigned major_version
,
701 unsigned minor_version
,
704 void *sharedContextPrivate
)
706 struct dri_context
*ctx
= NULL
;
707 struct dri_context
*share
= (struct dri_context
*)sharedContextPrivate
;
708 struct gl_context
*mesaCtx
= NULL
;
709 struct gl_context
*sharedCtx
= NULL
;
710 struct dd_function_table functions
;
714 /* Flag filtering is handled in dri2CreateContextAttribs.
720 if (major_version
> 2
721 || (major_version
== 2 && minor_version
> 1)) {
722 *error
= __DRI_CTX_ERROR_BAD_VERSION
;
729 case API_OPENGL_CORE
:
730 *error
= __DRI_CTX_ERROR_BAD_API
;
734 ctx
= CALLOC_STRUCT(dri_context
);
736 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
740 cPriv
->driverPrivate
= ctx
;
743 /* build table of device driver functions */
744 _mesa_init_driver_functions(&functions
);
745 swrast_init_driver_functions(&functions
);
748 sharedCtx
= &share
->Base
;
751 mesaCtx
= &ctx
->Base
;
753 /* basic context setup */
754 if (!_mesa_initialize_context(mesaCtx
, api
, visual
, sharedCtx
, &functions
)) {
755 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
759 /* do bounds checking to prevent segfaults and server crashes! */
760 mesaCtx
->Const
.CheckArrayBounds
= GL_TRUE
;
762 /* create module contexts */
763 _swrast_CreateContext( mesaCtx
);
764 _vbo_CreateContext( mesaCtx
);
765 _tnl_CreateContext( mesaCtx
);
766 _swsetup_CreateContext( mesaCtx
);
767 _swsetup_Wakeup( mesaCtx
);
769 /* use default TCL pipeline */
771 TNLcontext
*tnl
= TNL_CONTEXT(mesaCtx
);
772 tnl
->Driver
.RunPipeline
= _tnl_run_pipeline
;
775 _mesa_meta_init(mesaCtx
);
776 _mesa_enable_sw_extensions(mesaCtx
);
779 case API_OPENGL_CORE
:
780 /* XXX fix me, fall-through for now */
782 _mesa_enable_1_3_extensions(mesaCtx
);
783 _mesa_enable_1_4_extensions(mesaCtx
);
784 _mesa_enable_1_5_extensions(mesaCtx
);
785 _mesa_enable_2_0_extensions(mesaCtx
);
786 _mesa_enable_2_1_extensions(mesaCtx
);
789 _mesa_enable_1_3_extensions(mesaCtx
);
790 _mesa_enable_1_4_extensions(mesaCtx
);
791 _mesa_enable_1_5_extensions(mesaCtx
);
795 InitExtensionsES2( 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
,