diff options
author | Keith Whitwell <keithw@vmware.com> | 2010-11-19 16:17:36 +0000 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2010-11-19 16:17:36 +0000 |
commit | 546c5ffa11d70631348e5776df7a4168f07600f6 (patch) | |
tree | adb04885ca5b35e4a33b951d6eb7e16bd4188f19 | |
parent | 081ce2680eb94f4f322faa26800a3906db6e2571 (diff) |
llvmpipe: twoside for specular color alsolp-offset-twoside
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_context.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_derived.c | 26 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_setup.c | 20 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_setup.h | 12 |
4 files changed, 42 insertions, 20 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index 4515dbb0af..a35e09e8b4 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -105,10 +105,10 @@ struct llvmpipe_context { struct vertex_info vertex_info; /** Which vertex shader output slot contains color */ - int color_slot; + int color_slot[2]; /** Which vertex shader output slot contains bcolor */ - int bcolor_slot; + int bcolor_slot[2]; /** Which vertex shader output slot contains point size */ int psize_slot; diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index 1c9f03a381..8725ea39fe 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -53,6 +53,11 @@ 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; + /* * Match FS inputs against VS outputs, emitting the necessary * attributes. Could cache these structs and look them up with a @@ -75,9 +80,13 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe) vs_index = draw_find_shader_output(llvmpipe->draw, lpfs->info.base.input_semantic_name[i], lpfs->info.base.input_semantic_index[i]); - if (lpfs->info.base.input_semantic_name[i]==TGSI_SEMANTIC_COLOR){ - llvmpipe->color_slot = vinfo->num_attribs; + + 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; } + /* * Emit the requested fs attribute for all but position. */ @@ -86,14 +95,17 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe) /* Figure out if we need bcolor as well. */ - vs_index = draw_find_shader_output(llvmpipe->draw, - TGSI_SEMANTIC_BCOLOR, 0); + for (i = 0; i < 2; i++) { + vs_index = draw_find_shader_output(llvmpipe->draw, + TGSI_SEMANTIC_BCOLOR, i); - if (vs_index > 0) { - llvmpipe->bcolor_slot = vinfo->num_attribs; - draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index); + if (vs_index > 0) { + llvmpipe->bcolor_slot[i] = vinfo->num_attribs; + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index); + } } + /* Figure out if we need pointsize as well. */ vs_index = draw_find_shader_output(llvmpipe->draw, diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c b/src/gallium/drivers/llvmpipe/lp_state_setup.c index 129ec0af3d..194b014436 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c @@ -218,10 +218,11 @@ vert_clamp(LLVMBuilderRef b, static void lp_twoside(LLVMBuilderRef b, struct lp_setup_args *args, - const struct lp_setup_variant_key *key) + const struct lp_setup_variant_key *key, + int bcolor_slot) { LLVMValueRef a0_back, a1_back, a2_back; - LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), key->bcolor_slot, 0); + LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), bcolor_slot, 0); LLVMValueRef facing = args->facing; LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, LLVMConstInt(LLVMInt32Type(), 0, 0), ""); /** need i1 for if condition */ @@ -335,8 +336,11 @@ load_attribute(LLVMBuilderRef b, lp_do_offset_tri(b, args, key); } - if (key->twoside && vert_attr == key->color_slot) { - lp_twoside(b, args, key); + if (key->twoside) { + if (vert_attr == key->color_slot && key->bcolor_slot != ~0) + lp_twoside(b, args, key, key->bcolor_slot); + else if (vert_attr == key->spec_slot && key->bspec_slot != ~0) + lp_twoside(b, args, key, key->bspec_slot); } } @@ -746,9 +750,11 @@ lp_make_setup_variant_key(struct llvmpipe_context *lp, key->pixel_center_half = lp->rasterizer->gl_rasterization_rules; key->twoside = lp->rasterizer->light_twoside; key->size = Offset(struct lp_setup_variant_key, - inputs[key->num_inputs]); - key->color_slot = lp->color_slot; - key->bcolor_slot = lp->bcolor_slot; + inputs[key->num_inputs]); + 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->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 40fb8ef428..90c55ca4ce 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_state_setup.h @@ -15,14 +15,18 @@ struct lp_setup_variant_list_item struct lp_setup_variant_key { + unsigned size:16; unsigned num_inputs:8; + unsigned color_slot:8; + + unsigned bcolor_slot:8; + unsigned spec_slot:8; + unsigned bspec_slot:8; unsigned flatshade_first:1; unsigned pixel_center_half:1; unsigned twoside:1; - unsigned color_slot:8; - unsigned bcolor_slot:8; - unsigned size:16; - unsigned pad:21; + unsigned pad:5; + float units; float scale; struct lp_shader_input inputs[PIPE_MAX_SHADER_INPUTS]; |