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_buffers.h"
42
#include "intel_tex.h"
43
#include "intel_span.h"
44
#include "intel_tris.h"
45
#include "intel_ioctl.h"
46
#include "intel_fbo.h"
49
#include "dri_bufpool.h"
50
#include "intel_regions.h"
51
#include "intel_batchbuffer.h"
53
PUBLIC const char __driConfigOptions[] =
54
DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
55
DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
56
DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
57
DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY
58
DRI_CONF_FORCE_S3TC_ENABLE(false)
59
DRI_CONF_ALLOW_LARGE_TEXTURES(1)
60
DRI_CONF_SECTION_END DRI_CONF_END;
61
const GLuint __driNConfigOptions = 4;
63
#ifdef USE_NEW_INTERFACE
64
static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
65
#endif /*USE_NEW_INTERFACE */
67
extern const struct dri_extension card_extensions[];
70
* Map all the memory regions described by the screen.
71
* \return GL_TRUE if success, GL_FALSE if error.
74
intelMapScreenRegions(__DRIscreenPrivate * sPriv)
76
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
78
if (intelScreen->front.handle) {
80
intelScreen->front.handle,
81
intelScreen->front.size,
82
(drmAddress *) & intelScreen->front.map) != 0) {
83
_mesa_problem(NULL, "drmMap(frontbuffer) failed!");
88
_mesa_warning(NULL, "no front buffer handle in intelMapScreenRegions!");
92
_mesa_printf("Back 0x%08x ", intelScreen->back.handle);
94
intelScreen->back.handle,
95
intelScreen->back.size,
96
(drmAddress *) & intelScreen->back.map) != 0) {
97
intelUnmapScreenRegions(intelScreen);
101
if (intelScreen->third.handle) {
103
_mesa_printf("Third 0x%08x ", intelScreen->third.handle);
104
if (drmMap(sPriv->fd,
105
intelScreen->third.handle,
106
intelScreen->third.size,
107
(drmAddress *) & intelScreen->third.map) != 0) {
108
intelUnmapScreenRegions(intelScreen);
114
_mesa_printf("Depth 0x%08x ", intelScreen->depth.handle);
115
if (drmMap(sPriv->fd,
116
intelScreen->depth.handle,
117
intelScreen->depth.size,
118
(drmAddress *) & intelScreen->depth.map) != 0) {
119
intelUnmapScreenRegions(intelScreen);
124
_mesa_printf("TEX 0x%08x ", intelScreen->tex.handle);
125
if (drmMap(sPriv->fd,
126
intelScreen->tex.handle,
127
intelScreen->tex.size,
128
(drmAddress *) & intelScreen->tex.map) != 0) {
129
intelUnmapScreenRegions(intelScreen);
134
printf("Mappings: front: %p back: %p third: %p depth: %p tex: %p\n",
135
intelScreen->front.map,
136
intelScreen->back.map, intelScreen->third.map,
137
intelScreen->depth.map, intelScreen->tex.map);
142
static struct intel_region *
143
intel_recreate_static(intelScreenPrivate *intelScreen,
144
struct intel_region *region,
148
GLuint cpp, GLuint pitch, GLuint height)
151
intel_region_update_static(intelScreen, region, mem_type, offset,
152
virtual, cpp, pitch, height);
154
region = intel_region_create_static(intelScreen, mem_type, offset,
155
virtual, cpp, pitch, height);
161
/* Create intel_region structs to describe the static front,back,depth
162
* buffers created by the xserver.
164
* Although FBO's mean we now no longer use these as render targets in
165
* all circumstances, they won't go away until the back and depth
166
* buffers become private, and the front and rotated buffers will
169
* Note that these don't allocate video memory, just describe
170
* allocations alread made by the X server.
173
intel_recreate_static_regions(intelScreenPrivate *intelScreen)
175
intelScreen->front_region =
176
intel_recreate_static(intelScreen,
177
intelScreen->front_region,
179
intelScreen->front.offset,
180
intelScreen->front.map,
182
intelScreen->front.pitch / intelScreen->cpp,
183
intelScreen->height);
185
intelScreen->rotated_region =
186
intel_recreate_static(intelScreen,
187
intelScreen->rotated_region,
189
intelScreen->rotated.offset,
190
intelScreen->rotated.map,
192
intelScreen->rotated.pitch /
193
intelScreen->cpp, intelScreen->height);
196
intelScreen->back_region =
197
intel_recreate_static(intelScreen,
198
intelScreen->back_region,
200
intelScreen->back.offset,
201
intelScreen->back.map,
203
intelScreen->back.pitch / intelScreen->cpp,
204
intelScreen->height);
206
if (intelScreen->third.handle) {
207
intelScreen->third_region =
208
intel_recreate_static(intelScreen,
209
intelScreen->third_region,
211
intelScreen->third.offset,
212
intelScreen->third.map,
214
intelScreen->third.pitch / intelScreen->cpp,
215
intelScreen->height);
218
/* Still assuming front.cpp == depth.cpp
220
intelScreen->depth_region =
221
intel_recreate_static(intelScreen,
222
intelScreen->depth_region,
224
intelScreen->depth.offset,
225
intelScreen->depth.map,
227
intelScreen->depth.pitch / intelScreen->cpp,
228
intelScreen->height);
232
* Use the information in the sarea to update the screen parameters
233
* related to screen rotation. Needs to be called locked.
236
intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea)
238
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
240
intelUnmapScreenRegions(intelScreen);
241
intelUpdateScreenFromSAREA(intelScreen, sarea);
242
if (!intelMapScreenRegions(sPriv)) {
243
fprintf(stderr, "ERROR Remapping screen regions!!!\n");
245
intel_recreate_static_regions(intelScreen);
250
intelUnmapScreenRegions(intelScreenPrivate * intelScreen)
252
#define REALLY_UNMAP 1
253
if (intelScreen->front.map) {
255
if (drmUnmap(intelScreen->front.map, intelScreen->front.size) != 0)
256
printf("drmUnmap front failed!\n");
258
intelScreen->front.map = NULL;
260
if (intelScreen->back.map) {
262
if (drmUnmap(intelScreen->back.map, intelScreen->back.size) != 0)
263
printf("drmUnmap back failed!\n");
265
intelScreen->back.map = NULL;
267
if (intelScreen->third.map) {
269
if (drmUnmap(intelScreen->third.map, intelScreen->third.size) != 0)
270
printf("drmUnmap third failed!\n");
272
intelScreen->third.map = NULL;
274
if (intelScreen->depth.map) {
276
drmUnmap(intelScreen->depth.map, intelScreen->depth.size);
277
intelScreen->depth.map = NULL;
280
if (intelScreen->tex.map) {
282
drmUnmap(intelScreen->tex.map, intelScreen->tex.size);
283
intelScreen->tex.map = NULL;
290
intelPrintDRIInfo(intelScreenPrivate * intelScreen,
291
__DRIscreenPrivate * sPriv, I830DRIPtr gDRIPriv)
293
fprintf(stderr, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
294
intelScreen->front.size, intelScreen->front.offset,
295
intelScreen->front.pitch);
296
fprintf(stderr, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
297
intelScreen->back.size, intelScreen->back.offset,
298
intelScreen->back.pitch);
299
fprintf(stderr, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
300
intelScreen->depth.size, intelScreen->depth.offset,
301
intelScreen->depth.pitch);
302
fprintf(stderr, "*** Rotated size: 0x%x offset: 0x%x pitch: %d\n",
303
intelScreen->rotated.size, intelScreen->rotated.offset,
304
intelScreen->rotated.pitch);
305
fprintf(stderr, "*** Texture size: 0x%x offset: 0x%x\n",
306
intelScreen->tex.size, intelScreen->tex.offset);
307
fprintf(stderr, "*** Memory : 0x%x\n", gDRIPriv->mem);
312
intelPrintSAREA(const drmI830Sarea * sarea)
314
fprintf(stderr, "SAREA: sarea width %d height %d\n", sarea->width,
316
fprintf(stderr, "SAREA: pitch: %d\n", sarea->pitch);
318
"SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x\n",
319
sarea->front_offset, sarea->front_size,
320
(unsigned) sarea->front_handle);
322
"SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x\n",
323
sarea->back_offset, sarea->back_size,
324
(unsigned) sarea->back_handle);
325
fprintf(stderr, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x\n",
326
sarea->depth_offset, sarea->depth_size,
327
(unsigned) sarea->depth_handle);
328
fprintf(stderr, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
329
sarea->tex_offset, sarea->tex_size, (unsigned) sarea->tex_handle);
330
fprintf(stderr, "SAREA: rotation: %d\n", sarea->rotation);
332
"SAREA: rotated offset: 0x%08x size: 0x%x\n",
333
sarea->rotated_offset, sarea->rotated_size);
334
fprintf(stderr, "SAREA: rotated pitch: %d\n", sarea->rotated_pitch);
339
* A number of the screen parameters are obtained/computed from
340
* information in the SAREA. This function updates those parameters.
343
intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
344
drmI830Sarea * sarea)
346
intelScreen->width = sarea->width;
347
intelScreen->height = sarea->height;
349
intelScreen->front.offset = sarea->front_offset;
350
intelScreen->front.pitch = sarea->pitch * intelScreen->cpp;
351
intelScreen->front.handle = sarea->front_handle;
352
intelScreen->front.size = sarea->front_size;
354
intelScreen->back.offset = sarea->back_offset;
355
intelScreen->back.pitch = sarea->pitch * intelScreen->cpp;
356
intelScreen->back.handle = sarea->back_handle;
357
intelScreen->back.size = sarea->back_size;
359
if (intelScreen->driScrnPriv->ddxMinor >= 8) {
360
intelScreen->third.offset = sarea->third_offset;
361
intelScreen->third.pitch = sarea->pitch * intelScreen->cpp;
362
intelScreen->third.handle = sarea->third_handle;
363
intelScreen->third.size = sarea->third_size;
366
intelScreen->depth.offset = sarea->depth_offset;
367
intelScreen->depth.pitch = sarea->pitch * intelScreen->cpp;
368
intelScreen->depth.handle = sarea->depth_handle;
369
intelScreen->depth.size = sarea->depth_size;
371
intelScreen->tex.offset = sarea->tex_offset;
372
intelScreen->logTextureGranularity = sarea->log_tex_granularity;
373
intelScreen->tex.handle = sarea->tex_handle;
374
intelScreen->tex.size = sarea->tex_size;
376
intelScreen->rotated.offset = sarea->rotated_offset;
377
intelScreen->rotated.pitch = sarea->rotated_pitch * intelScreen->cpp;
378
intelScreen->rotated.size = sarea->rotated_size;
379
intelScreen->current_rotation = sarea->rotation;
380
matrix23Rotate(&intelScreen->rotMatrix,
381
sarea->width, sarea->height, sarea->rotation);
382
intelScreen->rotatedWidth = sarea->virtualX;
383
intelScreen->rotatedHeight = sarea->virtualY;
386
intelPrintSAREA(sarea);
390
intelCreatePools(intelScreenPrivate *intelScreen)
392
unsigned batchPoolSize = 1024*1024;
393
__DRIscreenPrivate * sPriv = intelScreen->driScrnPriv;
395
if (intelScreen->havePools)
398
batchPoolSize /= intelScreen->maxBatchSize;
399
intelScreen->regionPool = driDRMPoolInit(sPriv->fd);
401
if (!intelScreen->regionPool)
404
intelScreen->staticPool = driDRMStaticPoolInit(sPriv->fd);
406
if (!intelScreen->staticPool)
409
intelScreen->texPool = intelScreen->regionPool;
411
intelScreen->batchPool = driBatchPoolInit(sPriv->fd,
414
DRM_BO_FLAG_MEM_LOCAL,
415
intelScreen->maxBatchSize,
417
if (!intelScreen->batchPool) {
418
fprintf(stderr, "Failed to initialize batch pool - possible incorrect agpgart installed\n");
422
intel_recreate_static_regions(intelScreen);
423
intelScreen->havePools = GL_TRUE;
430
intelInitDriver(__DRIscreenPrivate * sPriv)
432
intelScreenPrivate *intelScreen;
433
I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv;
436
PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
437
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->
438
getProcAddress("glxEnableExtension"));
439
void *const psc = sPriv->psc->screenConfigs;
441
if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
443
"\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
447
/* Allocate the private area */
448
intelScreen = (intelScreenPrivate *) CALLOC(sizeof(intelScreenPrivate));
450
fprintf(stderr, "\nERROR! Allocating private area failed\n");
453
/* parse information in __driConfigOptions */
454
driParseOptionInfo(&intelScreen->optionCache,
455
__driConfigOptions, __driNConfigOptions);
457
intelScreen->driScrnPriv = sPriv;
458
sPriv->private = (void *) intelScreen;
459
intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
460
sarea = (drmI830Sarea *)
461
(((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset);
463
intelScreen->maxBatchSize = BATCH_SZ;
464
intelScreen->deviceID = gDRIPriv->deviceID;
465
if (intelScreen->deviceID == PCI_CHIP_I865_G)
466
intelScreen->maxBatchSize = 4096;
468
intelScreen->mem = gDRIPriv->mem;
469
intelScreen->cpp = gDRIPriv->cpp;
471
switch (gDRIPriv->bitsPerPixel) {
473
intelScreen->fbFormat = DV_PF_565;
476
intelScreen->fbFormat = DV_PF_8888;
483
intelUpdateScreenFromSAREA(intelScreen, sarea);
485
if (!intelMapScreenRegions(sPriv)) {
486
fprintf(stderr, "\nERROR! mapping regions\n");
487
_mesa_free(intelScreen);
488
sPriv->private = NULL;
495
* FIXME: Remove this code and its references.
498
intelScreen->tex.offset = gDRIPriv->textureOffset;
499
intelScreen->logTextureGranularity = gDRIPriv->logTextureGranularity;
500
intelScreen->tex.handle = gDRIPriv->textures;
501
intelScreen->tex.size = gDRIPriv->textureSize;
504
intelScreen->tex.offset = 0;
505
intelScreen->logTextureGranularity = 0;
506
intelScreen->tex.handle = 0;
507
intelScreen->tex.size = 0;
510
intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
513
intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
515
intelScreen->drmMinor = sPriv->drmMinor;
517
/* Determine if IRQs are active? */
522
gp.param = I830_PARAM_IRQ_ACTIVE;
523
gp.value = &intelScreen->irq_active;
525
ret = drmCommandWriteRead(sPriv->fd, DRM_I830_GETPARAM,
528
fprintf(stderr, "drmI830GetParam: %d\n", ret);
533
/* Determine if batchbuffers are allowed */
538
gp.param = I830_PARAM_ALLOW_BATCHBUFFER;
539
gp.value = &intelScreen->allow_batchbuffer;
541
ret = drmCommandWriteRead(sPriv->fd, DRM_I830_GETPARAM,
544
fprintf(stderr, "drmI830GetParam: (%d) %d\n", gp.param, ret);
549
if (glx_enable_extension != NULL) {
550
(*glx_enable_extension) (psc, "GLX_SGI_swap_control");
551
(*glx_enable_extension) (psc, "GLX_SGI_video_sync");
552
(*glx_enable_extension) (psc, "GLX_MESA_swap_control");
553
(*glx_enable_extension) (psc, "GLX_MESA_swap_frame_usage");
554
(*glx_enable_extension) (psc, "GLX_SGI_make_current_read");
562
intelDestroyScreen(__DRIscreenPrivate * sPriv)
564
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
566
intelUnmapScreenRegions(intelScreen);
568
if (intelScreen->havePools) {
569
driPoolTakeDown(intelScreen->regionPool);
570
driPoolTakeDown(intelScreen->staticPool);
571
driPoolTakeDown(intelScreen->batchPool);
574
sPriv->private = NULL;
579
* This is called when we need to set up GL rendering to a new X window.
582
intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
583
__DRIdrawablePrivate * driDrawPriv,
584
const __GLcontextModes * mesaVis, GLboolean isPixmap)
586
intelScreenPrivate *screen = (intelScreenPrivate *) driScrnPriv->private;
589
return GL_FALSE; /* not implemented */
592
GLboolean swStencil = (mesaVis->stencilBits > 0 &&
593
mesaVis->depthBits != 24);
594
GLenum rgbFormat = (mesaVis->redBits == 5 ? GL_RGB5 : GL_RGBA8);
596
struct intel_framebuffer *intel_fb = CALLOC_STRUCT(intel_framebuffer);
601
_mesa_initialize_framebuffer(&intel_fb->Base, mesaVis);
603
/* setup the hardware-based renderbuffers */
605
intel_fb->color_rb[0]
606
= intel_create_renderbuffer(rgbFormat,
607
screen->width, screen->height,
608
screen->front.offset,
612
intel_set_span_functions(&intel_fb->color_rb[0]->Base);
613
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
614
&intel_fb->color_rb[0]->Base);
617
if (mesaVis->doubleBufferMode) {
618
intel_fb->color_rb[1]
619
= intel_create_renderbuffer(rgbFormat,
620
screen->width, screen->height,
625
intel_set_span_functions(&intel_fb->color_rb[1]->Base);
626
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
627
&intel_fb->color_rb[1]->Base);
629
if (screen->third.handle) {
630
struct gl_renderbuffer *tmp_rb = NULL;
632
intel_fb->color_rb[2]
633
= intel_create_renderbuffer(rgbFormat,
634
screen->width, screen->height,
635
screen->third.offset,
639
intel_set_span_functions(&intel_fb->color_rb[2]->Base);
640
_mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base);
644
if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) {
645
/* combined depth/stencil buffer */
646
struct intel_renderbuffer *depthStencilRb
647
= intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT,
648
screen->width, screen->height,
649
screen->depth.offset,
651
screen->cpp, /* 4! */
653
intel_set_span_functions(&depthStencilRb->Base);
654
/* note: bind RB to two attachment points */
655
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
656
&depthStencilRb->Base);
657
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL,
658
&depthStencilRb->Base);
660
else if (mesaVis->depthBits == 16) {
661
/* just 16-bit depth buffer, no hw stencil */
662
struct intel_renderbuffer *depthRb
663
= intel_create_renderbuffer(GL_DEPTH_COMPONENT16,
664
screen->width, screen->height,
665
screen->depth.offset,
667
screen->cpp, /* 2! */
669
intel_set_span_functions(&depthRb->Base);
670
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
673
/* now add any/all software-based renderbuffers we may need */
674
_mesa_add_soft_renderbuffers(&intel_fb->Base,
675
GL_FALSE, /* never sw color */
676
GL_FALSE, /* never sw depth */
677
swStencil, mesaVis->accumRedBits > 0,
678
GL_FALSE, /* never sw alpha */
679
GL_FALSE /* never sw aux */ );
680
driDrawPriv->driverPrivate = (void *) intel_fb;
687
intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
689
_mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)));
694
* Get information about previous buffer swaps.
697
intelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
699
struct intel_framebuffer *intel_fb;
701
if ((dPriv == NULL) || (dPriv->driverPrivate == NULL)
702
|| (sInfo == NULL)) {
706
intel_fb = dPriv->driverPrivate;
707
sInfo->swap_count = intel_fb->swap_count;
708
sInfo->swap_ust = intel_fb->swap_ust;
709
sInfo->swap_missed_count = intel_fb->swap_missed_count;
711
sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
712
? driCalculateSwapUsage(dPriv, 0, intel_fb->swap_missed_ust)
719
/* There are probably better ways to do this, such as an
720
* init-designated function to register chipids and createcontext
723
extern GLboolean i830CreateContext(const __GLcontextModes * mesaVis,
724
__DRIcontextPrivate * driContextPriv,
725
void *sharedContextPrivate);
727
extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis,
728
__DRIcontextPrivate * driContextPriv,
729
void *sharedContextPrivate);
735
intelCreateContext(const __GLcontextModes * mesaVis,
736
__DRIcontextPrivate * driContextPriv,
737
void *sharedContextPrivate)
739
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
740
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
742
switch (intelScreen->deviceID) {
743
/* Don't deal with i830 until texture work complete:
746
case PCI_CHIP_I830_M:
747
case PCI_CHIP_I855_GM:
748
case PCI_CHIP_I865_G:
749
return i830CreateContext(mesaVis, driContextPriv, sharedContextPrivate);
751
case PCI_CHIP_I915_G:
752
case PCI_CHIP_I915_GM:
753
case PCI_CHIP_I945_G:
754
case PCI_CHIP_I945_GM:
755
case PCI_CHIP_I945_GME:
759
return i915CreateContext(mesaVis, driContextPriv, sharedContextPrivate);
762
fprintf(stderr, "Unrecognized deviceID %x\n", intelScreen->deviceID);
768
static const struct __DriverAPIRec intelAPI = {
769
.InitDriver = intelInitDriver,
770
.DestroyScreen = intelDestroyScreen,
771
.CreateContext = intelCreateContext,
772
.DestroyContext = intelDestroyContext,
773
.CreateBuffer = intelCreateBuffer,
774
.DestroyBuffer = intelDestroyBuffer,
775
.SwapBuffers = intelSwapBuffers,
776
.MakeCurrent = intelMakeCurrent,
777
.UnbindContext = intelUnbindContext,
778
.GetSwapInfo = intelGetSwapInfo,
779
.GetMSC = driGetMSC32,
780
.WaitForMSC = driWaitForMSC32,
782
.SwapBuffersMSC = NULL,
783
.CopySubBuffer = intelCopySubBuffer,
784
.setTexOffset = intelSetTexOffset,
788
static __GLcontextModes *
789
intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
790
unsigned stencil_bits, GLboolean have_back_buffer)
792
__GLcontextModes *modes;
795
unsigned depth_buffer_factor;
796
unsigned back_buffer_factor;
800
/* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
801
* support pageflipping at all.
803
static const GLenum back_buffer_modes[] = {
804
GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
807
u_int8_t depth_bits_array[3];
808
u_int8_t stencil_bits_array[3];
811
depth_bits_array[0] = 0;
812
depth_bits_array[1] = depth_bits;
813
depth_bits_array[2] = depth_bits;
815
/* Just like with the accumulation buffer, always provide some modes
816
* with a stencil buffer. It will be a sw fallback, but some apps won't
819
stencil_bits_array[0] = 0;
820
stencil_bits_array[1] = 0;
821
if (depth_bits == 24)
822
stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
824
stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits;
826
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
827
back_buffer_factor = (have_back_buffer) ? 3 : 1;
829
num_modes = depth_buffer_factor * back_buffer_factor * 4;
831
if (pixel_bits == 16) {
833
fb_type = GL_UNSIGNED_SHORT_5_6_5;
837
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
841
(*dri_interface->createContextModes) (num_modes,
842
sizeof(__GLcontextModes));
844
if (!driFillInModes(&m, fb_format, fb_type,
845
depth_bits_array, stencil_bits_array,
846
depth_buffer_factor, back_buffer_modes,
847
back_buffer_factor, GLX_TRUE_COLOR)) {
848
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
852
if (!driFillInModes(&m, fb_format, fb_type,
853
depth_bits_array, stencil_bits_array,
854
depth_buffer_factor, back_buffer_modes,
855
back_buffer_factor, GLX_DIRECT_COLOR)) {
856
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
861
/* Mark the visual as slow if there are "fake" stencil bits.
863
for (m = modes; m != NULL; m = m->next) {
864
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
865
m->visualRating = GLX_SLOW_CONFIG;
874
* This is the bootstrap function for the driver. libGL supplies all of the
875
* requisite information about the system, and the driver initializes itself.
876
* This routine also fills in the linked list pointed to by \c driver_modes
877
* with the \c __GLcontextModes that the driver can support for windows or
880
* \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
884
__driCreateNewScreen_20050727(__DRInativeDisplay * dpy, int scrn,
886
const __GLcontextModes * modes,
887
const __DRIversion * ddx_version,
888
const __DRIversion * dri_version,
889
const __DRIversion * drm_version,
890
const __DRIframebuffer * frame_buffer,
891
drmAddress pSAREA, int fd,
892
int internal_api_version,
893
const __DRIinterfaceMethods * interface,
894
__GLcontextModes ** driver_modes)
896
__DRIscreenPrivate *psp;
897
static const __DRIversion ddx_expected = { 1, 5, 0 };
898
static const __DRIversion dri_expected = { 4, 0, 0 };
899
static const __DRIversion drm_expected = { 1, 7, 0 };
901
dri_interface = interface;
903
if (!driCheckDriDdxDrmVersions2("i915",
904
dri_version, &dri_expected,
905
ddx_version, &ddx_expected,
906
drm_version, &drm_expected)) {
910
psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
911
ddx_version, dri_version, drm_version,
912
frame_buffer, pSAREA, fd,
913
internal_api_version, &intelAPI);
916
I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
917
*driver_modes = intelFillInModes(dri_priv->cpp * 8,
918
(dri_priv->cpp == 2) ? 16 : 24,
919
(dri_priv->cpp == 2) ? 0 : 8, 1);
921
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
922
* enable the extensions. It just makes sure that all the dispatch offsets for all
923
* the extensions that *might* be enables are known. This is needed because the
924
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
925
* enable the extensions until we have a context pointer.
927
* Hello chicken. Hello egg. How are you two today?
929
driInitExtensions(NULL, card_extensions, GL_FALSE);
935
struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
938
* This should probably change to have the screen allocate a dummy
939
* context at screen creation. For now just use the current context.
942
GET_CURRENT_CONTEXT(ctx);
944
_mesa_problem(NULL, "No current context in intelScreenContext\n");
947
return intel_context(ctx);