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)
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
= 9;
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\n", 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 driDestroyOptionCache(&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 _mesa_reference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)), NULL
);
414 * Get information about previous buffer swaps.
417 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
419 struct intel_framebuffer
*intel_fb
;
421 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
422 || (sInfo
== NULL
)) {
426 intel_fb
= dPriv
->driverPrivate
;
427 sInfo
->swap_count
= intel_fb
->swap_count
;
428 sInfo
->swap_ust
= intel_fb
->swap_ust
;
429 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
431 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
432 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
439 /* There are probably better ways to do this, such as an
440 * init-designated function to register chipids and createcontext
443 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
444 __DRIcontextPrivate
* driContextPriv
,
445 void *sharedContextPrivate
);
447 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
448 __DRIcontextPrivate
* driContextPriv
,
449 void *sharedContextPrivate
);
450 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
451 __DRIcontextPrivate
* driContextPriv
,
452 void *sharedContextPrivate
);
455 intelCreateContext(const __GLcontextModes
* mesaVis
,
456 __DRIcontextPrivate
* driContextPriv
,
457 void *sharedContextPrivate
)
459 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
460 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
463 if (IS_9XX(intelScreen
->deviceID
)) {
464 if (!IS_965(intelScreen
->deviceID
)) {
465 return i915CreateContext(mesaVis
, driContextPriv
,
466 sharedContextPrivate
);
469 intelScreen
->no_vbo
= GL_TRUE
;
470 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
473 if (IS_965(intelScreen
->deviceID
))
474 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
476 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
481 static __DRIconfig
**
482 intelFillInModes(__DRIscreenPrivate
*psp
,
483 unsigned pixel_bits
, unsigned depth_bits
,
484 unsigned stencil_bits
, GLboolean have_back_buffer
)
486 __DRIconfig
**configs
;
488 unsigned depth_buffer_factor
;
489 unsigned back_buffer_factor
;
492 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
493 * support pageflipping at all.
495 static const GLenum back_buffer_modes
[] = {
496 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
499 uint8_t depth_bits_array
[3];
500 uint8_t stencil_bits_array
[3];
501 uint8_t msaa_samples_array
[1];
503 depth_bits_array
[0] = 0;
504 depth_bits_array
[1] = depth_bits
;
505 depth_bits_array
[2] = depth_bits
;
507 /* Just like with the accumulation buffer, always provide some modes
508 * with a stencil buffer. It will be a sw fallback, but some apps won't
511 stencil_bits_array
[0] = 0;
512 stencil_bits_array
[1] = 0;
513 if (depth_bits
== 24)
514 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
516 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
518 msaa_samples_array
[0] = 0;
520 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
521 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
523 if (pixel_bits
== 16) {
524 configs
= driCreateConfigs(GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
,
525 depth_bits_array
, stencil_bits_array
,
526 depth_buffer_factor
, back_buffer_modes
,
528 msaa_samples_array
, 1);
531 __DRIconfig
**configs_a8r8g8b8
;
532 __DRIconfig
**configs_x8r8g8b8
;
534 configs_a8r8g8b8
= driCreateConfigs(GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
,
540 msaa_samples_array
, 1);
541 configs_x8r8g8b8
= driCreateConfigs(GL_BGR
, GL_UNSIGNED_INT_8_8_8_8_REV
,
547 msaa_samples_array
, 1);
548 configs
= driConcatConfigs(configs_a8r8g8b8
, configs_x8r8g8b8
);
551 if (configs
== NULL
) {
552 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
557 /* Mark the visual as slow if there are "fake" stencil bits.
559 for (i
= 0; configs
[i
]; i
++) {
560 m
= &configs
[i
]->modes
;
561 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
562 m
->visualRating
= GLX_SLOW_CONFIG
;
570 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
572 GLboolean gem_disable
= getenv("INTEL_NO_GEM") != NULL
;
574 GLboolean gem_supported
;
575 struct drm_i915_getparam gp
;
576 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
579 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
581 gp
.param
= I915_PARAM_HAS_GEM
;
582 gp
.value
= &gem_kernel
;
584 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
586 /* If we've got a new enough DDX that's initializing GEM and giving us
587 * object handles for the shared buffers, use that.
589 intelScreen
->ttm
= GL_FALSE
;
590 if (intelScreen
->driScrnPriv
->dri2
.enabled
)
591 gem_supported
= GL_TRUE
;
592 else if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9 &&
594 intelScreen
->front
.bo_handle
!= -1)
595 gem_supported
= GL_TRUE
;
597 gem_supported
= GL_FALSE
;
599 if (!gem_disable
&& gem_supported
) {
600 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
601 if (intelScreen
->bufmgr
!= NULL
)
602 intelScreen
->ttm
= GL_TRUE
;
604 /* Otherwise, use the classic buffer manager. */
605 if (intelScreen
->bufmgr
== NULL
) {
607 fprintf(stderr
, "GEM disabled. Using classic.\n");
609 fprintf(stderr
, "Failed to initialize GEM. "
610 "Falling back to classic.\n");
613 if (intelScreen
->tex
.size
== 0) {
614 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
619 intelScreen
->bufmgr
=
620 intel_bufmgr_fake_init(spriv
->fd
,
621 intelScreen
->tex
.offset
,
622 intelScreen
->tex
.map
,
623 intelScreen
->tex
.size
,
624 (unsigned int * volatile)
625 &intelScreen
->sarea
->last_dispatch
);
628 if (intel_get_param(spriv
, I915_PARAM_NUM_FENCES_AVAIL
, &num_fences
))
629 intelScreen
->kernel_exec_fencing
= !!num_fences
;
631 intelScreen
->kernel_exec_fencing
= GL_FALSE
;
637 * This is the driver specific part of the createNewScreen entry point.
638 * Called when using legacy DRI.
640 * \todo maybe fold this into intelInitDriver
642 * \return the __GLcontextModes supported by this driver
644 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
646 intelScreenPrivate
*intelScreen
;
648 static const __DRIversion ddx_expected
= { 1, 5, 0 };
650 static const __DRIversion ddx_expected
= { 1, 6, 0 };
652 static const __DRIversion dri_expected
= { 4, 0, 0 };
653 static const __DRIversion drm_expected
= { 1, 5, 0 };
654 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
656 if (!driCheckDriDdxDrmVersions2("i915",
657 &psp
->dri_version
, &dri_expected
,
658 &psp
->ddx_version
, &ddx_expected
,
659 &psp
->drm_version
, &drm_expected
)) {
663 /* Calling driInitExtensions here, with a NULL context pointer,
664 * does not actually enable the extensions. It just makes sure
665 * that all the dispatch offsets for all the extensions that
666 * *might* be enables are known. This is needed because the
667 * dispatch offsets need to be known when _mesa_context_create is
668 * called, but we can't enable the extensions until we have a
671 * Hello chicken. Hello egg. How are you two today?
673 intelInitExtensions(NULL
, GL_TRUE
);
675 if (!intelInitDriver(psp
))
678 psp
->extensions
= intelScreenExtensions
;
680 intelScreen
= psp
->private;
681 if (!intel_init_bufmgr(intelScreen
))
684 return (const __DRIconfig
**)
685 intelFillInModes(psp
, dri_priv
->cpp
* 8,
686 (dri_priv
->cpp
== 2) ? 16 : 24,
687 (dri_priv
->cpp
== 2) ? 0 : 8, 1);
690 struct intel_context
*intelScreenContext(intelScreenPrivate
*intelScreen
)
693 * This should probably change to have the screen allocate a dummy
694 * context at screen creation. For now just use the current context.
697 GET_CURRENT_CONTEXT(ctx
);
699 _mesa_problem(NULL
, "No current context in intelScreenContext\n");
702 return intel_context(ctx
);
706 * This is the driver specific part of the createNewScreen entry point.
707 * Called when using DRI2.
709 * \return the __GLcontextModes supported by this driver
712 __DRIconfig
**intelInitScreen2(__DRIscreenPrivate
*psp
)
714 intelScreenPrivate
*intelScreen
;
717 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
718 * support pageflipping at all.
720 static const GLenum back_buffer_modes
[] = {
721 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
723 uint8_t depth_bits
[4], stencil_bits
[4], msaa_samples_array
[1];
725 __DRIconfig
**configs
= NULL
;
727 /* Calling driInitExtensions here, with a NULL context pointer,
728 * does not actually enable the extensions. It just makes sure
729 * that all the dispatch offsets for all the extensions that
730 * *might* be enables are known. This is needed because the
731 * dispatch offsets need to be known when _mesa_context_create is
732 * called, but we can't enable the extensions until we have a
735 * Hello chicken. Hello egg. How are you two today?
737 intelInitExtensions(NULL
, GL_TRUE
);
739 /* Allocate the private area */
740 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
742 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
745 /* parse information in __driConfigOptions */
746 driParseOptionInfo(&intelScreen
->optionCache
,
747 __driConfigOptions
, __driNConfigOptions
);
749 intelScreen
->driScrnPriv
= psp
;
750 psp
->private = (void *) intelScreen
;
752 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
754 /* Determine chipset ID */
755 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
756 &intelScreen
->deviceID
))
759 if (!intel_init_bufmgr(intelScreen
))
762 intelScreen
->irq_active
= 1;
763 psp
->extensions
= intelScreenExtensions
;
774 msaa_samples_array
[0] = 0;
776 fb_format
[0] = GL_RGB
;
777 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
779 fb_format
[1] = GL_BGR
;
780 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
782 fb_format
[2] = GL_BGRA
;
783 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
788 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
789 __DRIconfig
**new_configs
;
792 /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer
793 * with the same cpp as the drawable. So we can't support depth cpp !=
794 * color cpp currently.
796 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
809 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
814 ARRAY_SIZE(back_buffer_modes
),
816 ARRAY_SIZE(msaa_samples_array
));
818 configs
= new_configs
;
820 configs
= driConcatConfigs(configs
, new_configs
);
823 if (configs
== NULL
) {
824 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
829 return (const __DRIconfig
**)configs
;
832 const struct __DriverAPIRec driDriverAPI
= {
833 .InitScreen
= intelInitScreen
,
834 .DestroyScreen
= intelDestroyScreen
,
835 .CreateContext
= intelCreateContext
,
836 .DestroyContext
= intelDestroyContext
,
837 .CreateBuffer
= intelCreateBuffer
,
838 .DestroyBuffer
= intelDestroyBuffer
,
839 .SwapBuffers
= intelSwapBuffers
,
840 .MakeCurrent
= intelMakeCurrent
,
841 .UnbindContext
= intelUnbindContext
,
842 .GetSwapInfo
= intelGetSwapInfo
,
843 .GetDrawableMSC
= driDrawableGetMSC32
,
844 .WaitForMSC
= driWaitForMSC32
,
845 .CopySubBuffer
= intelCopySubBuffer
,
847 .InitScreen2
= intelInitScreen2
,