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 **************************************************************************/
28 #include "main/glheader.h"
29 #include "main/context.h"
30 #include "main/framebuffer.h"
31 #include "main/renderbuffer.h"
37 #include "intel_batchbuffer.h"
38 #include "intel_buffers.h"
39 #include "intel_bufmgr.h"
40 #include "intel_chipset.h"
41 #include "intel_extensions.h"
42 #include "intel_fbo.h"
43 #include "intel_regions.h"
44 #include "intel_swapbuffers.h"
45 #include "intel_screen.h"
46 #include "intel_span.h"
47 #include "intel_tex.h"
53 PUBLIC
const char __driConfigOptions
[] =
55 DRI_CONF_SECTION_PERFORMANCE
56 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS
)
57 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC
)
58 /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
59 * DRI_CONF_BO_REUSE_ALL
61 DRI_CONF_OPT_BEGIN_V(bo_reuse
, enum, 1, "0:1")
62 DRI_CONF_DESC_BEGIN(en
, "Buffer object reuse")
63 DRI_CONF_ENUM(0, "Disable buffer object reuse")
64 DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
68 DRI_CONF_SECTION_QUALITY
69 DRI_CONF_FORCE_S3TC_ENABLE(false)
70 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
72 DRI_CONF_SECTION_DEBUG
73 DRI_CONF_NO_RAST(false)
77 const GLuint __driNConfigOptions
= 6;
79 #ifdef USE_NEW_INTERFACE
80 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
81 #endif /*USE_NEW_INTERFACE */
84 * Map all the memory regions described by the screen.
85 * \return GL_TRUE if success, GL_FALSE if error.
88 intelMapScreenRegions(__DRIscreenPrivate
* sPriv
)
90 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
93 _mesa_printf("TEX 0x%08x ", intelScreen
->tex
.handle
);
94 if (intelScreen
->tex
.size
!= 0) {
96 intelScreen
->tex
.handle
,
97 intelScreen
->tex
.size
,
98 (drmAddress
*) & intelScreen
->tex
.map
) != 0) {
99 intelUnmapScreenRegions(intelScreen
);
108 intelUnmapScreenRegions(intelScreenPrivate
* intelScreen
)
110 if (intelScreen
->tex
.map
) {
111 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
112 intelScreen
->tex
.map
= NULL
;
118 intelPrintDRIInfo(intelScreenPrivate
* intelScreen
,
119 __DRIscreenPrivate
* sPriv
, I830DRIPtr gDRIPriv
)
121 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
122 intelScreen
->front
.size
, intelScreen
->front
.offset
,
124 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
125 intelScreen
->back
.size
, intelScreen
->back
.offset
,
127 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
128 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
130 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
131 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
132 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
137 intelPrintSAREA(const drm_i915_sarea_t
* sarea
)
139 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
,
141 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
143 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
144 sarea
->front_offset
, sarea
->front_size
,
145 (unsigned) sarea
->front_handle
, sarea
->front_tiled
);
147 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
148 sarea
->back_offset
, sarea
->back_size
,
149 (unsigned) sarea
->back_handle
, sarea
->back_tiled
);
150 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
151 sarea
->depth_offset
, sarea
->depth_size
,
152 (unsigned) sarea
->depth_handle
, sarea
->depth_tiled
);
153 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
154 sarea
->tex_offset
, sarea
->tex_size
, (unsigned) sarea
->tex_handle
);
159 * A number of the screen parameters are obtained/computed from
160 * information in the SAREA. This function updates those parameters.
163 intelUpdateScreenFromSAREA(intelScreenPrivate
* intelScreen
,
164 drm_i915_sarea_t
* sarea
)
166 intelScreen
->width
= sarea
->width
;
167 intelScreen
->height
= sarea
->height
;
168 intelScreen
->pitch
= sarea
->pitch
;
170 intelScreen
->front
.offset
= sarea
->front_offset
;
171 intelScreen
->front
.handle
= sarea
->front_handle
;
172 intelScreen
->front
.size
= sarea
->front_size
;
173 intelScreen
->front
.tiled
= sarea
->front_tiled
;
175 intelScreen
->back
.offset
= sarea
->back_offset
;
176 intelScreen
->back
.handle
= sarea
->back_handle
;
177 intelScreen
->back
.size
= sarea
->back_size
;
178 intelScreen
->back
.tiled
= sarea
->back_tiled
;
180 intelScreen
->depth
.offset
= sarea
->depth_offset
;
181 intelScreen
->depth
.handle
= sarea
->depth_handle
;
182 intelScreen
->depth
.size
= sarea
->depth_size
;
183 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
185 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9) {
186 intelScreen
->front
.bo_handle
= sarea
->front_bo_handle
;
187 intelScreen
->back
.bo_handle
= sarea
->back_bo_handle
;
188 intelScreen
->depth
.bo_handle
= sarea
->depth_bo_handle
;
190 intelScreen
->front
.bo_handle
= -1;
191 intelScreen
->back
.bo_handle
= -1;
192 intelScreen
->depth
.bo_handle
= -1;
195 intelScreen
->tex
.offset
= sarea
->tex_offset
;
196 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
197 intelScreen
->tex
.handle
= sarea
->tex_handle
;
198 intelScreen
->tex
.size
= sarea
->tex_size
;
201 intelPrintSAREA(sarea
);
204 static const __DRItexOffsetExtension intelTexOffsetExtension
= {
205 { __DRI_TEX_OFFSET
},
209 static const __DRItexBufferExtension intelTexBufferExtension
= {
210 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
214 static const __DRIextension
*intelScreenExtensions
[] = {
215 &driReadDrawableExtension
,
216 &driCopySubBufferExtension
.base
,
217 &driSwapControlExtension
.base
,
218 &driFrameTrackingExtension
.base
,
219 &driMediaStreamCounterExtension
.base
,
220 &intelTexOffsetExtension
.base
,
221 &intelTexBufferExtension
.base
,
226 intel_get_param(__DRIscreenPrivate
*psp
, int param
, int *value
)
229 struct drm_i915_getparam gp
;
234 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
236 fprintf(stderr
, "drm_i915_getparam: %d\n", ret
);
243 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
245 intelScreenPrivate
*intelScreen
;
246 I830DRIPtr gDRIPriv
= (I830DRIPtr
) sPriv
->pDevPriv
;
247 drm_i915_sarea_t
*sarea
;
249 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
251 "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
255 /* Allocate the private area */
256 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
258 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
261 /* parse information in __driConfigOptions */
262 driParseOptionInfo(&intelScreen
->optionCache
,
263 __driConfigOptions
, __driNConfigOptions
);
265 intelScreen
->driScrnPriv
= sPriv
;
266 sPriv
->private = (void *) intelScreen
;
267 sarea
= (drm_i915_sarea_t
*)
268 (((GLubyte
*) sPriv
->pSAREA
) + gDRIPriv
->sarea_priv_offset
);
269 intelScreen
->sarea
= sarea
;
271 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
273 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
275 if (!intelMapScreenRegions(sPriv
)) {
276 fprintf(stderr
, "\nERROR! mapping regions\n");
277 _mesa_free(intelScreen
);
278 sPriv
->private = NULL
;
283 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
285 intelScreen
->drmMinor
= sPriv
->drm_version
.minor
;
287 /* Determine if IRQs are active? */
288 if (!intel_get_param(sPriv
, I915_PARAM_IRQ_ACTIVE
,
289 &intelScreen
->irq_active
))
292 sPriv
->extensions
= intelScreenExtensions
;
299 intelDestroyScreen(__DRIscreenPrivate
* sPriv
)
301 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
303 dri_bufmgr_destroy(intelScreen
->bufmgr
);
304 intelUnmapScreenRegions(intelScreen
);
305 driDestroyOptionCache(&intelScreen
->optionCache
);
308 sPriv
->private = NULL
;
313 * This is called when we need to set up GL rendering to a new X window.
316 intelCreateBuffer(__DRIscreenPrivate
* driScrnPriv
,
317 __DRIdrawablePrivate
* driDrawPriv
,
318 const __GLcontextModes
* mesaVis
, GLboolean isPixmap
)
321 return GL_FALSE
; /* not implemented */
324 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
325 mesaVis
->depthBits
!= 24);
328 struct intel_framebuffer
*intel_fb
= CALLOC_STRUCT(intel_framebuffer
);
333 _mesa_initialize_framebuffer(&intel_fb
->Base
, mesaVis
);
335 if (mesaVis
->redBits
== 5)
337 else if (mesaVis
->alphaBits
== 0)
340 rgbFormat
= GL_RGBA8
;
342 /* setup the hardware-based renderbuffers */
343 intel_fb
->color_rb
[0] = intel_create_renderbuffer(rgbFormat
);
344 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_FRONT_LEFT
,
345 &intel_fb
->color_rb
[0]->Base
);
347 if (mesaVis
->doubleBufferMode
) {
348 intel_fb
->color_rb
[1] = intel_create_renderbuffer(rgbFormat
);
350 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_BACK_LEFT
,
351 &intel_fb
->color_rb
[1]->Base
);
355 if (mesaVis
->depthBits
== 24) {
356 if (mesaVis
->stencilBits
== 8) {
357 /* combined depth/stencil buffer */
358 struct intel_renderbuffer
*depthStencilRb
359 = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT
);
360 /* note: bind RB to two attachment points */
361 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
362 &depthStencilRb
->Base
);
363 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
,
364 &depthStencilRb
->Base
);
366 struct intel_renderbuffer
*depthRb
367 = intel_create_renderbuffer(GL_DEPTH_COMPONENT24
);
368 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
372 else if (mesaVis
->depthBits
== 16) {
373 /* just 16-bit depth buffer, no hw stencil */
374 struct intel_renderbuffer
*depthRb
375 = intel_create_renderbuffer(GL_DEPTH_COMPONENT16
);
376 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
, &depthRb
->Base
);
379 /* now add any/all software-based renderbuffers we may need */
380 _mesa_add_soft_renderbuffers(&intel_fb
->Base
,
381 GL_FALSE
, /* never sw color */
382 GL_FALSE
, /* never sw depth */
383 swStencil
, mesaVis
->accumRedBits
> 0,
384 GL_FALSE
, /* never sw alpha */
385 GL_FALSE
/* never sw aux */ );
386 driDrawPriv
->driverPrivate
= (void *) intel_fb
;
393 intelDestroyBuffer(__DRIdrawablePrivate
* driDrawPriv
)
395 _mesa_unreference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)));
400 * Get information about previous buffer swaps.
403 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
405 struct intel_framebuffer
*intel_fb
;
407 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
408 || (sInfo
== NULL
)) {
412 intel_fb
= dPriv
->driverPrivate
;
413 sInfo
->swap_count
= intel_fb
->swap_count
;
414 sInfo
->swap_ust
= intel_fb
->swap_ust
;
415 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
417 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
418 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
425 /* There are probably better ways to do this, such as an
426 * init-designated function to register chipids and createcontext
429 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
430 __DRIcontextPrivate
* driContextPriv
,
431 void *sharedContextPrivate
);
433 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
434 __DRIcontextPrivate
* driContextPriv
,
435 void *sharedContextPrivate
);
436 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
437 __DRIcontextPrivate
* driContextPriv
,
438 void *sharedContextPrivate
);
441 intelCreateContext(const __GLcontextModes
* mesaVis
,
442 __DRIcontextPrivate
* driContextPriv
,
443 void *sharedContextPrivate
)
445 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
446 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
449 if (IS_9XX(intelScreen
->deviceID
)) {
450 if (!IS_965(intelScreen
->deviceID
)) {
451 return i915CreateContext(mesaVis
, driContextPriv
,
452 sharedContextPrivate
);
455 intelScreen
->no_vbo
= GL_TRUE
;
456 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
459 if (IS_965(intelScreen
->deviceID
))
460 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
462 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
467 static __DRIconfig
**
468 intelFillInModes(__DRIscreenPrivate
*psp
,
469 unsigned pixel_bits
, unsigned depth_bits
,
470 unsigned stencil_bits
, GLboolean have_back_buffer
)
472 __DRIconfig
**configs
;
474 unsigned depth_buffer_factor
;
475 unsigned back_buffer_factor
;
478 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
479 * support pageflipping at all.
481 static const GLenum back_buffer_modes
[] = {
482 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
485 uint8_t depth_bits_array
[3];
486 uint8_t stencil_bits_array
[3];
487 uint8_t msaa_samples_array
[1];
489 depth_bits_array
[0] = 0;
490 depth_bits_array
[1] = depth_bits
;
491 depth_bits_array
[2] = depth_bits
;
493 /* Just like with the accumulation buffer, always provide some modes
494 * with a stencil buffer. It will be a sw fallback, but some apps won't
497 stencil_bits_array
[0] = 0;
498 stencil_bits_array
[1] = 0;
499 if (depth_bits
== 24)
500 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
502 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
504 msaa_samples_array
[0] = 0;
506 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
507 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
509 if (pixel_bits
== 16) {
510 configs
= driCreateConfigs(GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
,
511 depth_bits_array
, stencil_bits_array
,
512 depth_buffer_factor
, back_buffer_modes
,
514 msaa_samples_array
, 1);
517 __DRIconfig
**configs_a8r8g8b8
;
518 __DRIconfig
**configs_x8r8g8b8
;
520 configs_a8r8g8b8
= driCreateConfigs(GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
,
526 msaa_samples_array
, 1);
527 configs_x8r8g8b8
= driCreateConfigs(GL_BGR
, GL_UNSIGNED_INT_8_8_8_8_REV
,
533 msaa_samples_array
, 1);
534 configs
= driConcatConfigs(configs_a8r8g8b8
, configs_x8r8g8b8
);
537 if (configs
== NULL
) {
538 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
543 /* Mark the visual as slow if there are "fake" stencil bits.
545 for (i
= 0; configs
[i
]; i
++) {
546 m
= &configs
[i
]->modes
;
547 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
548 m
->visualRating
= GLX_SLOW_CONFIG
;
556 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
558 GLboolean gem_disable
= getenv("INTEL_NO_GEM") != NULL
;
560 GLboolean gem_supported
;
561 struct drm_i915_getparam gp
;
562 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
564 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
566 gp
.param
= I915_PARAM_HAS_GEM
;
567 gp
.value
= &gem_kernel
;
569 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
571 /* If we've got a new enough DDX that's initializing GEM and giving us
572 * object handles for the shared buffers, use that.
574 intelScreen
->ttm
= GL_FALSE
;
575 if (intelScreen
->driScrnPriv
->dri2
.enabled
)
576 gem_supported
= GL_TRUE
;
577 else if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9 &&
579 intelScreen
->front
.bo_handle
!= -1)
580 gem_supported
= GL_TRUE
;
582 gem_supported
= GL_FALSE
;
584 if (!gem_disable
&& gem_supported
) {
585 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
586 if (intelScreen
->bufmgr
!= NULL
)
587 intelScreen
->ttm
= GL_TRUE
;
589 /* Otherwise, use the classic buffer manager. */
590 if (intelScreen
->bufmgr
== NULL
) {
592 fprintf(stderr
, "GEM disabled. Using classic.\n");
594 fprintf(stderr
, "Failed to initialize GEM. "
595 "Falling back to classic.\n");
598 if (intelScreen
->tex
.size
== 0) {
599 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
604 intelScreen
->bufmgr
=
605 intel_bufmgr_fake_init(spriv
->fd
,
606 intelScreen
->tex
.offset
,
607 intelScreen
->tex
.map
,
608 intelScreen
->tex
.size
,
609 (unsigned int * volatile)
610 &intelScreen
->sarea
->last_dispatch
);
613 /* XXX bufmgr should be per-screen, not per-context */
614 intelScreen
->ttm
= intelScreen
->ttm
;
620 * This is the driver specific part of the createNewScreen entry point.
621 * Called when using legacy DRI.
623 * \todo maybe fold this into intelInitDriver
625 * \return the __GLcontextModes supported by this driver
627 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
629 intelScreenPrivate
*intelScreen
;
631 static const __DRIversion ddx_expected
= { 1, 5, 0 };
633 static const __DRIversion ddx_expected
= { 1, 6, 0 };
635 static const __DRIversion dri_expected
= { 4, 0, 0 };
636 static const __DRIversion drm_expected
= { 1, 5, 0 };
637 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
639 if (!driCheckDriDdxDrmVersions2("i915",
640 &psp
->dri_version
, &dri_expected
,
641 &psp
->ddx_version
, &ddx_expected
,
642 &psp
->drm_version
, &drm_expected
)) {
646 /* Calling driInitExtensions here, with a NULL context pointer,
647 * does not actually enable the extensions. It just makes sure
648 * that all the dispatch offsets for all the extensions that
649 * *might* be enables are known. This is needed because the
650 * dispatch offsets need to be known when _mesa_context_create is
651 * called, but we can't enable the extensions until we have a
654 * Hello chicken. Hello egg. How are you two today?
656 intelInitExtensions(NULL
, GL_TRUE
);
658 if (!intelInitDriver(psp
))
661 psp
->extensions
= intelScreenExtensions
;
663 intelScreen
= psp
->private;
664 if (!intel_init_bufmgr(intelScreen
))
667 return (const __DRIconfig
**)
668 intelFillInModes(psp
, dri_priv
->cpp
* 8,
669 (dri_priv
->cpp
== 2) ? 16 : 24,
670 (dri_priv
->cpp
== 2) ? 0 : 8, 1);
673 struct intel_context
*intelScreenContext(intelScreenPrivate
*intelScreen
)
676 * This should probably change to have the screen allocate a dummy
677 * context at screen creation. For now just use the current context.
680 GET_CURRENT_CONTEXT(ctx
);
682 _mesa_problem(NULL
, "No current context in intelScreenContext\n");
685 return intel_context(ctx
);
689 * This is the driver specific part of the createNewScreen entry point.
690 * Called when using DRI2.
692 * \return the __GLcontextModes supported by this driver
695 __DRIconfig
**intelInitScreen2(__DRIscreenPrivate
*psp
)
697 intelScreenPrivate
*intelScreen
;
700 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
701 * support pageflipping at all.
703 static const GLenum back_buffer_modes
[] = {
704 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
706 uint8_t depth_bits
[4], stencil_bits
[4], msaa_samples_array
[1];
708 __DRIconfig
**configs
= NULL
;
710 /* Calling driInitExtensions here, with a NULL context pointer,
711 * does not actually enable the extensions. It just makes sure
712 * that all the dispatch offsets for all the extensions that
713 * *might* be enables are known. This is needed because the
714 * dispatch offsets need to be known when _mesa_context_create is
715 * called, but we can't enable the extensions until we have a
718 * Hello chicken. Hello egg. How are you two today?
720 intelInitExtensions(NULL
, GL_TRUE
);
722 /* Allocate the private area */
723 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
725 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
728 /* parse information in __driConfigOptions */
729 driParseOptionInfo(&intelScreen
->optionCache
,
730 __driConfigOptions
, __driNConfigOptions
);
732 intelScreen
->driScrnPriv
= psp
;
733 psp
->private = (void *) intelScreen
;
735 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
737 /* Determine chipset ID */
738 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
739 &intelScreen
->deviceID
))
742 if (!intel_init_bufmgr(intelScreen
))
745 intelScreen
->irq_active
= 1;
746 psp
->extensions
= intelScreenExtensions
;
757 msaa_samples_array
[0] = 0;
759 fb_format
[0] = GL_RGB
;
760 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
762 fb_format
[1] = GL_BGR
;
763 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
765 fb_format
[2] = GL_BGRA
;
766 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
771 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
772 __DRIconfig
**new_configs
;
775 /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer
776 * with the same cpp as the drawable. So we can't support depth cpp !=
777 * color cpp currently.
779 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
792 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
797 ARRAY_SIZE(back_buffer_modes
),
799 ARRAY_SIZE(msaa_samples_array
));
801 configs
= new_configs
;
803 configs
= driConcatConfigs(configs
, new_configs
);
806 if (configs
== NULL
) {
807 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
812 return (const __DRIconfig
**)configs
;
815 const struct __DriverAPIRec driDriverAPI
= {
816 .InitScreen
= intelInitScreen
,
817 .DestroyScreen
= intelDestroyScreen
,
818 .CreateContext
= intelCreateContext
,
819 .DestroyContext
= intelDestroyContext
,
820 .CreateBuffer
= intelCreateBuffer
,
821 .DestroyBuffer
= intelDestroyBuffer
,
822 .SwapBuffers
= intelSwapBuffers
,
823 .MakeCurrent
= intelMakeCurrent
,
824 .UnbindContext
= intelUnbindContext
,
825 .GetSwapInfo
= intelGetSwapInfo
,
826 .GetDrawableMSC
= driDrawableGetMSC32
,
827 .WaitForMSC
= driWaitForMSC32
,
828 .CopySubBuffer
= intelCopySubBuffer
,
830 .InitScreen2
= intelInitScreen2
,