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 **************************************************************************/
30 #include "framebuffer.h"
32 #include "renderbuffer.h"
33 #include "simple_list.h"
39 #include "intel_screen.h"
41 #include "intel_tex.h"
42 #include "intel_span.h"
43 #include "intel_ioctl.h"
47 PUBLIC
const char __driConfigOptions
[] =
49 DRI_CONF_SECTION_PERFORMANCE
50 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS
)
51 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0
)
53 DRI_CONF_SECTION_QUALITY
54 DRI_CONF_FORCE_S3TC_ENABLE(false)
55 DRI_CONF_ALLOW_LARGE_TEXTURES(1)
58 const GLuint __driNConfigOptions
= 4;
60 #ifdef USE_NEW_INTERFACE
61 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
62 #endif /*USE_NEW_INTERFACE*/
64 extern const struct dri_extension card_extensions
[];
67 * Map all the memory regions described by the screen.
68 * \return GL_TRUE if success, GL_FALSE if error.
71 intelMapScreenRegions(__DRIscreenPrivate
*sPriv
)
73 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)sPriv
->private;
75 if (intelScreen
->front
.handle
) {
77 intelScreen
->front
.handle
,
78 intelScreen
->front
.size
,
79 (drmAddress
*)&intelScreen
->front
.map
) != 0) {
80 _mesa_problem(NULL
, "drmMap(frontbuffer) failed!");
84 /* Use the old static allocation method if the server isn't setting up
85 * a movable handle for us. Add in the front buffer offset from
86 * framebuffer start, as our span routines (unlike other drivers) expect
87 * the renderbuffer address to point to the beginning of the
90 intelScreen
->front
.map
= (char *)sPriv
->pFB
;
91 if (intelScreen
->front
.map
== NULL
) {
92 fprintf(stderr
, "Failed to find framebuffer mapping\n");
98 intelScreen
->back
.handle
,
99 intelScreen
->back
.size
,
100 (drmAddress
*)&intelScreen
->back
.map
) != 0) {
101 intelUnmapScreenRegions(intelScreen
);
105 if (drmMap(sPriv
->fd
,
106 intelScreen
->depth
.handle
,
107 intelScreen
->depth
.size
,
108 (drmAddress
*)&intelScreen
->depth
.map
) != 0) {
109 intelUnmapScreenRegions(intelScreen
);
113 if (drmMap(sPriv
->fd
,
114 intelScreen
->tex
.handle
,
115 intelScreen
->tex
.size
,
116 (drmAddress
*)&intelScreen
->tex
.map
) != 0) {
117 intelUnmapScreenRegions(intelScreen
);
122 printf("Mappings: front: %p back: %p depth: %p tex: %p\n",
123 intelScreen
->front
.map
,
124 intelScreen
->back
.map
,
125 intelScreen
->depth
.map
,
126 intelScreen
->tex
.map
);
132 intelUnmapScreenRegions(intelScreenPrivate
*intelScreen
)
134 #define REALLY_UNMAP 1
135 /* If front.handle is present, we're doing the dynamic front buffer mapping,
136 * but if we've fallen back to static allocation then we shouldn't try to
139 if (intelScreen
->front
.handle
) {
141 if (drmUnmap(intelScreen
->front
.map
, intelScreen
->front
.size
) != 0)
142 printf("drmUnmap front failed!\n");
144 intelScreen
->front
.map
= NULL
;
146 if (intelScreen
->back
.map
) {
148 if (drmUnmap(intelScreen
->back
.map
, intelScreen
->back
.size
) != 0)
149 printf("drmUnmap back failed!\n");
151 intelScreen
->back
.map
= NULL
;
153 if (intelScreen
->depth
.map
) {
155 drmUnmap(intelScreen
->depth
.map
, intelScreen
->depth
.size
);
156 intelScreen
->depth
.map
= NULL
;
159 if (intelScreen
->tex
.map
) {
161 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
162 intelScreen
->tex
.map
= NULL
;
169 intelPrintDRIInfo(intelScreenPrivate
*intelScreen
,
170 __DRIscreenPrivate
*sPriv
,
173 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
174 intelScreen
->front
.size
, intelScreen
->front
.offset
,
175 intelScreen
->front
.pitch
);
176 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
177 intelScreen
->back
.size
, intelScreen
->back
.offset
,
178 intelScreen
->back
.pitch
);
179 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
180 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
181 intelScreen
->depth
.pitch
);
182 fprintf(stderr
, "*** Rotated size: 0x%x offset: 0x%x pitch: %d\n",
183 intelScreen
->rotated
.size
, intelScreen
->rotated
.offset
,
184 intelScreen
->rotated
.pitch
);
185 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
186 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
187 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
192 intelPrintSAREA(volatile drmI830Sarea
*sarea
)
194 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
, sarea
->height
);
195 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
197 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x\n",
198 sarea
->front_offset
, sarea
->front_size
,
199 (unsigned) sarea
->front_handle
);
201 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x\n",
202 sarea
->back_offset
, sarea
->back_size
,
203 (unsigned) sarea
->back_handle
);
204 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x\n",
205 sarea
->depth_offset
, sarea
->depth_size
,
206 (unsigned) sarea
->depth_handle
);
207 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
208 sarea
->tex_offset
, sarea
->tex_size
,
209 (unsigned) sarea
->tex_handle
);
210 fprintf(stderr
, "SAREA: rotation: %d\n", sarea
->rotation
);
212 "SAREA: rotated offset: 0x%08x size: 0x%x\n",
213 sarea
->rotated_offset
, sarea
->rotated_size
);
214 fprintf(stderr
, "SAREA: rotated pitch: %d\n", sarea
->rotated_pitch
);
219 * A number of the screen parameters are obtained/computed from
220 * information in the SAREA. This function updates those parameters.
223 intelUpdateScreenFromSAREA(intelScreenPrivate
*intelScreen
,
224 volatile drmI830Sarea
*sarea
)
226 intelScreen
->width
= sarea
->width
;
227 intelScreen
->height
= sarea
->height
;
229 intelScreen
->front
.offset
= sarea
->front_offset
;
230 intelScreen
->front
.pitch
= sarea
->pitch
* intelScreen
->cpp
;
231 intelScreen
->front
.handle
= sarea
->front_handle
;
232 intelScreen
->front
.size
= sarea
->front_size
;
233 intelScreen
->front
.tiled
= sarea
->front_tiled
;
235 intelScreen
->back
.offset
= sarea
->back_offset
;
236 intelScreen
->back
.pitch
= sarea
->pitch
* intelScreen
->cpp
;
237 intelScreen
->back
.handle
= sarea
->back_handle
;
238 intelScreen
->back
.size
= sarea
->back_size
;
239 intelScreen
->back
.tiled
= sarea
->back_tiled
;
241 intelScreen
->depth
.offset
= sarea
->depth_offset
;
242 intelScreen
->depth
.pitch
= sarea
->pitch
* intelScreen
->cpp
;
243 intelScreen
->depth
.handle
= sarea
->depth_handle
;
244 intelScreen
->depth
.size
= sarea
->depth_size
;
245 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
247 intelScreen
->tex
.offset
= sarea
->tex_offset
;
248 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
249 intelScreen
->tex
.handle
= sarea
->tex_handle
;
250 intelScreen
->tex
.size
= sarea
->tex_size
;
252 intelScreen
->rotated
.offset
= sarea
->rotated_offset
;
253 intelScreen
->rotated
.pitch
= sarea
->rotated_pitch
* intelScreen
->cpp
;
254 intelScreen
->rotated
.size
= sarea
->rotated_size
;
255 intelScreen
->rotated
.tiled
= sarea
->rotated_tiled
;
256 intelScreen
->current_rotation
= sarea
->rotation
;
258 matrix23Rotate(&intelScreen
->rotMatrix
,
259 sarea
->width
, sarea
->height
, sarea
->rotation
);
261 intelScreen
->rotatedWidth
= sarea
->virtualX
;
262 intelScreen
->rotatedHeight
= sarea
->virtualY
;
265 intelPrintSAREA(sarea
);
269 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
271 intelScreenPrivate
*intelScreen
;
272 I830DRIPtr gDRIPriv
= (I830DRIPtr
)sPriv
->pDevPriv
;
273 PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension
=
274 (PFNGLXSCRENABLEEXTENSIONPROC
) (*dri_interface
->getProcAddress("glxEnableExtension"));
275 void * const psc
= sPriv
->psc
->screenConfigs
;
276 volatile drmI830Sarea
*sarea
;
278 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
279 fprintf(stderr
,"\nERROR! sizeof(I830DRIRec) (%ld) does not match passed size from device driver (%d)\n", (unsigned long)sizeof(I830DRIRec
), sPriv
->devPrivSize
);
283 /* Allocate the private area */
284 intelScreen
= (intelScreenPrivate
*)CALLOC(sizeof(intelScreenPrivate
));
286 fprintf(stderr
,"\nERROR! Allocating private area failed\n");
289 /* parse information in __driConfigOptions */
290 driParseOptionInfo (&intelScreen
->optionCache
,
291 __driConfigOptions
, __driNConfigOptions
);
293 intelScreen
->driScrnPriv
= sPriv
;
294 sPriv
->private = (void *)intelScreen
;
295 intelScreen
->sarea_priv_offset
= gDRIPriv
->sarea_priv_offset
;
296 sarea
= (volatile drmI830Sarea
*)
297 (((GLubyte
*)sPriv
->pSAREA
)+intelScreen
->sarea_priv_offset
);
299 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
300 intelScreen
->mem
= gDRIPriv
->mem
;
301 intelScreen
->cpp
= gDRIPriv
->cpp
;
303 switch (gDRIPriv
->bitsPerPixel
) {
304 case 15: intelScreen
->fbFormat
= DV_PF_555
; break;
305 case 16: intelScreen
->fbFormat
= DV_PF_565
; break;
306 case 32: intelScreen
->fbFormat
= DV_PF_8888
; break;
309 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
312 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
314 if (!intelMapScreenRegions(sPriv
)) {
315 fprintf(stderr
,"\nERROR! mapping regions\n");
316 _mesa_free(intelScreen
);
317 sPriv
->private = NULL
;
321 intelScreen
->drmMinor
= sPriv
->drmMinor
;
323 /* Determine if IRQs are active? */
328 gp
.param
= I830_PARAM_IRQ_ACTIVE
;
329 gp
.value
= &intelScreen
->irq_active
;
331 ret
= drmCommandWriteRead( sPriv
->fd
, DRM_I830_GETPARAM
,
334 fprintf(stderr
, "drmI830GetParam: %d\n", ret
);
339 /* Determine if batchbuffers are allowed */
344 gp
.param
= I830_PARAM_ALLOW_BATCHBUFFER
;
345 gp
.value
= &intelScreen
->allow_batchbuffer
;
347 ret
= drmCommandWriteRead( sPriv
->fd
, DRM_I830_GETPARAM
,
350 fprintf(stderr
, "drmI830GetParam: (%d) %d\n", gp
.param
, ret
);
355 if (glx_enable_extension
!= NULL
) {
356 (*glx_enable_extension
)( psc
, "GLX_SGI_swap_control" );
357 (*glx_enable_extension
)( psc
, "GLX_SGI_video_sync" );
358 (*glx_enable_extension
)( psc
, "GLX_MESA_swap_control" );
359 (*glx_enable_extension
)( psc
, "GLX_MESA_swap_frame_usage" );
360 (*glx_enable_extension
)( psc
, "GLX_SGI_make_current_read" );
361 (*glx_enable_extension
)( psc
, "GLX_MESA_copy_sub_buffer" );
368 static void intelDestroyScreen(__DRIscreenPrivate
*sPriv
)
370 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)sPriv
->private;
372 intelUnmapScreenRegions(intelScreen
);
374 sPriv
->private = NULL
;
377 static GLboolean
intelCreateBuffer( __DRIscreenPrivate
*driScrnPriv
,
378 __DRIdrawablePrivate
*driDrawPriv
,
379 const __GLcontextModes
*mesaVis
,
382 intelScreenPrivate
*screen
= (intelScreenPrivate
*) driScrnPriv
->private;
385 return GL_FALSE
; /* not implemented */
387 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
388 mesaVis
->depthBits
!= 24);
390 struct gl_framebuffer
*fb
= _mesa_create_framebuffer(mesaVis
);
393 driRenderbuffer
*frontRb
394 = driNewRenderbuffer(GL_RGBA
,
397 screen
->front
.offset
, screen
->front
.pitch
,
399 intelSetSpanFunctions(frontRb
, mesaVis
);
400 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &frontRb
->Base
);
403 if (mesaVis
->doubleBufferMode
) {
404 driRenderbuffer
*backRb
405 = driNewRenderbuffer(GL_RGBA
,
408 screen
->back
.offset
, screen
->back
.pitch
,
410 intelSetSpanFunctions(backRb
, mesaVis
);
411 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &backRb
->Base
);
414 if (mesaVis
->depthBits
== 16) {
415 driRenderbuffer
*depthRb
416 = driNewRenderbuffer(GL_DEPTH_COMPONENT16
,
419 screen
->depth
.offset
, screen
->depth
.pitch
,
421 intelSetSpanFunctions(depthRb
, mesaVis
);
422 _mesa_add_renderbuffer(fb
, BUFFER_DEPTH
, &depthRb
->Base
);
424 else if (mesaVis
->depthBits
== 24) {
425 driRenderbuffer
*depthRb
426 = driNewRenderbuffer(GL_DEPTH_COMPONENT24
,
429 screen
->depth
.offset
, screen
->depth
.pitch
,
431 intelSetSpanFunctions(depthRb
, mesaVis
);
432 _mesa_add_renderbuffer(fb
, BUFFER_DEPTH
, &depthRb
->Base
);
435 if (mesaVis
->stencilBits
> 0 && !swStencil
) {
436 driRenderbuffer
*stencilRb
437 = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT
,
440 screen
->depth
.offset
, screen
->depth
.pitch
,
442 intelSetSpanFunctions(stencilRb
, mesaVis
);
443 _mesa_add_renderbuffer(fb
, BUFFER_STENCIL
, &stencilRb
->Base
);
446 _mesa_add_soft_renderbuffers(fb
,
447 GL_FALSE
, /* color */
448 GL_FALSE
, /* depth */
450 mesaVis
->accumRedBits
> 0,
451 GL_FALSE
, /* alpha */
453 driDrawPriv
->driverPrivate
= (void *) fb
;
455 return (driDrawPriv
->driverPrivate
!= NULL
);
459 static void intelDestroyBuffer(__DRIdrawablePrivate
*driDrawPriv
)
461 _mesa_destroy_framebuffer((GLframebuffer
*) (driDrawPriv
->driverPrivate
));
466 * Get information about previous buffer swaps.
469 intelGetSwapInfo( __DRIdrawablePrivate
*dPriv
, __DRIswapInfo
* sInfo
)
471 struct intel_context
*intel
;
473 if ( (dPriv
== NULL
) || (dPriv
->driContextPriv
== NULL
)
474 || (dPriv
->driContextPriv
->driverPrivate
== NULL
)
475 || (sInfo
== NULL
) ) {
479 intel
= dPriv
->driContextPriv
->driverPrivate
;
480 sInfo
->swap_count
= intel
->swap_count
;
481 sInfo
->swap_ust
= intel
->swap_ust
;
482 sInfo
->swap_missed_count
= intel
->swap_missed_count
;
484 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
485 ? driCalculateSwapUsage( dPriv
, 0, intel
->swap_missed_ust
)
492 /* There are probably better ways to do this, such as an
493 * init-designated function to register chipids and createcontext
496 extern GLboolean
i830CreateContext( const __GLcontextModes
*mesaVis
,
497 __DRIcontextPrivate
*driContextPriv
,
498 void *sharedContextPrivate
);
500 extern GLboolean
i915CreateContext( const __GLcontextModes
*mesaVis
,
501 __DRIcontextPrivate
*driContextPriv
,
502 void *sharedContextPrivate
);
504 extern GLboolean
brwCreateContext( const __GLcontextModes
*mesaVis
,
505 __DRIcontextPrivate
*driContextPriv
,
506 void *sharedContextPrivate
);
511 static GLboolean
intelCreateContext( const __GLcontextModes
*mesaVis
,
512 __DRIcontextPrivate
*driContextPriv
,
513 void *sharedContextPrivate
)
516 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
517 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)sPriv
->private;
518 switch (intelScreen
->deviceID
) {
520 case PCI_CHIP_I830_M
:
521 case PCI_CHIP_I855_GM
:
522 case PCI_CHIP_I865_G
:
523 return i830CreateContext( mesaVis
, driContextPriv
,
524 sharedContextPrivate
);
526 case PCI_CHIP_I915_G
:
527 case PCI_CHIP_I915_GM
:
528 case PCI_CHIP_I945_G
:
529 case PCI_CHIP_I945_GM
:
530 return i915CreateContext( mesaVis
, driContextPriv
,
531 sharedContextPrivate
);
534 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
538 return brwCreateContext( mesaVis
, driContextPriv
,
539 sharedContextPrivate
);
544 static const struct __DriverAPIRec intelAPI
= {
545 .InitDriver
= intelInitDriver
,
546 .DestroyScreen
= intelDestroyScreen
,
547 .CreateContext
= intelCreateContext
,
548 .DestroyContext
= intelDestroyContext
,
549 .CreateBuffer
= intelCreateBuffer
,
550 .DestroyBuffer
= intelDestroyBuffer
,
551 .SwapBuffers
= intelSwapBuffers
,
552 .MakeCurrent
= intelMakeCurrent
,
553 .UnbindContext
= intelUnbindContext
,
554 .GetSwapInfo
= intelGetSwapInfo
,
555 .GetMSC
= driGetMSC32
,
556 .WaitForMSC
= driWaitForMSC32
,
558 .SwapBuffersMSC
= NULL
,
559 .CopySubBuffer
= intelCopySubBuffer
563 static __GLcontextModes
*
564 intelFillInModes( unsigned pixel_bits
, unsigned depth_bits
,
565 unsigned stencil_bits
, GLboolean have_back_buffer
)
567 __GLcontextModes
* modes
;
568 __GLcontextModes
* m
;
570 unsigned depth_buffer_factor
;
571 unsigned back_buffer_factor
;
575 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
576 * support pageflipping at all.
578 static const GLenum back_buffer_modes
[] = {
579 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
582 u_int8_t depth_bits_array
[3];
583 u_int8_t stencil_bits_array
[3];
586 depth_bits_array
[0] = 0;
587 depth_bits_array
[1] = depth_bits
;
588 depth_bits_array
[2] = depth_bits
;
590 /* Just like with the accumulation buffer, always provide some modes
591 * with a stencil buffer. It will be a sw fallback, but some apps won't
594 stencil_bits_array
[0] = 0;
595 stencil_bits_array
[1] = 0;
596 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
598 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
599 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
601 num_modes
= depth_buffer_factor
* back_buffer_factor
* 4;
603 if ( pixel_bits
== 16 ) {
605 fb_type
= GL_UNSIGNED_SHORT_5_6_5
;
609 fb_type
= GL_UNSIGNED_INT_8_8_8_8_REV
;
612 modes
= (*dri_interface
->createContextModes
)( num_modes
, sizeof( __GLcontextModes
) );
614 if ( ! driFillInModes( & m
, fb_format
, fb_type
,
615 depth_bits_array
, stencil_bits_array
, depth_buffer_factor
,
616 back_buffer_modes
, back_buffer_factor
,
618 fprintf( stderr
, "[%s:%u] Error creating FBConfig!\n",
619 __func__
, __LINE__
);
622 if ( ! driFillInModes( & m
, fb_format
, fb_type
,
623 depth_bits_array
, stencil_bits_array
, depth_buffer_factor
,
624 back_buffer_modes
, back_buffer_factor
,
625 GLX_DIRECT_COLOR
) ) {
626 fprintf( stderr
, "[%s:%u] Error creating FBConfig!\n",
627 __func__
, __LINE__
);
631 /* Mark the visual as slow if there are "fake" stencil bits.
633 for ( m
= modes
; m
!= NULL
; m
= m
->next
) {
634 if ( (m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
) ) {
635 m
->visualRating
= GLX_SLOW_CONFIG
;
644 * This is the bootstrap function for the driver. libGL supplies all of the
645 * requisite information about the system, and the driver initializes itself.
646 * This routine also fills in the linked list pointed to by \c driver_modes
647 * with the \c __GLcontextModes that the driver can support for windows or
650 * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
654 void * __driCreateNewScreen_20050727( __DRInativeDisplay
*dpy
, int scrn
, __DRIscreen
*psc
,
655 const __GLcontextModes
* modes
,
656 const __DRIversion
* ddx_version
,
657 const __DRIversion
* dri_version
,
658 const __DRIversion
* drm_version
,
659 const __DRIframebuffer
* frame_buffer
,
660 drmAddress pSAREA
, int fd
,
661 int internal_api_version
,
662 const __DRIinterfaceMethods
* interface
,
663 __GLcontextModes
** driver_modes
)
666 __DRIscreenPrivate
*psp
;
667 static const __DRIversion ddx_expected
= { 1, 6, 0 };
668 static const __DRIversion dri_expected
= { 4, 0, 0 };
669 static const __DRIversion drm_expected
= { 1, 3, 0 };
671 dri_interface
= interface
;
673 if ( ! driCheckDriDdxDrmVersions2( "i915",
674 dri_version
, & dri_expected
,
675 ddx_version
, & ddx_expected
,
676 drm_version
, & drm_expected
) ) {
680 psp
= __driUtilCreateNewScreen(dpy
, scrn
, psc
, NULL
,
681 ddx_version
, dri_version
, drm_version
,
682 frame_buffer
, pSAREA
, fd
,
683 internal_api_version
, &intelAPI
);
685 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
686 *driver_modes
= intelFillInModes( dri_priv
->cpp
* 8,
687 (dri_priv
->cpp
== 2) ? 16 : 24,
688 (dri_priv
->cpp
== 2) ? 0 : 8,
691 /* Calling driInitExtensions here, with a NULL context pointer, does not actually
692 * enable the extensions. It just makes sure that all the dispatch offsets for all
693 * the extensions that *might* be enables are known. This is needed because the
694 * dispatch offsets need to be known when _mesa_context_create is called, but we can't
695 * enable the extensions until we have a context pointer.
697 * Hello chicken. Hello egg. How are you two today?
699 driInitExtensions( NULL
, card_extensions
, GL_FALSE
);