Remove/disable the attrib/slot mapping arrays in a few places.
Work in progress...
{
/* 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 );
}
* 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];
}
fs->dest[i * select] += size;
}
+#endif
fs->num_vert_emitted++;
}
};
/* 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))
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++;
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);
} 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 */
};
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++;
/* 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++) {
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*/
* 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);
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];
float oneoverarea;
- const unsigned *lookup; /**< vertex attribute positions */
-
struct tgsi_interp_coef coef[TGSI_ATTRIB_MAX];
struct quad_header quad;
{
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]);
}
{
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);
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???
setup->quad.coef = setup->coef;
- setup->lookup = softpipe->draw->vertex_info.attrib_to_slot;
-
return &setup->stage;
}
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);
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,
*/
/* 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);
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;
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;
}
*/
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:
*/
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
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);
}
}
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 */
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;
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
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;
/** 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;