svga: add can_use_upload flag
[mesa.git] / src / gallium / drivers / svga / svga_pipe_rasterizer.c
index d397c95da98cd92e24fb7f1c156bb552f7e42ca5..70d89f5cc639b421af8e9f32f2dae0bbd95f3eee 100644 (file)
@@ -38,8 +38,8 @@
 
 /* Hardware frontwinding is always set up as SVGA3D_FRONTWINDING_CW.
  */
-static SVGA3dFace svga_translate_cullmode( unsigned mode,
-                                           unsigned front_ccw )
+static SVGA3dFace
+svga_translate_cullmode(unsigned mode, unsigned front_ccw)
 {
    const int hw_front_ccw = 0;  /* hardware is always CW */
    switch (mode) {
@@ -57,7 +57,8 @@ static SVGA3dFace svga_translate_cullmode( unsigned mode,
    }
 }
 
-static SVGA3dShadeMode svga_translate_flatshade( unsigned mode )
+static SVGA3dShadeMode
+svga_translate_flatshade(unsigned mode)
 {
    return mode ? SVGA3D_SHADEMODE_FLAT : SVGA3D_SHADEMODE_SMOOTH;
 }
@@ -104,18 +105,20 @@ static void
 define_rasterizer_object(struct svga_context *svga,
                          struct svga_rasterizer_state *rast)
 {
+   struct svga_screen *svgascreen = svga_screen(svga->pipe.screen);
    unsigned fill_mode = translate_fill_mode(rast->templ.fill_front);
-   unsigned cull_mode = translate_cull_mode(rast->templ.cull_face);
-   int depth_bias = rast->templ.offset_units;
-   float slope_scaled_depth_bias =  rast->templ.offset_scale;
-   float depth_bias_clamp = 0.0; /* XXX fix me */
-   unsigned try;
+   const unsigned cull_mode = translate_cull_mode(rast->templ.cull_face);
+   const int depth_bias = rast->templ.offset_units;
+   const float slope_scaled_depth_bias = rast->templ.offset_scale;
+   /* PIPE_CAP_POLYGON_OFFSET_CLAMP not supported: */
+   const float depth_bias_clamp = 0.0;
    const float line_width = rast->templ.line_width > 0.0f ?
       rast->templ.line_width : 1.0f;
    const uint8 line_factor = rast->templ.line_stipple_enable ?
       rast->templ.line_stipple_factor : 0;
    const uint16 line_pattern = rast->templ.line_stipple_enable ?
       rast->templ.line_stipple_pattern : 0;
+   unsigned try;
 
    rast->id = util_bitmask_add(svga->rast_object_id_bm);
 
@@ -128,6 +131,8 @@ define_rasterizer_object(struct svga_context *svga,
    }
 
    for (try = 0; try < 2; try++) {
+      const uint8 pv_last = !rast->templ.flatshade_first &&
+         svgascreen->haveProvokingVertex;
       enum pipe_error ret =
          SVGA3D_vgpu10_DefineRasterizerState(svga->swc,
                                              rast->id,
@@ -145,7 +150,7 @@ define_rasterizer_object(struct svga_context *svga,
                                              rast->templ.line_stipple_enable,
                                              line_factor,
                                              line_pattern,
-                                             !rast->templ.flatshade_first);
+                                             pv_last);
       if (ret == PIPE_OK)
          return;
       svga_context_flush(svga, NULL);
@@ -158,7 +163,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
                              const struct pipe_rasterizer_state *templ)
 {
    struct svga_context *svga = svga_context(pipe);
-   struct svga_rasterizer_state *rast = CALLOC_STRUCT( svga_rasterizer_state );
+   struct svga_rasterizer_state *rast = CALLOC_STRUCT(svga_rasterizer_state);
    struct svga_screen *screen = svga_screen(pipe->screen);
 
    if (!rast)
@@ -179,9 +184,8 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
    /* line_width             - draw module */
    /* fill_cw, fill_ccw      - draw module or index translation */
 
-   rast->shademode = svga_translate_flatshade( templ->flatshade );
-   rast->cullmode = svga_translate_cullmode( templ->cull_face, 
-                                             templ->front_ccw );
+   rast->shademode = svga_translate_flatshade(templ->flatshade);
+   rast->cullmode = svga_translate_cullmode(templ->cull_face, templ->front_ccw);
    rast->scissortestenable = templ->scissor;
    rast->multisampleantialias = templ->multisample;
    rast->antialiasedlineenable = templ->line_smooth;
@@ -360,13 +364,16 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
                          "GL_POLYGON_SMOOTH not supported");
    }
 
-   svga->hud.num_state_objects++;
+   svga->hud.num_rasterizer_objects++;
+   SVGA_STATS_COUNT_INC(svga_screen(svga->pipe.screen)->sws,
+                        SVGA_STATS_COUNT_RASTERIZERSTATE);
 
    return rast;
 }
 
-static void svga_bind_rasterizer_state( struct pipe_context *pipe,
-                                        void *state )
+
+static void
+svga_bind_rasterizer_state(struct pipe_context *pipe, void *state)
 {
    struct svga_context *svga = svga_context(pipe);
    struct svga_rasterizer_state *raster = (struct svga_rasterizer_state *)state;
@@ -383,6 +390,7 @@ static void svga_bind_rasterizer_state( struct pipe_context *pipe,
    svga->dirty |= SVGA_NEW_RAST;
 }
 
+
 static void
 svga_delete_rasterizer_state(struct pipe_context *pipe, void *state)
 {
@@ -405,19 +413,14 @@ svga_delete_rasterizer_state(struct pipe_context *pipe, void *state)
    }
 
    FREE(state);
-   svga->hud.num_state_objects--;
+   svga->hud.num_rasterizer_objects--;
 }
 
 
-void svga_init_rasterizer_functions( struct svga_context *svga )
+void
+svga_init_rasterizer_functions(struct svga_context *svga)
 {
    svga->pipe.create_rasterizer_state = svga_create_rasterizer_state;
    svga->pipe.bind_rasterizer_state = svga_bind_rasterizer_state;
    svga->pipe.delete_rasterizer_state = svga_delete_rasterizer_state;
 }
-
-
-/***********************************************************************
- * Hardware state update
- */
-