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).")
82 DRI_CONF_OPT_BEGIN(fragment_shader
, bool, false)
83 DRI_CONF_DESC(en
, "Enable limited ARB_fragment_shader support on 915/945.")
87 DRI_CONF_SECTION_QUALITY
88 DRI_CONF_FORCE_S3TC_ENABLE(false)
89 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
91 DRI_CONF_SECTION_DEBUG
92 DRI_CONF_NO_RAST(false)
93 DRI_CONF_ALWAYS_FLUSH_BATCH(false)
94 DRI_CONF_ALWAYS_FLUSH_CACHE(false)
96 DRI_CONF_OPT_BEGIN(stub_occlusion_query
, bool, false)
97 DRI_CONF_DESC(en
, "Enable stub ARB_occlusion_query support on 915/945.")
102 const GLuint __driNConfigOptions
= 12;
104 #ifdef USE_NEW_INTERFACE
105 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
106 #endif /*USE_NEW_INTERFACE */
109 * Map all the memory regions described by the screen.
110 * \return GL_TRUE if success, GL_FALSE if error.
113 intelMapScreenRegions(__DRIscreenPrivate
* sPriv
)
115 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
118 _mesa_printf("TEX 0x%08x ", intelScreen
->tex
.handle
);
119 if (intelScreen
->tex
.size
!= 0) {
120 if (drmMap(sPriv
->fd
,
121 intelScreen
->tex
.handle
,
122 intelScreen
->tex
.size
,
123 (drmAddress
*) & intelScreen
->tex
.map
) != 0) {
124 intelUnmapScreenRegions(intelScreen
);
133 intelUnmapScreenRegions(intelScreenPrivate
* intelScreen
)
135 if (intelScreen
->tex
.map
) {
136 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
137 intelScreen
->tex
.map
= NULL
;
143 intelPrintDRIInfo(intelScreenPrivate
* intelScreen
,
144 __DRIscreenPrivate
* sPriv
, I830DRIPtr gDRIPriv
)
146 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
147 intelScreen
->front
.size
, intelScreen
->front
.offset
,
149 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
150 intelScreen
->back
.size
, intelScreen
->back
.offset
,
152 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
153 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
155 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
156 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
157 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
162 intelPrintSAREA(const drm_i915_sarea_t
* sarea
)
164 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
,
166 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
168 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
169 sarea
->front_offset
, sarea
->front_size
,
170 (unsigned) sarea
->front_handle
, sarea
->front_tiled
);
172 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
173 sarea
->back_offset
, sarea
->back_size
,
174 (unsigned) sarea
->back_handle
, sarea
->back_tiled
);
175 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
176 sarea
->depth_offset
, sarea
->depth_size
,
177 (unsigned) sarea
->depth_handle
, sarea
->depth_tiled
);
178 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
179 sarea
->tex_offset
, sarea
->tex_size
, (unsigned) sarea
->tex_handle
);
184 * A number of the screen parameters are obtained/computed from
185 * information in the SAREA. This function updates those parameters.
188 intelUpdateScreenFromSAREA(intelScreenPrivate
* intelScreen
,
189 drm_i915_sarea_t
* sarea
)
191 intelScreen
->width
= sarea
->width
;
192 intelScreen
->height
= sarea
->height
;
193 intelScreen
->pitch
= sarea
->pitch
;
195 intelScreen
->front
.offset
= sarea
->front_offset
;
196 intelScreen
->front
.handle
= sarea
->front_handle
;
197 intelScreen
->front
.size
= sarea
->front_size
;
198 intelScreen
->front
.tiled
= sarea
->front_tiled
;
200 intelScreen
->back
.offset
= sarea
->back_offset
;
201 intelScreen
->back
.handle
= sarea
->back_handle
;
202 intelScreen
->back
.size
= sarea
->back_size
;
203 intelScreen
->back
.tiled
= sarea
->back_tiled
;
205 intelScreen
->depth
.offset
= sarea
->depth_offset
;
206 intelScreen
->depth
.handle
= sarea
->depth_handle
;
207 intelScreen
->depth
.size
= sarea
->depth_size
;
208 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
210 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9) {
211 intelScreen
->front
.bo_handle
= sarea
->front_bo_handle
;
212 intelScreen
->back
.bo_handle
= sarea
->back_bo_handle
;
213 intelScreen
->depth
.bo_handle
= sarea
->depth_bo_handle
;
215 intelScreen
->front
.bo_handle
= -1;
216 intelScreen
->back
.bo_handle
= -1;
217 intelScreen
->depth
.bo_handle
= -1;
220 intelScreen
->tex
.offset
= sarea
->tex_offset
;
221 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
222 intelScreen
->tex
.handle
= sarea
->tex_handle
;
223 intelScreen
->tex
.size
= sarea
->tex_size
;
226 intelPrintSAREA(sarea
);
229 static const __DRItexOffsetExtension intelTexOffsetExtension
= {
230 { __DRI_TEX_OFFSET
},
234 static const __DRItexBufferExtension intelTexBufferExtension
= {
235 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
240 static const __DRIextension
*intelScreenExtensions
[] = {
241 &driReadDrawableExtension
,
242 &driCopySubBufferExtension
.base
,
243 &driSwapControlExtension
.base
,
244 &driFrameTrackingExtension
.base
,
245 &driMediaStreamCounterExtension
.base
,
246 &intelTexOffsetExtension
.base
,
247 &intelTexBufferExtension
.base
,
252 intel_get_param(__DRIscreenPrivate
*psp
, int param
, int *value
)
255 struct drm_i915_getparam gp
;
260 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
262 _mesa_warning(NULL
, "drm_i915_getparam: %d", ret
);
269 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
271 intelScreenPrivate
*intelScreen
;
272 I830DRIPtr gDRIPriv
= (I830DRIPtr
) sPriv
->pDevPriv
;
273 drm_i915_sarea_t
*sarea
;
275 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
277 "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
281 /* Allocate the private area */
282 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
284 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
287 /* parse information in __driConfigOptions */
288 driParseOptionInfo(&intelScreen
->optionCache
,
289 __driConfigOptions
, __driNConfigOptions
);
291 intelScreen
->driScrnPriv
= sPriv
;
292 sPriv
->private = (void *) intelScreen
;
293 sarea
= (drm_i915_sarea_t
*)
294 (((GLubyte
*) sPriv
->pSAREA
) + gDRIPriv
->sarea_priv_offset
);
295 intelScreen
->sarea
= sarea
;
297 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
299 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
301 if (!intelMapScreenRegions(sPriv
)) {
302 fprintf(stderr
, "\nERROR! mapping regions\n");
303 _mesa_free(intelScreen
);
304 sPriv
->private = NULL
;
309 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
311 intelScreen
->drmMinor
= sPriv
->drm_version
.minor
;
313 /* Determine if IRQs are active? */
314 if (!intel_get_param(sPriv
, I915_PARAM_IRQ_ACTIVE
,
315 &intelScreen
->irq_active
))
318 sPriv
->extensions
= intelScreenExtensions
;
325 intelDestroyScreen(__DRIscreenPrivate
* sPriv
)
327 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
329 dri_bufmgr_destroy(intelScreen
->bufmgr
);
330 intelUnmapScreenRegions(intelScreen
);
331 driDestroyOptionInfo(&intelScreen
->optionCache
);
334 sPriv
->private = NULL
;
339 * This is called when we need to set up GL rendering to a new X window.
342 intelCreateBuffer(__DRIscreenPrivate
* driScrnPriv
,
343 __DRIdrawablePrivate
* driDrawPriv
,
344 const __GLcontextModes
* mesaVis
, GLboolean isPixmap
)
347 return GL_FALSE
; /* not implemented */
350 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
351 mesaVis
->depthBits
!= 24);
354 struct intel_framebuffer
*intel_fb
= CALLOC_STRUCT(intel_framebuffer
);
359 _mesa_initialize_framebuffer(&intel_fb
->Base
, mesaVis
);
361 if (mesaVis
->redBits
== 5)
362 rgbFormat
= MESA_FORMAT_RGB565
;
363 else if (mesaVis
->alphaBits
== 0)
364 rgbFormat
= MESA_FORMAT_XRGB8888
;
366 rgbFormat
= MESA_FORMAT_ARGB8888
;
368 /* setup the hardware-based renderbuffers */
369 intel_fb
->color_rb
[0] = intel_create_renderbuffer(rgbFormat
);
370 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_FRONT_LEFT
,
371 &intel_fb
->color_rb
[0]->Base
);
373 if (mesaVis
->doubleBufferMode
) {
374 intel_fb
->color_rb
[1] = intel_create_renderbuffer(rgbFormat
);
376 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_BACK_LEFT
,
377 &intel_fb
->color_rb
[1]->Base
);
381 if (mesaVis
->depthBits
== 24) {
382 if (mesaVis
->stencilBits
== 8) {
383 /* combined depth/stencil buffer */
384 struct intel_renderbuffer
*depthStencilRb
385 = intel_create_renderbuffer(MESA_FORMAT_S8_Z24
);
386 /* note: bind RB to two attachment points */
387 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
388 &depthStencilRb
->Base
);
389 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
,
390 &depthStencilRb
->Base
);
392 struct intel_renderbuffer
*depthRb
393 = intel_create_renderbuffer(MESA_FORMAT_X8_Z24
);
394 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
398 else if (mesaVis
->depthBits
== 16) {
399 /* just 16-bit depth buffer, no hw stencil */
400 struct intel_renderbuffer
*depthRb
401 = intel_create_renderbuffer(MESA_FORMAT_Z16
);
402 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
, &depthRb
->Base
);
405 /* now add any/all software-based renderbuffers we may need */
406 _mesa_add_soft_renderbuffers(&intel_fb
->Base
,
407 GL_FALSE
, /* never sw color */
408 GL_FALSE
, /* never sw depth */
409 swStencil
, mesaVis
->accumRedBits
> 0,
410 GL_FALSE
, /* never sw alpha */
411 GL_FALSE
/* never sw aux */ );
412 driDrawPriv
->driverPrivate
= (void *) intel_fb
;
419 intelDestroyBuffer(__DRIdrawablePrivate
* driDrawPriv
)
421 struct intel_framebuffer
*intel_fb
= driDrawPriv
->driverPrivate
;
422 struct intel_renderbuffer
*depth_rb
;
423 struct intel_renderbuffer
*stencil_rb
;
426 if (intel_fb
->color_rb
[0]) {
427 intel_renderbuffer_set_region(intel_fb
->color_rb
[0], NULL
);
430 if (intel_fb
->color_rb
[1]) {
431 intel_renderbuffer_set_region(intel_fb
->color_rb
[1], NULL
);
434 depth_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
);
436 intel_renderbuffer_set_region(depth_rb
, NULL
);
439 stencil_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
);
441 intel_renderbuffer_set_region(stencil_rb
, NULL
);
445 _mesa_reference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)), NULL
);
450 * Get information about previous buffer swaps.
453 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
455 struct intel_framebuffer
*intel_fb
;
457 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
458 || (sInfo
== NULL
)) {
462 intel_fb
= dPriv
->driverPrivate
;
463 sInfo
->swap_count
= intel_fb
->swap_count
;
464 sInfo
->swap_ust
= intel_fb
->swap_ust
;
465 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
467 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
468 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
475 /* There are probably better ways to do this, such as an
476 * init-designated function to register chipids and createcontext
479 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
480 __DRIcontextPrivate
* driContextPriv
,
481 void *sharedContextPrivate
);
483 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
484 __DRIcontextPrivate
* driContextPriv
,
485 void *sharedContextPrivate
);
486 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
487 __DRIcontextPrivate
* driContextPriv
,
488 void *sharedContextPrivate
);
491 intelCreateContext(const __GLcontextModes
* mesaVis
,
492 __DRIcontextPrivate
* driContextPriv
,
493 void *sharedContextPrivate
)
495 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
496 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
499 if (IS_9XX(intelScreen
->deviceID
)) {
500 if (!IS_965(intelScreen
->deviceID
)) {
501 return i915CreateContext(mesaVis
, driContextPriv
,
502 sharedContextPrivate
);
505 intelScreen
->no_vbo
= GL_TRUE
;
506 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
509 if (IS_965(intelScreen
->deviceID
))
510 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
512 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
517 static __DRIconfig
**
518 intelFillInModes(__DRIscreenPrivate
*psp
,
519 unsigned pixel_bits
, unsigned depth_bits
,
520 unsigned stencil_bits
, GLboolean have_back_buffer
)
522 __DRIconfig
**configs
;
524 unsigned depth_buffer_factor
;
525 unsigned back_buffer_factor
;
528 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
529 * support pageflipping at all.
531 static const GLenum back_buffer_modes
[] = {
532 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
535 uint8_t depth_bits_array
[3];
536 uint8_t stencil_bits_array
[3];
537 uint8_t msaa_samples_array
[1];
539 depth_bits_array
[0] = 0;
540 depth_bits_array
[1] = depth_bits
;
541 depth_bits_array
[2] = depth_bits
;
543 /* Just like with the accumulation buffer, always provide some modes
544 * with a stencil buffer. It will be a sw fallback, but some apps won't
547 stencil_bits_array
[0] = 0;
548 stencil_bits_array
[1] = 0;
549 if (depth_bits
== 24)
550 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
552 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
554 msaa_samples_array
[0] = 0;
556 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
557 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
559 if (pixel_bits
== 16) {
560 configs
= driCreateConfigs(GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
,
561 depth_bits_array
, stencil_bits_array
,
562 depth_buffer_factor
, back_buffer_modes
,
564 msaa_samples_array
, 1);
567 __DRIconfig
**configs_a8r8g8b8
;
568 __DRIconfig
**configs_x8r8g8b8
;
570 configs_a8r8g8b8
= driCreateConfigs(GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
,
576 msaa_samples_array
, 1);
577 configs_x8r8g8b8
= driCreateConfigs(GL_BGR
, GL_UNSIGNED_INT_8_8_8_8_REV
,
583 msaa_samples_array
, 1);
584 configs
= driConcatConfigs(configs_a8r8g8b8
, configs_x8r8g8b8
);
587 if (configs
== NULL
) {
588 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
593 /* Mark the visual as slow if there are "fake" stencil bits.
595 for (i
= 0; configs
[i
]; i
++) {
596 m
= &configs
[i
]->modes
;
597 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
598 m
->visualRating
= GLX_SLOW_CONFIG
;
606 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
609 GLboolean gem_supported
;
610 struct drm_i915_getparam gp
;
611 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
614 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
616 gp
.param
= I915_PARAM_HAS_GEM
;
617 gp
.value
= &gem_kernel
;
619 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
621 /* If we've got a new enough DDX that's initializing GEM and giving us
622 * object handles for the shared buffers, use that.
624 if (intelScreen
->driScrnPriv
->dri2
.enabled
)
625 gem_supported
= GL_TRUE
;
626 else if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9 &&
628 intelScreen
->front
.bo_handle
!= -1)
629 gem_supported
= GL_TRUE
;
631 fprintf(stderr
, "[%s:%u] Error initializing GEM.\n",
636 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
637 /* Otherwise, use the classic buffer manager. */
638 if (intelScreen
->bufmgr
== NULL
) {
639 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
644 if (intel_get_param(spriv
, I915_PARAM_NUM_FENCES_AVAIL
, &num_fences
))
645 intelScreen
->kernel_exec_fencing
= !!num_fences
;
647 intelScreen
->kernel_exec_fencing
= GL_FALSE
;
653 * This is the driver specific part of the createNewScreen entry point.
654 * Called when using legacy DRI.
656 * \todo maybe fold this into intelInitDriver
658 * \return the __GLcontextModes supported by this driver
660 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
662 intelScreenPrivate
*intelScreen
;
664 static const __DRIversion ddx_expected
= { 1, 5, 0 };
666 static const __DRIversion ddx_expected
= { 1, 6, 0 };
668 static const __DRIversion dri_expected
= { 4, 0, 0 };
669 static const __DRIversion drm_expected
= { 1, 5, 0 };
670 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
672 if (!driCheckDriDdxDrmVersions2("i915",
673 &psp
->dri_version
, &dri_expected
,
674 &psp
->ddx_version
, &ddx_expected
,
675 &psp
->drm_version
, &drm_expected
)) {
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 /* Allocate the private area */
732 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
734 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
737 /* parse information in __driConfigOptions */
738 driParseOptionInfo(&intelScreen
->optionCache
,
739 __driConfigOptions
, __driNConfigOptions
);
741 intelScreen
->driScrnPriv
= psp
;
742 psp
->private = (void *) intelScreen
;
744 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
746 /* Determine chipset ID */
747 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
748 &intelScreen
->deviceID
))
751 if (!intel_init_bufmgr(intelScreen
))
754 intelScreen
->irq_active
= 1;
755 psp
->extensions
= intelScreenExtensions
;
766 msaa_samples_array
[0] = 0;
768 fb_format
[0] = GL_RGB
;
769 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
771 fb_format
[1] = GL_BGR
;
772 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
774 fb_format
[2] = GL_BGRA
;
775 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
780 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
781 __DRIconfig
**new_configs
;
784 /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer
785 * with the same cpp as the drawable. So we can't support depth cpp !=
786 * color cpp currently.
788 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
801 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
806 ARRAY_SIZE(back_buffer_modes
),
808 ARRAY_SIZE(msaa_samples_array
));
810 configs
= new_configs
;
812 configs
= driConcatConfigs(configs
, new_configs
);
815 if (configs
== NULL
) {
816 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
821 return (const __DRIconfig
**)configs
;
824 const struct __DriverAPIRec driDriverAPI
= {
825 .InitScreen
= intelInitScreen
,
826 .DestroyScreen
= intelDestroyScreen
,
827 .CreateContext
= intelCreateContext
,
828 .DestroyContext
= intelDestroyContext
,
829 .CreateBuffer
= intelCreateBuffer
,
830 .DestroyBuffer
= intelDestroyBuffer
,
831 .SwapBuffers
= intelSwapBuffers
,
832 .MakeCurrent
= intelMakeCurrent
,
833 .UnbindContext
= intelUnbindContext
,
834 .GetSwapInfo
= intelGetSwapInfo
,
835 .GetDrawableMSC
= driDrawableGetMSC32
,
836 .WaitForMSC
= driWaitForMSC32
,
837 .CopySubBuffer
= intelCopySubBuffer
,
839 .InitScreen2
= intelInitScreen2
,