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)
74 DRI_CONF_ALWAYS_FLUSH_BATCH(false)
75 DRI_CONF_ALWAYS_FLUSH_CACHE(false)
79 const GLuint __driNConfigOptions
= 8;
81 #ifdef USE_NEW_INTERFACE
82 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
83 #endif /*USE_NEW_INTERFACE */
86 * Map all the memory regions described by the screen.
87 * \return GL_TRUE if success, GL_FALSE if error.
90 intelMapScreenRegions(__DRIscreenPrivate
* sPriv
)
92 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
95 _mesa_printf("TEX 0x%08x ", intelScreen
->tex
.handle
);
96 if (intelScreen
->tex
.size
!= 0) {
98 intelScreen
->tex
.handle
,
99 intelScreen
->tex
.size
,
100 (drmAddress
*) & intelScreen
->tex
.map
) != 0) {
101 intelUnmapScreenRegions(intelScreen
);
110 intelUnmapScreenRegions(intelScreenPrivate
* intelScreen
)
112 if (intelScreen
->tex
.map
) {
113 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
114 intelScreen
->tex
.map
= NULL
;
120 intelPrintDRIInfo(intelScreenPrivate
* intelScreen
,
121 __DRIscreenPrivate
* sPriv
, I830DRIPtr gDRIPriv
)
123 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
124 intelScreen
->front
.size
, intelScreen
->front
.offset
,
126 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
127 intelScreen
->back
.size
, intelScreen
->back
.offset
,
129 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
130 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
132 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
133 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
134 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
139 intelPrintSAREA(const drm_i915_sarea_t
* sarea
)
141 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
,
143 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
145 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
146 sarea
->front_offset
, sarea
->front_size
,
147 (unsigned) sarea
->front_handle
, sarea
->front_tiled
);
149 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
150 sarea
->back_offset
, sarea
->back_size
,
151 (unsigned) sarea
->back_handle
, sarea
->back_tiled
);
152 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
153 sarea
->depth_offset
, sarea
->depth_size
,
154 (unsigned) sarea
->depth_handle
, sarea
->depth_tiled
);
155 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
156 sarea
->tex_offset
, sarea
->tex_size
, (unsigned) sarea
->tex_handle
);
161 * A number of the screen parameters are obtained/computed from
162 * information in the SAREA. This function updates those parameters.
165 intelUpdateScreenFromSAREA(intelScreenPrivate
* intelScreen
,
166 drm_i915_sarea_t
* sarea
)
168 intelScreen
->width
= sarea
->width
;
169 intelScreen
->height
= sarea
->height
;
170 intelScreen
->pitch
= sarea
->pitch
;
172 intelScreen
->front
.offset
= sarea
->front_offset
;
173 intelScreen
->front
.handle
= sarea
->front_handle
;
174 intelScreen
->front
.size
= sarea
->front_size
;
175 intelScreen
->front
.tiled
= sarea
->front_tiled
;
177 intelScreen
->back
.offset
= sarea
->back_offset
;
178 intelScreen
->back
.handle
= sarea
->back_handle
;
179 intelScreen
->back
.size
= sarea
->back_size
;
180 intelScreen
->back
.tiled
= sarea
->back_tiled
;
182 intelScreen
->depth
.offset
= sarea
->depth_offset
;
183 intelScreen
->depth
.handle
= sarea
->depth_handle
;
184 intelScreen
->depth
.size
= sarea
->depth_size
;
185 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
187 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9) {
188 intelScreen
->front
.bo_handle
= sarea
->front_bo_handle
;
189 intelScreen
->back
.bo_handle
= sarea
->back_bo_handle
;
190 intelScreen
->depth
.bo_handle
= sarea
->depth_bo_handle
;
192 intelScreen
->front
.bo_handle
= -1;
193 intelScreen
->back
.bo_handle
= -1;
194 intelScreen
->depth
.bo_handle
= -1;
197 intelScreen
->tex
.offset
= sarea
->tex_offset
;
198 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
199 intelScreen
->tex
.handle
= sarea
->tex_handle
;
200 intelScreen
->tex
.size
= sarea
->tex_size
;
203 intelPrintSAREA(sarea
);
206 static const __DRItexOffsetExtension intelTexOffsetExtension
= {
207 { __DRI_TEX_OFFSET
},
211 static const __DRItexBufferExtension intelTexBufferExtension
= {
212 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
217 static const __DRIextension
*intelScreenExtensions
[] = {
218 &driReadDrawableExtension
,
219 &driCopySubBufferExtension
.base
,
220 &driSwapControlExtension
.base
,
221 &driFrameTrackingExtension
.base
,
222 &driMediaStreamCounterExtension
.base
,
223 &intelTexOffsetExtension
.base
,
224 &intelTexBufferExtension
.base
,
229 intel_get_param(__DRIscreenPrivate
*psp
, int param
, int *value
)
232 struct drm_i915_getparam gp
;
237 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
239 fprintf(stderr
, "drm_i915_getparam: %d\n", ret
);
246 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
248 intelScreenPrivate
*intelScreen
;
249 I830DRIPtr gDRIPriv
= (I830DRIPtr
) sPriv
->pDevPriv
;
250 drm_i915_sarea_t
*sarea
;
252 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
254 "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
258 /* Allocate the private area */
259 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
261 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
264 /* parse information in __driConfigOptions */
265 driParseOptionInfo(&intelScreen
->optionCache
,
266 __driConfigOptions
, __driNConfigOptions
);
268 intelScreen
->driScrnPriv
= sPriv
;
269 sPriv
->private = (void *) intelScreen
;
270 sarea
= (drm_i915_sarea_t
*)
271 (((GLubyte
*) sPriv
->pSAREA
) + gDRIPriv
->sarea_priv_offset
);
272 intelScreen
->sarea
= sarea
;
274 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
276 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
278 if (!intelMapScreenRegions(sPriv
)) {
279 fprintf(stderr
, "\nERROR! mapping regions\n");
280 _mesa_free(intelScreen
);
281 sPriv
->private = NULL
;
286 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
288 intelScreen
->drmMinor
= sPriv
->drm_version
.minor
;
290 /* Determine if IRQs are active? */
291 if (!intel_get_param(sPriv
, I915_PARAM_IRQ_ACTIVE
,
292 &intelScreen
->irq_active
))
295 sPriv
->extensions
= intelScreenExtensions
;
302 intelDestroyScreen(__DRIscreenPrivate
* sPriv
)
304 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
306 dri_bufmgr_destroy(intelScreen
->bufmgr
);
307 intelUnmapScreenRegions(intelScreen
);
308 driDestroyOptionCache(&intelScreen
->optionCache
);
311 sPriv
->private = NULL
;
316 * This is called when we need to set up GL rendering to a new X window.
319 intelCreateBuffer(__DRIscreenPrivate
* driScrnPriv
,
320 __DRIdrawablePrivate
* driDrawPriv
,
321 const __GLcontextModes
* mesaVis
, GLboolean isPixmap
)
324 return GL_FALSE
; /* not implemented */
327 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
328 mesaVis
->depthBits
!= 24);
331 struct intel_framebuffer
*intel_fb
= CALLOC_STRUCT(intel_framebuffer
);
336 _mesa_initialize_framebuffer(&intel_fb
->Base
, mesaVis
);
338 if (mesaVis
->redBits
== 5)
340 else if (mesaVis
->alphaBits
== 0)
343 rgbFormat
= GL_RGBA8
;
345 /* setup the hardware-based renderbuffers */
346 intel_fb
->color_rb
[0] = intel_create_renderbuffer(rgbFormat
);
347 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_FRONT_LEFT
,
348 &intel_fb
->color_rb
[0]->Base
);
350 if (mesaVis
->doubleBufferMode
) {
351 intel_fb
->color_rb
[1] = intel_create_renderbuffer(rgbFormat
);
353 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_BACK_LEFT
,
354 &intel_fb
->color_rb
[1]->Base
);
358 if (mesaVis
->depthBits
== 24) {
359 if (mesaVis
->stencilBits
== 8) {
360 /* combined depth/stencil buffer */
361 struct intel_renderbuffer
*depthStencilRb
362 = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT
);
363 /* note: bind RB to two attachment points */
364 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
365 &depthStencilRb
->Base
);
366 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
,
367 &depthStencilRb
->Base
);
369 struct intel_renderbuffer
*depthRb
370 = intel_create_renderbuffer(GL_DEPTH_COMPONENT24
);
371 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
375 else if (mesaVis
->depthBits
== 16) {
376 /* just 16-bit depth buffer, no hw stencil */
377 struct intel_renderbuffer
*depthRb
378 = intel_create_renderbuffer(GL_DEPTH_COMPONENT16
);
379 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
, &depthRb
->Base
);
382 /* now add any/all software-based renderbuffers we may need */
383 _mesa_add_soft_renderbuffers(&intel_fb
->Base
,
384 GL_FALSE
, /* never sw color */
385 GL_FALSE
, /* never sw depth */
386 swStencil
, mesaVis
->accumRedBits
> 0,
387 GL_FALSE
, /* never sw alpha */
388 GL_FALSE
/* never sw aux */ );
389 driDrawPriv
->driverPrivate
= (void *) intel_fb
;
396 intelDestroyBuffer(__DRIdrawablePrivate
* driDrawPriv
)
398 _mesa_reference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)), NULL
);
403 * Get information about previous buffer swaps.
406 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
408 struct intel_framebuffer
*intel_fb
;
410 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
411 || (sInfo
== NULL
)) {
415 intel_fb
= dPriv
->driverPrivate
;
416 sInfo
->swap_count
= intel_fb
->swap_count
;
417 sInfo
->swap_ust
= intel_fb
->swap_ust
;
418 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
420 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
421 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
428 /* There are probably better ways to do this, such as an
429 * init-designated function to register chipids and createcontext
432 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
433 __DRIcontextPrivate
* driContextPriv
,
434 void *sharedContextPrivate
);
436 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
437 __DRIcontextPrivate
* driContextPriv
,
438 void *sharedContextPrivate
);
439 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
440 __DRIcontextPrivate
* driContextPriv
,
441 void *sharedContextPrivate
);
444 intelCreateContext(const __GLcontextModes
* mesaVis
,
445 __DRIcontextPrivate
* driContextPriv
,
446 void *sharedContextPrivate
)
448 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
449 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
452 if (IS_9XX(intelScreen
->deviceID
)) {
453 if (!IS_965(intelScreen
->deviceID
)) {
454 return i915CreateContext(mesaVis
, driContextPriv
,
455 sharedContextPrivate
);
458 intelScreen
->no_vbo
= GL_TRUE
;
459 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
462 if (IS_965(intelScreen
->deviceID
))
463 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
465 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
470 static __DRIconfig
**
471 intelFillInModes(__DRIscreenPrivate
*psp
,
472 unsigned pixel_bits
, unsigned depth_bits
,
473 unsigned stencil_bits
, GLboolean have_back_buffer
)
475 __DRIconfig
**configs
;
477 unsigned depth_buffer_factor
;
478 unsigned back_buffer_factor
;
481 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
482 * support pageflipping at all.
484 static const GLenum back_buffer_modes
[] = {
485 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
488 uint8_t depth_bits_array
[3];
489 uint8_t stencil_bits_array
[3];
490 uint8_t msaa_samples_array
[1];
492 depth_bits_array
[0] = 0;
493 depth_bits_array
[1] = depth_bits
;
494 depth_bits_array
[2] = depth_bits
;
496 /* Just like with the accumulation buffer, always provide some modes
497 * with a stencil buffer. It will be a sw fallback, but some apps won't
500 stencil_bits_array
[0] = 0;
501 stencil_bits_array
[1] = 0;
502 if (depth_bits
== 24)
503 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
505 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
507 msaa_samples_array
[0] = 0;
509 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
510 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
512 if (pixel_bits
== 16) {
513 configs
= driCreateConfigs(GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
,
514 depth_bits_array
, stencil_bits_array
,
515 depth_buffer_factor
, back_buffer_modes
,
517 msaa_samples_array
, 1);
520 __DRIconfig
**configs_a8r8g8b8
;
521 __DRIconfig
**configs_x8r8g8b8
;
523 configs_a8r8g8b8
= driCreateConfigs(GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
,
529 msaa_samples_array
, 1);
530 configs_x8r8g8b8
= driCreateConfigs(GL_BGR
, GL_UNSIGNED_INT_8_8_8_8_REV
,
536 msaa_samples_array
, 1);
537 configs
= driConcatConfigs(configs_a8r8g8b8
, configs_x8r8g8b8
);
540 if (configs
== NULL
) {
541 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
546 /* Mark the visual as slow if there are "fake" stencil bits.
548 for (i
= 0; configs
[i
]; i
++) {
549 m
= &configs
[i
]->modes
;
550 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
551 m
->visualRating
= GLX_SLOW_CONFIG
;
559 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
561 GLboolean gem_disable
= getenv("INTEL_NO_GEM") != NULL
;
563 GLboolean gem_supported
;
564 struct drm_i915_getparam gp
;
565 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
567 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
569 gp
.param
= I915_PARAM_HAS_GEM
;
570 gp
.value
= &gem_kernel
;
572 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
574 /* If we've got a new enough DDX that's initializing GEM and giving us
575 * object handles for the shared buffers, use that.
577 intelScreen
->ttm
= GL_FALSE
;
578 if (intelScreen
->driScrnPriv
->dri2
.enabled
)
579 gem_supported
= GL_TRUE
;
580 else if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9 &&
582 intelScreen
->front
.bo_handle
!= -1)
583 gem_supported
= GL_TRUE
;
585 gem_supported
= GL_FALSE
;
587 if (!gem_disable
&& gem_supported
) {
588 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
589 if (intelScreen
->bufmgr
!= NULL
)
590 intelScreen
->ttm
= GL_TRUE
;
592 /* Otherwise, use the classic buffer manager. */
593 if (intelScreen
->bufmgr
== NULL
) {
595 fprintf(stderr
, "GEM disabled. Using classic.\n");
597 fprintf(stderr
, "Failed to initialize GEM. "
598 "Falling back to classic.\n");
601 if (intelScreen
->tex
.size
== 0) {
602 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
607 intelScreen
->bufmgr
=
608 intel_bufmgr_fake_init(spriv
->fd
,
609 intelScreen
->tex
.offset
,
610 intelScreen
->tex
.map
,
611 intelScreen
->tex
.size
,
612 (unsigned int * volatile)
613 &intelScreen
->sarea
->last_dispatch
);
616 /* XXX bufmgr should be per-screen, not per-context */
617 intelScreen
->ttm
= intelScreen
->ttm
;
623 * This is the driver specific part of the createNewScreen entry point.
624 * Called when using legacy DRI.
626 * \todo maybe fold this into intelInitDriver
628 * \return the __GLcontextModes supported by this driver
630 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
632 intelScreenPrivate
*intelScreen
;
634 static const __DRIversion ddx_expected
= { 1, 5, 0 };
636 static const __DRIversion ddx_expected
= { 1, 6, 0 };
638 static const __DRIversion dri_expected
= { 4, 0, 0 };
639 static const __DRIversion drm_expected
= { 1, 5, 0 };
640 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
642 if (!driCheckDriDdxDrmVersions2("i915",
643 &psp
->dri_version
, &dri_expected
,
644 &psp
->ddx_version
, &ddx_expected
,
645 &psp
->drm_version
, &drm_expected
)) {
649 /* Calling driInitExtensions here, with a NULL context pointer,
650 * does not actually enable the extensions. It just makes sure
651 * that all the dispatch offsets for all the extensions that
652 * *might* be enables are known. This is needed because the
653 * dispatch offsets need to be known when _mesa_context_create is
654 * called, but we can't enable the extensions until we have a
657 * Hello chicken. Hello egg. How are you two today?
659 intelInitExtensions(NULL
, GL_TRUE
);
661 if (!intelInitDriver(psp
))
664 psp
->extensions
= intelScreenExtensions
;
666 intelScreen
= psp
->private;
667 if (!intel_init_bufmgr(intelScreen
))
670 return (const __DRIconfig
**)
671 intelFillInModes(psp
, dri_priv
->cpp
* 8,
672 (dri_priv
->cpp
== 2) ? 16 : 24,
673 (dri_priv
->cpp
== 2) ? 0 : 8, 1);
676 struct intel_context
*intelScreenContext(intelScreenPrivate
*intelScreen
)
679 * This should probably change to have the screen allocate a dummy
680 * context at screen creation. For now just use the current context.
683 GET_CURRENT_CONTEXT(ctx
);
685 _mesa_problem(NULL
, "No current context in intelScreenContext\n");
688 return intel_context(ctx
);
692 * This is the driver specific part of the createNewScreen entry point.
693 * Called when using DRI2.
695 * \return the __GLcontextModes supported by this driver
698 __DRIconfig
**intelInitScreen2(__DRIscreenPrivate
*psp
)
700 intelScreenPrivate
*intelScreen
;
703 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
704 * support pageflipping at all.
706 static const GLenum back_buffer_modes
[] = {
707 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
709 uint8_t depth_bits
[4], stencil_bits
[4], msaa_samples_array
[1];
711 __DRIconfig
**configs
= NULL
;
713 /* Calling driInitExtensions here, with a NULL context pointer,
714 * does not actually enable the extensions. It just makes sure
715 * that all the dispatch offsets for all the extensions that
716 * *might* be enables are known. This is needed because the
717 * dispatch offsets need to be known when _mesa_context_create is
718 * called, but we can't enable the extensions until we have a
721 * Hello chicken. Hello egg. How are you two today?
723 intelInitExtensions(NULL
, GL_TRUE
);
725 /* Allocate the private area */
726 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
728 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
731 /* parse information in __driConfigOptions */
732 driParseOptionInfo(&intelScreen
->optionCache
,
733 __driConfigOptions
, __driNConfigOptions
);
735 intelScreen
->driScrnPriv
= psp
;
736 psp
->private = (void *) intelScreen
;
738 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
740 /* Determine chipset ID */
741 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
742 &intelScreen
->deviceID
))
745 if (!intel_init_bufmgr(intelScreen
))
748 intelScreen
->irq_active
= 1;
749 psp
->extensions
= intelScreenExtensions
;
760 msaa_samples_array
[0] = 0;
762 fb_format
[0] = GL_RGB
;
763 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
765 fb_format
[1] = GL_BGR
;
766 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
768 fb_format
[2] = GL_BGRA
;
769 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
774 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
775 __DRIconfig
**new_configs
;
778 /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer
779 * with the same cpp as the drawable. So we can't support depth cpp !=
780 * color cpp currently.
782 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
795 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
800 ARRAY_SIZE(back_buffer_modes
),
802 ARRAY_SIZE(msaa_samples_array
));
804 configs
= new_configs
;
806 configs
= driConcatConfigs(configs
, new_configs
);
809 if (configs
== NULL
) {
810 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
815 return (const __DRIconfig
**)configs
;
818 const struct __DriverAPIRec driDriverAPI
= {
819 .InitScreen
= intelInitScreen
,
820 .DestroyScreen
= intelDestroyScreen
,
821 .CreateContext
= intelCreateContext
,
822 .DestroyContext
= intelDestroyContext
,
823 .CreateBuffer
= intelCreateBuffer
,
824 .DestroyBuffer
= intelDestroyBuffer
,
825 .SwapBuffers
= intelSwapBuffers
,
826 .MakeCurrent
= intelMakeCurrent
,
827 .UnbindContext
= intelUnbindContext
,
828 .GetSwapInfo
= intelGetSwapInfo
,
829 .GetDrawableMSC
= driDrawableGetMSC32
,
830 .WaitForMSC
= driWaitForMSC32
,
831 .CopySubBuffer
= intelCopySubBuffer
,
833 .InitScreen2
= intelInitScreen2
,