mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-14 14:28:08 +02: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;
|
= cell->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
|
||||||
struct vertex_info *vinfo = &cell->vertex_info;
|
struct vertex_info *vinfo = &cell->vertex_info;
|
||||||
uint front0;
|
uint front0;
|
||||||
|
uint src = 0;
|
||||||
|
|
||||||
memset(vinfo, 0, sizeof(*vinfo));
|
memset(vinfo, 0, sizeof(*vinfo));
|
||||||
|
|
||||||
|
|
@ -68,10 +69,10 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* always emit vertex pos */
|
/* 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
|
#if 1
|
||||||
front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
@ -94,11 +95,11 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
||||||
|
|
||||||
case TGSI_SEMANTIC_COLOR:
|
case TGSI_SEMANTIC_COLOR:
|
||||||
if (vs->output_semantic_index[i] == 0) {
|
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 {
|
else {
|
||||||
assert(vs->output_semantic_index[i] == 1);
|
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;
|
break;
|
||||||
|
|
||||||
|
|
@ -113,7 +114,7 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TGSI_SEMANTIC_FOG:
|
case TGSI_SEMANTIC_FOG:
|
||||||
draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE);
|
draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE, src++);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TGSI_SEMANTIC_PSIZE:
|
case TGSI_SEMANTIC_PSIZE:
|
||||||
|
|
@ -125,7 +126,7 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
||||||
|
|
||||||
case TGSI_SEMANTIC_GENERIC:
|
case TGSI_SEMANTIC_GENERIC:
|
||||||
/* this includes texcoords and varying vars */
|
/* 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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -140,14 +141,14 @@ static void calculate_vertex_layout( struct cell_context *cell )
|
||||||
* up 1:1 with the fragment shader inputs.
|
* up 1:1 with the fragment shader inputs.
|
||||||
*/
|
*/
|
||||||
if (emitBack0) {
|
if (emitBack0) {
|
||||||
back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||||
}
|
}
|
||||||
if (emitBack1) {
|
if (emitBack1) {
|
||||||
back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||||
}
|
}
|
||||||
if (emitPsize) {
|
if (emitPsize) {
|
||||||
cell->psize_slot
|
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
|
/* 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++;
|
vertex->vertex_id = vbuf->nr_vertices++;
|
||||||
|
|
||||||
for (i = 0; i < vinfo->num_attribs; i++) {
|
for (i = 0; i < vinfo->num_attribs; i++) {
|
||||||
|
uint j = vinfo->src_index[i];
|
||||||
switch (vinfo->format[i]) {
|
switch (vinfo->format[i]) {
|
||||||
case FORMAT_OMIT:
|
case FORMAT_OMIT:
|
||||||
/* no-op */
|
/* no-op */
|
||||||
break;
|
break;
|
||||||
case FORMAT_1F:
|
case FORMAT_1F:
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][0]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
|
||||||
count++;
|
count++;
|
||||||
break;
|
break;
|
||||||
case FORMAT_2F:
|
case FORMAT_2F:
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][0]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][1]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][1]);
|
||||||
count += 2;
|
count += 2;
|
||||||
break;
|
break;
|
||||||
case FORMAT_3F:
|
case FORMAT_3F:
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][0]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][1]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][1]);
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][2]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][2]);
|
||||||
count += 3;
|
count += 3;
|
||||||
break;
|
break;
|
||||||
case FORMAT_4F:
|
case FORMAT_4F:
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][0]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][1]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][1]);
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][2]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][2]);
|
||||||
*vbuf->vertex_ptr++ = fui(vertex->data[i][3]);
|
*vbuf->vertex_ptr++ = fui(vertex->data[j][3]);
|
||||||
count += 4;
|
count += 4;
|
||||||
break;
|
break;
|
||||||
case FORMAT_4UB:
|
case FORMAT_4UB:
|
||||||
*vbuf->vertex_ptr++ = pack_ub4(float_to_ubyte( vertex->data[i][2] ),
|
*vbuf->vertex_ptr++ = pack_ub4(float_to_ubyte( vertex->data[j][2] ),
|
||||||
float_to_ubyte( vertex->data[i][1] ),
|
float_to_ubyte( vertex->data[j][1] ),
|
||||||
float_to_ubyte( vertex->data[i][0] ),
|
float_to_ubyte( vertex->data[j][0] ),
|
||||||
float_to_ubyte( vertex->data[i][3] ));
|
float_to_ubyte( vertex->data[j][3] ));
|
||||||
count += 1;
|
count += 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ struct vertex_info
|
||||||
uint hwfmt[4]; /**< hardware format info for this format */
|
uint hwfmt[4]; /**< hardware format info for this format */
|
||||||
enum interp_mode interp_mode[PIPE_MAX_SHADER_OUTPUTS];
|
enum interp_mode interp_mode[PIPE_MAX_SHADER_OUTPUTS];
|
||||||
enum attrib_format format[PIPE_MAX_SHADER_OUTPUTS]; /**< FORMAT_x */
|
enum attrib_format format[PIPE_MAX_SHADER_OUTPUTS]; /**< FORMAT_x */
|
||||||
|
uint src_index[PIPE_MAX_SHADER_OUTPUTS];
|
||||||
uint size; /**< total vertex size in dwords */
|
uint size; /**< total vertex size in dwords */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -77,16 +78,20 @@ struct vertex_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add another attribute to the given vertex_info object.
|
* 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
|
* \return slot in which the attribute was added
|
||||||
*/
|
*/
|
||||||
static INLINE uint
|
static INLINE uint
|
||||||
draw_emit_vertex_attr(struct vertex_info *vinfo,
|
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;
|
const uint n = vinfo->num_attribs;
|
||||||
assert(n < PIPE_MAX_SHADER_OUTPUTS);
|
assert(n < PIPE_MAX_SHADER_OUTPUTS);
|
||||||
vinfo->format[n] = format;
|
vinfo->format[n] = format;
|
||||||
vinfo->interp_mode[n] = interp;
|
vinfo->interp_mode[n] = interp;
|
||||||
|
vinfo->src_index[n] = src_index;
|
||||||
vinfo->num_attribs++;
|
vinfo->num_attribs++;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,13 @@ static void calculate_vertex_layout( struct i915_context *i915 )
|
||||||
boolean needW = 0;
|
boolean needW = 0;
|
||||||
uint i;
|
uint i;
|
||||||
boolean texCoords[8];
|
boolean texCoords[8];
|
||||||
|
uint src = 0;
|
||||||
|
|
||||||
memset(texCoords, 0, sizeof(texCoords));
|
memset(texCoords, 0, sizeof(texCoords));
|
||||||
memset(&vinfo, 0, sizeof(vinfo));
|
memset(&vinfo, 0, sizeof(vinfo));
|
||||||
|
|
||||||
/* pos */
|
/* 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 */
|
/* Note: we'll set the S4_VFMT_XYZ[W] bits below */
|
||||||
|
|
||||||
for (i = 0; i < fs->num_inputs; i++) {
|
for (i = 0; i < fs->num_inputs; i++) {
|
||||||
|
|
@ -64,12 +65,12 @@ static void calculate_vertex_layout( struct i915_context *i915 )
|
||||||
break;
|
break;
|
||||||
case TGSI_SEMANTIC_COLOR:
|
case TGSI_SEMANTIC_COLOR:
|
||||||
if (fs->input_semantic_index[i] == 0) {
|
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;
|
vinfo.hwfmt[0] |= S4_VFMT_COLOR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(fs->input_semantic_index[i] == 1);
|
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;
|
vinfo.hwfmt[0] |= S4_VFMT_SPEC_FOG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -79,7 +80,7 @@ static void calculate_vertex_layout( struct i915_context *i915 )
|
||||||
const uint unit = fs->input_semantic_index[i];
|
const uint unit = fs->input_semantic_index[i];
|
||||||
uint hwtc;
|
uint hwtc;
|
||||||
texCoords[unit] = TRUE;
|
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;
|
hwtc = TEXCOORDFMT_4D;
|
||||||
needW = TRUE;
|
needW = TRUE;
|
||||||
vinfo.hwfmt[1] |= hwtc << (unit * 4);
|
vinfo.hwfmt[1] |= hwtc << (unit * 4);
|
||||||
|
|
@ -87,7 +88,7 @@ static void calculate_vertex_layout( struct i915_context *i915 )
|
||||||
break;
|
break;
|
||||||
case TGSI_SEMANTIC_FOG:
|
case TGSI_SEMANTIC_FOG:
|
||||||
fprintf(stderr, "i915 fogcoord not implemented yet\n");
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
@ -119,10 +120,10 @@ static void calculate_vertex_layout( struct i915_context *i915 )
|
||||||
*/
|
*/
|
||||||
if (i915->rasterizer->light_twoside) {
|
if (i915->rasterizer->light_twoside) {
|
||||||
if (front0) {
|
if (front0) {
|
||||||
back0 = draw_emit_vertex_attr(&vinfo, FORMAT_OMIT, colorInterp);
|
back0 = draw_emit_vertex_attr(&vinfo, FORMAT_OMIT, colorInterp, src++);
|
||||||
}
|
}
|
||||||
if (back0) {
|
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;
|
boolean emitBack0 = FALSE, emitBack1 = FALSE, emitPsize = FALSE;
|
||||||
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
|
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
|
||||||
uint i;
|
uint i;
|
||||||
|
int src = 0;
|
||||||
|
|
||||||
memset(vinfo, 0, sizeof(*vinfo));
|
memset(vinfo, 0, sizeof(*vinfo));
|
||||||
|
|
||||||
|
|
@ -61,7 +62,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
||||||
softpipe->psize_slot = -1;
|
softpipe->psize_slot = -1;
|
||||||
|
|
||||||
/* always emit vertex pos */
|
/* 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
|
* 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:
|
case TGSI_SEMANTIC_COLOR:
|
||||||
if (vs->output_semantic_index[i] == 0) {
|
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 {
|
else {
|
||||||
assert(vs->output_semantic_index[i] == 1);
|
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;
|
break;
|
||||||
|
|
||||||
|
|
@ -101,7 +102,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TGSI_SEMANTIC_FOG:
|
case TGSI_SEMANTIC_FOG:
|
||||||
draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE);
|
draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE, src++);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TGSI_SEMANTIC_PSIZE:
|
case TGSI_SEMANTIC_PSIZE:
|
||||||
|
|
@ -113,7 +114,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
||||||
|
|
||||||
case TGSI_SEMANTIC_GENERIC:
|
case TGSI_SEMANTIC_GENERIC:
|
||||||
/* this includes texcoords and varying vars */
|
/* 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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -128,14 +129,14 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
||||||
* up 1:1 with the fragment shader inputs.
|
* up 1:1 with the fragment shader inputs.
|
||||||
*/
|
*/
|
||||||
if (emitBack0) {
|
if (emitBack0) {
|
||||||
back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||||
}
|
}
|
||||||
if (emitBack1) {
|
if (emitBack1) {
|
||||||
back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
|
back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
|
||||||
}
|
}
|
||||||
if (emitPsize) {
|
if (emitPsize) {
|
||||||
softpipe->psize_slot
|
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
|
/* If the attributes have changed, tell the draw module about
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue