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"
43 #include "tnl/t_pipeline.h"
44 #include "tnl/t_vertex.h"
46 #include "drivers/common/driverfuncs.h"
48 #include "intel_screen.h"
51 #include "i830_common.h"
53 #include "intel_tex.h"
54 #include "intel_span.h"
55 #include "intel_tris.h"
56 #include "intel_ioctl.h"
57 #include "intel_batchbuffer.h"
61 #include "xmlpool.h" /* for symbolic values of enum-type options */
63 int INTEL_DEBUG
= (0);
66 #define need_GL_ARB_multisample
67 #define need_GL_ARB_point_parameters
68 #define need_GL_ARB_texture_compression
69 #define need_GL_ARB_vertex_buffer_object
70 #define need_GL_ARB_vertex_program
71 #define need_GL_ARB_window_pos
72 #define need_GL_EXT_blend_color
73 #define need_GL_EXT_blend_equation_separate
74 #define need_GL_EXT_blend_func_separate
75 #define need_GL_EXT_blend_minmax
76 #define need_GL_EXT_cull_vertex
77 #define need_GL_EXT_fog_coord
78 #define need_GL_EXT_multi_draw_arrays
79 #define need_GL_EXT_secondary_color
80 #define need_GL_NV_vertex_program
81 #include "extension_helper.h"
92 /***************************************
93 * Mesa's Driver Functions
94 ***************************************/
96 #define DRIVER_DATE "20061017"
98 const GLubyte
*intelGetString( GLcontext
*ctx
, GLenum name
)
100 const char * chipset
;
101 static char buffer
[128];
105 return (GLubyte
*)"Tungsten Graphics, Inc";
109 switch (INTEL_CONTEXT(ctx
)->intelScreen
->deviceID
) {
111 chipset
= "Intel(R) 845G"; break;
112 case PCI_CHIP_I830_M
:
113 chipset
= "Intel(R) 830M"; break;
114 case PCI_CHIP_I855_GM
:
115 chipset
= "Intel(R) 852GM/855GM"; break;
116 case PCI_CHIP_I865_G
:
117 chipset
= "Intel(R) 865G"; break;
118 case PCI_CHIP_I915_G
:
119 chipset
= "Intel(R) 915G"; break;
120 case PCI_CHIP_I915_GM
:
121 chipset
= "Intel(R) 915GM"; break;
122 case PCI_CHIP_I945_G
:
123 chipset
= "Intel(R) 945G"; break;
124 case PCI_CHIP_I945_GM
:
125 chipset
= "Intel(R) 945GM"; break;
126 case PCI_CHIP_I945_GME
:
127 chipset
= "Intel(R) 945GME"; break;
129 chipset
= "Intel(R) G33"; break;
131 chipset
= "Intel(R) Q35"; break;
133 chipset
= "Intel(R) Q33"; break;
135 chipset
= "Unknown Intel Chipset"; break;
138 (void) driGetRendererString( buffer
, chipset
, DRIVER_DATE
, 0 );
139 return (GLubyte
*) buffer
;
148 * Extension strings exported by the intel driver.
151 * It appears that ARB_texture_env_crossbar has "disappeared" compared to the
152 * old i830-specific driver.
154 const struct dri_extension card_extensions
[] =
156 { "GL_ARB_multisample", GL_ARB_multisample_functions
},
157 { "GL_ARB_multitexture", NULL
},
158 { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions
},
159 { "GL_ARB_texture_border_clamp", NULL
},
160 { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions
},
161 { "GL_ARB_texture_cube_map", NULL
},
162 { "GL_ARB_texture_env_add", NULL
},
163 { "GL_ARB_texture_env_combine", NULL
},
164 { "GL_ARB_texture_env_dot3", NULL
},
165 { "GL_ARB_texture_mirrored_repeat", NULL
},
166 { "GL_ARB_texture_rectangle", NULL
},
167 { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions
},
168 { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions
},
169 { "GL_ARB_window_pos", GL_ARB_window_pos_functions
},
170 { "GL_EXT_blend_color", GL_EXT_blend_color_functions
},
171 { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions
},
172 { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions
},
173 { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions
},
174 { "GL_EXT_blend_subtract", NULL
},
175 { "GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions
},
176 { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions
},
177 { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions
},
178 { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions
},
179 { "GL_EXT_stencil_wrap", NULL
},
180 { "GL_EXT_texture_edge_clamp", NULL
},
181 { "GL_EXT_texture_env_combine", NULL
},
182 { "GL_EXT_texture_env_dot3", NULL
},
183 { "GL_EXT_texture_filter_anisotropic", NULL
},
184 { "GL_EXT_texture_lod_bias", NULL
},
185 { "GL_3DFX_texture_compression_FXT1", NULL
},
186 { "GL_APPLE_client_storage", NULL
},
187 { "GL_MESA_pack_invert", NULL
},
188 { "GL_MESA_ycbcr_texture", NULL
},
189 { "GL_NV_blend_square", NULL
},
190 { "GL_NV_vertex_program", GL_NV_vertex_program_functions
},
191 { "GL_NV_vertex_program1_1", NULL
},
192 { "GL_SGIS_generate_mipmap", NULL
},
196 extern const struct tnl_pipeline_stage _intel_render_stage
;
198 static const struct tnl_pipeline_stage
*intel_pipeline
[] = {
199 &_tnl_vertex_transform_stage
,
200 &_tnl_vertex_cull_stage
,
201 &_tnl_normal_transform_stage
,
202 &_tnl_lighting_stage
,
203 &_tnl_fog_coordinate_stage
,
205 &_tnl_texture_transform_stage
,
206 &_tnl_point_attenuation_stage
,
207 &_tnl_vertex_program_stage
,
209 &_intel_render_stage
, /* ADD: unclipped rastersetup-to-dma */
216 static const struct dri_debug_control debug_control
[] =
218 { "fall", DEBUG_FALLBACKS
},
219 { "tex", DEBUG_TEXTURE
},
220 { "ioctl", DEBUG_IOCTL
},
221 { "prim", DEBUG_PRIMS
},
222 { "vert", DEBUG_VERTS
},
223 { "state", DEBUG_STATE
},
224 { "verb", DEBUG_VERBOSE
},
225 { "dri", DEBUG_DRI
},
226 { "dma", DEBUG_DMA
},
227 { "san", DEBUG_SANITY
},
228 { "sync", DEBUG_SYNC
},
229 { "sleep", DEBUG_SLEEP
},
230 { "pix", DEBUG_PIXEL
},
235 static void intelInvalidateState( GLcontext
*ctx
, GLuint new_state
)
237 _swrast_InvalidateState( ctx
, new_state
);
238 _swsetup_InvalidateState( ctx
, new_state
);
239 _vbo_InvalidateState( ctx
, new_state
);
240 _tnl_InvalidateState( ctx
, new_state
);
241 _tnl_invalidate_vertex_state( ctx
, new_state
);
242 INTEL_CONTEXT(ctx
)->NewGLState
|= new_state
;
246 void intelInitDriverFunctions( struct dd_function_table
*functions
)
248 _mesa_init_driver_functions( functions
);
250 functions
->Clear
= intelClear
;
251 functions
->Flush
= intelglFlush
;
252 functions
->Finish
= intelFinish
;
253 functions
->GetString
= intelGetString
;
254 functions
->UpdateState
= intelInvalidateState
;
256 intelInitTextureFuncs( functions
);
257 intelInitPixelFuncs( functions
);
258 intelInitStateFuncs( functions
);
261 static void intel_emit_invarient_state( GLcontext
*ctx
)
267 GLboolean
intelInitContext( intelContextPtr intel
,
268 const __GLcontextModes
*mesaVis
,
269 __DRIcontextPrivate
*driContextPriv
,
270 void *sharedContextPrivate
,
271 struct dd_function_table
*functions
)
273 GLcontext
*ctx
= &intel
->ctx
;
274 GLcontext
*shareCtx
= (GLcontext
*) sharedContextPrivate
;
275 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
276 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)sPriv
->private;
277 drmI830Sarea
*saPriv
= (drmI830Sarea
*)
278 (((GLubyte
*)sPriv
->pSAREA
)+intelScreen
->sarea_priv_offset
);
281 if (!_mesa_initialize_context(&intel
->ctx
,
287 driContextPriv
->driverPrivate
= intel
;
288 intel
->intelScreen
= intelScreen
;
289 intel
->driScreen
= sPriv
;
290 intel
->sarea
= saPriv
;
293 (void) memset( intel
->texture_heaps
, 0, sizeof( intel
->texture_heaps
) );
294 make_empty_list( & intel
->swapped
);
296 driParseConfigFiles (&intel
->optionCache
, &intelScreen
->optionCache
,
297 intel
->driScreen
->myNum
, "i915");
299 ctx
->Const
.MaxTextureMaxAnisotropy
= 2.0;
301 ctx
->Const
.MinLineWidth
= 1.0;
302 ctx
->Const
.MinLineWidthAA
= 1.0;
303 ctx
->Const
.MaxLineWidth
= 3.0;
304 ctx
->Const
.MaxLineWidthAA
= 3.0;
305 ctx
->Const
.LineWidthGranularity
= 1.0;
307 ctx
->Const
.MinPointSize
= 1.0;
308 ctx
->Const
.MinPointSizeAA
= 1.0;
309 ctx
->Const
.MaxPointSize
= 255.0;
310 ctx
->Const
.MaxPointSizeAA
= 3.0;
311 ctx
->Const
.PointSizeGranularity
= 1.0;
313 /* reinitialize the context point state.
314 * It depend on constants in __GLcontextRec::Const
316 _mesa_init_point(ctx
);
318 /* Initialize the software rasterizer and helper modules. */
319 _swrast_CreateContext( ctx
);
320 _vbo_CreateContext( ctx
);
321 _tnl_CreateContext( ctx
);
322 _swsetup_CreateContext( ctx
);
324 /* Install the customized pipeline: */
325 _tnl_destroy_pipeline( ctx
);
326 _tnl_install_pipeline( ctx
, intel_pipeline
);
328 /* Configure swrast to match hardware characteristics: */
329 _swrast_allow_pixel_fog( ctx
, GL_FALSE
);
330 _swrast_allow_vertex_fog( ctx
, GL_TRUE
);
333 intel
->hHWContext
= driContextPriv
->hHWContext
;
334 intel
->driFd
= sPriv
->fd
;
335 intel
->driHwLock
= (drmLock
*) &sPriv
->pSAREA
->lock
;
337 intel
->hw_stencil
= mesaVis
->stencilBits
&& mesaVis
->depthBits
== 24;
338 intel
->hw_stipple
= 1;
340 switch(mesaVis
->depthBits
) {
341 case 0: /* what to do in this case? */
343 intel
->depth_scale
= 1.0/0xffff;
344 intel
->polygon_offset_scale
= 1.0/0xffff;
345 intel
->depth_clear_mask
= ~0;
346 intel
->ClearDepth
= 0xffff;
349 intel
->depth_scale
= 1.0/0xffffff;
350 intel
->polygon_offset_scale
= 2.0/0xffffff; /* req'd to pass glean */
351 intel
->depth_clear_mask
= 0x00ffffff;
352 intel
->stencil_clear_mask
= 0xff000000;
353 intel
->ClearDepth
= 0x00ffffff;
360 /* Initialize swrast, tnl driver tables: */
361 intelInitSpanFuncs( ctx
);
362 intelInitTriFuncs( ctx
);
365 intel
->RenderIndex
= ~0;
367 fthrottle_mode
= driQueryOptioni(&intel
->optionCache
, "fthrottle_mode");
368 intel
->iw
.irq_seq
= -1;
369 intel
->irqsEmitted
= 0;
371 intel
->do_irqs
= (intel
->intelScreen
->irq_active
&&
372 fthrottle_mode
== DRI_CONF_FTHROTTLE_IRQS
);
374 intel
->do_usleeps
= (fthrottle_mode
== DRI_CONF_FTHROTTLE_USLEEPS
);
376 intel
->vblank_flags
= (intel
->intelScreen
->irq_active
!= 0)
377 ? driGetDefaultVBlankFlags(&intel
->optionCache
) : VBLANK_FLAG_NO_IRQ
;
379 (*dri_interface
->getUST
)(&intel
->swap_ust
);
380 _math_matrix_ctr (&intel
->ViewportMatrix
);
382 driInitExtensions( ctx
, card_extensions
, GL_TRUE
);
384 if (intel
->ctx
.Mesa_DXTn
) {
385 _mesa_enable_extension( ctx
, "GL_EXT_texture_compression_s3tc" );
386 _mesa_enable_extension( ctx
, "GL_S3_s3tc" );
388 else if (driQueryOptionb (&intel
->optionCache
, "force_s3tc_enable")) {
389 _mesa_enable_extension( ctx
, "GL_EXT_texture_compression_s3tc" );
392 /* driInitTextureObjects( ctx, & intel->swapped, */
393 /* DRI_TEXMGR_DO_TEXTURE_1D | */
394 /* DRI_TEXMGR_DO_TEXTURE_2D | */
395 /* DRI_TEXMGR_DO_TEXTURE_RECT ); */
398 intelInitBatchBuffer(&intel
->ctx
);
399 intel
->prim
.flush
= intel_emit_invarient_state
;
400 intel
->prim
.primitive
= ~0;
404 INTEL_DEBUG
= driParseDebugString( getenv( "INTEL_DEBUG" ),
406 INTEL_DEBUG
|= driParseDebugString( getenv( "INTEL_DEBUG" ),
411 if (getenv("INTEL_VERBOSE"))
415 if (getenv("INTEL_NO_RAST") ||
416 getenv("INTEL_NO_RAST")) {
417 fprintf(stderr
, "disabling 3D rasterization\n");
418 FALLBACK(intel
, INTEL_FALLBACK_USER
, 1);
424 void intelDestroyContext(__DRIcontextPrivate
*driContextPriv
)
426 intelContextPtr intel
= (intelContextPtr
) driContextPriv
->driverPrivate
;
428 assert(intel
); /* should never be null */
430 GLboolean release_texture_heaps
;
432 INTEL_FIREVERTICES( intel
);
434 intel
->vtbl
.destroy( intel
);
436 release_texture_heaps
= (intel
->ctx
.Shared
->RefCount
== 1);
437 _swsetup_DestroyContext (&intel
->ctx
);
438 _tnl_DestroyContext (&intel
->ctx
);
439 _vbo_DestroyContext (&intel
->ctx
);
441 _swrast_DestroyContext (&intel
->ctx
);
442 intel
->Fallback
= 0; /* don't call _swrast_Flush later */
444 intelDestroyBatchBuffer(&intel
->ctx
);
447 if ( release_texture_heaps
) {
448 /* This share group is about to go away, free our private
449 * texture object data.
453 for ( i
= 0 ; i
< intel
->nr_heaps
; i
++ ) {
454 driDestroyTextureHeap( intel
->texture_heaps
[ i
] );
455 intel
->texture_heaps
[ i
] = NULL
;
458 assert( is_empty_list( & intel
->swapped
) );
461 /* free the Mesa context */
462 _mesa_destroy_context(&intel
->ctx
);
466 void intelSetFrontClipRects( intelContextPtr intel
)
468 __DRIdrawablePrivate
*dPriv
= intel
->driDrawable
;
472 intel
->numClipRects
= dPriv
->numClipRects
;
473 intel
->pClipRects
= dPriv
->pClipRects
;
474 intel
->drawX
= dPriv
->x
;
475 intel
->drawY
= dPriv
->y
;
479 void intelSetBackClipRects( intelContextPtr intel
)
481 __DRIdrawablePrivate
*dPriv
= intel
->driDrawable
;
485 if (intel
->sarea
->pf_enabled
== 0 && dPriv
->numBackClipRects
== 0) {
486 intel
->numClipRects
= dPriv
->numClipRects
;
487 intel
->pClipRects
= dPriv
->pClipRects
;
488 intel
->drawX
= dPriv
->x
;
489 intel
->drawY
= dPriv
->y
;
491 intel
->numClipRects
= dPriv
->numBackClipRects
;
492 intel
->pClipRects
= dPriv
->pBackClipRects
;
493 intel
->drawX
= dPriv
->backX
;
494 intel
->drawY
= dPriv
->backY
;
496 if (dPriv
->numBackClipRects
== 1 &&
497 dPriv
->x
== dPriv
->backX
&&
498 dPriv
->y
== dPriv
->backY
) {
500 /* Repeat the calculation of the back cliprect dimensions here
501 * as early versions of dri.a in the Xserver are incorrect. Try
502 * very hard not to restrict future versions of dri.a which
503 * might eg. allocate truly private back buffers.
510 x2
= dPriv
->x
+ dPriv
->w
;
511 y2
= dPriv
->y
+ dPriv
->h
;
515 if (x2
> intel
->intelScreen
->width
) x2
= intel
->intelScreen
->width
;
516 if (y2
> intel
->intelScreen
->height
) y2
= intel
->intelScreen
->height
;
518 if (x1
== dPriv
->pBackClipRects
[0].x1
&&
519 y1
== dPriv
->pBackClipRects
[0].y1
) {
521 dPriv
->pBackClipRects
[0].x2
= x2
;
522 dPriv
->pBackClipRects
[0].y2
= y2
;
529 void intelWindowMoved( intelContextPtr intel
)
531 __DRIdrawablePrivate
*dPriv
= intel
->driDrawable
;
532 GLframebuffer
*drawFb
= (GLframebuffer
*) dPriv
->driverPrivate
;
534 if (!intel
->ctx
.DrawBuffer
) {
535 intelSetFrontClipRects( intel
);
538 driUpdateFramebufferSize(&intel
->ctx
, dPriv
);
539 switch (drawFb
->_ColorDrawBufferMask
[0]) {
540 case BUFFER_BIT_FRONT_LEFT
:
541 intelSetFrontClipRects( intel
);
543 case BUFFER_BIT_BACK_LEFT
:
544 intelSetBackClipRects( intel
);
547 /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */
548 intelSetFrontClipRects( intel
);
552 if (drawFb
->Width
!= dPriv
->w
|| drawFb
->Height
!= dPriv
->h
) {
553 /* update Mesa's notion of framebuffer/window size */
554 _mesa_resize_framebuffer(&intel
->ctx
, drawFb
, dPriv
->w
, dPriv
->h
);
555 drawFb
->Initialized
= GL_TRUE
; /* XXX remove someday */
558 /* Set state we know depends on drawable parameters:
561 GLcontext
*ctx
= &intel
->ctx
;
563 if (intel
->intelScreen
->driScrnPriv
->ddxMinor
>= 7) {
564 drmI830Sarea
*sarea
= intel
->sarea
;
565 drm_clip_rect_t drw_rect
= { .x1
= dPriv
->x
, .x2
= dPriv
->x
+ dPriv
->w
,
566 .y1
= dPriv
->y
, .y2
= dPriv
->y
+ dPriv
->h
};
567 drm_clip_rect_t planeA_rect
= { .x1
= sarea
->planeA_x
,
568 .x2
= sarea
->planeA_x
+ sarea
->planeA_w
,
569 .y1
= sarea
->planeA_y
,
570 .y2
= sarea
->planeA_y
+ sarea
->planeA_h
};
571 drm_clip_rect_t planeB_rect
= { .x1
= sarea
->planeB_x
,
572 .x2
= sarea
->planeB_x
+ sarea
->planeB_w
,
573 .y1
= sarea
->planeB_y
,
574 .y2
= sarea
->planeB_y
+ sarea
->planeB_h
};
575 GLint areaA
= driIntersectArea( drw_rect
, planeA_rect
);
576 GLint areaB
= driIntersectArea( drw_rect
, planeB_rect
);
577 GLuint flags
= intel
->vblank_flags
;
579 if (areaB
> areaA
|| (areaA
== areaB
&& areaB
> 0)) {
580 flags
= intel
->vblank_flags
| VBLANK_FLAG_SECONDARY
;
582 flags
= intel
->vblank_flags
& ~VBLANK_FLAG_SECONDARY
;
585 if (flags
!= intel
->vblank_flags
) {
586 intel
->vblank_flags
= flags
;
587 driGetCurrentVBlank(dPriv
, intel
->vblank_flags
, &intel
->vbl_seq
);
590 intel
->vblank_flags
&= ~VBLANK_FLAG_SECONDARY
;
593 ctx
->Driver
.Scissor( ctx
, ctx
->Scissor
.X
, ctx
->Scissor
.Y
,
594 ctx
->Scissor
.Width
, ctx
->Scissor
.Height
);
596 ctx
->Driver
.DepthRange( ctx
,
602 GLboolean
intelUnbindContext(__DRIcontextPrivate
*driContextPriv
)
607 GLboolean
intelMakeCurrent(__DRIcontextPrivate
*driContextPriv
,
608 __DRIdrawablePrivate
*driDrawPriv
,
609 __DRIdrawablePrivate
*driReadPriv
)
612 if (driContextPriv
) {
613 intelContextPtr intel
= (intelContextPtr
) driContextPriv
->driverPrivate
;
615 if ( intel
->driDrawable
!= driDrawPriv
) {
616 /* Shouldn't the readbuffer be stored also? */
617 driDrawableInitVBlank( driDrawPriv
, intel
->vblank_flags
,
620 intel
->driDrawable
= driDrawPriv
;
621 intelWindowMoved( intel
);
624 _mesa_make_current(&intel
->ctx
,
625 (GLframebuffer
*) driDrawPriv
->driverPrivate
,
626 (GLframebuffer
*) driReadPriv
->driverPrivate
);
628 intel
->ctx
.Driver
.DrawBuffer( &intel
->ctx
, intel
->ctx
.Color
.DrawBuffer
[0] );
630 _mesa_make_current(NULL
, NULL
, NULL
);
637 * Use the information in the sarea to update the screen parameters
638 * related to screen rotation.
641 intelUpdateScreenRotation(intelContextPtr intel
,
642 __DRIscreenPrivate
*sPriv
,
645 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)sPriv
->private;
646 intelRegion
*colorBuf
;
648 intelUnmapScreenRegions(intelScreen
);
650 intelUpdateScreenFromSAREA(intelScreen
, sarea
);
652 /* update the current hw offsets for the color and depth buffers */
653 if (intel
->ctx
.DrawBuffer
->_ColorDrawBufferMask
[0] == BUFFER_BIT_BACK_LEFT
)
654 colorBuf
= &intelScreen
->back
;
656 colorBuf
= &intelScreen
->front
;
657 intel
->vtbl
.update_color_z_regions(intel
, colorBuf
, &intelScreen
->depth
);
659 if (!intelMapScreenRegions(sPriv
)) {
660 fprintf(stderr
, "ERROR Remapping screen regions!!!\n");
664 void intelGetLock( intelContextPtr intel
, GLuint flags
)
666 __DRIdrawablePrivate
*dPriv
= intel
->driDrawable
;
667 __DRIscreenPrivate
*sPriv
= intel
->driScreen
;
668 intelScreenPrivate
*intelScreen
= (intelScreenPrivate
*)sPriv
->private;
669 drmI830Sarea
* sarea
= intel
->sarea
;
672 drmGetLock(intel
->driFd
, intel
->hHWContext
, flags
);
674 /* If the window moved, may need to set a new cliprect now.
676 * NOTE: This releases and regains the hw lock, so all state
677 * checking must be done *after* this call:
680 DRI_VALIDATE_DRAWABLE_INFO(sPriv
, dPriv
);
682 if (dPriv
&& intel
->lastStamp
!= dPriv
->lastStamp
) {
683 intelWindowMoved( intel
);
684 intel
->lastStamp
= dPriv
->lastStamp
;
687 /* If we lost context, need to dump all registers to hardware.
688 * Note that we don't care about 2d contexts, even if they perform
689 * accelerated commands, so the DRI locking in the X server is even
690 * more broken than usual.
693 if (sarea
->width
!= intelScreen
->width
||
694 sarea
->height
!= intelScreen
->height
||
695 sarea
->rotation
!= intelScreen
->current_rotation
) {
696 intelUpdateScreenRotation(intel
, sPriv
, sarea
);
698 /* This will drop the outstanding batchbuffer on the floor */
699 intel
->batch
.ptr
-= (intel
->batch
.size
- intel
->batch
.space
);
700 intel
->batch
.space
= intel
->batch
.size
;
701 /* lose all primitives */
702 intel
->prim
.primitive
= ~0;
703 intel
->prim
.start_ptr
= 0;
704 intel
->prim
.flush
= 0;
705 intel
->vtbl
.lost_hardware( intel
);
707 intel
->lastStamp
= 0; /* force window update */
709 /* Release batch buffer
711 intelDestroyBatchBuffer(&intel
->ctx
);
712 intelInitBatchBuffer(&intel
->ctx
);
713 intel
->prim
.flush
= intel_emit_invarient_state
;
715 /* Still need to reset the global LRU?
717 intel_driReinitTextureHeap( intel
->texture_heaps
[0], intel
->intelScreen
->tex
.size
);
720 /* Shared texture managment - if another client has played with
721 * texture space, figure out which if any of our textures have been
722 * ejected, and update our global LRU.
724 for ( i
= 0 ; i
< intel
->nr_heaps
; i
++ ) {
725 DRI_AGE_TEXTURES( intel
->texture_heaps
[ i
] );
730 void intelSwapBuffers( __DRIdrawablePrivate
*dPriv
)
732 if (dPriv
->driContextPriv
&& dPriv
->driContextPriv
->driverPrivate
) {
733 intelContextPtr intel
;
735 intel
= (intelContextPtr
) dPriv
->driContextPriv
->driverPrivate
;
737 if (ctx
->Visual
.doubleBufferMode
) {
738 intelScreenPrivate
*screen
= intel
->intelScreen
;
739 _mesa_notifySwapBuffers( ctx
); /* flush pending rendering comands */
740 if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */
741 intelPageFlip( dPriv
);
743 intelCopyBuffer( dPriv
, NULL
);
745 if (screen
->current_rotation
!= 0) {
746 intelRotateWindow(intel
, dPriv
, BUFFER_BIT_FRONT_LEFT
);
750 /* XXX this shouldn't be an error but we can't handle it for now */
751 fprintf(stderr
, "%s: drawable has no context!\n", __FUNCTION__
);
755 void intelCopySubBuffer( __DRIdrawablePrivate
*dPriv
,
756 int x
, int y
, int w
, int h
)
758 if (dPriv
->driContextPriv
&& dPriv
->driContextPriv
->driverPrivate
) {
759 intelContextPtr intel
;
761 intel
= (intelContextPtr
) dPriv
->driContextPriv
->driverPrivate
;
763 if (ctx
->Visual
.doubleBufferMode
) {
764 drm_clip_rect_t rect
;
765 rect
.x1
= x
+ dPriv
->x
;
766 rect
.y1
= (dPriv
->h
- y
- h
) + dPriv
->y
;
767 rect
.x2
= rect
.x1
+ w
;
768 rect
.y2
= rect
.y1
+ h
;
769 _mesa_notifySwapBuffers( ctx
); /* flush pending rendering comands */
770 intelCopyBuffer( dPriv
, &rect
);
773 /* XXX this shouldn't be an error but we can't handle it for now */
774 fprintf(stderr
, "%s: drawable has no context!\n", __FUNCTION__
);