mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 10:50:10 +01:00
gallium: add a src_index[] array to draw's vertex_info for mapping post-xform vertex attribs to hw vertex attribs
This commit is contained in:
parent
f4b89be701
commit
382b86e90f
5 changed files with 48 additions and 39 deletions
|
|
@ -54,6 +54,7 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
|||
= cell->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
|
||||
struct vertex_info *vinfo = &cell->vertex_info;
|
||||
uint front0;
|
||||
uint src = 0;
|
||||
|
||||
memset(vinfo, 0, sizeof(*vinfo));
|
||||
|
||||
|
|
@ -68,10 +69,10 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
|||
#endif
|
||||
|
||||
/* always emit vertex pos */
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR);
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR, src++);
|
||||
|
||||
#if 1
|
||||
front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
||||
front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
|
@ -94,11 +95,11 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
|||
|
||||
case TGSI_SEMANTIC_COLOR:
|
||||
if (vs->output_semantic_index[i] == 0) {
|
||||
front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
||||
front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||
}
|
||||
else {
|
||||
assert(vs->output_semantic_index[i] == 1);
|
||||
front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
||||
front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -113,7 +114,7 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
|||
break;
|
||||
|
||||
case TGSI_SEMANTIC_FOG:
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE);
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE, src++);
|
||||
break;
|
||||
|
||||
case TGSI_SEMANTIC_PSIZE:
|
||||
|
|
@ -125,7 +126,7 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
|||
|
||||
case TGSI_SEMANTIC_GENERIC:
|
||||
/* this includes texcoords and varying vars */
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE);
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src++);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -140,14 +141,14 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
|||
* up 1:1 with the fragment shader inputs.
|
||||
*/
|
||||
if (emitBack0) {
|
||||
back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
||||
back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||
}
|
||||
if (emitBack1) {
|
||||
back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
||||
back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||
}
|
||||
if (emitPsize) {
|
||||
cell->psize_slot
|
||||
= draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT);
|
||||
= draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT, src++);
|
||||
}
|
||||
|
||||
/* If the attributes have changed, tell the draw module about
|
||||
|
|
|
|||
|
|
@ -139,37 +139,38 @@ emit_vertex( struct vbuf_stage *vbuf,
|
|||
vertex->vertex_id = vbuf->nr_vertices++;
|
||||
|
||||
for (i = 0; i < vinfo->num_attribs; i++) {
|
||||
uint j = vinfo->src_index[i];
|
||||
switch (vinfo->format[i]) {
|
||||
case FORMAT_OMIT:
|
||||
/* no-op */
|
||||
break;
|
||||
case FORMAT_1F:
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][0]);
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
|
||||
count++;
|
||||
break;
|
||||
case FORMAT_2F:
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][0]);
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][1]);
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[j][1]);
|
||||
count += 2;
|
||||
break;
|
||||
case FORMAT_3F:
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][0]);
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][1]);
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][2]);
|
||||
*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:
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][0]);
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][1]);
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][2]);
|
||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][3]);
|
||||
*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:
|
||||
*vbuf->vertex_ptr++ = pack_ub4(float_to_ubyte( vertex->data[i][2] ),
|
||||
float_to_ubyte( vertex->data[i][1] ),
|
||||
float_to_ubyte( vertex->data[i][0] ),
|
||||
float_to_ubyte( vertex->data[i][3] ));
|
||||
*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] ),
|
||||
float_to_ubyte( vertex->data[j][3] ));
|
||||
count += 1;
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ struct vertex_info
|
|||
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 */
|
||||
uint src_index[PIPE_MAX_SHADER_OUTPUTS];
|
||||
uint size; /**< total vertex size in dwords */
|
||||
};
|
||||
|
||||
|
|
@ -77,16 +78,20 @@ struct vertex_info
|
|||
|
||||
/**
|
||||
* Add another attribute to the given vertex_info object.
|
||||
* \param src_index indicates which post-transformed vertex attrib slot
|
||||
* corresponds to this attribute.
|
||||
* \return slot in which the attribute was added
|
||||
*/
|
||||
static INLINE uint
|
||||
draw_emit_vertex_attr(struct vertex_info *vinfo,
|
||||
enum attrib_format format, enum interp_mode interp)
|
||||
enum attrib_format format, enum interp_mode interp,
|
||||
uint src_index)
|
||||
{
|
||||
const uint n = vinfo->num_attribs;
|
||||
assert(n < PIPE_MAX_SHADER_OUTPUTS);
|
||||
vinfo->format[n] = format;
|
||||
vinfo->interp_mode[n] = interp;
|
||||
vinfo->src_index[n] = src_index;
|
||||
vinfo->num_attribs++;
|
||||
return n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,12 +50,13 @@ static void calculate_vertex_layout( struct i915_context *i915 )
|
|||
boolean needW = 0;
|
||||
uint i;
|
||||
boolean texCoords[8];
|
||||
uint src = 0;
|
||||
|
||||
memset(texCoords, 0, sizeof(texCoords));
|
||||
memset(&vinfo, 0, sizeof(vinfo));
|
||||
|
||||
/* pos */
|
||||
draw_emit_vertex_attr(&vinfo, FORMAT_3F, INTERP_LINEAR);
|
||||
draw_emit_vertex_attr(&vinfo, FORMAT_3F, INTERP_LINEAR, src++);
|
||||
/* Note: we'll set the S4_VFMT_XYZ[W] bits below */
|
||||
|
||||
for (i = 0; i < fs->num_inputs; i++) {
|
||||
|
|
@ -64,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);
|
||||
front0 = draw_emit_vertex_attr(&vinfo, FORMAT_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);
|
||||
front1 = draw_emit_vertex_attr(&vinfo, FORMAT_4UB, colorInterp, src++);
|
||||
vinfo.hwfmt[0] |= S4_VFMT_SPEC_FOG;
|
||||
}
|
||||
break;
|
||||
|
|
@ -79,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);
|
||||
draw_emit_vertex_attr(&vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src++);
|
||||
hwtc = TEXCOORDFMT_4D;
|
||||
needW = TRUE;
|
||||
vinfo.hwfmt[1] |= hwtc << (unit * 4);
|
||||
|
|
@ -87,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);
|
||||
draw_emit_vertex_attr(&vinfo, FORMAT_1F, INTERP_PERSPECTIVE, src++);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
|
|
@ -119,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);
|
||||
back0 = draw_emit_vertex_attr(&vinfo, FORMAT_OMIT, colorInterp, src++);
|
||||
}
|
||||
if (back0) {
|
||||
back1 = draw_emit_vertex_attr(&vinfo, FORMAT_OMIT, colorInterp);
|
||||
back1 = draw_emit_vertex_attr(&vinfo, FORMAT_OMIT, colorInterp, src++);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
|||
boolean emitBack0 = FALSE, emitBack1 = FALSE, emitPsize = FALSE;
|
||||
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
|
||||
uint i;
|
||||
int src = 0;
|
||||
|
||||
memset(vinfo, 0, sizeof(*vinfo));
|
||||
|
||||
|
|
@ -61,7 +62,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
|||
softpipe->psize_slot = -1;
|
||||
|
||||
/* always emit vertex pos */
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR);
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR, src++);
|
||||
|
||||
/*
|
||||
* XXX I think we need to reconcile the vertex shader outputs with
|
||||
|
|
@ -82,11 +83,11 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
|||
|
||||
case TGSI_SEMANTIC_COLOR:
|
||||
if (vs->output_semantic_index[i] == 0) {
|
||||
front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
||||
front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||
}
|
||||
else {
|
||||
assert(vs->output_semantic_index[i] == 1);
|
||||
front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
||||
front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -101,7 +102,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
|||
break;
|
||||
|
||||
case TGSI_SEMANTIC_FOG:
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE);
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE, src++);
|
||||
break;
|
||||
|
||||
case TGSI_SEMANTIC_PSIZE:
|
||||
|
|
@ -113,7 +114,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
|||
|
||||
case TGSI_SEMANTIC_GENERIC:
|
||||
/* this includes texcoords and varying vars */
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE);
|
||||
draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src++);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -128,14 +129,14 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
|||
* up 1:1 with the fragment shader inputs.
|
||||
*/
|
||||
if (emitBack0) {
|
||||
back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
||||
back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||
}
|
||||
if (emitBack1) {
|
||||
back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
||||
back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||
}
|
||||
if (emitPsize) {
|
||||
softpipe->psize_slot
|
||||
= draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT);
|
||||
= draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT, src++);
|
||||
}
|
||||
|
||||
/* If the attributes have changed, tell the draw module about
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue