i830_state.c revision decc6e2a32ef49e673c081f30e19b8970155d887
16b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/**************************************************************************
26b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell *
36b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
46b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * All Rights Reserved.
56b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell *
66b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a
76b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * copy of this software and associated documentation files (the
86b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * "Software"), to deal in the Software without restriction, including
96b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish,
106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to
116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to
126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * the following conditions:
136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell *
146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * The above copyright notice and this permission notice (including the
156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * next paragraph) shall be included in all copies or substantial portions
166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * of the Software.
176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell *
186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell *
266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell **************************************************************************/
276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
29ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/glheader.h"
30ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/context.h"
31ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/macros.h"
32ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/enums.h"
33ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/dd.h"
34decc6e2a32ef49e673c081f30e19b8970155d887Brian Paul#include "main/state.h"
356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "texmem.h"
376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
38a194bc3a8527ed41eead88632cc79ecabe4c81acBrian#include "drivers/common/driverfuncs.h"
39a194bc3a8527ed41eead88632cc79ecabe4c81acBrian
406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_screen.h"
416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_batchbuffer.h"
426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_fbo.h"
430e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt#include "intel_buffers.h"
446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "i830_context.h"
466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "i830_reg.h"
476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define FILE_DEBUG_FLAG DEBUG_STATE
496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
51f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830StencilFuncSeparate(struct gl_context * ctx, GLenum face, GLenum func, GLint ref,
526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                        GLuint mask)
536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int test = intel_translate_compare_func(func);
566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   mask = mask & 0xff;
586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s : func: %s, ref : 0x%x, mask: 0x%x\n", __FUNCTION__,
606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(func), ref, mask);
616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK;
656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK |
666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           STENCIL_TEST_MASK(mask));
676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK |
686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_STENCIL_TEST_FUNC_MASK);
696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_REF_VALUE |
706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                               ENABLE_STENCIL_TEST_FUNC |
716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                               STENCIL_REF_VALUE(ref) |
726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                               STENCIL_TEST_FUNC(test));
736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
76f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830StencilMaskSeparate(struct gl_context * ctx, GLenum face, GLuint mask)
776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s : mask 0x%x\n", __FUNCTION__, mask);
816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   mask = mask & 0xff;
836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK;
866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK |
876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           STENCIL_WRITE_MASK(mask));
886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
91f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830StencilOpSeparate(struct gl_context * ctx, GLenum face, GLenum fail, GLenum zfail,
926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                      GLenum zpass)
936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int fop, dfop, dpop;
966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s: fail : %s, zfail: %s, zpass : %s\n", __FUNCTION__,
986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(fail),
996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(zfail),
1006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(zpass));
1016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   fop = 0;
1036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   dfop = 0;
1046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   dpop = 0;
1056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   switch (fail) {
1076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_KEEP:
1086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fop = STENCILOP_KEEP;
1096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_ZERO:
1116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fop = STENCILOP_ZERO;
1126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_REPLACE:
1146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fop = STENCILOP_REPLACE;
1156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_INCR:
1176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fop = STENCILOP_INCRSAT;
1186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_DECR:
1206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fop = STENCILOP_DECRSAT;
1216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_INCR_WRAP:
1236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fop = STENCILOP_INCR;
1246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_DECR_WRAP:
1266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fop = STENCILOP_DECR;
1276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_INVERT:
1296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fop = STENCILOP_INVERT;
1306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   default:
1326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
1346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   switch (zfail) {
1356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_KEEP:
1366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dfop = STENCILOP_KEEP;
1376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_ZERO:
1396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dfop = STENCILOP_ZERO;
1406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_REPLACE:
1426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dfop = STENCILOP_REPLACE;
1436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_INCR:
1456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dfop = STENCILOP_INCRSAT;
1466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_DECR:
1486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dfop = STENCILOP_DECRSAT;
1496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_INCR_WRAP:
1516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dfop = STENCILOP_INCR;
1526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_DECR_WRAP:
1546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dfop = STENCILOP_DECR;
1556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_INVERT:
1576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dfop = STENCILOP_INVERT;
1586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   default:
1606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
1626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   switch (zpass) {
1636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_KEEP:
1646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dpop = STENCILOP_KEEP;
1656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_ZERO:
1676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dpop = STENCILOP_ZERO;
1686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_REPLACE:
1706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dpop = STENCILOP_REPLACE;
1716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_INCR:
1736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dpop = STENCILOP_INCRSAT;
1746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_DECR:
1766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dpop = STENCILOP_DECRSAT;
1776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_INCR_WRAP:
1796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dpop = STENCILOP_INCR;
1806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_DECR_WRAP:
1826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dpop = STENCILOP_DECR;
1836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_INVERT:
1856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      dpop = STENCILOP_INVERT;
1866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   default:
1886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
1896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
1906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
1936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_OPS_MASK);
1946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_PARMS |
1956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                               STENCIL_FAIL_OP(fop) |
1966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                               STENCIL_PASS_DEPTH_FAIL_OP
1976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                               (dfop) |
1986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                               STENCIL_PASS_DEPTH_PASS_OP
1996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                               (dpop));
2006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
2016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
203f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830AlphaFunc(struct gl_context * ctx, GLenum func, GLfloat ref)
2046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
2056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
2066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int test = intel_translate_compare_func(func);
2076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLubyte refByte;
2086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint refInt;
2096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   UNCLAMPED_FLOAT_TO_UBYTE(refByte, ref);
2116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   refInt = (GLuint) refByte;
2126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
2146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE2] &= ~ALPHA_TEST_REF_MASK;
2156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE2] |= (ENABLE_ALPHA_TEST_FUNC |
2166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           ENABLE_ALPHA_REF_VALUE |
2176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           ALPHA_TEST_FUNC(test) |
2186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           ALPHA_REF_VALUE(refInt));
2196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
2206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/**
2226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Makes sure that the proper enables are set for LogicOp, Independant Alpha
2236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Blend, and Blending.  It needs to be called from numerous places where we
2246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * could change the LogicOp or Independant Alpha Blend without subsequent
2256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * calls to glEnable.
2266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell *
2276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * \todo
2286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * This function is substantially different from the old i830-specific driver.
2296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * I'm not sure which is correct.
2306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
2316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
232f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830EvalLogicOpBlendState(struct gl_context * ctx)
2336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
2346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
2356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
2376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
238decc6e2a32ef49e673c081f30e19b8970155d887Brian Paul   if (_mesa_rgba_logicop_enabled(ctx)) {
2396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
2406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                  ENABLE_LOGIC_OP_MASK);
2416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND |
2426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                 ENABLE_LOGIC_OP);
2436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
2446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else if (ctx->Color.BlendEnabled) {
2456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
2466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                  ENABLE_LOGIC_OP_MASK);
2476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (ENABLE_COLOR_BLEND |
2486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                 DISABLE_LOGIC_OP);
2496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
2506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else {
2516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
2526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                  ENABLE_LOGIC_OP_MASK);
2536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND |
2546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                 DISABLE_LOGIC_OP);
2556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
2566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
2576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
259f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830BlendColor(struct gl_context * ctx, const GLfloat color[4])
2606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
2616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
2626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLubyte r, g, b, a;
2636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s\n", __FUNCTION__);
2656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   UNCLAMPED_FLOAT_TO_UBYTE(r, color[RCOMP]);
2676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   UNCLAMPED_FLOAT_TO_UBYTE(g, color[GCOMP]);
2686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   UNCLAMPED_FLOAT_TO_UBYTE(b, color[BCOMP]);
2696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   UNCLAMPED_FLOAT_TO_UBYTE(a, color[ACOMP]);
2706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
2726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] =
2736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      (a << 24) | (r << 16) | (g << 8) | b;
2746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
2756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/**
2776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Sets both the blend equation (called "function" in i830 docs) and the
2786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * blend function (called "factor" in i830 docs).  This is done in a single
2796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * function because some blend equations (i.e., \c GL_MIN and \c GL_MAX)
2806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * change the interpretation of the blend function.
2816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
2826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
283f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830_set_blend_state(struct gl_context * ctx)
2846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
2856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
2866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int funcA;
2876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int funcRGB;
2886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int eqnA;
2896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int eqnRGB;
2906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int iab;
2916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int s1;
2926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   funcRGB =
29574713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul      SRC_BLND_FACT(intel_translate_blend_factor(ctx->Color.Blend[0].SrcRGB))
29674713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul      | DST_BLND_FACT(intel_translate_blend_factor(ctx->Color.Blend[0].DstRGB));
2976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
29874713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul   switch (ctx->Color.Blend[0].EquationRGB) {
2996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_FUNC_ADD:
3006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnRGB = BLENDFUNC_ADD;
3016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_MIN:
3036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnRGB = BLENDFUNC_MIN;
3046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
3056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_MAX:
3076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnRGB = BLENDFUNC_MAX;
3086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
3096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_FUNC_SUBTRACT:
3116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnRGB = BLENDFUNC_SUB;
3126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_FUNC_REVERSE_SUBTRACT:
3146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnRGB = BLENDFUNC_RVRSE_SUB;
3156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   default:
3176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fprintf(stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
31874713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul              __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationRGB);
3196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      return;
3206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
3216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
32374713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul   funcA = SRC_ABLEND_FACT(intel_translate_blend_factor(ctx->Color.Blend[0].SrcA))
32474713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul      | DST_ABLEND_FACT(intel_translate_blend_factor(ctx->Color.Blend[0].DstA));
3256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
32674713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul   switch (ctx->Color.Blend[0].EquationA) {
3276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_FUNC_ADD:
3286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnA = BLENDFUNC_ADD;
3296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_MIN:
3316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnA = BLENDFUNC_MIN;
3326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
3336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_MAX:
3356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnA = BLENDFUNC_MAX;
3366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
3376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_FUNC_SUBTRACT:
3396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnA = BLENDFUNC_SUB;
3406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_FUNC_REVERSE_SUBTRACT:
3426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      eqnA = BLENDFUNC_RVRSE_SUB;
3436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
3446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   default:
3456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fprintf(stderr, "[%s:%u] Invalid alpha blend equation (0x%04x).\n",
34674713e2d293f9e796a4053a5a99ee5cb7df5c740Brian Paul              __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationA);
3476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      return;
3486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
3496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   iab = eqnA | funcA
3516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      | _3DSTATE_INDPT_ALPHA_BLEND_CMD
3526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      | ENABLE_SRC_ABLEND_FACTOR | ENABLE_DST_ABLEND_FACTOR
3536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      | ENABLE_ALPHA_BLENDFUNC;
3546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   s1 = eqnRGB | funcRGB
3556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      | _3DSTATE_MODES_1_CMD
3566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      | ENABLE_SRC_BLND_FACTOR | ENABLE_DST_BLND_FACTOR
3576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      | ENABLE_COLR_BLND_FUNC;
3586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if ((eqnA | funcA) != (eqnRGB | funcRGB))
3606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      iab |= ENABLE_INDPT_ALPHA_BLEND;
3616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else
3626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      iab |= DISABLE_INDPT_ALPHA_BLEND;
3636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (iab != i830->state.Ctx[I830_CTXREG_IALPHAB] ||
3656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       s1 != i830->state.Ctx[I830_CTXREG_STATE1]) {
3666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_CTX);
3676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_IALPHAB] = iab;
3686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_STATE1] = s1;
3696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
3706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   /* This will catch a logicop blend equation.  It will also ensure
3726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell    * independant alpha blend is really in the correct state (either enabled
3736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell    * or disabled) if blending is already enabled.
3746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell    */
3756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830EvalLogicOpBlendState(ctx);
3776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (0) {
3796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      fprintf(stderr,
3806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell              "[%s:%u] STATE1: 0x%08x IALPHAB: 0x%08x blend is %sabled\n",
3816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell              __FUNCTION__, __LINE__, i830->state.Ctx[I830_CTXREG_STATE1],
3826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell              i830->state.Ctx[I830_CTXREG_IALPHAB],
3836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell              (ctx->Color.BlendEnabled) ? "en" : "dis");
3846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
3856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
3866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
389f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830BlendEquationSeparate(struct gl_context * ctx, GLenum modeRGB, GLenum modeA)
3906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
3916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s -> %s, %s\n", __FUNCTION__,
3926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(modeRGB),
3936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(modeA));
3946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   (void) modeRGB;
3966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   (void) modeA;
3976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830_set_blend_state(ctx);
3986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
3996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
402f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830BlendFuncSeparate(struct gl_context * ctx, GLenum sfactorRGB,
4036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                      GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA)
4046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
4056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s -> RGB(%s, %s) A(%s, %s)\n", __FUNCTION__,
4066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(sfactorRGB),
4076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(dfactorRGB),
4086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(sfactorA),
4096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       _mesa_lookup_enum_by_nr(dfactorA));
4106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   (void) sfactorRGB;
4126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   (void) dfactorRGB;
4136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   (void) sfactorA;
4146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   (void) dfactorA;
4156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830_set_blend_state(ctx);
4166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
4176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
421f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830DepthFunc(struct gl_context * ctx, GLenum func)
4226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
4236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
4246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int test = intel_translate_compare_func(func);
4256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s\n", __FUNCTION__);
4276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
4296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK;
4306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC |
4316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           DEPTH_TEST_FUNC(test));
4326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
4336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
435f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830DepthMask(struct gl_context * ctx, GLboolean flag)
4366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
4376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
4386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s flag (%d)\n", __FUNCTION__, flag);
4406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
4426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK;
4446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (flag && ctx->Depth.Test)
4466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DEPTH_WRITE;
4476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else
4486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;
4496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
4506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4510e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt/** Called from ctx->Driver.Viewport() */
4520e83e8f51af07a3066519f169f07d9afbf23252eEric Anholtstatic void
453f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830Viewport(struct gl_context * ctx,
4540e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt              GLint x, GLint y, GLsizei width, GLsizei height)
4550e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt{
4560e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt   intelCalcViewport(ctx);
4570e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt}
4580e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt
4590e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt
4600e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt/** Called from ctx->Driver.DepthRange() */
4610e83e8f51af07a3066519f169f07d9afbf23252eEric Anholtstatic void
462f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830DepthRange(struct gl_context * ctx, GLclampd nearval, GLclampd farval)
4630e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt{
4640e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt   intelCalcViewport(ctx);
4650e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt}
4660e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt
4676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* =============================================================
4686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Polygon stipple
4696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell *
4706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * The i830 supports a 4x4 stipple natively, GL wants 32x32.
4716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Fortunately stipple is usually a repeating pattern.
4726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
4736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
474f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830PolygonStipple(struct gl_context * ctx, const GLubyte * mask)
4756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
4766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
4776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   const GLubyte *m = mask;
4786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLubyte p[4];
4796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int i, j, k;
4806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int active = (ctx->Polygon.StippleFlag &&
4816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                 i830->intel.reduced_primitive == GL_TRIANGLES);
4826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint newMask;
4836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (active) {
4856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE);
4866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE;
4876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
4886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   p[0] = mask[12] & 0xf;
4906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   p[0] |= p[0] << 4;
4916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   p[1] = mask[8] & 0xf;
4926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   p[1] |= p[1] << 4;
4936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   p[2] = mask[4] & 0xf;
4946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   p[2] |= p[2] << 4;
4956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   p[3] = mask[0] & 0xf;
4966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   p[3] |= p[3] << 4;
4976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
4986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   for (k = 0; k < 8; k++)
4996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      for (j = 3; j >= 0; j--)
5006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         for (i = 0; i < 4; i++, m++)
5016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            if (*m != p[j]) {
5026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell               i830->intel.hw_stipple = 0;
5036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell               return;
5046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            }
5056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   newMask = (((p[0] & 0xf) << 0) |
5076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell              ((p[1] & 0xf) << 4) |
5086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell              ((p[2] & 0xf) << 8) | ((p[3] & 0xf) << 12));
5096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (newMask == 0xffff || newMask == 0x0) {
5126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      /* this is needed to make conform pass */
5136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->intel.hw_stipple = 0;
5146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      return;
5156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
5166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Stipple[I830_STPREG_ST1] &= ~0xffff;
5186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Stipple[I830_STPREG_ST1] |= newMask;
5196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->intel.hw_stipple = 1;
5206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (active)
5226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Stipple[I830_STPREG_ST1] |= ST1_ENABLE;
5236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
5246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* =============================================================
5276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Hardware clipping
5286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
5296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
530f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
5316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
5326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
5336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int x1, y1, x2, y2;
5346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (!ctx->DrawBuffer)
5366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      return;
5376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h);
5396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (ctx->DrawBuffer->Name == 0) {
5416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      x1 = x;
5426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      y1 = ctx->DrawBuffer->Height - (y + h);
5436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      x2 = x + w - 1;
5446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      y2 = y1 + h - 1;
5456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      DBG("%s %d..%d,%d..%d (inverted)\n", __FUNCTION__, x1, x2, y1, y2);
5466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
5476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else {
5486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      /* FBO - not inverted
5496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       */
5506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      x1 = x;
5516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      y1 = y;
5526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      x2 = x + w - 1;
5536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      y2 = y + h - 1;
5546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      DBG("%s %d..%d,%d..%d (not inverted)\n", __FUNCTION__, x1, x2, y1, y2);
5556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
5566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   x1 = CLAMP(x1, 0, ctx->DrawBuffer->Width - 1);
5586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   y1 = CLAMP(y1, 0, ctx->DrawBuffer->Height - 1);
5596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   x2 = CLAMP(x2, 0, ctx->DrawBuffer->Width - 1);
5606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   y2 = CLAMP(y2, 0, ctx->DrawBuffer->Height - 1);
5616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s %d..%d,%d..%d (clamped)\n", __FUNCTION__, x1, x2, y1, y2);
5636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
5656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Buffer[I830_DESTREG_SR1] = (y1 << 16) | (x1 & 0xffff);
5666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Buffer[I830_DESTREG_SR2] = (y2 << 16) | (x2 & 0xffff);
5676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
5686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
570f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830LogicOp(struct gl_context * ctx, GLenum opcode)
5716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
5726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
5736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int tmp = intel_translate_logic_op(opcode);
5746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s\n", __FUNCTION__);
5766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
5786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE4] &= ~LOGICOP_MASK;
5796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE4] |= LOGIC_OP_FUNC(tmp);
5806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
5816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
585f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830CullFaceFrontFace(struct gl_context * ctx, GLenum unused)
5866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
5876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
5886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint mode;
5896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s\n", __FUNCTION__);
5916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (!ctx->Polygon.CullFlag) {
5936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      mode = CULLMODE_NONE;
5946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
5956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) {
5966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      mode = CULLMODE_CW;
5976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
5986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      if (ctx->Polygon.CullFaceMode == GL_FRONT)
5996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
6006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      if (ctx->Polygon.FrontFace != GL_CCW)
6016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
6026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
6036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else {
6046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      mode = CULLMODE_BOTH;
6056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
6066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
6086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE3] &= ~CULLMODE_MASK;
6096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE3] |= ENABLE_CULL_MODE | mode;
6106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
6116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
613f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830LineWidth(struct gl_context * ctx, GLfloat widthf)
6146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
6156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
6166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int width;
6176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   int state5;
6186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s\n", __FUNCTION__);
6206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   width = (int) (widthf * 2);
622d203dbc73d3b036937e0404b580fb04d23e10652Eric Anholt   width = CLAMP(width, 1, 15);
6236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   state5 = i830->state.Ctx[I830_CTXREG_STATE5] & ~FIXED_LINE_WIDTH_MASK;
6256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   state5 |= (ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(width));
6266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (state5 != i830->state.Ctx[I830_CTXREG_STATE5]) {
6286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_CTX);
6296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_STATE5] = state5;
6306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
6316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
6326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
634f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830PointSize(struct gl_context * ctx, GLfloat size)
6356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
6366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
6376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLint point_size = (int) size;
6386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s\n", __FUNCTION__);
6406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
641d203dbc73d3b036937e0404b580fb04d23e10652Eric Anholt   point_size = CLAMP(point_size, 1, 256);
6426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
6436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE5] &= ~FIXED_POINT_WIDTH_MASK;
6446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE5] |= (ENABLE_FIXED_POINT_WIDTH |
6456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           FIXED_POINT_WIDTH(point_size));
6466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
6476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* =============================================================
6506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Color masks
6516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
6526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
654f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830ColorMask(struct gl_context * ctx,
6556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell              GLboolean r, GLboolean g, GLboolean b, GLboolean a)
6566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
6576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
6586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint tmp = 0;
6596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a);
6616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   tmp = ((i830->state.Ctx[I830_CTXREG_ENABLES_2] & ~WRITEMASK_MASK) |
6636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          ENABLE_COLOR_MASK |
6646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          ENABLE_COLOR_WRITE |
6656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          ((!r) << WRITEMASK_RED_SHIFT) |
6666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          ((!g) << WRITEMASK_GREEN_SHIFT) |
6676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          ((!b) << WRITEMASK_BLUE_SHIFT) | ((!a) << WRITEMASK_ALPHA_SHIFT));
6686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (tmp != i830->state.Ctx[I830_CTXREG_ENABLES_2]) {
6706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_CTX);
6716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_2] = tmp;
6726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
6736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
6746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
676f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergupdate_specular(struct gl_context * ctx)
6776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
6786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
6796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
6816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK;
6826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
683decc6e2a32ef49e673c081f30e19b8970155d887Brian Paul   if (_mesa_need_secondary_color(ctx))
6846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_SPEC_ADD;
6856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else
6866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_SPEC_ADD;
6876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
6886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
690f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830LightModelfv(struct gl_context * ctx, GLenum pname, const GLfloat * param)
6916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
6926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s\n", __FUNCTION__);
6936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
6956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      update_specular(ctx);
6966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
6976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
6986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
6996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* In Mesa 3.5 we can reliably do native flatshading.
7006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
7016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
702f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830ShadeModel(struct gl_context * ctx, GLenum mode)
7036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
7046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
7056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
7066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define SHADE_MODE_MASK ((1<<10)|(1<<8)|(1<<6)|(1<<4))
7096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE3] &= ~SHADE_MODE_MASK;
7116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (mode == GL_FLAT) {
7136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_STATE3] |=
7146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         (ALPHA_SHADE_MODE(SHADE_MODE_FLAT) | FOG_SHADE_MODE(SHADE_MODE_FLAT)
7156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          | SPEC_SHADE_MODE(SHADE_MODE_FLAT) |
7166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          COLOR_SHADE_MODE(SHADE_MODE_FLAT));
7176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
7186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else {
7196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_STATE3] |=
7206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         (ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) |
7216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          FOG_SHADE_MODE(SHADE_MODE_LINEAR) |
7226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          SPEC_SHADE_MODE(SHADE_MODE_LINEAR) |
7236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          COLOR_SHADE_MODE(SHADE_MODE_LINEAR));
7246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
7256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
7266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* =============================================================
7286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Fog
7296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
7306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
731f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830Fogfv(struct gl_context * ctx, GLenum pname, const GLfloat * param)
7326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
7336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
7346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   DBG("%s\n", __FUNCTION__);
7366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (pname == GL_FOG_COLOR) {
7386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      GLuint color = (((GLubyte) (ctx->Fog.Color[0] * 255.0F) << 16) |
7396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                      ((GLubyte) (ctx->Fog.Color[1] * 255.0F) << 8) |
7406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                      ((GLubyte) (ctx->Fog.Color[2] * 255.0F) << 0));
7416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_CTX);
7436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_FOGCOLOR] =
7446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         (_3DSTATE_FOG_COLOR_CMD | color);
7456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
7466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
7476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* =============================================================
7496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
7506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
752f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830Enable(struct gl_context * ctx, GLenum cap, GLboolean state)
7536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
7546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i830_context *i830 = i830_context(ctx);
7556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   switch (cap) {
7576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_LIGHTING:
7586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_COLOR_SUM:
7596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      update_specular(ctx);
7606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
7616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_ALPHA_TEST:
7636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_CTX);
7646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_ALPHA_TEST_MASK;
7656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      if (state)
7666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_ALPHA_TEST;
7676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      else
7686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_ALPHA_TEST;
7696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
7716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_BLEND:
7736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830EvalLogicOpBlendState(ctx);
7746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
7756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_COLOR_LOGIC_OP:
7776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830EvalLogicOpBlendState(ctx);
7786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      /* Logicop doesn't seem to work at 16bpp:
7806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       */
78146eb02b60920a920b782bacb15f01b44e18f888dKristian Høgsberg      if (i830->intel.ctx.Visual.rgbBits == 16)
7826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         FALLBACK(&i830->intel, I830_FALLBACK_LOGICOP, state);
7836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
7846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_DITHER:
7866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_CTX);
7876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DITHER;
7886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      if (state)
7906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DITHER;
7916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      else
7926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DITHER;
7936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
7946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_DEPTH_TEST:
7966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_CTX);
7976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK;
7986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
7996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      if (state)
8006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST;
8016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      else
8026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST;
8036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      /* Also turn off depth writes when GL_DEPTH_TEST is disabled:
8056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       */
8066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830DepthMask(ctx, ctx->Depth.Mask);
8076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
8086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_SCISSOR_TEST:
8106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
8116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      if (state)
8136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Buffer[I830_DESTREG_SENABLE] =
8146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            (_3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT);
8156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      else
8166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Buffer[I830_DESTREG_SENABLE] =
8176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            (_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
8186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
8206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_LINE_SMOOTH:
8226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_CTX);
8236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_AA] &= ~AA_LINE_ENABLE;
8256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      if (state)
8266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_ENABLE;
8276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      else
8286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_DISABLE;
8296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
8306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_FOG:
8326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      I830_STATECHANGE(i830, I830_UPLOAD_CTX);
8336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_FOG_MASK;
8346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      if (state)
8356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_FOG;
8366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      else
8376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_FOG;
8386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
8396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_CULL_FACE:
8416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830CullFaceFrontFace(ctx, 0);
8426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
8436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_TEXTURE_2D:
8456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
8466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_STENCIL_TEST:
8486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      {
8496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         GLboolean hw_stencil = GL_FALSE;
8506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         if (ctx->DrawBuffer) {
8516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            struct intel_renderbuffer *irbStencil
8526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell               = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL);
8536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            hw_stencil = (irbStencil && irbStencil->region);
8546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         }
8556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         if (hw_stencil) {
8566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            I830_STATECHANGE(i830, I830_UPLOAD_CTX);
8576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            if (state) {
8596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell               i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_STENCIL_TEST;
8606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell               i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_STENCIL_WRITE;
8616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            }
8626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            else {
8636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell               i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_STENCIL_TEST;
8646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell               i830->state.Ctx[I830_CTXREG_ENABLES_2] &=
8656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                  ~ENABLE_STENCIL_WRITE;
8666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell               i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_STENCIL_TEST;
8676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell               i830->state.Ctx[I830_CTXREG_ENABLES_2] |=
8686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                  DISABLE_STENCIL_WRITE;
8696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            }
8706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         }
8716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         else {
8726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            FALLBACK(&i830->intel, I830_FALLBACK_STENCIL, state);
8736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         }
8746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      }
8756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
8766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   case GL_POLYGON_STIPPLE:
8786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      /* The stipple command worked on my 855GM box, but not my 845G.
8796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       * I'll do more testing later to find out exactly which hardware
8806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       * supports it.  Disabled for now.
8816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell       */
8826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      if (i830->intel.hw_stipple &&
8836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell          i830->intel.reduced_primitive == GL_TRIANGLES) {
8846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE);
8856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         i830->state.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE;
8866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell         if (state)
8876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell            i830->state.Stipple[I830_STPREG_ST1] |= ST1_ENABLE;
8886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      }
8896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      break;
8906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   default:
8926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      ;
8936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
8946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
8956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
8976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void
8986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli830_init_packets(struct i830_context *i830)
8996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
9006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   /* Zero all state */
9016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   memset(&i830->state, 0, sizeof(i830->state));
9026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   /* Set default blend state */
9046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.TexBlend[0][0] = (_3DSTATE_MAP_BLEND_OP_CMD(0) |
9056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXPIPE_COLOR |
9066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 ENABLE_TEXOUTPUT_WRT_SEL |
9076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXOP_OUTPUT_CURRENT |
9086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 DISABLE_TEX_CNTRL_STAGE |
9096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXOP_SCALE_1X |
9106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXOP_MODIFY_PARMS |
9116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXOP_LAST_STAGE | TEXBLENDOP_ARG1);
9126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.TexBlend[0][1] = (_3DSTATE_MAP_BLEND_OP_CMD(0) |
9136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXPIPE_ALPHA |
9146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 ENABLE_TEXOUTPUT_WRT_SEL |
9156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXOP_OUTPUT_CURRENT |
9166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXOP_SCALE_1X |
9176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXOP_MODIFY_PARMS | TEXBLENDOP_ARG1);
9186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.TexBlend[0][2] = (_3DSTATE_MAP_BLEND_ARG_CMD(0) |
9196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXPIPE_COLOR |
9206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXBLEND_ARG1 |
9216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXBLENDARG_MODIFY_PARMS |
9226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXBLENDARG_DIFFUSE);
9236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.TexBlend[0][3] = (_3DSTATE_MAP_BLEND_ARG_CMD(0) |
9246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXPIPE_ALPHA |
9256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXBLEND_ARG1 |
9266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXBLENDARG_MODIFY_PARMS |
9276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 TEXBLENDARG_DIFFUSE);
9286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.TexBlendWordsUsed[0] = 4;
9306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_VF] = 0;
9336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_VF2] = 0;
9346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_AA] = (_3DSTATE_AA_CMD |
9366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                      AA_LINE_ECAAR_WIDTH_ENABLE |
9376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                      AA_LINE_ECAAR_WIDTH_1_0 |
9386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                      AA_LINE_REGION_WIDTH_ENABLE |
9396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                      AA_LINE_REGION_WIDTH_1_0 |
9406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                      AA_LINE_DISABLE);
9416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_ENABLES_1] = (_3DSTATE_ENABLES_1_CMD |
9436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                             DISABLE_LOGIC_OP |
9446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                             DISABLE_STENCIL_TEST |
9456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                             DISABLE_DEPTH_BIAS |
9466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                             DISABLE_SPEC_ADD |
9476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                             DISABLE_FOG |
9486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                             DISABLE_ALPHA_TEST |
9496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                             DISABLE_COLOR_BLEND |
9506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                             DISABLE_DEPTH_TEST);
9516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#if 000                         /* XXX all the stencil enable state is set in i830Enable(), right? */
9536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (i830->intel.hw_stencil) {
9546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_2] = (_3DSTATE_ENABLES_2_CMD |
9556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_STENCIL_WRITE |
9566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_TEX_CACHE |
9576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_DITHER |
9586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_COLOR_MASK |
9596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                /* set no color comps disabled */
9606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_COLOR_WRITE |
9616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_DEPTH_WRITE);
9626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
9636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else
9646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#endif
9656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   {
9666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      i830->state.Ctx[I830_CTXREG_ENABLES_2] = (_3DSTATE_ENABLES_2_CMD |
9676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                DISABLE_STENCIL_WRITE |
9686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_TEX_CACHE |
9696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_DITHER |
9706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_COLOR_MASK |
9716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                /* set no color comps disabled */
9726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_COLOR_WRITE |
9736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                                ENABLE_DEPTH_WRITE);
9746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   }
9756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE1] = (_3DSTATE_MODES_1_CMD |
9776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_COLR_BLND_FUNC |
9786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          BLENDFUNC_ADD |
9796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_SRC_BLND_FACTOR |
9806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          SRC_BLND_FACT(BLENDFACT_ONE) |
9816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_DST_BLND_FACTOR |
9826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          DST_BLND_FACT(BLENDFACT_ZERO));
9836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE2] = (_3DSTATE_MODES_2_CMD |
9856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_GLOBAL_DEPTH_BIAS |
9866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          GLOBAL_DEPTH_BIAS(0) |
9876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_ALPHA_TEST_FUNC |
9886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ALPHA_TEST_FUNC(COMPAREFUNC_ALWAYS)
9896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          | ALPHA_REF_VALUE(0));
9906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
9916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE3] = (_3DSTATE_MODES_3_CMD |
9926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_DEPTH_TEST_FUNC |
9936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          DEPTH_TEST_FUNC(COMPAREFUNC_LESS) |
9946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_ALPHA_SHADE_MODE |
9956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ALPHA_SHADE_MODE(SHADE_MODE_LINEAR)
9966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          | ENABLE_FOG_SHADE_MODE |
9976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          FOG_SHADE_MODE(SHADE_MODE_LINEAR) |
9986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_SPEC_SHADE_MODE |
9996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          SPEC_SHADE_MODE(SHADE_MODE_LINEAR) |
10006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_COLOR_SHADE_MODE |
10016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          COLOR_SHADE_MODE(SHADE_MODE_LINEAR)
10026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          | ENABLE_CULL_MODE | CULLMODE_NONE);
10036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE4] = (_3DSTATE_MODES_4_CMD |
10056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_LOGIC_OP_FUNC |
10066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          LOGIC_OP_FUNC(LOGICOP_COPY) |
10076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_STENCIL_TEST_MASK |
10086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          STENCIL_TEST_MASK(0xff) |
10096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_STENCIL_WRITE_MASK |
10106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          STENCIL_WRITE_MASK(0xff));
10116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STENCILTST] = (_3DSTATE_STENCIL_TEST_CMD |
10136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              ENABLE_STENCIL_PARMS |
10146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              STENCIL_FAIL_OP(STENCILOP_KEEP)
10156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              |
10166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              STENCIL_PASS_DEPTH_FAIL_OP
10176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              (STENCILOP_KEEP) |
10186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              STENCIL_PASS_DEPTH_PASS_OP
10196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              (STENCILOP_KEEP) |
10206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              ENABLE_STENCIL_TEST_FUNC |
10216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              STENCIL_TEST_FUNC
10226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              (COMPAREFUNC_ALWAYS) |
10236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              ENABLE_STENCIL_REF_VALUE |
10246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                              STENCIL_REF_VALUE(0));
10256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_STATE5] = (_3DSTATE_MODES_5_CMD | FLUSH_TEXTURE_CACHE | ENABLE_SPRITE_POINT_TEX | SPRITE_POINT_TEX_OFF | ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(0x2) |       /* 1.0 */
10276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          ENABLE_FIXED_POINT_WIDTH |
10286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                          FIXED_POINT_WIDTH(1));
10296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_IALPHAB] = (_3DSTATE_INDPT_ALPHA_BLEND_CMD |
10316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           DISABLE_INDPT_ALPHA_BLEND |
10326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           ENABLE_ALPHA_BLENDFUNC |
10336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                           ABLENDFUNC_ADD);
10346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_FOGCOLOR] = (_3DSTATE_FOG_COLOR_CMD |
10366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                            FOG_COLOR_RED(0) |
10376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                            FOG_COLOR_GREEN(0) |
10386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                            FOG_COLOR_BLUE(0));
10396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_BLENDCOLOR0] = _3DSTATE_CONST_BLEND_COLOR_CMD;
10416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] = 0;
10426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_MCSB0] = _3DSTATE_MAP_COORD_SETBIND_CMD;
10446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Ctx[I830_CTXREG_MCSB1] = (TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) |
10456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                         TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) |
10466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                         TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) |
10476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                         TEXBIND_SET0(TEXCOORDSRC_VTXSET_0));
10486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1049de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   i830->state.RasterRules[I830_RASTER_RULES] = (_3DSTATE_RASTER_RULES_CMD |
1050de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						 ENABLE_POINT_RASTER_RULE |
1051de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						 OGL_POINT_RASTER_RULE |
1052de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						 ENABLE_LINE_STRIP_PROVOKE_VRTX |
1053de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						 ENABLE_TRI_FAN_PROVOKE_VRTX |
1054de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						 ENABLE_TRI_STRIP_PROVOKE_VRTX |
1055de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						 LINE_STRIP_PROVOKE_VRTX(1) |
1056de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						 TRI_FAN_PROVOKE_VRTX(2) |
1057de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						 TRI_STRIP_PROVOKE_VRTX(2));
1058de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt
10596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Stipple[I830_STPREG_ST0] = _3DSTATE_STIPPLE;
10616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Buffer[I830_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD;
10636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Buffer[I830_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD |
10646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                               DISABLE_SCISSOR_RECT);
10656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Buffer[I830_DESTREG_SR0] = _3DSTATE_SCISSOR_RECT_0_CMD;
10666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Buffer[I830_DESTREG_SR1] = 0;
10676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.Buffer[I830_DESTREG_SR2] = 0;
10686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
10696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1070de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholtvoid
1071f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi830_update_provoking_vertex(struct gl_context * ctx)
1072de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt{
1073de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   struct i830_context *i830 = i830_context(ctx);
1074de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt
1075de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   I830_STATECHANGE(i830, I830_UPLOAD_RASTER_RULES);
1076de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   i830->state.RasterRules[I830_RASTER_RULES] &= ~(LINE_STRIP_PROVOKE_VRTX_MASK |
1077de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						   TRI_FAN_PROVOKE_VRTX_MASK |
1078de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						   TRI_STRIP_PROVOKE_VRTX_MASK);
1079de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt
1080de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   /* _NEW_LIGHT */
1081de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION) {
1082de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt      i830->state.RasterRules[I830_RASTER_RULES] |= (LINE_STRIP_PROVOKE_VRTX(1) |
1083de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						     TRI_FAN_PROVOKE_VRTX(2) |
1084de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						     TRI_STRIP_PROVOKE_VRTX(2));
1085de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   } else {
1086de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt      i830->state.RasterRules[I830_RASTER_RULES] |= (LINE_STRIP_PROVOKE_VRTX(0) |
1087de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						     TRI_FAN_PROVOKE_VRTX(1) |
1088de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt						     TRI_STRIP_PROVOKE_VRTX(0));
1089de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt    }
1090de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt}
10916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
10926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellvoid
10936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli830InitStateFuncs(struct dd_function_table *functions)
10946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
10956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->AlphaFunc = i830AlphaFunc;
10966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->BlendColor = i830BlendColor;
10976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->BlendEquationSeparate = i830BlendEquationSeparate;
10986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->BlendFuncSeparate = i830BlendFuncSeparate;
10996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->ColorMask = i830ColorMask;
11006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->CullFace = i830CullFaceFrontFace;
11016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->DepthFunc = i830DepthFunc;
11026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->DepthMask = i830DepthMask;
11036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->Enable = i830Enable;
11046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->Fogfv = i830Fogfv;
11056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->FrontFace = i830CullFaceFrontFace;
11066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->LightModelfv = i830LightModelfv;
11076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->LineWidth = i830LineWidth;
11086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->LogicOpcode = i830LogicOp;
11096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->PointSize = i830PointSize;
11106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->PolygonStipple = i830PolygonStipple;
11116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->Scissor = i830Scissor;
11126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->ShadeModel = i830ShadeModel;
11136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->StencilFuncSeparate = i830StencilFuncSeparate;
11146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->StencilMaskSeparate = i830StencilMaskSeparate;
11156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   functions->StencilOpSeparate = i830StencilOpSeparate;
11160e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt   functions->DepthRange = i830DepthRange;
11170e83e8f51af07a3066519f169f07d9afbf23252eEric Anholt   functions->Viewport = i830Viewport;
11186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
11196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
11206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellvoid
11216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli830InitState(struct i830_context *i830)
11226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
1123f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg   struct gl_context *ctx = &i830->intel.ctx;
11246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
11256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830_init_packets(i830);
11266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1127a194bc3a8527ed41eead88632cc79ecabe4c81acBrian   _mesa_init_driver_state(ctx);
11286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
11296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.emitted = 0;
11306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   i830->state.active = (I830_UPLOAD_INVARIENT |
1131de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt                         I830_UPLOAD_RASTER_RULES |
11326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                         I830_UPLOAD_TEXBLEND(0) |
11336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                         I830_UPLOAD_STIPPLE |
11346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                         I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS);
11356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
1136