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