Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / src / mesa / drivers / dri / sis / sis6326_state.c
1 /*
2 * Copyright 2005 Eric Anholt
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 * Authors:
25 * Eric Anholt <anholt@FreeBSD.org>
26 *
27 */
28
29 #include "sis_context.h"
30 #include "sis_state.h"
31 #include "sis_tris.h"
32 #include "sis_lock.h"
33 #include "sis_tex.h"
34 #include "sis_reg.h"
35
36 #include "main/context.h"
37 #include "main/enums.h"
38 #include "main/colormac.h"
39 #include "swrast/swrast.h"
40 #include "vbo/vbo.h"
41 #include "tnl/tnl.h"
42 #include "swrast_setup/swrast_setup.h"
43
44 #include "tnl/t_pipeline.h"
45
46 /* =============================================================
47 * Alpha blending
48 */
49
50 static void
51 sis6326DDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
52 {
53 sisContextPtr smesa = SIS_CONTEXT(ctx);
54 GLubyte refbyte;
55
56 __GLSiSHardware *prev = &smesa->prev;
57 __GLSiSHardware *current = &smesa->current;
58
59 CLAMPED_FLOAT_TO_UBYTE(refbyte, ref);
60 current->hwAlpha = refbyte << 16;
61
62 /* Alpha Test function */
63 switch (func)
64 {
65 case GL_NEVER:
66 current->hwAlpha |= S_ASET_PASS_NEVER;
67 break;
68 case GL_LESS:
69 current->hwAlpha |= S_ASET_PASS_LESS;
70 break;
71 case GL_EQUAL:
72 current->hwAlpha |= S_ASET_PASS_EQUAL;
73 break;
74 case GL_LEQUAL:
75 current->hwAlpha |= S_ASET_PASS_LEQUAL;
76 break;
77 case GL_GREATER:
78 current->hwAlpha |= S_ASET_PASS_GREATER;
79 break;
80 case GL_NOTEQUAL:
81 current->hwAlpha |= S_ASET_PASS_NOTEQUAL;
82 break;
83 case GL_GEQUAL:
84 current->hwAlpha |= S_ASET_PASS_GEQUAL;
85 break;
86 case GL_ALWAYS:
87 current->hwAlpha |= S_ASET_PASS_ALWAYS;
88 break;
89 }
90
91 prev->hwAlpha = current->hwAlpha;
92 smesa->GlobalFlag |= GFLAG_ALPHASETTING;
93 }
94
95 static void
96 sis6326DDBlendFuncSeparate( GLcontext *ctx,
97 GLenum sfactorRGB, GLenum dfactorRGB,
98 GLenum sfactorA, GLenum dfactorA )
99 {
100 sisContextPtr smesa = SIS_CONTEXT(ctx);
101
102 __GLSiSHardware *prev = &smesa->prev;
103 __GLSiSHardware *current = &smesa->current;
104
105 current->hwDstSrcBlend = 0;
106
107 switch (dfactorRGB)
108 {
109 case GL_ZERO:
110 current->hwDstSrcBlend |= S_DBLEND_ZERO;
111 break;
112 case GL_ONE:
113 current->hwDstSrcBlend |= S_DBLEND_ONE;
114 break;
115 case GL_SRC_COLOR:
116 current->hwDstSrcBlend |= S_DBLEND_SRC_COLOR;
117 break;
118 case GL_ONE_MINUS_SRC_COLOR:
119 current->hwDstSrcBlend |= S_DBLEND_INV_SRC_COLOR;
120 break;
121 case GL_SRC_ALPHA:
122 current->hwDstSrcBlend |= S_DBLEND_SRC_ALPHA;
123 break;
124 case GL_ONE_MINUS_SRC_ALPHA:
125 current->hwDstSrcBlend |= S_DBLEND_INV_SRC_ALPHA;
126 break;
127 case GL_DST_ALPHA:
128 current->hwDstSrcBlend |= S_DBLEND_DST_ALPHA;
129 break;
130 case GL_ONE_MINUS_DST_ALPHA:
131 current->hwDstSrcBlend |= S_DBLEND_INV_DST_ALPHA;
132 break;
133 }
134
135 switch (sfactorRGB)
136 {
137 case GL_ZERO:
138 current->hwDstSrcBlend |= S_SBLEND_ZERO;
139 break;
140 case GL_ONE:
141 current->hwDstSrcBlend |= S_SBLEND_ONE;
142 break;
143 case GL_SRC_ALPHA:
144 current->hwDstSrcBlend |= S_SBLEND_SRC_ALPHA;
145 break;
146 case GL_ONE_MINUS_SRC_ALPHA:
147 current->hwDstSrcBlend |= S_SBLEND_INV_SRC_ALPHA;
148 break;
149 case GL_DST_ALPHA:
150 current->hwDstSrcBlend |= S_SBLEND_DST_ALPHA;
151 break;
152 case GL_ONE_MINUS_DST_ALPHA:
153 current->hwDstSrcBlend |= S_SBLEND_INV_DST_ALPHA;
154 break;
155 case GL_DST_COLOR:
156 current->hwDstSrcBlend |= S_SBLEND_DST_COLOR;
157 break;
158 case GL_ONE_MINUS_DST_COLOR:
159 current->hwDstSrcBlend |= S_SBLEND_INV_DST_COLOR;
160 break;
161 case GL_SRC_ALPHA_SATURATE:
162 current->hwDstSrcBlend |= S_SBLEND_SRC_ALPHA_SAT;
163 break;
164 }
165
166 if (current->hwDstSrcBlend != prev->hwDstSrcBlend) {
167 prev->hwDstSrcBlend = current->hwDstSrcBlend;
168 smesa->GlobalFlag |= GFLAG_DSTBLEND;
169 }
170 }
171
172 /* =============================================================
173 * Depth testing
174 */
175
176 static void
177 sis6326DDDepthFunc( GLcontext *ctx, GLenum func )
178 {
179 sisContextPtr smesa = SIS_CONTEXT(ctx);
180 __GLSiSHardware *prev = &smesa->prev;
181 __GLSiSHardware *current = &smesa->current;
182
183 current->hwZ &= ~MASK_6326_ZTestMode;
184 switch (func)
185 {
186 case GL_LESS:
187 current->hwZ |= S_ZSET_PASS_LESS;
188 break;
189 case GL_GEQUAL:
190 current->hwZ |= S_ZSET_PASS_GEQUAL;
191 break;
192 case GL_LEQUAL:
193 current->hwZ |= S_ZSET_PASS_LEQUAL;
194 break;
195 case GL_GREATER:
196 current->hwZ |= S_ZSET_PASS_GREATER;
197 break;
198 case GL_NOTEQUAL:
199 current->hwZ |= S_ZSET_PASS_NOTEQUAL;
200 break;
201 case GL_EQUAL:
202 current->hwZ |= S_ZSET_PASS_EQUAL;
203 break;
204 case GL_ALWAYS:
205 current->hwZ |= S_ZSET_PASS_ALWAYS;
206 break;
207 case GL_NEVER:
208 current->hwZ |= S_ZSET_PASS_NEVER;
209 break;
210 }
211
212 if (current->hwZ != prev->hwZ) {
213 prev->hwZ = current->hwZ;
214 smesa->GlobalFlag |= GFLAG_ZSETTING;
215 }
216 }
217
218 static void
219 sis6326DDDepthMask( GLcontext *ctx, GLboolean flag )
220 {
221 sisContextPtr smesa = SIS_CONTEXT(ctx);
222 __GLSiSHardware *current = &smesa->current;
223
224 if (ctx->Depth.Test)
225 current->hwCapEnable |= S_ENABLE_ZWrite;
226 else
227 current->hwCapEnable &= ~S_ENABLE_ZWrite;
228 }
229
230 /* =============================================================
231 * Fog
232 */
233
234 static void
235 sis6326DDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
236 {
237 sisContextPtr smesa = SIS_CONTEXT(ctx);
238 __GLSiSHardware *current = &smesa->current;
239 __GLSiSHardware *prev = &smesa->prev;
240
241 GLint fogColor;
242
243 switch(pname)
244 {
245 case GL_FOG_COLOR:
246 fogColor = FLOAT_TO_UBYTE( ctx->Fog.Color[0] ) << 16;
247 fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[1] ) << 8;
248 fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[2] );
249 current->hwFog = 0x01000000 | fogColor;
250 if (current->hwFog != prev->hwFog) {
251 prev->hwFog = current->hwFog;
252 smesa->GlobalFlag |= GFLAG_FOGSETTING;
253 }
254 break;
255 }
256 }
257
258 /* =============================================================
259 * Clipping
260 */
261
262 void
263 sis6326UpdateClipping(GLcontext *ctx)
264 {
265 sisContextPtr smesa = SIS_CONTEXT(ctx);
266
267 __GLSiSHardware *prev = &smesa->prev;
268 __GLSiSHardware *current = &smesa->current;
269
270 GLint x1, y1, x2, y2;
271
272 x1 = 0;
273 y1 = 0;
274 x2 = smesa->width - 1;
275 y2 = smesa->height - 1;
276
277 if (ctx->Scissor.Enabled) {
278 if (ctx->Scissor.X > x1)
279 x1 = ctx->Scissor.X;
280 if (ctx->Scissor.Y > y1)
281 y1 = ctx->Scissor.Y;
282 if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2)
283 x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
284 if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < y2)
285 y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1;
286 }
287
288 y1 = Y_FLIP(y1);
289 y2 = Y_FLIP(y2);
290
291 /*current->clipTopBottom = (y2 << 13) | y1;
292 current->clipLeftRight = (x1 << 13) | x2;*/ /* XXX */
293 current->clipTopBottom = (0 << 13) | smesa->height;
294 current->clipLeftRight = (0 << 13) | smesa->width;
295
296 if ((current->clipTopBottom != prev->clipTopBottom) ||
297 (current->clipLeftRight != prev->clipLeftRight)) {
298 prev->clipTopBottom = current->clipTopBottom;
299 prev->clipLeftRight = current->clipLeftRight;
300 smesa->GlobalFlag |= GFLAG_CLIPPING;
301 }
302 }
303
304 static void
305 sis6326DDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h )
306 {
307 if (ctx->Scissor.Enabled)
308 sis6326UpdateClipping( ctx );
309 }
310
311 /* =============================================================
312 * Culling
313 */
314
315 static void
316 sis6326UpdateCull( GLcontext *ctx )
317 {
318 /* XXX culling */
319 }
320
321
322 static void
323 sis6326DDCullFace( GLcontext *ctx, GLenum mode )
324 {
325 sis6326UpdateCull( ctx );
326 }
327
328 static void
329 sis6326DDFrontFace( GLcontext *ctx, GLenum mode )
330 {
331 sis6326UpdateCull( ctx );
332 }
333
334 /* =============================================================
335 * Masks
336 */
337
338 static void sis6326DDColorMask( GLcontext *ctx,
339 GLboolean r, GLboolean g,
340 GLboolean b, GLboolean a )
341 {
342 sisContextPtr smesa = SIS_CONTEXT(ctx);
343
344 if (r && g && b && ((ctx->Visual.alphaBits == 0) || a)) {
345 FALLBACK(smesa, SIS_FALLBACK_WRITEMASK, 0);
346 } else {
347 FALLBACK(smesa, SIS_FALLBACK_WRITEMASK, 1);
348 }
349 }
350
351 /* =============================================================
352 * Rendering attributes
353 */
354
355 static void sis6326UpdateSpecular(GLcontext *ctx)
356 {
357 sisContextPtr smesa = SIS_CONTEXT(ctx);
358 __GLSiSHardware *current = &smesa->current;
359
360 if (NEED_SECONDARY_COLOR(ctx))
361 current->hwCapEnable |= S_ENABLE_Specular;
362 else
363 current->hwCapEnable &= ~S_ENABLE_Specular;
364 }
365
366 static void sis6326DDLightModelfv(GLcontext *ctx, GLenum pname,
367 const GLfloat *param)
368 {
369 if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
370 sis6326UpdateSpecular(ctx);
371 }
372 }
373 static void sis6326DDShadeModel( GLcontext *ctx, GLenum mode )
374 {
375 sisContextPtr smesa = SIS_CONTEXT(ctx);
376
377 /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */
378 smesa->hw_primitive = -1;
379 }
380
381 /* =============================================================
382 * Window position
383 */
384
385 /* =============================================================
386 * Viewport
387 */
388
389 static void sis6326CalcViewport( GLcontext *ctx )
390 {
391 sisContextPtr smesa = SIS_CONTEXT(ctx);
392 const GLfloat *v = ctx->Viewport._WindowMap.m;
393 GLfloat *m = smesa->hw_viewport;
394
395 /* See also sis_translate_vertex.
396 */
397 m[MAT_SX] = v[MAT_SX];
398 m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
399 m[MAT_SY] = - v[MAT_SY];
400 m[MAT_TY] = - v[MAT_TY] + smesa->driDrawable->h + SUBPIXEL_Y;
401 m[MAT_SZ] = v[MAT_SZ] * smesa->depth_scale;
402 m[MAT_TZ] = v[MAT_TZ] * smesa->depth_scale;
403 }
404
405 static void sis6326DDViewport( GLcontext *ctx,
406 GLint x, GLint y,
407 GLsizei width, GLsizei height )
408 {
409 sis6326CalcViewport( ctx );
410 }
411
412 static void sis6326DDDepthRange( GLcontext *ctx,
413 GLclampd nearval, GLclampd farval )
414 {
415 sis6326CalcViewport( ctx );
416 }
417
418 /* =============================================================
419 * Miscellaneous
420 */
421
422 static void
423 sis6326DDLogicOpCode( GLcontext *ctx, GLenum opcode )
424 {
425 sisContextPtr smesa = SIS_CONTEXT(ctx);
426
427 __GLSiSHardware *prev = &smesa->prev;
428 __GLSiSHardware *current = &smesa->current;
429
430 if (!ctx->Color.ColorLogicOpEnabled)
431 return;
432
433 current->hwDstSet &= ~MASK_ROP2;
434 switch (opcode)
435 {
436 case GL_CLEAR:
437 current->hwDstSet |= LOP_CLEAR;
438 break;
439 case GL_SET:
440 current->hwDstSet |= LOP_SET;
441 break;
442 case GL_COPY:
443 current->hwDstSet |= LOP_COPY;
444 break;
445 case GL_COPY_INVERTED:
446 current->hwDstSet |= LOP_COPY_INVERTED;
447 break;
448 case GL_NOOP:
449 current->hwDstSet |= LOP_NOOP;
450 break;
451 case GL_INVERT:
452 current->hwDstSet |= LOP_INVERT;
453 break;
454 case GL_AND:
455 current->hwDstSet |= LOP_AND;
456 break;
457 case GL_NAND:
458 current->hwDstSet |= LOP_NAND;
459 break;
460 case GL_OR:
461 current->hwDstSet |= LOP_OR;
462 break;
463 case GL_NOR:
464 current->hwDstSet |= LOP_NOR;
465 break;
466 case GL_XOR:
467 current->hwDstSet |= LOP_XOR;
468 break;
469 case GL_EQUIV:
470 current->hwDstSet |= LOP_EQUIV;
471 break;
472 case GL_AND_REVERSE:
473 current->hwDstSet |= LOP_AND_REVERSE;
474 break;
475 case GL_AND_INVERTED:
476 current->hwDstSet |= LOP_AND_INVERTED;
477 break;
478 case GL_OR_REVERSE:
479 current->hwDstSet |= LOP_OR_REVERSE;
480 break;
481 case GL_OR_INVERTED:
482 current->hwDstSet |= LOP_OR_INVERTED;
483 break;
484 }
485
486 if (current->hwDstSet != prev->hwDstSet) {
487 prev->hwDstSet = current->hwDstSet;
488 smesa->GlobalFlag |= GFLAG_DESTSETTING;
489 }
490 }
491
492 void sis6326DDDrawBuffer( GLcontext *ctx, GLenum mode )
493 {
494 sisContextPtr smesa = SIS_CONTEXT(ctx);
495
496 __GLSiSHardware *prev = &smesa->prev;
497 __GLSiSHardware *current = &smesa->current;
498
499 if(getenv("SIS_DRAW_FRONT"))
500 ctx->DrawBuffer->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT;
501
502 if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) {
503 FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );
504 return;
505 }
506
507 current->hwDstSet &= ~MASK_DstBufferPitch;
508
509 switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
510 case BUFFER_FRONT_LEFT:
511 current->hwOffsetDest = smesa->front.offset;
512 current->hwDstSet |= smesa->front.pitch;
513 FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
514 break;
515 case BUFFER_BACK_LEFT:
516 current->hwOffsetDest = smesa->back.offset;
517 current->hwDstSet |= smesa->back.pitch;
518 FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
519 break;
520 default:
521 FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );
522 return;
523 }
524
525 if (current->hwDstSet != prev->hwDstSet) {
526 prev->hwDstSet = current->hwDstSet;
527 smesa->GlobalFlag |= GFLAG_DESTSETTING;
528 }
529
530 if (current->hwOffsetDest != prev->hwOffsetDest) {
531 prev->hwOffsetDest = current->hwOffsetDest;
532 smesa->GlobalFlag |= GFLAG_DESTSETTING;
533 }
534 }
535
536 /* =============================================================
537 * Polygon stipple
538 */
539
540 /* =============================================================
541 * Render mode
542 */
543
544 /* =============================================================
545 * State enable/disable
546 */
547
548 static void
549 sis6326DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
550 {
551 sisContextPtr smesa = SIS_CONTEXT(ctx);
552
553 __GLSiSHardware *current = &smesa->current;
554
555 switch (cap)
556 {
557 case GL_ALPHA_TEST:
558 if (state)
559 current->hwCapEnable |= S_ENABLE_AlphaTest;
560 else
561 current->hwCapEnable &= ~S_ENABLE_AlphaTest;
562 break;
563 case GL_BLEND:
564 /* TODO: */
565 if (state)
566 /* if (state & !ctx->Color.ColorLogicOpEnabled) */
567 current->hwCapEnable |= S_ENABLE_Blend;
568 else
569 current->hwCapEnable &= ~S_ENABLE_Blend;
570 break;
571 case GL_CULL_FACE:
572 /* XXX culling */
573 break;
574 case GL_DEPTH_TEST:
575 if (state && smesa->depth.offset != 0)
576 current->hwCapEnable |= S_ENABLE_ZTest;
577 else
578 current->hwCapEnable &= ~S_ENABLE_ZTest;
579 sis6326DDDepthMask( ctx, ctx->Depth.Mask );
580 break;
581 case GL_DITHER:
582 if (state)
583 current->hwCapEnable |= S_ENABLE_Dither;
584 else
585 current->hwCapEnable &= ~S_ENABLE_Dither;
586 break;
587 case GL_FOG:
588 if (state)
589 current->hwCapEnable |= S_ENABLE_Fog;
590 else
591 current->hwCapEnable &= ~S_ENABLE_Fog;
592 break;
593 case GL_COLOR_LOGIC_OP:
594 if (state)
595 sis6326DDLogicOpCode( ctx, ctx->Color.LogicOp );
596 else
597 sis6326DDLogicOpCode( ctx, GL_COPY );
598 break;
599 case GL_SCISSOR_TEST:
600 sis6326UpdateClipping( ctx );
601 break;
602 case GL_STENCIL_TEST:
603 if (state) {
604 FALLBACK(smesa, SIS_FALLBACK_STENCIL, 1);
605 } else {
606 FALLBACK(smesa, SIS_FALLBACK_STENCIL, 0);
607 }
608 break;
609 case GL_LIGHTING:
610 case GL_COLOR_SUM_EXT:
611 sis6326UpdateSpecular(ctx);
612 break;
613 }
614 }
615
616 /* =============================================================
617 * State initialization, management
618 */
619
620 /* Called before beginning of rendering. */
621 void
622 sis6326UpdateHWState( GLcontext *ctx )
623 {
624 sisContextPtr smesa = SIS_CONTEXT(ctx);
625 __GLSiSHardware *prev = &smesa->prev;
626 __GLSiSHardware *current = &smesa->current;
627
628 if (smesa->NewGLState & _NEW_TEXTURE)
629 sisUpdateTextureState( ctx );
630
631 if (current->hwCapEnable ^ prev->hwCapEnable) {
632 prev->hwCapEnable = current->hwCapEnable;
633 smesa->GlobalFlag |= GFLAG_ENABLESETTING;
634 }
635
636 if (smesa->GlobalFlag & GFLAG_RENDER_STATES)
637 sis_update_render_state( smesa );
638
639 if (smesa->GlobalFlag & GFLAG_TEXTURE_STATES)
640 sis_update_texture_state( smesa );
641 }
642
643 static void
644 sis6326DDInvalidateState( GLcontext *ctx, GLuint new_state )
645 {
646 sisContextPtr smesa = SIS_CONTEXT(ctx);
647
648 _swrast_InvalidateState( ctx, new_state );
649 _swsetup_InvalidateState( ctx, new_state );
650 _vbo_InvalidateState( ctx, new_state );
651 _tnl_InvalidateState( ctx, new_state );
652 smesa->NewGLState |= new_state;
653 }
654
655 /* Initialize the context's hardware state.
656 */
657 void sis6326DDInitState( sisContextPtr smesa )
658 {
659 __GLSiSHardware *prev = &smesa->prev;
660 __GLSiSHardware *current = &smesa->current;
661 GLcontext *ctx = smesa->glCtx;
662
663 /* add Texture Perspective Enable */
664 current->hwCapEnable = S_ENABLE_TextureCache |
665 S_ENABLE_TexturePerspective | S_ENABLE_Dither;
666
667 /* Z test mode is LESS */
668 current->hwZ = S_ZSET_PASS_LESS | S_ZSET_FORMAT_16;
669 if (ctx->Visual.depthBits > 0)
670 current->hwCapEnable |= S_ENABLE_ZWrite;
671
672 /* Alpha test mode is ALWAYS, alpha ref value is 0 */
673 current->hwAlpha = S_ASET_PASS_ALWAYS;
674
675 /* ROP2 is COPYPEN */
676 current->hwDstSet = LOP_COPY;
677
678 /* LinePattern is 0, Repeat Factor is 0 */
679 current->hwLinePattern = 0x00008000;
680
681 /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
682 current->hwDstSrcBlend = S_SBLEND_ONE | S_DBLEND_ZERO;
683
684 switch (smesa->bytesPerPixel)
685 {
686 case 2:
687 current->hwDstSet |= DST_FORMAT_RGB_565;
688 break;
689 case 4:
690 current->hwDstSet |= DST_FORMAT_ARGB_8888;
691 break;
692 }
693
694 smesa->depth_scale = 1.0 / (GLfloat)0xffff;
695
696 smesa->clearTexCache = GL_TRUE;
697
698 smesa->clearColorPattern = 0;
699
700 sis6326UpdateZPattern(smesa, 1.0);
701 sis6326UpdateCull(ctx);
702
703 /* Set initial fog settings. Start and end are the same case. */
704 sis6326DDFogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
705 sis6326DDFogfv( ctx, GL_FOG_END, &ctx->Fog.End );
706 sis6326DDFogfv( ctx, GL_FOG_MODE, NULL );
707
708 memcpy(prev, current, sizeof(__GLSiSHardware));
709 }
710
711 /* Initialize the driver's state functions.
712 */
713 void sis6326DDInitStateFuncs( GLcontext *ctx )
714 {
715 ctx->Driver.UpdateState = sis6326DDInvalidateState;
716
717 ctx->Driver.Clear = sis6326DDClear;
718 ctx->Driver.ClearColor = sis6326DDClearColor;
719 ctx->Driver.ClearDepth = sis6326DDClearDepth;
720
721 ctx->Driver.AlphaFunc = sis6326DDAlphaFunc;
722 ctx->Driver.BlendFuncSeparate = sis6326DDBlendFuncSeparate;
723 ctx->Driver.ColorMask = sis6326DDColorMask;
724 ctx->Driver.CullFace = sis6326DDCullFace;
725 ctx->Driver.DepthMask = sis6326DDDepthMask;
726 ctx->Driver.DepthFunc = sis6326DDDepthFunc;
727 ctx->Driver.DepthRange = sis6326DDDepthRange;
728 ctx->Driver.DrawBuffer = sis6326DDDrawBuffer;
729 ctx->Driver.Enable = sis6326DDEnable;
730 ctx->Driver.FrontFace = sis6326DDFrontFace;
731 ctx->Driver.Fogfv = sis6326DDFogfv;
732 ctx->Driver.LogicOpcode = sis6326DDLogicOpCode;
733 ctx->Driver.Scissor = sis6326DDScissor;
734 ctx->Driver.ShadeModel = sis6326DDShadeModel;
735 ctx->Driver.LightModelfv = sis6326DDLightModelfv;
736 ctx->Driver.Viewport = sis6326DDViewport;
737 }