replace _mesa_logbase2 with util_logbase2
[mesa.git] / src / mesa / state_tracker / st_atom_rasterizer.c
index 2bffa684a25336599c6ff9d2627268b8deeb8478..bcbb3cd6b79b864130904051405328c09a64d307 100644 (file)
@@ -37,6 +37,7 @@
 #include "st_atom.h"
 #include "st_debug.h"
 #include "st_program.h"
+#include "st_util.h"
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "cso_cache/cso_context.h"
@@ -60,13 +61,11 @@ translate_fill(GLenum mode)
    }
 }
 
-
 void
 st_update_rasterizer(struct st_context *st)
 {
    struct gl_context *ctx = st->ctx;
    struct pipe_rasterizer_state *raster = &st->state.rasterizer;
-   const struct gl_program *vertProg = ctx->VertexProgram._Current;
    const struct gl_program *fragProg = ctx->FragmentProgram._Current;
 
    memset(raster, 0, sizeof(*raster));
@@ -95,13 +94,15 @@ st_update_rasterizer(struct st_context *st)
 
    /* _NEW_LIGHT
     */
-   raster->flatshade = ctx->Light.ShadeModel == GL_FLAT;
+   raster->flatshade = !st->lower_flatshade &&
+                       ctx->Light.ShadeModel == GL_FLAT;
 
    raster->flatshade_first = ctx->Light.ProvokingVertex ==
                              GL_FIRST_VERTEX_CONVENTION_EXT;
 
    /* _NEW_LIGHT | _NEW_PROGRAM */
-   raster->light_twoside = _mesa_vertex_program_two_side_enabled(ctx);
+   if (!st->lower_two_sided_color)
+      raster->light_twoside = _mesa_vertex_program_two_side_enabled(ctx);
 
    /*_NEW_LIGHT | _NEW_BUFFERS */
    raster->clamp_vertex_color = !st->clamp_vert_color_in_shader &&
@@ -197,34 +198,7 @@ st_update_rasterizer(struct st_context *st)
 
    /* ST_NEW_VERTEX_PROGRAM
     */
-   if (vertProg) {
-      if (vertProg->Id == 0) {
-         if (vertProg->info.outputs_written &
-             BITFIELD64_BIT(VARYING_SLOT_PSIZ)) {
-            /* generated program which emits point size */
-            raster->point_size_per_vertex = TRUE;
-         }
-      }
-      else if (ctx->API != API_OPENGLES2) {
-         /* PointSizeEnabled is always set in ES2 contexts */
-         raster->point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled;
-      }
-      else {
-         /* ST_NEW_TESSEVAL_PROGRAM | ST_NEW_GEOMETRY_PROGRAM */
-         /* We have to check the last bound stage and see if it writes psize */
-         struct gl_program *last = NULL;
-         if (ctx->GeometryProgram._Current)
-            last = ctx->GeometryProgram._Current;
-         else if (ctx->TessEvalProgram._Current)
-            last = ctx->TessEvalProgram._Current;
-         else if (ctx->VertexProgram._Current)
-            last = ctx->VertexProgram._Current;
-         if (last)
-            raster->point_size_per_vertex =
-               !!(last->info.outputs_written &
-                  BITFIELD64_BIT(VARYING_SLOT_PSIZ));
-      }
-   }
+   raster->point_size_per_vertex = st_point_size_per_vertex(ctx);
    if (!raster->point_size_per_vertex) {
       /* clamp size now */
       raster->point_size = CLAMP(ctx->Point.Size,
@@ -294,8 +268,10 @@ st_update_rasterizer(struct st_context *st)
    }
 
    /* _NEW_TRANSFORM */
-   raster->depth_clip_near = !ctx->Transform.DepthClampNear;
-   raster->depth_clip_far = !ctx->Transform.DepthClampFar;
+   raster->depth_clip_near = st->clamp_frag_depth_in_shader ||
+                             !ctx->Transform.DepthClampNear;
+   raster->depth_clip_far = st->clamp_frag_depth_in_shader ||
+                            !ctx->Transform.DepthClampFar;
    raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled;
    raster->clip_halfz = (ctx->Transform.ClipDepthMode == GL_ZERO_TO_ONE);
 
@@ -305,6 +281,8 @@ st_update_rasterizer(struct st_context *st)
          raster->conservative_raster_mode = PIPE_CONSERVATIVE_RASTER_POST_SNAP;
       else
          raster->conservative_raster_mode = PIPE_CONSERVATIVE_RASTER_PRE_SNAP;
+   } else if (ctx->IntelConservativeRasterization) {
+      raster->conservative_raster_mode = PIPE_CONSERVATIVE_RASTER_POST_SNAP;
    } else {
       raster->conservative_raster_mode = PIPE_CONSERVATIVE_RASTER_OFF;
    }