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_context.h"
42 #include "intel_tex.h"
43 #include "intel_span.h"
44 #include "intel_ioctl.h"
48 PUBLIC
const char __driConfigOptions
[] =
50 DRI_CONF_SECTION_PERFORMANCE
51 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS
)
52 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0
)
54 DRI_CONF_SECTION_QUALITY
55 DRI_CONF_FORCE_S3TC_ENABLE(false)
56 DRI_CONF_ALLOW_LARGE_TEXTURES(1)
59 const GLuint __driNConfigOptions
= 4;
61 #ifdef USE_NEW_INTERFACE
62 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
63 #endif /*USE_NEW_INTERFACE*/
66 * Map all the memory regions described by the screen.
67 * \return GL_TRUE if success, GL_FALSE if error.
70 intelMapScreenRegions(__DRIscreenPrivate
*sPriv
)
72 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)sPriv
->private;
74 if (intelScreen
->front
.handle
) {
76 intelScreen
->front
.handle
,
77 intelScreen
->front
.size
,
78 (drmAddress
*)&intelScreen
->front
.map
) != 0) {
79 _mesa_problem(NULL
, "drmMap(frontbuffer) failed!");
83 /* Use the old static allocation method if the server isn't setting up
84 * a movable handle for us. Add in the front buffer offset from
85 * framebuffer start, as our span routines (unlike other drivers) expect
86 * the renderbuffer address to point to the beginning of the
89 intelScreen
->front
.map
= (char *)sPriv
->pFB
;
90 if (intelScreen
->front
.map
== NULL
) {
91 fprintf(stderr
, "Failed to find framebuffer mapping\n");
97 intelScreen
->back
.handle
,
98 intelScreen
->back
.size
,
99 (drmAddress
*)&intelScreen
->back
.map
) != 0) {
100 intelUnmapScreenRegions(intelScreen
);
104 if (drmMap(sPriv
->fd
,
105 intelScreen
->depth
.handle
,
106 intelScreen
->depth
.size
,
107 (drmAddress
*)&intelScreen
->depth
.map
) != 0) {
108 intelUnmapScreenRegions(intelScreen
);
112 if (intelScreen
->tex
.size
!= 0) {
113 intelScreen
->ttm
= GL_FALSE
;
115 if (drmMap(sPriv
->fd
,
116 intelScreen
->tex
.handle
,
117 intelScreen
->tex
.size
,
118 (drmAddress
*)&intelScreen
->tex
.map
) != 0) {
119 intelUnmapScreenRegions(intelScreen
);
123 intelScreen
->ttm
= GL_TRUE
;
127 printf("Mappings: front: %p back: %p depth: %p tex: %p\n",
128 intelScreen
->front
.map
,
129 intelScreen
->back
.map
,
130 intelScreen
->depth
.map
,
131 intelScreen
->tex
.map
);
137 intelUnmapScreenRegions(intelScreenPrivate
*intelScreen
)
139 #define REALLY_UNMAP 1
140 /* If front.handle is present, we're doing the dynamic front buffer mapping,
141 * but if we've fallen back to static allocation then we shouldn't try to
144 if (intelScreen
->front
.handle
) {
146 if (drmUnmap(intelScreen
->front
.map
, intelScreen
->front
.size
) != 0)
147 printf("drmUnmap front failed!\n");
149 intelScreen
->front
.map
= NULL
;
151 if (intelScreen
->back
.map
) {
153 if (drmUnmap(intelScreen
->back
.map
, intelScreen
->back
.size
) != 0)
154 printf("drmUnmap back failed!\n");
156 intelScreen
->back
.map
= NULL
;
158 if (intelScreen
->depth
.map
) {
160 drmUnmap(intelScreen
->depth
.map
, intelScreen
->depth
.size
);
161 intelScreen
->depth
.map
= NULL
;
164 if (intelScreen
->tex
.map
) {
166 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
167 intelScreen
->tex
.map
= NULL
;
172 /** Driver-specific fence emit implementation for the fake memory manager. */
174 intel_fence_emit(void *private)
176 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)private;
179 /* XXX: Need to emit a flush, if we haven't already (at least with the
180 * current batchbuffer implementation, we have).
183 fence
= intelEmitIrqLocked(intelScreen
);
188 /** Driver-specific fence wait implementation for the fake memory manager. */
190 intel_fence_wait(void *private, unsigned int cookie
)
192 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)private;
194 intelWaitIrq(intelScreen
, cookie
);
200 intelPrintDRIInfo(intelScreenPrivate
*intelScreen
,
201 __DRIscreenPrivate
*sPriv
,
204 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
205 intelScreen
->front
.size
, intelScreen
->front
.offset
,
206 intelScreen
->front
.pitch
);
207 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
208 intelScreen
->back
.size
, intelScreen
->back
.offset
,
209 intelScreen
->back
.pitch
);
210 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
211 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
212 intelScreen
->depth
.pitch
);
213 fprintf(stderr
, "*** Rotated size: 0x%x offset: 0x%x pitch: %d\n",
214 intelScreen
->rotated
.size
, intelScreen
->rotated
.offset
,
215 intelScreen
->rotated
.pitch
);
216 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
217 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
218 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
223 intelPrintSAREA(volatile drmI830Sarea
*sarea
)
225 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
, sarea
->height
);
226 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
228 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x\n",
229 sarea
->front_offset
, sarea
->front_size
,
230 (unsigned) sarea
->front_handle
);
232 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x\n",
233 sarea
->back_offset
, sarea
->back_size
,
234 (unsigned) sarea
->back_handle
);
235 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x\n",
236 sarea
->depth_offset
, sarea
->depth_size
,
237 (unsigned) sarea
->depth_handle
);
238 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
239 sarea
->tex_offset
, sarea
->tex_size
,
240 (unsigned) sarea
->tex_handle
);
241 fprintf(stderr
, "SAREA: rotation: %d\n", sarea
->rotation
);
243 "SAREA: rotated offset: 0x%08x size: 0x%x\n",
244 sarea
->rotated_offset
, sarea
->rotated_size
);
245 fprintf(stderr
, "SAREA: rotated pitch: %d\n", sarea
->rotated_pitch
);
250 * A number of the screen parameters are obtained/computed from
251 * information in the SAREA. This function updates those parameters.
254 intelUpdateScreenFromSAREA(intelScreenPrivate
*intelScreen
,
255 volatile drmI830Sarea
*sarea
)
257 intelScreen
->width
= sarea
->width
;
258 intelScreen
->height
= sarea
->height
;
260 intelScreen
->front
.offset
= sarea
->front_offset
;
261 intelScreen
->front
.pitch
= sarea
->pitch
* intelScreen
->cpp
;
262 intelScreen
->front
.handle
= sarea
->front_handle
;
263 intelScreen
->front
.size
= sarea
->front_size
;
264 intelScreen
->front
.tiled
= sarea
->front_tiled
;
266 intelScreen
->back
.offset
= sarea
->back_offset
;
267 intelScreen
->back
.pitch
= sarea
->pitch
* intelScreen
->cpp
;
268 intelScreen
->back
.handle
= sarea
->back_handle
;
269 intelScreen
->back
.size
= sarea
->back_size
;
270 intelScreen
->back
.tiled
= sarea
->back_tiled
;
272 intelScreen
->depth
.offset
= sarea
->depth_offset
;
273 intelScreen
->depth
.pitch
= sarea
->pitch
* intelScreen
->cpp
;
274 intelScreen
->depth
.handle
= sarea
->depth_handle
;
275 intelScreen
->depth
.size
= sarea
->depth_size
;
276 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
278 intelScreen
->tex
.offset
= sarea
->tex_offset
;
279 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
280 intelScreen
->tex
.handle
= sarea
->tex_handle
;
281 intelScreen
->tex
.size
= sarea
->tex_size
;
283 intelScreen
->rotated
.offset
= sarea
->rotated_offset
;
284 intelScreen
->rotated
.pitch
= sarea
->rotated_pitch
* intelScreen
->cpp
;
285 intelScreen
->rotated
.size
= sarea
->rotated_size
;
286 intelScreen
->rotated
.tiled
= sarea
->rotated_tiled
;
287 intelScreen
->current_rotation
= sarea
->rotation
;
289 matrix23Rotate(&intelScreen
->rotMatrix
,
290 sarea
->width
, sarea
->height
, sarea
->rotation
);
292 intelScreen
->rotatedWidth
= sarea
->virtualX
;
293 intelScreen
->rotatedHeight
= sarea
->virtualY
;
296 intelPrintSAREA(sarea
);
300 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
302 intelScreenPrivate
*intelScreen
;
303 I830DRIPtr gDRIPriv
= (I830DRIPtr
)sPriv
->pDevPriv
;
304 PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension
=
305 (PFNGLXSCRENABLEEXTENSIONPROC
) (*dri_interface
->getProcAddress("glxEnableExtension"));
306 void * const psc
= sPriv
->psc
->screenConfigs
;
307 volatile drmI830Sarea
*sarea
;
309 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
310 fprintf(stderr
,"\nERROR! sizeof(I830DRIRec) (%ld) does not match passed size from device driver (%d)\n", (unsigned long)sizeof(I830DRIRec
), sPriv
->devPrivSize
);
314 /* Allocate the private area */
315 intelScreen
= (intelScreenPrivate
*)CALLOC(sizeof(intelScreenPrivate
));
317 fprintf(stderr
,"\nERROR! Allocating private area failed\n");
320 /* parse information in __driConfigOptions */
321 driParseOptionInfo (&intelScreen
->optionCache
,
322 __driConfigOptions
, __driNConfigOptions
);
324 intelScreen
->driScrnPriv
= sPriv
;
325 sPriv
->private = (void *)intelScreen
;
326 intelScreen
->sarea_priv_offset
= gDRIPriv
->sarea_priv_offset
;
327 sarea
= (volatile drmI830Sarea
*)
328 (((GLubyte
*)sPriv
->pSAREA
)+intelScreen
->sarea_priv_offset
);
330 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
331 intelScreen
->mem
= gDRIPriv
->mem
;
332 intelScreen
->cpp
= gDRIPriv
->cpp
;
334 switch (gDRIPriv
->bitsPerPixel
) {
335 case 15: intelScreen
->fbFormat
= DV_PF_555
; break;
336 case 16: intelScreen
->fbFormat
= DV_PF_565
; break;
337 case 32: intelScreen
->fbFormat
= DV_PF_8888
; break;
340 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
343 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
345 if (!intelMapScreenRegions(sPriv
)) {
346 fprintf(stderr
,"\nERROR! mapping regions\n");
347 _mesa_free(intelScreen
);
348 sPriv
->private = NULL
;
352 intelScreen
->drmMinor
= sPriv
->drmMinor
;
354 /* Determine if IRQs are active? */
359 gp
.param
= I830_PARAM_IRQ_ACTIVE
;
360 gp
.value
= &intelScreen
->irq_active
;
362 ret
= drmCommandWriteRead( sPriv
->fd
, DRM_I830_GETPARAM
,
365 fprintf(stderr
, "drmI830GetParam: %d\n", ret
);
370 /* Determine if batchbuffers are allowed */
375 gp
.param
= I830_PARAM_ALLOW_BATCHBUFFER
;
376 gp
.value
= &intelScreen
->allow_batchbuffer
;
378 ret
= drmCommandWriteRead( sPriv
->fd
, DRM_I830_GETPARAM
,
381 fprintf(stderr
, "drmI830GetParam: (%d) %d\n", gp
.param
, ret
);
386 if (glx_enable_extension
!= NULL
) {
387 (*glx_enable_extension
)( psc
, "GLX_SGI_swap_control" );
388 (*glx_enable_extension
)( psc
, "GLX_SGI_video_sync" );
389 (*glx_enable_extension
)( psc
, "GLX_MESA_swap_control" );
390 (*glx_enable_extension
)( psc
, "GLX_MESA_swap_frame_usage" );
391 (*glx_enable_extension
)( psc
, "GLX_SGI_make_current_read" );
392 (*glx_enable_extension
)( psc
, "GLX_MESA_copy_sub_buffer" );
395 assert(!intelScreen
->ttm
);
396 intelScreen
->bufmgr
= dri_bufmgr_fake_init(intelScreen
->tex
.offset
,
397 intelScreen
->tex
.map
,
398 intelScreen
->tex
.size
,
402 if (intelScreen
->bufmgr
== FALSE
) {
403 fprintf(stderr
, "Couldn't initialize buffer manager\n");
411 static void intelDestroyScreen(__DRIscreenPrivate
*sPriv
)
413 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)sPriv
->private;
415 intelUnmapScreenRegions(intelScreen
);
416 dri_bufmgr_destroy(intelScreen
->bufmgr
);
418 sPriv
->private = NULL
;
421 static GLboolean
intelCreateBuffer( __DRIscreenPrivate
*driScrnPriv
,
422 __DRIdrawablePrivate
*driDrawPriv
,
423 const __GLcontextModes
*mesaVis
,
426 intelScreenPrivate
*screen
= (intelScreenPrivate
*) driScrnPriv
->private;
429 return GL_FALSE
; /* not implemented */
431 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
432 mesaVis
->depthBits
!= 24);
434 struct gl_framebuffer
*fb
= _mesa_create_framebuffer(mesaVis
);
437 driRenderbuffer
*frontRb
438 = driNewRenderbuffer(GL_RGBA
,
441 screen
->front
.offset
, screen
->front
.pitch
,
443 intelSetSpanFunctions(frontRb
, mesaVis
);
444 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &frontRb
->Base
);
447 if (mesaVis
->doubleBufferMode
) {
448 driRenderbuffer
*backRb
449 = driNewRenderbuffer(GL_RGBA
,
452 screen
->back
.offset
, screen
->back
.pitch
,
454 intelSetSpanFunctions(backRb
, mesaVis
);
455 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &backRb
->Base
);
458 if (mesaVis
->depthBits
== 16) {
459 driRenderbuffer
*depthRb
460 = driNewRenderbuffer(GL_DEPTH_COMPONENT16
,
463 screen
->depth
.offset
, screen
->depth
.pitch
,
465 intelSetSpanFunctions(depthRb
, mesaVis
);
466 _mesa_add_renderbuffer(fb
, BUFFER_DEPTH
, &depthRb
->Base
);
468 else if (mesaVis
->depthBits
== 24) {
469 driRenderbuffer
*depthRb
470 = driNewRenderbuffer(GL_DEPTH_COMPONENT24
,
473 screen
->depth
.offset
, screen
->depth
.pitch
,
475 intelSetSpanFunctions(depthRb
, mesaVis
);
476 _mesa_add_renderbuffer(fb
, BUFFER_DEPTH
, &depthRb
->Base
);
479 if (mesaVis
->stencilBits
> 0 && !swStencil
) {
480 driRenderbuffer
*stencilRb
481 = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT
,
484 screen
->depth
.offset
, screen
->depth
.pitch
,
486 intelSetSpanFunctions(stencilRb
, mesaVis
);
487 _mesa_add_renderbuffer(fb
, BUFFER_STENCIL
, &stencilRb
->Base
);
490 _mesa_add_soft_renderbuffers(fb
,
491 GL_FALSE
, /* color */
492 GL_FALSE
, /* depth */
494 mesaVis
->accumRedBits
> 0,
495 GL_FALSE
, /* alpha */
497 driDrawPriv
->driverPrivate
= (void *) fb
;
499 return (driDrawPriv
->driverPrivate
!= NULL
);
503 static void intelDestroyBuffer(__DRIdrawablePrivate
*driDrawPriv
)
505 _mesa_unreference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)));
510 * Get information about previous buffer swaps.
513 intelGetSwapInfo( __DRIdrawablePrivate
*dPriv
, __DRIswapInfo
* sInfo
)
515 struct intel_context
*intel
;
517 if ( (dPriv
== NULL
) || (dPriv
->driContextPriv
== NULL
)
518 || (dPriv
->driContextPriv
->driverPrivate
== NULL
)
519 || (sInfo
== NULL
) ) {
523 intel
= dPriv
->driContextPriv
->driverPrivate
;
524 sInfo
->swap_count
= intel
->swap_count
;
525 sInfo
->swap_ust
= intel
->swap_ust
;
526 sInfo
->swap_missed_count
= intel
->swap_missed_count
;
528 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
529 ? driCalculateSwapUsage( dPriv
, 0, intel
->swap_missed_ust
)
536 /* There are probably better ways to do this, such as an
537 * init-designated function to register chipids and createcontext
540 extern GLboolean
i830CreateContext( const __GLcontextModes
*mesaVis
,
541 __DRIcontextPrivate
*driContextPriv
,
542 void *sharedContextPrivate
);
544 extern GLboolean
i915CreateContext( const __GLcontextModes
*mesaVis
,
545 __DRIcontextPrivate
*driContextPriv
,
546 void *sharedContextPrivate
);
548 extern GLboolean
brwCreateContext( const __GLcontextModes
*mesaVis
,
549 __DRIcontextPrivate
*driContextPriv
,
550 void *sharedContextPrivate
);
555 static GLboolean
intelCreateContext( const __GLcontextModes
*mesaVis
,
556 __DRIcontextPrivate
*driContextPriv
,
557 void *sharedContextPrivate
)
560 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
561 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)sPriv
->private;
562 switch (intelScreen
->deviceID
) {
564 case PCI_CHIP_I830_M
:
565 case PCI_CHIP_I855_GM
:
566 case PCI_CHIP_I865_G
:
567 return i830CreateContext( mesaVis
, driContextPriv
,
568 sharedContextPrivate
);
570 case PCI_CHIP_I915_G
:
571 case PCI_CHIP_I915_GM
:
572 case PCI_CHIP_I945_G
:
573 case PCI_CHIP_I945_GM
:
574 return i915CreateContext( mesaVis
, driContextPriv
,
575 sharedContextPrivate
);
578 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
582 return brwCreateContext( mesaVis
, driContextPriv
,
583 sharedContextPrivate
);
588 static const struct __DriverAPIRec intelAPI
= {
589 .InitDriver
= intelInitDriver
,
590 .DestroyScreen
= intelDestroyScreen
,
591 .CreateContext
= intelCreateContext
,
592 .DestroyContext
= intelDestroyContext
,
593 .CreateBuffer
= intelCreateBuffer
,
594 .DestroyBuffer
= intelDestroyBuffer
,
595 .SwapBuffers
= intelSwapBuffers
,
596 .MakeCurrent
= intelMakeCurrent
,
597 .UnbindContext
= intelUnbindContext
,
598 .GetSwapInfo
= intelGetSwapInfo
,
599 .GetMSC
= driGetMSC32
,
600 .WaitForMSC
= driWaitForMSC32
,
602 .SwapBuffersMSC
= NULL
,
603 .CopySubBuffer
= intelCopySubBuffer
607 static __GLcontextModes
*
608 intelFillInModes( unsigned pixel_bits
, unsigned depth_bits
,
609 unsigned stencil_bits
, GLboolean have_back_buffer
)
611 __GLcontextModes
* modes
;
612 __GLcontextModes
* m
;
614 unsigned depth_buffer_factor
;
615 unsigned back_buffer_factor
;
619 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
620 * support pageflipping at all.
622 static const GLenum back_buffer_modes
[] = {
623 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
626 u_int8_t depth_bits_array
[3];
627 u_int8_t stencil_bits_array
[3];
630 depth_bits_array
[0] = 0;
631 depth_bits_array
[1] = depth_bits
;
632 depth_bits_array
[2] = depth_bits
;
634 /* Just like with the accumulation buffer, always provide some modes
635 * with a stencil buffer. It will be a sw fallback, but some apps won't
638 stencil_bits_array
[0] = 0;
639 stencil_bits_array
[1] = 0;
640 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
642 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
643 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
645 num_modes
= depth_buffer_factor
* back_buffer_factor
* 4;
647 if ( pixel_bits
== 16 ) {
649 fb_type
= GL_UNSIGNED_SHORT_5_6_5
;
653 fb_type
= GL_UNSIGNED_INT_8_8_8_8_REV
;
656 modes
= (*dri_interface
->createContextModes
)( num_modes
, sizeof( __GLcontextModes
) );
658 if ( ! driFillInModes( & m
, fb_format
, fb_type
,
659 depth_bits_array
, stencil_bits_array
, depth_buffer_factor
,
660 back_buffer_modes
, back_buffer_factor
,
662 fprintf( stderr
, "[%s:%u] Error creating FBConfig!\n",
663 __func__
, __LINE__
);
666 if ( ! driFillInModes( & m
, fb_format
, fb_type
,
667 depth_bits_array
, stencil_bits_array
, depth_buffer_factor
,
668 back_buffer_modes
, back_buffer_factor
,
669 GLX_DIRECT_COLOR
) ) {
670 fprintf( stderr
, "[%s:%u] Error creating FBConfig!\n",
671 __func__
, __LINE__
);
675 /* Mark the visual as slow if there are "fake" stencil bits.
677 for ( m
= modes
; m
!= NULL
; m
= m
->next
) {
678 if ( (m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
) ) {
679 m
->visualRating
= GLX_SLOW_CONFIG
;
688 * This is the bootstrap function for the driver. libGL supplies all of the
689 * requisite information about the system, and the driver initializes itself.
690 * This routine also fills in the linked list pointed to by \c driver_modes
691 * with the \c __GLcontextModes that the driver can support for windows or
694 * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
698 void * __driCreateNewScreen_20050727( __DRInativeDisplay
*dpy
, int scrn
, __DRIscreen
*psc
,
699 const __GLcontextModes
* modes
,
700 const __DRIversion
* ddx_version
,
701 const __DRIversion
* dri_version
,
702 const __DRIversion
* drm_version
,
703 const __DRIframebuffer
* frame_buffer
,
704 drmAddress pSAREA
, int fd
,
705 int internal_api_version
,
706 const __DRIinterfaceMethods
* interface
,
707 __GLcontextModes
** driver_modes
)
710 __DRIscreenPrivate
*psp
;
711 static const __DRIversion ddx_expected
= { 1, 6, 0 };
712 static const __DRIversion dri_expected
= { 4, 0, 0 };
713 static const __DRIversion drm_expected
= { 1, 3, 0 };
715 dri_interface
= interface
;
717 if ( ! driCheckDriDdxDrmVersions2( "i915",
718 dri_version
, & dri_expected
,
719 ddx_version
, & ddx_expected
,
720 drm_version
, & drm_expected
) ) {
724 psp
= __driUtilCreateNewScreen(dpy
, scrn
, psc
, NULL
,
725 ddx_version
, dri_version
, drm_version
,
726 frame_buffer
, pSAREA
, fd
,
727 internal_api_version
, &intelAPI
);
729 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
730 *driver_modes
= intelFillInModes( dri_priv
->cpp
* 8,
731 (dri_priv
->cpp
== 2) ? 16 : 24,
732 (dri_priv
->cpp
== 2) ? 0 : 8,
734 /* Calling driInitExtensions here, with a NULL context pointer, does not actually
735 * enable the extensions. It just makes sure that all the dispatch offsets for all
736 * the extensions that *might* be enables are known. This is needed because the
737 * dispatch offsets need to be known when _mesa_context_create is called, but we can't
738 * enable the extensions until we have a context pointer.
740 * Hello chicken. Hello egg. How are you two today?
742 intelInitExtensions(NULL
, GL_FALSE
);