diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-09-20 14:47:22 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-09-20 14:47:22 -0600 |
commit | f69b5c56feb60791bad27d491ee9592238d4efb0 (patch) | |
tree | 4e20d2ee723239121e5bf8b94a9786dc05e00440 /src/mesa/pipe/i915simple | |
parent | 478d1e2c9c73fc29542375c44d01ab964ce8eccf (diff) |
Clean-up the TGSI_SEMANTIC tokens, introduce semantic indexes.
Still need to produce decl instructions for vertex shaders...
Diffstat (limited to 'src/mesa/pipe/i915simple')
-rw-r--r-- | src/mesa/pipe/i915simple/i915_fpc.h | 3 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_fpc_translate.c | 48 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state_derived.c | 32 |
3 files changed, 39 insertions, 44 deletions
diff --git a/src/mesa/pipe/i915simple/i915_fpc.h b/src/mesa/pipe/i915simple/i915_fpc.h index 5c4f2f90e9..5fdc7ef27e 100644 --- a/src/mesa/pipe/i915simple/i915_fpc.h +++ b/src/mesa/pipe/i915simple/i915_fpc.h @@ -51,7 +51,8 @@ struct i915_fp_compile { uint declarations[I915_PROGRAM_SIZE]; uint program[I915_PROGRAM_SIZE]; - uint input_semantic[PIPE_MAX_SHADER_INPUTS]; + uint input_semantic_name[PIPE_MAX_SHADER_INPUTS]; + uint input_semantic_index[PIPE_MAX_SHADER_INPUTS]; /** points into the i915->current.constants array: */ float (*constants)[4]; diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c index df8859bec8..6f78c72e04 100644 --- a/src/mesa/pipe/i915simple/i915_fpc_translate.c +++ b/src/mesa/pipe/i915simple/i915_fpc_translate.c @@ -128,7 +128,7 @@ src_vector(struct i915_fp_compile *p, const struct tgsi_full_src_register *source) { uint index = source->SrcRegister.Index; - uint src, sem; + uint src, sem_name, sem_ind; switch (source->SrcRegister.File) { case TGSI_FILE_TEMPORARY: @@ -152,10 +152,11 @@ src_vector(struct i915_fp_compile *p, /* use vertex format info to map a slot number to a VF attrib */ assert(index < p->vertex_info->num_attribs); - sem = p->input_semantic[index]; + sem_name = p->input_semantic_name[index]; + sem_ind = p->input_semantic_index[index]; #if 1 - switch (sem) { + switch (sem_name) { case TGSI_SEMANTIC_POSITION: printf("SKIP SEM POS\n"); /* @@ -163,28 +164,23 @@ src_vector(struct i915_fp_compile *p, src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL); */ break; - case TGSI_SEMANTIC_COLOR0: - src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL); - break; - case TGSI_SEMANTIC_COLOR1: - src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ); - src = swizzle(src, X, Y, Z, ONE); + case TGSI_SEMANTIC_COLOR: + if (sem_ind == 0) { + src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL); + } + else { + /* secondary color */ + assert(sem_ind == 1); + src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ); + src = swizzle(src, X, Y, Z, ONE); + } break; case TGSI_SEMANTIC_FOG: src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W); src = swizzle(src, W, W, W, W); break; - case TGSI_SEMANTIC_TEX0: - case TGSI_SEMANTIC_TEX1: - case TGSI_SEMANTIC_TEX2: - case TGSI_SEMANTIC_TEX3: - case TGSI_SEMANTIC_TEX4: - case TGSI_SEMANTIC_TEX5: - case TGSI_SEMANTIC_TEX6: - case TGSI_SEMANTIC_TEX7: - src = i915_emit_decl(p, REG_TYPE_T, - T_TEX0 + (sem - TGSI_SEMANTIC_TEX0), - D0_CHANNEL_ALL); + case TGSI_SEMANTIC_TEXCOORD: + src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + sem_ind, D0_CHANNEL_ALL); break; default: i915_program_error(p, "Bad source->Index"); @@ -895,11 +891,13 @@ i915_translate_instructions(struct i915_fp_compile *p, if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_INPUT) { /* save input register info for use in src_vector() */ - uint ind, sem; + uint ind, sem, semi; ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First; sem = parse.FullToken.FullDeclaration.Semantic.SemanticName; + semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex; /*printf("FS Input DECL [%u] sem %u\n", ind, sem);*/ - p->input_semantic[ind] = sem; + p->input_semantic_name[ind] = sem; + p->input_semantic_index[ind] = semi; } break; @@ -1059,7 +1057,7 @@ i915_find_wpos_space(struct i915_fp_compile *p) i915_program_error(p, "No free texcoord for wpos value"); } #else - if (p->shader->input_semantics[0] == TGSI_SEMANTIC_POSITION) { + if (p->shader->input_semantic_name[0] == TGSI_SEMANTIC_POSITION) { /* frag shader using the fragment position input */ #if 0 assert(0); @@ -1079,8 +1077,8 @@ i915_find_wpos_space(struct i915_fp_compile *p) static void i915_fixup_depth_write(struct i915_fp_compile *p) { - /* XXX assuming depth is always in output[0] */ - if (p->shader->output_semantics[0] == TGSI_SEMANTIC_DEPTH) { + /* XXX assuming pos/depth is always in output[0] */ + if (p->shader->output_semantic_name[0] == TGSI_SEMANTIC_POSITION) { const uint depth = UREG(REG_TYPE_OD, 0); i915_emit_arith(p, diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 2a03650620..e825971199 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -59,28 +59,24 @@ static void calculate_vertex_layout( struct i915_context *i915 ) /* Note: we'll set the S4_VFMT_XYZ[W] bits below */ for (i = 0; i < fs->num_inputs; i++) { - switch (fs->input_semantics[i]) { + switch (fs->input_semantic_name[i]) { case TGSI_SEMANTIC_POSITION: break; - case TGSI_SEMANTIC_COLOR0: - front0 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp); - vinfo->hwfmt[0] |= S4_VFMT_COLOR; - break; - case TGSI_SEMANTIC_COLOR1: - assert(0); /* untested */ - front1 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp); - vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG; + case TGSI_SEMANTIC_COLOR: + if (fs->input_semantic_index[i] == 0) { + front0 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp); + vinfo->hwfmt[0] |= S4_VFMT_COLOR; + } + else { + assert(fs->input_semantic_index[i] == 1); + assert(0); /* untested */ + front1 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp); + vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG; + } break; - case TGSI_SEMANTIC_TEX0: - case TGSI_SEMANTIC_TEX1: - case TGSI_SEMANTIC_TEX2: - case TGSI_SEMANTIC_TEX3: - case TGSI_SEMANTIC_TEX4: - case TGSI_SEMANTIC_TEX5: - case TGSI_SEMANTIC_TEX6: - case TGSI_SEMANTIC_TEX7: + case TGSI_SEMANTIC_TEXCOORD: { - const uint unit = fs->input_semantics[i] - TGSI_SEMANTIC_TEX0; + const uint unit = fs->input_semantic_index[i]; uint hwtc; texCoords[unit] = TRUE; draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE); |