i965: SF: Modify calculate_point_sprite_mask to use the VUE map.
authorPaul Berry <stereotype441@gmail.com>
Tue, 23 Aug 2011 22:49:32 +0000 (15:49 -0700)
committerPaul Berry <stereotype441@gmail.com>
Tue, 6 Sep 2011 18:04:34 +0000 (11:04 -0700)
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_sf.c
src/mesa/drivers/dri/i965/brw_sf.h
src/mesa/drivers/dri/i965/brw_sf_emit.c

index 1c149dbfd1e0b8962593657e58d2524bcb3c8e20..7b003dcdff743adf070e84396030ae24f1002344 100644 (file)
@@ -67,6 +67,9 @@ static void compile_sf_prog( struct brw_context *brw,
    c.nr_attr_regs = (c.nr_attrs+1)/2;
    c.nr_setup_attrs = brw_count_bits(c.key.attrs);
    c.nr_setup_regs = (c.nr_setup_attrs+1)/2;
+   brw_compute_vue_map(&c.vue_map, intel, c.key.nr_userclip,
+                       c.key.do_twoside_color, c.key.attrs);
+   c.urb_entry_read_offset = brw_sf_compute_urb_entry_read_offset(intel);
 
    c.prog_data.urb_read_length = c.nr_attr_regs;
    c.prog_data.urb_entry_size = c.nr_setup_regs * 2;
@@ -163,6 +166,9 @@ static void upload_sf_prog(struct brw_context *brw)
       break;
    }
 
+   /* _NEW_TRANSFORM */
+   key.nr_userclip = brw_count_bits(ctx->Transform.ClipPlanesEnabled);
+
    /* _NEW_POINT */
    key.do_point_sprite = ctx->Point.PointSprite;
    if (key.do_point_sprite) {
@@ -198,7 +204,7 @@ static void upload_sf_prog(struct brw_context *brw)
 
 const struct brw_tracked_state brw_sf_prog = {
    .dirty = {
-      .mesa  = (_NEW_HINT | _NEW_LIGHT | _NEW_POLYGON | _NEW_POINT),
+      .mesa  = (_NEW_HINT | _NEW_LIGHT | _NEW_POLYGON | _NEW_POINT | _NEW_TRANSFORM),
       .brw   = (BRW_NEW_REDUCED_PRIMITIVE),
       .cache = CACHE_NEW_VS_PROG
    },
index 102df3302ace5d667b850781571296006ebd284c..12c655f09231d5be23dfe04239a16a8cb324ba5a 100644 (file)
@@ -53,7 +53,8 @@ struct brw_sf_prog_key {
    GLuint frontface_ccw:1;
    GLuint do_point_sprite:1;
    GLuint sprite_origin_lower_left:1;
-   GLuint pad:24;
+   GLuint nr_userclip:4;
+   GLuint pad:20;
 };
 
 struct brw_sf_compile {
@@ -93,9 +94,11 @@ struct brw_sf_compile {
    GLuint nr_attr_regs;
    GLuint nr_setup_attrs;
    GLuint nr_setup_regs;
+   int urb_entry_read_offset;
 
    GLubyte attr_to_idx[VERT_RESULT_MAX];   
    GLubyte idx_to_attr[VERT_RESULT_MAX];   
+   struct brw_vue_map vue_map;
 };
 
  
index 52a3fb3893d14416d228de432f277ab16839f6f0..f1fe567c88a767edaf054f90c85963665451b2fe 100644 (file)
 #include "brw_sf.h"
 
 
+/**
+ * Determine the vert_result corresponding to the given half of the given
+ * register.  half=0 means the first half of a register, half=1 means the
+ * second half.
+ */
+static inline int vert_reg_to_vert_result(struct brw_sf_compile *c, GLuint reg,
+                                          int half)
+{
+   int vue_slot = (reg + c->urb_entry_read_offset) * 2 + half;
+   return c->vue_map.slot_to_vert_result[vue_slot];
+}
+
 static struct brw_reg get_vert_attr(struct brw_sf_compile *c,
                                    struct brw_reg vert,
                                    GLuint attr)
@@ -359,22 +371,20 @@ static GLboolean calculate_masks( struct brw_sf_compile *c,
 static uint16_t
 calculate_point_sprite_mask(struct brw_sf_compile *c, GLuint reg)
 {
-   int attr1, attr2;
+   int vert_result1, vert_result2;
    uint16_t pc = 0;
 
-   attr1 = c->idx_to_attr[reg * 2];
-   if (attr1 >= VERT_RESULT_TEX0 && attr1 <= VERT_RESULT_TEX7) {
-      if (c->key.point_sprite_coord_replace & (1 << (attr1 - VERT_RESULT_TEX0)))
+   vert_result1 = vert_reg_to_vert_result(c, reg, 0);
+   if (vert_result1 >= VERT_RESULT_TEX0 && vert_result1 <= VERT_RESULT_TEX7) {
+      if (c->key.point_sprite_coord_replace & (1 << (vert_result1 - VERT_RESULT_TEX0)))
         pc |= 0x0f;
    }
 
-   if (reg * 2 + 1 < c->nr_setup_attrs) {
-       attr2 = c->idx_to_attr[reg * 2 + 1];
-       if (attr2 >= VERT_RESULT_TEX0 && attr2 <= VERT_RESULT_TEX7) {
-         if (c->key.point_sprite_coord_replace & (1 << (attr2 -
-                                                        VERT_RESULT_TEX0)))
-            pc |= 0xf0;
-       }
+   vert_result2 = vert_reg_to_vert_result(c, reg, 1);
+   if (vert_result2 >= VERT_RESULT_TEX0 && vert_result2 <= VERT_RESULT_TEX7) {
+      if (c->key.point_sprite_coord_replace & (1 << (vert_result2 -
+                                                     VERT_RESULT_TEX0)))
+         pc |= 0xf0;
    }
 
    return pc;