mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 02:48:06 +02:00
llvmpipe: twoside for specular color also
This commit is contained in:
parent
081ce2680e
commit
546c5ffa11
4 changed files with 42 additions and 20 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue