diff options
author | Brian <[email protected]> | 2007-08-30 14:41:23 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-08-30 14:43:08 -0600 |
commit | 942b9bc5bc13d959baa86779a7c669cf96659b9a (patch) | |
tree | 8753ff6f40f91fb7b3eff740ccde1edb35349bed /src/mesa/pipe/draw | |
parent | aaf03b94861cbf5a602863e4542dd1c2e54ba365 (diff) |
In draw_flatshade.c use vertex_info->interp_mode[] to choose attribs/colors to cpy.
One less dependency on the TGSI_ATTRIB_x flags.
This requires setting the vertex_info->interp_mode[] values in the i915 driver and passing them to draw_set_vertex_attributes().
Diffstat (limited to 'src/mesa/pipe/draw')
-rw-r--r-- | src/mesa/pipe/draw/draw_arrays.c | 16 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_context.h | 2 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_flatshade.c | 53 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex.h | 9 |
4 files changed, 38 insertions, 42 deletions
diff --git a/src/mesa/pipe/draw/draw_arrays.c b/src/mesa/pipe/draw/draw_arrays.c index b7d06dd5a70..9e219ed43be 100644 --- a/src/mesa/pipe/draw/draw_arrays.c +++ b/src/mesa/pipe/draw/draw_arrays.c @@ -75,7 +75,7 @@ draw_arrays(struct draw_context *draw, unsigned prim, static INLINE void -emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format) +emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format, uint interp) { const uint n = vinfo->num_attribs; vinfo->attr_mask |= (1 << vfAttr); @@ -85,8 +85,7 @@ emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format) assert(vfAttr < Elements(vinfo->attrib_to_slot)); vinfo->attrib_to_slot[vfAttr] = n - 2; } - /*printf("Vertex slot %d = vfattrib %d\n", n, vfAttr);*/ - /*vinfo->interp_mode[n] = interpMode;*/ + vinfo->interp_mode[n] = interp; vinfo->format[n] = format; vinfo->num_attribs++; @@ -127,7 +126,8 @@ compute_vertex_size(struct vertex_info *vinfo) void draw_set_vertex_attributes( struct draw_context *draw, - const unsigned *slot_to_vf_attr, + const uint *slot_to_vf_attr, + const uint *interp_mode, unsigned nr_attrs ) { struct vertex_info *vinfo = &draw->vertex_info; @@ -140,15 +140,15 @@ draw_set_vertex_attributes( struct draw_context *draw, /* * First three attribs are always the same: header, clip pos, winpos */ - emit_vertex_attr(vinfo, TGSI_ATTRIB_VERTEX_HEADER, FORMAT_1F); - emit_vertex_attr(vinfo, TGSI_ATTRIB_CLIP_POS, FORMAT_4F); - emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_4F_VIEWPORT); + emit_vertex_attr(vinfo, TGSI_ATTRIB_VERTEX_HEADER, FORMAT_1F, INTERP_NONE); + emit_vertex_attr(vinfo, TGSI_ATTRIB_CLIP_POS, FORMAT_4F, INTERP_LINEAR); + emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_4F_VIEWPORT, INTERP_LINEAR); /* * Remaining attribs (color, texcoords, etc) */ for (i = 1; i < nr_attrs; i++) { - emit_vertex_attr(vinfo, slot_to_vf_attr[i], FORMAT_4F); + emit_vertex_attr(vinfo, slot_to_vf_attr[i], FORMAT_4F, interp_mode[i]); } compute_vertex_size(vinfo); diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 1bd0e624fe1..4c9e64a12d2 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -89,7 +89,7 @@ void draw_set_setup_stage( struct draw_context *draw, struct draw_stage *stage ); void draw_set_vertex_attributes( struct draw_context *draw, - const unsigned *attrs, + const uint *attrs, const uint *interp_mode, unsigned nr_attrs ); unsigned draw_prim_info( unsigned prim, unsigned *first, unsigned *incr ); diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c index 5a23e10c030..602a8785adf 100644 --- a/src/mesa/pipe/draw/draw_flatshade.c +++ b/src/mesa/pipe/draw/draw_flatshade.c @@ -32,20 +32,6 @@ #include "draw_private.h" -struct flatshade_stage { - struct draw_stage stage; - - const unsigned *lookup; -}; - - - -static INLINE struct flatshade_stage *flatshade_stage( struct draw_stage *stage ) -{ - return (struct flatshade_stage *)stage; -} - - static void flatshade_begin( struct draw_stage *stage ) { stage->next->begin( stage->next ); @@ -69,13 +55,16 @@ static INLINE void copy_colors( struct draw_stage *stage, struct vertex_header *dst, const struct vertex_header *src ) { - const struct flatshade_stage *flatshade = flatshade_stage(stage); - const unsigned *lookup = flatshade->lookup; - - copy_attr( lookup[TGSI_ATTRIB_COLOR0], dst, src ); - copy_attr( lookup[TGSI_ATTRIB_COLOR1], dst, src ); - copy_attr( lookup[TGSI_ATTRIB_BFC0], dst, src ); - copy_attr( lookup[TGSI_ATTRIB_BFC1], dst, src ); + const uint num_attribs = stage->draw->vertex_info.num_attribs; + const uint *interp_mode = stage->draw->vertex_info.interp_mode; + uint i; + + /* Look for constant/flat attribs and duplicate from src to dst vertex */ + for (i = 1; i < num_attribs - 2; i++) { + if (interp_mode[i + 2] == INTERP_CONSTANT) { + copy_attr( i, dst, src ); + } + } } @@ -142,22 +131,20 @@ static void flatshade_reset_stipple_counter( struct draw_stage *stage ) */ struct draw_stage *draw_flatshade_stage( struct draw_context *draw ) { - struct flatshade_stage *flatshade = CALLOC_STRUCT(flatshade_stage); + struct draw_stage *flatshade = CALLOC_STRUCT(draw_stage); draw_alloc_tmps( &flatshade->stage, 2 ); - flatshade->stage.draw = draw; - flatshade->stage.next = NULL; - flatshade->stage.begin = flatshade_begin; - flatshade->stage.point = flatshade_point; - flatshade->stage.line = flatshade_line; - flatshade->stage.tri = flatshade_tri; - flatshade->stage.end = flatshade_end; - flatshade->stage.reset_stipple_counter = flatshade_reset_stipple_counter; - - flatshade->lookup = draw->vertex_info.attrib_to_slot; + flatshade->draw = draw; + flatshade->next = NULL; + flatshade->begin = flatshade_begin; + flatshade->point = flatshade_point; + flatshade->line = flatshade_line; + flatshade->tri = flatshade_tri; + flatshade->end = flatshade_end; + flatshade->reset_stipple_counter = flatshade_reset_stipple_counter; - return &flatshade->stage; + return flatshade; } diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 5d22e01d5cc..6778df30d1e 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -47,6 +47,15 @@ #define FORMAT_4UB 5 +enum interp_mode { + INTERP_NONE, /**< never interpolate vertex header info */ + INTERP_CONSTANT, + INTERP_LINEAR, + INTERP_PERSPECTIVE +}; + + + struct vertex_info { uint num_attribs; |