18e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell/**************************************************************************
28e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
38e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
48e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * All Rights Reserved.
58e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
68e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a
78e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * copy of this software and associated documentation files (the
88e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * "Software"), to deal in the Software without restriction, including
98e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish,
108e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to
118e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to
128e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * the following conditions:
138e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
148e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * The above copyright notice and this permission notice (including the
158e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * next paragraph) shall be included in all copies or substantial portions
168e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * of the Software.
178e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
188e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
198e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
208e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
218e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
228e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
238e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
248e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
258e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
268e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell **************************************************************************/
278e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
288e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell /*
298e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell  * Authors:
308e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell  *   Keith Whitwell <keith@tungstengraphics.com>
318e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell  */
328e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
3309ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian#include "main/macros.h"
348e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell#include "st_context.h"
35339e7ec6805e6de8794514c0a935081b5d36d38fBrian#include "st_atom.h"
36943964a1e5bad86bdceb0a06d60fb3b302ebce6aKeith Whitwell#include "pipe/p_context.h"
37f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian#include "pipe/p_defines.h"
38339e7ec6805e6de8794514c0a935081b5d36d38fBrian#include "cso_cache/cso_context.h"
39339e7ec6805e6de8794514c0a935081b5d36d38fBrian
408e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
418e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwellstatic GLuint translate_fill( GLenum mode )
428e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell{
438e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   switch (mode) {
44f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian   case GL_POINT:
45f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian      return PIPE_POLYGON_MODE_POINT;
46f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian   case GL_LINE:
47f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian      return PIPE_POLYGON_MODE_LINE;
48f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian   case GL_FILL:
49f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian      return PIPE_POLYGON_MODE_FILL;
50f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian   default:
51f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian      assert(0);
52f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian      return 0;
538e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   }
548e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}
558e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
568e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
578e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
58294401814d1d89cc731de1c22c25333aa5d59374Zack Rusinstatic void update_raster_state( struct st_context *st )
598e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell{
60f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg   struct gl_context *ctx = st->ctx;
61339e7ec6805e6de8794514c0a935081b5d36d38fBrian   struct pipe_rasterizer_state *raster = &st->state.rasterizer;
622444f6c6a4c2f54c3198882c2256419628ca49d1Brian   const struct gl_vertex_program *vertProg = ctx->VertexProgram._Current;
63e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul   const struct gl_fragment_program *fragProg = ctx->FragmentProgram._Current;
641b4852345954af9b582b03a91a3d8399b8fb0e92Brian   uint i;
658e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
66339e7ec6805e6de8794514c0a935081b5d36d38fBrian   memset(raster, 0, sizeof(*raster));
67017f862de1f857bca29f09794539aaf411014f13Brian
688e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   /* _NEW_POLYGON, _NEW_BUFFERS
698e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell    */
708e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   {
719c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      raster->front_ccw = (ctx->Polygon.FrontFace == GL_CCW);
728e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
734c251b88613ae3650a7b9eb255b79a95d0c837a7Brian Paul      /*
744c251b88613ae3650a7b9eb255b79a95d0c837a7Brian Paul       * Gallium's surfaces are Y=0=TOP orientation.  OpenGL is the
754c251b88613ae3650a7b9eb255b79a95d0c837a7Brian Paul       * opposite.  Window system surfaces are Y=0=TOP.  Mesa's FBOs
764c251b88613ae3650a7b9eb255b79a95d0c837a7Brian Paul       * must match OpenGL conventions so FBOs use Y=0=BOTTOM.  In that
774c251b88613ae3650a7b9eb255b79a95d0c837a7Brian Paul       * case, we must invert Y and flip the notion of front vs. back.
78dc313b578386dc07f4916fba98da061af3ab18e5Brian       */
794c251b88613ae3650a7b9eb255b79a95d0c837a7Brian Paul      if (st_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM) {
804c251b88613ae3650a7b9eb255b79a95d0c837a7Brian Paul         /* Drawing to an FBO.  The viewport will be inverted. */
819c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell         raster->front_ccw ^= 1;
824c251b88613ae3650a7b9eb255b79a95d0c837a7Brian Paul      }
838e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   }
848e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
858e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   /* _NEW_LIGHT
868e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell    */
878e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   if (ctx->Light.ShadeModel == GL_FLAT)
88339e7ec6805e6de8794514c0a935081b5d36d38fBrian      raster->flatshade = 1;
898e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
90b631d5fbf45f4df44d1c445a9defb8c8f05599e2Brian Paul   if (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION_EXT)
91b631d5fbf45f4df44d1c445a9defb8c8f05599e2Brian Paul      raster->flatshade_first = 1;
92b631d5fbf45f4df44d1c445a9defb8c8f05599e2Brian Paul
93b478fcb9a99ef084674529f7db95f041db4a4796Marek Olšák   /* _NEW_LIGHT | _NEW_PROGRAM */
94b478fcb9a99ef084674529f7db95f041db4a4796Marek Olšák   raster->light_twoside = ctx->VertexProgram._TwoSideEnabled;
958e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
96b478fcb9a99ef084674529f7db95f041db4a4796Marek Olšák   /*_NEW_LIGHT | _NEW_BUFFERS */
97bc1c8369384b5e16547c5bf9728aa78f8dfd66ccMarek Olšák   raster->clamp_vertex_color = !st->clamp_vert_color_in_shader &&
98bc1c8369384b5e16547c5bf9728aa78f8dfd66ccMarek Olšák                                ctx->Light._ClampVertexColor;
9947e3896dfd89a26abbe4ca2469c2480f3982b204Luca Barbieri
1008e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   /* _NEW_POLYGON
1018e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell    */
1028e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   if (ctx->Polygon.CullFlag) {
1039c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      switch (ctx->Polygon.CullFaceMode) {
1049c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      case GL_FRONT:
1059c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell	 raster->cull_face = PIPE_FACE_FRONT;
1069c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell         break;
1079c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      case GL_BACK:
1089c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell	 raster->cull_face = PIPE_FACE_BACK;
1099c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell         break;
1109c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      case GL_FRONT_AND_BACK:
1119c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell	 raster->cull_face = PIPE_FACE_FRONT_AND_BACK;
1129c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell         break;
1138e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell      }
1148e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   }
1159c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell   else {
1169c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      raster->cull_face = PIPE_FACE_NONE;
1179c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell   }
1188e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
1198e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   /* _NEW_POLYGON
1208e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell    */
1218e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   {
1229c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      raster->fill_front = translate_fill( ctx->Polygon.FrontMode );
1239c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      raster->fill_back = translate_fill( ctx->Polygon.BackMode );
1248e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
1258e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell      /* Simplify when culling is active:
1268e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell       */
1279c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      if (raster->cull_face & PIPE_FACE_FRONT) {
1289c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell	 raster->fill_front = raster->fill_back;
1298e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell      }
1308e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
1319c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      if (raster->cull_face & PIPE_FACE_BACK) {
1329c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell	 raster->fill_back = raster->fill_front;
1338e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell      }
1348e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   }
1358e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
136f6dffd6ee70473dcbf65420a9c635049199f7a4eBrian   /* _NEW_POLYGON
1378e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell    */
138f6dffd6ee70473dcbf65420a9c635049199f7a4eBrian   if (ctx->Polygon.OffsetUnits != 0.0 ||
139f6dffd6ee70473dcbf65420a9c635049199f7a4eBrian       ctx->Polygon.OffsetFactor != 0.0) {
1409c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      raster->offset_point = ctx->Polygon.OffsetPoint;
1419c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      raster->offset_line = ctx->Polygon.OffsetLine;
1429c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell      raster->offset_tri = ctx->Polygon.OffsetFill;
1439c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell   }
1449c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell
1459c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell   if (ctx->Polygon.OffsetPoint ||
1469c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell       ctx->Polygon.OffsetLine ||
1479c264642c385557d64b9bc6bbe31d2d15e703affKeith Whitwell       ctx->Polygon.OffsetFill) {
148339e7ec6805e6de8794514c0a935081b5d36d38fBrian      raster->offset_units = ctx->Polygon.OffsetUnits;
149339e7ec6805e6de8794514c0a935081b5d36d38fBrian      raster->offset_scale = ctx->Polygon.OffsetFactor;
150f6dffd6ee70473dcbf65420a9c635049199f7a4eBrian   }
1518e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
1521be17dc446aa6b0770d76a3eccf79d0faf6608c0Brian   if (ctx->Polygon.SmoothFlag)
153339e7ec6805e6de8794514c0a935081b5d36d38fBrian      raster->poly_smooth = 1;
1541be17dc446aa6b0770d76a3eccf79d0faf6608c0Brian
1551be17dc446aa6b0770d76a3eccf79d0faf6608c0Brian   if (ctx->Polygon.StippleFlag)
156339e7ec6805e6de8794514c0a935081b5d36d38fBrian      raster->poly_stipple_enable = 1;
15768f93ea3eb83cfad014b8ec93cec3564c1aa9833Roland Scheidegger
1581be17dc446aa6b0770d76a3eccf79d0faf6608c0Brian   /* _NEW_POINT
1591be17dc446aa6b0770d76a3eccf79d0faf6608c0Brian    */
160339e7ec6805e6de8794514c0a935081b5d36d38fBrian   raster->point_size = ctx->Point.Size;
161bc739440c29c551fcc44e9e12d0d9c170d8d24fbKeith Whitwell
1624a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger   if (!ctx->Point.PointSprite && ctx->Point.SmoothFlag)
1634a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger      raster->point_smooth = 1;
1644a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger
165e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul   /* _NEW_POINT | _NEW_PROGRAM
166e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul    */
1674a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger   if (ctx->Point.PointSprite) {
168e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul      /* origin */
1694a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger      if ((ctx->Point.SpriteOrigin == GL_UPPER_LEFT) ^
1704a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger          (st_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM))
1714a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger         raster->sprite_coord_mode = PIPE_SPRITE_COORD_UPPER_LEFT;
1724a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger      else
1734a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger         raster->sprite_coord_mode = PIPE_SPRITE_COORD_LOWER_LEFT;
174e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul
175e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul      /* Coord replacement flags.  If bit 'k' is set that means
176e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul       * that we need to replace GENERIC[k] attrib with an automatically
177e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul       * computed texture coord.
178e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul       */
1794a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger      for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
1804a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger         if (ctx->Point.CoordReplace[i]) {
1814a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger            raster->sprite_coord_enable |= 1 << i;
1824a4daa75a85db22cd37ebd533ebbccb427e07077Roland Scheidegger         }
1831b4852345954af9b582b03a91a3d8399b8fb0e92Brian      }
184e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul      if (fragProg->Base.InputsRead & FRAG_BIT_PNTC) {
185e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul         raster->sprite_coord_enable |=
186e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul            1 << (FRAG_ATTRIB_PNTC - FRAG_ATTRIB_TEX0);
187e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul      }
188e22e3927b056806e9bbb089734132ad0bcb98df1Brian Paul
18968f93ea3eb83cfad014b8ec93cec3564c1aa9833Roland Scheidegger      raster->point_quad_rasterization = 1;
1901b4852345954af9b582b03a91a3d8399b8fb0e92Brian   }
191f7556fdd40ed2719beaba271eee4a7551e212ad1Brian Paul
192f7556fdd40ed2719beaba271eee4a7551e212ad1Brian Paul   /* ST_NEW_VERTEX_PROGRAM
193f7556fdd40ed2719beaba271eee4a7551e212ad1Brian Paul    */
1942444f6c6a4c2f54c3198882c2256419628ca49d1Brian   if (vertProg) {
1952444f6c6a4c2f54c3198882c2256419628ca49d1Brian      if (vertProg->Base.Id == 0) {
196b46750d601655c39ccb967ae525d4edcbb9fb9d2Ben Skeggs         if (vertProg->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_PSIZ)) {
1972444f6c6a4c2f54c3198882c2256419628ca49d1Brian            /* generated program which emits point size */
198339e7ec6805e6de8794514c0a935081b5d36d38fBrian            raster->point_size_per_vertex = TRUE;
1992444f6c6a4c2f54c3198882c2256419628ca49d1Brian         }
2002444f6c6a4c2f54c3198882c2256419628ca49d1Brian      }
2012444f6c6a4c2f54c3198882c2256419628ca49d1Brian      else if (ctx->VertexProgram.PointSizeEnabled) {
2022444f6c6a4c2f54c3198882c2256419628ca49d1Brian         /* user-defined program and GL_VERTEX_PROGRAM_POINT_SIZE set */
203339e7ec6805e6de8794514c0a935081b5d36d38fBrian         raster->point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled;
2042444f6c6a4c2f54c3198882c2256419628ca49d1Brian      }
2052444f6c6a4c2f54c3198882c2256419628ca49d1Brian   }
206cbf42c45a15d6a132c7f7d4946c422ee3de35e6cBrian Paul   if (!raster->point_size_per_vertex) {
207cbf42c45a15d6a132c7f7d4946c422ee3de35e6cBrian Paul      /* clamp size now */
208cbf42c45a15d6a132c7f7d4946c422ee3de35e6cBrian Paul      raster->point_size = CLAMP(ctx->Point.Size,
209cbf42c45a15d6a132c7f7d4946c422ee3de35e6cBrian Paul                                 ctx->Point.MinSize,
210cbf42c45a15d6a132c7f7d4946c422ee3de35e6cBrian Paul                                 ctx->Point.MaxSize);
211cbf42c45a15d6a132c7f7d4946c422ee3de35e6cBrian Paul   }
2121be17dc446aa6b0770d76a3eccf79d0faf6608c0Brian
2131be17dc446aa6b0770d76a3eccf79d0faf6608c0Brian   /* _NEW_LINE
2141be17dc446aa6b0770d76a3eccf79d0faf6608c0Brian    */
215339e7ec6805e6de8794514c0a935081b5d36d38fBrian   raster->line_smooth = ctx->Line.SmoothFlag;
21609ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian   if (ctx->Line.SmoothFlag) {
217339e7ec6805e6de8794514c0a935081b5d36d38fBrian      raster->line_width = CLAMP(ctx->Line.Width,
21809ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian                                ctx->Const.MinLineWidthAA,
21909ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian                                ctx->Const.MaxLineWidthAA);
22009ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian   }
22109ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian   else {
222339e7ec6805e6de8794514c0a935081b5d36d38fBrian      raster->line_width = CLAMP(ctx->Line.Width,
22309ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian                                ctx->Const.MinLineWidth,
22409ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian                                ctx->Const.MaxLineWidth);
22509ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian   }
22609ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658Brian
227339e7ec6805e6de8794514c0a935081b5d36d38fBrian   raster->line_stipple_enable = ctx->Line.StippleFlag;
228339e7ec6805e6de8794514c0a935081b5d36d38fBrian   raster->line_stipple_pattern = ctx->Line.StipplePattern;
229a813f654872380547faf67fba75fa30792f87ea6Brian   /* GL stipple factor is in [1,256], remap to [0, 255] here */
230339e7ec6805e6de8794514c0a935081b5d36d38fBrian   raster->line_stipple_factor = ctx->Line.StippleFactor - 1;
2311be17dc446aa6b0770d76a3eccf79d0faf6608c0Brian
23286352ff70d8c9a31fe0ebb4d02ce4bb4644fe54aBrian   /* _NEW_MULTISAMPLE */
2331a820f52f6fa125786538c1adf2aa350e66b8c1eBrian Paul   if (ctx->Multisample._Enabled || st->force_msaa)
234339e7ec6805e6de8794514c0a935081b5d36d38fBrian      raster->multisample = 1;
2358e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
2366abdad28f6f6c69158b942fe420a55f12c71fb08Brian   /* _NEW_SCISSOR */
2376abdad28f6f6c69158b942fe420a55f12c71fb08Brian   if (ctx->Scissor.Enabled)
238339e7ec6805e6de8794514c0a935081b5d36d38fBrian      raster->scissor = 1;
2396abdad28f6f6c69158b942fe420a55f12c71fb08Brian
24047e3896dfd89a26abbe4ca2469c2480f3982b204Luca Barbieri   /* _NEW_FRAG_CLAMP */
241bc1c8369384b5e16547c5bf9728aa78f8dfd66ccMarek Olšák   raster->clamp_fragment_color = !st->clamp_frag_color_in_shader &&
24203b78ceb50b97611bcaa2d2354ff5b505306b0a1Marek Olšák                                  ctx->Color._ClampFragmentColor &&
24303b78ceb50b97611bcaa2d2354ff5b505306b0a1Marek Olšák                                  !ctx->DrawBuffer->_IntegerColor;
2448e33194837dd206d920889851d9cf22190100c99Keith Whitwell   raster->gl_rasterization_rules = 1;
2458e33194837dd206d920889851d9cf22190100c99Keith Whitwell
246d44878e754e65550c0725feb76fe0cbab0ae5d93Paul Berry   /* _NEW_RASTERIZER_DISCARD */
247aee96806f049c17384a8edc11acce76257d98a57Paul Berry   raster->rasterizer_discard = ctx->RasterDiscard;
248c05fafa4a0fd93d4264c46578e23a83ecf2b481eMarek Olšák
249dc4c821f0817a3db716f965692fb701079f66340Marek Olšák   /* _NEW_TRANSFORM */
250dc4c821f0817a3db716f965692fb701079f66340Marek Olšák   raster->depth_clip = ctx->Transform.DepthClamp == GL_FALSE;
251dc4c821f0817a3db716f965692fb701079f66340Marek Olšák   raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled;
252dc4c821f0817a3db716f965692fb701079f66340Marek Olšák
253339e7ec6805e6de8794514c0a935081b5d36d38fBrian   cso_set_rasterizer(st->cso_context, raster);
2548e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}
2558e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
256294401814d1d89cc731de1c22c25333aa5d59374Zack Rusinconst struct st_tracked_state st_update_rasterizer = {
257e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul   "st_update_rasterizer",    /* name */
258e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul   {
259e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul      (_NEW_BUFFERS |
260e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul       _NEW_LIGHT |
261e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul       _NEW_LINE |
262e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul       _NEW_MULTISAMPLE |
263e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul       _NEW_POINT |
264e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul       _NEW_POLYGON |
265e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul       _NEW_PROGRAM |
26647e3896dfd89a26abbe4ca2469c2480f3982b204Luca Barbieri       _NEW_SCISSOR |
267c05fafa4a0fd93d4264c46578e23a83ecf2b481eMarek Olšák       _NEW_FRAG_CLAMP |
268dc4c821f0817a3db716f965692fb701079f66340Marek Olšák       _NEW_RASTERIZER_DISCARD |
269dc4c821f0817a3db716f965692fb701079f66340Marek Olšák       _NEW_TRANSFORM),      /* mesa state dependencies*/
270f7556fdd40ed2719beaba271eee4a7551e212ad1Brian Paul      ST_NEW_VERTEX_PROGRAM,  /* state tracker dependencies */
2718e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   },
272e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93Brian Paul   update_raster_state     /* update function */
2738e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell};
274