Add GL_ARB_texture_cube_map support for i830. Most of the code was
[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 "20040919"
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 /* driInitTextureObjects( ctx, & intel->swapped, */
358 /* DRI_TEXMGR_DO_TEXTURE_1D | */
359 /* DRI_TEXMGR_DO_TEXTURE_2D | */
360 /* DRI_TEXMGR_DO_TEXTURE_RECT ); */
361
362
363 intel->prim.flush = intelInitBatchBuffer;
364 intel->prim.primitive = ~0;
365
366
367 #if DO_DEBUG
368 INTEL_DEBUG = driParseDebugString( getenv( "INTEL_DEBUG" ),
369 debug_control );
370 INTEL_DEBUG |= driParseDebugString( getenv( "INTEL_DEBUG" ),
371 debug_control );
372 #endif
373
374 #ifndef VERBOSE
375 if (getenv("INTEL_VERBOSE"))
376 VERBOSE=1;
377 #endif
378
379 if (getenv("INTEL_NO_RAST") ||
380 getenv("INTEL_NO_RAST")) {
381 fprintf(stderr, "disabling 3D rasterization\n");
382 FALLBACK(intel, INTEL_FALLBACK_USER, 1);
383 }
384
385 return GL_TRUE;
386 }
387
388 void intelDestroyContext(__DRIcontextPrivate *driContextPriv)
389 {
390 intelContextPtr intel = (intelContextPtr) driContextPriv->driverPrivate;
391
392 assert(intel); /* should never be null */
393 if (intel) {
394 GLboolean release_texture_heaps;
395
396
397 intel->vtbl.destroy( intel );
398
399 release_texture_heaps = (intel->ctx.Shared->RefCount == 1);
400 _swsetup_DestroyContext (&intel->ctx);
401 _tnl_DestroyContext (&intel->ctx);
402 _ac_DestroyContext (&intel->ctx);
403
404 _swrast_DestroyContext (&intel->ctx);
405 intel->Fallback = 0; /* don't call _swrast_Flush later */
406
407 intelDestroyBatchBuffer(&intel->ctx);
408
409
410 if ( release_texture_heaps ) {
411 /* This share group is about to go away, free our private
412 * texture object data.
413 */
414 int i;
415
416 for ( i = 0 ; i < intel->nr_heaps ; i++ ) {
417 driDestroyTextureHeap( intel->texture_heaps[ i ] );
418 intel->texture_heaps[ i ] = NULL;
419 }
420
421 assert( is_empty_list( & intel->swapped ) );
422 }
423
424 /* free the Mesa context */
425 _mesa_destroy_context(&intel->ctx);
426 }
427 }
428
429 void intelSetFrontClipRects( intelContextPtr intel )
430 {
431 __DRIdrawablePrivate *dPriv = intel->driDrawable;
432
433 if (!dPriv) return;
434
435 intel->numClipRects = dPriv->numClipRects;
436 intel->pClipRects = dPriv->pClipRects;
437 intel->drawX = dPriv->x;
438 intel->drawY = dPriv->y;
439 }
440
441
442 void intelSetBackClipRects( intelContextPtr intel )
443 {
444 __DRIdrawablePrivate *dPriv = intel->driDrawable;
445
446 if (!dPriv) return;
447
448 if (intel->sarea->pf_enabled == 0 && dPriv->numBackClipRects == 0) {
449 intel->numClipRects = dPriv->numClipRects;
450 intel->pClipRects = dPriv->pClipRects;
451 intel->drawX = dPriv->x;
452 intel->drawY = dPriv->y;
453 } else {
454 intel->numClipRects = dPriv->numBackClipRects;
455 intel->pClipRects = dPriv->pBackClipRects;
456 intel->drawX = dPriv->backX;
457 intel->drawY = dPriv->backY;
458
459 if (dPriv->numBackClipRects == 1 &&
460 dPriv->x == dPriv->backX &&
461 dPriv->y == dPriv->backY) {
462
463 /* Repeat the calculation of the back cliprect dimensions here
464 * as early versions of dri.a in the Xserver are incorrect. Try
465 * very hard not to restrict future versions of dri.a which
466 * might eg. allocate truly private back buffers.
467 */
468 int x1, y1;
469 int x2, y2;
470
471 x1 = dPriv->x;
472 y1 = dPriv->y;
473 x2 = dPriv->x + dPriv->w;
474 y2 = dPriv->y + dPriv->h;
475
476 if (x1 < 0) x1 = 0;
477 if (y1 < 0) y1 = 0;
478 if (x2 > intel->intelScreen->width) x2 = intel->intelScreen->width;
479 if (y2 > intel->intelScreen->height) y2 = intel->intelScreen->height;
480
481 if (x1 == dPriv->pBackClipRects[0].x1 &&
482 y1 == dPriv->pBackClipRects[0].y1) {
483
484 dPriv->pBackClipRects[0].x2 = x2;
485 dPriv->pBackClipRects[0].y2 = y2;
486 }
487 }
488 }
489 }
490
491
492 void intelWindowMoved( intelContextPtr intel )
493 {
494 switch (intel->ctx.Color._DrawDestMask) {
495 case DD_FRONT_LEFT_BIT:
496 intelSetFrontClipRects( intel );
497 break;
498 case DD_BACK_LEFT_BIT:
499 intelSetBackClipRects( intel );
500 break;
501 default:
502 /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */
503 intelSetFrontClipRects( intel );
504 }
505 }
506
507 GLboolean intelUnbindContext(__DRIcontextPrivate *driContextPriv)
508 {
509 return GL_TRUE;
510 }
511
512 GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
513 __DRIdrawablePrivate *driDrawPriv,
514 __DRIdrawablePrivate *driReadPriv)
515 {
516
517 if (driContextPriv) {
518 intelContextPtr intel = (intelContextPtr) driContextPriv->driverPrivate;
519
520 if ( intel->driDrawable != driDrawPriv ) {
521 /* Shouldn't the readbuffer be stored also? */
522 intel->driDrawable = driDrawPriv;
523 intelWindowMoved( intel );
524 }
525
526 _mesa_make_current2(&intel->ctx,
527 (GLframebuffer *) driDrawPriv->driverPrivate,
528 (GLframebuffer *) driReadPriv->driverPrivate);
529
530 if (!intel->ctx.Viewport.Width)
531 _mesa_set_viewport(&intel->ctx, 0, 0, driDrawPriv->w, driDrawPriv->h);
532 } else {
533 _mesa_make_current(0,0);
534 }
535
536 return GL_TRUE;
537 }
538
539 void intelGetLock( intelContextPtr intel, GLuint flags )
540 {
541 __DRIdrawablePrivate *dPriv = intel->driDrawable;
542 __DRIscreenPrivate *sPriv = intel->driScreen;
543 drmI830Sarea * sarea = intel->sarea;
544 int me = intel->hHWContext;
545 unsigned i;
546
547 drmGetLock(intel->driFd, intel->hHWContext, flags);
548
549 /* If the window moved, may need to set a new cliprect now.
550 *
551 * NOTE: This releases and regains the hw lock, so all state
552 * checking must be done *after* this call:
553 */
554 if (dPriv)
555 DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
556
557 /* If we lost context, need to dump all registers to hardware.
558 * Note that we don't care about 2d contexts, even if they perform
559 * accelerated commands, so the DRI locking in the X server is even
560 * more broken than usual.
561 */
562
563 if (sarea->ctxOwner != me) {
564 intel->perf_boxes |= I830_BOX_LOST_CONTEXT;
565 sarea->ctxOwner = me;
566 }
567
568 /* Shared texture managment - if another client has played with
569 * texture space, figure out which if any of our textures have been
570 * ejected, and update our global LRU.
571 */
572
573 for ( i = 0 ; i < intel->nr_heaps ; i++ ) {
574 DRI_AGE_TEXTURES( intel->texture_heaps[ i ] );
575 }
576
577 if (dPriv && intel->lastStamp != dPriv->lastStamp) {
578 intelWindowMoved( intel );
579 intel->lastStamp = dPriv->lastStamp;
580 }
581 }
582
583 void intelSwapBuffers( __DRIdrawablePrivate *dPriv )
584 {
585 if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
586 intelContextPtr intel;
587 GLcontext *ctx;
588 intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
589 ctx = &intel->ctx;
590 if (ctx->Visual.doubleBufferMode) {
591 _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
592 if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */
593 intelPageFlip( dPriv );
594 } else {
595 intelCopyBuffer( dPriv );
596 }
597 }
598 } else {
599 /* XXX this shouldn't be an error but we can't handle it for now */
600 fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
601 }
602 }
603
604
605 void intelInitState( GLcontext *ctx )
606 {
607 /* Mesa should do this for us:
608 */
609 ctx->Driver.AlphaFunc( ctx,
610 ctx->Color.AlphaFunc,
611 ctx->Color.AlphaRef);
612
613 ctx->Driver.BlendColor( ctx,
614 ctx->Color.BlendColor );
615
616 ctx->Driver.BlendEquationSeparate( ctx,
617 ctx->Color.BlendEquationRGB,
618 ctx->Color.BlendEquationA);
619
620 ctx->Driver.BlendFuncSeparate( ctx,
621 ctx->Color.BlendSrcRGB,
622 ctx->Color.BlendDstRGB,
623 ctx->Color.BlendSrcA,
624 ctx->Color.BlendDstA);
625
626 ctx->Driver.ColorMask( ctx,
627 ctx->Color.ColorMask[RCOMP],
628 ctx->Color.ColorMask[GCOMP],
629 ctx->Color.ColorMask[BCOMP],
630 ctx->Color.ColorMask[ACOMP]);
631
632 ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode );
633 ctx->Driver.DepthFunc( ctx, ctx->Depth.Func );
634 ctx->Driver.DepthMask( ctx, ctx->Depth.Mask );
635
636 ctx->Driver.Enable( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled );
637 ctx->Driver.Enable( ctx, GL_BLEND, ctx->Color.BlendEnabled );
638 ctx->Driver.Enable( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled );
639 ctx->Driver.Enable( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled );
640 ctx->Driver.Enable( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag );
641 ctx->Driver.Enable( ctx, GL_DEPTH_TEST, ctx->Depth.Test );
642 ctx->Driver.Enable( ctx, GL_DITHER, ctx->Color.DitherFlag );
643 ctx->Driver.Enable( ctx, GL_FOG, ctx->Fog.Enabled );
644 ctx->Driver.Enable( ctx, GL_LIGHTING, ctx->Light.Enabled );
645 ctx->Driver.Enable( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
646 ctx->Driver.Enable( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag );
647 ctx->Driver.Enable( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
648 ctx->Driver.Enable( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
649 ctx->Driver.Enable( ctx, GL_TEXTURE_1D, GL_FALSE );
650 ctx->Driver.Enable( ctx, GL_TEXTURE_2D, GL_FALSE );
651 ctx->Driver.Enable( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE );
652 ctx->Driver.Enable( ctx, GL_TEXTURE_3D, GL_FALSE );
653 ctx->Driver.Enable( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE );
654
655 ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
656 ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 );
657 ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
658 ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
659 ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
660
661 ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace );
662
663 {
664 GLfloat f = (GLfloat)ctx->Light.Model.ColorControl;
665 ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f );
666 }
667
668 ctx->Driver.LineWidth( ctx, ctx->Line.Width );
669 ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
670 ctx->Driver.PointSize( ctx, ctx->Point.Size );
671 ctx->Driver.PolygonStipple( ctx, (const GLubyte *)ctx->PolygonStipple );
672 ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
673 ctx->Scissor.Width, ctx->Scissor.Height );
674 ctx->Driver.ShadeModel( ctx, ctx->Light.ShadeModel );
675 ctx->Driver.StencilFunc( ctx,
676 ctx->Stencil.Function[0],
677 ctx->Stencil.Ref[0],
678 ctx->Stencil.ValueMask[0] );
679 ctx->Driver.StencilMask( ctx, ctx->Stencil.WriteMask[0] );
680 ctx->Driver.StencilOp( ctx,
681 ctx->Stencil.FailFunc[0],
682 ctx->Stencil.ZFailFunc[0],
683 ctx->Stencil.ZPassFunc[0]);
684
685
686 ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer );
687 }