diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/pipe/draw/draw_vbuf.c | 27 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex.c | 21 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex.h | 27 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_prim_emit.c | 14 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state_derived.c | 18 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_derived.c | 22 |
6 files changed, 63 insertions, 66 deletions
diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index c179b5e9dd1..82051d2e65b 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -141,42 +141,43 @@ emit_vertex( struct vbuf_stage *vbuf, for (i = 0; i < vinfo->num_attribs; i++) { uint j = vinfo->src_index[i]; - switch (vinfo->format[i]) { - case FORMAT_OMIT: + switch (vinfo->emit[i]) { + case EMIT_OMIT: /* no-op */ break; - case FORMAT_HEADER: - memcpy(vbuf->vertex_ptr, vertex, sizeof(*vertex)); - vbuf->vertex_ptr += sizeof(*vertex) / 4; - count += sizeof(*vertex) / 4; - break; - case FORMAT_1F: + case EMIT_ALL: + /* just copy the whole vertex as-is to the vbuf */ + assert(i == 0); + memcpy(vbuf->vertex_ptr, vertex, vinfo->size * 4); + vbuf->vertex_ptr += vinfo->size; + return; + case EMIT_1F: *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); count++; break; - case FORMAT_1F_PSIZE: + case EMIT_1F_PSIZE: *vbuf->vertex_ptr++ = fui(vbuf->stage.draw->rasterizer->point_size); count++; break; - case FORMAT_2F: + case EMIT_2F: *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); *vbuf->vertex_ptr++ = fui(vertex->data[j][1]); count += 2; break; - case FORMAT_3F: + case EMIT_3F: *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); *vbuf->vertex_ptr++ = fui(vertex->data[j][1]); *vbuf->vertex_ptr++ = fui(vertex->data[j][2]); count += 3; break; - case FORMAT_4F: + case EMIT_4F: *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); *vbuf->vertex_ptr++ = fui(vertex->data[j][1]); *vbuf->vertex_ptr++ = fui(vertex->data[j][2]); *vbuf->vertex_ptr++ = fui(vertex->data[j][3]); count += 4; break; - case FORMAT_4UB: + case EMIT_4UB: *vbuf->vertex_ptr++ = pack_ub4(float_to_ubyte( vertex->data[j][2] ), float_to_ubyte( vertex->data[j][1] ), float_to_ubyte( vertex->data[j][0] ), diff --git a/src/mesa/pipe/draw/draw_vertex.c b/src/mesa/pipe/draw/draw_vertex.c index 37d8b04ef9c..2d6592150fc 100644 --- a/src/mesa/pipe/draw/draw_vertex.c +++ b/src/mesa/pipe/draw/draw_vertex.c @@ -49,28 +49,27 @@ draw_compute_vertex_size(struct vertex_info *vinfo) vinfo->size = 0; for (i = 0; i < vinfo->num_attribs; i++) { - switch (vinfo->format[i]) { - case FORMAT_OMIT: + switch (vinfo->emit[i]) { + case EMIT_OMIT: break; - case FORMAT_HEADER: - vinfo->size += sizeof(struct vertex_header) / 4; - break; - case FORMAT_4UB: + case EMIT_4UB: /* fall-through */ - case FORMAT_1F_PSIZE: + case EMIT_1F_PSIZE: /* fall-through */ - case FORMAT_1F: + case EMIT_1F: vinfo->size += 1; break; - case FORMAT_2F: + case EMIT_2F: vinfo->size += 2; break; - case FORMAT_3F: + case EMIT_3F: vinfo->size += 3; break; - case FORMAT_4F: + case EMIT_4F: vinfo->size += 4; break; + case EMIT_ALL: + /* fall-through */ default: assert(0); } diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 7e9d8abcce1..f20b10f8d77 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -35,18 +35,17 @@ /** - * Vertex attribute format - * XXX rename to "EMIT" + * Vertex attribute emit modes */ -enum attrib_format { - FORMAT_OMIT, /**< don't emit the attribute */ - FORMAT_HEADER, /**< The 5-byte vertex header */ - FORMAT_1F, - FORMAT_1F_PSIZE, /**< insert constant point size */ - FORMAT_2F, - FORMAT_3F, - FORMAT_4F, - FORMAT_4UB /**< XXX may need variations for RGBA vs BGRA, etc */ +enum attrib_emit { + EMIT_OMIT, /**< don't emit the attribute */ + EMIT_ALL, /**< emit whole post-xform vertex, w/ header */ + EMIT_1F, + EMIT_1F_PSIZE, /**< insert constant point size */ + EMIT_2F, + EMIT_3F, + EMIT_4F, + EMIT_4UB /**< XXX may need variations for RGBA vs BGRA, etc */ }; @@ -70,7 +69,7 @@ struct vertex_info uint num_attribs; uint hwfmt[4]; /**< hardware format info for this format */ enum interp_mode interp_mode[PIPE_MAX_SHADER_OUTPUTS]; - enum attrib_format format[PIPE_MAX_SHADER_OUTPUTS]; /**< FORMAT_x */ + enum attrib_emit emit[PIPE_MAX_SHADER_OUTPUTS]; /**< EMIT_x */ uint src_index[PIPE_MAX_SHADER_OUTPUTS]; /**< map to post-xform attribs */ uint size; /**< total vertex size in dwords */ }; @@ -85,12 +84,12 @@ struct vertex_info */ static INLINE uint draw_emit_vertex_attr(struct vertex_info *vinfo, - enum attrib_format format, enum interp_mode interp, + enum attrib_emit emit, enum interp_mode interp, uint src_index) { const uint n = vinfo->num_attribs; assert(n < PIPE_MAX_SHADER_OUTPUTS); - vinfo->format[n] = format; + vinfo->emit[n] = emit; vinfo->interp_mode[n] = interp; vinfo->src_index[n] = src_index; vinfo->num_attribs++; diff --git a/src/mesa/pipe/i915simple/i915_prim_emit.c b/src/mesa/pipe/i915simple/i915_prim_emit.c index c50a5915899..f74671b39ce 100644 --- a/src/mesa/pipe/i915simple/i915_prim_emit.c +++ b/src/mesa/pipe/i915simple/i915_prim_emit.c @@ -73,33 +73,33 @@ emit_hw_vertex( struct i915_context *i915, uint count = 0; /* for debug/sanity */ for (i = 0; i < vinfo->num_attribs; i++) { - switch (vinfo->format[i]) { - case FORMAT_OMIT: + switch (vinfo->emit[i]) { + case EMIT_OMIT: /* no-op */ break; - case FORMAT_1F: + case EMIT_1F: OUT_BATCH( fui(vertex->data[i][0]) ); count++; break; - case FORMAT_2F: + case EMIT_2F: OUT_BATCH( fui(vertex->data[i][0]) ); OUT_BATCH( fui(vertex->data[i][1]) ); count += 2; break; - case FORMAT_3F: + case EMIT_3F: OUT_BATCH( fui(vertex->data[i][0]) ); OUT_BATCH( fui(vertex->data[i][1]) ); OUT_BATCH( fui(vertex->data[i][2]) ); count += 3; break; - case FORMAT_4F: + case EMIT_4F: OUT_BATCH( fui(vertex->data[i][0]) ); OUT_BATCH( fui(vertex->data[i][1]) ); OUT_BATCH( fui(vertex->data[i][2]) ); OUT_BATCH( fui(vertex->data[i][3]) ); count += 4; break; - case FORMAT_4UB: + case EMIT_4UB: OUT_BATCH( pack_ub4(float_to_ubyte( vertex->data[i][2] ), float_to_ubyte( vertex->data[i][1] ), float_to_ubyte( vertex->data[i][0] ), diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 03a46edc55f..62741e30f80 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -56,7 +56,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) memset(&vinfo, 0, sizeof(vinfo)); /* pos */ - draw_emit_vertex_attr(&vinfo, FORMAT_3F, INTERP_LINEAR, src++); + draw_emit_vertex_attr(&vinfo, EMIT_3F, INTERP_LINEAR, src++); /* Note: we'll set the S4_VFMT_XYZ[W] bits below */ for (i = 0; i < fs->num_inputs; i++) { @@ -65,12 +65,12 @@ static void calculate_vertex_layout( struct i915_context *i915 ) break; case TGSI_SEMANTIC_COLOR: if (fs->input_semantic_index[i] == 0) { - front0 = draw_emit_vertex_attr(&vinfo, FORMAT_4UB, colorInterp, src++); + front0 = draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src++); vinfo.hwfmt[0] |= S4_VFMT_COLOR; } else { assert(fs->input_semantic_index[i] == 1); - front1 = draw_emit_vertex_attr(&vinfo, FORMAT_4UB, colorInterp, src++); + front1 = draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src++); vinfo.hwfmt[0] |= S4_VFMT_SPEC_FOG; } break; @@ -80,7 +80,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) const uint unit = fs->input_semantic_index[i]; uint hwtc; texCoords[unit] = TRUE; - draw_emit_vertex_attr(&vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src++); + draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++); hwtc = TEXCOORDFMT_4D; needW = TRUE; vinfo.hwfmt[1] |= hwtc << (unit * 4); @@ -88,7 +88,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) break; case TGSI_SEMANTIC_FOG: fprintf(stderr, "i915 fogcoord not implemented yet\n"); - draw_emit_vertex_attr(&vinfo, FORMAT_1F, INTERP_PERSPECTIVE, src++); + draw_emit_vertex_attr(&vinfo, EMIT_1F, INTERP_PERSPECTIVE, src++); break; default: assert(0); @@ -107,11 +107,11 @@ static void calculate_vertex_layout( struct i915_context *i915 ) /* go back and fill in the vertex position info now that we have needW */ if (needW) { vinfo.hwfmt[0] |= S4_VFMT_XYZW; - vinfo.format[0] = FORMAT_4F; + vinfo.emit[0] = EMIT_4F; } else { vinfo.hwfmt[0] |= S4_VFMT_XYZ; - vinfo.format[0] = FORMAT_3F; + vinfo.emit[0] = EMIT_3F; } /* Additional attributes required for setup: Just twosided @@ -120,10 +120,10 @@ static void calculate_vertex_layout( struct i915_context *i915 ) */ if (i915->rasterizer->light_twoside) { if (front0) { - back0 = draw_emit_vertex_attr(&vinfo, FORMAT_OMIT, colorInterp, src++); + back0 = draw_emit_vertex_attr(&vinfo, EMIT_OMIT, colorInterp, src++); } if (back0) { - back1 = draw_emit_vertex_attr(&vinfo, FORMAT_OMIT, colorInterp, src++); + back1 = draw_emit_vertex_attr(&vinfo, EMIT_OMIT, colorInterp, src++); } } diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 4be3641d677..39c3e1afe10 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -29,6 +29,7 @@ #include "pipe/p_shader_tokens.h" #include "pipe/draw/draw_context.h" #include "pipe/draw/draw_vertex.h" +#include "pipe/draw/draw_private.h" #include "sp_context.h" #include "sp_state.h" @@ -61,20 +62,16 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) const enum interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &softpipe->vertex_info; - struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf; uint i; - int src; if (softpipe->vbuf) { /* if using the post-transform vertex buffer, tell draw_vbuf to * simply emit the whole post-xform vertex as-is: */ + struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf; vinfo_vbuf->num_attribs = 0; - draw_emit_vertex_attr(vinfo_vbuf, FORMAT_HEADER, INTERP_NONE, 0); - for (i = 0; i < vs->num_outputs; i++) { - draw_emit_vertex_attr(vinfo_vbuf, FORMAT_4F, INTERP_NONE, i); - } - draw_compute_vertex_size(vinfo_vbuf); + draw_emit_vertex_attr(vinfo_vbuf, EMIT_ALL, INTERP_NONE, 0); + vinfo_vbuf->size = 4 * vs->num_outputs + sizeof(struct vertex_header)/4; } /* @@ -83,18 +80,19 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) */ vinfo->num_attribs = 0; for (i = 0; i < fs->num_inputs; i++) { + int src; switch (fs->input_semantic_name[i]) { case TGSI_SEMANTIC_POSITION: src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0); assert(src >= 0); - draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_POS, src); + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src); break; case TGSI_SEMANTIC_COLOR: src = find_vs_output(vs, TGSI_SEMANTIC_COLOR, fs->input_semantic_index[i]); assert(src >= 0); - draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src); + draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src); break; case TGSI_SEMANTIC_FOG: @@ -104,7 +102,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) src = 0; #endif assert(src >= 0); - draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src); + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src); break; case TGSI_SEMANTIC_GENERIC: @@ -112,7 +110,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC, fs->input_semantic_index[i]); assert(src >= 0); - draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src); + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src); break; default: @@ -122,7 +120,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) softpipe->psize_slot = find_vs_output(vs, TGSI_SEMANTIC_PSIZE, 0); if (softpipe->psize_slot >= 0) { - draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_CONSTANT, + draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, softpipe->psize_slot); } |