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"
52 #define DRI_CONF_TEXTURE_TILING(def) \
53 DRI_CONF_OPT_BEGIN(texture_tiling, bool, def) \
54 DRI_CONF_DESC(en, "Enable texture tiling") \
57 PUBLIC const char __driConfigOptions[] =
59 DRI_CONF_SECTION_PERFORMANCE
60 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS
)
61 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC
)
62 /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
63 * DRI_CONF_BO_REUSE_ALL
65 DRI_CONF_OPT_BEGIN_V(bo_reuse
, enum, 1, "0:1")
66 DRI_CONF_DESC_BEGIN(en
, "Buffer object reuse")
67 DRI_CONF_ENUM(0, "Disable buffer object reuse")
68 DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
73 DRI_CONF_TEXTURE_TILING(false)
75 DRI_CONF_TEXTURE_TILING(true)
78 DRI_CONF_OPT_BEGIN(early_z
, bool, false)
79 DRI_CONF_DESC(en
, "Enable early Z in classic mode (unstable, 945-only).")
83 DRI_CONF_SECTION_QUALITY
84 DRI_CONF_FORCE_S3TC_ENABLE(false)
85 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
87 DRI_CONF_SECTION_DEBUG
88 DRI_CONF_NO_RAST(false)
89 DRI_CONF_ALWAYS_FLUSH_BATCH(false)
90 DRI_CONF_ALWAYS_FLUSH_CACHE(false)
94 const GLuint __driNConfigOptions
= 10;
96 #ifdef USE_NEW_INTERFACE
97 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
98 #endif /*USE_NEW_INTERFACE */
101 * Map all the memory regions described by the screen.
102 * \return GL_TRUE if success, GL_FALSE if error.
105 intelMapScreenRegions(__DRIscreenPrivate
* sPriv
)
107 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
110 _mesa_printf("TEX 0x%08x ", intelScreen
->tex
.handle
);
111 if (intelScreen
->tex
.size
!= 0) {
112 if (drmMap(sPriv
->fd
,
113 intelScreen
->tex
.handle
,
114 intelScreen
->tex
.size
,
115 (drmAddress
*) & intelScreen
->tex
.map
) != 0) {
116 intelUnmapScreenRegions(intelScreen
);
125 intelUnmapScreenRegions(intelScreenPrivate
* intelScreen
)
127 if (intelScreen
->tex
.map
) {
128 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
129 intelScreen
->tex
.map
= NULL
;
135 intelPrintDRIInfo(intelScreenPrivate
* intelScreen
,
136 __DRIscreenPrivate
* sPriv
, I830DRIPtr gDRIPriv
)
138 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
139 intelScreen
->front
.size
, intelScreen
->front
.offset
,
141 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
142 intelScreen
->back
.size
, intelScreen
->back
.offset
,
144 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
145 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
147 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
148 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
149 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
154 intelPrintSAREA(const drm_i915_sarea_t
* sarea
)
156 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
,
158 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
160 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
161 sarea
->front_offset
, sarea
->front_size
,
162 (unsigned) sarea
->front_handle
, sarea
->front_tiled
);
164 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
165 sarea
->back_offset
, sarea
->back_size
,
166 (unsigned) sarea
->back_handle
, sarea
->back_tiled
);
167 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
168 sarea
->depth_offset
, sarea
->depth_size
,
169 (unsigned) sarea
->depth_handle
, sarea
->depth_tiled
);
170 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
171 sarea
->tex_offset
, sarea
->tex_size
, (unsigned) sarea
->tex_handle
);
176 * A number of the screen parameters are obtained/computed from
177 * information in the SAREA. This function updates those parameters.
180 intelUpdateScreenFromSAREA(intelScreenPrivate
* intelScreen
,
181 drm_i915_sarea_t
* sarea
)
183 intelScreen
->width
= sarea
->width
;
184 intelScreen
->height
= sarea
->height
;
185 intelScreen
->pitch
= sarea
->pitch
;
187 intelScreen
->front
.offset
= sarea
->front_offset
;
188 intelScreen
->front
.handle
= sarea
->front_handle
;
189 intelScreen
->front
.size
= sarea
->front_size
;
190 intelScreen
->front
.tiled
= sarea
->front_tiled
;
192 intelScreen
->back
.offset
= sarea
->back_offset
;
193 intelScreen
->back
.handle
= sarea
->back_handle
;
194 intelScreen
->back
.size
= sarea
->back_size
;
195 intelScreen
->back
.tiled
= sarea
->back_tiled
;
197 intelScreen
->depth
.offset
= sarea
->depth_offset
;
198 intelScreen
->depth
.handle
= sarea
->depth_handle
;
199 intelScreen
->depth
.size
= sarea
->depth_size
;
200 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
202 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9) {
203 intelScreen
->front
.bo_handle
= sarea
->front_bo_handle
;
204 intelScreen
->back
.bo_handle
= sarea
->back_bo_handle
;
205 intelScreen
->depth
.bo_handle
= sarea
->depth_bo_handle
;
207 intelScreen
->front
.bo_handle
= -1;
208 intelScreen
->back
.bo_handle
= -1;
209 intelScreen
->depth
.bo_handle
= -1;
212 intelScreen
->tex
.offset
= sarea
->tex_offset
;
213 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
214 intelScreen
->tex
.handle
= sarea
->tex_handle
;
215 intelScreen
->tex
.size
= sarea
->tex_size
;
218 intelPrintSAREA(sarea
);
221 static const __DRItexOffsetExtension intelTexOffsetExtension
= {
222 { __DRI_TEX_OFFSET
},
226 static const __DRItexBufferExtension intelTexBufferExtension
= {
227 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
232 static const __DRIextension
*intelScreenExtensions
[] = {
233 &driReadDrawableExtension
,
234 &driCopySubBufferExtension
.base
,
235 &driSwapControlExtension
.base
,
236 &driFrameTrackingExtension
.base
,
237 &driMediaStreamCounterExtension
.base
,
238 &intelTexOffsetExtension
.base
,
239 &intelTexBufferExtension
.base
,
244 intel_get_param(__DRIscreenPrivate
*psp
, int param
, int *value
)
247 struct drm_i915_getparam gp
;
252 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
254 _mesa_warning(NULL
, "drm_i915_getparam: %d", ret
);
261 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
263 intelScreenPrivate
*intelScreen
;
264 I830DRIPtr gDRIPriv
= (I830DRIPtr
) sPriv
->pDevPriv
;
265 drm_i915_sarea_t
*sarea
;
267 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
269 "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
273 /* Allocate the private area */
274 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
276 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
279 /* parse information in __driConfigOptions */
280 driParseOptionInfo(&intelScreen
->optionCache
,
281 __driConfigOptions
, __driNConfigOptions
);
283 intelScreen
->driScrnPriv
= sPriv
;
284 sPriv
->private = (void *) intelScreen
;
285 sarea
= (drm_i915_sarea_t
*)
286 (((GLubyte
*) sPriv
->pSAREA
) + gDRIPriv
->sarea_priv_offset
);
287 intelScreen
->sarea
= sarea
;
289 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
291 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
293 if (!intelMapScreenRegions(sPriv
)) {
294 fprintf(stderr
, "\nERROR! mapping regions\n");
295 _mesa_free(intelScreen
);
296 sPriv
->private = NULL
;
301 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
303 intelScreen
->drmMinor
= sPriv
->drm_version
.minor
;
305 /* Determine if IRQs are active? */
306 if (!intel_get_param(sPriv
, I915_PARAM_IRQ_ACTIVE
,
307 &intelScreen
->irq_active
))
310 sPriv
->extensions
= intelScreenExtensions
;
317 intelDestroyScreen(__DRIscreenPrivate
* sPriv
)
319 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
321 dri_bufmgr_destroy(intelScreen
->bufmgr
);
322 intelUnmapScreenRegions(intelScreen
);
323 driDestroyOptionCache(&intelScreen
->optionCache
);
326 sPriv
->private = NULL
;
331 * This is called when we need to set up GL rendering to a new X window.
334 intelCreateBuffer(__DRIscreenPrivate
* driScrnPriv
,
335 __DRIdrawablePrivate
* driDrawPriv
,
336 const __GLcontextModes
* mesaVis
, GLboolean isPixmap
)
339 return GL_FALSE
; /* not implemented */
342 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
343 mesaVis
->depthBits
!= 24);
346 struct intel_framebuffer
*intel_fb
= CALLOC_STRUCT(intel_framebuffer
);
351 _mesa_initialize_framebuffer(&intel_fb
->Base
, mesaVis
);
353 if (mesaVis
->redBits
== 5)
355 else if (mesaVis
->alphaBits
== 0)
358 rgbFormat
= GL_RGBA8
;
360 /* setup the hardware-based renderbuffers */
361 intel_fb
->color_rb
[0] = intel_create_renderbuffer(rgbFormat
);
362 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_FRONT_LEFT
,
363 &intel_fb
->color_rb
[0]->Base
);
365 if (mesaVis
->doubleBufferMode
) {
366 intel_fb
->color_rb
[1] = intel_create_renderbuffer(rgbFormat
);
368 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_BACK_LEFT
,
369 &intel_fb
->color_rb
[1]->Base
);
373 if (mesaVis
->depthBits
== 24) {
374 if (mesaVis
->stencilBits
== 8) {
375 /* combined depth/stencil buffer */
376 struct intel_renderbuffer
*depthStencilRb
377 = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT
);
378 /* note: bind RB to two attachment points */
379 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
380 &depthStencilRb
->Base
);
381 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
,
382 &depthStencilRb
->Base
);
384 struct intel_renderbuffer
*depthRb
385 = intel_create_renderbuffer(GL_DEPTH_COMPONENT24
);
386 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
390 else if (mesaVis
->depthBits
== 16) {
391 /* just 16-bit depth buffer, no hw stencil */
392 struct intel_renderbuffer
*depthRb
393 = intel_create_renderbuffer(GL_DEPTH_COMPONENT16
);
394 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
, &depthRb
->Base
);
397 /* now add any/all software-based renderbuffers we may need */
398 _mesa_add_soft_renderbuffers(&intel_fb
->Base
,
399 GL_FALSE
, /* never sw color */
400 GL_FALSE
, /* never sw depth */
401 swStencil
, mesaVis
->accumRedBits
> 0,
402 GL_FALSE
, /* never sw alpha */
403 GL_FALSE
/* never sw aux */ );
404 driDrawPriv
->driverPrivate
= (void *) intel_fb
;
411 intelDestroyBuffer(__DRIdrawablePrivate
* driDrawPriv
)
413 _mesa_reference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)), NULL
);
418 * Get information about previous buffer swaps.
421 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
423 struct intel_framebuffer
*intel_fb
;
425 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
426 || (sInfo
== NULL
)) {
430 intel_fb
= dPriv
->driverPrivate
;
431 sInfo
->swap_count
= intel_fb
->swap_count
;
432 sInfo
->swap_ust
= intel_fb
->swap_ust
;
433 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
435 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
436 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
443 /* There are probably better ways to do this, such as an
444 * init-designated function to register chipids and createcontext
447 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
448 __DRIcontextPrivate
* driContextPriv
,
449 void *sharedContextPrivate
);
451 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
452 __DRIcontextPrivate
* driContextPriv
,
453 void *sharedContextPrivate
);
454 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
455 __DRIcontextPrivate
* driContextPriv
,
456 void *sharedContextPrivate
);
459 intelCreateContext(const __GLcontextModes
* mesaVis
,
460 __DRIcontextPrivate
* driContextPriv
,
461 void *sharedContextPrivate
)
463 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
464 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
467 if (IS_9XX(intelScreen
->deviceID
)) {
468 if (!IS_965(intelScreen
->deviceID
)) {
469 return i915CreateContext(mesaVis
, driContextPriv
,
470 sharedContextPrivate
);
473 intelScreen
->no_vbo
= GL_TRUE
;
474 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
477 if (IS_965(intelScreen
->deviceID
))
478 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
480 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
485 static __DRIconfig
**
486 intelFillInModes(__DRIscreenPrivate
*psp
,
487 unsigned pixel_bits
, unsigned depth_bits
,
488 unsigned stencil_bits
, GLboolean have_back_buffer
)
490 __DRIconfig
**configs
;
492 unsigned depth_buffer_factor
;
493 unsigned back_buffer_factor
;
496 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
497 * support pageflipping at all.
499 static const GLenum back_buffer_modes
[] = {
500 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
503 uint8_t depth_bits_array
[3];
504 uint8_t stencil_bits_array
[3];
505 uint8_t msaa_samples_array
[1];
507 depth_bits_array
[0] = 0;
508 depth_bits_array
[1] = depth_bits
;
509 depth_bits_array
[2] = depth_bits
;
511 /* Just like with the accumulation buffer, always provide some modes
512 * with a stencil buffer. It will be a sw fallback, but some apps won't
515 stencil_bits_array
[0] = 0;
516 stencil_bits_array
[1] = 0;
517 if (depth_bits
== 24)
518 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
520 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
522 msaa_samples_array
[0] = 0;
524 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
525 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
527 if (pixel_bits
== 16) {
528 configs
= driCreateConfigs(GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
,
529 depth_bits_array
, stencil_bits_array
,
530 depth_buffer_factor
, back_buffer_modes
,
532 msaa_samples_array
, 1);
535 __DRIconfig
**configs_a8r8g8b8
;
536 __DRIconfig
**configs_x8r8g8b8
;
538 configs_a8r8g8b8
= driCreateConfigs(GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
,
544 msaa_samples_array
, 1);
545 configs_x8r8g8b8
= driCreateConfigs(GL_BGR
, GL_UNSIGNED_INT_8_8_8_8_REV
,
551 msaa_samples_array
, 1);
552 configs
= driConcatConfigs(configs_a8r8g8b8
, configs_x8r8g8b8
);
555 if (configs
== NULL
) {
556 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
561 /* Mark the visual as slow if there are "fake" stencil bits.
563 for (i
= 0; configs
[i
]; i
++) {
564 m
= &configs
[i
]->modes
;
565 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
566 m
->visualRating
= GLX_SLOW_CONFIG
;
574 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
576 GLboolean gem_disable
= getenv("INTEL_NO_GEM") != NULL
;
578 GLboolean gem_supported
;
579 struct drm_i915_getparam gp
;
580 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
583 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
585 gp
.param
= I915_PARAM_HAS_GEM
;
586 gp
.value
= &gem_kernel
;
588 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
590 /* If we've got a new enough DDX that's initializing GEM and giving us
591 * object handles for the shared buffers, use that.
593 intelScreen
->ttm
= GL_FALSE
;
594 if (intelScreen
->driScrnPriv
->dri2
.enabled
)
595 gem_supported
= GL_TRUE
;
596 else if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9 &&
598 intelScreen
->front
.bo_handle
!= -1)
599 gem_supported
= GL_TRUE
;
601 gem_supported
= GL_FALSE
;
603 if (!gem_disable
&& gem_supported
) {
604 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
605 if (intelScreen
->bufmgr
!= NULL
)
606 intelScreen
->ttm
= GL_TRUE
;
608 /* Otherwise, use the classic buffer manager. */
609 if (intelScreen
->bufmgr
== NULL
) {
611 fprintf(stderr
, "GEM disabled. Using classic.\n");
613 fprintf(stderr
, "Failed to initialize GEM. "
614 "Falling back to classic.\n");
617 if (intelScreen
->tex
.size
== 0) {
618 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
623 intelScreen
->bufmgr
=
624 intel_bufmgr_fake_init(spriv
->fd
,
625 intelScreen
->tex
.offset
,
626 intelScreen
->tex
.map
,
627 intelScreen
->tex
.size
,
628 (unsigned int * volatile)
629 &intelScreen
->sarea
->last_dispatch
);
632 if (intel_get_param(spriv
, I915_PARAM_NUM_FENCES_AVAIL
, &num_fences
))
633 intelScreen
->kernel_exec_fencing
= !!num_fences
;
635 intelScreen
->kernel_exec_fencing
= GL_FALSE
;
641 * This is the driver specific part of the createNewScreen entry point.
642 * Called when using legacy DRI.
644 * \todo maybe fold this into intelInitDriver
646 * \return the __GLcontextModes supported by this driver
648 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
650 intelScreenPrivate
*intelScreen
;
652 static const __DRIversion ddx_expected
= { 1, 5, 0 };
654 static const __DRIversion ddx_expected
= { 1, 6, 0 };
656 static const __DRIversion dri_expected
= { 4, 0, 0 };
657 static const __DRIversion drm_expected
= { 1, 5, 0 };
658 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
660 if (!driCheckDriDdxDrmVersions2("i915",
661 &psp
->dri_version
, &dri_expected
,
662 &psp
->ddx_version
, &ddx_expected
,
663 &psp
->drm_version
, &drm_expected
)) {
667 /* Calling driInitExtensions here, with a NULL context pointer,
668 * does not actually enable the extensions. It just makes sure
669 * that all the dispatch offsets for all the extensions that
670 * *might* be enables are known. This is needed because the
671 * dispatch offsets need to be known when _mesa_context_create is
672 * called, but we can't enable the extensions until we have a
675 * Hello chicken. Hello egg. How are you two today?
677 intelInitExtensions(NULL
, GL_TRUE
);
679 if (!intelInitDriver(psp
))
682 psp
->extensions
= intelScreenExtensions
;
684 intelScreen
= psp
->private;
685 if (!intel_init_bufmgr(intelScreen
))
688 return (const __DRIconfig
**)
689 intelFillInModes(psp
, dri_priv
->cpp
* 8,
690 (dri_priv
->cpp
== 2) ? 16 : 24,
691 (dri_priv
->cpp
== 2) ? 0 : 8, 1);
694 struct intel_context
*intelScreenContext(intelScreenPrivate
*intelScreen
)
697 * This should probably change to have the screen allocate a dummy
698 * context at screen creation. For now just use the current context.
701 GET_CURRENT_CONTEXT(ctx
);
703 _mesa_problem(NULL
, "No current context in intelScreenContext\n");
706 return intel_context(ctx
);
710 * This is the driver specific part of the createNewScreen entry point.
711 * Called when using DRI2.
713 * \return the __GLcontextModes supported by this driver
716 __DRIconfig
**intelInitScreen2(__DRIscreenPrivate
*psp
)
718 intelScreenPrivate
*intelScreen
;
721 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
722 * support pageflipping at all.
724 static const GLenum back_buffer_modes
[] = {
725 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
727 uint8_t depth_bits
[4], stencil_bits
[4], msaa_samples_array
[1];
729 __DRIconfig
**configs
= NULL
;
731 /* Calling driInitExtensions here, with a NULL context pointer,
732 * does not actually enable the extensions. It just makes sure
733 * that all the dispatch offsets for all the extensions that
734 * *might* be enables are known. This is needed because the
735 * dispatch offsets need to be known when _mesa_context_create is
736 * called, but we can't enable the extensions until we have a
739 * Hello chicken. Hello egg. How are you two today?
741 intelInitExtensions(NULL
, GL_TRUE
);
743 /* Allocate the private area */
744 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
746 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
749 /* parse information in __driConfigOptions */
750 driParseOptionInfo(&intelScreen
->optionCache
,
751 __driConfigOptions
, __driNConfigOptions
);
753 intelScreen
->driScrnPriv
= psp
;
754 psp
->private = (void *) intelScreen
;
756 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
758 /* Determine chipset ID */
759 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
760 &intelScreen
->deviceID
))
763 if (!intel_init_bufmgr(intelScreen
))
766 intelScreen
->irq_active
= 1;
767 psp
->extensions
= intelScreenExtensions
;
778 msaa_samples_array
[0] = 0;
780 fb_format
[0] = GL_RGB
;
781 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
783 fb_format
[1] = GL_BGR
;
784 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
786 fb_format
[2] = GL_BGRA
;
787 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
792 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
793 __DRIconfig
**new_configs
;
796 /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer
797 * with the same cpp as the drawable. So we can't support depth cpp !=
798 * color cpp currently.
800 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
813 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
818 ARRAY_SIZE(back_buffer_modes
),
820 ARRAY_SIZE(msaa_samples_array
));
822 configs
= new_configs
;
824 configs
= driConcatConfigs(configs
, new_configs
);
827 if (configs
== NULL
) {
828 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
833 return (const __DRIconfig
**)configs
;
836 const struct __DriverAPIRec driDriverAPI
= {
837 .InitScreen
= intelInitScreen
,
838 .DestroyScreen
= intelDestroyScreen
,
839 .CreateContext
= intelCreateContext
,
840 .DestroyContext
= intelDestroyContext
,
841 .CreateBuffer
= intelCreateBuffer
,
842 .DestroyBuffer
= intelDestroyBuffer
,
843 .SwapBuffers
= intelSwapBuffers
,
844 .MakeCurrent
= intelMakeCurrent
,
845 .UnbindContext
= intelUnbindContext
,
846 .GetSwapInfo
= intelGetSwapInfo
,
847 .GetDrawableMSC
= driDrawableGetMSC32
,
848 .WaitForMSC
= driWaitForMSC32
,
849 .CopySubBuffer
= intelCopySubBuffer
,
851 .InitScreen2
= intelInitScreen2
,