From 0cbb49aff59f7a671d153d9baa70aa78b07da538 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 31 Oct 2011 19:35:55 +0000 Subject: [PATCH] llvmpipe: Use -1 instead of ~0 for "no slot". 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 8725ea39fe9..a8b3142d8cf 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 f7ba0035b37..a9d9f4f4665 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 90c55ca4ce6..609c4f62511 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; -- 2.30.2