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_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC
)
61 /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
62 * DRI_CONF_BO_REUSE_ALL
64 DRI_CONF_OPT_BEGIN_V(bo_reuse
, enum, 1, "0:1")
65 DRI_CONF_DESC_BEGIN(en
, "Buffer object reuse")
66 DRI_CONF_ENUM(0, "Disable buffer object reuse")
67 DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
72 DRI_CONF_TEXTURE_TILING(false)
74 DRI_CONF_TEXTURE_TILING(true)
77 DRI_CONF_OPT_BEGIN(early_z
, bool, false)
78 DRI_CONF_DESC(en
, "Enable early Z in classic mode (unstable, 945-only).")
81 DRI_CONF_OPT_BEGIN(fragment_shader
, bool, false)
82 DRI_CONF_DESC(en
, "Enable limited ARB_fragment_shader support on 915/945.")
86 DRI_CONF_SECTION_QUALITY
87 DRI_CONF_FORCE_S3TC_ENABLE(false)
88 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
90 DRI_CONF_SECTION_DEBUG
91 DRI_CONF_NO_RAST(false)
92 DRI_CONF_ALWAYS_FLUSH_BATCH(false)
93 DRI_CONF_ALWAYS_FLUSH_CACHE(false)
95 DRI_CONF_OPT_BEGIN(stub_occlusion_query
, bool, false)
96 DRI_CONF_DESC(en
, "Enable stub ARB_occlusion_query support on 915/945.")
101 const GLuint __driNConfigOptions
= 11;
103 #ifdef USE_NEW_INTERFACE
104 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
105 #endif /*USE_NEW_INTERFACE */
108 * Map all the memory regions described by the screen.
109 * \return GL_TRUE if success, GL_FALSE if error.
112 intelMapScreenRegions(__DRIscreenPrivate
* sPriv
)
114 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
117 _mesa_printf("TEX 0x%08x ", intelScreen
->tex
.handle
);
118 if (intelScreen
->tex
.size
!= 0) {
119 if (drmMap(sPriv
->fd
,
120 intelScreen
->tex
.handle
,
121 intelScreen
->tex
.size
,
122 (drmAddress
*) & intelScreen
->tex
.map
) != 0) {
123 intelUnmapScreenRegions(intelScreen
);
132 intelUnmapScreenRegions(intelScreenPrivate
* intelScreen
)
134 if (intelScreen
->tex
.map
) {
135 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
136 intelScreen
->tex
.map
= NULL
;
142 intelPrintDRIInfo(intelScreenPrivate
* intelScreen
,
143 __DRIscreenPrivate
* sPriv
, I830DRIPtr gDRIPriv
)
145 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
146 intelScreen
->front
.size
, intelScreen
->front
.offset
,
148 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
149 intelScreen
->back
.size
, intelScreen
->back
.offset
,
151 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
152 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
154 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
155 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
156 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
161 intelPrintSAREA(const drm_i915_sarea_t
* sarea
)
163 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
,
165 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
167 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
168 sarea
->front_offset
, sarea
->front_size
,
169 (unsigned) sarea
->front_handle
, sarea
->front_tiled
);
171 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
172 sarea
->back_offset
, sarea
->back_size
,
173 (unsigned) sarea
->back_handle
, sarea
->back_tiled
);
174 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
175 sarea
->depth_offset
, sarea
->depth_size
,
176 (unsigned) sarea
->depth_handle
, sarea
->depth_tiled
);
177 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
178 sarea
->tex_offset
, sarea
->tex_size
, (unsigned) sarea
->tex_handle
);
183 * A number of the screen parameters are obtained/computed from
184 * information in the SAREA. This function updates those parameters.
187 intelUpdateScreenFromSAREA(intelScreenPrivate
* intelScreen
,
188 drm_i915_sarea_t
* sarea
)
190 intelScreen
->width
= sarea
->width
;
191 intelScreen
->height
= sarea
->height
;
192 intelScreen
->pitch
= sarea
->pitch
;
194 intelScreen
->front
.offset
= sarea
->front_offset
;
195 intelScreen
->front
.handle
= sarea
->front_handle
;
196 intelScreen
->front
.size
= sarea
->front_size
;
197 intelScreen
->front
.tiled
= sarea
->front_tiled
;
199 intelScreen
->back
.offset
= sarea
->back_offset
;
200 intelScreen
->back
.handle
= sarea
->back_handle
;
201 intelScreen
->back
.size
= sarea
->back_size
;
202 intelScreen
->back
.tiled
= sarea
->back_tiled
;
204 intelScreen
->depth
.offset
= sarea
->depth_offset
;
205 intelScreen
->depth
.handle
= sarea
->depth_handle
;
206 intelScreen
->depth
.size
= sarea
->depth_size
;
207 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
209 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9) {
210 intelScreen
->front
.bo_handle
= sarea
->front_bo_handle
;
211 intelScreen
->back
.bo_handle
= sarea
->back_bo_handle
;
212 intelScreen
->depth
.bo_handle
= sarea
->depth_bo_handle
;
214 intelScreen
->front
.bo_handle
= -1;
215 intelScreen
->back
.bo_handle
= -1;
216 intelScreen
->depth
.bo_handle
= -1;
219 intelScreen
->tex
.offset
= sarea
->tex_offset
;
220 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
221 intelScreen
->tex
.handle
= sarea
->tex_handle
;
222 intelScreen
->tex
.size
= sarea
->tex_size
;
225 intelPrintSAREA(sarea
);
228 static const __DRItexOffsetExtension intelTexOffsetExtension
= {
229 { __DRI_TEX_OFFSET
},
233 static const __DRItexBufferExtension intelTexBufferExtension
= {
234 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
239 static const __DRIextension
*intelScreenExtensions
[] = {
240 &driReadDrawableExtension
,
241 &driCopySubBufferExtension
.base
,
242 &driSwapControlExtension
.base
,
243 &driFrameTrackingExtension
.base
,
244 &driMediaStreamCounterExtension
.base
,
245 &intelTexOffsetExtension
.base
,
246 &intelTexBufferExtension
.base
,
251 intel_get_param(__DRIscreenPrivate
*psp
, int param
, int *value
)
254 struct drm_i915_getparam gp
;
259 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
261 _mesa_warning(NULL
, "drm_i915_getparam: %d", ret
);
268 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
270 intelScreenPrivate
*intelScreen
;
271 I830DRIPtr gDRIPriv
= (I830DRIPtr
) sPriv
->pDevPriv
;
272 drm_i915_sarea_t
*sarea
;
274 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
276 "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
280 /* Allocate the private area */
281 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
283 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
286 /* parse information in __driConfigOptions */
287 driParseOptionInfo(&intelScreen
->optionCache
,
288 __driConfigOptions
, __driNConfigOptions
);
290 intelScreen
->driScrnPriv
= sPriv
;
291 sPriv
->private = (void *) intelScreen
;
292 sarea
= (drm_i915_sarea_t
*)
293 (((GLubyte
*) sPriv
->pSAREA
) + gDRIPriv
->sarea_priv_offset
);
294 intelScreen
->sarea
= sarea
;
296 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
298 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
300 if (!intelMapScreenRegions(sPriv
)) {
301 fprintf(stderr
, "\nERROR! mapping regions\n");
302 _mesa_free(intelScreen
);
303 sPriv
->private = NULL
;
308 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
310 intelScreen
->drmMinor
= sPriv
->drm_version
.minor
;
312 /* Determine if IRQs are active? */
313 if (!intel_get_param(sPriv
, I915_PARAM_IRQ_ACTIVE
,
314 &intelScreen
->irq_active
))
317 sPriv
->extensions
= intelScreenExtensions
;
324 intelDestroyScreen(__DRIscreenPrivate
* sPriv
)
326 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
328 dri_bufmgr_destroy(intelScreen
->bufmgr
);
329 intelUnmapScreenRegions(intelScreen
);
330 driDestroyOptionInfo(&intelScreen
->optionCache
);
333 sPriv
->private = NULL
;
338 * This is called when we need to set up GL rendering to a new X window.
341 intelCreateBuffer(__DRIscreenPrivate
* driScrnPriv
,
342 __DRIdrawablePrivate
* driDrawPriv
,
343 const __GLcontextModes
* mesaVis
, GLboolean isPixmap
)
346 return GL_FALSE
; /* not implemented */
349 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
350 mesaVis
->depthBits
!= 24);
353 struct intel_framebuffer
*intel_fb
= CALLOC_STRUCT(intel_framebuffer
);
358 _mesa_initialize_framebuffer(&intel_fb
->Base
, mesaVis
);
360 if (mesaVis
->redBits
== 5)
361 rgbFormat
= MESA_FORMAT_RGB565
;
362 else if (mesaVis
->alphaBits
== 0)
363 rgbFormat
= MESA_FORMAT_XRGB8888
;
365 rgbFormat
= MESA_FORMAT_ARGB8888
;
367 /* setup the hardware-based renderbuffers */
368 intel_fb
->color_rb
[0] = intel_create_renderbuffer(rgbFormat
);
369 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_FRONT_LEFT
,
370 &intel_fb
->color_rb
[0]->Base
);
372 if (mesaVis
->doubleBufferMode
) {
373 intel_fb
->color_rb
[1] = intel_create_renderbuffer(rgbFormat
);
375 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_BACK_LEFT
,
376 &intel_fb
->color_rb
[1]->Base
);
380 if (mesaVis
->depthBits
== 24) {
381 if (mesaVis
->stencilBits
== 8) {
382 /* combined depth/stencil buffer */
383 struct intel_renderbuffer
*depthStencilRb
384 = intel_create_renderbuffer(MESA_FORMAT_S8_Z24
);
385 /* note: bind RB to two attachment points */
386 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
387 &depthStencilRb
->Base
);
388 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
,
389 &depthStencilRb
->Base
);
391 struct intel_renderbuffer
*depthRb
392 = intel_create_renderbuffer(MESA_FORMAT_X8_Z24
);
393 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
397 else if (mesaVis
->depthBits
== 16) {
398 /* just 16-bit depth buffer, no hw stencil */
399 struct intel_renderbuffer
*depthRb
400 = intel_create_renderbuffer(MESA_FORMAT_Z16
);
401 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
, &depthRb
->Base
);
404 /* now add any/all software-based renderbuffers we may need */
405 _mesa_add_soft_renderbuffers(&intel_fb
->Base
,
406 GL_FALSE
, /* never sw color */
407 GL_FALSE
, /* never sw depth */
408 swStencil
, mesaVis
->accumRedBits
> 0,
409 GL_FALSE
, /* never sw alpha */
410 GL_FALSE
/* never sw aux */ );
411 driDrawPriv
->driverPrivate
= (void *) intel_fb
;
418 intelDestroyBuffer(__DRIdrawablePrivate
* driDrawPriv
)
420 struct intel_framebuffer
*intel_fb
= driDrawPriv
->driverPrivate
;
421 struct intel_renderbuffer
*depth_rb
;
422 struct intel_renderbuffer
*stencil_rb
;
425 if (intel_fb
->color_rb
[0]) {
426 intel_renderbuffer_set_region(intel_fb
->color_rb
[0], NULL
);
429 if (intel_fb
->color_rb
[1]) {
430 intel_renderbuffer_set_region(intel_fb
->color_rb
[1], NULL
);
433 depth_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
);
435 intel_renderbuffer_set_region(depth_rb
, NULL
);
438 stencil_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
);
440 intel_renderbuffer_set_region(stencil_rb
, NULL
);
444 _mesa_reference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)), NULL
);
449 * Get information about previous buffer swaps.
452 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
454 struct intel_framebuffer
*intel_fb
;
456 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
457 || (sInfo
== NULL
)) {
461 intel_fb
= dPriv
->driverPrivate
;
462 sInfo
->swap_count
= intel_fb
->swap_count
;
463 sInfo
->swap_ust
= intel_fb
->swap_ust
;
464 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
466 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
467 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
474 /* There are probably better ways to do this, such as an
475 * init-designated function to register chipids and createcontext
478 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
479 __DRIcontextPrivate
* driContextPriv
,
480 void *sharedContextPrivate
);
482 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
483 __DRIcontextPrivate
* driContextPriv
,
484 void *sharedContextPrivate
);
485 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
486 __DRIcontextPrivate
* driContextPriv
,
487 void *sharedContextPrivate
);
490 intelCreateContext(const __GLcontextModes
* mesaVis
,
491 __DRIcontextPrivate
* driContextPriv
,
492 void *sharedContextPrivate
)
494 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
495 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
498 if (IS_9XX(intelScreen
->deviceID
)) {
499 if (!IS_965(intelScreen
->deviceID
)) {
500 return i915CreateContext(mesaVis
, driContextPriv
,
501 sharedContextPrivate
);
504 intelScreen
->no_vbo
= GL_TRUE
;
505 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
508 if (IS_965(intelScreen
->deviceID
))
509 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
511 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
516 static __DRIconfig
**
517 intelFillInModes(__DRIscreenPrivate
*psp
,
518 unsigned pixel_bits
, unsigned depth_bits
,
519 unsigned stencil_bits
, GLboolean have_back_buffer
)
521 __DRIconfig
**configs
;
523 unsigned depth_buffer_factor
;
524 unsigned back_buffer_factor
;
527 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
528 * support pageflipping at all.
530 static const GLenum back_buffer_modes
[] = {
531 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
534 uint8_t depth_bits_array
[3];
535 uint8_t stencil_bits_array
[3];
536 uint8_t msaa_samples_array
[1];
538 depth_bits_array
[0] = 0;
539 depth_bits_array
[1] = depth_bits
;
540 depth_bits_array
[2] = depth_bits
;
542 /* Just like with the accumulation buffer, always provide some modes
543 * with a stencil buffer. It will be a sw fallback, but some apps won't
546 stencil_bits_array
[0] = 0;
547 stencil_bits_array
[1] = 0;
548 if (depth_bits
== 24)
549 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
551 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
553 msaa_samples_array
[0] = 0;
555 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
556 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
558 if (pixel_bits
== 16) {
559 configs
= driCreateConfigs(GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
,
560 depth_bits_array
, stencil_bits_array
,
561 depth_buffer_factor
, back_buffer_modes
,
563 msaa_samples_array
, 1);
566 __DRIconfig
**configs_a8r8g8b8
;
567 __DRIconfig
**configs_x8r8g8b8
;
569 configs_a8r8g8b8
= driCreateConfigs(GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
,
575 msaa_samples_array
, 1);
576 configs_x8r8g8b8
= driCreateConfigs(GL_BGR
, GL_UNSIGNED_INT_8_8_8_8_REV
,
582 msaa_samples_array
, 1);
583 configs
= driConcatConfigs(configs_a8r8g8b8
, configs_x8r8g8b8
);
586 if (configs
== NULL
) {
587 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
592 /* Mark the visual as slow if there are "fake" stencil bits.
594 for (i
= 0; configs
[i
]; i
++) {
595 m
= &configs
[i
]->modes
;
596 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
597 m
->visualRating
= GLX_SLOW_CONFIG
;
605 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
608 struct drm_i915_getparam gp
;
609 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
612 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
614 gp
.param
= I915_PARAM_HAS_GEM
;
615 gp
.value
= &gem_kernel
;
617 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
619 /* If we've got a new enough DDX that's initializing GEM and giving us
620 * object handles for the shared buffers, use that.
622 if (!intelScreen
->driScrnPriv
->dri2
.enabled
&&
623 intelScreen
->driScrnPriv
->ddx_version
.minor
< 9) {
624 fprintf(stderr
, "[%s:%u] Error initializing GEM.\n",
629 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
630 /* Otherwise, use the classic buffer manager. */
631 if (intelScreen
->bufmgr
== NULL
) {
632 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
637 if (intel_get_param(spriv
, I915_PARAM_NUM_FENCES_AVAIL
, &num_fences
))
638 intelScreen
->kernel_exec_fencing
= !!num_fences
;
640 intelScreen
->kernel_exec_fencing
= GL_FALSE
;
646 * This is the driver specific part of the createNewScreen entry point.
647 * Called when using legacy DRI.
649 * \todo maybe fold this into intelInitDriver
651 * \return the __GLcontextModes supported by this driver
653 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
655 intelScreenPrivate
*intelScreen
;
657 static const __DRIversion ddx_expected
= { 1, 5, 0 };
659 static const __DRIversion ddx_expected
= { 1, 6, 0 };
661 static const __DRIversion dri_expected
= { 4, 0, 0 };
662 static const __DRIversion drm_expected
= { 1, 5, 0 };
663 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
665 if (!driCheckDriDdxDrmVersions2("i915",
666 &psp
->dri_version
, &dri_expected
,
667 &psp
->ddx_version
, &ddx_expected
,
668 &psp
->drm_version
, &drm_expected
)) {
672 if (!intelInitDriver(psp
))
675 psp
->extensions
= intelScreenExtensions
;
677 intelScreen
= psp
->private;
678 if (!intel_init_bufmgr(intelScreen
))
681 return (const __DRIconfig
**)
682 intelFillInModes(psp
, dri_priv
->cpp
* 8,
683 (dri_priv
->cpp
== 2) ? 16 : 24,
684 (dri_priv
->cpp
== 2) ? 0 : 8, 1);
687 struct intel_context
*intelScreenContext(intelScreenPrivate
*intelScreen
)
690 * This should probably change to have the screen allocate a dummy
691 * context at screen creation. For now just use the current context.
694 GET_CURRENT_CONTEXT(ctx
);
696 _mesa_problem(NULL
, "No current context in intelScreenContext\n");
699 return intel_context(ctx
);
703 * This is the driver specific part of the createNewScreen entry point.
704 * Called when using DRI2.
706 * \return the __GLcontextModes supported by this driver
709 __DRIconfig
**intelInitScreen2(__DRIscreenPrivate
*psp
)
711 intelScreenPrivate
*intelScreen
;
714 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
715 * support pageflipping at all.
717 static const GLenum back_buffer_modes
[] = {
718 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
720 uint8_t depth_bits
[4], stencil_bits
[4], msaa_samples_array
[1];
722 __DRIconfig
**configs
= NULL
;
724 /* Allocate the private area */
725 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
727 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
730 /* parse information in __driConfigOptions */
731 driParseOptionInfo(&intelScreen
->optionCache
,
732 __driConfigOptions
, __driNConfigOptions
);
734 intelScreen
->driScrnPriv
= psp
;
735 psp
->private = (void *) intelScreen
;
737 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
739 /* Determine chipset ID */
740 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
741 &intelScreen
->deviceID
))
744 if (!intel_init_bufmgr(intelScreen
))
747 intelScreen
->irq_active
= 1;
748 psp
->extensions
= intelScreenExtensions
;
759 msaa_samples_array
[0] = 0;
761 fb_format
[0] = GL_RGB
;
762 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
764 fb_format
[1] = GL_BGR
;
765 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
767 fb_format
[2] = GL_BGRA
;
768 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
773 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
774 __DRIconfig
**new_configs
;
777 /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer
778 * with the same cpp as the drawable. So we can't support depth cpp !=
779 * color cpp currently.
781 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
794 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
799 ARRAY_SIZE(back_buffer_modes
),
801 ARRAY_SIZE(msaa_samples_array
));
803 configs
= new_configs
;
805 configs
= driConcatConfigs(configs
, new_configs
);
808 if (configs
== NULL
) {
809 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
814 return (const __DRIconfig
**)configs
;
817 const struct __DriverAPIRec driDriverAPI
= {
818 .InitScreen
= intelInitScreen
,
819 .DestroyScreen
= intelDestroyScreen
,
820 .CreateContext
= intelCreateContext
,
821 .DestroyContext
= intelDestroyContext
,
822 .CreateBuffer
= intelCreateBuffer
,
823 .DestroyBuffer
= intelDestroyBuffer
,
824 .SwapBuffers
= intelSwapBuffers
,
825 .MakeCurrent
= intelMakeCurrent
,
826 .UnbindContext
= intelUnbindContext
,
827 .GetSwapInfo
= intelGetSwapInfo
,
828 .GetDrawableMSC
= driDrawableGetMSC32
,
829 .WaitForMSC
= driWaitForMSC32
,
830 .CopySubBuffer
= intelCopySubBuffer
,
832 .InitScreen2
= intelInitScreen2
,