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)
98 const GLuint __driNConfigOptions
= 11;
100 #ifdef USE_NEW_INTERFACE
101 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
102 #endif /*USE_NEW_INTERFACE */
105 * Map all the memory regions described by the screen.
106 * \return GL_TRUE if success, GL_FALSE if error.
109 intelMapScreenRegions(__DRIscreenPrivate
* sPriv
)
111 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
114 _mesa_printf("TEX 0x%08x ", intelScreen
->tex
.handle
);
115 if (intelScreen
->tex
.size
!= 0) {
116 if (drmMap(sPriv
->fd
,
117 intelScreen
->tex
.handle
,
118 intelScreen
->tex
.size
,
119 (drmAddress
*) & intelScreen
->tex
.map
) != 0) {
120 intelUnmapScreenRegions(intelScreen
);
129 intelUnmapScreenRegions(intelScreenPrivate
* intelScreen
)
131 if (intelScreen
->tex
.map
) {
132 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
133 intelScreen
->tex
.map
= NULL
;
139 intelPrintDRIInfo(intelScreenPrivate
* intelScreen
,
140 __DRIscreenPrivate
* sPriv
, I830DRIPtr gDRIPriv
)
142 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
143 intelScreen
->front
.size
, intelScreen
->front
.offset
,
145 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
146 intelScreen
->back
.size
, intelScreen
->back
.offset
,
148 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
149 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
151 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
152 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
153 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
158 intelPrintSAREA(const drm_i915_sarea_t
* sarea
)
160 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
,
162 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
164 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
165 sarea
->front_offset
, sarea
->front_size
,
166 (unsigned) sarea
->front_handle
, sarea
->front_tiled
);
168 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
169 sarea
->back_offset
, sarea
->back_size
,
170 (unsigned) sarea
->back_handle
, sarea
->back_tiled
);
171 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
172 sarea
->depth_offset
, sarea
->depth_size
,
173 (unsigned) sarea
->depth_handle
, sarea
->depth_tiled
);
174 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
175 sarea
->tex_offset
, sarea
->tex_size
, (unsigned) sarea
->tex_handle
);
180 * A number of the screen parameters are obtained/computed from
181 * information in the SAREA. This function updates those parameters.
184 intelUpdateScreenFromSAREA(intelScreenPrivate
* intelScreen
,
185 drm_i915_sarea_t
* sarea
)
187 intelScreen
->width
= sarea
->width
;
188 intelScreen
->height
= sarea
->height
;
189 intelScreen
->pitch
= sarea
->pitch
;
191 intelScreen
->front
.offset
= sarea
->front_offset
;
192 intelScreen
->front
.handle
= sarea
->front_handle
;
193 intelScreen
->front
.size
= sarea
->front_size
;
194 intelScreen
->front
.tiled
= sarea
->front_tiled
;
196 intelScreen
->back
.offset
= sarea
->back_offset
;
197 intelScreen
->back
.handle
= sarea
->back_handle
;
198 intelScreen
->back
.size
= sarea
->back_size
;
199 intelScreen
->back
.tiled
= sarea
->back_tiled
;
201 intelScreen
->depth
.offset
= sarea
->depth_offset
;
202 intelScreen
->depth
.handle
= sarea
->depth_handle
;
203 intelScreen
->depth
.size
= sarea
->depth_size
;
204 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
206 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9) {
207 intelScreen
->front
.bo_handle
= sarea
->front_bo_handle
;
208 intelScreen
->back
.bo_handle
= sarea
->back_bo_handle
;
209 intelScreen
->depth
.bo_handle
= sarea
->depth_bo_handle
;
211 intelScreen
->front
.bo_handle
= -1;
212 intelScreen
->back
.bo_handle
= -1;
213 intelScreen
->depth
.bo_handle
= -1;
216 intelScreen
->tex
.offset
= sarea
->tex_offset
;
217 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
218 intelScreen
->tex
.handle
= sarea
->tex_handle
;
219 intelScreen
->tex
.size
= sarea
->tex_size
;
222 intelPrintSAREA(sarea
);
225 static const __DRItexOffsetExtension intelTexOffsetExtension
= {
226 { __DRI_TEX_OFFSET
},
230 static const __DRItexBufferExtension intelTexBufferExtension
= {
231 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
236 static const __DRIextension
*intelScreenExtensions
[] = {
237 &driReadDrawableExtension
,
238 &driCopySubBufferExtension
.base
,
239 &driSwapControlExtension
.base
,
240 &driFrameTrackingExtension
.base
,
241 &driMediaStreamCounterExtension
.base
,
242 &intelTexOffsetExtension
.base
,
243 &intelTexBufferExtension
.base
,
248 intel_get_param(__DRIscreenPrivate
*psp
, int param
, int *value
)
251 struct drm_i915_getparam gp
;
256 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
258 _mesa_warning(NULL
, "drm_i915_getparam: %d", ret
);
265 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
267 intelScreenPrivate
*intelScreen
;
268 I830DRIPtr gDRIPriv
= (I830DRIPtr
) sPriv
->pDevPriv
;
269 drm_i915_sarea_t
*sarea
;
271 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
273 "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
277 /* Allocate the private area */
278 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
280 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
283 /* parse information in __driConfigOptions */
284 driParseOptionInfo(&intelScreen
->optionCache
,
285 __driConfigOptions
, __driNConfigOptions
);
287 intelScreen
->driScrnPriv
= sPriv
;
288 sPriv
->private = (void *) intelScreen
;
289 sarea
= (drm_i915_sarea_t
*)
290 (((GLubyte
*) sPriv
->pSAREA
) + gDRIPriv
->sarea_priv_offset
);
291 intelScreen
->sarea
= sarea
;
293 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
295 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
297 if (!intelMapScreenRegions(sPriv
)) {
298 fprintf(stderr
, "\nERROR! mapping regions\n");
299 _mesa_free(intelScreen
);
300 sPriv
->private = NULL
;
305 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
307 intelScreen
->drmMinor
= sPriv
->drm_version
.minor
;
309 /* Determine if IRQs are active? */
310 if (!intel_get_param(sPriv
, I915_PARAM_IRQ_ACTIVE
,
311 &intelScreen
->irq_active
))
314 sPriv
->extensions
= intelScreenExtensions
;
321 intelDestroyScreen(__DRIscreenPrivate
* sPriv
)
323 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
325 dri_bufmgr_destroy(intelScreen
->bufmgr
);
326 intelUnmapScreenRegions(intelScreen
);
327 driDestroyOptionInfo(&intelScreen
->optionCache
);
330 sPriv
->private = NULL
;
335 * This is called when we need to set up GL rendering to a new X window.
338 intelCreateBuffer(__DRIscreenPrivate
* driScrnPriv
,
339 __DRIdrawablePrivate
* driDrawPriv
,
340 const __GLcontextModes
* mesaVis
, GLboolean isPixmap
)
343 return GL_FALSE
; /* not implemented */
346 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
347 mesaVis
->depthBits
!= 24);
350 struct intel_framebuffer
*intel_fb
= CALLOC_STRUCT(intel_framebuffer
);
355 _mesa_initialize_framebuffer(&intel_fb
->Base
, mesaVis
);
357 if (mesaVis
->redBits
== 5)
359 else if (mesaVis
->alphaBits
== 0)
362 rgbFormat
= GL_RGBA8
;
364 /* setup the hardware-based renderbuffers */
365 intel_fb
->color_rb
[0] = intel_create_renderbuffer(rgbFormat
);
366 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_FRONT_LEFT
,
367 &intel_fb
->color_rb
[0]->Base
);
369 if (mesaVis
->doubleBufferMode
) {
370 intel_fb
->color_rb
[1] = intel_create_renderbuffer(rgbFormat
);
372 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_BACK_LEFT
,
373 &intel_fb
->color_rb
[1]->Base
);
377 if (mesaVis
->depthBits
== 24) {
378 if (mesaVis
->stencilBits
== 8) {
379 /* combined depth/stencil buffer */
380 struct intel_renderbuffer
*depthStencilRb
381 = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT
);
382 /* note: bind RB to two attachment points */
383 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
384 &depthStencilRb
->Base
);
385 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
,
386 &depthStencilRb
->Base
);
388 struct intel_renderbuffer
*depthRb
389 = intel_create_renderbuffer(GL_DEPTH_COMPONENT24
);
390 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
394 else if (mesaVis
->depthBits
== 16) {
395 /* just 16-bit depth buffer, no hw stencil */
396 struct intel_renderbuffer
*depthRb
397 = intel_create_renderbuffer(GL_DEPTH_COMPONENT16
);
398 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
, &depthRb
->Base
);
401 /* now add any/all software-based renderbuffers we may need */
402 _mesa_add_soft_renderbuffers(&intel_fb
->Base
,
403 GL_FALSE
, /* never sw color */
404 GL_FALSE
, /* never sw depth */
405 swStencil
, mesaVis
->accumRedBits
> 0,
406 GL_FALSE
, /* never sw alpha */
407 GL_FALSE
/* never sw aux */ );
408 driDrawPriv
->driverPrivate
= (void *) intel_fb
;
415 intelDestroyBuffer(__DRIdrawablePrivate
* driDrawPriv
)
417 struct intel_framebuffer
*intel_fb
= driDrawPriv
->driverPrivate
;
418 struct intel_renderbuffer
*depth_rb
;
419 struct intel_renderbuffer
*stencil_rb
;
422 if (intel_fb
->color_rb
[0]) {
423 intel_renderbuffer_set_region(intel_fb
->color_rb
[0], NULL
);
426 if (intel_fb
->color_rb
[1]) {
427 intel_renderbuffer_set_region(intel_fb
->color_rb
[1], NULL
);
430 depth_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
);
432 intel_renderbuffer_set_region(depth_rb
, NULL
);
435 stencil_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
);
437 intel_renderbuffer_set_region(stencil_rb
, NULL
);
441 _mesa_reference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)), NULL
);
446 * Get information about previous buffer swaps.
449 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
451 struct intel_framebuffer
*intel_fb
;
453 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
454 || (sInfo
== NULL
)) {
458 intel_fb
= dPriv
->driverPrivate
;
459 sInfo
->swap_count
= intel_fb
->swap_count
;
460 sInfo
->swap_ust
= intel_fb
->swap_ust
;
461 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
463 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
464 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
471 /* There are probably better ways to do this, such as an
472 * init-designated function to register chipids and createcontext
475 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
476 __DRIcontextPrivate
* driContextPriv
,
477 void *sharedContextPrivate
);
479 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
480 __DRIcontextPrivate
* driContextPriv
,
481 void *sharedContextPrivate
);
482 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
483 __DRIcontextPrivate
* driContextPriv
,
484 void *sharedContextPrivate
);
487 intelCreateContext(const __GLcontextModes
* mesaVis
,
488 __DRIcontextPrivate
* driContextPriv
,
489 void *sharedContextPrivate
)
491 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
492 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
495 if (IS_9XX(intelScreen
->deviceID
)) {
496 if (!IS_965(intelScreen
->deviceID
)) {
497 return i915CreateContext(mesaVis
, driContextPriv
,
498 sharedContextPrivate
);
501 intelScreen
->no_vbo
= GL_TRUE
;
502 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
505 if (IS_965(intelScreen
->deviceID
))
506 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
508 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
513 static __DRIconfig
**
514 intelFillInModes(__DRIscreenPrivate
*psp
,
515 unsigned pixel_bits
, unsigned depth_bits
,
516 unsigned stencil_bits
, GLboolean have_back_buffer
)
518 __DRIconfig
**configs
;
520 unsigned depth_buffer_factor
;
521 unsigned back_buffer_factor
;
524 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
525 * support pageflipping at all.
527 static const GLenum back_buffer_modes
[] = {
528 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
531 uint8_t depth_bits_array
[3];
532 uint8_t stencil_bits_array
[3];
533 uint8_t msaa_samples_array
[1];
535 depth_bits_array
[0] = 0;
536 depth_bits_array
[1] = depth_bits
;
537 depth_bits_array
[2] = depth_bits
;
539 /* Just like with the accumulation buffer, always provide some modes
540 * with a stencil buffer. It will be a sw fallback, but some apps won't
543 stencil_bits_array
[0] = 0;
544 stencil_bits_array
[1] = 0;
545 if (depth_bits
== 24)
546 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
548 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
550 msaa_samples_array
[0] = 0;
552 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
553 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
555 if (pixel_bits
== 16) {
556 configs
= driCreateConfigs(GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
,
557 depth_bits_array
, stencil_bits_array
,
558 depth_buffer_factor
, back_buffer_modes
,
560 msaa_samples_array
, 1);
563 __DRIconfig
**configs_a8r8g8b8
;
564 __DRIconfig
**configs_x8r8g8b8
;
566 configs_a8r8g8b8
= driCreateConfigs(GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
,
572 msaa_samples_array
, 1);
573 configs_x8r8g8b8
= driCreateConfigs(GL_BGR
, GL_UNSIGNED_INT_8_8_8_8_REV
,
579 msaa_samples_array
, 1);
580 configs
= driConcatConfigs(configs_a8r8g8b8
, configs_x8r8g8b8
);
583 if (configs
== NULL
) {
584 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
589 /* Mark the visual as slow if there are "fake" stencil bits.
591 for (i
= 0; configs
[i
]; i
++) {
592 m
= &configs
[i
]->modes
;
593 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
594 m
->visualRating
= GLX_SLOW_CONFIG
;
602 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
604 GLboolean gem_disable
= getenv("INTEL_NO_GEM") != NULL
;
606 GLboolean gem_supported
;
607 struct drm_i915_getparam gp
;
608 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
611 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
613 gp
.param
= I915_PARAM_HAS_GEM
;
614 gp
.value
= &gem_kernel
;
616 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
618 /* If we've got a new enough DDX that's initializing GEM and giving us
619 * object handles for the shared buffers, use that.
621 intelScreen
->ttm
= GL_FALSE
;
622 if (intelScreen
->driScrnPriv
->dri2
.enabled
)
623 gem_supported
= GL_TRUE
;
624 else if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9 &&
626 intelScreen
->front
.bo_handle
!= -1)
627 gem_supported
= GL_TRUE
;
629 gem_supported
= GL_FALSE
;
631 if (!gem_disable
&& gem_supported
) {
632 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
633 if (intelScreen
->bufmgr
!= NULL
)
634 intelScreen
->ttm
= GL_TRUE
;
636 /* Otherwise, use the classic buffer manager. */
637 if (intelScreen
->bufmgr
== NULL
) {
639 _mesa_warning(NULL
, "GEM disabled. Using classic.");
642 "Failed to initialize GEM. Falling back to classic.");
645 if (intelScreen
->tex
.size
== 0) {
646 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
651 intelScreen
->bufmgr
=
652 intel_bufmgr_fake_init(spriv
->fd
,
653 intelScreen
->tex
.offset
,
654 intelScreen
->tex
.map
,
655 intelScreen
->tex
.size
,
656 (unsigned int * volatile)
657 &intelScreen
->sarea
->last_dispatch
);
660 if (intel_get_param(spriv
, I915_PARAM_NUM_FENCES_AVAIL
, &num_fences
))
661 intelScreen
->kernel_exec_fencing
= !!num_fences
;
663 intelScreen
->kernel_exec_fencing
= GL_FALSE
;
669 * This is the driver specific part of the createNewScreen entry point.
670 * Called when using legacy DRI.
672 * \todo maybe fold this into intelInitDriver
674 * \return the __GLcontextModes supported by this driver
676 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
678 intelScreenPrivate
*intelScreen
;
680 static const __DRIversion ddx_expected
= { 1, 5, 0 };
682 static const __DRIversion ddx_expected
= { 1, 6, 0 };
684 static const __DRIversion dri_expected
= { 4, 0, 0 };
685 static const __DRIversion drm_expected
= { 1, 5, 0 };
686 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
688 if (!driCheckDriDdxDrmVersions2("i915",
689 &psp
->dri_version
, &dri_expected
,
690 &psp
->ddx_version
, &ddx_expected
,
691 &psp
->drm_version
, &drm_expected
)) {
695 /* Calling driInitExtensions here, with a NULL context pointer,
696 * does not actually enable the extensions. It just makes sure
697 * that all the dispatch offsets for all the extensions that
698 * *might* be enables are known. This is needed because the
699 * dispatch offsets need to be known when _mesa_context_create is
700 * called, but we can't enable the extensions until we have a
703 * Hello chicken. Hello egg. How are you two today?
705 intelInitExtensions(NULL
, GL_TRUE
);
707 if (!intelInitDriver(psp
))
710 psp
->extensions
= intelScreenExtensions
;
712 intelScreen
= psp
->private;
713 if (!intel_init_bufmgr(intelScreen
))
716 return (const __DRIconfig
**)
717 intelFillInModes(psp
, dri_priv
->cpp
* 8,
718 (dri_priv
->cpp
== 2) ? 16 : 24,
719 (dri_priv
->cpp
== 2) ? 0 : 8, 1);
722 struct intel_context
*intelScreenContext(intelScreenPrivate
*intelScreen
)
725 * This should probably change to have the screen allocate a dummy
726 * context at screen creation. For now just use the current context.
729 GET_CURRENT_CONTEXT(ctx
);
731 _mesa_problem(NULL
, "No current context in intelScreenContext\n");
734 return intel_context(ctx
);
738 * This is the driver specific part of the createNewScreen entry point.
739 * Called when using DRI2.
741 * \return the __GLcontextModes supported by this driver
744 __DRIconfig
**intelInitScreen2(__DRIscreenPrivate
*psp
)
746 intelScreenPrivate
*intelScreen
;
749 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
750 * support pageflipping at all.
752 static const GLenum back_buffer_modes
[] = {
753 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
755 uint8_t depth_bits
[4], stencil_bits
[4], msaa_samples_array
[1];
757 __DRIconfig
**configs
= NULL
;
759 /* Calling driInitExtensions here, with a NULL context pointer,
760 * does not actually enable the extensions. It just makes sure
761 * that all the dispatch offsets for all the extensions that
762 * *might* be enables are known. This is needed because the
763 * dispatch offsets need to be known when _mesa_context_create is
764 * called, but we can't enable the extensions until we have a
767 * Hello chicken. Hello egg. How are you two today?
769 intelInitExtensions(NULL
, GL_TRUE
);
771 /* Allocate the private area */
772 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
774 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
777 /* parse information in __driConfigOptions */
778 driParseOptionInfo(&intelScreen
->optionCache
,
779 __driConfigOptions
, __driNConfigOptions
);
781 intelScreen
->driScrnPriv
= psp
;
782 psp
->private = (void *) intelScreen
;
784 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
786 /* Determine chipset ID */
787 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
788 &intelScreen
->deviceID
))
791 if (!intel_init_bufmgr(intelScreen
))
794 intelScreen
->irq_active
= 1;
795 psp
->extensions
= intelScreenExtensions
;
806 msaa_samples_array
[0] = 0;
808 fb_format
[0] = GL_RGB
;
809 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
811 fb_format
[1] = GL_BGR
;
812 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
814 fb_format
[2] = GL_BGRA
;
815 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
820 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
821 __DRIconfig
**new_configs
;
824 /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer
825 * with the same cpp as the drawable. So we can't support depth cpp !=
826 * color cpp currently.
828 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
841 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
846 ARRAY_SIZE(back_buffer_modes
),
848 ARRAY_SIZE(msaa_samples_array
));
850 configs
= new_configs
;
852 configs
= driConcatConfigs(configs
, new_configs
);
855 if (configs
== NULL
) {
856 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
861 return (const __DRIconfig
**)configs
;
864 const struct __DriverAPIRec driDriverAPI
= {
865 .InitScreen
= intelInitScreen
,
866 .DestroyScreen
= intelDestroyScreen
,
867 .CreateContext
= intelCreateContext
,
868 .DestroyContext
= intelDestroyContext
,
869 .CreateBuffer
= intelCreateBuffer
,
870 .DestroyBuffer
= intelDestroyBuffer
,
871 .SwapBuffers
= intelSwapBuffers
,
872 .MakeCurrent
= intelMakeCurrent
,
873 .UnbindContext
= intelUnbindContext
,
874 .GetSwapInfo
= intelGetSwapInfo
,
875 .GetDrawableMSC
= driDrawableGetMSC32
,
876 .WaitForMSC
= driWaitForMSC32
,
877 .CopySubBuffer
= intelCopySubBuffer
,
879 .InitScreen2
= intelInitScreen2
,