From 086734502a614e7778533018846ee66a66df9821 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 20 Sep 2007 13:42:37 -0600 Subject: Checkpoint: vertex attribute clean-up. Remove/disable the attrib/slot mapping arrays in a few places. Work in progress... --- src/mesa/pipe/draw/draw_clip.c | 2 ++ src/mesa/pipe/draw/draw_feedback.c | 3 ++- src/mesa/pipe/draw/draw_private.h | 2 +- src/mesa/pipe/draw/draw_vertex.c | 19 +++++++------------ src/mesa/pipe/draw/draw_vertex.h | 16 ++++++++-------- src/mesa/pipe/draw/draw_vertex_fetch.c | 5 +++++ src/mesa/pipe/i915simple/i915_state_derived.c | 2 +- src/mesa/pipe/softpipe/sp_context.h | 1 + src/mesa/pipe/softpipe/sp_prim_setup.c | 11 ++++------- src/mesa/pipe/softpipe/sp_state_derived.c | 7 +++++-- src/mesa/state_tracker/st_atom_vs.c | 23 ++++++++++++----------- src/mesa/state_tracker/st_cb_clear.c | 2 +- src/mesa/state_tracker/st_cb_feedback.c | 10 ++++++++-- src/mesa/state_tracker/st_context.h | 12 ++++++++++-- src/mesa/state_tracker/st_program.h | 5 ----- 15 files changed, 67 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c index 1396b60f45e..e2af69e0485 100644 --- a/src/mesa/pipe/draw/draw_clip.c +++ b/src/mesa/pipe/draw/draw_clip.c @@ -382,8 +382,10 @@ static void clip_begin( struct draw_stage *stage ) { /* sanity checks. If these fail, review the clip/interp code! */ assert(stage->draw->vertex_info.num_attribs >= 3); +#if 0 assert(stage->draw->vertex_info.slot_to_attrib[0] == TGSI_ATTRIB_VERTEX_HEADER); assert(stage->draw->vertex_info.slot_to_attrib[1] == TGSI_ATTRIB_CLIP_POS); +#endif stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/draw/draw_feedback.c b/src/mesa/pipe/draw/draw_feedback.c index ecdd98e83d7..3b8400233ed 100644 --- a/src/mesa/pipe/draw/draw_feedback.c +++ b/src/mesa/pipe/draw/draw_feedback.c @@ -78,7 +78,7 @@ feedback_vertex(struct draw_stage *stage, const struct vertex_header *vertex) * we can either address output buffer 0 (for interleaving) or * output buffer i (for non-interleaved). */ - +#if 0 for (i = 0; i < feedback->num_attribs; i++) { const uint attr = feedback->attrib[i]; const uint slot = stage->draw->vertex_info.attrib_to_slot[attr]; @@ -104,6 +104,7 @@ feedback_vertex(struct draw_stage *stage, const struct vertex_header *vertex) } fs->dest[i * select] += size; } +#endif fs->num_vert_emitted++; } diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index bd8c11eb940..1285f3200c8 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -62,7 +62,7 @@ struct vertex_header { }; /* XXX This is too large */ -#define MAX_VERTEX_SIZE ((2 + TGSI_ATTRIB_MAX) * 4 * sizeof(float)) +#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float)) diff --git a/src/mesa/pipe/draw/draw_vertex.c b/src/mesa/pipe/draw/draw_vertex.c index 1c7e1d8662b..ab4e6c78641 100644 --- a/src/mesa/pipe/draw/draw_vertex.c +++ b/src/mesa/pipe/draw/draw_vertex.c @@ -45,17 +45,10 @@ static INLINE void -emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, +emit_vertex_attr(struct vertex_info *vinfo, /*uint vfAttr,*/ attrib_format format, interp_mode interp) { 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 */ - assert(vfAttr < Elements(vinfo->attrib_to_slot)); - vinfo->attrib_to_slot[vfAttr] = n - 2; - } vinfo->interp_mode[n] = interp; vinfo->format[n] = format; vinfo->num_attribs++; @@ -110,22 +103,24 @@ draw_set_vertex_attributes( struct draw_context *draw, struct vertex_info *vinfo = &draw->vertex_info; unsigned i; +#if 0 assert(slot_to_vf_attr[0] == TGSI_ATTRIB_POS); +#endif memset(vinfo, 0, sizeof(*vinfo)); /* * First three attribs are always the same: header, clip pos, winpos */ - 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); + 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, interps[i]); + emit_vertex_attr(vinfo, /*slot_to_vf_attr[i],*/ FORMAT_4F, interps[i]); } draw_compute_vertex_size(vinfo); diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 4e3e86d86e1..1d900b3a4ee 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -68,16 +68,15 @@ typedef enum { } interp_mode; - +/** + * Information about post-transformed vertex layout. + */ struct vertex_info { uint num_attribs; uint hwfmt[4]; /**< hardware format info for this format */ - uint attr_mask; /**< mask of VF_ATTR_ bits */ - uint slot_to_attrib[MAX_VERT_ATTRIBS]; - uint attrib_to_slot[TGSI_ATTRIB_MAX]; - interp_mode interp_mode[MAX_VERT_ATTRIBS]; - attrib_format format[MAX_VERT_ATTRIBS]; /**< FORMAT_x */ + interp_mode interp_mode[PIPE_MAX_SHADER_OUTPUTS]; + attrib_format format[PIPE_MAX_SHADER_OUTPUTS]; /**< FORMAT_x */ uint size; /**< total vertex size in dwords */ }; @@ -92,9 +91,10 @@ draw_emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, attrib_format format, interp_mode interp) { const uint n = vinfo->num_attribs; - assert(n < MAX_VERT_ATTRIBS); + assert(n < PIPE_MAX_SHADER_OUTPUTS); + /* vinfo->attr_mask |= (1 << vfAttr); - vinfo->slot_to_attrib[n] = vfAttr; + */ vinfo->format[n] = format; vinfo->interp_mode[n] = interp; vinfo->num_attribs++; diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index ce402d681f0..62e8d61be4c 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -81,6 +81,9 @@ void draw_vertex_fetch( struct draw_context *draw, /* loop over vertices */ for (j = 0; j < count; j++) { uint attr; + + /*printf("fetch vertex %u: \n", j);*/ + /* loop over vertex attributes (vertex shader inputs) */ for (attr = 0; attr < draw->vertex_shader.num_inputs; attr++) { @@ -94,6 +97,8 @@ void draw_vertex_fetch( struct draw_context *draw, fetch_attrib4(src, draw->vertex_element[attr].src_format, p); + /*printf(" %u: %f %f %f %f\n", attr, p[0], p[1], p[2], p[3]);*/ + machine->Inputs[attr].xyzw[0].f[j] = p[0]; /*X*/ machine->Inputs[attr].xyzw[1].f[j] = p[1]; /*Y*/ machine->Inputs[attr].xyzw[2].f[j] = p[2]; /*Z*/ diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 572d270f39e..91d00fb1c2b 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -173,7 +173,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) * vertex layout. We'll also update the hardware vertex format info. */ draw_set_vertex_attributes( i915->draw, - vinfo->slot_to_attrib, + NULL,/*vinfo->slot_to_attrib,*/ vinfo->interp_mode, vinfo->num_attribs); diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 5c17c47b128..95215eb6408 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -111,6 +111,7 @@ struct softpipe_context { unsigned nr_frag_attrs; /**< number of active fragment attribs */ boolean need_z; /**< produce quad/fragment Z values? */ boolean need_w; /**< produce quad/fragment W values? */ + int psize_slot; /** Feedback buffers */ struct pipe_feedback_buffer feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS]; diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 8a4be79d114..913ae446012 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -79,8 +79,6 @@ struct setup_stage { float oneoverarea; - const unsigned *lookup; /**< vertex attribute positions */ - struct tgsi_interp_coef coef[TGSI_ATTRIB_MAX]; struct quad_header quad; @@ -249,7 +247,7 @@ static void print_vertex(const struct setup_stage *setup, { int i; printf("Vertex:\n"); - for (i = 0; i < setup->softpipe->nr_attrs; i++) { + for (i = 0; i < setup->quad.nr_attrs; i++) { printf(" %d: %f %f %f\n", i, v->data[i][0], v->data[i][1], v->data[i][2]); } @@ -907,8 +905,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim) { struct setup_stage *setup = setup_stage( stage ); const struct vertex_header *v0 = prim->v[0]; - - const int sizeAttr = setup->lookup[TGSI_ATTRIB_POINTSIZE]; + const int sizeAttr = setup->softpipe->psize_slot; const float halfSize = sizeAttr ? (0.5f * v0->data[sizeAttr][0]) : (0.5f * setup->softpipe->rasterizer->point_size); @@ -917,6 +914,8 @@ setup_point(struct draw_stage *stage, struct prim_header *prim) const float y = v0->data[TGSI_ATTRIB_POS][1]; unsigned slot, j; + assert(sizeAttr >= 0); + /* For points, all interpolants are constant-valued. * However, for point sprites, we'll need to setup texcoords appropriately. * XXX: which coefficients are the texcoords??? @@ -1097,7 +1096,5 @@ struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe ) setup->quad.coef = setup->coef; - setup->lookup = softpipe->draw->vertex_info.attrib_to_slot; - return &setup->stage; } diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 0dd0eea0b83..03b5d7ea3f0 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -59,6 +59,8 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) softpipe->need_z = FALSE; softpipe->need_w = FALSE; + softpipe->psize_slot = -1; + /* always emit vertex pos */ /* TODO - Figure out if we need to do perspective divide, etc. */ draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_4F, INTERP_LINEAR); @@ -93,6 +95,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) FORMAT_4F, INTERP_CONSTANT); break; #endif + softpipe->psize_slot = i; /*case TGSI_SEMANTIC_TEXCOORD:*/ case TGSI_SEMANTIC_TEX0: draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_TEX0, @@ -131,10 +134,10 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) */ /* XXX we also need to do this when the shading mode (interp modes) change: */ if (1/*vinfo->attr_mask != softpipe->attr_mask*/) { - softpipe->attr_mask = vinfo->attr_mask; + /*softpipe->attr_mask = vinfo->attr_mask;*/ draw_set_vertex_attributes( softpipe->draw, - vinfo->slot_to_attrib, + NULL,/*vinfo->slot_to_attrib,*/ vinfo->interp_mode, vinfo->num_attribs); diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index 9c2994fddf3..2b8aef5c63a 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -57,7 +57,6 @@ const struct cso_vertex_shader * st_translate_vertex_shader(struct st_context *st, struct st_vertex_program *stvp) { - GLuint outputMapping[PIPE_MAX_SHADER_INPUTS]; struct pipe_shader_state vs; const struct cso_vertex_shader *cso; GLuint i; @@ -83,6 +82,9 @@ st_translate_vertex_shader(struct st_context *st, case VERT_ATTRIB_COLOR1: vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1; break; + case VERT_ATTRIB_TEX0: + vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_TEX0; + break; default: vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_OTHER; } @@ -95,11 +97,8 @@ st_translate_vertex_shader(struct st_context *st, */ for (i = 0; i < VERT_RESULT_MAX; i++) { if (stvp->Base.Base.OutputsWritten & (1 << i)) { -#if 0 - stvp->output_to_index[i] = vs.num_outputs; - stvp->index_to_output[vs.num_outputs] = i; -#endif - outputMapping[i] = vs.num_outputs; + /* put this attrib in the next available slot */ + st->vertex_attrib_to_slot[i] = vs.num_outputs; switch (i) { case VERT_RESULT_HPOS: @@ -129,11 +128,7 @@ st_translate_vertex_shader(struct st_context *st, */ tgsi_mesa_compile_vp_program( &stvp->Base, stvp->input_to_index, -#if 0 - stvp->output_to_index, -#else - outputMapping, -#endif + st->vertex_attrib_to_slot, stvp->tokens, ST_FP_MAX_TOKENS ); #if 0 @@ -195,6 +190,12 @@ static void update_vs( struct st_context *st ) st->vp = stvp; st->state.vs = stvp->vs; +#if 0 + printf("###### bind vp tokens: %p %p num_inp=%u\n", + stvp, stvp->tokens, stvp->vs->state.num_inputs); + if (TGSI_DEBUG) + tgsi_dump( stvp->tokens, 0 ); +#endif st->pipe->bind_vs_state(st->pipe, st->state.vs->data); } } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index bfc977daa4d..5e632050885 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -491,7 +491,7 @@ clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) assert(strb->surface->format); -#if 01 +#if 0 if (ctx->Scissor.Enabled || (isDS && ctx->DrawBuffer->Visual.stencilBits > 0)) { /* scissoring or we have a combined depth/stencil buffer */ diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 8e8084fe598..e846463c4c3 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -87,6 +87,7 @@ static void feedback_vertex(GLcontext *ctx, const struct draw_context *draw, const struct vertex_header *v) { + const struct st_context *st = ctx->st; GLfloat win[4]; const GLfloat *color, *texcoord; const GLfloat ci = 0; @@ -97,13 +98,18 @@ feedback_vertex(GLcontext *ctx, const struct draw_context *draw, win[2] = v->data[0][2]; win[3] = 1.0F / v->data[0][3]; - slot = draw->vertex_info.attrib_to_slot[TGSI_ATTRIB_COLOR0]; + /* XXX + * When we compute vertex layout, save info about position of the + * color and texcoord attribs to use here. + */ + + slot = st->vertex_attrib_to_slot[VERT_RESULT_COL0]; if (slot) color = v->data[slot]; else color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - slot = draw->vertex_info.attrib_to_slot[TGSI_ATTRIB_TEX0]; + slot = st->vertex_attrib_to_slot[VERT_RESULT_TEX0]; if (slot) texcoord = v->data[slot]; else diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 8a57227c84f..55a857f46d4 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -119,9 +119,17 @@ struct st_context GLfloat polygon_offset_scale; /* ?? */ - struct st_vertex_program *vp; - struct st_fragment_program *fp; + /** Mapping from VERT_ATTRIB_x to post-transformed vertex slot */ + GLuint vertex_attrib_to_slot[VERT_RESULT_MAX]; + struct st_vertex_program *vp; /**< Currently bound vertex program */ + struct st_fragment_program *fp; /**< Currently bound fragment program */ + + /** + * Buffer object which stores the ctx->Current.Attrib[] values. + * Used for vertex array drawing when we we need an attribute for + * which there's no enabled array. + */ struct pipe_buffer_handle *default_attrib_buffer; struct cso_cache *cache; diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 4f9ace3e6a8..c21e27628ea 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -71,11 +71,6 @@ struct st_vertex_program /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */ GLuint index_to_input[MAX_VERTEX_PROGRAM_ATTRIBS]; -#if 0 - GLuint output_to_index[MAX_VERTEX_PROGRAM_ATTRIBS]; - GLuint index_to_output[MAX_VERTEX_PROGRAM_ATTRIBS]; -#endif - /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; GLboolean dirty; -- cgit v1.2.3