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_object
*texObj
;
75 struct gl_texture_image
*texImage
;
76 struct swrast_texture_image
*swImage
;
77 uint32_t internalFormat
;
78 mesa_format texFormat
;
80 dri_ctx
= pDRICtx
->driverPrivate
;
82 internalFormat
= (texture_format
== __DRI_TEXTURE_FORMAT_RGB
? 3 : 4);
84 texObj
= _mesa_get_current_tex_object(&dri_ctx
->Base
, 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_B8G8R8X8_UNORM
;
95 texFormat
= MESA_FORMAT_B8G8R8A8_UNORM
;
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_B5G6R5_UNORM
;
170 format
= MESA_FORMAT_B8G8R8X8_UNORM
;
173 format
= MESA_FORMAT_B8G8R8A8_UNORM
;
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
->max_gl_compat_version
= 21;
203 psp
->max_gl_es1_version
= 11;
204 psp
->max_gl_es2_version
= 20;
206 psp
->extensions
= dri_screen_extensions
;
208 configs16
= swrastFillInModes(psp
, 16, 16, 0, 1);
209 configs24
= swrastFillInModes(psp
, 24, 24, 8, 1);
210 configs32
= swrastFillInModes(psp
, 32, 24, 8, 1);
212 configs24
= driConcatConfigs(configs16
, configs24
);
213 configs32
= driConcatConfigs(configs24
, configs32
);
215 return (const __DRIconfig
**)configs32
;
219 dri_destroy_screen(__DRIscreen
* sPriv
)
227 * Framebuffer and renderbuffer-related functions.
231 choose_pixel_format(const struct gl_config
*v
)
233 int depth
= v
->rgbBits
;
236 && v
->redMask
== 0xff0000
237 && v
->greenMask
== 0x00ff00
238 && v
->blueMask
== 0x0000ff)
241 && v
->redMask
== 0xff0000
242 && v
->greenMask
== 0x00ff00
243 && v
->blueMask
== 0x0000ff)
246 && v
->redMask
== 0xf800
247 && v
->greenMask
== 0x07e0
248 && v
->blueMask
== 0x001f)
251 && v
->redMask
== 0x07
252 && v
->greenMask
== 0x38
253 && v
->blueMask
== 0xc0)
256 _mesa_problem( NULL
, "unexpected format in %s", __FUNCTION__
);
261 swrast_delete_renderbuffer(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
)
263 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
267 free(xrb
->Base
.Buffer
);
268 _mesa_delete_renderbuffer(ctx
, rb
);
271 /* see bytes_per_line in libGL */
273 bytes_per_line(unsigned pitch_bits
, unsigned mul
)
275 unsigned mask
= mul
- 1;
277 return ((pitch_bits
+ mask
) & ~mask
) / 8;
281 swrast_alloc_front_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
282 GLenum internalFormat
, GLuint width
, GLuint height
)
284 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
289 (void) internalFormat
;
291 xrb
->Base
.Buffer
= NULL
;
294 xrb
->pitch
= bytes_per_line(width
* xrb
->bpp
, 32);
300 swrast_alloc_back_storage(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
,
301 GLenum internalFormat
, GLuint width
, GLuint height
)
303 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
307 free(xrb
->Base
.Buffer
);
309 swrast_alloc_front_storage(ctx
, rb
, internalFormat
, width
, height
);
311 xrb
->Base
.Buffer
= malloc(height
* xrb
->pitch
);
316 static struct dri_swrast_renderbuffer
*
317 swrast_new_renderbuffer(const struct gl_config
*visual
, __DRIdrawable
*dPriv
,
320 struct dri_swrast_renderbuffer
*xrb
= calloc(1, sizeof *xrb
);
321 struct gl_renderbuffer
*rb
;
329 rb
= &xrb
->Base
.Base
;
331 _mesa_init_renderbuffer(rb
, 0);
333 pixel_format
= choose_pixel_format(visual
);
336 xrb
->Base
.Base
.Delete
= swrast_delete_renderbuffer
;
338 rb
->AllocStorage
= swrast_alloc_front_storage
;
341 rb
->AllocStorage
= swrast_alloc_back_storage
;
344 switch (pixel_format
) {
346 rb
->Format
= MESA_FORMAT_B8G8R8A8_UNORM
;
347 rb
->InternalFormat
= GL_RGBA
;
348 rb
->_BaseFormat
= GL_RGBA
;
352 rb
->Format
= MESA_FORMAT_B8G8R8A8_UNORM
; /* XXX */
353 rb
->InternalFormat
= GL_RGB
;
354 rb
->_BaseFormat
= GL_RGB
;
358 rb
->Format
= MESA_FORMAT_B5G6R5_UNORM
;
359 rb
->InternalFormat
= GL_RGB
;
360 rb
->_BaseFormat
= GL_RGB
;
364 rb
->Format
= MESA_FORMAT_B2G3R3_UNORM
;
365 rb
->InternalFormat
= GL_RGB
;
366 rb
->_BaseFormat
= GL_RGB
;
378 swrast_map_renderbuffer(struct gl_context
*ctx
,
379 struct gl_renderbuffer
*rb
,
380 GLuint x
, GLuint y
, GLuint w
, GLuint h
,
385 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
386 GLubyte
*map
= xrb
->Base
.Buffer
;
387 int cpp
= _mesa_get_format_bytes(rb
->Format
);
388 int stride
= rb
->Width
* cpp
;
390 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
391 __DRIdrawable
*dPriv
= xrb
->dPriv
;
392 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
394 xrb
->map_mode
= mode
;
401 xrb
->Base
.Buffer
= malloc(h
* stride
);
403 sPriv
->swrast_loader
->getImage(dPriv
, x
, rb
->Height
- y
- h
, w
, h
,
404 (char *) xrb
->Base
.Buffer
,
405 dPriv
->loaderPrivate
);
407 *out_map
= xrb
->Base
.Buffer
+ (h
- 1) * stride
;
408 *out_stride
= -stride
;
412 ASSERT(xrb
->Base
.Buffer
);
414 if (rb
->AllocStorage
== swrast_alloc_back_storage
) {
415 map
+= (rb
->Height
- 1) * stride
;
419 map
+= (GLsizei
)y
* stride
;
420 map
+= (GLsizei
)x
* cpp
;
423 *out_stride
= stride
;
427 swrast_unmap_renderbuffer(struct gl_context
*ctx
,
428 struct gl_renderbuffer
*rb
)
430 struct dri_swrast_renderbuffer
*xrb
= dri_swrast_renderbuffer(rb
);
432 if (rb
->AllocStorage
== swrast_alloc_front_storage
) {
433 __DRIdrawable
*dPriv
= xrb
->dPriv
;
434 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
436 if (xrb
->map_mode
& GL_MAP_WRITE_BIT
) {
437 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_DRAW
,
438 xrb
->map_x
, xrb
->map_y
,
439 xrb
->map_w
, xrb
->map_h
,
440 (char *) xrb
->Base
.Buffer
,
441 dPriv
->loaderPrivate
);
444 free(xrb
->Base
.Buffer
);
445 xrb
->Base
.Buffer
= NULL
;
450 dri_create_buffer(__DRIscreen
* sPriv
,
451 __DRIdrawable
* dPriv
,
452 const struct gl_config
* visual
, GLboolean isPixmap
)
454 struct dri_drawable
*drawable
= NULL
;
455 struct gl_framebuffer
*fb
;
456 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
463 drawable
= CALLOC_STRUCT(dri_drawable
);
464 if (drawable
== NULL
)
467 dPriv
->driverPrivate
= drawable
;
468 drawable
->dPriv
= dPriv
;
470 drawable
->row
= malloc(SWRAST_MAX_WIDTH
* 4);
471 if (drawable
->row
== NULL
)
474 fb
= &drawable
->Base
;
476 /* basic framebuffer setup */
477 _mesa_initialize_window_framebuffer(fb
, visual
);
479 /* add front renderbuffer */
480 frontrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_TRUE
);
481 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &frontrb
->Base
.Base
);
483 /* add back renderbuffer */
484 if (visual
->doubleBufferMode
) {
485 backrb
= swrast_new_renderbuffer(visual
, dPriv
, GL_FALSE
);
486 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &backrb
->Base
.Base
);
489 /* add software renderbuffers */
490 _swrast_add_soft_renderbuffers(fb
,
491 GL_FALSE
, /* color */
492 visual
->haveDepthBuffer
,
493 visual
->haveStencilBuffer
,
494 visual
->haveAccumBuffer
,
495 GL_FALSE
, /* alpha */
496 GL_FALSE
/* aux bufs */);
511 dri_destroy_buffer(__DRIdrawable
* dPriv
)
516 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
517 struct gl_framebuffer
*fb
;
521 fb
= &drawable
->Base
;
523 fb
->DeletePending
= GL_TRUE
;
524 _mesa_reference_framebuffer(&fb
, NULL
);
529 dri_swap_buffers(__DRIdrawable
* dPriv
)
531 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
533 GET_CURRENT_CONTEXT(ctx
);
535 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
536 struct gl_framebuffer
*fb
;
537 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
541 fb
= &drawable
->Base
;
544 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
546 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_BACK_LEFT
].Renderbuffer
);
548 /* check for signle-buffered */
552 /* check if swapping currently bound buffer */
553 if (ctx
&& ctx
->DrawBuffer
== fb
) {
554 /* flush pending rendering */
555 _mesa_notifySwapBuffers(ctx
);
558 sPriv
->swrast_loader
->putImage(dPriv
, __DRI_SWRAST_IMAGE_OP_SWAP
,
560 frontrb
->Base
.Base
.Width
,
561 frontrb
->Base
.Base
.Height
,
562 (char *) backrb
->Base
.Buffer
,
563 dPriv
->loaderPrivate
);
568 * General device driver functions.
572 get_window_size( struct gl_framebuffer
*fb
, GLsizei
*w
, GLsizei
*h
)
574 __DRIdrawable
*dPriv
= swrast_drawable(fb
)->dPriv
;
575 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
578 sPriv
->swrast_loader
->getDrawableInfo(dPriv
,
580 dPriv
->loaderPrivate
);
584 swrast_check_and_update_window_size( struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
586 GLsizei width
, height
;
588 get_window_size(fb
, &width
, &height
);
589 if (fb
->Width
!= width
|| fb
->Height
!= height
) {
590 _mesa_resize_framebuffer(ctx
, fb
, width
, height
);
594 static const GLubyte
*
595 get_string(struct gl_context
*ctx
, GLenum pname
)
600 return (const GLubyte
*) "Mesa Project";
602 return (const GLubyte
*) "Software Rasterizer";
609 update_state( struct gl_context
*ctx
, GLuint new_state
)
611 /* not much to do here - pass it on */
612 _swrast_InvalidateState( ctx
, new_state
);
613 _swsetup_InvalidateState( ctx
, new_state
);
614 _vbo_InvalidateState( ctx
, new_state
);
615 _tnl_InvalidateState( ctx
, new_state
);
619 viewport(struct gl_context
*ctx
)
621 struct gl_framebuffer
*draw
= ctx
->WinSysDrawBuffer
;
622 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 mesa_format
swrastChooseTextureFormat(struct gl_context
* ctx
,
630 GLint internalFormat
,
634 if (internalFormat
== GL_RGB
)
635 return MESA_FORMAT_B8G8R8X8_UNORM
;
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
->Viewport
= viewport
;
645 driver
->ChooseTextureFormat
= swrastChooseTextureFormat
;
646 driver
->MapRenderbuffer
= swrast_map_renderbuffer
;
647 driver
->UnmapRenderbuffer
= swrast_unmap_renderbuffer
;
651 * Context-related functions.
655 dri_create_context(gl_api api
,
656 const struct gl_config
* visual
,
657 __DRIcontext
* cPriv
,
658 unsigned major_version
,
659 unsigned minor_version
,
663 void *sharedContextPrivate
)
665 struct dri_context
*ctx
= NULL
;
666 struct dri_context
*share
= (struct dri_context
*)sharedContextPrivate
;
667 struct gl_context
*mesaCtx
= NULL
;
668 struct gl_context
*sharedCtx
= NULL
;
669 struct dd_function_table functions
;
673 /* Flag filtering is handled in dri2CreateContextAttribs.
677 ctx
= CALLOC_STRUCT(dri_context
);
679 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
683 cPriv
->driverPrivate
= ctx
;
686 /* build table of device driver functions */
687 _mesa_init_driver_functions(&functions
);
688 swrast_init_driver_functions(&functions
);
691 sharedCtx
= &share
->Base
;
694 mesaCtx
= &ctx
->Base
;
696 /* basic context setup */
697 if (!_mesa_initialize_context(mesaCtx
, api
, visual
, sharedCtx
, &functions
)) {
698 *error
= __DRI_CTX_ERROR_NO_MEMORY
;
702 driContextSetFlags(mesaCtx
, flags
);
704 /* do bounds checking to prevent segfaults and server crashes! */
705 mesaCtx
->Const
.CheckArrayBounds
= GL_TRUE
;
707 /* create module contexts */
708 _swrast_CreateContext( mesaCtx
);
709 _vbo_CreateContext( mesaCtx
);
710 _tnl_CreateContext( mesaCtx
);
711 _swsetup_CreateContext( mesaCtx
);
712 _swsetup_Wakeup( mesaCtx
);
714 /* use default TCL pipeline */
716 TNLcontext
*tnl
= TNL_CONTEXT(mesaCtx
);
717 tnl
->Driver
.RunPipeline
= _tnl_run_pipeline
;
720 _mesa_meta_init(mesaCtx
);
721 _mesa_enable_sw_extensions(mesaCtx
);
723 _mesa_compute_version(mesaCtx
);
725 _mesa_initialize_dispatch_tables(mesaCtx
);
726 _mesa_initialize_vbo_vtxfmt(mesaCtx
);
728 *error
= __DRI_CTX_ERROR_SUCCESS
;
739 dri_destroy_context(__DRIcontext
* cPriv
)
744 struct dri_context
*ctx
= dri_context(cPriv
);
745 struct gl_context
*mesaCtx
;
747 mesaCtx
= &ctx
->Base
;
749 _mesa_meta_free(mesaCtx
);
750 _swsetup_DestroyContext( mesaCtx
);
751 _swrast_DestroyContext( mesaCtx
);
752 _tnl_DestroyContext( mesaCtx
);
753 _vbo_DestroyContext( mesaCtx
);
754 _mesa_destroy_context( mesaCtx
);
759 dri_make_current(__DRIcontext
* cPriv
,
760 __DRIdrawable
* driDrawPriv
,
761 __DRIdrawable
* driReadPriv
)
763 struct gl_context
*mesaCtx
;
764 struct gl_framebuffer
*mesaDraw
;
765 struct gl_framebuffer
*mesaRead
;
769 struct dri_context
*ctx
= dri_context(cPriv
);
770 struct dri_drawable
*draw
;
771 struct dri_drawable
*read
;
773 if (!driDrawPriv
|| !driReadPriv
)
776 draw
= dri_drawable(driDrawPriv
);
777 read
= dri_drawable(driReadPriv
);
778 mesaCtx
= &ctx
->Base
;
779 mesaDraw
= &draw
->Base
;
780 mesaRead
= &read
->Base
;
782 /* check for same context and buffer */
783 if (mesaCtx
== _mesa_get_current_context()
784 && mesaCtx
->DrawBuffer
== mesaDraw
785 && mesaCtx
->ReadBuffer
== mesaRead
) {
789 _glapi_check_multithread();
791 swrast_check_and_update_window_size(mesaCtx
, mesaDraw
);
792 if (mesaRead
!= mesaDraw
)
793 swrast_check_and_update_window_size(mesaCtx
, mesaRead
);
795 _mesa_make_current( mesaCtx
,
801 _mesa_make_current( NULL
, NULL
, NULL
);
808 dri_unbind_context(__DRIcontext
* cPriv
)
813 /* Unset current context and dispath table */
814 _mesa_make_current(NULL
, NULL
, NULL
);
820 dri_copy_sub_buffer(__DRIdrawable
*dPriv
, int x
, int y
,
823 __DRIscreen
*sPriv
= dPriv
->driScreenPriv
;
826 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
827 struct gl_framebuffer
*fb
;
828 struct dri_swrast_renderbuffer
*frontrb
, *backrb
;
832 fb
= &drawable
->Base
;
835 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
837 dri_swrast_renderbuffer(fb
->Attachment
[BUFFER_BACK_LEFT
].Renderbuffer
);
839 /* check for signle-buffered */
843 iy
= frontrb
->Base
.Base
.Height
- y
- h
;
844 data
= (char *)backrb
->Base
.Buffer
+ (iy
* backrb
->pitch
) + (x
* ((backrb
->bpp
+ 7) / 8));
845 sPriv
->swrast_loader
->putImage2(dPriv
, __DRI_SWRAST_IMAGE_OP_SWAP
,
849 dPriv
->loaderPrivate
);
853 static const struct __DriverAPIRec swrast_driver_api
= {
854 .InitScreen
= dri_init_screen
,
855 .DestroyScreen
= dri_destroy_screen
,
856 .CreateContext
= dri_create_context
,
857 .DestroyContext
= dri_destroy_context
,
858 .CreateBuffer
= dri_create_buffer
,
859 .DestroyBuffer
= dri_destroy_buffer
,
860 .SwapBuffers
= dri_swap_buffers
,
861 .MakeCurrent
= dri_make_current
,
862 .UnbindContext
= dri_unbind_context
,
863 .CopySubBuffer
= dri_copy_sub_buffer
,
866 static const struct __DRIDriverVtableExtensionRec swrast_vtable
= {
867 .base
= { __DRI_DRIVER_VTABLE
, 1 },
868 .vtable
= &swrast_driver_api
,
871 static const __DRIextension
*swrast_driver_extensions
[] = {
872 &driCoreExtension
.base
,
873 &driSWRastExtension
.base
,
874 &driCopySubBufferExtension
.base
,
879 PUBLIC
const __DRIextension
**__driDriverGetExtensions_swrast(void)
881 globalDriverAPI
= &swrast_driver_api
;
883 return swrast_driver_extensions
;