Fixed off by one errors in clipping.
[mesa.git] / src / mesa / drivers / dri / i915 / intel_context.c
1 /**************************************************************************
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28
29 #include "glheader.h"
30 #include "context.h"
31 #include "matrix.h"
32 #include "simple_list.h"
33 #include "extensions.h"
34 #include "imports.h"
35
36 #include "swrast/swrast.h"
37 #include "swrast_setup/swrast_setup.h"
38 #include "tnl/tnl.h"
39 #include "array_cache/acache.h"
40
41 #include "tnl/t_pipeline.h"
42 #include "tnl/t_vertex.h"
43
44 #include "drivers/common/driverfuncs.h"
45
46 #include "intel_screen.h"
47
48 #include "i830_dri.h"
49 #include "i830_common.h"
50
51 #include "intel_tex.h"
52 #include "intel_span.h"
53 #include "intel_tris.h"
54 #include "intel_ioctl.h"
55 #include "intel_batchbuffer.h"
56
57 #include "utils.h"
58 #ifndef INTEL_DEBUG
59 int INTEL_DEBUG = (0);
60 #endif
61
62 #ifndef VERBOSE
63 int VERBOSE = 0;
64 #endif
65
66 #if DEBUG_LOCKING
67 char *prevLockFile;
68 int prevLockLine;
69 #endif
70
71 /***************************************
72 * Mesa's Driver Functions
73 ***************************************/
74
75 #define DRIVER_DATE "20041007"
76
77 const GLubyte *intelGetString( GLcontext *ctx, GLenum name )
78 {
79 const char * chipset;
80 static char buffer[128];
81
82 switch (name) {
83 case GL_VENDOR:
84 return (GLubyte *)"Tungsten Graphics, Inc";
85 break;
86
87 case GL_RENDERER:
88 switch (INTEL_CONTEXT(ctx)->intelScreen->deviceID) {
89 case PCI_CHIP_845_G:
90 chipset = "Intel(R) 845G"; break;
91 case PCI_CHIP_I830_M:
92 chipset = "Intel(R) 830M"; break;
93 case PCI_CHIP_I855_GM:
94 chipset = "Intel(R) 852GM/855GM"; break;
95 case PCI_CHIP_I865_G:
96 chipset = "Intel(R) 865G"; break;
97 case PCI_CHIP_I915_G:
98 chipset = "Intel(R) 915G"; break;
99 default:
100 chipset = "Unknown Intel Chipset"; break;
101 }
102
103 (void) driGetRendererString( buffer, chipset, DRIVER_DATE, 0 );
104 return (GLubyte *) buffer;
105
106 default:
107 return NULL;
108 }
109 }
110
111 static void intelBufferSize(GLframebuffer *buffer,
112 GLuint *width, GLuint *height)
113 {
114 GET_CURRENT_CONTEXT(ctx);
115 intelContextPtr intel = INTEL_CONTEXT(ctx);
116 /* Need to lock to make sure the driDrawable is uptodate. This
117 * information is used to resize Mesa's software buffers, so it has
118 * to be correct.
119 */
120 LOCK_HARDWARE(intel);
121 *width = intel->driDrawable->w;
122 *height = intel->driDrawable->h;
123 UNLOCK_HARDWARE(intel);
124 }
125
126
127
128 /**
129 * Extension strings exported by the intel driver.
130 *
131 * \note
132 * It appears that ARB_texture_env_crossbar and NV_blend_square have
133 * "disappeared" compared to the old i830-specific driver.
134 *
135 * \note
136 * See implementation of \c glGetString in each hw_context.c file:
137 * This set of extensions is overridden and many are not actually
138 * exported to the driver. They are however enabled internally as
139 * Mesa requires this when calculating things like GL version number.
140 */
141 static const char * const card_extensions[] =
142 {
143 "GL_ARB_multisample",
144 "GL_ARB_multitexture",
145 "GL_ARB_point_parameters",
146 "GL_ARB_texture_border_clamp",
147 "GL_ARB_texture_cube_map",
148 "GL_ARB_texture_compression",
149 "GL_ARB_texture_env_add",
150 "GL_ARB_texture_env_combine",
151 "GL_ARB_texture_env_dot3",
152 "GL_ARB_texture_mirrored_repeat",
153 "GL_ARB_texture_rectangle",
154 "GL_ARB_vertex_buffer_object",
155 "GL_ARB_vertex_program",
156 "GL_ARB_window_pos",
157
158 "GL_EXT_abgr",
159 "GL_EXT_bgra",
160 "GL_EXT_blend_color",
161 "GL_EXT_blend_equation_separate",
162 "GL_EXT_blend_func_separate",
163 "GL_EXT_blend_minmax",
164 "GL_EXT_blend_subtract",
165 "GL_EXT_fog_coord",
166 "GL_EXT_multi_draw_arrays",
167 "GL_EXT_secondary_color",
168 "GL_EXT_stencil_wrap",
169 "GL_EXT_texture_edge_clamp",
170 "GL_EXT_texture_env_combine",
171 "GL_EXT_texture_env_dot3",
172 "GL_EXT_texture_filter_anisotropic",
173 "GL_EXT_texture_lod_bias",
174
175 "GL_3DFX_texture_compression_FXT1",
176 "GL_APPLE_client_storage",
177 "GL_MESA_pack_invert",
178 "GL_MESA_ycbcr_texture",
179 "GL_NV_vertex_program",
180 "GL_NV_vertex_program1_1",
181 "GL_SGIS_generate_mipmap",
182
183 NULL
184 };
185
186
187 extern const struct tnl_pipeline_stage _intel_render_stage;
188
189 static const struct tnl_pipeline_stage *intel_pipeline[] = {
190 &_tnl_vertex_transform_stage,
191 &_tnl_normal_transform_stage,
192 &_tnl_lighting_stage,
193 &_tnl_fog_coordinate_stage,
194 &_tnl_texgen_stage,
195 &_tnl_texture_transform_stage,
196 &_tnl_point_attenuation_stage,
197 &_tnl_vertex_program_stage,
198 #if 1
199 &_intel_render_stage, /* ADD: unclipped rastersetup-to-dma */
200 #endif
201 &_tnl_render_stage,
202 0,
203 };
204
205
206 static const struct dri_debug_control debug_control[] =
207 {
208 { "fall", DEBUG_FALLBACKS },
209 { "tex", DEBUG_TEXTURE },
210 { "ioctl", DEBUG_IOCTL },
211 { "prim", DEBUG_PRIMS },
212 { "vert", DEBUG_VERTS },
213 { "state", DEBUG_STATE },
214 { "verb", DEBUG_VERBOSE },
215 { "dri", DEBUG_DRI },
216 { "dma", DEBUG_DMA },
217 { "san", DEBUG_SANITY },
218 { "sync", DEBUG_SYNC },
219 { "sleep", DEBUG_SLEEP },
220 { "pix", DEBUG_PIXEL },
221 { NULL, 0 }
222 };
223
224
225 static void intelInvalidateState( GLcontext *ctx, GLuint new_state )
226 {
227 _swrast_InvalidateState( ctx, new_state );
228 _swsetup_InvalidateState( ctx, new_state );
229 _ac_InvalidateState( ctx, new_state );
230 _tnl_InvalidateState( ctx, new_state );
231 _tnl_invalidate_vertex_state( ctx, new_state );
232 INTEL_CONTEXT(ctx)->NewGLState |= new_state;
233 }
234
235
236 void intelInitDriverFunctions( struct dd_function_table *functions )
237 {
238 _mesa_init_driver_functions( functions );
239
240 functions->Flush = intelFlush;
241 functions->Clear = intelClear;
242 functions->Finish = intelFinish;
243 functions->GetBufferSize = intelBufferSize;
244 functions->ResizeBuffers = _swrast_alloc_buffers;
245 functions->GetString = intelGetString;
246 functions->UpdateState = intelInvalidateState;
247 functions->CopyColorTable = _swrast_CopyColorTable;
248 functions->CopyColorSubTable = _swrast_CopyColorSubTable;
249 functions->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
250 functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
251
252 intelInitTextureFuncs( functions );
253 intelInitPixelFuncs( functions );
254 intelInitStateFuncs( functions );
255 }
256
257
258
259 GLboolean intelInitContext( intelContextPtr intel,
260 const __GLcontextModes *mesaVis,
261 __DRIcontextPrivate *driContextPriv,
262 void *sharedContextPrivate,
263 struct dd_function_table *functions )
264 {
265 GLcontext *ctx = &intel->ctx;
266 GLcontext *shareCtx = (GLcontext *) sharedContextPrivate;
267 __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
268 intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private;
269 drmI830Sarea *saPriv = (drmI830Sarea *)
270 (((GLubyte *)sPriv->pSAREA)+intelScreen->sarea_priv_offset);
271
272 if (!_mesa_initialize_context(&intel->ctx,
273 mesaVis, shareCtx,
274 functions,
275 (void*) intel))
276 return GL_FALSE;
277
278 driContextPriv->driverPrivate = intel;
279 intel->intelScreen = intelScreen;
280 intel->driScreen = sPriv;
281 intel->sarea = saPriv;
282
283
284 (void) memset( intel->texture_heaps, 0, sizeof( intel->texture_heaps ) );
285 make_empty_list( & intel->swapped );
286
287 ctx->Const.MaxTextureMaxAnisotropy = 2.0;
288
289 ctx->Const.MinLineWidth = 1.0;
290 ctx->Const.MinLineWidthAA = 1.0;
291 ctx->Const.MaxLineWidth = 3.0;
292 ctx->Const.MaxLineWidthAA = 3.0;
293 ctx->Const.LineWidthGranularity = 1.0;
294
295 ctx->Const.MinPointSize = 1.0;
296 ctx->Const.MinPointSizeAA = 1.0;
297 ctx->Const.MaxPointSize = 255.0;
298 ctx->Const.MaxPointSizeAA = 3.0;
299 ctx->Const.PointSizeGranularity = 1.0;
300
301 /* Initialize the software rasterizer and helper modules. */
302 _swrast_CreateContext( ctx );
303 _ac_CreateContext( ctx );
304 _tnl_CreateContext( ctx );
305 _swsetup_CreateContext( ctx );
306
307 /* Install the customized pipeline: */
308 _tnl_destroy_pipeline( ctx );
309 _tnl_install_pipeline( ctx, intel_pipeline );
310
311 /* Configure swrast to match hardware characteristics: */
312 _swrast_allow_pixel_fog( ctx, GL_FALSE );
313 _swrast_allow_vertex_fog( ctx, GL_TRUE );
314
315 /* Dri stuff */
316 intel->hHWContext = driContextPriv->hHWContext;
317 intel->driFd = sPriv->fd;
318 intel->driHwLock = (drmLock *) &sPriv->pSAREA->lock;
319
320 intel->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
321 intel->hw_stipple = 1;
322
323 switch(mesaVis->depthBits) {
324 case 0: /* what to do in this case? */
325 case 16:
326 intel->depth_scale = 1.0/0xffff;
327 intel->polygon_offset_scale = 1.0/0xffff;
328 intel->depth_clear_mask = ~0;
329 intel->ClearDepth = 0xffff;
330 break;
331 case 24:
332 intel->depth_scale = 1.0/0xffffff;
333 intel->polygon_offset_scale = 2.0/0xffffff; /* req'd to pass glean */
334 intel->depth_clear_mask = 0x00ffffff;
335 intel->stencil_clear_mask = 0xff000000;
336 intel->ClearDepth = 0x00ffffff;
337 break;
338 default:
339 assert(0);
340 break;
341 }
342
343 /* Initialize swrast, tnl driver tables: */
344 intelInitSpanFuncs( ctx );
345 intelInitTriFuncs( ctx );
346
347
348 intel->RenderIndex = ~0;
349
350 intel->do_irqs = (intel->intelScreen->irq_active &&
351 !getenv("INTEL_NO_IRQS"));
352
353 _math_matrix_ctr (&intel->ViewportMatrix);
354
355 driInitExtensions( ctx, card_extensions, GL_TRUE );
356
357 if (intel->ctx.Mesa_DXTn) {
358 _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
359 _mesa_enable_extension( ctx, "GL_S3_s3tc" );
360 }
361 else if (driQueryOptionb (&intelScreen->optionCache, "force_s3tc_enable")) {
362 _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
363 }
364
365 /* driInitTextureObjects( ctx, & intel->swapped, */
366 /* DRI_TEXMGR_DO_TEXTURE_1D | */
367 /* DRI_TEXMGR_DO_TEXTURE_2D | */
368 /* DRI_TEXMGR_DO_TEXTURE_RECT ); */
369
370
371 intel->prim.flush = intelInitBatchBuffer;
372 intel->prim.primitive = ~0;
373
374
375 #if DO_DEBUG
376 INTEL_DEBUG = driParseDebugString( getenv( "INTEL_DEBUG" ),
377 debug_control );
378 INTEL_DEBUG |= driParseDebugString( getenv( "INTEL_DEBUG" ),
379 debug_control );
380 #endif
381
382 #ifndef VERBOSE
383 if (getenv("INTEL_VERBOSE"))
384 VERBOSE=1;
385 #endif
386
387 if (getenv("INTEL_NO_RAST") ||
388 getenv("INTEL_NO_RAST")) {
389 fprintf(stderr, "disabling 3D rasterization\n");
390 FALLBACK(intel, INTEL_FALLBACK_USER, 1);
391 }
392
393 return GL_TRUE;
394 }
395
396 void intelDestroyContext(__DRIcontextPrivate *driContextPriv)
397 {
398 intelContextPtr intel = (intelContextPtr) driContextPriv->driverPrivate;
399
400 assert(intel); /* should never be null */
401 if (intel) {
402 GLboolean release_texture_heaps;
403
404
405 intel->vtbl.destroy( intel );
406
407 release_texture_heaps = (intel->ctx.Shared->RefCount == 1);
408 _swsetup_DestroyContext (&intel->ctx);
409 _tnl_DestroyContext (&intel->ctx);
410 _ac_DestroyContext (&intel->ctx);
411
412 _swrast_DestroyContext (&intel->ctx);
413 intel->Fallback = 0; /* don't call _swrast_Flush later */
414
415 intelDestroyBatchBuffer(&intel->ctx);
416
417
418 if ( release_texture_heaps ) {
419 /* This share group is about to go away, free our private
420 * texture object data.
421 */
422 int i;
423
424 for ( i = 0 ; i < intel->nr_heaps ; i++ ) {
425 driDestroyTextureHeap( intel->texture_heaps[ i ] );
426 intel->texture_heaps[ i ] = NULL;
427 }
428
429 assert( is_empty_list( & intel->swapped ) );
430 }
431
432 /* free the Mesa context */
433 _mesa_destroy_context(&intel->ctx);
434 }
435 }
436
437 void intelSetFrontClipRects( intelContextPtr intel )
438 {
439 __DRIdrawablePrivate *dPriv = intel->driDrawable;
440
441 if (!dPriv) return;
442
443 intel->numClipRects = dPriv->numClipRects;
444 intel->pClipRects = dPriv->pClipRects;
445 intel->drawX = dPriv->x;
446 intel->drawY = dPriv->y;
447 }
448
449
450 void intelSetBackClipRects( intelContextPtr intel )
451 {
452 __DRIdrawablePrivate *dPriv = intel->driDrawable;
453
454 if (!dPriv) return;
455
456 if (intel->sarea->pf_enabled == 0 && dPriv->numBackClipRects == 0) {
457 intel->numClipRects = dPriv->numClipRects;
458 intel->pClipRects = dPriv->pClipRects;
459 intel->drawX = dPriv->x;
460 intel->drawY = dPriv->y;
461 } else {
462 intel->numClipRects = dPriv->numBackClipRects;
463 intel->pClipRects = dPriv->pBackClipRects;
464 intel->drawX = dPriv->backX;
465 intel->drawY = dPriv->backY;
466
467 if (dPriv->numBackClipRects == 1 &&
468 dPriv->x == dPriv->backX &&
469 dPriv->y == dPriv->backY) {
470
471 /* Repeat the calculation of the back cliprect dimensions here
472 * as early versions of dri.a in the Xserver are incorrect. Try
473 * very hard not to restrict future versions of dri.a which
474 * might eg. allocate truly private back buffers.
475 */
476 int x1, y1;
477 int x2, y2;
478
479 x1 = dPriv->x;
480 y1 = dPriv->y;
481 x2 = dPriv->x + dPriv->w;
482 y2 = dPriv->y + dPriv->h;
483
484 if (x1 < 0) x1 = 0;
485 if (y1 < 0) y1 = 0;
486 if (x2 > intel->intelScreen->width) x2 = intel->intelScreen->width;
487 if (y2 > intel->intelScreen->height) y2 = intel->intelScreen->height;
488
489 if (x1 == dPriv->pBackClipRects[0].x1 &&
490 y1 == dPriv->pBackClipRects[0].y1) {
491
492 dPriv->pBackClipRects[0].x2 = x2;
493 dPriv->pBackClipRects[0].y2 = y2;
494 }
495 }
496 }
497 }
498
499
500 void intelWindowMoved( intelContextPtr intel )
501 {
502 switch (intel->ctx.Color._DrawDestMask[0]) {
503 case DD_FRONT_LEFT_BIT:
504 intelSetFrontClipRects( intel );
505 break;
506 case DD_BACK_LEFT_BIT:
507 intelSetBackClipRects( intel );
508 break;
509 default:
510 /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */
511 intelSetFrontClipRects( intel );
512 }
513 }
514
515 GLboolean intelUnbindContext(__DRIcontextPrivate *driContextPriv)
516 {
517 return GL_TRUE;
518 }
519
520 GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
521 __DRIdrawablePrivate *driDrawPriv,
522 __DRIdrawablePrivate *driReadPriv)
523 {
524
525 if (driContextPriv) {
526 intelContextPtr intel = (intelContextPtr) driContextPriv->driverPrivate;
527
528 if ( intel->driDrawable != driDrawPriv ) {
529 /* Shouldn't the readbuffer be stored also? */
530 intel->driDrawable = driDrawPriv;
531 intelWindowMoved( intel );
532 }
533
534 _mesa_make_current2(&intel->ctx,
535 (GLframebuffer *) driDrawPriv->driverPrivate,
536 (GLframebuffer *) driReadPriv->driverPrivate);
537
538 if (!intel->ctx.Viewport.Width)
539 _mesa_set_viewport(&intel->ctx, 0, 0, driDrawPriv->w, driDrawPriv->h);
540 } else {
541 _mesa_make_current(0,0);
542 }
543
544 return GL_TRUE;
545 }
546
547 void intelGetLock( intelContextPtr intel, GLuint flags )
548 {
549 __DRIdrawablePrivate *dPriv = intel->driDrawable;
550 __DRIscreenPrivate *sPriv = intel->driScreen;
551 drmI830Sarea * sarea = intel->sarea;
552 int me = intel->hHWContext;
553 unsigned i;
554
555 drmGetLock(intel->driFd, intel->hHWContext, flags);
556
557 /* If the window moved, may need to set a new cliprect now.
558 *
559 * NOTE: This releases and regains the hw lock, so all state
560 * checking must be done *after* this call:
561 */
562 if (dPriv)
563 DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
564
565 /* If we lost context, need to dump all registers to hardware.
566 * Note that we don't care about 2d contexts, even if they perform
567 * accelerated commands, so the DRI locking in the X server is even
568 * more broken than usual.
569 */
570
571 if (sarea->ctxOwner != me) {
572 intel->perf_boxes |= I830_BOX_LOST_CONTEXT;
573 sarea->ctxOwner = me;
574 }
575
576 /* Shared texture managment - if another client has played with
577 * texture space, figure out which if any of our textures have been
578 * ejected, and update our global LRU.
579 */
580
581 for ( i = 0 ; i < intel->nr_heaps ; i++ ) {
582 DRI_AGE_TEXTURES( intel->texture_heaps[ i ] );
583 }
584
585 if (dPriv && intel->lastStamp != dPriv->lastStamp) {
586 intelWindowMoved( intel );
587 intel->lastStamp = dPriv->lastStamp;
588 }
589 }
590
591 void intelSwapBuffers( __DRIdrawablePrivate *dPriv )
592 {
593 if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
594 intelContextPtr intel;
595 GLcontext *ctx;
596 intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
597 ctx = &intel->ctx;
598 if (ctx->Visual.doubleBufferMode) {
599 _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
600 if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */
601 intelPageFlip( dPriv );
602 } else {
603 intelCopyBuffer( dPriv );
604 }
605 }
606 } else {
607 /* XXX this shouldn't be an error but we can't handle it for now */
608 fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
609 }
610 }
611
612
613 void intelInitState( GLcontext *ctx )
614 {
615 /* Mesa should do this for us:
616 */
617 ctx->Driver.AlphaFunc( ctx,
618 ctx->Color.AlphaFunc,
619 ctx->Color.AlphaRef);
620
621 ctx->Driver.BlendColor( ctx,
622 ctx->Color.BlendColor );
623
624 ctx->Driver.BlendEquationSeparate( ctx,
625 ctx->Color.BlendEquationRGB,
626 ctx->Color.BlendEquationA);
627
628 ctx->Driver.BlendFuncSeparate( ctx,
629 ctx->Color.BlendSrcRGB,
630 ctx->Color.BlendDstRGB,
631 ctx->Color.BlendSrcA,
632 ctx->Color.BlendDstA);
633
634 ctx->Driver.ColorMask( ctx,
635 ctx->Color.ColorMask[RCOMP],
636 ctx->Color.ColorMask[GCOMP],
637 ctx->Color.ColorMask[BCOMP],
638 ctx->Color.ColorMask[ACOMP]);
639
640 ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode );
641 ctx->Driver.DepthFunc( ctx, ctx->Depth.Func );
642 ctx->Driver.DepthMask( ctx, ctx->Depth.Mask );
643
644 ctx->Driver.Enable( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled );
645 ctx->Driver.Enable( ctx, GL_BLEND, ctx->Color.BlendEnabled );
646 ctx->Driver.Enable( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled );
647 ctx->Driver.Enable( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled );
648 ctx->Driver.Enable( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag );
649 ctx->Driver.Enable( ctx, GL_DEPTH_TEST, ctx->Depth.Test );
650 ctx->Driver.Enable( ctx, GL_DITHER, ctx->Color.DitherFlag );
651 ctx->Driver.Enable( ctx, GL_FOG, ctx->Fog.Enabled );
652 ctx->Driver.Enable( ctx, GL_LIGHTING, ctx->Light.Enabled );
653 ctx->Driver.Enable( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
654 ctx->Driver.Enable( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag );
655 ctx->Driver.Enable( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
656 ctx->Driver.Enable( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
657 ctx->Driver.Enable( ctx, GL_TEXTURE_1D, GL_FALSE );
658 ctx->Driver.Enable( ctx, GL_TEXTURE_2D, GL_FALSE );
659 ctx->Driver.Enable( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE );
660 ctx->Driver.Enable( ctx, GL_TEXTURE_3D, GL_FALSE );
661 ctx->Driver.Enable( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE );
662
663 ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
664 ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 );
665 ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
666 ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
667 ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
668
669 ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace );
670
671 {
672 GLfloat f = (GLfloat)ctx->Light.Model.ColorControl;
673 ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f );
674 }
675
676 ctx->Driver.LineWidth( ctx, ctx->Line.Width );
677 ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
678 ctx->Driver.PointSize( ctx, ctx->Point.Size );
679 ctx->Driver.PolygonStipple( ctx, (const GLubyte *)ctx->PolygonStipple );
680 ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
681 ctx->Scissor.Width, ctx->Scissor.Height );
682 ctx->Driver.ShadeModel( ctx, ctx->Light.ShadeModel );
683 ctx->Driver.StencilFunc( ctx,
684 ctx->Stencil.Function[0],
685 ctx->Stencil.Ref[0],
686 ctx->Stencil.ValueMask[0] );
687 ctx->Driver.StencilMask( ctx, ctx->Stencil.WriteMask[0] );
688 ctx->Driver.StencilOp( ctx,
689 ctx->Stencil.FailFunc[0],
690 ctx->Stencil.ZFailFunc[0],
691 ctx->Stencil.ZPassFunc[0]);
692
693
694 ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
695 }