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")
72 DRI_CONF_TEXTURE_TILING(false)
74 DRI_CONF_OPT_BEGIN(early_z
, bool, false)
75 DRI_CONF_DESC(en
, "Enable early Z in classic mode (unstable, 945-only).")
79 DRI_CONF_SECTION_QUALITY
80 DRI_CONF_FORCE_S3TC_ENABLE(false)
81 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
83 DRI_CONF_SECTION_DEBUG
84 DRI_CONF_NO_RAST(false)
85 DRI_CONF_ALWAYS_FLUSH_BATCH(false)
86 DRI_CONF_ALWAYS_FLUSH_CACHE(false)
90 const GLuint __driNConfigOptions
= 10;
92 #ifdef USE_NEW_INTERFACE
93 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
94 #endif /*USE_NEW_INTERFACE */
97 * Map all the memory regions described by the screen.
98 * \return GL_TRUE if success, GL_FALSE if error.
101 intelMapScreenRegions(__DRIscreenPrivate
* sPriv
)
103 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
106 _mesa_printf("TEX 0x%08x ", intelScreen
->tex
.handle
);
107 if (intelScreen
->tex
.size
!= 0) {
108 if (drmMap(sPriv
->fd
,
109 intelScreen
->tex
.handle
,
110 intelScreen
->tex
.size
,
111 (drmAddress
*) & intelScreen
->tex
.map
) != 0) {
112 intelUnmapScreenRegions(intelScreen
);
121 intelUnmapScreenRegions(intelScreenPrivate
* intelScreen
)
123 if (intelScreen
->tex
.map
) {
124 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
125 intelScreen
->tex
.map
= NULL
;
131 intelPrintDRIInfo(intelScreenPrivate
* intelScreen
,
132 __DRIscreenPrivate
* sPriv
, I830DRIPtr gDRIPriv
)
134 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
135 intelScreen
->front
.size
, intelScreen
->front
.offset
,
137 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
138 intelScreen
->back
.size
, intelScreen
->back
.offset
,
140 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
141 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
143 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
144 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
145 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
150 intelPrintSAREA(const drm_i915_sarea_t
* sarea
)
152 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
,
154 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
156 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
157 sarea
->front_offset
, sarea
->front_size
,
158 (unsigned) sarea
->front_handle
, sarea
->front_tiled
);
160 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
161 sarea
->back_offset
, sarea
->back_size
,
162 (unsigned) sarea
->back_handle
, sarea
->back_tiled
);
163 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
164 sarea
->depth_offset
, sarea
->depth_size
,
165 (unsigned) sarea
->depth_handle
, sarea
->depth_tiled
);
166 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
167 sarea
->tex_offset
, sarea
->tex_size
, (unsigned) sarea
->tex_handle
);
172 * A number of the screen parameters are obtained/computed from
173 * information in the SAREA. This function updates those parameters.
176 intelUpdateScreenFromSAREA(intelScreenPrivate
* intelScreen
,
177 drm_i915_sarea_t
* sarea
)
179 intelScreen
->width
= sarea
->width
;
180 intelScreen
->height
= sarea
->height
;
181 intelScreen
->pitch
= sarea
->pitch
;
183 intelScreen
->front
.offset
= sarea
->front_offset
;
184 intelScreen
->front
.handle
= sarea
->front_handle
;
185 intelScreen
->front
.size
= sarea
->front_size
;
186 intelScreen
->front
.tiled
= sarea
->front_tiled
;
188 intelScreen
->back
.offset
= sarea
->back_offset
;
189 intelScreen
->back
.handle
= sarea
->back_handle
;
190 intelScreen
->back
.size
= sarea
->back_size
;
191 intelScreen
->back
.tiled
= sarea
->back_tiled
;
193 intelScreen
->depth
.offset
= sarea
->depth_offset
;
194 intelScreen
->depth
.handle
= sarea
->depth_handle
;
195 intelScreen
->depth
.size
= sarea
->depth_size
;
196 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
198 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9) {
199 intelScreen
->front
.bo_handle
= sarea
->front_bo_handle
;
200 intelScreen
->back
.bo_handle
= sarea
->back_bo_handle
;
201 intelScreen
->depth
.bo_handle
= sarea
->depth_bo_handle
;
203 intelScreen
->front
.bo_handle
= -1;
204 intelScreen
->back
.bo_handle
= -1;
205 intelScreen
->depth
.bo_handle
= -1;
208 intelScreen
->tex
.offset
= sarea
->tex_offset
;
209 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
210 intelScreen
->tex
.handle
= sarea
->tex_handle
;
211 intelScreen
->tex
.size
= sarea
->tex_size
;
214 intelPrintSAREA(sarea
);
217 static const __DRItexOffsetExtension intelTexOffsetExtension
= {
218 { __DRI_TEX_OFFSET
},
222 static const __DRItexBufferExtension intelTexBufferExtension
= {
223 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
228 static const __DRIextension
*intelScreenExtensions
[] = {
229 &driReadDrawableExtension
,
230 &driCopySubBufferExtension
.base
,
231 &driSwapControlExtension
.base
,
232 &driFrameTrackingExtension
.base
,
233 &driMediaStreamCounterExtension
.base
,
234 &intelTexOffsetExtension
.base
,
235 &intelTexBufferExtension
.base
,
240 intel_get_param(__DRIscreenPrivate
*psp
, int param
, int *value
)
243 struct drm_i915_getparam gp
;
248 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
250 _mesa_warning(NULL
, "drm_i915_getparam: %d", ret
);
257 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
259 intelScreenPrivate
*intelScreen
;
260 I830DRIPtr gDRIPriv
= (I830DRIPtr
) sPriv
->pDevPriv
;
261 drm_i915_sarea_t
*sarea
;
263 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
265 "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
269 /* Allocate the private area */
270 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
272 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
275 /* parse information in __driConfigOptions */
276 driParseOptionInfo(&intelScreen
->optionCache
,
277 __driConfigOptions
, __driNConfigOptions
);
279 intelScreen
->driScrnPriv
= sPriv
;
280 sPriv
->private = (void *) intelScreen
;
281 sarea
= (drm_i915_sarea_t
*)
282 (((GLubyte
*) sPriv
->pSAREA
) + gDRIPriv
->sarea_priv_offset
);
283 intelScreen
->sarea
= sarea
;
285 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
287 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
289 if (!intelMapScreenRegions(sPriv
)) {
290 fprintf(stderr
, "\nERROR! mapping regions\n");
291 _mesa_free(intelScreen
);
292 sPriv
->private = NULL
;
297 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
299 intelScreen
->drmMinor
= sPriv
->drm_version
.minor
;
301 /* Determine if IRQs are active? */
302 if (!intel_get_param(sPriv
, I915_PARAM_IRQ_ACTIVE
,
303 &intelScreen
->irq_active
))
306 sPriv
->extensions
= intelScreenExtensions
;
313 intelDestroyScreen(__DRIscreenPrivate
* sPriv
)
315 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
317 dri_bufmgr_destroy(intelScreen
->bufmgr
);
318 intelUnmapScreenRegions(intelScreen
);
319 driDestroyOptionInfo(&intelScreen
->optionCache
);
322 sPriv
->private = NULL
;
327 * This is called when we need to set up GL rendering to a new X window.
330 intelCreateBuffer(__DRIscreenPrivate
* driScrnPriv
,
331 __DRIdrawablePrivate
* driDrawPriv
,
332 const __GLcontextModes
* mesaVis
, GLboolean isPixmap
)
335 return GL_FALSE
; /* not implemented */
338 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
339 mesaVis
->depthBits
!= 24);
342 struct intel_framebuffer
*intel_fb
= CALLOC_STRUCT(intel_framebuffer
);
347 _mesa_initialize_framebuffer(&intel_fb
->Base
, mesaVis
);
349 if (mesaVis
->redBits
== 5)
351 else if (mesaVis
->alphaBits
== 0)
354 rgbFormat
= GL_RGBA8
;
356 /* setup the hardware-based renderbuffers */
357 intel_fb
->color_rb
[0] = intel_create_renderbuffer(rgbFormat
);
358 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_FRONT_LEFT
,
359 &intel_fb
->color_rb
[0]->Base
);
361 if (mesaVis
->doubleBufferMode
) {
362 intel_fb
->color_rb
[1] = intel_create_renderbuffer(rgbFormat
);
364 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_BACK_LEFT
,
365 &intel_fb
->color_rb
[1]->Base
);
369 if (mesaVis
->depthBits
== 24) {
370 if (mesaVis
->stencilBits
== 8) {
371 /* combined depth/stencil buffer */
372 struct intel_renderbuffer
*depthStencilRb
373 = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT
);
374 /* note: bind RB to two attachment points */
375 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
376 &depthStencilRb
->Base
);
377 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
,
378 &depthStencilRb
->Base
);
380 struct intel_renderbuffer
*depthRb
381 = intel_create_renderbuffer(GL_DEPTH_COMPONENT24
);
382 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
386 else if (mesaVis
->depthBits
== 16) {
387 /* just 16-bit depth buffer, no hw stencil */
388 struct intel_renderbuffer
*depthRb
389 = intel_create_renderbuffer(GL_DEPTH_COMPONENT16
);
390 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
, &depthRb
->Base
);
393 /* now add any/all software-based renderbuffers we may need */
394 _mesa_add_soft_renderbuffers(&intel_fb
->Base
,
395 GL_FALSE
, /* never sw color */
396 GL_FALSE
, /* never sw depth */
397 swStencil
, mesaVis
->accumRedBits
> 0,
398 GL_FALSE
, /* never sw alpha */
399 GL_FALSE
/* never sw aux */ );
400 driDrawPriv
->driverPrivate
= (void *) intel_fb
;
407 intelDestroyBuffer(__DRIdrawablePrivate
* driDrawPriv
)
409 struct intel_framebuffer
*intel_fb
= driDrawPriv
->driverPrivate
;
410 struct intel_renderbuffer
*depth_rb
;
411 struct intel_renderbuffer
*stencil_rb
;
414 if (intel_fb
->color_rb
[0]) {
415 intel_renderbuffer_set_region(intel_fb
->color_rb
[0], NULL
);
418 if (intel_fb
->color_rb
[1]) {
419 intel_renderbuffer_set_region(intel_fb
->color_rb
[1], NULL
);
422 depth_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
);
424 intel_renderbuffer_set_region(depth_rb
, NULL
);
427 stencil_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
);
429 intel_renderbuffer_set_region(stencil_rb
, NULL
);
433 _mesa_reference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)), NULL
);
438 * Get information about previous buffer swaps.
441 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
443 struct intel_framebuffer
*intel_fb
;
445 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
446 || (sInfo
== NULL
)) {
450 intel_fb
= dPriv
->driverPrivate
;
451 sInfo
->swap_count
= intel_fb
->swap_count
;
452 sInfo
->swap_ust
= intel_fb
->swap_ust
;
453 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
455 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
456 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
463 /* There are probably better ways to do this, such as an
464 * init-designated function to register chipids and createcontext
467 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
468 __DRIcontextPrivate
* driContextPriv
,
469 void *sharedContextPrivate
);
471 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
472 __DRIcontextPrivate
* driContextPriv
,
473 void *sharedContextPrivate
);
474 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
475 __DRIcontextPrivate
* driContextPriv
,
476 void *sharedContextPrivate
);
479 intelCreateContext(const __GLcontextModes
* mesaVis
,
480 __DRIcontextPrivate
* driContextPriv
,
481 void *sharedContextPrivate
)
483 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
484 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
487 if (IS_9XX(intelScreen
->deviceID
)) {
488 if (!IS_965(intelScreen
->deviceID
)) {
489 return i915CreateContext(mesaVis
, driContextPriv
,
490 sharedContextPrivate
);
493 intelScreen
->no_vbo
= GL_TRUE
;
494 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
497 if (IS_965(intelScreen
->deviceID
))
498 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
500 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
505 static __DRIconfig
**
506 intelFillInModes(__DRIscreenPrivate
*psp
,
507 unsigned pixel_bits
, unsigned depth_bits
,
508 unsigned stencil_bits
, GLboolean have_back_buffer
)
510 __DRIconfig
**configs
;
512 unsigned depth_buffer_factor
;
513 unsigned back_buffer_factor
;
516 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
517 * support pageflipping at all.
519 static const GLenum back_buffer_modes
[] = {
520 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
523 uint8_t depth_bits_array
[3];
524 uint8_t stencil_bits_array
[3];
525 uint8_t msaa_samples_array
[1];
527 depth_bits_array
[0] = 0;
528 depth_bits_array
[1] = depth_bits
;
529 depth_bits_array
[2] = depth_bits
;
531 /* Just like with the accumulation buffer, always provide some modes
532 * with a stencil buffer. It will be a sw fallback, but some apps won't
535 stencil_bits_array
[0] = 0;
536 stencil_bits_array
[1] = 0;
537 if (depth_bits
== 24)
538 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
540 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
542 msaa_samples_array
[0] = 0;
544 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
545 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
547 if (pixel_bits
== 16) {
548 configs
= driCreateConfigs(GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
,
549 depth_bits_array
, stencil_bits_array
,
550 depth_buffer_factor
, back_buffer_modes
,
552 msaa_samples_array
, 1);
555 __DRIconfig
**configs_a8r8g8b8
;
556 __DRIconfig
**configs_x8r8g8b8
;
558 configs_a8r8g8b8
= driCreateConfigs(GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
,
564 msaa_samples_array
, 1);
565 configs_x8r8g8b8
= driCreateConfigs(GL_BGR
, GL_UNSIGNED_INT_8_8_8_8_REV
,
571 msaa_samples_array
, 1);
572 configs
= driConcatConfigs(configs_a8r8g8b8
, configs_x8r8g8b8
);
575 if (configs
== NULL
) {
576 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
581 /* Mark the visual as slow if there are "fake" stencil bits.
583 for (i
= 0; configs
[i
]; i
++) {
584 m
= &configs
[i
]->modes
;
585 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
586 m
->visualRating
= GLX_SLOW_CONFIG
;
594 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
596 GLboolean gem_disable
= getenv("INTEL_NO_GEM") != NULL
;
598 GLboolean gem_supported
;
599 struct drm_i915_getparam gp
;
600 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
603 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
605 gp
.param
= I915_PARAM_HAS_GEM
;
606 gp
.value
= &gem_kernel
;
608 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
610 /* If we've got a new enough DDX that's initializing GEM and giving us
611 * object handles for the shared buffers, use that.
613 intelScreen
->ttm
= GL_FALSE
;
614 if (intelScreen
->driScrnPriv
->dri2
.enabled
)
615 gem_supported
= GL_TRUE
;
616 else if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9 &&
618 intelScreen
->front
.bo_handle
!= -1)
619 gem_supported
= GL_TRUE
;
621 gem_supported
= GL_FALSE
;
623 if (!gem_disable
&& gem_supported
) {
624 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
625 if (intelScreen
->bufmgr
!= NULL
)
626 intelScreen
->ttm
= GL_TRUE
;
628 /* Otherwise, use the classic buffer manager. */
629 if (intelScreen
->bufmgr
== NULL
) {
631 fprintf(stderr
, "GEM disabled. Using classic.\n");
633 fprintf(stderr
, "Failed to initialize GEM. "
634 "Falling back to classic.\n");
637 if (intelScreen
->tex
.size
== 0) {
638 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
643 intelScreen
->bufmgr
=
644 intel_bufmgr_fake_init(spriv
->fd
,
645 intelScreen
->tex
.offset
,
646 intelScreen
->tex
.map
,
647 intelScreen
->tex
.size
,
648 (unsigned int * volatile)
649 &intelScreen
->sarea
->last_dispatch
);
652 if (intel_get_param(spriv
, I915_PARAM_NUM_FENCES_AVAIL
, &num_fences
))
653 intelScreen
->kernel_exec_fencing
= !!num_fences
;
655 intelScreen
->kernel_exec_fencing
= GL_FALSE
;
661 * This is the driver specific part of the createNewScreen entry point.
662 * Called when using legacy DRI.
664 * \todo maybe fold this into intelInitDriver
666 * \return the __GLcontextModes supported by this driver
668 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
670 intelScreenPrivate
*intelScreen
;
672 static const __DRIversion ddx_expected
= { 1, 5, 0 };
674 static const __DRIversion ddx_expected
= { 1, 6, 0 };
676 static const __DRIversion dri_expected
= { 4, 0, 0 };
677 static const __DRIversion drm_expected
= { 1, 5, 0 };
678 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
680 if (!driCheckDriDdxDrmVersions2("i915",
681 &psp
->dri_version
, &dri_expected
,
682 &psp
->ddx_version
, &ddx_expected
,
683 &psp
->drm_version
, &drm_expected
)) {
687 /* Calling driInitExtensions here, with a NULL context pointer,
688 * does not actually enable the extensions. It just makes sure
689 * that all the dispatch offsets for all the extensions that
690 * *might* be enables are known. This is needed because the
691 * dispatch offsets need to be known when _mesa_context_create is
692 * called, but we can't enable the extensions until we have a
695 * Hello chicken. Hello egg. How are you two today?
697 intelInitExtensions(NULL
, GL_TRUE
);
699 if (!intelInitDriver(psp
))
702 psp
->extensions
= intelScreenExtensions
;
704 intelScreen
= psp
->private;
705 if (!intel_init_bufmgr(intelScreen
))
708 return (const __DRIconfig
**)
709 intelFillInModes(psp
, dri_priv
->cpp
* 8,
710 (dri_priv
->cpp
== 2) ? 16 : 24,
711 (dri_priv
->cpp
== 2) ? 0 : 8, 1);
714 struct intel_context
*intelScreenContext(intelScreenPrivate
*intelScreen
)
717 * This should probably change to have the screen allocate a dummy
718 * context at screen creation. For now just use the current context.
721 GET_CURRENT_CONTEXT(ctx
);
723 _mesa_problem(NULL
, "No current context in intelScreenContext\n");
726 return intel_context(ctx
);
730 * This is the driver specific part of the createNewScreen entry point.
731 * Called when using DRI2.
733 * \return the __GLcontextModes supported by this driver
736 __DRIconfig
**intelInitScreen2(__DRIscreenPrivate
*psp
)
738 intelScreenPrivate
*intelScreen
;
741 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
742 * support pageflipping at all.
744 static const GLenum back_buffer_modes
[] = {
745 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
747 uint8_t depth_bits
[4], stencil_bits
[4], msaa_samples_array
[1];
749 __DRIconfig
**configs
= NULL
;
751 /* Calling driInitExtensions here, with a NULL context pointer,
752 * does not actually enable the extensions. It just makes sure
753 * that all the dispatch offsets for all the extensions that
754 * *might* be enables are known. This is needed because the
755 * dispatch offsets need to be known when _mesa_context_create is
756 * called, but we can't enable the extensions until we have a
759 * Hello chicken. Hello egg. How are you two today?
761 intelInitExtensions(NULL
, GL_TRUE
);
763 /* Allocate the private area */
764 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
766 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
769 /* parse information in __driConfigOptions */
770 driParseOptionInfo(&intelScreen
->optionCache
,
771 __driConfigOptions
, __driNConfigOptions
);
773 intelScreen
->driScrnPriv
= psp
;
774 psp
->private = (void *) intelScreen
;
776 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
778 /* Determine chipset ID */
779 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
780 &intelScreen
->deviceID
))
783 if (!intel_init_bufmgr(intelScreen
))
786 intelScreen
->irq_active
= 1;
787 psp
->extensions
= intelScreenExtensions
;
798 msaa_samples_array
[0] = 0;
800 fb_format
[0] = GL_RGB
;
801 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
803 fb_format
[1] = GL_BGR
;
804 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
806 fb_format
[2] = GL_BGRA
;
807 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
812 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
813 __DRIconfig
**new_configs
;
816 /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer
817 * with the same cpp as the drawable. So we can't support depth cpp !=
818 * color cpp currently.
820 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
833 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
838 ARRAY_SIZE(back_buffer_modes
),
840 ARRAY_SIZE(msaa_samples_array
));
842 configs
= new_configs
;
844 configs
= driConcatConfigs(configs
, new_configs
);
847 if (configs
== NULL
) {
848 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
853 return (const __DRIconfig
**)configs
;
856 const struct __DriverAPIRec driDriverAPI
= {
857 .InitScreen
= intelInitScreen
,
858 .DestroyScreen
= intelDestroyScreen
,
859 .CreateContext
= intelCreateContext
,
860 .DestroyContext
= intelDestroyContext
,
861 .CreateBuffer
= intelCreateBuffer
,
862 .DestroyBuffer
= intelDestroyBuffer
,
863 .SwapBuffers
= intelSwapBuffers
,
864 .MakeCurrent
= intelMakeCurrent
,
865 .UnbindContext
= intelUnbindContext
,
866 .GetSwapInfo
= intelGetSwapInfo
,
867 .GetDrawableMSC
= driDrawableGetMSC32
,
868 .WaitForMSC
= driWaitForMSC32
,
869 .CopySubBuffer
= intelCopySubBuffer
,
871 .InitScreen2
= intelInitScreen2
,