diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-08-23 13:27:18 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-08-23 13:27:18 -0600 |
commit | d3eb25c575464bed7dbfc8be4717d85cb2928ec1 (patch) | |
tree | 9d0a18cc6c7c7e5c3939066dc6868a867d651fa0 /src/mesa/pipe/draw | |
parent | 690a9de40b20092ae9027dc52d7b26a48995bbff (diff) |
Checkpoint commit: i915 texture works, use new vertex_info struct
Basic i915 2D texturing seems to work now.
The vertex format is determined from the current fragment shader.
Diffstat (limited to 'src/mesa/pipe/draw')
-rw-r--r-- | src/mesa/pipe/draw/draw_arrays.c | 78 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_clip.c | 8 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_flatshade.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_prim.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_private.h | 34 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_twoside.c | 2 |
6 files changed, 68 insertions, 58 deletions
diff --git a/src/mesa/pipe/draw/draw_arrays.c b/src/mesa/pipe/draw/draw_arrays.c index 738fa144b2..430dc15ce2 100644 --- a/src/mesa/pipe/draw/draw_arrays.c +++ b/src/mesa/pipe/draw/draw_arrays.c @@ -70,17 +70,53 @@ draw_arrays(struct draw_context *draw, unsigned prim, } -/* XXX move this into draw_context.c? */ +static INLINE void +emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format) +{ + const uint n = vinfo->num_attribs; + vinfo->attr_mask |= (1 << vfAttr); + vinfo->slot_to_attrib[n] = vfAttr; + if (n >= 2) { + /* the first two slots are the vertex header & clippos */ + vinfo->attrib_to_slot[vfAttr] = n - 2; + } + /*printf("Vertex slot %d = vfattrib %d\n", n, vfAttr);*/ + /*vinfo->interp_mode[n] = interpMode;*/ + vinfo->format[n] = format; + vinfo->num_attribs++; + +} -#define EMIT_ATTR( VF_ATTR, STYLE, SIZE ) \ -do { \ - if (draw->nr_attrs >= 2) \ - draw->vf_attr_to_slot[VF_ATTR] = draw->nr_attrs - 2; \ - draw->attrs[draw->nr_attrs].attrib = VF_ATTR; \ - /*draw->attrs[draw->nr_attrs].format = STYLE*/; \ - draw->nr_attrs++; \ - draw->vertex_size += SIZE; \ -} while (0) + +static void +compute_vertex_size(struct vertex_info *vinfo) +{ + uint i; + + vinfo->size = 0; + for (i = 0; i < vinfo->num_attribs; i++) { + switch (vinfo->format[i]) { + case FORMAT_OMIT: + break; + case FORMAT_4UB: + /* fall-through */ + case FORMAT_1F: + vinfo->size += 1; + break; + case FORMAT_2F: + vinfo->size += 2; + break; + case FORMAT_3F: + vinfo->size += 3; + break; + case FORMAT_4F: + vinfo->size += 4; + break; + default: + assert(0); + } + } +} void @@ -88,26 +124,26 @@ draw_set_vertex_attributes( struct draw_context *draw, const unsigned *slot_to_vf_attr, unsigned nr_attrs ) { + struct vertex_info *vinfo = &draw->vertex_info; unsigned i; - memset(draw->vf_attr_to_slot, 0, sizeof(draw->vf_attr_to_slot)); - draw->nr_attrs = 0; - draw->vertex_size = 0; + assert(slot_to_vf_attr[0] == VF_ATTRIB_POS); + + memset(vinfo, 0, sizeof(*vinfo)); /* * First three attribs are always the same: header, clip pos, winpos */ - EMIT_ATTR(VF_ATTRIB_VERTEX_HEADER, EMIT_1F, 1); - EMIT_ATTR(VF_ATTRIB_CLIP_POS, EMIT_4F, 4); - - assert(slot_to_vf_attr[0] == VF_ATTRIB_POS); - EMIT_ATTR(slot_to_vf_attr[0], EMIT_4F_VIEWPORT, 4); + emit_vertex_attr(vinfo, VF_ATTRIB_VERTEX_HEADER, FORMAT_1F); + emit_vertex_attr(vinfo, VF_ATTRIB_CLIP_POS, FORMAT_4F); + emit_vertex_attr(vinfo, VF_ATTRIB_POS, FORMAT_4F_VIEWPORT); /* * Remaining attribs (color, texcoords, etc) */ - for (i = 1; i < nr_attrs; i++) - EMIT_ATTR(slot_to_vf_attr[i], EMIT_4F, 4); + for (i = 1; i < nr_attrs; i++) { + emit_vertex_attr(vinfo, slot_to_vf_attr[i], FORMAT_4F); + } - draw->vertex_size *= 4; /* floats to bytes */ + compute_vertex_size(vinfo); } diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c index 7e5ceacdfe..1c2491d2c6 100644 --- a/src/mesa/pipe/draw/draw_clip.c +++ b/src/mesa/pipe/draw/draw_clip.c @@ -93,7 +93,7 @@ static void interp( const struct clipper *clip, const struct vertex_header *out, const struct vertex_header *in ) { - const unsigned nr_attrs = clip->stage.draw->nr_attrs; + const unsigned nr_attrs = clip->stage.draw->vertex_info.num_attribs; unsigned j; /* Vertex header. @@ -379,9 +379,9 @@ static void clip_begin( struct draw_stage *stage ) unsigned nr = stage->draw->nr_planes; /* sanity checks. If these fail, review the clip/interp code! */ - assert(stage->draw->nr_attrs >= 3); - assert(stage->draw->attrs[0].attrib == VF_ATTRIB_VERTEX_HEADER); - assert(stage->draw->attrs[1].attrib == VF_ATTRIB_CLIP_POS); + assert(stage->draw->vertex_info.num_attribs >= 3); + assert(stage->draw->vertex_info.slot_to_attrib[0] == VF_ATTRIB_VERTEX_HEADER); + assert(stage->draw->vertex_info.slot_to_attrib[1] == VF_ATTRIB_CLIP_POS); /* Hacky bitmask to use when we hit CLIP_USER_BIT: */ diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c index 128acc5b2b..34588c83b6 100644 --- a/src/mesa/pipe/draw/draw_flatshade.c +++ b/src/mesa/pipe/draw/draw_flatshade.c @@ -154,7 +154,7 @@ struct draw_stage *draw_flatshade_stage( struct draw_context *draw ) flatshade->stage.end = flatshade_end; flatshade->stage.reset_stipple_counter = flatshade_reset_stipple_counter; - flatshade->lookup = draw->vf_attr_to_slot; + flatshade->lookup = draw->vertex_info.attrib_to_slot; return &flatshade->stage; } diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c index 8f409424ca..23eb578221 100644 --- a/src/mesa/pipe/draw/draw_prim.c +++ b/src/mesa/pipe/draw/draw_prim.c @@ -282,7 +282,7 @@ run_vertex_program(struct draw_context *draw, slot = 1; for (attr = 1; attr < VERT_RESULT_MAX; attr++) { if (draw->vertex_shader.outputs_written & (1 << attr)) { - assert(slot < draw->nr_attrs); + assert(slot < draw->vertex_info.num_attribs); vOut[j]->data[slot][0] = machine.Outputs[attr].xyzw[0].f[j]; vOut[j]->data[slot][1] = machine.Outputs[attr].xyzw[1].f[j]; vOut[j]->data[slot][2] = machine.Outputs[attr].xyzw[2].f[j]; diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index 75f7c5d84e..531bb2e254 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -44,28 +44,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" - -/* XXX these are temporary */ -struct vf_attr_map { - unsigned attrib; - /* - unsigned format; - */ - unsigned offset; -}; -#define VF_ATTRIB_POS 0 -#define VF_ATTRIB_COLOR0 3 -#define VF_ATTRIB_COLOR1 4 -#define VF_ATTRIB_BFC0 25 -#define VF_ATTRIB_BFC1 26 - -#define VF_ATTRIB_CLIP_POS 27 -#define VF_ATTRIB_VERTEX_HEADER 28 -#define VF_ATTRIB_MAX 29 -#define EMIT_1F 0 -#define EMIT_4F 3 -#define EMIT_4F_VIEWPORT 6 -#define FRAG_ATTRIB_MAX 13 +#include "draw_vertex.h" /** @@ -175,14 +154,9 @@ struct draw_context float plane[12][4]; unsigned nr_planes; - /* - * Vertex attribute info - */ - unsigned vf_attr_to_slot[PIPE_ATTRIB_MAX]; - struct vf_attr_map attrs[VF_ATTRIB_MAX]; - unsigned nr_attrs; + /** Describes the layout of post-transformation vertices */ + struct vertex_info vertex_info; - unsigned vertex_size; /**< in bytes */ unsigned nr_vertices; unsigned prim; /**< current prim type: PIPE_PRIM_x */ @@ -250,7 +224,7 @@ dup_vert( struct draw_stage *stage, unsigned idx ) { struct vertex_header *tmp = stage->tmp[idx]; - memcpy(tmp, vert, stage->draw->vertex_size ); + memcpy(tmp, vert, stage->draw->vertex_info.size * sizeof(float) ); return tmp; } diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c index d7d993841b..822cadd61f 100644 --- a/src/mesa/pipe/draw/draw_twoside.c +++ b/src/mesa/pipe/draw/draw_twoside.c @@ -163,7 +163,7 @@ struct draw_stage *draw_twoside_stage( struct draw_context *draw ) twoside->stage.end = twoside_end; twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter; - twoside->lookup = draw->vf_attr_to_slot; + twoside->lookup = draw->vertex_info.attrib_to_slot; return &twoside->stage; } |