1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
|
/*
* Author: Max Lingua <sunmax@libero.it>
*/
#include <X11/Xlibint.h>
#include "s3v_context.h"
#include "s3v_macros.h"
#include "macros.h"
#include "s3v_dri.h"
#include "colormac.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "vbo/vbo.h"
#include "tnl/tnl.h"
/* #define DEBUG(str) printf str */
#define ENABLELIGHTING 0
/* =============================================================
* Alpha blending
*/
static void s3vUpdateAlphaMode( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
CARD32 cmd = vmesa->CMD;
cmd &= ~ALPHA_BLEND_MASK;
if ( ctx->Color.BlendEnabled ) {
DEBUG(("ctx->Color.AlphaEnabled = 1"));
vmesa->_alpha[0] = ALPHA_SRC;
vmesa->_alpha[1] = vmesa->_alpha_tex; /* FIXME: not all tex modes
support alpha */
} else {
DEBUG(("ctx->Color.AlphaEnabled = 0"));
vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF;
}
#if 1
if ((cmd & DO_MASK) & DO_3D_LINE) { /* we are drawing 3d lines */
/* which don't support tex */
cmd |= vmesa->_alpha[0];
} else {
cmd |= vmesa->_alpha[vmesa->_3d_mode];
}
vmesa->CMD = cmd; /* FIXME: enough? */
#else
vmesa->restore_primitive = -1;
#endif
}
static void s3vDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
DEBUG(("s3vDDAlphaFunc\n"));
vmesa->new_state |= S3V_NEW_ALPHA;
}
static void s3vDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
DEBUG(("s3vDDBlendFunc\n"));
vmesa->new_state |= S3V_NEW_ALPHA;
}
/* ================================================================
* Buffer clear
*/
static void s3vDDClear( GLcontext *ctx, GLbitfield mask )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
unsigned int _stride;
GLint cx = ctx->DrawBuffer->_Xmin;
GLint cy = ctx->DrawBuffer->_Ymin;
GLint cw = ctx->DrawBuffer->_Xmax - cx;
GLint ch = ctx->DrawBuffer->_Ymax - cy;
/* XXX FIX ME: the cx,cy,cw,ch vars are currently ignored! */
vmesa->restore_primitive = -1;
/* Update and emit any new state. We need to do this here to catch
* changes to the masks.
* FIXME: Just update the masks?
*/
if ( vmesa->new_state )
s3vDDUpdateHWState( ctx );
/* s3vUpdateMasks( ctx ); */
/* s3vUpdateClipping( ctx ); */
/* s3vEmitHwState( vmesa ); */
#if 1 /* soft (0)/hw (1)*/
DEBUG(("*** s3vDDClear ***\n"));
DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
DMAOUT(vmesa->SrcBase);
DMAOUT(vmesa->DestBlit);
DMAOUT( vmesa->ScissorLR );
DMAOUT( vmesa->ScissorTB );
DMAOUT( (vmesa->SrcStride << 16) | vmesa->SrcStride ); /* FIXME: unify */
DMAOUT( (~(0)) ); /* masks */
DMAOUT( (~(0)) );
DMAOUT(0);
DMAOUT(vmesa->ClearColor);
DMAOUT(0);
DMAOUT(0);
/* FIXME */
DMAOUT(0x16000122 | 0x5 | (0xF0 << 17)); /* black magic to me */
DMAOUT(vmesa->ScissorWH);
DMAOUT(vmesa->SrcXY);
DMAOUT(vmesa->DestXY);
DMAFINISH();
if (mask & BUFFER_BIT_DEPTH) { /* depth */
DEBUG(("BUFFER_BIT_DEPTH\n"));
_stride = ((cw+31)&~31) * 2; /* XXX cw or Buffer->Width??? */
DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
DMAOUT(0);
DMAOUT(vmesa->s3vScreen->depthOffset);
DMAOUT( (0 << 16) | cw );
DMAOUT( (0 << 16) | ch );
DMAOUT( (vmesa->SrcStride << 16) | vmesa->DestStride );
DMAOUT( (~(0)) ); /* masks */
DMAOUT( (~(0)) );
DMAOUT(0);
DMAOUT(vmesa->ClearDepth); /* 0x7FFF */
/* FIXME */
DMAOUT(0);
DMAOUT(0);
DMAOUT(0x16000122 | 0x5 | (0xF0 << 17));
DMAOUT( ((cw-1) << 16) | (ch-1) );
DMAOUT(0);
DMAOUT( (0 << 16) | 0 );
DMAFINISH();
DEBUG(("vmesa->ClearDepth = 0x%x\n", vmesa->ClearDepth));
mask &= ~BUFFER_BIT_DEPTH;
}
if (!vmesa->NotClipped) {
DEBUG(("vmesa->NotClipped\n")); /* yes */
}
if (!(vmesa->EnabledFlags & S3V_BACK_BUFFER)) {
DEBUG(("!S3V_BACK_BUFFER -> flush\n"));
DMAFLUSH();
}
/*
if ( mask )
DEBUG(("still masked ;3(\n")); */ /* yes */
#else
_swrast_Clear( ctx, mask );
#endif
}
/* =============================================================
* Depth testing
*/
static void s3vUpdateZMode( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
CARD32 cmd = vmesa->CMD;
DEBUG(("Depth.Test = %i\n", ctx->Depth.Test));
DEBUG(("CMD was = 0x%x ", cmd));
/* printf("depth --- CMD was = 0x%x \n", cmd); */
cmd &= ~Z_MASK; /* 0xfc0fffff; */
/* Z_BUFFER */ /* 000 mode */ /* Z_UPDATE_OFF */
if (!ctx->Depth.Test)
cmd |= Z_OFF;
if ( ctx->Depth.Mask )
cmd |= Z_UPDATE_ON;
switch ( ctx->Depth.Func ) {
case GL_NEVER:
cmd |= Z_NEVER;
break;
case GL_ALWAYS:
cmd |= Z_ALWAYS;
break;
case GL_LESS:
cmd |= Z_LESS;
break;
case GL_LEQUAL:
cmd |= Z_LEQUAL;
break;
case GL_EQUAL:
cmd |= Z_EQUAL;
break;
case GL_GEQUAL:
cmd |= Z_GEQUAL;
break;
case GL_GREATER:
cmd |= Z_GREATER;
break;
case GL_NOTEQUAL:
cmd |= Z_NOTEQUAL;
break;
}
DEBUG(("CMD is 0x%x\n", cmd));
vmesa->dirty |= S3V_UPLOAD_DEPTH;
vmesa->CMD = cmd;
}
static void s3vDDDepthFunc( GLcontext *ctx, GLenum func )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
/* FLUSH_BATCH( vmesa ); */
DEBUG(("s3vDDDepthFunc\n"));
vmesa->new_state |= S3V_NEW_DEPTH;
}
static void s3vDDDepthMask( GLcontext *ctx, GLboolean flag )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
/* FLUSH_BATCH( vmesa ); */
DEBUG(("s3vDDDepthMask\n"));
vmesa->new_state |= S3V_NEW_DEPTH;
}
static void s3vDDClearDepth( GLcontext *ctx, GLclampd d )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
switch ( vmesa->DepthSize ) {
case 15:
case 16:
vmesa->ClearDepth = d * 0x0000ffff; /* 65536 */
DEBUG(("GLclampd d = %f\n", d));
DEBUG(("ctx->Depth.Clear = %f\n", ctx->Depth.Clear));
DEBUG(("(They should be the same)\n"));
break;
case 24:
vmesa->ClearDepth = d * 0x00ffffff;
break;
case 32:
vmesa->ClearDepth = d * 0xffffffff;
break;
}
}
static void s3vDDFinish( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
DMAFLUSH();
}
static void s3vDDFlush( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
DMAFLUSH();
}
/* =============================================================
* Fog
*/
static void s3vUpdateFogAttrib( GLcontext *ctx )
{
/* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
if (ctx->Fog.Enabled) {
} else {
}
switch (ctx->Fog.Mode) {
case GL_LINEAR:
break;
case GL_EXP:
break;
case GL_EXP2:
break;
}
}
static void s3vDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
vmesa->new_state |= S3V_NEW_FOG;
}
/* =============================================================
* Lines
*/
static void s3vDDLineWidth( GLcontext *ctx, GLfloat width )
{
/* FIXME: on virge you only have one size of 3d lines *
* if we wanted more, we should start using tris instead *
* but virge has problem with some tris when all of the *
* vertices stay on a line */
}
/* =============================================================
* Points
*/
static void s3vDDPointSize( GLcontext *ctx, GLfloat size )
{
/* FIXME: we use 3d line to fake points. So same limitations
* as above apply */
}
/* =============================================================
* Polygon
*/
static void s3vUpdatePolygon( GLcontext *ctx )
{
/* FIXME: I don't think we could do much here */
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
vmesa->dirty |= S3V_UPLOAD_POLYGON;
}
/* =============================================================
* Clipping
*/
static void s3vUpdateClipping( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
int x0,y0,x1,y1;
DEBUG((">>> s3vUpdateClipping <<<\n"));
/*
if ( vmesa->driDrawable ) {
DEBUG(("s3vUpdateClipping\n"));
*/
if (vmesa->EnabledFlags & S3V_BACK_BUFFER) {
DEBUG(("S3V_BACK_BUFFER\n"));
x0 = 0;
y0 = 0;
x1 = dPriv->w - 1;
y1 = dPriv->h - 1;
vmesa->SrcBase = 0;
vmesa->DestBase = vmesa->s3vScreen->backOffset;
vmesa->DestBlit = vmesa->DestBase;
vmesa->ScissorLR = ( (0 << 16) | (dPriv->w-1) );
vmesa->ScissorTB = ( (0 << 16) | (dPriv->h-1) );
/*
vmesa->ScissorLR = ( (x0 << 16) | x1 );
vmesa->ScissorTB = ( (y0 << 16) | y1 );
*/
vmesa->SrcStride = ( ((dPriv->w+31)&~31) * vmesa->s3vScreen->cpp );
vmesa->DestStride = vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp;
vmesa->ScissorWH = ( (dPriv->w << 16) | dPriv->h );
vmesa->SrcXY = 0;
/* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */
vmesa->DestXY = ( (0 << 16) | 0 );
} else {
DEBUG(("S3V_FRONT_BUFFER\n"));
x0 = dPriv->x;
y0 = dPriv->y;
x1 = x0 + dPriv->w - 1;
y1 = y0 + dPriv->h - 1;
vmesa->SrcBase = 0;
vmesa->DestBase = 0;
vmesa->ScissorLR = ( (x0 << 16) | x1 );
vmesa->ScissorTB = ( (y0 << 16) | y1 );
vmesa->DestStride = vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp;
vmesa->SrcStride = vmesa->DestStride;
vmesa->DestBase = (y0 * vmesa->DestStride)
+ x0*vmesa->s3vScreen->cpp;
vmesa->DestBlit = 0;
vmesa->ScissorWH = ( (x1 << 16) | y1 );
vmesa->SrcXY = 0;
vmesa->DestXY = ( (0 << 16) | 0 );
/* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */
}
DEBUG(("x0=%i y0=%i x1=%i y1=%i\n", x0, y0, x1, y1));
DEBUG(("stride=%i rectWH=0x%x\n\n", vmesa->DestStride, vmesa->ScissorWH));
/* FIXME: how could we use the following info? */
/* if (ctx->Scissor.Enabled) {} */
vmesa->dirty |= S3V_UPLOAD_CLIP;
/* } */
}
static void s3vDDScissor( GLcontext *ctx,
GLint x, GLint y, GLsizei w, GLsizei h )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
DEBUG((">>> s3vDDScissor <<<"));
/* FLUSH_BATCH( vmesa ); */
vmesa->new_state |= S3V_NEW_CLIP;
}
/* =============================================================
* Culling
*/
static void s3vUpdateCull( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
GLfloat backface_sign = 1;
DEBUG(("s3vUpdateCull\n"));
/* FIXME: GL_FRONT_AND_BACK */
switch ( ctx->Polygon.CullFaceMode ) {
case GL_BACK:
if (ctx->Polygon.FrontFace == GL_CCW)
backface_sign = -1;
break;
case GL_FRONT:
if (ctx->Polygon.FrontFace != GL_CCW)
backface_sign = -1;
break;
default:
break;
}
vmesa->backface_sign = backface_sign;
vmesa->dirty |= S3V_UPLOAD_GEOMETRY;
}
static void s3vDDCullFace( GLcontext *ctx, GLenum mode )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
/* FLUSH_BATCH( vmesa ); */
vmesa->new_state |= S3V_NEW_CULL;
}
static void s3vDDFrontFace( GLcontext *ctx, GLenum mode )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
/* FLUSH_BATCH( vmesa ); */
vmesa->new_state |= S3V_NEW_CULL;
}
/* =============================================================
* Masks
*/
static void s3vUpdateMasks( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
GLuint mask = s3vPackColor( vmesa->s3vScreen->cpp,
ctx->Color.ColorMask[RCOMP],
ctx->Color.ColorMask[GCOMP],
ctx->Color.ColorMask[BCOMP],
ctx->Color.ColorMask[ACOMP] );
if (vmesa->s3vScreen->cpp == 2) mask |= mask << 16;
/* FIXME: can we do something in virge? */
}
/*
static void s3vDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g,
GLboolean b, GLboolean a)
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
FLUSH_BATCH( vmesa );
vmesa->new_state |= S3V_NEW_MASKS;
}
*/
/* =============================================================
* Rendering attributes
*/
/* =============================================================
* Miscellaneous
*/
static void s3vDDClearColor( GLcontext *ctx, const GLfloat color[4])
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
DEBUG(("*** s3vDDClearColor\n"));
vmesa->ClearColor = s3vPackColor( 2, /* vmesa->s3vScreen->cpp, */
color[0], color[1], color[2], color[3] );
#if 0
if (vmesa->s3vScreen->cpp == 2) vmesa->ClearColor |= vmesa->ClearColor<<16;
#endif
}
static void s3vDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
int found = GL_TRUE;
DEBUG(("*** s3vDDSetDrawBuffer ***\n"));
/* FLUSH_BATCH( vmesa ); */
switch ( mode ) {
case GL_FRONT_LEFT:
vmesa->drawOffset = vmesa->s3vScreen->frontOffset;
break;
case GL_BACK_LEFT:
vmesa->drawOffset = vmesa->s3vScreen->backOffset;
/* vmesa->driScreen->fbHeight *
* vmesa->driScreen->fbWidth *
* vmesa->s3vScreen->cpp; */
break;
default:
found = GL_FALSE;
break;
}
DEBUG(("vmesa->drawOffset = 0x%x\n", vmesa->drawOffset));
/* return GL_TRUE; */
}
/* =============================================================
* Window position and viewport transformation
*/
void s3vUpdateWindow( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
GLfloat xoffset = (GLfloat)dPriv->x;
GLfloat yoffset =
vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
const GLfloat *v = ctx->Viewport._WindowMap.m;
GLfloat sx = v[MAT_SX];
GLfloat tx = v[MAT_TX] + xoffset;
GLfloat sy = v[MAT_SY];
GLfloat ty = v[MAT_TY] + yoffset;
GLfloat sz = v[MAT_SZ] * vmesa->depth_scale;
GLfloat tz = v[MAT_TZ] * vmesa->depth_scale;
vmesa->dirty |= S3V_UPLOAD_VIEWPORT;
vmesa->ViewportScaleX = sx;
vmesa->ViewportScaleY = sy;
vmesa->ViewportScaleZ = sz;
vmesa->ViewportOffsetX = tx;
vmesa->ViewportOffsetY = ty;
vmesa->ViewportOffsetZ = tz;
}
/*
static void s3vDDViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
s3vUpdateWindow( ctx );
}
static void s3vDDDepthRange( GLcontext *ctx, GLclampd nearval,
GLclampd farval )
{
s3vUpdateWindow( ctx );
}
*/
void s3vUpdateViewportOffset( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
GLfloat xoffset = (GLfloat)dPriv->x;
GLfloat yoffset =
vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
const GLfloat *v = ctx->Viewport._WindowMap.m;
GLfloat tx = v[MAT_TX] + xoffset;
GLfloat ty = v[MAT_TY] + yoffset;
DEBUG(("*** s3vUpdateViewportOffset ***\n"));
if ( vmesa->ViewportOffsetX != tx ||
vmesa->ViewportOffsetY != ty )
{
vmesa->ViewportOffsetX = tx;
vmesa->ViewportOffsetY = ty;
vmesa->new_state |= S3V_NEW_WINDOW;
}
/* vmesa->new_state |= S3V_NEW_CLIP; */
}
/* =============================================================
* State enable/disable
*/
static void s3vDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
switch ( cap ) {
case GL_ALPHA_TEST:
case GL_BLEND:
vmesa->new_state |= S3V_NEW_ALPHA;
DEBUG(("s3vDDEnable: GL_BLEND\n"));
break;
case GL_CULL_FACE:
vmesa->new_state |= S3V_NEW_CULL;
DEBUG(("s3vDDEnable: GL_CULL_FACE\n"));
break;
case GL_DEPTH_TEST:
vmesa->new_state |= S3V_NEW_DEPTH;
DEBUG(("s3vDDEnable: GL_DEPTH\n"));
break;
#if 0
case GL_FOG:
vmesa->new_state |= S3V_NEW_FOG;
break;
#endif
case GL_SCISSOR_TEST:
vmesa->new_state |= S3V_NEW_CLIP;
break;
case GL_TEXTURE_2D:
DEBUG(("*** GL_TEXTURE_2D: %i\n", state));
vmesa->_3d_mode = state;
vmesa->restore_primitive = -1;
break;
default:
return;
}
}
/* =============================================================
* State initialization, management
*/
/*
* Load the current context's state into the hardware.
*
* NOTE: Be VERY careful about ensuring the context state is marked for
* upload, the only place it shouldn't be uploaded is when the setup
* state has changed in ReducedPrimitiveChange as this comes right after
* a state update.
*
* Blits of any type should always upload the context and masks after
* they are done.
*/
void s3vEmitHwState( s3vContextPtr vmesa )
{
if (!vmesa->driDrawable) return;
if (!vmesa->dirty) return;
DEBUG(("**********************\n"));
DEBUG(("*** s3vEmitHwState ***\n"));
DEBUG(("**********************\n"));
if (vmesa->dirty & S3V_UPLOAD_VIEWPORT) {
vmesa->dirty &= ~S3V_UPLOAD_VIEWPORT;
DEBUG(("S3V_UPLOAD_VIEWPORT\n"));
}
if ( (vmesa->dirty & S3V_UPLOAD_POINTMODE) ||
(vmesa->dirty & S3V_UPLOAD_LINEMODE) ||
(vmesa->dirty & S3V_UPLOAD_TRIMODE) ) {
}
if (vmesa->dirty & S3V_UPLOAD_POINTMODE) {
vmesa->dirty &= ~S3V_UPLOAD_POINTMODE;
}
if (vmesa->dirty & S3V_UPLOAD_LINEMODE) {
vmesa->dirty &= ~S3V_UPLOAD_LINEMODE;
}
if (vmesa->dirty & S3V_UPLOAD_TRIMODE) {
vmesa->dirty &= ~S3V_UPLOAD_TRIMODE;
}
if (vmesa->dirty & S3V_UPLOAD_FOG) {
GLchan c[3], col;
UNCLAMPED_FLOAT_TO_RGB_CHAN( c, vmesa->glCtx->Fog.Color );
DEBUG(("uploading ** FOG **\n"));
col = s3vPackColor(2, c[0], c[1], c[2], 0);
vmesa->dirty &= ~S3V_UPLOAD_FOG;
}
if (vmesa->dirty & S3V_UPLOAD_DITHER) {
vmesa->dirty &= ~S3V_UPLOAD_DITHER;
}
if (vmesa->dirty & S3V_UPLOAD_LOGICOP) {
vmesa->dirty &= ~S3V_UPLOAD_LOGICOP;
}
if (vmesa->dirty & S3V_UPLOAD_CLIP) {
vmesa->dirty &= ~S3V_UPLOAD_CLIP;
DEBUG(("S3V_UPLOAD_CLIP\n"));
DEBUG(("vmesa->ScissorLR: %i\n", vmesa->ScissorLR));
DEBUG(("vmesa->ScissorTB: %i\n", vmesa->ScissorTB));
}
if (vmesa->dirty & S3V_UPLOAD_MASKS) {
vmesa->dirty &= ~S3V_UPLOAD_MASKS;
DEBUG(("S3V_UPLOAD_BLEND\n"));
}
if (vmesa->dirty & S3V_UPLOAD_ALPHA) {
vmesa->dirty &= ~S3V_UPLOAD_ALPHA;
DEBUG(("S3V_UPLOAD_ALPHA\n"));
}
if (vmesa->dirty & S3V_UPLOAD_SHADE) {
vmesa->dirty &= ~S3V_UPLOAD_SHADE;
}
if (vmesa->dirty & S3V_UPLOAD_POLYGON) {
vmesa->dirty &= ~S3V_UPLOAD_POLYGON;
}
if (vmesa->dirty & S3V_UPLOAD_DEPTH) {
vmesa->dirty &= ~S3V_UPLOAD_DEPTH;
DEBUG(("S3V_UPLOAD_DEPTH: DepthMode = 0x%x08\n", vmesa->DepthMode));
}
if (vmesa->dirty & S3V_UPLOAD_GEOMETRY) {
vmesa->dirty &= ~S3V_UPLOAD_GEOMETRY;
}
if (vmesa->dirty & S3V_UPLOAD_TRANSFORM) {
vmesa->dirty &= ~S3V_UPLOAD_TRANSFORM;
}
if (vmesa->dirty & S3V_UPLOAD_TEX0) {
s3vTextureObjectPtr curTex = vmesa->CurrentTexObj[0];
vmesa->dirty &= ~S3V_UPLOAD_TEX0;
DEBUG(("S3V_UPLOAD_TEX0\n"));
if (curTex) {
DEBUG(("S3V_UPLOAD_TEX0: curTex\n"));
} else {
DEBUG(("S3V_UPLOAD_TEX0: !curTex\n"));
}
}
}
void s3vDDUpdateHWState( GLcontext *ctx )
{
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
int new_state = vmesa->new_state;
/* s3vUpdateClipping( ctx ); */
if ( new_state )
{
vmesa->new_state = 0;
/* Update the various parts of the context's state.
*/
if ( new_state & S3V_NEW_ALPHA )
s3vUpdateAlphaMode( ctx );
if ( new_state & S3V_NEW_DEPTH )
s3vUpdateZMode( ctx );
if ( new_state & S3V_NEW_FOG )
s3vUpdateFogAttrib( ctx );
if ( new_state & S3V_NEW_CLIP )
{
DEBUG(("---> going to s3vUpdateClipping\n"));
s3vUpdateClipping( ctx );
}
if ( new_state & S3V_NEW_POLYGON )
s3vUpdatePolygon( ctx );
if ( new_state & S3V_NEW_CULL )
s3vUpdateCull( ctx );
if ( new_state & S3V_NEW_MASKS )
s3vUpdateMasks( ctx );
if ( new_state & S3V_NEW_WINDOW )
s3vUpdateWindow( ctx );
/*
if ( new_state & S3_NEW_TEXTURE )
s3vUpdateTextureState( ctx );
*/
CMDCHANGE();
}
/* HACK ! */
s3vEmitHwState( vmesa );
}
static void s3vDDUpdateState( GLcontext *ctx, GLuint new_state )
{
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
_vbo_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
S3V_CONTEXT(ctx)->new_gl_state |= new_state;
}
/* Initialize the context's hardware state.
*/
void s3vInitState( s3vContextPtr vmesa )
{
vmesa->new_state = 0;
}
/* Initialize the driver's state functions.
*/
void s3vInitStateFuncs( GLcontext *ctx )
{
ctx->Driver.UpdateState = s3vDDUpdateState;
ctx->Driver.Clear = s3vDDClear;
ctx->Driver.ClearIndex = NULL;
ctx->Driver.ClearColor = s3vDDClearColor;
ctx->Driver.DrawBuffer = s3vDDSetDrawBuffer;
ctx->Driver.ReadBuffer = NULL; /* XXX */
ctx->Driver.IndexMask = NULL;
ctx->Driver.ColorMask = NULL; /* s3vDDColorMask; */ /* FIXME */
ctx->Driver.AlphaFunc = s3vDDAlphaFunc; /* FIXME */
#if 0
ctx->Driver.BlendEquation = NULL; /* s3vDDBlendEquation; */
ctx->Driver.BlendFunc = s3vDDBlendFunc; /* FIXME */
#endif
ctx->Driver.BlendFuncSeparate = NULL; /* s3vDDBlendFuncSeparate; */
ctx->Driver.ClearDepth = s3vDDClearDepth;
ctx->Driver.CullFace = s3vDDCullFace;
ctx->Driver.FrontFace = s3vDDFrontFace;
ctx->Driver.DepthFunc = s3vDDDepthFunc; /* FIXME */
ctx->Driver.DepthMask = s3vDDDepthMask; /* FIXME */
ctx->Driver.DepthRange = NULL; /* s3vDDDepthRange; */
ctx->Driver.Enable = s3vDDEnable; /* FIXME */
ctx->Driver.Finish = s3vDDFinish;
ctx->Driver.Flush = s3vDDFlush;
#if 1
ctx->Driver.Fogfv = NULL; /* s3vDDFogfv; */
#endif
ctx->Driver.Hint = NULL;
ctx->Driver.LineWidth = NULL; /* s3vDDLineWidth; */
ctx->Driver.LineStipple = NULL; /* s3vDDLineStipple; */
#if ENABLELIGHTING
ctx->Driver.Lightfv = NULL; /* s3vDDLightfv; */
ctx->Driver.LightModelfv = NULL; /* s3vDDLightModelfv; */
#endif
ctx->Driver.LogicOpcode = NULL; /* s3vDDLogicalOpcode; */
ctx->Driver.PointSize = NULL; /* s3vDDPointSize; */
ctx->Driver.PolygonMode = NULL; /* s3vDDPolygonMode; */
ctx->Driver.PolygonStipple = NULL; /* s3vDDPolygonStipple; */
ctx->Driver.Scissor = s3vDDScissor; /* ScissorLR / ScissorTB */
ctx->Driver.ShadeModel = NULL; /* s3vDDShadeModel; */
ctx->Driver.Viewport = NULL; /* s3vDDViewport; */
}
|