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"
62 const __DRIextension
**__driDriverGetExtensions_swrast(void);
65 * Screen and config-related functions
68 static void swrastSetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
,
69 GLint texture_format
, __DRIdrawable
*dPriv
)
71 struct dri_context
*dri_ctx
;
73 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
74 struct gl_texture_unit
*texUnit
;
75 struct gl_texture_object
*texObj
;
76 struct gl_texture_image
*texImage
;
77 struct swrast_texture_image
*swImage
;
78 uint32_t internalFormat
;
81 dri_ctx
= pDRICtx
->driverPrivate
;
83 internalFormat
= (texture_format
== __DRI_TEXTURE_FORMAT_RGB
? 3 : 4);
85 texUnit
= _mesa_get_current_tex_unit(&dri_ctx
->Base
);
86 texObj
= _mesa_select_tex_object(&dri_ctx
->Base
, texUnit
, target
);
87 texImage
= _mesa_get_tex_image(&dri_ctx
->Base
, texObj
, target
, 0);
88 swImage
= swrast_texture_image(texImage
);
90 _mesa_lock_texture(&dri_ctx
->Base
, texObj
);
92 sPriv
->swrast_loader
->getDrawableInfo(dPriv
, &x
, &y
, &w
, &h
, dPriv
->loaderPrivate
);
94 if (texture_format
== __DRI_TEXTURE_FORMAT_RGB
)
95 texFormat
= MESA_FORMAT_XRGB8888
;
97 texFormat
= MESA_FORMAT_ARGB8888
;
99 _mesa_init_teximage_fields(&dri_ctx
->Base
, texImage
,
100 w
, h
, 1, 0, internalFormat
, texFormat
);
102 sPriv
->swrast_loader
->getImage(dPriv
, x
, y
, w
, h
, (char *)swImage
->Buffer
,
103 dPriv
->loaderPrivate
);
105 _mesa_unlock_texture(&dri_ctx
->Base
, texObj
);
108 static void swrastSetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
,
109 __DRIdrawable
*dPriv
)
111 swrastSetTexBuffer2(pDRICtx
, target
, __DRI_TEXTURE_FORMAT_RGBA
, dPriv
);
114 static const __DRItexBufferExtension swrastTexBufferExtension
= {
115 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
120 static const __DRIextension
*dri_screen_extensions
[] = {
121 &swrastTexBufferExtension
.base
,
125 static __DRIconfig
**
126 swrastFillInModes(__DRIscreen
*psp
,
127 unsigned pixel_bits
, unsigned depth_bits
,
128 unsigned stencil_bits
, GLboolean have_back_buffer
)
130 __DRIconfig
**configs
;
131 unsigned depth_buffer_factor
;
132 unsigned back_buffer_factor
;
135 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
136 * support pageflipping at all.
138 static const GLenum back_buffer_modes
[] = {
139 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
142 uint8_t depth_bits_array
[4];
143 uint8_t stencil_bits_array
[4];
144 uint8_t msaa_samples_array
[1];
147 (void) have_back_buffer
;
149 depth_bits_array
[0] = 0;
150 depth_bits_array
[1] = 0;
151 depth_bits_array
[2] = depth_bits
;
152 depth_bits_array
[3] = depth_bits
;
154 /* Just like with the accumulation buffer, always provide some modes
155 * with a stencil buffer.
157 stencil_bits_array
[0] = 0;
158 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
159 stencil_bits_array
[2] = 0;
160 stencil_bits_array
[3] = (stencil_bits
== 0) ? 8 : stencil_bits
;
162 msaa_samples_array
[0] = 0;
164 depth_buffer_factor
= 4;
165 back_buffer_factor
= 2;
167 switch (pixel_bits
) {
169 format
= MESA_FORMAT_RGB565
;
172 format
= MESA_FORMAT_XRGB8888
;
175 format
= MESA_FORMAT_ARGB8888
;
178 fprintf(stderr
, "[%s:%u] bad depth %d\n", __func__
, __LINE__
,
183 configs
= driCreateConfigs(format
,
184 depth_bits_array
, stencil_bits_array
,
185 depth_buffer_factor
, back_buffer_modes
,
186 back_buffer_factor
, msaa_samples_array
, 1,
188 if (configs
== NULL
) {
189 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
197 static const __DRIconfig
**
198 dri_init_screen(__DRIscreen
* psp
)
200 __DRIconfig
**configs16
, **configs24
, **configs32
;
204 psp
->max_gl_compat_version
= 21;
205 psp
->max_gl_es1_version
= 11;
206 psp
->max_gl_es2_version
= 20;
208 psp
->extensions
= dri_screen_extensions
;
210 configs16
= swrastFillInModes(psp
, 16, 16, 0, 1);
211 configs24
= swrastFillInModes(psp
, 24, 24, 8, 1);
212 configs32
= swrastFillInModes(psp
, 32, 24, 8, 1);
214 configs24
= driConcatConfigs(configs16
, configs24
);
215 configs32
= driConcatConfigs(configs24
, configs32
);
217 return (const __DRIconfig
**)configs32
;
221 dri_destroy_screen(__DRIscreen
* sPriv
)
229 * Framebuffer and renderbuffer-related functions.
233 choose_pixel_format(const struct gl_config
*v
)
235 int depth
= v
->rgbBits
;
238 && v
->redMask
== 0xff0000
239 && v
->greenMask
== 0x00ff00
240 && v
->blueMask
== 0x0000ff)
243 && v
->redMask
== 0xff0000
244 && v
->greenMask
== 0x00ff00
245 && v
->blueMask
== 0x0000ff)
248 && v
->redMask
== 0xf800
249 && v
->greenMask
== 0x07e0
250 && v
->blueMask
== 0x001f)
253 && v
->redMask
== 0x07
254 && v
->greenMask
== 0x38
255 && v
->blueMask
== 0xc0)
258 _mesa_problem( NULL
, "unexpected format in %s", __FUNCTION__
);
263 swrast_delete_renderbuffer(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
)
265 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
269 free(xrb
->Base
.Buffer
);
270 _mesa_delete_renderbuffer(ctx
, rb
);
273 /* see bytes_per_line in libGL */
275 bytes_per_line(unsigned pitch_bits
, unsigned mul
)
277 unsigned mask
= mul
- 1;
279 return ((pitch_bits
+ mask
) & ~mask
) / 8;
283 swrast_alloc_front_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
284 GLenum internalFormat
, GLuint width
, GLuint height
)
286 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
291 (void) internalFormat
;
293 xrb
->Base
.Buffer
= NULL
;
296 xrb
->pitch
= bytes_per_line(width
* xrb
->bpp
, 32);
302 swrast_alloc_back_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
303 GLenum internalFormat
, GLuint width
, GLuint height
)
305 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
309 free(xrb
->Base
.Buffer
);
311 swrast_alloc_front_storage(ctx
, rb
, internalFormat
, width
, height
);
313 xrb
->Base
.Buffer
= malloc(height
* xrb
->pitch
);
318 static struct dri_swrast_renderbuffer
*
319 swrast_new_renderbuffer(const struct gl_config
*visual
, __DRIdrawable
*dPriv
,
322 struct dri_swrast_renderbuffer
*xrb
= calloc(1, sizeof *xrb
);
323 struct gl_renderbuffer
*rb
;
331 rb
= &xrb
->Base
.Base
;
333 _mesa_init_renderbuffer(rb
, 0);
335 pixel_format
= choose_pixel_format(visual
);
338 xrb
->Base
.Base
.Delete
= swrast_delete_renderbuffer
;
340 rb
->AllocStorage
= swrast_alloc_front_storage
;
343 rb
->AllocStorage
= swrast_alloc_back_storage
;
346 switch (pixel_format
) {
348 rb
->Format
= MESA_FORMAT_ARGB8888
;
349 rb
->InternalFormat
= GL_RGBA
;
350 rb
->_BaseFormat
= GL_RGBA
;
354 rb
->Format
= MESA_FORMAT_ARGB8888
; /* XXX */
355 rb
->InternalFormat
= GL_RGB
;
356 rb
->_BaseFormat
= GL_RGB
;
360 rb
->Format
= MESA_FORMAT_RGB565
;
361 rb
->InternalFormat
= GL_RGB
;
362 rb
->_BaseFormat
= GL_RGB
;
366 rb
->Format
= MESA_FORMAT_RGB332
;
367 rb
->InternalFormat
= GL_RGB
;
368 rb
->_BaseFormat
= GL_RGB
;
380 swrast_map_renderbuffer(struct gl_context
*ctx
,
381 struct gl_renderbuffer
*rb
,
382 GLuint x
, GLuint y
, GLuint w
, GLuint h
,
387 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
388 GLubyte
*map
= xrb
->Base
.Buffer
;
389 int cpp
= _mesa_get_format_bytes(rb
->Format
);
390 int stride
= rb
->Width
* cpp
;
392 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
393 __DRIdrawable
*dPriv
= xrb
->dPriv
;
394 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
396 xrb
->map_mode
= mode
;
403 xrb
->Base
.Buffer
= malloc(h
* stride
);
405 sPriv
->swrast_loader
->getImage(dPriv
, x
, rb
->Height
- y
- h
, w
, h
,
406 (char *) xrb
->Base
.Buffer
,
407 dPriv
->loaderPrivate
);
409 *out_map
= xrb
->Base
.Buffer
+ (h
- 1) * stride
;
410 *out_stride
= -stride
;
414 ASSERT(xrb
->Base
.Buffer
);
416 if (rb
->AllocStorage
== swrast_alloc_back_storage
) {
417 map
+= (rb
->Height
- 1) * stride
;
421 map
+= (GLsizei
)y
* stride
;
422 map
+= (GLsizei
)x
* cpp
;
425 *out_stride
= stride
;
429 swrast_unmap_renderbuffer(struct gl_context
*ctx
,
430 struct gl_renderbuffer
*rb
)
432 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
434 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
435 __DRIdrawable
*dPriv
= xrb
->dPriv
;
436 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
438 if (xrb
->map_mode
& GL_MAP_WRITE_BIT
) {
439 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_DRAW
,
440 xrb
->map_x
, xrb
->map_y
,
441 xrb
->map_w
, xrb
->map_h
,
442 (char *) xrb
->Base
.Buffer
,
443 dPriv
->loaderPrivate
);
446 free(xrb
->Base
.Buffer
);
447 xrb
->Base
.Buffer
= NULL
;
452 dri_create_buffer(__DRIscreen
* sPriv
,
453 __DRIdrawable
* dPriv
,
454 const struct gl_config
* visual
, GLboolean isPixmap
)
456 struct dri_drawable
*drawable
= NULL
;
457 struct gl_framebuffer
*fb
;
458 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
465 drawable
= CALLOC_STRUCT(dri_drawable
);
466 if (drawable
== NULL
)
469 dPriv
->driverPrivate
= drawable
;
470 drawable
->dPriv
= dPriv
;
472 drawable
->row
= malloc(SWRAST_MAX_WIDTH
* 4);
473 if (drawable
->row
== NULL
)
476 fb
= &drawable
->Base
;
478 /* basic framebuffer setup */
479 _mesa_initialize_window_framebuffer(fb
, visual
);
481 /* add front renderbuffer */
482 frontrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_TRUE
);
483 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &frontrb
->Base
.Base
);
485 /* add back renderbuffer */
486 if (visual
->doubleBufferMode
) {
487 backrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_FALSE
);
488 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &backrb
->Base
.Base
);
491 /* add software renderbuffers */
492 _swrast_add_soft_renderbuffers(fb
,
493 GL_FALSE
, /* color */
494 visual
->haveDepthBuffer
,
495 visual
->haveStencilBuffer
,
496 visual
->haveAccumBuffer
,
497 GL_FALSE
, /* alpha */
498 GL_FALSE
/* aux bufs */);
513 dri_destroy_buffer(__DRIdrawable
* dPriv
)
518 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
519 struct gl_framebuffer
*fb
;
523 fb
= &drawable
->Base
;
525 fb
->DeletePending
= GL_TRUE
;
526 _mesa_reference_framebuffer(&fb
, NULL
);
531 dri_swap_buffers(__DRIdrawable
* dPriv
)
533 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
535 GET_CURRENT_CONTEXT(ctx
);
537 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
538 struct gl_framebuffer
*fb
;
539 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
543 fb
= &drawable
->Base
;
546 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
548 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_BACK_LEFT
].Renderbuffer
);
550 /* check for signle-buffered */
554 /* check if swapping currently bound buffer */
555 if (ctx
&& ctx
->DrawBuffer
== fb
) {
556 /* flush pending rendering */
557 _mesa_notifySwapBuffers(ctx
);
560 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_SWAP
,
562 frontrb
->Base
.Base
.Width
,
563 frontrb
->Base
.Base
.Height
,
564 (char *) backrb
->Base
.Buffer
,
565 dPriv
->loaderPrivate
);
570 * General device driver functions.
574 get_window_size( struct gl_framebuffer
*fb
, GLsizei
*w
, GLsizei
*h
)
576 __DRIdrawable
*dPriv
= swrast_drawable(fb
)->dPriv
;
577 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
580 sPriv
->swrast_loader
->getDrawableInfo(dPriv
,
582 dPriv
->loaderPrivate
);
586 swrast_check_and_update_window_size( struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
588 GLsizei width
, height
;
590 get_window_size(fb
, &width
, &height
);
591 if (fb
->Width
!= width
|| fb
->Height
!= height
) {
592 _mesa_resize_framebuffer(ctx
, fb
, width
, height
);
596 static const GLubyte
*
597 get_string(struct gl_context
*ctx
, GLenum pname
)
602 return (const GLubyte
*) "Mesa Project";
604 return (const GLubyte
*) "Software Rasterizer";
611 update_state( struct gl_context
*ctx
, GLuint new_state
)
613 /* not much to do here - pass it on */
614 _swrast_InvalidateState( ctx
, new_state
);
615 _swsetup_InvalidateState( ctx
, new_state
);
616 _vbo_InvalidateState( ctx
, new_state
);
617 _tnl_InvalidateState( ctx
, new_state
);
621 viewport(struct gl_context
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
623 struct gl_framebuffer
*draw
= ctx
->WinSysDrawBuffer
;
624 struct gl_framebuffer
*read
= ctx
->WinSysReadBuffer
;
630 swrast_check_and_update_window_size(ctx
, draw
);
631 swrast_check_and_update_window_size(ctx
, read
);
634 static gl_format
swrastChooseTextureFormat(struct gl_context
* ctx
,
636 GLint internalFormat
,
640 if (internalFormat
== GL_RGB
)
641 return MESA_FORMAT_XRGB8888
;
642 return _mesa_choose_tex_format(ctx
, target
, internalFormat
, format
, type
);
646 swrast_init_driver_functions(struct dd_function_table
*driver
)
648 driver
->GetString
= get_string
;
649 driver
->UpdateState
= update_state
;
650 driver
->Viewport
= viewport
;
651 driver
->ChooseTextureFormat
= swrastChooseTextureFormat
;
652 driver
->MapRenderbuffer
= swrast_map_renderbuffer
;
653 driver
->UnmapRenderbuffer
= swrast_unmap_renderbuffer
;
657 * Context-related functions.
661 dri_create_context(gl_api api
,
662 const struct gl_config
* visual
,
663 __DRIcontext
* cPriv
,
664 unsigned major_version
,
665 unsigned minor_version
,
669 void *sharedContextPrivate
)
671 struct dri_context
*ctx
= NULL
;
672 struct dri_context
*share
= (struct dri_context
*)sharedContextPrivate
;
673 struct gl_context
*mesaCtx
= NULL
;
674 struct gl_context
*sharedCtx
= NULL
;
675 struct dd_function_table functions
;
679 /* Flag filtering is handled in dri2CreateContextAttribs.
683 ctx
= CALLOC_STRUCT(dri_context
);
685 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
689 cPriv
->driverPrivate
= ctx
;
692 /* build table of device driver functions */
693 _mesa_init_driver_functions(&functions
);
694 swrast_init_driver_functions(&functions
);
697 sharedCtx
= &share
->Base
;
700 mesaCtx
= &ctx
->Base
;
702 /* basic context setup */
703 if (!_mesa_initialize_context(mesaCtx
, api
, visual
, sharedCtx
, &functions
)) {
704 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
708 driContextSetFlags(mesaCtx
, flags
);
710 /* do bounds checking to prevent segfaults and server crashes! */
711 mesaCtx
->Const
.CheckArrayBounds
= GL_TRUE
;
713 /* create module contexts */
714 _swrast_CreateContext( mesaCtx
);
715 _vbo_CreateContext( mesaCtx
);
716 _tnl_CreateContext( mesaCtx
);
717 _swsetup_CreateContext( mesaCtx
);
718 _swsetup_Wakeup( mesaCtx
);
720 /* use default TCL pipeline */
722 TNLcontext
*tnl
= TNL_CONTEXT(mesaCtx
);
723 tnl
->Driver
.RunPipeline
= _tnl_run_pipeline
;
726 _mesa_meta_init(mesaCtx
);
727 _mesa_enable_sw_extensions(mesaCtx
);
729 _mesa_compute_version(mesaCtx
);
731 _mesa_initialize_dispatch_tables(mesaCtx
);
732 _mesa_initialize_vbo_vtxfmt(mesaCtx
);
734 *error
= __DRI_CTX_ERROR_SUCCESS
;
745 dri_destroy_context(__DRIcontext
* cPriv
)
750 struct dri_context
*ctx
= dri_context(cPriv
);
751 struct gl_context
*mesaCtx
;
753 mesaCtx
= &ctx
->Base
;
755 _mesa_meta_free(mesaCtx
);
756 _swsetup_DestroyContext( mesaCtx
);
757 _swrast_DestroyContext( mesaCtx
);
758 _tnl_DestroyContext( mesaCtx
);
759 _vbo_DestroyContext( mesaCtx
);
760 _mesa_destroy_context( mesaCtx
);
765 dri_make_current(__DRIcontext
* cPriv
,
766 __DRIdrawable
* driDrawPriv
,
767 __DRIdrawable
* driReadPriv
)
769 struct gl_context
*mesaCtx
;
770 struct gl_framebuffer
*mesaDraw
;
771 struct gl_framebuffer
*mesaRead
;
775 struct dri_context
*ctx
= dri_context(cPriv
);
776 struct dri_drawable
*draw
;
777 struct dri_drawable
*read
;
779 if (!driDrawPriv
|| !driReadPriv
)
782 draw
= dri_drawable(driDrawPriv
);
783 read
= dri_drawable(driReadPriv
);
784 mesaCtx
= &ctx
->Base
;
785 mesaDraw
= &draw
->Base
;
786 mesaRead
= &read
->Base
;
788 /* check for same context and buffer */
789 if (mesaCtx
== _mesa_get_current_context()
790 && mesaCtx
->DrawBuffer
== mesaDraw
791 && mesaCtx
->ReadBuffer
== mesaRead
) {
795 _glapi_check_multithread();
797 swrast_check_and_update_window_size(mesaCtx
, mesaDraw
);
798 if (mesaRead
!= mesaDraw
)
799 swrast_check_and_update_window_size(mesaCtx
, mesaRead
);
801 _mesa_make_current( mesaCtx
,
807 _mesa_make_current( NULL
, NULL
, NULL
);
814 dri_unbind_context(__DRIcontext
* cPriv
)
819 /* Unset current context and dispath table */
820 _mesa_make_current(NULL
, NULL
, NULL
);
826 dri_copy_sub_buffer(__DRIdrawable
*dPriv
, int x
, int y
,
829 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
832 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
833 struct gl_framebuffer
*fb
;
834 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
838 fb
= &drawable
->Base
;
841 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
843 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_BACK_LEFT
].Renderbuffer
);
845 /* check for signle-buffered */
849 iy
= frontrb
->Base
.Base
.Height
- y
- h
;
850 data
= (char *)backrb
->Base
.Buffer
+ (iy
* backrb
->pitch
) + (x
* ((backrb
->bpp
+ 7) / 8));
851 sPriv
->swrast_loader
->putImage2(dPriv
, __DRI_SWRAST_IMAGE_OP_SWAP
,
855 dPriv
->loaderPrivate
);
859 static const struct __DriverAPIRec swrast_driver_api
= {
860 .InitScreen
= dri_init_screen
,
861 .DestroyScreen
= dri_destroy_screen
,
862 .CreateContext
= dri_create_context
,
863 .DestroyContext
= dri_destroy_context
,
864 .CreateBuffer
= dri_create_buffer
,
865 .DestroyBuffer
= dri_destroy_buffer
,
866 .SwapBuffers
= dri_swap_buffers
,
867 .MakeCurrent
= dri_make_current
,
868 .UnbindContext
= dri_unbind_context
,
869 .CopySubBuffer
= dri_copy_sub_buffer
,
872 static const struct __DRIDriverVtableExtensionRec swrast_vtable
= {
873 .base
= { __DRI_DRIVER_VTABLE
, 1 },
874 .vtable
= &swrast_driver_api
,
877 static const __DRIextension
*swrast_driver_extensions
[] = {
878 &driCoreExtension
.base
,
879 &driSWRastExtension
.base
,
880 &driCopySubBufferExtension
.base
,
885 PUBLIC
const __DRIextension
**__driDriverGetExtensions_swrast(void)
887 globalDriverAPI
= &swrast_driver_api
;
889 return swrast_driver_extensions
;