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_fbo.h"
42 #include "intel_swapbuffers.h"
43 #include "intel_screen.h"
44 #include "intel_tex.h"
49 #define DRI_CONF_TEXTURE_TILING(def) \
50 DRI_CONF_OPT_BEGIN(texture_tiling, bool, def) \
51 DRI_CONF_DESC(en, "Enable texture tiling") \
54 PUBLIC const char __driConfigOptions[] =
56 DRI_CONF_SECTION_PERFORMANCE
57 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS
)
58 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC
)
59 /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
60 * DRI_CONF_BO_REUSE_ALL
62 DRI_CONF_OPT_BEGIN_V(bo_reuse
, enum, 1, "0:1")
63 DRI_CONF_DESC_BEGIN(en
, "Buffer object reuse")
64 DRI_CONF_ENUM(0, "Disable buffer object reuse")
65 DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
70 DRI_CONF_TEXTURE_TILING(false)
72 DRI_CONF_TEXTURE_TILING(true)
75 DRI_CONF_OPT_BEGIN(early_z
, bool, false)
76 DRI_CONF_DESC(en
, "Enable early Z in classic mode (unstable, 945-only).")
79 DRI_CONF_OPT_BEGIN(fragment_shader
, bool, false)
80 DRI_CONF_DESC(en
, "Enable limited ARB_fragment_shader support on 915/945.")
84 DRI_CONF_SECTION_QUALITY
85 DRI_CONF_FORCE_S3TC_ENABLE(false)
86 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
88 DRI_CONF_SECTION_DEBUG
89 DRI_CONF_NO_RAST(false)
90 DRI_CONF_ALWAYS_FLUSH_BATCH(false)
91 DRI_CONF_ALWAYS_FLUSH_CACHE(false)
93 DRI_CONF_OPT_BEGIN(stub_occlusion_query
, bool, false)
94 DRI_CONF_DESC(en
, "Enable stub ARB_occlusion_query support on 915/945.")
99 const GLuint __driNConfigOptions
= 12;
101 #ifdef USE_NEW_INTERFACE
102 static PFNGLXCREATECONTEXTMODES create_context_modes
= NULL
;
103 #endif /*USE_NEW_INTERFACE */
106 * Map all the memory regions described by the screen.
107 * \return GL_TRUE if success, GL_FALSE if error.
110 intelMapScreenRegions(__DRIscreenPrivate
* sPriv
)
112 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
115 _mesa_printf("TEX 0x%08x ", intelScreen
->tex
.handle
);
116 if (intelScreen
->tex
.size
!= 0) {
117 if (drmMap(sPriv
->fd
,
118 intelScreen
->tex
.handle
,
119 intelScreen
->tex
.size
,
120 (drmAddress
*) & intelScreen
->tex
.map
) != 0) {
121 intelUnmapScreenRegions(intelScreen
);
130 intelUnmapScreenRegions(intelScreenPrivate
* intelScreen
)
132 if (intelScreen
->tex
.map
) {
133 drmUnmap(intelScreen
->tex
.map
, intelScreen
->tex
.size
);
134 intelScreen
->tex
.map
= NULL
;
140 intelPrintDRIInfo(intelScreenPrivate
* intelScreen
,
141 __DRIscreenPrivate
* sPriv
, I830DRIPtr gDRIPriv
)
143 fprintf(stderr
, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
144 intelScreen
->front
.size
, intelScreen
->front
.offset
,
146 fprintf(stderr
, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
147 intelScreen
->back
.size
, intelScreen
->back
.offset
,
149 fprintf(stderr
, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
150 intelScreen
->depth
.size
, intelScreen
->depth
.offset
,
152 fprintf(stderr
, "*** Texture size: 0x%x offset: 0x%x\n",
153 intelScreen
->tex
.size
, intelScreen
->tex
.offset
);
154 fprintf(stderr
, "*** Memory : 0x%x\n", gDRIPriv
->mem
);
159 intelPrintSAREA(const drm_i915_sarea_t
* sarea
)
161 fprintf(stderr
, "SAREA: sarea width %d height %d\n", sarea
->width
,
163 fprintf(stderr
, "SAREA: pitch: %d\n", sarea
->pitch
);
165 "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
166 sarea
->front_offset
, sarea
->front_size
,
167 (unsigned) sarea
->front_handle
, sarea
->front_tiled
);
169 "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
170 sarea
->back_offset
, sarea
->back_size
,
171 (unsigned) sarea
->back_handle
, sarea
->back_tiled
);
172 fprintf(stderr
, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
173 sarea
->depth_offset
, sarea
->depth_size
,
174 (unsigned) sarea
->depth_handle
, sarea
->depth_tiled
);
175 fprintf(stderr
, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
176 sarea
->tex_offset
, sarea
->tex_size
, (unsigned) sarea
->tex_handle
);
181 * A number of the screen parameters are obtained/computed from
182 * information in the SAREA. This function updates those parameters.
185 intelUpdateScreenFromSAREA(intelScreenPrivate
* intelScreen
,
186 drm_i915_sarea_t
* sarea
)
188 intelScreen
->width
= sarea
->width
;
189 intelScreen
->height
= sarea
->height
;
190 intelScreen
->pitch
= sarea
->pitch
;
192 intelScreen
->front
.offset
= sarea
->front_offset
;
193 intelScreen
->front
.handle
= sarea
->front_handle
;
194 intelScreen
->front
.size
= sarea
->front_size
;
195 intelScreen
->front
.tiled
= sarea
->front_tiled
;
197 intelScreen
->back
.offset
= sarea
->back_offset
;
198 intelScreen
->back
.handle
= sarea
->back_handle
;
199 intelScreen
->back
.size
= sarea
->back_size
;
200 intelScreen
->back
.tiled
= sarea
->back_tiled
;
202 intelScreen
->depth
.offset
= sarea
->depth_offset
;
203 intelScreen
->depth
.handle
= sarea
->depth_handle
;
204 intelScreen
->depth
.size
= sarea
->depth_size
;
205 intelScreen
->depth
.tiled
= sarea
->depth_tiled
;
207 if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9) {
208 intelScreen
->front
.bo_handle
= sarea
->front_bo_handle
;
209 intelScreen
->back
.bo_handle
= sarea
->back_bo_handle
;
210 intelScreen
->depth
.bo_handle
= sarea
->depth_bo_handle
;
212 intelScreen
->front
.bo_handle
= -1;
213 intelScreen
->back
.bo_handle
= -1;
214 intelScreen
->depth
.bo_handle
= -1;
217 intelScreen
->tex
.offset
= sarea
->tex_offset
;
218 intelScreen
->logTextureGranularity
= sarea
->log_tex_granularity
;
219 intelScreen
->tex
.handle
= sarea
->tex_handle
;
220 intelScreen
->tex
.size
= sarea
->tex_size
;
223 intelPrintSAREA(sarea
);
226 static const __DRItexOffsetExtension intelTexOffsetExtension
= {
227 { __DRI_TEX_OFFSET
},
231 static const __DRItexBufferExtension intelTexBufferExtension
= {
232 { __DRI_TEX_BUFFER
, __DRI_TEX_BUFFER_VERSION
},
237 static const __DRIextension
*intelScreenExtensions
[] = {
238 &driReadDrawableExtension
,
239 &driCopySubBufferExtension
.base
,
240 &driSwapControlExtension
.base
,
241 &driFrameTrackingExtension
.base
,
242 &driMediaStreamCounterExtension
.base
,
243 &intelTexOffsetExtension
.base
,
244 &intelTexBufferExtension
.base
,
249 intel_get_param(__DRIscreenPrivate
*psp
, int param
, int *value
)
252 struct drm_i915_getparam gp
;
257 ret
= drmCommandWriteRead(psp
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
259 _mesa_warning(NULL
, "drm_i915_getparam: %d", ret
);
266 static GLboolean
intelInitDriver(__DRIscreenPrivate
*sPriv
)
268 intelScreenPrivate
*intelScreen
;
269 I830DRIPtr gDRIPriv
= (I830DRIPtr
) sPriv
->pDevPriv
;
270 drm_i915_sarea_t
*sarea
;
272 if (sPriv
->devPrivSize
!= sizeof(I830DRIRec
)) {
274 "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
278 /* Allocate the private area */
279 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
281 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
284 /* parse information in __driConfigOptions */
285 driParseOptionInfo(&intelScreen
->optionCache
,
286 __driConfigOptions
, __driNConfigOptions
);
288 intelScreen
->driScrnPriv
= sPriv
;
289 sPriv
->private = (void *) intelScreen
;
290 sarea
= (drm_i915_sarea_t
*)
291 (((GLubyte
*) sPriv
->pSAREA
) + gDRIPriv
->sarea_priv_offset
);
292 intelScreen
->sarea
= sarea
;
294 intelScreen
->deviceID
= gDRIPriv
->deviceID
;
296 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
298 if (!intelMapScreenRegions(sPriv
)) {
299 fprintf(stderr
, "\nERROR! mapping regions\n");
300 _mesa_free(intelScreen
);
301 sPriv
->private = NULL
;
306 intelPrintDRIInfo(intelScreen
, sPriv
, gDRIPriv
);
308 intelScreen
->drmMinor
= sPriv
->drm_version
.minor
;
310 /* Determine if IRQs are active? */
311 if (!intel_get_param(sPriv
, I915_PARAM_IRQ_ACTIVE
,
312 &intelScreen
->irq_active
))
315 sPriv
->extensions
= intelScreenExtensions
;
322 intelDestroyScreen(__DRIscreenPrivate
* sPriv
)
324 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
326 dri_bufmgr_destroy(intelScreen
->bufmgr
);
327 intelUnmapScreenRegions(intelScreen
);
328 driDestroyOptionInfo(&intelScreen
->optionCache
);
331 sPriv
->private = NULL
;
336 * This is called when we need to set up GL rendering to a new X window.
339 intelCreateBuffer(__DRIscreenPrivate
* driScrnPriv
,
340 __DRIdrawablePrivate
* driDrawPriv
,
341 const __GLcontextModes
* mesaVis
, GLboolean isPixmap
)
344 return GL_FALSE
; /* not implemented */
347 GLboolean swStencil
= (mesaVis
->stencilBits
> 0 &&
348 mesaVis
->depthBits
!= 24);
351 struct intel_framebuffer
*intel_fb
= CALLOC_STRUCT(intel_framebuffer
);
356 _mesa_initialize_framebuffer(&intel_fb
->Base
, mesaVis
);
358 if (mesaVis
->redBits
== 5)
359 rgbFormat
= MESA_FORMAT_RGB565
;
360 else if (mesaVis
->alphaBits
== 0)
361 rgbFormat
= MESA_FORMAT_XRGB8888
;
363 rgbFormat
= MESA_FORMAT_ARGB8888
;
365 /* setup the hardware-based renderbuffers */
366 intel_fb
->color_rb
[0] = intel_create_renderbuffer(rgbFormat
);
367 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_FRONT_LEFT
,
368 &intel_fb
->color_rb
[0]->Base
);
370 if (mesaVis
->doubleBufferMode
) {
371 intel_fb
->color_rb
[1] = intel_create_renderbuffer(rgbFormat
);
373 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_BACK_LEFT
,
374 &intel_fb
->color_rb
[1]->Base
);
378 if (mesaVis
->depthBits
== 24) {
379 if (mesaVis
->stencilBits
== 8) {
380 /* combined depth/stencil buffer */
381 struct intel_renderbuffer
*depthStencilRb
382 = intel_create_renderbuffer(MESA_FORMAT_S8_Z24
);
383 /* note: bind RB to two attachment points */
384 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
385 &depthStencilRb
->Base
);
386 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
,
387 &depthStencilRb
->Base
);
389 struct intel_renderbuffer
*depthRb
390 = intel_create_renderbuffer(MESA_FORMAT_X8_Z24
);
391 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
,
395 else if (mesaVis
->depthBits
== 16) {
396 /* just 16-bit depth buffer, no hw stencil */
397 struct intel_renderbuffer
*depthRb
398 = intel_create_renderbuffer(MESA_FORMAT_Z16
);
399 _mesa_add_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
, &depthRb
->Base
);
402 /* now add any/all software-based renderbuffers we may need */
403 _mesa_add_soft_renderbuffers(&intel_fb
->Base
,
404 GL_FALSE
, /* never sw color */
405 GL_FALSE
, /* never sw depth */
406 swStencil
, mesaVis
->accumRedBits
> 0,
407 GL_FALSE
, /* never sw alpha */
408 GL_FALSE
/* never sw aux */ );
409 driDrawPriv
->driverPrivate
= (void *) intel_fb
;
416 intelDestroyBuffer(__DRIdrawablePrivate
* driDrawPriv
)
418 struct intel_framebuffer
*intel_fb
= driDrawPriv
->driverPrivate
;
419 struct intel_renderbuffer
*depth_rb
;
420 struct intel_renderbuffer
*stencil_rb
;
423 if (intel_fb
->color_rb
[0]) {
424 intel_renderbuffer_set_region(intel_fb
->color_rb
[0], NULL
);
427 if (intel_fb
->color_rb
[1]) {
428 intel_renderbuffer_set_region(intel_fb
->color_rb
[1], NULL
);
431 depth_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
);
433 intel_renderbuffer_set_region(depth_rb
, NULL
);
436 stencil_rb
= intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
);
438 intel_renderbuffer_set_region(stencil_rb
, NULL
);
442 _mesa_reference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)), NULL
);
447 * Get information about previous buffer swaps.
450 intelGetSwapInfo(__DRIdrawablePrivate
* dPriv
, __DRIswapInfo
* sInfo
)
452 struct intel_framebuffer
*intel_fb
;
454 if ((dPriv
== NULL
) || (dPriv
->driverPrivate
== NULL
)
455 || (sInfo
== NULL
)) {
459 intel_fb
= dPriv
->driverPrivate
;
460 sInfo
->swap_count
= intel_fb
->swap_count
;
461 sInfo
->swap_ust
= intel_fb
->swap_ust
;
462 sInfo
->swap_missed_count
= intel_fb
->swap_missed_count
;
464 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
465 ? driCalculateSwapUsage(dPriv
, 0, intel_fb
->swap_missed_ust
)
472 /* There are probably better ways to do this, such as an
473 * init-designated function to register chipids and createcontext
476 extern GLboolean
i830CreateContext(const __GLcontextModes
* mesaVis
,
477 __DRIcontextPrivate
* driContextPriv
,
478 void *sharedContextPrivate
);
480 extern GLboolean
i915CreateContext(const __GLcontextModes
* mesaVis
,
481 __DRIcontextPrivate
* driContextPriv
,
482 void *sharedContextPrivate
);
483 extern GLboolean
brwCreateContext(const __GLcontextModes
* mesaVis
,
484 __DRIcontextPrivate
* driContextPriv
,
485 void *sharedContextPrivate
);
488 intelCreateContext(const __GLcontextModes
* mesaVis
,
489 __DRIcontextPrivate
* driContextPriv
,
490 void *sharedContextPrivate
)
492 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
493 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
496 if (IS_9XX(intelScreen
->deviceID
)) {
497 if (!IS_965(intelScreen
->deviceID
)) {
498 return i915CreateContext(mesaVis
, driContextPriv
,
499 sharedContextPrivate
);
502 intelScreen
->no_vbo
= GL_TRUE
;
503 return i830CreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
506 if (IS_965(intelScreen
->deviceID
))
507 return brwCreateContext(mesaVis
, driContextPriv
, sharedContextPrivate
);
509 fprintf(stderr
, "Unrecognized deviceID %x\n", intelScreen
->deviceID
);
514 static __DRIconfig
**
515 intelFillInModes(__DRIscreenPrivate
*psp
,
516 unsigned pixel_bits
, unsigned depth_bits
,
517 unsigned stencil_bits
, GLboolean have_back_buffer
)
519 __DRIconfig
**configs
;
521 unsigned depth_buffer_factor
;
522 unsigned back_buffer_factor
;
525 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
526 * support pageflipping at all.
528 static const GLenum back_buffer_modes
[] = {
529 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
532 uint8_t depth_bits_array
[3];
533 uint8_t stencil_bits_array
[3];
534 uint8_t msaa_samples_array
[1];
536 depth_bits_array
[0] = 0;
537 depth_bits_array
[1] = depth_bits
;
538 depth_bits_array
[2] = depth_bits
;
540 /* Just like with the accumulation buffer, always provide some modes
541 * with a stencil buffer. It will be a sw fallback, but some apps won't
544 stencil_bits_array
[0] = 0;
545 stencil_bits_array
[1] = 0;
546 if (depth_bits
== 24)
547 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
549 stencil_bits_array
[2] = (stencil_bits
== 0) ? 8 : stencil_bits
;
551 msaa_samples_array
[0] = 0;
553 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 3 : 1;
554 back_buffer_factor
= (have_back_buffer
) ? 3 : 1;
556 if (pixel_bits
== 16) {
557 configs
= driCreateConfigs(GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
,
558 depth_bits_array
, stencil_bits_array
,
559 depth_buffer_factor
, back_buffer_modes
,
561 msaa_samples_array
, 1);
564 __DRIconfig
**configs_a8r8g8b8
;
565 __DRIconfig
**configs_x8r8g8b8
;
567 configs_a8r8g8b8
= driCreateConfigs(GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
,
573 msaa_samples_array
, 1);
574 configs_x8r8g8b8
= driCreateConfigs(GL_BGR
, GL_UNSIGNED_INT_8_8_8_8_REV
,
580 msaa_samples_array
, 1);
581 configs
= driConcatConfigs(configs_a8r8g8b8
, configs_x8r8g8b8
);
584 if (configs
== NULL
) {
585 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
590 /* Mark the visual as slow if there are "fake" stencil bits.
592 for (i
= 0; configs
[i
]; i
++) {
593 m
= &configs
[i
]->modes
;
594 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
595 m
->visualRating
= GLX_SLOW_CONFIG
;
603 intel_init_bufmgr(intelScreenPrivate
*intelScreen
)
605 GLboolean gem_disable
= getenv("INTEL_NO_GEM") != NULL
;
607 GLboolean gem_supported
;
608 struct drm_i915_getparam gp
;
609 __DRIscreenPrivate
*spriv
= intelScreen
->driScrnPriv
;
612 intelScreen
->no_hw
= getenv("INTEL_NO_HW") != NULL
;
614 gp
.param
= I915_PARAM_HAS_GEM
;
615 gp
.value
= &gem_kernel
;
617 (void) drmCommandWriteRead(spriv
->fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
619 /* If we've got a new enough DDX that's initializing GEM and giving us
620 * object handles for the shared buffers, use that.
622 intelScreen
->ttm
= GL_FALSE
;
623 if (intelScreen
->driScrnPriv
->dri2
.enabled
)
624 gem_supported
= GL_TRUE
;
625 else if (intelScreen
->driScrnPriv
->ddx_version
.minor
>= 9 &&
627 intelScreen
->front
.bo_handle
!= -1)
628 gem_supported
= GL_TRUE
;
630 gem_supported
= GL_FALSE
;
632 if (!gem_disable
&& gem_supported
) {
633 intelScreen
->bufmgr
= intel_bufmgr_gem_init(spriv
->fd
, BATCH_SZ
);
634 if (intelScreen
->bufmgr
!= NULL
)
635 intelScreen
->ttm
= GL_TRUE
;
637 /* Otherwise, use the classic buffer manager. */
638 if (intelScreen
->bufmgr
== NULL
) {
640 _mesa_warning(NULL
, "GEM disabled. Using classic.");
643 "Failed to initialize GEM. Falling back to classic.");
646 if (intelScreen
->tex
.size
== 0) {
647 fprintf(stderr
, "[%s:%u] Error initializing buffer manager.\n",
652 intelScreen
->bufmgr
=
653 intel_bufmgr_fake_init(spriv
->fd
,
654 intelScreen
->tex
.offset
,
655 intelScreen
->tex
.map
,
656 intelScreen
->tex
.size
,
657 (unsigned int * volatile)
658 &intelScreen
->sarea
->last_dispatch
);
661 if (intel_get_param(spriv
, I915_PARAM_NUM_FENCES_AVAIL
, &num_fences
))
662 intelScreen
->kernel_exec_fencing
= !!num_fences
;
664 intelScreen
->kernel_exec_fencing
= GL_FALSE
;
670 * This is the driver specific part of the createNewScreen entry point.
671 * Called when using legacy DRI.
673 * \todo maybe fold this into intelInitDriver
675 * \return the __GLcontextModes supported by this driver
677 static const __DRIconfig
**intelInitScreen(__DRIscreenPrivate
*psp
)
679 intelScreenPrivate
*intelScreen
;
681 static const __DRIversion ddx_expected
= { 1, 5, 0 };
683 static const __DRIversion ddx_expected
= { 1, 6, 0 };
685 static const __DRIversion dri_expected
= { 4, 0, 0 };
686 static const __DRIversion drm_expected
= { 1, 5, 0 };
687 I830DRIPtr dri_priv
= (I830DRIPtr
) psp
->pDevPriv
;
689 if (!driCheckDriDdxDrmVersions2("i915",
690 &psp
->dri_version
, &dri_expected
,
691 &psp
->ddx_version
, &ddx_expected
,
692 &psp
->drm_version
, &drm_expected
)) {
696 if (!intelInitDriver(psp
))
699 psp
->extensions
= intelScreenExtensions
;
701 intelScreen
= psp
->private;
702 if (!intel_init_bufmgr(intelScreen
))
705 return (const __DRIconfig
**)
706 intelFillInModes(psp
, dri_priv
->cpp
* 8,
707 (dri_priv
->cpp
== 2) ? 16 : 24,
708 (dri_priv
->cpp
== 2) ? 0 : 8, 1);
711 struct intel_context
*intelScreenContext(intelScreenPrivate
*intelScreen
)
714 * This should probably change to have the screen allocate a dummy
715 * context at screen creation. For now just use the current context.
718 GET_CURRENT_CONTEXT(ctx
);
720 _mesa_problem(NULL
, "No current context in intelScreenContext\n");
723 return intel_context(ctx
);
727 * This is the driver specific part of the createNewScreen entry point.
728 * Called when using DRI2.
730 * \return the __GLcontextModes supported by this driver
733 __DRIconfig
**intelInitScreen2(__DRIscreenPrivate
*psp
)
735 intelScreenPrivate
*intelScreen
;
738 /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
739 * support pageflipping at all.
741 static const GLenum back_buffer_modes
[] = {
742 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
, GLX_SWAP_COPY_OML
744 uint8_t depth_bits
[4], stencil_bits
[4], msaa_samples_array
[1];
746 __DRIconfig
**configs
= NULL
;
748 /* Allocate the private area */
749 intelScreen
= (intelScreenPrivate
*) CALLOC(sizeof(intelScreenPrivate
));
751 fprintf(stderr
, "\nERROR! Allocating private area failed\n");
754 /* parse information in __driConfigOptions */
755 driParseOptionInfo(&intelScreen
->optionCache
,
756 __driConfigOptions
, __driNConfigOptions
);
758 intelScreen
->driScrnPriv
= psp
;
759 psp
->private = (void *) intelScreen
;
761 intelScreen
->drmMinor
= psp
->drm_version
.minor
;
763 /* Determine chipset ID */
764 if (!intel_get_param(psp
, I915_PARAM_CHIPSET_ID
,
765 &intelScreen
->deviceID
))
768 if (!intel_init_bufmgr(intelScreen
))
771 intelScreen
->irq_active
= 1;
772 psp
->extensions
= intelScreenExtensions
;
783 msaa_samples_array
[0] = 0;
785 fb_format
[0] = GL_RGB
;
786 fb_type
[0] = GL_UNSIGNED_SHORT_5_6_5
;
788 fb_format
[1] = GL_BGR
;
789 fb_type
[1] = GL_UNSIGNED_INT_8_8_8_8_REV
;
791 fb_format
[2] = GL_BGRA
;
792 fb_type
[2] = GL_UNSIGNED_INT_8_8_8_8_REV
;
797 for (color
= 0; color
< ARRAY_SIZE(fb_format
); color
++) {
798 __DRIconfig
**new_configs
;
801 /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer
802 * with the same cpp as the drawable. So we can't support depth cpp !=
803 * color cpp currently.
805 if (fb_type
[color
] == GL_UNSIGNED_SHORT_5_6_5
) {
818 new_configs
= driCreateConfigs(fb_format
[color
], fb_type
[color
],
823 ARRAY_SIZE(back_buffer_modes
),
825 ARRAY_SIZE(msaa_samples_array
));
827 configs
= new_configs
;
829 configs
= driConcatConfigs(configs
, new_configs
);
832 if (configs
== NULL
) {
833 fprintf(stderr
, "[%s:%u] Error creating FBConfig!\n", __func__
,
838 return (const __DRIconfig
**)configs
;
841 const struct __DriverAPIRec driDriverAPI
= {
842 .InitScreen
= intelInitScreen
,
843 .DestroyScreen
= intelDestroyScreen
,
844 .CreateContext
= intelCreateContext
,
845 .DestroyContext
= intelDestroyContext
,
846 .CreateBuffer
= intelCreateBuffer
,
847 .DestroyBuffer
= intelDestroyBuffer
,
848 .SwapBuffers
= intelSwapBuffers
,
849 .MakeCurrent
= intelMakeCurrent
,
850 .UnbindContext
= intelUnbindContext
,
851 .GetSwapInfo
= intelGetSwapInfo
,
852 .GetDrawableMSC
= driDrawableGetMSC32
,
853 .WaitForMSC
= driWaitForMSC32
,
854 .CopySubBuffer
= intelCopySubBuffer
,
856 .InitScreen2
= intelInitScreen2
,