1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include "main/glheader.h"
30 #include "main/context.h"
31 #include "main/framebuffer.h"
32 #include "main/renderbuffer.h"
33 #include "main/hash.h"
34 #include "main/fbobject.h"
35 #include "main/mfeatures.h"
40 PUBLIC
const char __driConfigOptions
[] =
42 DRI_CONF_SECTION_PERFORMANCE
43 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC
)
44 /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
45 * DRI_CONF_BO_REUSE_ALL
47 DRI_CONF_OPT_BEGIN_V(bo_reuse
, enum, 1, "0:1")
48 DRI_CONF_DESC_BEGIN(en
, "Buffer object reuse")
49 DRI_CONF_ENUM(0, "Disable buffer object reuse")
50 DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
54 DRI_CONF_OPT_BEGIN(texture_tiling
, bool, true)
55 DRI_CONF_DESC(en
, "Enable texture tiling")
58 DRI_CONF_OPT_BEGIN(early_z
, bool, false)
59 DRI_CONF_DESC(en
, "Enable early Z in classic mode (unstable, 945-only).")
62 DRI_CONF_OPT_BEGIN(fragment_shader
, bool, true)
63 DRI_CONF_DESC(en
, "Enable limited ARB_fragment_shader support on 915/945.")
67 DRI_CONF_SECTION_QUALITY
68 DRI_CONF_FORCE_S3TC_ENABLE(false)
69 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
71 DRI_CONF_SECTION_DEBUG
72 DRI_CONF_NO_RAST(false)
73 DRI_CONF_ALWAYS_FLUSH_BATCH(false)
74 DRI_CONF_ALWAYS_FLUSH_CACHE(false)
76 DRI_CONF_OPT_BEGIN(stub_occlusion_query
, bool, false)
77 DRI_CONF_DESC(en
, "Enable stub ARB_occlusion_query support on 915/945.")
82 const GLuint __driNConfigOptions
= 11;
84 #include "intel_batchbuffer.h"
85 #include "intel_buffers.h"
86 #include "intel_bufmgr.h"
87 #include "intel_chipset.h"
88 #include "intel_fbo.h"
89 #include "intel_screen.h"
90 #include "intel_tex.h"
91 #include "intel_regions.h"
95 #ifdef USE_NEW_INTERFACE
96 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
97 #endif /*USE_NEW_INTERFACE */
99 static const __DRItexBufferExtension intelTexBufferExtension
= {
100 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
106 intelDRI2Flush(__DRIdrawable
*drawable
)
108 GET_CURRENT_CONTEXT(ctx
);
109 struct intel_context
*intel
= intel_context(ctx
);
112 INTEL_FIREVERTICES(intel
);
114 intel
->need_throttle
= GL_TRUE
;
116 if (intel
->batch
.used
)
117 intel_batchbuffer_flush(intel
);
120 static const struct __DRI2flushExtensionRec intelFlushExtension
= {
121 { __DRI2_FLUSH
, __DRI2_FLUSH_VERSION
},
123 dri2InvalidateDrawable
,
127 intel_create_image_from_name(__DRIscreen
*screen
,
128 int width
, int height
, int format
,
129 int name
, int pitch
, void *loaderPrivate
)
131 struct intel_screen
*intelScreen
= screen
->private;
135 image
= CALLOC(sizeof *image
);
140 case __DRI_IMAGE_FORMAT_RGB565
:
141 image
->format
= MESA_FORMAT_RGB565
;
142 image
->internal_format
= GL_RGB
;
143 image
->data_type
= GL_UNSIGNED_BYTE
;
145 case __DRI_IMAGE_FORMAT_XRGB8888
:
146 image
->format
= MESA_FORMAT_XRGB8888
;
147 image
->internal_format
= GL_RGB
;
148 image
->data_type
= GL_UNSIGNED_BYTE
;
150 case __DRI_IMAGE_FORMAT_ARGB8888
:
151 image
->format
= MESA_FORMAT_ARGB8888
;
152 image
->internal_format
= GL_RGBA
;
153 image
->data_type
= GL_UNSIGNED_BYTE
;
155 case __DRI_IMAGE_FORMAT_ABGR8888
:
156 image
->format
= MESA_FORMAT_RGBA8888_REV
;
157 image
->internal_format
= GL_RGBA
;
158 image
->data_type
= GL_UNSIGNED_BYTE
;
165 image
->data
= loaderPrivate
;
166 cpp
= _mesa_get_format_bytes(image
->format
);
168 image
->region
= intel_region_alloc_for_handle(intelScreen
,
170 pitch
, name
, "image");
171 if (image
->region
== NULL
) {
180 intel_create_image_from_renderbuffer(__DRIcontext
*context
,
181 int renderbuffer
, void *loaderPrivate
)
184 struct intel_context
*intel
= context
->driverPrivate
;
185 struct gl_renderbuffer
*rb
;
186 struct intel_renderbuffer
*irb
;
188 rb
= _mesa_lookup_renderbuffer(&intel
->ctx
, renderbuffer
);
190 _mesa_error(&intel
->ctx
,
191 GL_INVALID_OPERATION
, "glRenderbufferExternalMESA");
195 irb
= intel_renderbuffer(rb
);
196 image
= CALLOC(sizeof *image
);
200 image
->internal_format
= rb
->InternalFormat
;
201 image
->format
= rb
->Format
;
202 image
->data_type
= rb
->DataType
;
203 image
->data
= loaderPrivate
;
204 intel_region_reference(&image
->region
, irb
->region
);
210 intel_destroy_image(__DRIimage
*image
)
212 intel_region_release(&image
->region
);
217 intel_create_image(__DRIscreen
*screen
,
218 int width
, int height
, int format
,
223 struct intel_screen
*intelScreen
= screen
->private;
227 tiling
= I915_TILING_X
;
228 if (use
& __DRI_IMAGE_USE_CURSOR
) {
229 if (width
!= 64 || height
!= 64)
231 tiling
= I915_TILING_NONE
;
234 image
= CALLOC(sizeof *image
);
239 case __DRI_IMAGE_FORMAT_RGB565
:
240 image
->format
= MESA_FORMAT_RGB565
;
241 image
->internal_format
= GL_RGB
;
242 image
->data_type
= GL_UNSIGNED_BYTE
;
244 case __DRI_IMAGE_FORMAT_XRGB8888
:
245 image
->format
= MESA_FORMAT_XRGB8888
;
246 image
->internal_format
= GL_RGB
;
247 image
->data_type
= GL_UNSIGNED_BYTE
;
249 case __DRI_IMAGE_FORMAT_ARGB8888
:
250 image
->format
= MESA_FORMAT_ARGB8888
;
251 image
->internal_format
= GL_RGBA
;
252 image
->data_type
= GL_UNSIGNED_BYTE
;
254 case __DRI_IMAGE_FORMAT_ABGR8888
:
255 image
->format
= MESA_FORMAT_RGBA8888_REV
;
256 image
->internal_format
= GL_RGBA
;
257 image
->data_type
= GL_UNSIGNED_BYTE
;
264 image
->data
= loaderPrivate
;
265 cpp
= _mesa_get_format_bytes(image
->format
);
268 intel_region_alloc(intelScreen
, tiling
,
269 cpp
, width
, height
, GL_TRUE
);
270 if (image
->region
== NULL
) {
279 intel_query_image(__DRIimage
*image
, int attrib
, int *value
)
282 case __DRI_IMAGE_ATTRIB_STRIDE
:
283 *value
= image
->region
->pitch
* image
->region
->cpp
;
285 case __DRI_IMAGE_ATTRIB_HANDLE
:
286 *value
= image
->region
->buffer
->handle
;
288 case __DRI_IMAGE_ATTRIB_NAME
:
289 return intel_region_flink(image
->region
, (uint32_t *) value
);
296 intel_dup_image(__DRIimage
*orig_image
, void *loaderPrivate
)
300 image
= CALLOC(sizeof *image
);
304 intel_region_reference(&image
->region
, orig_image
->region
);
305 if (image
->region
== NULL
) {
310 image
->internal_format
= orig_image
->internal_format
;
311 image
->format
= orig_image
->format
;
312 image
->data_type
= orig_image
->data_type
;
313 image
->data
= loaderPrivate
;
318 static struct __DRIimageExtensionRec intelImageExtension
= {
319 { __DRI_IMAGE
, __DRI_IMAGE_VERSION
},
320 intel_create_image_from_name
,
321 intel_create_image_from_renderbuffer
,
328 static const __DRIextension
*intelScreenExtensions
[] = {
329 &driReadDrawableExtension
,
330 &intelTexBufferExtension
.base
,
331 &intelFlushExtension
.base
,
332 &intelImageExtension
.base
,
333 &dri2ConfigQueryExtension
.base
,
338 intel_get_param(__DRIscreen
*psp
, int param
, int *value
)
341 struct drm_i915_getparam gp
;
346 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
349 _mesa_warning(NULL
, "drm_i915_getparam: %d", ret
);
357 intel_get_boolean(__DRIscreen
*psp
, int param
)
360 return intel_get_param(psp
, param
, &value
) && value
;
364 nop_callback(GLuint key
, void *data
, void *userData
)
369 intelDestroyScreen(__DRIscreen
* sPriv
)
371 struct intel_screen
*intelScreen
= sPriv
->private;
373 dri_bufmgr_destroy(intelScreen
->bufmgr
);
374 driDestroyOptionInfo(&intelScreen
->optionCache
);
376 /* Some regions may still have references to them at this point, so
377 * flush the hash table to prevent _mesa_DeleteHashTable() from
378 * complaining about the hash not being empty; */
379 _mesa_HashDeleteAll(intelScreen
->named_regions
, nop_callback
, NULL
);
380 _mesa_DeleteHashTable(intelScreen
->named_regions
);
383 sPriv
->private = NULL
;
388 * This is called when we need to set up GL rendering to a new X window.
391 intelCreateBuffer(__DRIscreen
* driScrnPriv
,
392 __DRIdrawable
* driDrawPriv
,
393 const struct gl_config
* mesaVis
, GLboolean isPixmap
)
395 struct intel_renderbuffer
*rb
;
396 struct intel_screen
*screen
= (struct intel_screen
*) driScrnPriv
->private;
399 return GL_FALSE
; /* not implemented */
404 struct gl_framebuffer
*fb
= CALLOC_STRUCT(gl_framebuffer
);
409 _mesa_initialize_window_framebuffer(fb
, mesaVis
);
411 if (mesaVis
->redBits
== 5)
412 rgbFormat
= MESA_FORMAT_RGB565
;
413 else if (mesaVis
->alphaBits
== 0)
414 rgbFormat
= MESA_FORMAT_XRGB8888
;
416 rgbFormat
= MESA_FORMAT_ARGB8888
;
418 /* setup the hardware-based renderbuffers */
419 rb
= intel_create_renderbuffer(rgbFormat
);
420 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &rb
->Base
);
422 if (mesaVis
->doubleBufferMode
) {
423 rb
= intel_create_renderbuffer(rgbFormat
);
424 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &rb
->Base
);
428 * Assert here that the gl_config has an expected depth/stencil bit
429 * combination: one of d24/s8, d16/s0, d0/s0. (See intelInitScreen2(),
430 * which constructs the advertised configs.)
432 if (mesaVis
->depthBits
== 24) {
433 assert(mesaVis
->stencilBits
== 8);
435 if (screen
->hw_has_separate_stencil
436 && screen
->dri2_has_hiz
!= INTEL_DRI2_HAS_HIZ_FALSE
) {
438 * Request a separate stencil buffer even if we do not yet know if
439 * the screen supports it. (See comments for
440 * enum intel_dri2_has_hiz).
442 rb
= intel_create_renderbuffer(MESA_FORMAT_X8_Z24
);
443 _mesa_add_renderbuffer(fb
, BUFFER_DEPTH
, &rb
->Base
);
444 rb
= intel_create_renderbuffer(MESA_FORMAT_S8
);
445 _mesa_add_renderbuffer(fb
, BUFFER_STENCIL
, &rb
->Base
);
448 * Use combined depth/stencil. Note that the renderbuffer is
449 * attached to two attachment points.
451 rb
= intel_create_renderbuffer(MESA_FORMAT_S8_Z24
);
452 _mesa_add_renderbuffer(fb
, BUFFER_DEPTH
, &rb
->Base
);
453 _mesa_add_renderbuffer(fb
, BUFFER_STENCIL
, &rb
->Base
);
456 else if (mesaVis
->depthBits
== 16) {
457 assert(mesaVis
->stencilBits
== 0);
458 /* just 16-bit depth buffer, no hw stencil */
459 struct intel_renderbuffer
*depthRb
460 = intel_create_renderbuffer(MESA_FORMAT_Z16
);
461 _mesa_add_renderbuffer(fb
, BUFFER_DEPTH
, &depthRb
->Base
);
464 assert(mesaVis
->depthBits
== 0);
465 assert(mesaVis
->stencilBits
== 0);
468 /* now add any/all software-based renderbuffers we may need */
469 _mesa_add_soft_renderbuffers(fb
,
470 GL_FALSE
, /* never sw color */
471 GL_FALSE
, /* never sw depth */
472 GL_FALSE
, /* never sw stencil */
473 mesaVis
->accumRedBits
> 0,
474 GL_FALSE
, /* never sw alpha */
475 GL_FALSE
/* never sw aux */ );
476 driDrawPriv
->driverPrivate
= fb
;
483 intelDestroyBuffer(__DRIdrawable
* driDrawPriv
)
485 struct gl_framebuffer
*fb
= driDrawPriv
->driverPrivate
;
487 _mesa_reference_framebuffer(&fb
, NULL
);
490 /* There are probably better ways to do this, such as an
491 * init-designated function to register chipids and createcontext
494 extern GLboolean
i830CreateContext(const struct gl_config
* mesaVis
,
495 __DRIcontext
* driContextPriv
,
496 void *sharedContextPrivate
);
498 extern GLboolean
i915CreateContext(int api
,
499 const struct gl_config
* mesaVis
,
500 __DRIcontext
* driContextPriv
,
501 void *sharedContextPrivate
);
502 extern GLboolean
brwCreateContext(int api
,
503 const struct gl_config
* mesaVis
,
504 __DRIcontext
* driContextPriv
,
505 void *sharedContextPrivate
);
508 intelCreateContext(gl_api api
,
509 const struct gl_config
* mesaVis
,
510 __DRIcontext
* driContextPriv
,
511 void *sharedContextPrivate
)
513 __DRIscreen
*sPriv
= driContextPriv
->driScreenPriv
;
514 struct intel_screen
*intelScreen
= sPriv
->private;
517 if (IS_9XX(intelScreen
->deviceID
)) {
518 if (!IS_965(intelScreen
->deviceID
)) {
519 return i915CreateContext(api
, mesaVis
, driContextPriv
,
520 sharedContextPrivate
);
523 intelScreen
->no_vbo
= GL_TRUE
;
524 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
527 if (IS_965(intelScreen
->deviceID
))
528 return brwCreateContext(api
, mesaVis
,
529 driContextPriv
, sharedContextPrivate
);
531 fprintf(stderr
, "Unrecognized deviceID 0x%x\n", intelScreen
->deviceID
);
536 intel_init_bufmgr(struct intel_screen
*intelScreen
)
538 __DRIscreen
*spriv
= intelScreen
->driScrnPriv
;
541 intelScreen
->no_hw
= (getenv("INTEL_NO_HW") != NULL
||
542 getenv("INTEL_DEVID_OVERRIDE") != NULL
);
544 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
545 if (intelScreen
->bufmgr
== NULL
) {
546 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
551 if (!intel_get_param(spriv
, I915_PARAM_NUM_FENCES_AVAIL
, &num_fences
) ||
553 fprintf(stderr
, "[%s: %u] Kernel 2.6.29 required.\n", __func__
, __LINE__
);
557 drm_intel_bufmgr_gem_enable_fenced_relocs(intelScreen
->bufmgr
);
559 intelScreen
->named_regions
= _mesa_NewHashTable();
561 intelScreen
->relaxed_relocations
= 0;
562 intelScreen
->relaxed_relocations
|=
563 intel_get_boolean(spriv
, I915_PARAM_HAS_RELAXED_DELTA
) << 0;
569 * Override intel_screen.hw_has_hiz with environment variable INTEL_HIZ.
571 * Valid values for INTEL_HIZ are "0" and "1". If an invalid valid value is
572 * encountered, a warning is emitted and INTEL_HIZ is ignored.
575 intel_override_hiz(struct intel_screen
*intel
)
577 const char *s
= getenv("INTEL_HIZ");
580 } else if (!strncmp("0", s
, 2)) {
581 intel
->hw_has_hiz
= false;
582 } else if (!strncmp("1", s
, 2)) {
583 intel
->hw_has_hiz
= true;
586 "warning: env variable INTEL_HIZ=\"%s\" has invalid value "
587 "and is ignored", s
);
592 * Override intel_screen.hw_has_separate_stencil with environment variable
593 * INTEL_SEPARATE_STENCIL.
595 * Valid values for INTEL_SEPARATE_STENCIL are "0" and "1". If an invalid
596 * valid value is encountered, a warning is emitted and INTEL_SEPARATE_STENCIL
600 intel_override_separate_stencil(struct intel_screen
*screen
)
602 const char *s
= getenv("INTEL_SEPARATE_STENCIL");
605 } else if (!strncmp("0", s
, 2)) {
606 screen
->hw_has_separate_stencil
= false;
607 } else if (!strncmp("1", s
, 2)) {
608 screen
->hw_has_separate_stencil
= true;
611 "warning: env variable INTEL_SEPARATE_STENCIL=\"%s\" has "
612 "invalid value and is ignored", s
);
617 * This is the driver specific part of the createNewScreen entry point.
618 * Called when using DRI2.
620 * \return the struct gl_config supported by this driver
623 __DRIconfig
**intelInitScreen2(__DRIscreen
*psp
)
625 struct intel_screen
*intelScreen
;
628 unsigned int api_mask
;
629 char *devid_override
;
631 static const GLenum back_buffer_modes
[] = {
632 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
634 uint8_t depth_bits
[4], stencil_bits
[4], msaa_samples_array
[1];
636 __DRIconfig
**configs
= NULL
;
638 /* Allocate the private area */
639 intelScreen
= CALLOC(sizeof *intelScreen
);
641 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
644 /* parse information in __driConfigOptions */
645 driParseOptionInfo(&intelScreen
->optionCache
,
646 __driConfigOptions
, __driNConfigOptions
);
648 intelScreen
->driScrnPriv
= psp
;
649 psp
->private = (void *) intelScreen
;
651 /* Determine chipset ID */
652 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
653 &intelScreen
->deviceID
))
656 /* Allow an override of the device ID for the purpose of making the
657 * driver produce dumps for debugging of new chipset enablement.
658 * This implies INTEL_NO_HW, to avoid programming your actual GPU
661 devid_override
= getenv("INTEL_DEVID_OVERRIDE");
662 if (devid_override
) {
663 intelScreen
->deviceID
= strtod(devid_override
, NULL
);
666 if (IS_GEN7(intelScreen
->deviceID
)) {
667 intelScreen
->gen
= 7;
668 } else if (IS_GEN6(intelScreen
->deviceID
)) {
669 intelScreen
->gen
= 6;
670 } else if (IS_GEN5(intelScreen
->deviceID
)) {
671 intelScreen
->gen
= 5;
672 } else if (IS_965(intelScreen
->deviceID
)) {
673 intelScreen
->gen
= 4;
674 } else if (IS_9XX(intelScreen
->deviceID
)) {
675 intelScreen
->gen
= 3;
677 intelScreen
->gen
= 2;
681 * FIXME: The hiz and separate stencil fields need updating once the
682 * FIXME: features are completely implemented for a given chipset.
684 intelScreen
->hw_has_separate_stencil
= intelScreen
->gen
>= 7;
685 intelScreen
->hw_must_use_separate_stencil
= intelScreen
->gen
>= 7;
686 intelScreen
->hw_has_hiz
= false;
687 intelScreen
->dri2_has_hiz
= INTEL_DRI2_HAS_HIZ_UNKNOWN
;
689 intel_override_hiz(intelScreen
);
690 intel_override_separate_stencil(intelScreen
);
692 api_mask
= (1 << __DRI_API_OPENGL
);
694 api_mask
|= (1 << __DRI_API_GLES
);
697 api_mask
|= (1 << __DRI_API_GLES2
);
700 if (IS_9XX(intelScreen
->deviceID
) || IS_965(intelScreen
->deviceID
))
701 psp
->api_mask
= api_mask
;
703 if (!intel_init_bufmgr(intelScreen
))
706 psp
->extensions
= intelScreenExtensions
;
708 msaa_samples_array
[0] = 0;
710 fb_format
[0] = GL_RGB
;
711 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
713 fb_format
[1] = GL_BGR
;
714 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
716 fb_format
[2] = GL_BGRA
;
717 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
722 /* Generate a rich set of useful configs that do not include an
723 * accumulation buffer.
725 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
726 __DRIconfig
**new_configs
;
729 /* Starting with DRI2 protocol version 1.1 we can request a depth/stencil
730 * buffer that has a diffferent number of bits per pixel than the color
731 * buffer. This isn't yet supported here.
733 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
743 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
748 ARRAY_SIZE(back_buffer_modes
),
750 ARRAY_SIZE(msaa_samples_array
),
753 configs
= new_configs
;
755 configs
= driConcatConfigs(configs
, new_configs
);
758 /* Generate the minimum possible set of configs that include an
759 * accumulation buffer.
761 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
762 __DRIconfig
**new_configs
;
764 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
772 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
773 depth_bits
, stencil_bits
, 1,
774 back_buffer_modes
+ 1, 1,
775 msaa_samples_array
, 1,
778 configs
= new_configs
;
780 configs
= driConcatConfigs(configs
, new_configs
);
783 if (configs
== NULL
) {
784 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
789 return (const __DRIconfig
**)configs
;
792 struct intel_buffer
{
794 struct intel_region
*region
;
798 intelAllocateBuffer(__DRIscreen
*screen
,
799 unsigned attachment
, unsigned format
,
800 int width
, int height
)
802 struct intel_buffer
*intelBuffer
;
803 struct intel_screen
*intelScreen
= screen
->private;
806 intelBuffer
= CALLOC(sizeof *intelBuffer
);
807 if (intelBuffer
== NULL
)
810 if ((attachment
== __DRI_BUFFER_DEPTH
||
811 attachment
== __DRI_BUFFER_STENCIL
||
812 attachment
== __DRI_BUFFER_DEPTH_STENCIL
) &&
813 intelScreen
->gen
>= 4)
814 tiling
= I915_TILING_Y
;
816 tiling
= I915_TILING_X
;
818 intelBuffer
->region
= intel_region_alloc(intelScreen
, tiling
,
819 format
/ 8, width
, height
, GL_TRUE
);
821 if (intelBuffer
->region
== NULL
) {
826 intel_region_flink(intelBuffer
->region
, &intelBuffer
->base
.name
);
828 intelBuffer
->base
.attachment
= attachment
;
829 intelBuffer
->base
.cpp
= intelBuffer
->region
->cpp
;
830 intelBuffer
->base
.pitch
=
831 intelBuffer
->region
->pitch
* intelBuffer
->region
->cpp
;
833 return &intelBuffer
->base
;
837 intelReleaseBuffer(__DRIscreen
*screen
, __DRIbuffer
*buffer
)
839 struct intel_buffer
*intelBuffer
= (struct intel_buffer
*) buffer
;
841 intel_region_release(&intelBuffer
->region
);
846 const struct __DriverAPIRec driDriverAPI
= {
847 .DestroyScreen
= intelDestroyScreen
,
848 .CreateContext
= intelCreateContext
,
849 .DestroyContext
= intelDestroyContext
,
850 .CreateBuffer
= intelCreateBuffer
,
851 .DestroyBuffer
= intelDestroyBuffer
,
852 .MakeCurrent
= intelMakeCurrent
,
853 .UnbindContext
= intelUnbindContext
,
854 .InitScreen2
= intelInitScreen2
,
855 .AllocateBuffer
= intelAllocateBuffer
,
856 .ReleaseBuffer
= intelReleaseBuffer
859 /* This is the table of extensions that the loader will dlsym() for. */
860 PUBLIC
const __DRIextension
*__driDriverExtensions
[] = {
861 &driCoreExtension
.base
,
862 &driDRI2Extension
.base
,