[Mesa-dev] [PATCH] llvmpipe: Use -1 instead of ~0 for "no slot".
jfonseca at vmware.com
jfonseca at vmware.com
Mon Oct 31 12:39:52 PDT 2011
From: José Fonseca <jfonseca at vmware.com>
As the value of unsigned ~0 depends on the bit-width.
Fixes fdo 42411.
---
src/gallium/drivers/llvmpipe/lp_state_derived.c | 12 ++++++------
src/gallium/drivers/llvmpipe/lp_state_setup.c | 16 +++++++++++-----
src/gallium/drivers/llvmpipe/lp_state_setup.h | 8 ++++----
3 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c
index 8725ea3..a8b3142 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_derived.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c
@@ -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);
}
}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index f7ba003..a9d9f4f 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -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;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.h b/src/gallium/drivers/llvmpipe/lp_state_setup.h
index 90c55ca..609c4f6 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.h
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.h
@@ -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;
--
1.7.7.1
More information about the mesa-dev
mailing list