llvmpipe: Use -1 instead of ~0 for "no slot".
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 31 Oct 2011 19:35:55 +0000 (19:35 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 1 Nov 2011 11:29:31 +0000 (11:29 +0000)
As the value of unsigned ~0 depends on the bit-width.

Fixes fdo 42411.

src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_setup.c
src/gallium/drivers/llvmpipe/lp_state_setup.h

index 8725ea39fe971f8523a658d880bd194630c6d658..a8b3142d8cf60a08811f8e00bf5f1a6963238575 100644 (file)
@@ -53,10 +53,10 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
    unsigned vs_index;
    uint i;
 
-   llvmpipe->color_slot[0] = ~0;
-   llvmpipe->color_slot[1] = ~0;
-   llvmpipe->bcolor_slot[0] = ~0;
-   llvmpipe->bcolor_slot[1] = ~0;
+   llvmpipe->color_slot[0] = -1;
+   llvmpipe->color_slot[1] = -1;
+   llvmpipe->bcolor_slot[0] = -1;
+   llvmpipe->bcolor_slot[1] = -1;
 
    /*
     * Match FS inputs against VS outputs, emitting the necessary
@@ -84,7 +84,7 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
       if (lpfs->info.base.input_semantic_name[i] == TGSI_SEMANTIC_COLOR &&
           lpfs->info.base.input_semantic_index[i] < 2) {
          int idx = lpfs->info.base.input_semantic_index[i];
-         llvmpipe->color_slot[idx] = vinfo->num_attribs;
+         llvmpipe->color_slot[idx] = (int)vinfo->num_attribs;
       }
 
       /*
@@ -100,7 +100,7 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
                                          TGSI_SEMANTIC_BCOLOR, i);
 
       if (vs_index > 0) {
-         llvmpipe->bcolor_slot[i] = vinfo->num_attribs;
+         llvmpipe->bcolor_slot[i] = (int)vinfo->num_attribs;
          draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
       }
    }
index f7ba0035b3736ccac1f5bd2322e51fc5596ea2f4..a9d9f4f466591eef7b74dcb0bd8301a5757aab4b 100644 (file)
@@ -351,9 +351,9 @@ load_attribute(struct gallivm_state *gallivm,
    }
 
    if (key->twoside) {
-      if (vert_attr == key->color_slot && key->bcolor_slot != ~0)
+      if (vert_attr == key->color_slot && key->bcolor_slot >= 0)
          lp_twoside(gallivm, args, key, key->bcolor_slot);
-      else if (vert_attr == key->spec_slot && key->bspec_slot != ~0)
+      else if (vert_attr == key->spec_slot && key->bspec_slot >= 0)
          lp_twoside(gallivm, args, key, key->bspec_slot);
    }
 }
@@ -771,10 +771,16 @@ lp_make_setup_variant_key(struct llvmpipe_context *lp,
    key->twoside = lp->rasterizer->light_twoside;
    key->size = Offset(struct lp_setup_variant_key,
                      inputs[key->num_inputs]);
-   key->color_slot = lp->color_slot[0];
+
+   key->color_slot  = lp->color_slot [0];
    key->bcolor_slot = lp->bcolor_slot[0];
-   key->spec_slot = lp->color_slot[1];
-   key->bspec_slot = lp->bcolor_slot[1];
+   key->spec_slot   = lp->color_slot [1];
+   key->bspec_slot  = lp->bcolor_slot[1];
+   assert(key->color_slot  == lp->color_slot [0]);
+   assert(key->bcolor_slot == lp->bcolor_slot[0]);
+   assert(key->spec_slot   == lp->color_slot [1]);
+   assert(key->bspec_slot  == lp->bcolor_slot[1]);
+
    key->units = (float) (lp->rasterizer->offset_units * lp->mrd);
    key->scale = lp->rasterizer->offset_scale;
    key->pad = 0;
index 90c55ca4ce654a48a25c58c0e8441173602ffd6d..609c4f625117252dff7a15f2073589d0daaa166a 100644 (file)
@@ -17,11 +17,11 @@ struct lp_setup_variant_list_item
 struct lp_setup_variant_key {   
    unsigned size:16;
    unsigned num_inputs:8;
-   unsigned color_slot:8;
+   int color_slot:8;
 
-   unsigned bcolor_slot:8;
-   unsigned spec_slot:8;
-   unsigned bspec_slot:8;
+   int bcolor_slot:8;
+   int spec_slot:8;
+   int bspec_slot:8;
    unsigned flatshade_first:1;
    unsigned pixel_center_half:1;
    unsigned twoside:1;