galahad: do map/unmap counting for resources
[mesa.git] / src / gallium / drivers / i965 / brw_sf.c
index 0b94dc40c31ba7ba7df49190b66acbf22775e751..5abf3848ab4e6d7865c505e5215845443cbb7946 100644 (file)
@@ -36,7 +36,6 @@
 #include "brw_context.h"
 #include "brw_pipe_rast.h"
 #include "brw_eu.h"
-#include "brw_util.h"
 #include "brw_sf.h"
 #include "brw_state.h"
 
@@ -127,8 +126,11 @@ static enum pipe_error compile_sf_prog( struct brw_context *brw,
  */
 static enum pipe_error upload_sf_prog(struct brw_context *brw)
 {
-   enum pipe_error ret;
+   const struct brw_fs_signature *sig = &brw->curr.fragment_shader->signature;
+   const struct pipe_rasterizer_state *rast = &brw->curr.rast->templ;
    struct brw_sf_prog_key key;
+   enum pipe_error ret;
+   unsigned i;
 
    memset(&key, 0, sizeof(key));
 
@@ -138,32 +140,34 @@ static enum pipe_error upload_sf_prog(struct brw_context *brw)
    /* XXX: Add one to account for the position input.
     */
    /* PIPE_NEW_FRAGMENT_SIGNATURE */
-   key.nr_attrs = brw->curr.fragment_shader->signature.nr_inputs + 1;
+   key.nr_attrs = sig->nr_inputs + 1;
 
 
-   /* XXX: this is probably where the mapping between vertex shader
-    * outputs and fragment shader inputs should be handled.  Assume
-    * for now 1:1 correspondance.
-    *
-    * XXX: scan frag shader inputs to work out linear vs. perspective
-    * interpolation below.
-    *
-    * XXX: as long as we're hard-wiring, is eg. position required to
-    * be linear?
+   /* XXX: why is position required to be linear?  why do we care
+    * about it at all?
     */
-   //key.linear_attrs = 0;
-   //key.persp_attrs = (1 << key.nr_attrs) - 1;
+   key.linear_attrs = 1;        /* position -- but why? */
 
-   key.linear_attrs = (1 << key.nr_attrs) - 1;
-   key.persp_attrs = 0;
+   for (i = 0; i < sig->nr_inputs; i++) {
+      switch (sig->input[i].interp) {
+      case TGSI_INTERPOLATE_CONSTANT:
+         break;
+      case TGSI_INTERPOLATE_LINEAR:
+         key.linear_attrs |= 1 << (i+1);
+         break;
+      case TGSI_INTERPOLATE_PERSPECTIVE:
+         key.persp_attrs |= 1 << (i+1);
+         break;
+      }
+   }
 
    /* BRW_NEW_REDUCED_PRIMITIVE */
    switch (brw->reduced_primitive) {
    case PIPE_PRIM_TRIANGLES: 
       /* PIPE_NEW_RAST
        */
-      if (brw->curr.rast->templ.fill_cw != PIPE_POLYGON_MODE_FILL ||
-         brw->curr.rast->templ.fill_ccw != PIPE_POLYGON_MODE_FILL)
+      if (rast->fill_front != PIPE_POLYGON_MODE_FILL ||
+         rast->fill_back != PIPE_POLYGON_MODE_FILL)
         key.primitive = SF_UNFILLED_TRIS;
       else
         key.primitive = SF_TRIANGLES;
@@ -176,14 +180,14 @@ static enum pipe_error upload_sf_prog(struct brw_context *brw)
       break;
    }
 
-   key.do_point_sprite = brw->curr.rast->templ.point_sprite;
-   key.sprite_origin_lower_left = 0; /* XXX: ctx->Point.SpriteOrigin - fix rast state */
-   key.do_flat_shading = brw->curr.rast->templ.flatshade;
-   key.do_twoside_color = brw->curr.rast->templ.light_twoside;
+   key.do_point_sprite = rast->sprite_coord_enable ? 1 : 0;
+   key.sprite_origin_lower_left = (rast->sprite_coord_mode == PIPE_SPRITE_COORD_LOWER_LEFT);
+   key.point_coord_replace_attrs = rast->sprite_coord_enable;
+   key.do_flat_shading = rast->flatshade;
+   key.do_twoside_color = rast->light_twoside;
 
    if (key.do_twoside_color) {
-      key.frontface_ccw = (brw->curr.rast->templ.front_winding == 
-                          PIPE_WINDING_CCW);
+      key.frontface_ccw = rast->front_ccw;
    }
 
    if (brw_search_cache(&brw->cache, BRW_SF_PROG,