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 **************************************************************************/
32 #include "simple_list.h"
33 #include "extensions.h"
34 #include "framebuffer.h"
38 #include "swrast/swrast.h"
39 #include "swrast_setup/swrast_setup.h"
42 #include "tnl/t_pipeline.h"
43 #include "tnl/t_vertex.h"
45 #include "drivers/common/driverfuncs.h"
47 #include "intel_screen.h"
51 #include "intel_buffers.h"
52 #include "intel_tex.h"
53 #include "intel_span.h"
54 #include "intel_tris.h"
55 #include "intel_ioctl.h"
56 #include "intel_batchbuffer.h"
57 #include "intel_blit.h"
58 #include "intel_pixel.h"
59 #include "intel_regions.h"
60 #include "intel_buffer_objects.h"
61 #include "intel_fbo.h"
63 #include "drirenderbuffer.h"
66 #include "xmlpool.h" /* for symbolic values of enum-type options */
68 int INTEL_DEBUG
= (0);
71 #define need_GL_ARB_multisample
72 #define need_GL_ARB_point_parameters
73 #define need_GL_ARB_texture_compression
74 #define need_GL_ARB_vertex_buffer_object
75 #define need_GL_ARB_vertex_program
76 #define need_GL_ARB_window_pos
77 #define need_GL_EXT_blend_color
78 #define need_GL_EXT_blend_equation_separate
79 #define need_GL_EXT_blend_func_separate
80 #define need_GL_EXT_blend_minmax
81 #define need_GL_EXT_cull_vertex
82 #define need_GL_EXT_fog_coord
83 #define need_GL_EXT_framebuffer_object
84 #define need_GL_EXT_multi_draw_arrays
85 #define need_GL_EXT_secondary_color
86 #define need_GL_NV_vertex_program
87 #include "extension_helper.h"
90 #define DRIVER_DATE "20061102"
92 _glthread_Mutex lockMutex
;
93 static GLboolean lockMutexInit
= GL_FALSE
;
96 static const GLubyte
*
97 intelGetString(GLcontext
* ctx
, GLenum name
)
100 static char buffer
[128];
104 return (GLubyte
*) "Tungsten Graphics, Inc";
108 switch (intel_context(ctx
)->intelScreen
->deviceID
) {
110 chipset
= "Intel(R) 845G";
112 case PCI_CHIP_I830_M
:
113 chipset
= "Intel(R) 830M";
115 case PCI_CHIP_I855_GM
:
116 chipset
= "Intel(R) 852GM/855GM";
118 case PCI_CHIP_I865_G
:
119 chipset
= "Intel(R) 865G";
121 case PCI_CHIP_I915_G
:
122 chipset
= "Intel(R) 915G";
124 case PCI_CHIP_I915_GM
:
125 chipset
= "Intel(R) 915GM";
127 case PCI_CHIP_I945_G
:
128 chipset
= "Intel(R) 945G";
130 case PCI_CHIP_I945_GM
:
131 chipset
= "Intel(R) 945GM";
133 case PCI_CHIP_I945_GME
:
134 chipset
= "Intel(R) 945GME";
137 chipset
= "Intel(R) G33";
140 chipset
= "Intel(R) Q35";
143 chipset
= "Intel(R) Q33";
146 chipset
= "Unknown Intel Chipset";
150 (void) driGetRendererString(buffer
, chipset
, DRIVER_DATE
, 0);
151 return (GLubyte
*) buffer
;
160 * Extension strings exported by the intel driver.
163 * It appears that ARB_texture_env_crossbar has "disappeared" compared to the
164 * old i830-specific driver.
166 const struct dri_extension card_extensions
[] = {
167 {"GL_ARB_multisample", GL_ARB_multisample_functions
},
168 {"GL_ARB_multitexture", NULL
},
169 {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions
},
170 {"GL_ARB_texture_border_clamp", NULL
},
171 {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions
},
172 {"GL_ARB_texture_cube_map", NULL
},
173 {"GL_ARB_texture_env_add", NULL
},
174 {"GL_ARB_texture_env_combine", NULL
},
175 {"GL_ARB_texture_env_dot3", NULL
},
176 {"GL_ARB_texture_mirrored_repeat", NULL
},
177 {"GL_ARB_texture_rectangle", NULL
},
178 {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions
},
179 {"GL_ARB_pixel_buffer_object", NULL
},
180 {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions
},
181 {"GL_ARB_window_pos", GL_ARB_window_pos_functions
},
182 {"GL_EXT_blend_color", GL_EXT_blend_color_functions
},
183 {"GL_EXT_blend_equation_separate",
184 GL_EXT_blend_equation_separate_functions
},
185 {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions
},
186 {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions
},
187 {"GL_EXT_blend_subtract", NULL
},
188 {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions
},
189 {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions
},
190 {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions
},
191 {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions
},
192 #if 1 /* XXX FBO temporary? */
193 {"GL_EXT_packed_depth_stencil", NULL
},
195 {"GL_EXT_pixel_buffer_object", NULL
},
196 {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions
},
197 {"GL_EXT_stencil_wrap", NULL
},
198 {"GL_EXT_texture_edge_clamp", NULL
},
199 {"GL_EXT_texture_env_combine", NULL
},
200 {"GL_EXT_texture_env_dot3", NULL
},
201 {"GL_EXT_texture_filter_anisotropic", NULL
},
202 {"GL_EXT_texture_lod_bias", NULL
},
203 {"GL_3DFX_texture_compression_FXT1", NULL
},
204 {"GL_APPLE_client_storage", NULL
},
205 {"GL_MESA_pack_invert", NULL
},
206 {"GL_MESA_ycbcr_texture", NULL
},
207 {"GL_NV_blend_square", NULL
},
208 {"GL_NV_vertex_program", GL_NV_vertex_program_functions
},
209 {"GL_NV_vertex_program1_1", NULL
},
210 /* { "GL_SGIS_generate_mipmap", NULL }, */
214 extern const struct tnl_pipeline_stage _intel_render_stage
;
216 static const struct tnl_pipeline_stage
*intel_pipeline
[] = {
217 &_tnl_vertex_transform_stage
,
218 &_tnl_vertex_cull_stage
,
219 &_tnl_normal_transform_stage
,
220 &_tnl_lighting_stage
,
221 &_tnl_fog_coordinate_stage
,
223 &_tnl_texture_transform_stage
,
224 &_tnl_point_attenuation_stage
,
225 &_tnl_vertex_program_stage
,
227 &_intel_render_stage
, /* ADD: unclipped rastersetup-to-dma */
234 static const struct dri_debug_control debug_control
[] = {
235 {"tex", DEBUG_TEXTURE
},
236 {"state", DEBUG_STATE
},
237 {"ioctl", DEBUG_IOCTL
},
238 {"blit", DEBUG_BLIT
},
239 {"mip", DEBUG_MIPTREE
},
240 {"fall", DEBUG_FALLBACKS
},
241 {"verb", DEBUG_VERBOSE
},
242 {"bat", DEBUG_BATCH
},
243 {"pix", DEBUG_PIXEL
},
244 {"buf", DEBUG_BUFMGR
},
245 {"reg", DEBUG_REGION
},
247 {"lock", DEBUG_LOCK
},
253 intelInvalidateState(GLcontext
* ctx
, GLuint new_state
)
255 _swrast_InvalidateState(ctx
, new_state
);
256 _swsetup_InvalidateState(ctx
, new_state
);
257 _vbo_InvalidateState(ctx
, new_state
);
258 _tnl_InvalidateState(ctx
, new_state
);
259 _tnl_invalidate_vertex_state(ctx
, new_state
);
260 intel_context(ctx
)->NewGLState
|= new_state
;
265 intelFlush(GLcontext
* ctx
)
267 struct intel_context
*intel
= intel_context(ctx
);
272 INTEL_FIREVERTICES(intel
);
274 if (intel
->batch
->map
!= intel
->batch
->ptr
)
275 intel_batchbuffer_flush(intel
->batch
);
277 /* XXX: Need to do an MI_FLUSH here.
283 * Check if we need to rotate/warp the front color buffer to the
284 * rotated screen. We generally need to do this when we get a glFlush
285 * or glFinish after drawing to the front color buffer.
286 * If no rotation, just copy the private fake front buffer to the real one.
289 intelCheckFrontUpdate(GLcontext
* ctx
)
291 struct intel_context
*intel
= intel_context(ctx
);
292 /* can't use _ColorDrawBufferMask as its value
293 might change if a different drawable is bound! */
294 if (ctx
->Color
.DrawBuffer
[0] == GL_FRONT_LEFT
) {
295 intelScreenPrivate
*screen
= intel
->intelScreen
;
296 __DRIdrawablePrivate
*dPriv
= intel
->driDrawable
;
297 if (screen
->current_rotation
!= 0) {
298 intelRotateWindow(intel
, dPriv
, BUFFER_BIT_FRONT_LEFT
);
301 intelCopyBuffer(dPriv
, NULL
);
308 * Called via glFlush.
311 intelglFlush(GLcontext
* ctx
)
314 intelCheckFrontUpdate(ctx
);
318 intelFinish(GLcontext
* ctx
)
320 struct intel_context
*intel
= intel_context(ctx
);
322 if (intel
->batch
->last_fence
) {
323 driFenceFinish(intel
->batch
->last_fence
,
325 driFenceUnReference(intel
->batch
->last_fence
);
326 intel
->batch
->last_fence
= NULL
;
328 intelCheckFrontUpdate(ctx
);
333 intelInitDriverFunctions(struct dd_function_table
*functions
)
335 _mesa_init_driver_functions(functions
);
337 functions
->Flush
= intelglFlush
;
338 functions
->Finish
= intelFinish
;
339 functions
->GetString
= intelGetString
;
340 functions
->UpdateState
= intelInvalidateState
;
341 functions
->CopyColorTable
= _swrast_CopyColorTable
;
342 functions
->CopyColorSubTable
= _swrast_CopyColorSubTable
;
343 functions
->CopyConvolutionFilter1D
= _swrast_CopyConvolutionFilter1D
;
344 functions
->CopyConvolutionFilter2D
= _swrast_CopyConvolutionFilter2D
;
346 intelInitTextureFuncs(functions
);
347 intelInitPixelFuncs(functions
);
348 intelInitStateFuncs(functions
);
349 intelInitBufferFuncs(functions
);
354 intelInitContext(struct intel_context
*intel
,
355 const __GLcontextModes
* mesaVis
,
356 __DRIcontextPrivate
* driContextPriv
,
357 void *sharedContextPrivate
,
358 struct dd_function_table
*functions
)
360 GLcontext
*ctx
= &intel
->ctx
;
361 GLcontext
*shareCtx
= (GLcontext
*) sharedContextPrivate
;
362 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
363 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
364 drmI830Sarea
*saPriv
= (drmI830Sarea
*)
365 (((GLubyte
*) sPriv
->pSAREA
) + intelScreen
->sarea_priv_offset
);
369 DRM_LIGHT_LOCK(sPriv
->fd
, &sPriv
->pSAREA
->lock
, driContextPriv
->hHWContext
);
370 havePools
= intelCreatePools(intelScreen
);
371 DRM_UNLOCK(sPriv
->fd
, &sPriv
->pSAREA
->lock
, driContextPriv
->hHWContext
);
376 if (!_mesa_initialize_context(&intel
->ctx
,
378 functions
, (void *) intel
))
381 driContextPriv
->driverPrivate
= intel
;
382 intel
->intelScreen
= intelScreen
;
383 intel
->driScreen
= sPriv
;
384 intel
->sarea
= saPriv
;
386 intel
->width
= intelScreen
->width
;
387 intel
->height
= intelScreen
->height
;
388 intel
->current_rotation
= intelScreen
->current_rotation
;
390 if (!lockMutexInit
) {
391 lockMutexInit
= GL_TRUE
;
392 _glthread_INIT_MUTEX(lockMutex
);
395 driParseConfigFiles(&intel
->optionCache
, &intelScreen
->optionCache
,
396 intel
->driScreen
->myNum
, "i915");
398 ctx
->Const
.MaxTextureMaxAnisotropy
= 2.0;
400 /* This doesn't yet catch all non-conformant rendering, but it's a
403 if (getenv("INTEL_STRICT_CONFORMANCE")) {
404 intel
->strict_conformance
= 1;
407 ctx
->Const
.MinLineWidth
= 1.0;
408 ctx
->Const
.MinLineWidthAA
= 1.0;
409 ctx
->Const
.MaxLineWidth
= 3.0;
410 ctx
->Const
.MaxLineWidthAA
= 3.0;
411 ctx
->Const
.LineWidthGranularity
= 1.0;
413 ctx
->Const
.MinPointSize
= 1.0;
414 ctx
->Const
.MinPointSizeAA
= 1.0;
415 ctx
->Const
.MaxPointSize
= 255.0;
416 ctx
->Const
.MaxPointSizeAA
= 3.0;
417 ctx
->Const
.PointSizeGranularity
= 1.0;
419 /* reinitialize the context point state.
420 * It depend on constants in __GLcontextRec::Const
422 _mesa_init_point(ctx
);
424 ctx
->Const
.MaxColorAttachments
= 4; /* XXX FBO: review this */
426 /* Initialize the software rasterizer and helper modules. */
427 _swrast_CreateContext(ctx
);
428 _vbo_CreateContext(ctx
);
429 _tnl_CreateContext(ctx
);
430 _swsetup_CreateContext(ctx
);
432 /* Install the customized pipeline: */
433 _tnl_destroy_pipeline(ctx
);
434 _tnl_install_pipeline(ctx
, intel_pipeline
);
436 /* Configure swrast to match hardware characteristics: */
437 _swrast_allow_pixel_fog(ctx
, GL_FALSE
);
438 _swrast_allow_vertex_fog(ctx
, GL_TRUE
);
441 intel
->hHWContext
= driContextPriv
->hHWContext
;
442 intel
->driFd
= sPriv
->fd
;
443 intel
->driHwLock
= (drmLock
*) & sPriv
->pSAREA
->lock
;
445 intel
->hw_stipple
= 1;
447 /* XXX FBO: this doesn't seem to be used anywhere */
448 switch (mesaVis
->depthBits
) {
449 case 0: /* what to do in this case? */
451 intel
->polygon_offset_scale
= 1.0 / 0xffff;
454 intel
->polygon_offset_scale
= 2.0 / 0xffffff; /* req'd to pass glean */
461 /* Initialize swrast, tnl driver tables: */
462 intelInitSpanFuncs(ctx
);
463 intelInitTriFuncs(ctx
);
466 intel
->RenderIndex
= ~0;
468 fthrottle_mode
= driQueryOptioni(&intel
->optionCache
, "fthrottle_mode");
469 intel
->iw
.irq_seq
= -1;
470 intel
->irqsEmitted
= 0;
472 intel
->do_irqs
= (intel
->intelScreen
->irq_active
&&
473 fthrottle_mode
== DRI_CONF_FTHROTTLE_IRQS
);
475 intel
->do_usleeps
= (fthrottle_mode
== DRI_CONF_FTHROTTLE_USLEEPS
);
477 _math_matrix_ctr(&intel
->ViewportMatrix
);
479 /* Disable imaging extension until convolution is working in
482 driInitExtensions(ctx
, card_extensions
,
487 intel
->batch
= intel_batchbuffer_alloc(intel
);
488 intel
->last_swap_fence
= NULL
;
489 intel
->first_swap_fence
= NULL
;
491 intel_bufferobj_init(intel
);
492 intel_fbo_init(intel
);
494 if (intel
->ctx
.Mesa_DXTn
) {
495 _mesa_enable_extension(ctx
, "GL_EXT_texture_compression_s3tc");
496 _mesa_enable_extension(ctx
, "GL_S3_s3tc");
498 else if (driQueryOptionb(&intel
->optionCache
, "force_s3tc_enable")) {
499 _mesa_enable_extension(ctx
, "GL_EXT_texture_compression_s3tc");
502 intel
->prim
.primitive
= ~0;
506 INTEL_DEBUG
= driParseDebugString(getenv("INTEL_DEBUG"), debug_control
);
509 if (getenv("INTEL_NO_RAST")) {
510 fprintf(stderr
, "disabling 3D rasterization\n");
511 FALLBACK(intel
, INTEL_FALLBACK_USER
, 1);
518 intelDestroyContext(__DRIcontextPrivate
* driContextPriv
)
520 struct intel_context
*intel
=
521 (struct intel_context
*) driContextPriv
->driverPrivate
;
523 assert(intel
); /* should never be null */
525 GLboolean release_texture_heaps
;
527 INTEL_FIREVERTICES(intel
);
529 intel
->vtbl
.destroy(intel
);
531 release_texture_heaps
= (intel
->ctx
.Shared
->RefCount
== 1);
532 _swsetup_DestroyContext(&intel
->ctx
);
533 _tnl_DestroyContext(&intel
->ctx
);
534 _vbo_DestroyContext(&intel
->ctx
);
536 _swrast_DestroyContext(&intel
->ctx
);
537 intel
->Fallback
= 0; /* don't call _swrast_Flush later */
539 intel_batchbuffer_free(intel
->batch
);
541 if (intel
->last_swap_fence
) {
542 driFenceFinish(intel
->last_swap_fence
, DRM_FENCE_TYPE_EXE
, GL_TRUE
);
543 driFenceUnReference(intel
->last_swap_fence
);
544 intel
->last_swap_fence
= NULL
;
546 if (intel
->first_swap_fence
) {
547 driFenceFinish(intel
->first_swap_fence
, DRM_FENCE_TYPE_EXE
, GL_TRUE
);
548 driFenceUnReference(intel
->first_swap_fence
);
549 intel
->first_swap_fence
= NULL
;
553 if (release_texture_heaps
) {
554 /* This share group is about to go away, free our private
555 * texture object data.
557 if (INTEL_DEBUG
& DEBUG_TEXTURE
)
558 fprintf(stderr
, "do something to free texture heaps\n");
561 /* free the Mesa context */
562 _mesa_free_context_data(&intel
->ctx
);
567 intelUnbindContext(__DRIcontextPrivate
* driContextPriv
)
573 intelMakeCurrent(__DRIcontextPrivate
* driContextPriv
,
574 __DRIdrawablePrivate
* driDrawPriv
,
575 __DRIdrawablePrivate
* driReadPriv
)
580 fprintf(stderr
, "x %d, y %d, width %d, height %d\n",
581 driDrawPriv
->x
, driDrawPriv
->y
, driDrawPriv
->w
, driDrawPriv
->h
);
585 if (driContextPriv
) {
586 struct intel_context
*intel
=
587 (struct intel_context
*) driContextPriv
->driverPrivate
;
588 struct intel_framebuffer
*intel_fb
=
589 (struct intel_framebuffer
*) driDrawPriv
->driverPrivate
;
590 GLframebuffer
*readFb
= (GLframebuffer
*) driReadPriv
->driverPrivate
;
592 /* this is a hack so we have a valid context when the region allocation
593 is done. Need a per-screen context? */
594 intel
->intelScreen
->dummyctxptr
= intel
;
596 /* XXX FBO temporary fix-ups! */
597 /* if the renderbuffers don't have regions, init them from the context */
599 struct intel_renderbuffer
*irbDepth
600 = intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_DEPTH
);
601 struct intel_renderbuffer
*irbStencil
602 = intel_get_renderbuffer(&intel_fb
->Base
, BUFFER_STENCIL
);
604 if (intel_fb
->color_rb
[0] && !intel_fb
->color_rb
[0]->region
) {
605 intel_region_reference(&intel_fb
->color_rb
[0]->region
,
606 intel
->intelScreen
->front_region
);
608 if (intel_fb
->color_rb
[1] && !intel_fb
->color_rb
[1]->region
) {
609 intel_region_reference(&intel_fb
->color_rb
[1]->region
,
610 intel
->intelScreen
->back_region
);
612 if (intel_fb
->color_rb
[2] && !intel_fb
->color_rb
[2]->region
) {
613 intel_region_reference(&intel_fb
->color_rb
[2]->region
,
614 intel
->intelScreen
->third_region
);
616 if (irbDepth
&& !irbDepth
->region
) {
617 intel_region_reference(&irbDepth
->region
, intel
->intelScreen
->depth_region
);
619 if (irbStencil
&& !irbStencil
->region
) {
620 intel_region_reference(&irbStencil
->region
, intel
->intelScreen
->depth_region
);
624 /* update GLframebuffer size to match window if needed */
625 driUpdateFramebufferSize(&intel
->ctx
, driDrawPriv
);
627 if (driReadPriv
!= driDrawPriv
) {
628 driUpdateFramebufferSize(&intel
->ctx
, driReadPriv
);
631 _mesa_make_current(&intel
->ctx
, &intel_fb
->Base
, readFb
);
633 /* The drawbuffer won't always be updated by _mesa_make_current:
635 if (intel
->ctx
.DrawBuffer
== &intel_fb
->Base
) {
637 if (intel
->driDrawable
!= driDrawPriv
) {
638 intel_fb
->vblank_flags
= (intel
->intelScreen
->irq_active
!= 0)
639 ? driGetDefaultVBlankFlags(&intel
->optionCache
)
640 : VBLANK_FLAG_NO_IRQ
;
641 (*dri_interface
->getUST
) (&intel_fb
->swap_ust
);
642 driDrawableInitVBlank(driDrawPriv
, intel_fb
->vblank_flags
,
644 intel
->driDrawable
= driDrawPriv
;
645 intelWindowMoved(intel
);
646 intel
->lastStamp
= driDrawPriv
->lastStamp
;
648 else if (intel
->lastStamp
!= driDrawPriv
->lastStamp
) {
649 intel_draw_buffer(&intel
->ctx
, &intel_fb
->Base
);
654 _mesa_make_current(NULL
, NULL
, NULL
);
661 intelContendedLock(struct intel_context
*intel
, GLuint flags
)
663 __DRIdrawablePrivate
*dPriv
= intel
->driDrawable
;
664 __DRIscreenPrivate
*sPriv
= intel
->driScreen
;
665 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*) sPriv
->private;
666 drmI830Sarea
*sarea
= intel
->sarea
;
668 drmGetLock(intel
->driFd
, intel
->hHWContext
, flags
);
670 if (INTEL_DEBUG
& DEBUG_LOCK
)
671 _mesa_printf("%s - got contended lock\n", __progname
);
673 /* If the window moved, may need to set a new cliprect now.
675 * NOTE: This releases and regains the hw lock, so all state
676 * checking must be done *after* this call:
679 DRI_VALIDATE_DRAWABLE_INFO(sPriv
, dPriv
);
681 if (sarea
->width
!= intelScreen
->width
||
682 sarea
->height
!= intelScreen
->height
||
683 sarea
->rotation
!= intelScreen
->current_rotation
) {
685 intelUpdateScreenRotation(sPriv
, sarea
);
689 if (sarea
->width
!= intel
->width
||
690 sarea
->height
!= intel
->height
||
691 sarea
->rotation
!= intel
->current_rotation
) {
693 void *batchMap
= intel
->batch
->map
;
696 * FIXME: Really only need to do this when drawing to a
697 * common back- or front buffer.
701 * This will drop the outstanding batchbuffer on the floor
704 if (batchMap
!= NULL
) {
705 driBOUnmap(intel
->batch
->buffer
);
706 intel
->batch
->map
= NULL
;
709 intel_batchbuffer_reset(intel
->batch
);
711 if (batchMap
== NULL
) {
712 driBOUnmap(intel
->batch
->buffer
);
713 intel
->batch
->map
= NULL
;
716 /* lose all primitives */
717 intel
->prim
.primitive
= ~0;
718 intel
->prim
.start_ptr
= 0;
719 intel
->prim
.flush
= 0;
721 /* re-emit all state */
722 intel
->vtbl
.lost_hardware(intel
);
724 /* force window update */
725 intel
->lastStamp
= 0;
727 intel
->width
= sarea
->width
;
728 intel
->height
= sarea
->height
;
729 intel
->current_rotation
= sarea
->rotation
;
736 /* Lock the hardware and validate our state.
738 void LOCK_HARDWARE( struct intel_context
*intel
)
741 struct intel_framebuffer
*intel_fb
= NULL
;
742 struct intel_renderbuffer
*intel_rb
= NULL
;
743 _glthread_LOCK_MUTEX(lockMutex
);
744 assert(!intel
->locked
);
746 if (intel
->driDrawable
) {
747 intel_fb
= intel
->driDrawable
->driverPrivate
;
751 intel_get_renderbuffer(&intel_fb
->Base
,
752 intel_fb
->Base
._ColorDrawBufferMask
[0] ==
753 BUFFER_BIT_FRONT_LEFT
? BUFFER_FRONT_LEFT
:
757 if (intel_rb
&& (intel_fb
->vbl_waited
- intel_rb
->vbl_pending
) > (1<<23)) {
760 vbl
.request
.type
= DRM_VBLANK_ABSOLUTE
;
762 if ( intel_fb
->vblank_flags
& VBLANK_FLAG_SECONDARY
) {
763 vbl
.request
.type
|= DRM_VBLANK_SECONDARY
;
766 vbl
.request
.sequence
= intel_rb
->vbl_pending
;
767 drmWaitVBlank(intel
->driFd
, &vbl
);
768 intel_fb
->vbl_waited
= vbl
.reply
.sequence
;
771 DRM_CAS(intel
->driHwLock
, intel
->hHWContext
,
772 (DRM_LOCK_HELD
|intel
->hHWContext
), __ret
);
775 intelContendedLock( intel
, 0 );
777 if (INTEL_DEBUG
& DEBUG_LOCK
)
778 _mesa_printf("%s - locked\n", __progname
);
784 /* Unlock the hardware using the global current context
786 void UNLOCK_HARDWARE( struct intel_context
*intel
)
790 DRM_UNLOCK(intel
->driFd
, intel
->driHwLock
, intel
->hHWContext
);
792 _glthread_UNLOCK_MUTEX(lockMutex
);
794 if (INTEL_DEBUG
& DEBUG_LOCK
)
795 _mesa_printf("%s - unlocked\n", __progname
);