i915g: handle varyings properly.

This commit is contained in:
Stéphane Marchesin 2011-06-03 17:06:59 -07:00
parent 893b92adff
commit 0ce977a66e
2 changed files with 27 additions and 9 deletions

View File

@ -192,8 +192,14 @@ src_vector(struct i915_fp_compile *p,
src = swizzle(src, W, W, W, W); src = swizzle(src, W, W, W, W);
break; break;
case TGSI_SEMANTIC_GENERIC: case TGSI_SEMANTIC_GENERIC:
/* usually a texcoord */ if (sem_ind < 8)
src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + sem_ind, D0_CHANNEL_ALL); /* a texcoord */
src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + sem_ind, D0_CHANNEL_ALL);
else if ( (sem_ind >= 10) && (sem_ind < 18) )
/* a varying */
src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + sem_ind - 10, D0_CHANNEL_ALL);
else
debug_printf("%s: unhandled generic %d\n", __func__, sem_ind);
break; break;
default: default:
i915_program_error(p, "Bad source->Index"); i915_program_error(p, "Bad source->Index");

View File

@ -46,12 +46,12 @@ static void calculate_vertex_layout(struct i915_context *i915)
const struct i915_fragment_shader *fs = i915->fs; const struct i915_fragment_shader *fs = i915->fs;
const enum interp_mode colorInterp = i915->rasterizer->color_interp; const enum interp_mode colorInterp = i915->rasterizer->color_interp;
struct vertex_info vinfo; struct vertex_info vinfo;
boolean texCoords[8], colors[2], fog, needW; boolean texCoords[8], colors[2], fog, needW, have_varyings;
uint i; uint i;
int src; int src;
memset(texCoords, 0, sizeof(texCoords)); memset(texCoords, 0, sizeof(texCoords));
colors[0] = colors[1] = fog = needW = FALSE; colors[0] = colors[1] = fog = needW = have_varyings = FALSE;
memset(&vinfo, 0, sizeof(vinfo)); memset(&vinfo, 0, sizeof(vinfo));
/* Determine which fragment program inputs are needed. Setup HW vertex /* Determine which fragment program inputs are needed. Setup HW vertex
@ -66,10 +66,19 @@ static void calculate_vertex_layout(struct i915_context *i915)
colors[fs->info.input_semantic_index[i]] = TRUE; colors[fs->info.input_semantic_index[i]] = TRUE;
break; break;
case TGSI_SEMANTIC_GENERIC: case TGSI_SEMANTIC_GENERIC:
/* usually a texcoord */
{ {
const uint unit = fs->info.input_semantic_index[i]; /* texcoords/varyings */
/* XXX handle back/front face and point size */
uint unit = fs->info.input_semantic_index[i];
/* Route varyings as tex coords */
if ( (unit >= 10) && (unit < 18) ) {
have_varyings = TRUE;
unit -= 10;
}
assert(unit < 8); assert(unit < 8);
texCoords[unit] = TRUE; texCoords[unit] = TRUE;
needW = TRUE; needW = TRUE;
} }
@ -82,7 +91,7 @@ static void calculate_vertex_layout(struct i915_context *i915)
} }
} }
/* pos */ /* pos */
src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_POSITION, 0); src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_POSITION, 0);
if (needW) { if (needW) {
@ -120,12 +129,15 @@ static void calculate_vertex_layout(struct i915_context *i915)
vinfo.hwfmt[0] |= S4_VFMT_FOG_PARAM; vinfo.hwfmt[0] |= S4_VFMT_FOG_PARAM;
} }
/* texcoords */ /* texcoords/varyings */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
uint hwtc; uint hwtc;
if (texCoords[i]) { if (texCoords[i]) {
hwtc = TEXCOORDFMT_4D; hwtc = TEXCOORDFMT_4D;
src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_GENERIC, i); if (!have_varyings)
src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_GENERIC, i);
else
src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_GENERIC, i + 10);
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src); draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
} }
else { else {