2 * Mesa 3-D graphics library
5 * Copyright 2009, VMware, Inc.
7 * Copyright (C) 2010 LunarG Inc.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Keith Whitwell <keithw@vmware.com>
28 * Jakob Bornecrantz <wallbraker@gmail.com>
29 * Chia-I Wu <olv@lunarg.com>
32 #include "util/u_memory.h"
33 #include "util/u_inlines.h"
34 #include "util/u_format.h"
35 #include "util/u_debug.h"
36 #include "state_tracker/drm_driver.h"
38 #include "dri_screen.h"
39 #include "dri_context.h"
40 #include "dri_drawable.h"
41 #include "dri2_buffer.h"
44 * DRI2 flush extension.
47 dri2_flush_drawable(__DRIdrawable
*dPriv
)
49 dri_flush(dPriv
->driContextPriv
, dPriv
, __DRI2_FLUSH_DRAWABLE
, 0);
53 dri2_invalidate_drawable(__DRIdrawable
*dPriv
)
55 struct dri_drawable
*drawable
= dri_drawable(dPriv
);
57 dri2InvalidateDrawable(dPriv
);
58 drawable
->dPriv
->lastStamp
= drawable
->dPriv
->dri2
.stamp
;
60 p_atomic_inc(&drawable
->base
.stamp
);
63 static const __DRI2flushExtension dri2FlushExtension
= {
64 { __DRI2_FLUSH
, __DRI2_FLUSH_VERSION
},
66 dri2_invalidate_drawable
,
71 * Retrieve __DRIbuffer from the DRI loader.
74 dri2_drawable_get_buffers(struct dri_drawable
*drawable
,
75 const enum st_attachment_type
*atts
,
78 __DRIdrawable
*dri_drawable
= drawable
->dPriv
;
79 struct __DRIdri2LoaderExtensionRec
*loader
= drawable
->sPriv
->dri2
.loader
;
83 unsigned attachments
[10];
84 unsigned num_attachments
, i
;
87 with_format
= dri_with_format(drawable
->sPriv
);
91 /* for Xserver 1.6.0 (DRI2 version 1) we always need to ask for the front */
93 attachments
[num_attachments
++] = __DRI_BUFFER_FRONT_LEFT
;
95 for (i
= 0; i
< *count
; i
++) {
96 enum pipe_format format
;
100 dri_drawable_get_format(drawable
, atts
[i
], &format
, &bind
);
101 if (format
== PIPE_FORMAT_NONE
)
105 case ST_ATTACHMENT_FRONT_LEFT
:
109 att
= __DRI_BUFFER_FRONT_LEFT
;
111 case ST_ATTACHMENT_BACK_LEFT
:
112 att
= __DRI_BUFFER_BACK_LEFT
;
114 case ST_ATTACHMENT_FRONT_RIGHT
:
115 att
= __DRI_BUFFER_FRONT_RIGHT
;
117 case ST_ATTACHMENT_BACK_RIGHT
:
118 att
= __DRI_BUFFER_BACK_RIGHT
;
125 * In this switch statement we must support all formats that
126 * may occur as the stvis->color_format.
129 case PIPE_FORMAT_B8G8R8A8_UNORM
:
132 case PIPE_FORMAT_B8G8R8X8_UNORM
:
135 case PIPE_FORMAT_B5G6R5_UNORM
:
139 depth
= util_format_get_blocksizebits(format
);
140 assert(!"Unexpected format in dri2_drawable_get_buffers()");
143 attachments
[num_attachments
++] = att
;
145 attachments
[num_attachments
++] = depth
;
150 num_attachments
/= 2;
151 buffers
= loader
->getBuffersWithFormat(dri_drawable
,
152 &dri_drawable
->w
, &dri_drawable
->h
,
153 attachments
, num_attachments
,
154 &num_buffers
, dri_drawable
->loaderPrivate
);
157 buffers
= loader
->getBuffers(dri_drawable
,
158 &dri_drawable
->w
, &dri_drawable
->h
,
159 attachments
, num_attachments
,
160 &num_buffers
, dri_drawable
->loaderPrivate
);
164 *count
= num_buffers
;
170 * Process __DRIbuffer and convert them into pipe_resources.
173 dri2_drawable_process_buffers(struct dri_drawable
*drawable
,
174 __DRIbuffer
*buffers
, unsigned buffer_count
,
175 const enum st_attachment_type
*atts
,
178 struct dri_screen
*screen
= dri_screen(drawable
->sPriv
);
179 __DRIdrawable
*dri_drawable
= drawable
->dPriv
;
180 struct pipe_resource templ
;
181 struct winsys_handle whandle
;
182 boolean alloc_depthstencil
= FALSE
;
185 if (drawable
->old_num
== buffer_count
&&
186 drawable
->old_w
== dri_drawable
->w
&&
187 drawable
->old_h
== dri_drawable
->h
&&
188 memcmp(drawable
->old
, buffers
, sizeof(__DRIbuffer
) * buffer_count
) == 0)
191 for (i
= 0; i
< ST_ATTACHMENT_COUNT
; i
++)
192 pipe_resource_reference(&drawable
->textures
[i
], NULL
);
193 for (i
= 0; i
< ST_ATTACHMENT_COUNT
; i
++)
194 pipe_resource_reference(&drawable
->msaa_textures
[i
], NULL
);
196 memset(&templ
, 0, sizeof(templ
));
197 templ
.target
= screen
->target
;
198 templ
.last_level
= 0;
199 templ
.width0
= dri_drawable
->w
;
200 templ
.height0
= dri_drawable
->h
;
202 templ
.array_size
= 1;
204 memset(&whandle
, 0, sizeof(whandle
));
206 /* Process DRI-provided buffers and get pipe_resources. */
207 for (i
= 0; i
< buffer_count
; i
++) {
208 __DRIbuffer
*buf
= &buffers
[i
];
209 enum st_attachment_type statt
;
210 enum pipe_format format
;
212 switch (buf
->attachment
) {
213 case __DRI_BUFFER_FRONT_LEFT
:
214 if (!screen
->auto_fake_front
) {
215 continue; /* invalid attachment */
218 case __DRI_BUFFER_FAKE_FRONT_LEFT
:
219 statt
= ST_ATTACHMENT_FRONT_LEFT
;
221 case __DRI_BUFFER_BACK_LEFT
:
222 statt
= ST_ATTACHMENT_BACK_LEFT
;
225 continue; /* invalid attachment */
228 dri_drawable_get_format(drawable
, statt
, &format
, &bind
);
229 if (format
== PIPE_FORMAT_NONE
)
232 templ
.format
= format
;
234 whandle
.handle
= buf
->name
;
235 whandle
.stride
= buf
->pitch
;
237 drawable
->textures
[statt
] =
238 screen
->base
.screen
->resource_from_handle(screen
->base
.screen
,
240 assert(drawable
->textures
[statt
]);
243 /* Allocate private MSAA colorbuffers. */
244 if (drawable
->stvis
.samples
> 1) {
245 for (i
= 0; i
< att_count
; i
++) {
246 enum st_attachment_type att
= atts
[i
];
248 if (drawable
->textures
[att
]) {
249 templ
.format
= drawable
->textures
[att
]->format
;
250 templ
.bind
= drawable
->textures
[att
]->bind
;
251 templ
.nr_samples
= drawable
->stvis
.samples
;
253 drawable
->msaa_textures
[att
] =
254 screen
->base
.screen
->resource_create(screen
->base
.screen
,
256 assert(drawable
->msaa_textures
[att
]);
261 /* See if we need a depth-stencil buffer. */
262 for (i
= 0; i
< att_count
; i
++) {
263 if (atts
[i
] == ST_ATTACHMENT_DEPTH_STENCIL
) {
264 alloc_depthstencil
= TRUE
;
269 /* Allocate a private depth-stencil buffer. */
270 if (alloc_depthstencil
) {
271 enum pipe_format format
;
274 dri_drawable_get_format(drawable
, ST_ATTACHMENT_DEPTH_STENCIL
,
277 templ
.format
= format
;
280 if (drawable
->stvis
.samples
> 1) {
281 templ
.nr_samples
= drawable
->stvis
.samples
;
282 drawable
->msaa_textures
[ST_ATTACHMENT_DEPTH_STENCIL
] =
283 screen
->base
.screen
->resource_create(screen
->base
.screen
,
285 assert(drawable
->msaa_textures
[ST_ATTACHMENT_DEPTH_STENCIL
]);
288 templ
.nr_samples
= 0;
289 drawable
->textures
[ST_ATTACHMENT_DEPTH_STENCIL
] =
290 screen
->base
.screen
->resource_create(screen
->base
.screen
,
292 assert(drawable
->textures
[ST_ATTACHMENT_DEPTH_STENCIL
]);
297 drawable
->old_num
= buffer_count
;
298 drawable
->old_w
= dri_drawable
->w
;
299 drawable
->old_h
= dri_drawable
->h
;
300 memcpy(drawable
->old
, buffers
, sizeof(__DRIbuffer
) * buffer_count
);
304 dri2_allocate_buffer(__DRIscreen
*sPriv
,
305 unsigned attachment
, unsigned format
,
306 int width
, int height
)
308 struct dri_screen
*screen
= dri_screen(sPriv
);
309 struct dri2_buffer
*buffer
;
310 struct pipe_resource templ
;
313 struct winsys_handle whandle
;
315 switch (attachment
) {
316 case __DRI_BUFFER_FRONT_LEFT
:
317 case __DRI_BUFFER_FAKE_FRONT_LEFT
:
318 bind
= PIPE_BIND_RENDER_TARGET
| PIPE_BIND_SAMPLER_VIEW
;
320 case __DRI_BUFFER_BACK_LEFT
:
321 bind
= PIPE_BIND_RENDER_TARGET
| PIPE_BIND_SAMPLER_VIEW
;
323 case __DRI_BUFFER_DEPTH
:
324 case __DRI_BUFFER_DEPTH_STENCIL
:
325 case __DRI_BUFFER_STENCIL
:
326 bind
= PIPE_BIND_DEPTH_STENCIL
; /* XXX sampler? */
330 /* because we get the handle and stride */
331 bind
|= PIPE_BIND_SHARED
;
335 pf
= PIPE_FORMAT_B8G8R8A8_UNORM
;
338 pf
= PIPE_FORMAT_B8G8R8X8_UNORM
;
341 pf
= PIPE_FORMAT_Z16_UNORM
;
347 buffer
= CALLOC_STRUCT(dri2_buffer
);
351 memset(&templ
, 0, sizeof(templ
));
354 templ
.target
= PIPE_TEXTURE_2D
;
355 templ
.last_level
= 0;
356 templ
.width0
= width
;
357 templ
.height0
= height
;
359 templ
.array_size
= 1;
362 screen
->base
.screen
->resource_create(screen
->base
.screen
, &templ
);
363 if (!buffer
->resource
) {
368 memset(&whandle
, 0, sizeof(whandle
));
369 whandle
.type
= DRM_API_HANDLE_TYPE_SHARED
;
370 screen
->base
.screen
->resource_get_handle(screen
->base
.screen
,
371 buffer
->resource
, &whandle
);
373 buffer
->base
.attachment
= attachment
;
374 buffer
->base
.name
= whandle
.handle
;
375 buffer
->base
.cpp
= util_format_get_blocksize(pf
);
376 buffer
->base
.pitch
= whandle
.stride
;
378 return &buffer
->base
;
382 dri2_release_buffer(__DRIscreen
*sPriv
, __DRIbuffer
*bPriv
)
384 struct dri2_buffer
*buffer
= dri2_buffer(bPriv
);
386 pipe_resource_reference(&buffer
->resource
, NULL
);
391 * Backend functions for st_framebuffer interface.
395 dri2_allocate_textures(struct dri_drawable
*drawable
,
396 const enum st_attachment_type
*statts
,
397 unsigned statts_count
)
399 __DRIbuffer
*buffers
;
400 unsigned num_buffers
= statts_count
;
402 buffers
= dri2_drawable_get_buffers(drawable
, statts
, &num_buffers
);
404 dri2_drawable_process_buffers(drawable
, buffers
, num_buffers
,
405 statts
, statts_count
);
409 dri2_flush_frontbuffer(struct dri_context
*ctx
,
410 struct dri_drawable
*drawable
,
411 enum st_attachment_type statt
)
413 __DRIdrawable
*dri_drawable
= drawable
->dPriv
;
414 struct __DRIdri2LoaderExtensionRec
*loader
= drawable
->sPriv
->dri2
.loader
;
416 if (statt
!= ST_ATTACHMENT_FRONT_LEFT
)
419 if (drawable
->stvis
.samples
> 1) {
420 struct pipe_context
*pipe
= ctx
->st
->pipe
;
422 dri_msaa_resolve(ctx
, drawable
, ST_ATTACHMENT_FRONT_LEFT
);
423 pipe
->flush(pipe
, NULL
, 0);
426 if (loader
->flushFrontBuffer
) {
427 loader
->flushFrontBuffer(dri_drawable
, dri_drawable
->loaderPrivate
);
432 dri2_update_tex_buffer(struct dri_drawable
*drawable
,
433 struct dri_context
*ctx
,
434 struct pipe_resource
*res
)
440 dri2_lookup_egl_image(struct dri_screen
*screen
, void *handle
)
442 __DRIimageLookupExtension
*loader
= screen
->sPriv
->dri2
.image
;
445 if (!loader
->lookupEGLImage
)
448 img
= loader
->lookupEGLImage(screen
->sPriv
,
449 handle
, screen
->sPriv
->loaderPrivate
);
455 dri2_create_image_from_name(__DRIscreen
*_screen
,
456 int width
, int height
, int format
,
457 int name
, int pitch
, void *loaderPrivate
)
459 struct dri_screen
*screen
= dri_screen(_screen
);
461 struct pipe_resource templ
;
462 struct winsys_handle whandle
;
466 tex_usage
= PIPE_BIND_RENDER_TARGET
| PIPE_BIND_SAMPLER_VIEW
;
469 case __DRI_IMAGE_FORMAT_RGB565
:
470 pf
= PIPE_FORMAT_B5G6R5_UNORM
;
472 case __DRI_IMAGE_FORMAT_XRGB8888
:
473 pf
= PIPE_FORMAT_B8G8R8X8_UNORM
;
475 case __DRI_IMAGE_FORMAT_ARGB8888
:
476 pf
= PIPE_FORMAT_B8G8R8A8_UNORM
;
478 case __DRI_IMAGE_FORMAT_ABGR8888
:
479 pf
= PIPE_FORMAT_R8G8B8A8_UNORM
;
482 pf
= PIPE_FORMAT_NONE
;
485 if (pf
== PIPE_FORMAT_NONE
)
488 img
= CALLOC_STRUCT(__DRIimageRec
);
492 memset(&templ
, 0, sizeof(templ
));
493 templ
.bind
= tex_usage
;
495 templ
.target
= screen
->target
;
496 templ
.last_level
= 0;
497 templ
.width0
= width
;
498 templ
.height0
= height
;
500 templ
.array_size
= 1;
502 memset(&whandle
, 0, sizeof(whandle
));
503 whandle
.handle
= name
;
504 whandle
.stride
= pitch
* util_format_get_blocksize(pf
);
506 img
->texture
= screen
->base
.screen
->resource_from_handle(screen
->base
.screen
,
515 img
->dri_format
= format
;
516 img
->loader_private
= loaderPrivate
;
522 dri2_create_image_from_renderbuffer(__DRIcontext
*context
,
523 int renderbuffer
, void *loaderPrivate
)
525 struct dri_context
*ctx
= dri_context(context
);
527 if (!ctx
->st
->get_resource_for_egl_image
)
535 dri2_create_image(__DRIscreen
*_screen
,
536 int width
, int height
, int format
,
537 unsigned int use
, void *loaderPrivate
)
539 struct dri_screen
*screen
= dri_screen(_screen
);
541 struct pipe_resource templ
;
545 tex_usage
= PIPE_BIND_RENDER_TARGET
| PIPE_BIND_SAMPLER_VIEW
;
546 if (use
& __DRI_IMAGE_USE_SCANOUT
)
547 tex_usage
|= PIPE_BIND_SCANOUT
;
548 if (use
& __DRI_IMAGE_USE_SHARE
)
549 tex_usage
|= PIPE_BIND_SHARED
;
550 if (use
& __DRI_IMAGE_USE_CURSOR
) {
551 if (width
!= 64 || height
!= 64)
553 tex_usage
|= PIPE_BIND_CURSOR
;
557 case __DRI_IMAGE_FORMAT_RGB565
:
558 pf
= PIPE_FORMAT_B5G6R5_UNORM
;
560 case __DRI_IMAGE_FORMAT_XRGB8888
:
561 pf
= PIPE_FORMAT_B8G8R8X8_UNORM
;
563 case __DRI_IMAGE_FORMAT_ARGB8888
:
564 pf
= PIPE_FORMAT_B8G8R8A8_UNORM
;
566 case __DRI_IMAGE_FORMAT_ABGR8888
:
567 pf
= PIPE_FORMAT_R8G8B8A8_UNORM
;
570 pf
= PIPE_FORMAT_NONE
;
573 if (pf
== PIPE_FORMAT_NONE
)
576 img
= CALLOC_STRUCT(__DRIimageRec
);
580 memset(&templ
, 0, sizeof(templ
));
581 templ
.bind
= tex_usage
;
583 templ
.target
= PIPE_TEXTURE_2D
;
584 templ
.last_level
= 0;
585 templ
.width0
= width
;
586 templ
.height0
= height
;
588 templ
.array_size
= 1;
590 img
->texture
= screen
->base
.screen
->resource_create(screen
->base
.screen
, &templ
);
598 img
->dri_format
= format
;
599 img
->dri_components
= 0;
601 img
->loader_private
= loaderPrivate
;
606 dri2_query_image(__DRIimage
*image
, int attrib
, int *value
)
608 struct winsys_handle whandle
;
609 memset(&whandle
, 0, sizeof(whandle
));
612 case __DRI_IMAGE_ATTRIB_STRIDE
:
613 image
->texture
->screen
->resource_get_handle(image
->texture
->screen
,
614 image
->texture
, &whandle
);
615 *value
= whandle
.stride
;
617 case __DRI_IMAGE_ATTRIB_HANDLE
:
618 whandle
.type
= DRM_API_HANDLE_TYPE_KMS
;
619 image
->texture
->screen
->resource_get_handle(image
->texture
->screen
,
620 image
->texture
, &whandle
);
621 *value
= whandle
.handle
;
623 case __DRI_IMAGE_ATTRIB_NAME
:
624 whandle
.type
= DRM_API_HANDLE_TYPE_SHARED
;
625 image
->texture
->screen
->resource_get_handle(image
->texture
->screen
,
626 image
->texture
, &whandle
);
627 *value
= whandle
.handle
;
629 case __DRI_IMAGE_ATTRIB_FORMAT
:
630 *value
= image
->dri_format
;
632 case __DRI_IMAGE_ATTRIB_WIDTH
:
633 *value
= image
->texture
->width0
;
635 case __DRI_IMAGE_ATTRIB_HEIGHT
:
636 *value
= image
->texture
->height0
;
638 case __DRI_IMAGE_ATTRIB_COMPONENTS
:
639 if (image
->dri_components
== 0)
641 *value
= image
->dri_components
;
649 dri2_dup_image(__DRIimage
*image
, void *loaderPrivate
)
653 img
= CALLOC_STRUCT(__DRIimageRec
);
658 pipe_resource_reference(&img
->texture
, image
->texture
);
659 img
->level
= image
->level
;
660 img
->layer
= image
->layer
;
661 /* This should be 0 for sub images, but dup is also used for base images. */
662 img
->dri_components
= image
->dri_components
;
663 img
->loader_private
= loaderPrivate
;
669 dri2_validate_usage(__DRIimage
*image
, unsigned int use
)
672 * Gallium drivers are bad at adding usages to the resources
673 * once opened again in another process, which is the main use
674 * case for this, so we have to lie.
683 dri2_from_names(__DRIscreen
*screen
, int width
, int height
, int format
,
684 int *names
, int num_names
, int *strides
, int *offsets
,
688 int stride
, dri_components
;
696 case __DRI_IMAGE_FOURCC_RGB565
:
697 format
= __DRI_IMAGE_FORMAT_RGB565
;
698 dri_components
= __DRI_IMAGE_COMPONENTS_RGB
;
700 case __DRI_IMAGE_FOURCC_ARGB8888
:
701 format
= __DRI_IMAGE_FORMAT_ARGB8888
;
702 dri_components
= __DRI_IMAGE_COMPONENTS_RGBA
;
704 case __DRI_IMAGE_FOURCC_XRGB8888
:
705 format
= __DRI_IMAGE_FORMAT_XRGB8888
;
706 dri_components
= __DRI_IMAGE_COMPONENTS_RGB
;
708 case __DRI_IMAGE_FOURCC_ABGR8888
:
709 format
= __DRI_IMAGE_FORMAT_ABGR8888
;
710 dri_components
= __DRI_IMAGE_COMPONENTS_RGBA
;
712 case __DRI_IMAGE_FOURCC_XBGR8888
:
713 format
= __DRI_IMAGE_FORMAT_XBGR8888
;
714 dri_components
= __DRI_IMAGE_COMPONENTS_RGB
;
720 /* Strides are in bytes not pixels. */
721 stride
= strides
[0] /4;
723 img
= dri2_create_image_from_name(screen
, width
, height
, format
,
724 names
[0], stride
, loaderPrivate
);
728 img
->dri_components
= dri_components
;
733 dri2_from_planar(__DRIimage
*image
, int plane
, void *loaderPrivate
)
740 if (image
->dri_components
== 0)
743 img
= dri2_dup_image(image
, loaderPrivate
);
747 /* set this to 0 for sub images. */
748 img
->dri_components
= 0;
753 dri2_destroy_image(__DRIimage
*img
)
755 pipe_resource_reference(&img
->texture
, NULL
);
759 static struct __DRIimageExtensionRec dri2ImageExtension
= {
761 dri2_create_image_from_name
,
762 dri2_create_image_from_renderbuffer
,
773 * Backend function init_screen.
776 static const __DRIextension
*dri_screen_extensions
[] = {
777 &driTexBufferExtension
.base
,
778 &dri2FlushExtension
.base
,
779 &dri2ImageExtension
.base
,
780 &dri2ConfigQueryExtension
.base
,
781 &dri2ThrottleExtension
.base
,
786 * This is the driver specific part of the createNewScreen entry point.
788 * Returns the struct gl_config supported by this driver.
790 static const __DRIconfig
**
791 dri2_init_screen(__DRIscreen
* sPriv
)
793 const __DRIconfig
**configs
;
794 struct dri_screen
*screen
;
795 struct pipe_screen
*pscreen
;
796 const struct drm_conf_ret
*throttle_ret
= NULL
;
798 screen
= CALLOC_STRUCT(dri_screen
);
802 screen
->sPriv
= sPriv
;
803 screen
->fd
= sPriv
->fd
;
805 sPriv
->driverPrivate
= (void *)screen
;
807 pscreen
= driver_descriptor
.create_screen(screen
->fd
);
808 if (driver_descriptor
.configuration
)
809 throttle_ret
= driver_descriptor
.configuration(DRM_CONF_THROTTLE
);
811 if (throttle_ret
&& throttle_ret
->val
.val_int
!= -1) {
812 screen
->throttling_enabled
= TRUE
;
813 screen
->default_throttle_frames
= throttle_ret
->val
.val_int
;
816 sPriv
->extensions
= dri_screen_extensions
;
818 /* dri_init_screen_helper checks pscreen for us */
820 configs
= dri_init_screen_helper(screen
, pscreen
);
825 if (screen
->st_api
->profile_mask
& ST_PROFILE_DEFAULT_MASK
)
826 sPriv
->api_mask
|= 1 << __DRI_API_OPENGL
;
827 if (screen
->st_api
->profile_mask
& ST_PROFILE_OPENGL_ES1_MASK
)
828 sPriv
->api_mask
|= 1 << __DRI_API_GLES
;
829 if (screen
->st_api
->profile_mask
& ST_PROFILE_OPENGL_ES2_MASK
)
830 sPriv
->api_mask
|= 1 << __DRI_API_GLES2
;
832 screen
->auto_fake_front
= dri_with_format(sPriv
);
833 screen
->broken_invalidate
= !sPriv
->dri2
.useInvalidate
;
834 screen
->lookup_egl_image
= dri2_lookup_egl_image
;
838 dri_destroy_screen_helper(screen
);
844 dri2_create_buffer(__DRIscreen
* sPriv
,
845 __DRIdrawable
* dPriv
,
846 const struct gl_config
* visual
, boolean isPixmap
)
848 struct dri_drawable
*drawable
= NULL
;
850 if (!dri_create_buffer(sPriv
, dPriv
, visual
, isPixmap
))
853 drawable
= dPriv
->driverPrivate
;
855 drawable
->allocate_textures
= dri2_allocate_textures
;
856 drawable
->flush_frontbuffer
= dri2_flush_frontbuffer
;
857 drawable
->update_tex_buffer
= dri2_update_tex_buffer
;
863 * DRI driver virtual function table.
865 * DRI versions differ in their implementation of init_screen and swap_buffers.
867 const struct __DriverAPIRec driDriverAPI
= {
868 .InitScreen
= dri2_init_screen
,
869 .DestroyScreen
= dri_destroy_screen
,
870 .CreateContext
= dri_create_context
,
871 .DestroyContext
= dri_destroy_context
,
872 .CreateBuffer
= dri2_create_buffer
,
873 .DestroyBuffer
= dri_destroy_buffer
,
874 .MakeCurrent
= dri_make_current
,
875 .UnbindContext
= dri_unbind_context
,
877 .AllocateBuffer
= dri2_allocate_buffer
,
878 .ReleaseBuffer
= dri2_release_buffer
,
881 /* This is the table of extensions that the loader will dlsym() for. */
882 PUBLIC
const __DRIextension
*__driDriverExtensions
[] = {
883 &driCoreExtension
.base
,
884 &driDRI2Extension
.base
,
888 /* vim: set sw=3 ts=8 sts=3 expandtab: */