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 **************************************************************************/
29 #include "main/glheader.h"
30 #include "main/context.h"
31 #include "main/extensions.h"
32 #include "main/fbobject.h"
33 #include "main/framebuffer.h"
34 #include "main/imports.h"
35 #include "main/points.h"
37 #include "swrast/swrast.h"
38 #include "swrast_setup/swrast_setup.h"
40 #include "drivers/common/driverfuncs.h"
41 #include "drivers/common/meta.h"
43 #include "intel_chipset.h"
44 #include "intel_buffers.h"
45 #include "intel_tex.h"
46 #include "intel_batchbuffer.h"
47 #include "intel_clear.h"
48 #include "intel_extensions.h"
49 #include "intel_pixel.h"
50 #include "intel_regions.h"
51 #include "intel_buffer_objects.h"
52 #include "intel_fbo.h"
53 #include "intel_bufmgr.h"
54 #include "intel_screen.h"
56 #include "drirenderbuffer.h"
61 int INTEL_DEBUG = (0);
65 #define DRIVER_DATE "20100330 DEVELOPMENT"
66 #define DRIVER_DATE_GEM "GEM " DRIVER_DATE
69 static const GLubyte *
70 intelGetString(GLcontext * ctx, GLenum name)
72 const struct intel_context *const intel = intel_context(ctx);
74 static char buffer[128];
78 return (GLubyte *) "Tungsten Graphics, Inc";
82 switch (intel->intelScreen->deviceID) {
84 chipset = "Intel(R) 845G";
87 chipset = "Intel(R) 830M";
89 case PCI_CHIP_I855_GM:
90 chipset = "Intel(R) 852GM/855GM";
93 chipset = "Intel(R) 865G";
96 chipset = "Intel(R) 915G";
98 case PCI_CHIP_E7221_G:
99 chipset = "Intel (R) E7221G (i915)";
101 case PCI_CHIP_I915_GM:
102 chipset = "Intel(R) 915GM";
104 case PCI_CHIP_I945_G:
105 chipset = "Intel(R) 945G";
107 case PCI_CHIP_I945_GM:
108 chipset = "Intel(R) 945GM";
110 case PCI_CHIP_I945_GME:
111 chipset = "Intel(R) 945GME";
114 chipset = "Intel(R) G33";
117 chipset = "Intel(R) Q35";
120 chipset = "Intel(R) Q33";
122 case PCI_CHIP_IGD_GM:
124 chipset = "Intel(R) IGD";
126 case PCI_CHIP_I965_Q:
127 chipset = "Intel(R) 965Q";
129 case PCI_CHIP_I965_G:
130 case PCI_CHIP_I965_G_1:
131 chipset = "Intel(R) 965G";
133 case PCI_CHIP_I946_GZ:
134 chipset = "Intel(R) 946GZ";
136 case PCI_CHIP_I965_GM:
137 chipset = "Intel(R) 965GM";
139 case PCI_CHIP_I965_GME:
140 chipset = "Intel(R) 965GME/GLE";
142 case PCI_CHIP_GM45_GM:
143 chipset = "Mobile IntelĀ® GM45 Express Chipset";
145 case PCI_CHIP_IGD_E_G:
146 chipset = "Intel(R) Integrated Graphics Device";
149 chipset = "Intel(R) G45/G43";
152 chipset = "Intel(R) Q45/Q43";
155 chipset = "Intel(R) G41";
158 chipset = "Intel(R) B43";
161 chipset = "Intel(R) Ironlake Desktop";
164 chipset = "Intel(R) Ironlake Mobile";
167 chipset = "Unknown Intel Chipset";
171 (void) driGetRendererString(buffer, chipset, DRIVER_DATE_GEM, 0);
172 return (GLubyte *) buffer;
180 intel_flush_front(GLcontext *ctx)
182 struct intel_context *intel = intel_context(ctx);
183 __DRIcontext *driContext = intel->driContext;
184 __DRIscreen *const screen = intel->intelScreen->driScrnPriv;
186 if ((ctx->DrawBuffer->Name == 0) && intel->front_buffer_dirty) {
187 if (screen->dri2.loader &&
188 (screen->dri2.loader->base.version >= 2)
189 && (screen->dri2.loader->flushFrontBuffer != NULL) &&
190 driContext->driDrawablePriv &&
191 driContext->driDrawablePriv->loaderPrivate) {
192 (*screen->dri2.loader->flushFrontBuffer)(driContext->driDrawablePriv,
193 driContext->driDrawablePriv->loaderPrivate);
195 /* We set the dirty bit in intel_prepare_render() if we're
196 * front buffer rendering once we get there.
198 intel->front_buffer_dirty = GL_FALSE;
204 intel_bits_per_pixel(const struct intel_renderbuffer *rb)
206 return _mesa_get_format_bytes(rb->Base.Format) * 8;
210 intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
212 struct gl_framebuffer *fb = drawable->driverPrivate;
213 struct intel_renderbuffer *rb;
214 struct intel_region *region, *depth_region;
215 struct intel_context *intel = context->driverPrivate;
216 struct intel_renderbuffer *front_rb, *back_rb, *depth_rb, *stencil_rb;
217 __DRIbuffer *buffers = NULL;
220 unsigned int attachments[10];
221 const char *region_name;
223 /* If we're rendering to the fake front buffer, make sure all the
224 * pending drawing has landed on the real front buffer. Otherwise
225 * when we eventually get to DRI2GetBuffersWithFormat the stale
226 * real front buffer contents will get copied to the new fake front
229 if (intel->is_front_buffer_rendering) {
230 intel_flush(&intel->ctx);
231 intel_flush_front(&intel->ctx);
234 /* Set this up front, so that in case our buffers get invalidated
235 * while we're getting new buffers, we don't clobber the stamp and
236 * thus ignore the invalidate. */
237 drawable->lastStamp = drawable->dri2.stamp;
239 if (INTEL_DEBUG & DEBUG_DRI)
240 fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
242 screen = intel->intelScreen->driScrnPriv;
244 if (screen->dri2.loader
245 && (screen->dri2.loader->base.version > 2)
246 && (screen->dri2.loader->getBuffersWithFormat != NULL)) {
248 front_rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
249 back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
250 depth_rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
251 stencil_rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
254 if ((intel->is_front_buffer_rendering ||
255 intel->is_front_buffer_reading ||
256 !back_rb) && front_rb) {
257 attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
258 attachments[i++] = intel_bits_per_pixel(front_rb);
262 attachments[i++] = __DRI_BUFFER_BACK_LEFT;
263 attachments[i++] = intel_bits_per_pixel(back_rb);
266 if ((depth_rb != NULL) && (stencil_rb != NULL)) {
267 attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
268 attachments[i++] = intel_bits_per_pixel(depth_rb);
269 } else if (depth_rb != NULL) {
270 attachments[i++] = __DRI_BUFFER_DEPTH;
271 attachments[i++] = intel_bits_per_pixel(depth_rb);
272 } else if (stencil_rb != NULL) {
273 attachments[i++] = __DRI_BUFFER_STENCIL;
274 attachments[i++] = intel_bits_per_pixel(stencil_rb);
278 (*screen->dri2.loader->getBuffersWithFormat)(drawable,
283 drawable->loaderPrivate);
284 } else if (screen->dri2.loader) {
286 if (intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT))
287 attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
288 if (intel_get_renderbuffer(fb, BUFFER_BACK_LEFT))
289 attachments[i++] = __DRI_BUFFER_BACK_LEFT;
290 if (intel_get_renderbuffer(fb, BUFFER_DEPTH))
291 attachments[i++] = __DRI_BUFFER_DEPTH;
292 if (intel_get_renderbuffer(fb, BUFFER_STENCIL))
293 attachments[i++] = __DRI_BUFFER_STENCIL;
295 buffers = (*screen->dri2.loader->getBuffers)(drawable,
300 drawable->loaderPrivate);
310 drawable->numClipRects = 1;
311 drawable->pClipRects[0].x1 = 0;
312 drawable->pClipRects[0].y1 = 0;
313 drawable->pClipRects[0].x2 = drawable->w;
314 drawable->pClipRects[0].y2 = drawable->h;
315 drawable->numBackClipRects = 1;
316 drawable->pBackClipRects[0].x1 = 0;
317 drawable->pBackClipRects[0].y1 = 0;
318 drawable->pBackClipRects[0].x2 = drawable->w;
319 drawable->pBackClipRects[0].y2 = drawable->h;
322 for (i = 0; i < count; i++) {
323 switch (buffers[i].attachment) {
324 case __DRI_BUFFER_FRONT_LEFT:
325 rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
326 region_name = "dri2 front buffer";
329 case __DRI_BUFFER_FAKE_FRONT_LEFT:
330 rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
331 region_name = "dri2 fake front buffer";
334 case __DRI_BUFFER_BACK_LEFT:
335 rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
336 region_name = "dri2 back buffer";
339 case __DRI_BUFFER_DEPTH:
340 rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
341 region_name = "dri2 depth buffer";
344 case __DRI_BUFFER_DEPTH_STENCIL:
345 rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
346 region_name = "dri2 depth / stencil buffer";
349 case __DRI_BUFFER_STENCIL:
350 rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
351 region_name = "dri2 stencil buffer";
354 case __DRI_BUFFER_ACCUM:
357 "unhandled buffer attach event, attacment type %d\n",
358 buffers[i].attachment);
365 if (rb->region && rb->region->name == buffers[i].name)
368 if (INTEL_DEBUG & DEBUG_DRI)
370 "attaching buffer %d, at %d, cpp %d, pitch %d\n",
371 buffers[i].name, buffers[i].attachment,
372 buffers[i].cpp, buffers[i].pitch);
374 if (buffers[i].attachment == __DRI_BUFFER_STENCIL && depth_region) {
375 if (INTEL_DEBUG & DEBUG_DRI)
376 fprintf(stderr, "(reusing depth buffer as stencil)\n");
377 intel_region_reference(®ion, depth_region);
380 region = intel_region_alloc_for_handle(intel->intelScreen,
384 buffers[i].pitch / buffers[i].cpp,
388 if (buffers[i].attachment == __DRI_BUFFER_DEPTH)
389 depth_region = region;
391 intel_renderbuffer_set_region(intel, rb, region);
392 intel_region_release(®ion);
394 if (buffers[i].attachment == __DRI_BUFFER_DEPTH_STENCIL) {
395 rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
397 struct intel_region *stencil_region = NULL;
399 if (rb->region && rb->region->name == buffers[i].name)
402 intel_region_reference(&stencil_region, region);
403 intel_renderbuffer_set_region(intel, rb, stencil_region);
404 intel_region_release(&stencil_region);
409 driUpdateFramebufferSize(&intel->ctx, drawable);
413 * intel_prepare_render should be called anywhere that curent read/drawbuffer
417 intel_prepare_render(struct intel_context *intel)
419 __DRIcontext *driContext = intel->driContext;
420 __DRIdrawable *drawable;
422 drawable = driContext->driDrawablePriv;
423 if (drawable && drawable->dri2.stamp != driContext->dri2.draw_stamp) {
424 if (drawable->lastStamp != drawable->dri2.stamp)
425 intel_update_renderbuffers(driContext, drawable);
426 intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
427 driContext->dri2.draw_stamp = drawable->dri2.stamp;
430 drawable = driContext->driReadablePriv;
431 if (drawable && drawable->dri2.stamp != driContext->dri2.read_stamp) {
432 if (drawable->lastStamp != drawable->dri2.stamp)
433 intel_update_renderbuffers(driContext, drawable);
434 driContext->dri2.read_stamp = drawable->dri2.stamp;
437 /* If we're currently rendering to the front buffer, the rendering
438 * that will happen next will probably dirty the front buffer. So
439 * mark it as dirty here.
441 if (intel->is_front_buffer_rendering)
442 intel->front_buffer_dirty = GL_TRUE;
444 /* Wait for the swapbuffers before the one we just emitted, so we
445 * don't get too many swaps outstanding for apps that are GPU-heavy
448 * We're using intelDRI2Flush (called from the loader before
449 * swapbuffer) and glFlush (for front buffer rendering) as the
450 * indicator that a frame is done and then throttle when we get
451 * here as we prepare to render the next frame. At this point for
452 * round trips for swap/copy and getting new buffers are done and
453 * we'll spend less time waiting on the GPU.
455 * Unfortunately, we don't have a handle to the batch containing
456 * the swap, and getting our hands on that doesn't seem worth it,
457 * so we just us the first batch we emitted after the last swap.
459 if (intel->need_throttle && intel->first_post_swapbuffers_batch) {
460 drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch);
461 drm_intel_bo_unreference(intel->first_post_swapbuffers_batch);
462 intel->first_post_swapbuffers_batch = NULL;
463 intel->need_throttle = GL_FALSE;
468 intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
470 struct intel_context *intel = intel_context(ctx);
471 __DRIcontext *driContext = intel->driContext;
473 if (intel->saved_viewport)
474 intel->saved_viewport(ctx, x, y, w, h);
476 if (!intel->meta.internal_viewport_call && ctx->DrawBuffer->Name == 0) {
477 dri2InvalidateDrawable(driContext->driDrawablePriv);
478 dri2InvalidateDrawable(driContext->driReadablePriv);
482 static const struct dri_debug_control debug_control[] = {
483 { "tex", DEBUG_TEXTURE},
484 { "state", DEBUG_STATE},
485 { "ioctl", DEBUG_IOCTL},
486 { "blit", DEBUG_BLIT},
487 { "mip", DEBUG_MIPTREE},
488 { "fall", DEBUG_FALLBACKS},
489 { "verb", DEBUG_VERBOSE},
490 { "bat", DEBUG_BATCH},
491 { "pix", DEBUG_PIXEL},
492 { "buf", DEBUG_BUFMGR},
493 { "reg", DEBUG_REGION},
496 { "sync", DEBUG_SYNC},
497 { "prim", DEBUG_PRIMS },
498 { "vert", DEBUG_VERTS },
499 { "dri", DEBUG_DRI },
501 { "san", DEBUG_SANITY },
502 { "sleep", DEBUG_SLEEP },
503 { "stats", DEBUG_STATS },
504 { "tile", DEBUG_TILE },
505 { "sing", DEBUG_SINGLE_THREAD },
506 { "thre", DEBUG_SINGLE_THREAD },
508 { "glsl_force", DEBUG_GLSL_FORCE },
509 { "urb", DEBUG_URB },
511 { "clip", DEBUG_CLIP },
517 intelInvalidateState(GLcontext * ctx, GLuint new_state)
519 struct intel_context *intel = intel_context(ctx);
521 _swrast_InvalidateState(ctx, new_state);
522 _swsetup_InvalidateState(ctx, new_state);
523 _vbo_InvalidateState(ctx, new_state);
524 _tnl_InvalidateState(ctx, new_state);
525 _tnl_invalidate_vertex_state(ctx, new_state);
527 intel->NewGLState |= new_state;
529 if (intel->vtbl.invalidate_state)
530 intel->vtbl.invalidate_state( intel, new_state );
534 intel_flush(GLcontext *ctx)
536 struct intel_context *intel = intel_context(ctx);
542 INTEL_FIREVERTICES(intel);
544 if (intel->batch->map != intel->batch->ptr)
545 intel_batchbuffer_flush(intel->batch);
549 intel_glFlush(GLcontext *ctx)
551 struct intel_context *intel = intel_context(ctx);
554 intel_flush_front(ctx);
555 intel->need_throttle = GL_TRUE;
559 intelFinish(GLcontext * ctx)
561 struct gl_framebuffer *fb = ctx->DrawBuffer;
565 intel_flush_front(ctx);
567 for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
568 struct intel_renderbuffer *irb;
570 irb = intel_renderbuffer(fb->_ColorDrawBuffers[i]);
572 if (irb && irb->region)
573 drm_intel_bo_wait_rendering(irb->region->buffer);
575 if (fb->_DepthBuffer) {
576 /* XXX: Wait on buffer idle */
581 intelInitDriverFunctions(struct dd_function_table *functions)
583 _mesa_init_driver_functions(functions);
585 functions->Flush = intel_glFlush;
586 functions->Finish = intelFinish;
587 functions->GetString = intelGetString;
588 functions->UpdateState = intelInvalidateState;
590 intelInitTextureFuncs(functions);
591 intelInitTextureImageFuncs(functions);
592 intelInitTextureSubImageFuncs(functions);
593 intelInitTextureCopyImageFuncs(functions);
594 intelInitStateFuncs(functions);
595 intelInitClearFuncs(functions);
596 intelInitBufferFuncs(functions);
597 intelInitPixelFuncs(functions);
598 intelInitBufferObjectFuncs(functions);
599 intel_init_syncobj_functions(functions);
604 intelInitContext(struct intel_context *intel,
606 const __GLcontextModes * mesaVis,
607 __DRIcontext * driContextPriv,
608 void *sharedContextPrivate,
609 struct dd_function_table *functions)
611 GLcontext *ctx = &intel->ctx;
612 GLcontext *shareCtx = (GLcontext *) sharedContextPrivate;
613 __DRIscreen *sPriv = driContextPriv->driScreenPriv;
614 struct intel_screen *intelScreen = sPriv->private;
616 __GLcontextModes visual;
618 /* we can't do anything without a connection to the device */
619 if (intelScreen->bufmgr == NULL)
622 /* Can't rely on invalidate events, fall back to glViewport hack */
623 if (!driContextPriv->driScreenPriv->dri2.useInvalidate) {
624 intel->saved_viewport = functions->Viewport;
625 functions->Viewport = intel_viewport;
628 if (mesaVis == NULL) {
629 memset(&visual, 0, sizeof visual);
633 if (!_mesa_initialize_context_for_api(&intel->ctx, api, mesaVis, shareCtx,
634 functions, (void *) intel)) {
635 printf("%s: failed to init mesa context\n", __FUNCTION__);
639 driContextPriv->driverPrivate = intel;
640 intel->intelScreen = intelScreen;
641 intel->driContext = driContextPriv;
642 intel->driFd = sPriv->fd;
644 intel->has_xrgb_textures = GL_TRUE;
645 if (IS_GEN6(intel->intelScreen->deviceID)) {
647 intel->needs_ff_sync = GL_TRUE;
648 intel->has_luminance_srgb = GL_TRUE;
649 } else if (IS_GEN5(intel->intelScreen->deviceID)) {
651 intel->needs_ff_sync = GL_TRUE;
652 intel->has_luminance_srgb = GL_TRUE;
653 } else if (IS_965(intel->intelScreen->deviceID)) {
655 if (IS_G4X(intel->intelScreen->deviceID)) {
656 intel->has_luminance_srgb = GL_TRUE;
657 intel->is_g4x = GL_TRUE;
659 } else if (IS_9XX(intel->intelScreen->deviceID)) {
661 if (IS_945(intel->intelScreen->deviceID)) {
662 intel->is_945 = GL_TRUE;
666 if (intel->intelScreen->deviceID == PCI_CHIP_I830_M ||
667 intel->intelScreen->deviceID == PCI_CHIP_845_G) {
668 intel->has_xrgb_textures = GL_FALSE;
672 driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
673 sPriv->myNum, (intel->gen >= 4) ? "i965" : "i915");
674 if (intelScreen->deviceID == PCI_CHIP_I865_G)
675 intel->maxBatchSize = 4096;
677 intel->maxBatchSize = BATCH_SZ;
679 intel->bufmgr = intelScreen->bufmgr;
681 bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
682 switch (bo_reuse_mode) {
683 case DRI_CONF_BO_REUSE_DISABLED:
685 case DRI_CONF_BO_REUSE_ALL:
686 intel_bufmgr_gem_enable_reuse(intel->bufmgr);
690 /* This doesn't yet catch all non-conformant rendering, but it's a
693 if (getenv("INTEL_STRICT_CONFORMANCE")) {
694 unsigned int value = atoi(getenv("INTEL_STRICT_CONFORMANCE"));
696 intel->conformance_mode = value;
699 intel->conformance_mode = 1;
703 if (intel->conformance_mode > 0) {
704 ctx->Const.MinLineWidth = 1.0;
705 ctx->Const.MinLineWidthAA = 1.0;
706 ctx->Const.MaxLineWidth = 1.0;
707 ctx->Const.MaxLineWidthAA = 1.0;
708 ctx->Const.LineWidthGranularity = 1.0;
711 ctx->Const.MinLineWidth = 1.0;
712 ctx->Const.MinLineWidthAA = 1.0;
713 ctx->Const.MaxLineWidth = 5.0;
714 ctx->Const.MaxLineWidthAA = 5.0;
715 ctx->Const.LineWidthGranularity = 0.5;
718 ctx->Const.MinPointSize = 1.0;
719 ctx->Const.MinPointSizeAA = 1.0;
720 ctx->Const.MaxPointSize = 255.0;
721 ctx->Const.MaxPointSizeAA = 3.0;
722 ctx->Const.PointSizeGranularity = 1.0;
724 ctx->Const.MaxSamples = 1.0;
726 /* reinitialize the context point state.
727 * It depend on constants in __GLcontextRec::Const
729 _mesa_init_point(ctx);
731 meta_init_metaops(ctx, &intel->meta);
732 if (intel->gen >= 4) {
733 if (MAX_WIDTH > 8192)
734 ctx->Const.MaxRenderbufferSize = 8192;
736 if (MAX_WIDTH > 2048)
737 ctx->Const.MaxRenderbufferSize = 2048;
740 /* Initialize the software rasterizer and helper modules. */
741 _swrast_CreateContext(ctx);
742 _vbo_CreateContext(ctx);
743 _tnl_CreateContext(ctx);
744 _swsetup_CreateContext(ctx);
746 /* Configure swrast to match hardware characteristics: */
747 _swrast_allow_pixel_fog(ctx, GL_FALSE);
748 _swrast_allow_vertex_fog(ctx, GL_TRUE);
750 _mesa_meta_init(ctx);
752 intel->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
753 intel->hw_stipple = 1;
755 /* XXX FBO: this doesn't seem to be used anywhere */
756 switch (mesaVis->depthBits) {
757 case 0: /* what to do in this case? */
759 intel->polygon_offset_scale = 1.0;
762 intel->polygon_offset_scale = 2.0; /* req'd to pass glean */
770 intel->polygon_offset_scale /= 0xffff;
772 intel->RenderIndex = ~0;
776 intelInitExtensions(ctx);
781 intelInitExtensionsES2(ctx);
785 INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
786 if (INTEL_DEBUG & DEBUG_BUFMGR)
787 dri_bufmgr_set_debug(intel->bufmgr, GL_TRUE);
789 intel->batch = intel_batchbuffer_alloc(intel);
791 intel_fbo_init(intel);
793 if (intel->ctx.Mesa_DXTn) {
794 _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
795 _mesa_enable_extension(ctx, "GL_S3_s3tc");
797 else if (driQueryOptionb(&intel->optionCache, "force_s3tc_enable")) {
798 _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
800 intel->use_texture_tiling = driQueryOptionb(&intel->optionCache,
802 intel->use_early_z = driQueryOptionb(&intel->optionCache, "early_z");
804 intel->prim.primitive = ~0;
806 /* Force all software fallbacks */
807 if (driQueryOptionb(&intel->optionCache, "no_rast")) {
808 fprintf(stderr, "disabling 3D rasterization\n");
812 if (driQueryOptionb(&intel->optionCache, "always_flush_batch")) {
813 fprintf(stderr, "flushing batchbuffer before/after each draw call\n");
814 intel->always_flush_batch = 1;
817 if (driQueryOptionb(&intel->optionCache, "always_flush_cache")) {
818 fprintf(stderr, "flushing GPU caches before/after each draw call\n");
819 intel->always_flush_cache = 1;
822 /* Disable all hardware rendering (skip emitting batches and fences/waits
825 intel->no_hw = getenv("INTEL_NO_HW") != NULL;
831 intelDestroyContext(__DRIcontext * driContextPriv)
833 struct intel_context *intel =
834 (struct intel_context *) driContextPriv->driverPrivate;
836 assert(intel); /* should never be null */
838 INTEL_FIREVERTICES(intel);
840 _mesa_meta_free(&intel->ctx);
842 meta_destroy_metaops(&intel->meta);
844 intel->vtbl.destroy(intel);
846 _swsetup_DestroyContext(&intel->ctx);
847 _tnl_DestroyContext(&intel->ctx);
848 _vbo_DestroyContext(&intel->ctx);
850 _swrast_DestroyContext(&intel->ctx);
851 intel->Fallback = 0x0; /* don't call _swrast_Flush later */
853 intel_batchbuffer_free(intel->batch);
856 free(intel->prim.vb);
857 intel->prim.vb = NULL;
858 drm_intel_bo_unreference(intel->prim.vb_bo);
859 intel->prim.vb_bo = NULL;
860 drm_intel_bo_unreference(intel->first_post_swapbuffers_batch);
861 intel->first_post_swapbuffers_batch = NULL;
863 driDestroyOptionCache(&intel->optionCache);
865 /* free the Mesa context */
866 _mesa_free_context_data(&intel->ctx);
869 driContextPriv->driverPrivate = NULL;
874 intelUnbindContext(__DRIcontext * driContextPriv)
876 /* Unset current context and dispath table */
877 _mesa_make_current(NULL, NULL, NULL);
883 intelMakeCurrent(__DRIcontext * driContextPriv,
884 __DRIdrawable * driDrawPriv,
885 __DRIdrawable * driReadPriv)
887 struct intel_context *intel;
888 GET_CURRENT_CONTEXT(curCtx);
891 intel = (struct intel_context *) driContextPriv->driverPrivate;
895 /* According to the glXMakeCurrent() man page: "Pending commands to
896 * the previous context, if any, are flushed before it is released."
897 * But only flush if we're actually changing contexts.
899 if (intel_context(curCtx) && intel_context(curCtx) != intel) {
903 if (driContextPriv) {
904 struct gl_framebuffer *fb, *readFb;
906 if (driDrawPriv == NULL && driReadPriv == NULL) {
907 fb = _mesa_get_incomplete_framebuffer();
908 readFb = _mesa_get_incomplete_framebuffer();
910 fb = driDrawPriv->driverPrivate;
911 readFb = driReadPriv->driverPrivate;
912 driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1;
913 driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
916 intel_prepare_render(intel);
917 _mesa_make_current(&intel->ctx, fb, readFb);
919 /* We do this in intel_prepare_render() too, but intel->ctx.DrawBuffer
920 * is NULL at that point. We can't call _mesa_makecurrent()
921 * first, since we need the buffer size for the initial
922 * viewport. So just call intel_draw_buffer() again here. */
923 intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
926 _mesa_make_current(NULL, NULL, NULL);