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
;
130 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
131 * support pageflipping at all.
133 static const GLenum back_buffer_modes
[] = {
134 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
137 uint8_t depth_bits_array
[4];
138 uint8_t stencil_bits_array
[4];
139 uint8_t msaa_samples_array
[1];
142 (void) have_back_buffer
;
144 depth_bits_array
[0] = 0;
145 depth_bits_array
[1] = 0;
146 depth_bits_array
[2] = depth_bits
;
147 depth_bits_array
[3] = depth_bits
;
149 /* Just like with the accumulation buffer, always provide some modes
150 * with a stencil buffer.
152 stencil_bits_array
[0] = 0;
153 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
154 stencil_bits_array
[2] = 0;
155 stencil_bits_array
[3] = (stencil_bits
== 0) ? 8 : stencil_bits
;
157 msaa_samples_array
[0] = 0;
159 depth_buffer_factor
= 4;
160 back_buffer_factor
= 2;
162 switch (pixel_bits
) {
164 format
= MESA_FORMAT_RGB565
;
167 format
= MESA_FORMAT_XRGB8888
;
170 format
= MESA_FORMAT_ARGB8888
;
173 fprintf(stderr
, "[%s:%u] bad depth %d\n", __func__
, __LINE__
,
178 configs
= driCreateConfigs(format
,
179 depth_bits_array
, stencil_bits_array
,
180 depth_buffer_factor
, back_buffer_modes
,
181 back_buffer_factor
, msaa_samples_array
, 1,
183 if (configs
== NULL
) {
184 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
192 static const __DRIconfig
**
193 dri_init_screen(__DRIscreen
* psp
)
195 __DRIconfig
**configs8
, **configs16
, **configs24
, **configs32
;
199 psp
->extensions
= dri_screen_extensions
;
201 configs8
= swrastFillInModes(psp
, 8, 8, 0, 1);
202 configs16
= swrastFillInModes(psp
, 16, 16, 0, 1);
203 configs24
= swrastFillInModes(psp
, 24, 24, 8, 1);
204 configs32
= swrastFillInModes(psp
, 32, 24, 8, 1);
206 configs16
= driConcatConfigs(configs8
, configs16
);
207 configs24
= driConcatConfigs(configs16
, configs24
);
208 configs32
= driConcatConfigs(configs24
, configs32
);
210 return (const __DRIconfig
**)configs32
;
214 dri_destroy_screen(__DRIscreen
* sPriv
)
222 * Framebuffer and renderbuffer-related functions.
226 choose_pixel_format(const struct gl_config
*v
)
228 int depth
= v
->rgbBits
;
231 && v
->redMask
== 0xff0000
232 && v
->greenMask
== 0x00ff00
233 && v
->blueMask
== 0x0000ff)
236 && v
->redMask
== 0xff0000
237 && v
->greenMask
== 0x00ff00
238 && v
->blueMask
== 0x0000ff)
241 && v
->redMask
== 0xf800
242 && v
->greenMask
== 0x07e0
243 && v
->blueMask
== 0x001f)
246 && v
->redMask
== 0x07
247 && v
->greenMask
== 0x38
248 && v
->blueMask
== 0xc0)
251 _mesa_problem( NULL
, "unexpected format in %s", __FUNCTION__
);
256 swrast_delete_renderbuffer(struct gl_renderbuffer
*rb
)
258 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
262 free(xrb
->Base
.Buffer
);
263 _mesa_delete_renderbuffer(rb
);
266 /* see bytes_per_line in libGL */
268 bytes_per_line(unsigned pitch_bits
, unsigned mul
)
270 unsigned mask
= mul
- 1;
272 return ((pitch_bits
+ mask
) & ~mask
) / 8;
276 swrast_alloc_front_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
277 GLenum internalFormat
, GLuint width
, GLuint height
)
279 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
284 (void) internalFormat
;
286 xrb
->Base
.Buffer
= NULL
;
289 xrb
->pitch
= bytes_per_line(width
* xrb
->bpp
, 32);
295 swrast_alloc_back_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
296 GLenum internalFormat
, GLuint width
, GLuint height
)
298 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
302 free(xrb
->Base
.Buffer
);
304 swrast_alloc_front_storage(ctx
, rb
, internalFormat
, width
, height
);
306 xrb
->Base
.Buffer
= malloc(height
* xrb
->pitch
);
311 static struct dri_swrast_renderbuffer
*
312 swrast_new_renderbuffer(const struct gl_config
*visual
, __DRIdrawable
*dPriv
,
315 struct dri_swrast_renderbuffer
*xrb
= calloc(1, sizeof *xrb
);
316 struct gl_renderbuffer
*rb
;
324 rb
= &xrb
->Base
.Base
;
326 _mesa_init_renderbuffer(rb
, 0);
328 pixel_format
= choose_pixel_format(visual
);
331 xrb
->Base
.Base
.Delete
= swrast_delete_renderbuffer
;
333 rb
->AllocStorage
= swrast_alloc_front_storage
;
336 rb
->AllocStorage
= swrast_alloc_back_storage
;
339 switch (pixel_format
) {
341 rb
->Format
= MESA_FORMAT_ARGB8888
;
342 rb
->InternalFormat
= GL_RGBA
;
343 rb
->_BaseFormat
= GL_RGBA
;
347 rb
->Format
= MESA_FORMAT_ARGB8888
; /* XXX */
348 rb
->InternalFormat
= GL_RGB
;
349 rb
->_BaseFormat
= GL_RGB
;
353 rb
->Format
= MESA_FORMAT_RGB565
;
354 rb
->InternalFormat
= GL_RGB
;
355 rb
->_BaseFormat
= GL_RGB
;
359 rb
->Format
= MESA_FORMAT_RGB332
;
360 rb
->InternalFormat
= GL_RGB
;
361 rb
->_BaseFormat
= GL_RGB
;
372 swrast_map_renderbuffer(struct gl_context
*ctx
,
373 struct gl_renderbuffer
*rb
,
374 GLuint x
, GLuint y
, GLuint w
, GLuint h
,
379 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
380 GLubyte
*map
= xrb
->Base
.Buffer
;
381 int cpp
= _mesa_get_format_bytes(rb
->Format
);
382 int stride
= rb
->Width
* cpp
;
384 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
385 __DRIdrawable
*dPriv
= xrb
->dPriv
;
386 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
388 xrb
->map_mode
= mode
;
395 xrb
->Base
.Buffer
= malloc(h
* stride
);
397 sPriv
->swrast_loader
->getImage(dPriv
, x
, y
, w
, h
,
398 (char *) xrb
->Base
.Buffer
,
399 dPriv
->loaderPrivate
);
401 *out_map
= xrb
->Base
.Buffer
;
402 *out_stride
= stride
;
406 ASSERT(xrb
->Base
.Buffer
);
408 if (rb
->AllocStorage
== swrast_alloc_back_storage
) {
409 map
+= (rb
->Height
- 1) * stride
;
413 map
+= (GLsizei
)y
* stride
;
414 map
+= (GLsizei
)x
* cpp
;
417 *out_stride
= stride
;
421 swrast_unmap_renderbuffer(struct gl_context
*ctx
,
422 struct gl_renderbuffer
*rb
)
424 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
426 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
427 __DRIdrawable
*dPriv
= xrb
->dPriv
;
428 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
430 if (xrb
->map_mode
& GL_MAP_WRITE_BIT
) {
431 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_DRAW
,
432 xrb
->map_x
, xrb
->map_y
,
433 xrb
->map_w
, xrb
->map_h
,
434 (char *) xrb
->Base
.Buffer
,
435 dPriv
->loaderPrivate
);
438 free(xrb
->Base
.Buffer
);
439 xrb
->Base
.Buffer
= NULL
;
444 dri_create_buffer(__DRIscreen
* sPriv
,
445 __DRIdrawable
* dPriv
,
446 const struct gl_config
* visual
, GLboolean isPixmap
)
448 struct dri_drawable
*drawable
= NULL
;
449 struct gl_framebuffer
*fb
;
450 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
457 drawable
= CALLOC_STRUCT(dri_drawable
);
458 if (drawable
== NULL
)
461 dPriv
->driverPrivate
= drawable
;
462 drawable
->dPriv
= dPriv
;
464 drawable
->row
= malloc(SWRAST_MAX_WIDTH
* 4);
465 if (drawable
->row
== NULL
)
468 fb
= &drawable
->Base
;
470 /* basic framebuffer setup */
471 _mesa_initialize_window_framebuffer(fb
, visual
);
473 /* add front renderbuffer */
474 frontrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_TRUE
);
475 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &frontrb
->Base
.Base
);
477 /* add back renderbuffer */
478 if (visual
->doubleBufferMode
) {
479 backrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_FALSE
);
480 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &backrb
->Base
.Base
);
483 /* add software renderbuffers */
484 _swrast_add_soft_renderbuffers(fb
,
485 GL_FALSE
, /* color */
486 visual
->haveDepthBuffer
,
487 visual
->haveStencilBuffer
,
488 visual
->haveAccumBuffer
,
489 GL_FALSE
, /* alpha */
490 GL_FALSE
/* aux bufs */);
505 dri_destroy_buffer(__DRIdrawable
* dPriv
)
510 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
511 struct gl_framebuffer
*fb
;
515 fb
= &drawable
->Base
;
517 fb
->DeletePending
= GL_TRUE
;
518 _mesa_reference_framebuffer(&fb
, NULL
);
523 dri_swap_buffers(__DRIdrawable
* dPriv
)
525 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
527 GET_CURRENT_CONTEXT(ctx
);
529 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
530 struct gl_framebuffer
*fb
;
531 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
535 fb
= &drawable
->Base
;
538 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
540 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_BACK_LEFT
].Renderbuffer
);
542 /* check for signle-buffered */
546 /* check if swapping currently bound buffer */
547 if (ctx
&& ctx
->DrawBuffer
== fb
) {
548 /* flush pending rendering */
549 _mesa_notifySwapBuffers(ctx
);
552 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_SWAP
,
554 frontrb
->Base
.Base
.Width
,
555 frontrb
->Base
.Base
.Height
,
556 (char *) backrb
->Base
.Buffer
,
557 dPriv
->loaderPrivate
);
562 * General device driver functions.
566 get_window_size( struct gl_framebuffer
*fb
, GLsizei
*w
, GLsizei
*h
)
568 __DRIdrawable
*dPriv
= swrast_drawable(fb
)->dPriv
;
569 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
572 sPriv
->swrast_loader
->getDrawableInfo(dPriv
,
574 dPriv
->loaderPrivate
);
578 swrast_check_and_update_window_size( struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
580 GLsizei width
, height
;
582 get_window_size(fb
, &width
, &height
);
583 if (fb
->Width
!= width
|| fb
->Height
!= height
) {
584 _mesa_resize_framebuffer(ctx
, fb
, width
, height
);
588 static const GLubyte
*
589 get_string(struct gl_context
*ctx
, GLenum pname
)
594 return (const GLubyte
*) "Mesa Project";
596 return (const GLubyte
*) "Software Rasterizer";
603 update_state( struct gl_context
*ctx
, GLuint new_state
)
605 /* not much to do here - pass it on */
606 _swrast_InvalidateState( ctx
, new_state
);
607 _swsetup_InvalidateState( ctx
, new_state
);
608 _vbo_InvalidateState( ctx
, new_state
);
609 _tnl_InvalidateState( ctx
, new_state
);
613 viewport(struct gl_context
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
615 struct gl_framebuffer
*draw
= ctx
->WinSysDrawBuffer
;
616 struct gl_framebuffer
*read
= ctx
->WinSysReadBuffer
;
622 swrast_check_and_update_window_size(ctx
, draw
);
623 swrast_check_and_update_window_size(ctx
, read
);
626 static gl_format
swrastChooseTextureFormat(struct gl_context
* ctx
,
628 GLint internalFormat
,
632 if (internalFormat
== GL_RGB
)
633 return MESA_FORMAT_XRGB8888
;
634 return _mesa_choose_tex_format(ctx
, target
, internalFormat
, format
, type
);
638 swrast_init_driver_functions(struct dd_function_table
*driver
)
640 driver
->GetString
= get_string
;
641 driver
->UpdateState
= update_state
;
642 driver
->GetBufferSize
= NULL
;
643 driver
->Viewport
= viewport
;
644 driver
->ChooseTextureFormat
= swrastChooseTextureFormat
;
645 driver
->MapRenderbuffer
= swrast_map_renderbuffer
;
646 driver
->UnmapRenderbuffer
= swrast_unmap_renderbuffer
;
649 static const char *es2_extensions
[] = {
650 /* Used by mesa internally (cf all_mesa_extensions in ../common/utils.c) */
651 "GL_EXT_blend_func_separate",
652 "GL_EXT_framebuffer_blit",
653 "GL_IBM_multimode_draw_arrays",
654 "GL_MESA_window_pos",
656 /* Required by GLES2 */
657 "GL_ARB_fragment_program",
658 "GL_ARB_fragment_shader",
659 "GL_ARB_shader_objects",
660 "GL_ARB_texture_cube_map",
661 "GL_ARB_texture_non_power_of_two",
662 "GL_ARB_vertex_shader",
663 "GL_EXT_blend_color",
664 "GL_EXT_blend_equation_separate",
665 "GL_EXT_blend_minmax",
668 "GL_ARB_framebuffer_object",
669 "GL_EXT_texture_filter_anisotropic",
670 "GL_ARB_depth_texture",
671 "GL_EXT_packed_depth_stencil",
672 "GL_EXT_framebuffer_object",
677 InitExtensionsES2(struct gl_context
*ctx
)
681 for (i
= 0; es2_extensions
[i
]; i
++)
682 _mesa_enable_extension(ctx
, es2_extensions
[i
]);
686 * Context-related functions.
690 dri_create_context(gl_api api
,
691 const struct gl_config
* visual
,
692 __DRIcontext
* cPriv
,
693 unsigned major_version
,
694 unsigned minor_version
,
697 void *sharedContextPrivate
)
699 struct dri_context
*ctx
= NULL
;
700 struct dri_context
*share
= (struct dri_context
*)sharedContextPrivate
;
701 struct gl_context
*mesaCtx
= NULL
;
702 struct gl_context
*sharedCtx
= NULL
;
703 struct dd_function_table functions
;
707 /* Flag filtering is handled in dri2CreateContextAttribs.
713 if (major_version
> 2
714 || (major_version
== 2 && minor_version
> 1)) {
715 *error
= __DRI_CTX_ERROR_BAD_VERSION
;
722 case API_OPENGL_CORE
:
723 *error
= __DRI_CTX_ERROR_BAD_API
;
727 ctx
= CALLOC_STRUCT(dri_context
);
729 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
733 cPriv
->driverPrivate
= ctx
;
736 /* build table of device driver functions */
737 _mesa_init_driver_functions(&functions
);
738 swrast_init_driver_functions(&functions
);
741 sharedCtx
= &share
->Base
;
744 mesaCtx
= &ctx
->Base
;
746 /* basic context setup */
747 if (!_mesa_initialize_context(mesaCtx
, api
, visual
, sharedCtx
, &functions
)) {
748 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
752 /* do bounds checking to prevent segfaults and server crashes! */
753 mesaCtx
->Const
.CheckArrayBounds
= GL_TRUE
;
755 /* create module contexts */
756 _swrast_CreateContext( mesaCtx
);
757 _vbo_CreateContext( mesaCtx
);
758 _tnl_CreateContext( mesaCtx
);
759 _swsetup_CreateContext( mesaCtx
);
760 _swsetup_Wakeup( mesaCtx
);
762 /* use default TCL pipeline */
764 TNLcontext
*tnl
= TNL_CONTEXT(mesaCtx
);
765 tnl
->Driver
.RunPipeline
= _tnl_run_pipeline
;
768 _mesa_meta_init(mesaCtx
);
769 _mesa_enable_sw_extensions(mesaCtx
);
772 case API_OPENGL_CORE
:
773 /* XXX fix me, fall-through for now */
775 _mesa_enable_1_3_extensions(mesaCtx
);
776 _mesa_enable_1_4_extensions(mesaCtx
);
777 _mesa_enable_1_5_extensions(mesaCtx
);
778 _mesa_enable_2_0_extensions(mesaCtx
);
779 _mesa_enable_2_1_extensions(mesaCtx
);
782 _mesa_enable_1_3_extensions(mesaCtx
);
783 _mesa_enable_1_4_extensions(mesaCtx
);
784 _mesa_enable_1_5_extensions(mesaCtx
);
788 InitExtensionsES2( mesaCtx
);
792 *error
= __DRI_CTX_ERROR_SUCCESS
;
803 dri_destroy_context(__DRIcontext
* cPriv
)
808 struct dri_context
*ctx
= dri_context(cPriv
);
809 struct gl_context
*mesaCtx
;
811 mesaCtx
= &ctx
->Base
;
813 _mesa_meta_free(mesaCtx
);
814 _swsetup_DestroyContext( mesaCtx
);
815 _swrast_DestroyContext( mesaCtx
);
816 _tnl_DestroyContext( mesaCtx
);
817 _vbo_DestroyContext( mesaCtx
);
818 _mesa_destroy_context( mesaCtx
);
823 dri_make_current(__DRIcontext
* cPriv
,
824 __DRIdrawable
* driDrawPriv
,
825 __DRIdrawable
* driReadPriv
)
827 struct gl_context
*mesaCtx
;
828 struct gl_framebuffer
*mesaDraw
;
829 struct gl_framebuffer
*mesaRead
;
833 struct dri_context
*ctx
= dri_context(cPriv
);
834 struct dri_drawable
*draw
;
835 struct dri_drawable
*read
;
837 if (!driDrawPriv
|| !driReadPriv
)
840 draw
= dri_drawable(driDrawPriv
);
841 read
= dri_drawable(driReadPriv
);
842 mesaCtx
= &ctx
->Base
;
843 mesaDraw
= &draw
->Base
;
844 mesaRead
= &read
->Base
;
846 /* check for same context and buffer */
847 if (mesaCtx
== _mesa_get_current_context()
848 && mesaCtx
->DrawBuffer
== mesaDraw
849 && mesaCtx
->ReadBuffer
== mesaRead
) {
853 _glapi_check_multithread();
855 swrast_check_and_update_window_size(mesaCtx
, mesaDraw
);
856 if (mesaRead
!= mesaDraw
)
857 swrast_check_and_update_window_size(mesaCtx
, mesaRead
);
859 _mesa_make_current( mesaCtx
,
865 _mesa_make_current( NULL
, NULL
, NULL
);
872 dri_unbind_context(__DRIcontext
* cPriv
)
877 /* Unset current context and dispath table */
878 _mesa_make_current(NULL
, NULL
, NULL
);
884 const struct __DriverAPIRec driDriverAPI
= {
885 .InitScreen
= dri_init_screen
,
886 .DestroyScreen
= dri_destroy_screen
,
887 .CreateContext
= dri_create_context
,
888 .DestroyContext
= dri_destroy_context
,
889 .CreateBuffer
= dri_create_buffer
,
890 .DestroyBuffer
= dri_destroy_buffer
,
891 .SwapBuffers
= dri_swap_buffers
,
892 .MakeCurrent
= dri_make_current
,
893 .UnbindContext
= dri_unbind_context
,
896 /* This is the table of extensions that the loader will dlsym() for. */
897 PUBLIC
const __DRIextension
*__driDriverExtensions
[] = {
898 &driCoreExtension
.base
,
899 &driSWRastExtension
.base
,