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/matrix.h"
32 #include "main/renderbuffer.h"
33 #include "main/simple_list.h"
39 #include "intel_screen.h"
41 #include "intel_buffers.h"
42 #include "intel_tex.h"
43 #include "intel_span.h"
44 #include "intel_fbo.h"
45 #include "intel_chipset.h"
49 #include "intel_regions.h"
50 #include "intel_batchbuffer.h"
51 #include "intel_bufmgr.h"
53 PUBLIC
const char __driConfigOptions
[] =
55 DRI_CONF_SECTION_PERFORMANCE
56 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS
)
57 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC
)
58 /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
59 * DRI_CONF_BO_REUSE_ALL
61 DRI_CONF_OPT_BEGIN_V(bo_reuse
, enum, 1, "0:1")
62 DRI_CONF_DESC_BEGIN(en
, "Buffer object reuse")
63 DRI_CONF_ENUM(0, "Disable buffer object reuse")
64 DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
68 DRI_CONF_SECTION_QUALITY
69 DRI_CONF_FORCE_S3TC_ENABLE(false)
70 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
72 DRI_CONF_SECTION_DEBUG
73 DRI_CONF_NO_RAST(false)
77 const GLuint __driNConfigOptions
= 6;
79 #ifdef USE_NEW_INTERFACE
80 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
81 #endif /*USE_NEW_INTERFACE */
84 * Map all the memory regions described by the screen.
85 * \return GL_TRUE if success, GL_FALSE if error.
88 intelMapScreenRegions(__DRIscreenPrivate
* sPriv
)
90 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
93 _mesa_printf("TEX 0x%08x ", intelScreen
->tex
.handle
);
94 if (intelScreen
->tex
.size
!= 0) {
96 intelScreen
->tex
.handle
,
97 intelScreen
->tex
.size
,
98 (drmAddress
*) & intelScreen
->tex
.map
) != 0) {
99 intelUnmapScreenRegions(intelScreen
);
108 intelUnmapScreenRegions(intelScreenPrivate
* intelScreen
)
110 if (intelScreen
->tex
.map
) {
111 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
112 intelScreen
->tex
.map
= NULL
;
118 intelPrintDRIInfo(intelScreenPrivate
* intelScreen
,
119 __DRIscreenPrivate
* sPriv
, I830DRIPtr gDRIPriv
)
121 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
122 intelScreen
->front
.size
, intelScreen
->front
.offset
,
124 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
125 intelScreen
->back
.size
, intelScreen
->back
.offset
,
127 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
128 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
130 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
131 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
132 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
137 intelPrintSAREA(const struct drm_i915_sarea
* sarea
)
139 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
,
141 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
143 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
144 sarea
->front_offset
, sarea
->front_size
,
145 (unsigned) sarea
->front_handle
, sarea
->front_tiled
);
147 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
148 sarea
->back_offset
, sarea
->back_size
,
149 (unsigned) sarea
->back_handle
, sarea
->back_tiled
);
150 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
151 sarea
->depth_offset
, sarea
->depth_size
,
152 (unsigned) sarea
->depth_handle
, sarea
->depth_tiled
);
153 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
154 sarea
->tex_offset
, sarea
->tex_size
, (unsigned) sarea
->tex_handle
);
159 * A number of the screen parameters are obtained/computed from
160 * information in the SAREA. This function updates those parameters.
163 intelUpdateScreenFromSAREA(intelScreenPrivate
* intelScreen
,
164 struct drm_i915_sarea
* sarea
)
166 intelScreen
->width
= sarea
->width
;
167 intelScreen
->height
= sarea
->height
;
168 intelScreen
->pitch
= sarea
->pitch
;
170 intelScreen
->front
.offset
= sarea
->front_offset
;
171 intelScreen
->front
.handle
= sarea
->front_handle
;
172 intelScreen
->front
.size
= sarea
->front_size
;
173 intelScreen
->front
.tiled
= sarea
->front_tiled
;
175 intelScreen
->back
.offset
= sarea
->back_offset
;
176 intelScreen
->back
.handle
= sarea
->back_handle
;
177 intelScreen
->back
.size
= sarea
->back_size
;
178 intelScreen
->back
.tiled
= sarea
->back_tiled
;
180 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 8) {
181 intelScreen
->third
.offset
= sarea
->third_offset
;
182 intelScreen
->third
.handle
= sarea
->third_handle
;
183 intelScreen
->third
.size
= sarea
->third_size
;
184 intelScreen
->third
.tiled
= sarea
->third_tiled
;
187 intelScreen
->depth
.offset
= sarea
->depth_offset
;
188 intelScreen
->depth
.handle
= sarea
->depth_handle
;
189 intelScreen
->depth
.size
= sarea
->depth_size
;
190 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
192 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9) {
193 intelScreen
->front
.bo_handle
= sarea
->front_bo_handle
;
194 intelScreen
->back
.bo_handle
= sarea
->back_bo_handle
;
195 intelScreen
->third
.bo_handle
= sarea
->third_bo_handle
;
196 intelScreen
->depth
.bo_handle
= sarea
->depth_bo_handle
;
198 intelScreen
->front
.bo_handle
= -1;
199 intelScreen
->back
.bo_handle
= -1;
200 intelScreen
->third
.bo_handle
= -1;
201 intelScreen
->depth
.bo_handle
= -1;
204 intelScreen
->tex
.offset
= sarea
->tex_offset
;
205 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
206 intelScreen
->tex
.handle
= sarea
->tex_handle
;
207 intelScreen
->tex
.size
= sarea
->tex_size
;
210 intelPrintSAREA(sarea
);
213 static const __DRItexOffsetExtension intelTexOffsetExtension
= {
214 { __DRI_TEX_OFFSET
},
218 static const __DRItexBufferExtension intelTexBufferExtension
= {
219 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
223 static const __DRIextension
*intelScreenExtensions
[] = {
224 &driReadDrawableExtension
,
225 &driCopySubBufferExtension
.base
,
226 &driSwapControlExtension
.base
,
227 &driFrameTrackingExtension
.base
,
228 &driMediaStreamCounterExtension
.base
,
229 &intelTexOffsetExtension
.base
,
230 &intelTexBufferExtension
.base
,
235 intel_get_param(__DRIscreenPrivate
*psp
, int param
, int *value
)
238 struct drm_i915_getparam gp
;
243 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
245 fprintf(stderr
, "drm_i915_getparam: %d\n", ret
);
252 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
254 intelScreenPrivate
*intelScreen
;
255 I830DRIPtr gDRIPriv
= (I830DRIPtr
) sPriv
->pDevPriv
;
256 struct drm_i915_sarea
*sarea
;
258 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
260 "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
264 /* Allocate the private area */
265 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
267 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
270 /* parse information in __driConfigOptions */
271 driParseOptionInfo(&intelScreen
->optionCache
,
272 __driConfigOptions
, __driNConfigOptions
);
274 intelScreen
->driScrnPriv
= sPriv
;
275 sPriv
->private = (void *) intelScreen
;
276 sarea
= (struct drm_i915_sarea
*)
277 (((GLubyte
*) sPriv
->pSAREA
) + gDRIPriv
->sarea_priv_offset
);
278 intelScreen
->sarea
= sarea
;
280 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
282 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
284 if (!intelMapScreenRegions(sPriv
)) {
285 fprintf(stderr
, "\nERROR! mapping regions\n");
286 _mesa_free(intelScreen
);
287 sPriv
->private = NULL
;
292 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
294 intelScreen
->drmMinor
= sPriv
->drm_version
.minor
;
296 /* Determine if IRQs are active? */
297 if (!intel_get_param(sPriv
, I915_PARAM_IRQ_ACTIVE
,
298 &intelScreen
->irq_active
))
301 sPriv
->extensions
= intelScreenExtensions
;
308 intelDestroyScreen(__DRIscreenPrivate
* sPriv
)
310 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
312 dri_bufmgr_destroy(intelScreen
->bufmgr
);
313 intelUnmapScreenRegions(intelScreen
);
316 sPriv
->private = NULL
;
321 * This is called when we need to set up GL rendering to a new X window.
324 intelCreateBuffer(__DRIscreenPrivate
* driScrnPriv
,
325 __DRIdrawablePrivate
* driDrawPriv
,
326 const __GLcontextModes
* mesaVis
, GLboolean isPixmap
)
328 intelScreenPrivate
*screen
= (intelScreenPrivate
*) driScrnPriv
->private;
331 return GL_FALSE
; /* not implemented */
334 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
335 mesaVis
->depthBits
!= 24);
336 GLenum rgbFormat
= (mesaVis
->redBits
== 5 ? GL_RGB5
: GL_RGBA8
);
338 struct intel_framebuffer
*intel_fb
= CALLOC_STRUCT(intel_framebuffer
);
343 _mesa_initialize_framebuffer(&intel_fb
->Base
, mesaVis
);
345 /* setup the hardware-based renderbuffers */
346 intel_fb
->color_rb
[0] = intel_create_renderbuffer(rgbFormat
);
347 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_FRONT_LEFT
,
348 &intel_fb
->color_rb
[0]->Base
);
350 if (mesaVis
->doubleBufferMode
) {
351 intel_fb
->color_rb
[1] = intel_create_renderbuffer(rgbFormat
);
353 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_BACK_LEFT
,
354 &intel_fb
->color_rb
[1]->Base
);
356 if (screen
->third
.handle
) {
357 struct gl_renderbuffer
*tmp_rb
= NULL
;
359 intel_fb
->color_rb
[2] = intel_create_renderbuffer(rgbFormat
);
360 _mesa_reference_renderbuffer(&tmp_rb
, &intel_fb
->color_rb
[2]->Base
);
364 if (mesaVis
->depthBits
== 24) {
365 if (mesaVis
->stencilBits
== 8) {
366 /* combined depth/stencil buffer */
367 struct intel_renderbuffer
*depthStencilRb
368 = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT
);
369 /* note: bind RB to two attachment points */
370 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
371 &depthStencilRb
->Base
);
372 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
,
373 &depthStencilRb
->Base
);
375 struct intel_renderbuffer
*depthRb
376 = intel_create_renderbuffer(GL_DEPTH_COMPONENT24
);
377 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
381 else if (mesaVis
->depthBits
== 16) {
382 /* just 16-bit depth buffer, no hw stencil */
383 struct intel_renderbuffer
*depthRb
384 = intel_create_renderbuffer(GL_DEPTH_COMPONENT16
);
385 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
, &depthRb
->Base
);
388 /* now add any/all software-based renderbuffers we may need */
389 _mesa_add_soft_renderbuffers(&intel_fb
->Base
,
390 GL_FALSE
, /* never sw color */
391 GL_FALSE
, /* never sw depth */
392 swStencil
, mesaVis
->accumRedBits
> 0,
393 GL_FALSE
, /* never sw alpha */
394 GL_FALSE
/* never sw aux */ );
395 driDrawPriv
->driverPrivate
= (void *) intel_fb
;
402 intelDestroyBuffer(__DRIdrawablePrivate
* driDrawPriv
)
404 _mesa_unreference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)));
409 * Get information about previous buffer swaps.
412 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
414 struct intel_framebuffer
*intel_fb
;
416 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
417 || (sInfo
== NULL
)) {
421 intel_fb
= dPriv
->driverPrivate
;
422 sInfo
->swap_count
= intel_fb
->swap_count
;
423 sInfo
->swap_ust
= intel_fb
->swap_ust
;
424 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
426 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
427 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
434 /* There are probably better ways to do this, such as an
435 * init-designated function to register chipids and createcontext
438 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
439 __DRIcontextPrivate
* driContextPriv
,
440 void *sharedContextPrivate
);
442 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
443 __DRIcontextPrivate
* driContextPriv
,
444 void *sharedContextPrivate
);
445 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
446 __DRIcontextPrivate
* driContextPriv
,
447 void *sharedContextPrivate
);
450 intelCreateContext(const __GLcontextModes
* mesaVis
,
451 __DRIcontextPrivate
* driContextPriv
,
452 void *sharedContextPrivate
)
454 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
455 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
458 if (IS_9XX(intelScreen
->deviceID
)) {
459 if (!IS_965(intelScreen
->deviceID
)) {
460 return i915CreateContext(mesaVis
, driContextPriv
,
461 sharedContextPrivate
);
464 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
467 if (IS_965(intelScreen
->deviceID
))
468 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
470 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
475 static __DRIconfig
**
476 intelFillInModes(__DRIscreenPrivate
*psp
,
477 unsigned pixel_bits
, unsigned depth_bits
,
478 unsigned stencil_bits
, GLboolean have_back_buffer
)
480 __DRIconfig
**configs
;
482 unsigned depth_buffer_factor
;
483 unsigned back_buffer_factor
;
488 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
489 * support pageflipping at all.
491 static const GLenum back_buffer_modes
[] = {
492 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
495 u_int8_t depth_bits_array
[3];
496 u_int8_t stencil_bits_array
[3];
498 depth_bits_array
[0] = 0;
499 depth_bits_array
[1] = depth_bits
;
500 depth_bits_array
[2] = depth_bits
;
502 /* Just like with the accumulation buffer, always provide some modes
503 * with a stencil buffer. It will be a sw fallback, but some apps won't
506 stencil_bits_array
[0] = 0;
507 stencil_bits_array
[1] = 0;
508 if (depth_bits
== 24)
509 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
511 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
513 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
514 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
516 if (pixel_bits
== 16) {
518 fb_type
= GL_UNSIGNED_SHORT_5_6_5
;
522 fb_type
= GL_UNSIGNED_INT_8_8_8_8_REV
;
525 configs
= driCreateConfigs(fb_format
, fb_type
,
526 depth_bits_array
, stencil_bits_array
,
527 depth_buffer_factor
, back_buffer_modes
,
529 if (configs
== NULL
) {
530 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
535 /* Mark the visual as slow if there are "fake" stencil bits.
537 for (i
= 0; configs
[i
]; i
++) {
538 m
= &configs
[i
]->modes
;
539 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
540 m
->visualRating
= GLX_SLOW_CONFIG
;
548 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
550 GLboolean gem_disable
= getenv("INTEL_NO_GEM") != NULL
;
552 GLboolean gem_supported
;
553 struct drm_i915_getparam gp
;
554 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
556 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
558 gp
.param
= I915_PARAM_HAS_GEM
;
559 gp
.value
= &gem_kernel
;
561 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
563 /* If we've got a new enough DDX that's initializing GEM and giving us
564 * object handles for the shared buffers, use that.
566 intelScreen
->ttm
= GL_FALSE
;
567 if (intelScreen
->driScrnPriv
->dri2
.enabled
)
568 gem_supported
= GL_TRUE
;
569 else if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9 &&
571 intelScreen
->front
.bo_handle
!= -1)
572 gem_supported
= GL_TRUE
;
574 gem_supported
= GL_FALSE
;
576 if (!gem_disable
&& gem_supported
) {
577 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
578 if (intelScreen
->bufmgr
!= NULL
)
579 intelScreen
->ttm
= GL_TRUE
;
581 /* Otherwise, use the classic buffer manager. */
582 if (intelScreen
->bufmgr
== NULL
) {
584 fprintf(stderr
, "GEM disabled. Using classic.\n");
586 fprintf(stderr
, "Failed to initialize GEM. "
587 "Falling back to classic.\n");
590 if (intelScreen
->tex
.size
== 0) {
591 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
596 intelScreen
->bufmgr
=
597 intel_bufmgr_fake_init(spriv
->fd
,
598 intelScreen
->tex
.offset
,
599 intelScreen
->tex
.map
,
600 intelScreen
->tex
.size
,
601 (unsigned int * volatile)
602 &intelScreen
->sarea
->last_dispatch
);
605 /* XXX bufmgr should be per-screen, not per-context */
606 intelScreen
->ttm
= intelScreen
->ttm
;
612 * This is the driver specific part of the createNewScreen entry point.
613 * Called when using legacy DRI.
615 * \todo maybe fold this into intelInitDriver
617 * \return the __GLcontextModes supported by this driver
619 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
621 intelScreenPrivate
*intelScreen
;
623 static const __DRIversion ddx_expected
= { 1, 5, 0 };
625 static const __DRIversion ddx_expected
= { 1, 6, 0 };
627 static const __DRIversion dri_expected
= { 4, 0, 0 };
628 static const __DRIversion drm_expected
= { 1, 5, 0 };
629 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
631 if (!driCheckDriDdxDrmVersions2("i915",
632 &psp
->dri_version
, &dri_expected
,
633 &psp
->ddx_version
, &ddx_expected
,
634 &psp
->drm_version
, &drm_expected
)) {
638 /* Calling driInitExtensions here, with a NULL context pointer,
639 * does not actually enable the extensions. It just makes sure
640 * that all the dispatch offsets for all the extensions that
641 * *might* be enables are known. This is needed because the
642 * dispatch offsets need to be known when _mesa_context_create is
643 * called, but we can't enable the extensions until we have a
646 * Hello chicken. Hello egg. How are you two today?
648 intelInitExtensions(NULL
, GL_TRUE
);
650 if (!intelInitDriver(psp
))
653 psp
->extensions
= intelScreenExtensions
;
655 intelScreen
= psp
->private;
656 if (!intel_init_bufmgr(intelScreen
))
659 return (const __DRIconfig
**)
660 intelFillInModes(psp
, dri_priv
->cpp
* 8,
661 (dri_priv
->cpp
== 2) ? 16 : 24,
662 (dri_priv
->cpp
== 2) ? 0 : 8, 1);
665 struct intel_context
*intelScreenContext(intelScreenPrivate
*intelScreen
)
668 * This should probably change to have the screen allocate a dummy
669 * context at screen creation. For now just use the current context.
672 GET_CURRENT_CONTEXT(ctx
);
674 _mesa_problem(NULL
, "No current context in intelScreenContext\n");
677 return intel_context(ctx
);
681 * This is the driver specific part of the createNewScreen entry point.
682 * Called when using DRI2.
684 * \return the __GLcontextModes supported by this driver
687 __DRIconfig
**intelInitScreen2(__DRIscreenPrivate
*psp
)
689 intelScreenPrivate
*intelScreen
;
691 /* Calling driInitExtensions here, with a NULL context pointer,
692 * does not actually enable the extensions. It just makes sure
693 * that all the dispatch offsets for all the extensions that
694 * *might* be enables are known. This is needed because the
695 * dispatch offsets need to be known when _mesa_context_create is
696 * called, but we can't enable the extensions until we have a
699 * Hello chicken. Hello egg. How are you two today?
701 intelInitExtensions(NULL
, GL_TRUE
);
703 /* Allocate the private area */
704 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
706 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
709 /* parse information in __driConfigOptions */
710 driParseOptionInfo(&intelScreen
->optionCache
,
711 __driConfigOptions
, __driNConfigOptions
);
713 intelScreen
->driScrnPriv
= psp
;
714 psp
->private = (void *) intelScreen
;
716 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
718 /* Determine chipset ID */
719 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
720 &intelScreen
->deviceID
))
723 if (!intel_init_bufmgr(intelScreen
))
726 intelScreen
->irq_active
= 1;
727 psp
->extensions
= intelScreenExtensions
;
729 return driConcatConfigs(intelFillInModes(psp
, 16, 16, 0, 1),
730 intelFillInModes(psp
, 32, 24, 8, 1));
733 const struct __DriverAPIRec driDriverAPI
= {
734 .InitScreen
= intelInitScreen
,
735 .DestroyScreen
= intelDestroyScreen
,
736 .CreateContext
= intelCreateContext
,
737 .DestroyContext
= intelDestroyContext
,
738 .CreateBuffer
= intelCreateBuffer
,
739 .DestroyBuffer
= intelDestroyBuffer
,
740 .SwapBuffers
= intelSwapBuffers
,
741 .MakeCurrent
= intelMakeCurrent
,
742 .UnbindContext
= intelUnbindContext
,
743 .GetSwapInfo
= intelGetSwapInfo
,
744 .GetDrawableMSC
= driDrawableGetMSC32
,
745 .WaitForMSC
= driWaitForMSC32
,
746 .CopySubBuffer
= intelCopySubBuffer
,
748 .InitScreen2
= intelInitScreen2
,