From: Brian Date: Thu, 20 Sep 2007 20:47:22 +0000 (-0600) Subject: Clean-up the TGSI_SEMANTIC tokens, introduce semantic indexes. X-Git-Tag: 062012170305~17580^2~390^2~4063 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f69b5c56feb60791bad27d491ee9592238d4efb0;p=profile%2Fivi%2Fmesa.git Clean-up the TGSI_SEMANTIC tokens, introduce semantic indexes. Still need to produce decl instructions for vertex shaders... --- diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index 6461e3e..ef0399c 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -94,7 +94,8 @@ run_vertex_program(struct draw_context *draw, const float *trans = draw->viewport.translate; assert(count <= 4); - assert(draw->vertex_shader.output_semantics[0] == TGSI_SEMANTIC_POSITION); + assert(draw->vertex_shader.output_semantic_name[0] + == TGSI_SEMANTIC_POSITION); #ifdef DEBUG memset( &machine, 0, sizeof( machine ) ); diff --git a/src/mesa/pipe/i915simple/i915_fpc.h b/src/mesa/pipe/i915simple/i915_fpc.h index 5c4f2f9..5fdc7ef 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 df8859b..6f78c72 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 2a03650..e825971 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); diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 6396d49..d67736c 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -148,8 +148,12 @@ struct pipe_shader_state { /** These fields somewhat constitute the shader "signature" */ ubyte num_inputs; ubyte num_outputs; - ubyte input_semantics[PIPE_MAX_SHADER_INPUTS]; - ubyte output_semantics[PIPE_MAX_SHADER_OUTPUTS]; + + ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */ + ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS]; + + ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */ + ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; }; struct pipe_depth_stencil_state diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index b51ab66..66e5cc4 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -65,7 +65,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR); for (i = 0; i < fs->num_inputs; i++) { - switch (fs->input_semantics[i]) { + switch (fs->input_semantic_name[i]) { case TGSI_SEMANTIC_POSITION: /* Need Z if depth test is enabled or the fragment program uses the * fragment position (XYZW). @@ -73,13 +73,16 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) softpipe->need_z = TRUE; softpipe->need_w = TRUE; break; - case TGSI_SEMANTIC_COLOR0: - front0 = draw_emit_vertex_attr(vinfo, - FORMAT_4F, colorInterp); - break; - case TGSI_SEMANTIC_COLOR1: - front1 = draw_emit_vertex_attr(vinfo, - FORMAT_4F, colorInterp); + case TGSI_SEMANTIC_COLOR: + if (fs->input_semantic_index[i] == 0) { + front0 = draw_emit_vertex_attr(vinfo, + FORMAT_4F, colorInterp); + } + else { + assert(fs->input_semantic_index[i] == 1); + front1 = draw_emit_vertex_attr(vinfo, + FORMAT_4F, colorInterp); + } break; case TGSI_SEMANTIC_FOG: draw_emit_vertex_attr(vinfo, @@ -96,12 +99,13 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) #endif softpipe->psize_slot = i; /*case TGSI_SEMANTIC_TEXCOORD:*/ - case TGSI_SEMANTIC_TEX0: + case TGSI_SEMANTIC_TEXCOORD: + /* unit = fs->input_semantic_index[i] */ draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE); softpipe->need_w = TRUE; break; - case TGSI_SEMANTIC_OTHER: + case TGSI_SEMANTIC_GENERIC: draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE); softpipe->need_w = TRUE; break; diff --git a/src/mesa/pipe/tgsi/exec/tgsi_build.c b/src/mesa/pipe/tgsi/exec/tgsi_build.c index 1320872..78f648a 100755 --- a/src/mesa/pipe/tgsi/exec/tgsi_build.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_build.c @@ -309,7 +309,7 @@ tgsi_default_declaration_semantic( void ) { struct tgsi_declaration_semantic ds; - ds.SemanticName = TGSI_SEMANTIC_DEPTH; + ds.SemanticName = TGSI_SEMANTIC_POSITION; ds.SemanticIndex = 0; ds.Padding = 0; diff --git a/src/mesa/pipe/tgsi/exec/tgsi_dump.c b/src/mesa/pipe/tgsi/exec/tgsi_dump.c index 0a47ad2..3153541 100755 --- a/src/mesa/pipe/tgsi/exec/tgsi_dump.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_dump.c @@ -201,28 +201,22 @@ static const char *TGSI_INTERPOLATES_SHORT[] = static const char *TGSI_SEMANTICS[] = { - "SEMANTIC_DEPTH", - "SEMANTIC_COLOR0", - "SEMANTIC_COLOR1", - "SEMANTIC_COLOR0B", - "SEMANTIC_COLOR1B", "SEMANTIC_POSITION", + "SEMANTIC_COLOR", + "SEMANTIC_BCOLOR", "SEMANTIC_FOG", - "SEMANTIC_OTHER," - "SEMANTIC_TEX0", + "SEMANTIC_TEXCOORD", + "SEMANTIC_GENERIC," }; static const char *TGSI_SEMANTICS_SHORT[] = { - "DEPTH", - "COLOR0", - "COLOR1", - "COLOR0B", - "COLOR1B", "POSITION", + "COLOR", + "BCOLOR", "FOG", - "OTHER", - "TEX0" + "TEXCOORD", + "GENERIC", }; static const char *TGSI_IMMS[] = diff --git a/src/mesa/pipe/tgsi/exec/tgsi_token.h b/src/mesa/pipe/tgsi/exec/tgsi_token.h index a642ba1..2d468b8 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_token.h +++ b/src/mesa/pipe/tgsi/exec/tgsi_token.h @@ -103,23 +103,13 @@ struct tgsi_declaration_interpolation unsigned Padding : 28; }; -#define TGSI_SEMANTIC_DEPTH 0 -#define TGSI_SEMANTIC_COLOR0 1 -#define TGSI_SEMANTIC_COLOR1 2 -#define TGSI_SEMANTIC_COLOR0B 3 /**< back-face primary color */ -#define TGSI_SEMANTIC_COLOR1B 4 /**< back-face secondary color */ -#define TGSI_SEMANTIC_POSITION 5 -#define TGSI_SEMANTIC_FOG 6 -#define TGSI_SEMANTIC_OTHER 7 /* XXX temp */ -#define TGSI_SEMANTIC_TEX0 8 -#define TGSI_SEMANTIC_TEX1 9 -#define TGSI_SEMANTIC_TEX2 10 -#define TGSI_SEMANTIC_TEX3 11 -#define TGSI_SEMANTIC_TEX4 12 -#define TGSI_SEMANTIC_TEX5 13 -#define TGSI_SEMANTIC_TEX6 14 -#define TGSI_SEMANTIC_TEX7 15 -#define TGSI_SEMANTIC_COUNT 16 /**< number of semantic values */ +#define TGSI_SEMANTIC_POSITION 0 +#define TGSI_SEMANTIC_COLOR 1 +#define TGSI_SEMANTIC_BCOLOR 2 /**< back-face color */ +#define TGSI_SEMANTIC_FOG 3 +#define TGSI_SEMANTIC_TEXCOORD 4 +#define TGSI_SEMANTIC_GENERIC 5 +#define TGSI_SEMANTIC_COUNT 6 /**< number of semantic values */ struct tgsi_declaration_semantic { diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index 115c5d1..c7b62c9 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -473,7 +473,8 @@ make_frag_input_decl( GLuint index, GLuint interpolate, GLuint usage_mask, - GLuint semantic_name ) + GLuint semantic_name, + GLuint semantic_index ) { struct tgsi_full_declaration decl; @@ -486,6 +487,7 @@ make_frag_input_decl( decl.u.DeclarationRange.First = index; decl.u.DeclarationRange.Last = index; decl.Semantic.SemanticName = semantic_name; + decl.Semantic.SemanticIndex = semantic_index; decl.Interpolation.Interpolate = interpolate; return decl; @@ -495,6 +497,7 @@ static struct tgsi_full_declaration make_frag_output_decl( GLuint index, GLuint semantic_name, + GLuint semantic_index, GLuint usage_mask ) { struct tgsi_full_declaration decl; @@ -507,7 +510,7 @@ make_frag_output_decl( decl.u.DeclarationRange.First = index; decl.u.DeclarationRange.Last = index; decl.Semantic.SemanticName = semantic_name; - decl.Semantic.SemanticIndex = 0; + decl.Semantic.SemanticIndex = semantic_index; return decl; } @@ -528,7 +531,8 @@ tgsi_mesa_compile_fp_program( const struct gl_fragment_program *program, GLuint numInputs, const GLuint inputMapping[], - const ubyte inputSemantic[], + const ubyte inputSemanticName[], + const ubyte inputSemanticIndex[], const GLuint interpMode[], const GLuint outputMapping[], struct tgsi_token *tokens, @@ -553,13 +557,13 @@ tgsi_mesa_compile_fp_program( ti = 3; for (i = 0; i < numInputs; i++) { - switch (inputSemantic[i]) { + switch (inputSemanticName[i]) { case TGSI_SEMANTIC_POSITION: /* Fragment XY pos */ fulldecl = make_frag_input_decl(i, TGSI_INTERPOLATE_CONSTANT, TGSI_WRITEMASK_XY, - TGSI_SEMANTIC_POSITION ); + TGSI_SEMANTIC_POSITION, 0 ); ti += tgsi_build_full_declaration( &fulldecl, &tokens[ti], @@ -569,7 +573,7 @@ tgsi_mesa_compile_fp_program( fulldecl = make_frag_input_decl(i, TGSI_INTERPOLATE_LINEAR, TGSI_WRITEMASK_ZW, - TGSI_SEMANTIC_POSITION ); + TGSI_SEMANTIC_POSITION, 0 ); ti += tgsi_build_full_declaration( &fulldecl, &tokens[ti], @@ -580,7 +584,8 @@ tgsi_mesa_compile_fp_program( fulldecl = make_frag_input_decl(i, interpMode[i], TGSI_WRITEMASK_XYZW, - inputSemantic[i] ); + inputSemanticName[i], + inputSemanticIndex[i]); ti += tgsi_build_full_declaration(&fulldecl, &tokens[ti], header, @@ -599,7 +604,7 @@ tgsi_mesa_compile_fp_program( fulldecl = make_frag_output_decl( 0, - TGSI_SEMANTIC_DEPTH, + TGSI_SEMANTIC_POSITION, 0, /* Z / Depth */ TGSI_WRITEMASK_Z ); ti += tgsi_build_full_declaration( &fulldecl, @@ -610,7 +615,7 @@ tgsi_mesa_compile_fp_program( if( program->Base.OutputsWritten & (1 << FRAG_RESULT_COLR) ) { fulldecl = make_frag_output_decl( 1, - TGSI_SEMANTIC_COLOR0, + TGSI_SEMANTIC_COLOR, 0, TGSI_WRITEMASK_XYZW ); ti += tgsi_build_full_declaration( &fulldecl, diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h index d61d80b..b403319 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h @@ -12,7 +12,8 @@ tgsi_mesa_compile_fp_program( const struct gl_fragment_program *program, GLuint numInputs, const GLuint inputMapping[], - const ubyte inputSemantic[], + const ubyte inputSemanticName[], + const ubyte inputSemanticIndex[], const GLuint interpMode[], const GLuint outputMapping[], struct tgsi_token *tokens, diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index 4d65035..8ee4f40 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -77,23 +77,41 @@ st_translate_fragment_shader(struct st_context *st, switch (i) { case FRAG_ATTRIB_WPOS: - fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_POSITION; + fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_POSITION; + fs.input_semantic_index[fs.num_inputs] = 0; interpMode[fs.num_inputs] = TGSI_INTERPOLATE_CONSTANT; break; case FRAG_ATTRIB_COL0: - fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_COLOR0; + fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_COLOR; + fs.input_semantic_index[fs.num_inputs] = 0; interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR; break; case FRAG_ATTRIB_COL1: - fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_COLOR1; + fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_COLOR; + fs.input_semantic_index[fs.num_inputs] = 1; interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR; break; + case FRAG_ATTRIB_FOGC: + assert(0); + break; case FRAG_ATTRIB_TEX0: - fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_TEX0; + case FRAG_ATTRIB_TEX1: + case FRAG_ATTRIB_TEX2: + case FRAG_ATTRIB_TEX3: + case FRAG_ATTRIB_TEX4: + case FRAG_ATTRIB_TEX5: + case FRAG_ATTRIB_TEX6: + case FRAG_ATTRIB_TEX7: + fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_TEXCOORD; + fs.input_semantic_index[fs.num_inputs] = i - FRAG_ATTRIB_TEX0; interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; break; + case FRAG_ATTRIB_VAR0: + /* fall-through */ default: - assert(0); + fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_GENERIC; + fs.input_semantic_index[fs.num_inputs] = i - FRAG_ATTRIB_VAR0; + interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; } fs.num_inputs++; @@ -107,11 +125,11 @@ st_translate_fragment_shader(struct st_context *st, if (stfp->Base.Base.OutputsWritten & (1 << i)) { switch (i) { case FRAG_RESULT_DEPR: - fs.output_semantics[fs.num_outputs] = TGSI_SEMANTIC_DEPTH; + fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_POSITION; outputMapping[i] = fs.num_outputs; break; case FRAG_RESULT_COLR: - fs.output_semantics[fs.num_outputs] = TGSI_SEMANTIC_COLOR0; + fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_COLOR; outputMapping[i] = fs.num_outputs; break; default: @@ -126,7 +144,8 @@ st_translate_fragment_shader(struct st_context *st, tgsi_mesa_compile_fp_program( &stfp->Base, fs.num_inputs, inputMapping, - fs.input_semantics, + fs.input_semantic_name, + fs.input_semantic_index, interpMode, outputMapping, stfp->tokens, ST_FP_MAX_TOKENS ); diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index fcf99bf..b09f2be 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -64,9 +64,8 @@ st_translate_vertex_shader(struct st_context *st, memset(&vs, 0, sizeof(vs)); /* - * Determine how many inputs there are. - * Also, compute two look-up tables that map between Mesa VERT_ATTRIB_x - * values and TGSI generic input indexes. + * Determine number of inputs, the mappings between VERT_ATTRIB_x + * and TGSI generic input indexes, plus input attrib semantic info. */ for (i = 0; i < MAX_VERTEX_PROGRAM_ATTRIBS; i++) { if (stvp->Base.Base.InputsRead & (1 << i)) { @@ -74,26 +73,57 @@ st_translate_vertex_shader(struct st_context *st, stvp->index_to_input[vs.num_inputs] = i; switch (i) { case VERT_ATTRIB_POS: - vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_POSITION; + vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_POSITION; + vs.input_semantic_index[vs.num_inputs] = 0; + break; + case VERT_ATTRIB_WEIGHT: + /* fall-through */ + case VERT_ATTRIB_NORMAL: + /* just label as a generic */ + vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC; + vs.input_semantic_index[vs.num_inputs] = 0; break; case VERT_ATTRIB_COLOR0: - vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR0; + vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR; + vs.input_semantic_index[vs.num_inputs] = 0; break; case VERT_ATTRIB_COLOR1: - vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1; + vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR; + vs.input_semantic_index[vs.num_inputs] = 1; break; case VERT_ATTRIB_TEX0: - vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_TEX0; + case VERT_ATTRIB_TEX1: + case VERT_ATTRIB_TEX2: + case VERT_ATTRIB_TEX3: + case VERT_ATTRIB_TEX4: + case VERT_ATTRIB_TEX5: + case VERT_ATTRIB_TEX6: + case VERT_ATTRIB_TEX7: + vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_TEXCOORD; + vs.input_semantic_index[vs.num_inputs] = 1 - VERT_ATTRIB_TEX0; + break; + case VERT_ATTRIB_GENERIC0: + case VERT_ATTRIB_GENERIC1: + case VERT_ATTRIB_GENERIC2: + case VERT_ATTRIB_GENERIC3: + case VERT_ATTRIB_GENERIC4: + case VERT_ATTRIB_GENERIC5: + case VERT_ATTRIB_GENERIC6: + case VERT_ATTRIB_GENERIC7: + assert(i < VERT_ATTRIB_MAX); + vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC; + vs.input_semantic_index[vs.num_inputs] = 1 - VERT_ATTRIB_GENERIC0; break; default: - vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_OTHER; + assert(0); } vs.num_inputs++; } } /* - * Determine number of outputs and the register mapping. + * Determine number of outputs, the register mapping and + * the semantic information for each vertex output/result. */ for (i = 0; i < VERT_RESULT_MAX; i++) { if (stvp->Base.Base.OutputsWritten & (1 << i)) { @@ -102,23 +132,49 @@ st_translate_vertex_shader(struct st_context *st, switch (i) { case VERT_RESULT_HPOS: - vs.output_semantics[vs.num_outputs] = TGSI_SEMANTIC_POSITION; + vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_POSITION; + vs.output_semantic_index[vs.num_inputs] = 0; break; case VERT_RESULT_COL0: - vs.output_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR0; + vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR; + vs.output_semantic_index[vs.num_inputs] = 0; break; case VERT_RESULT_COL1: - vs.output_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1; + vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR; + vs.output_semantic_index[vs.num_inputs] = 1; break; case VERT_RESULT_BFC0: - vs.output_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR0B; + vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_BCOLOR; + vs.output_semantic_index[vs.num_inputs] = 0; break; case VERT_RESULT_BFC1: - vs.output_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1B; + vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_BCOLOR; + vs.output_semantic_index[vs.num_inputs] = 1; + break; + case VERT_RESULT_FOGC: + case VERT_RESULT_PSIZ: + case VERT_RESULT_EDGE: + assert(0); break; + case VERT_RESULT_TEX0: + case VERT_RESULT_TEX1: + case VERT_RESULT_TEX2: + case VERT_RESULT_TEX3: + case VERT_RESULT_TEX4: + case VERT_RESULT_TEX5: + case VERT_RESULT_TEX6: + case VERT_RESULT_TEX7: + vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_TEXCOORD; + vs.output_semantic_index[vs.num_inputs] = i - VERT_RESULT_TEX0; + break; + case VERT_RESULT_VAR0: + /* fall-through */ default: - vs.output_semantics[vs.num_outputs] = TGSI_SEMANTIC_OTHER; + assert(i - VERT_RESULT_VAR0 < MAX_VARYING); + vs.output_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC; + vs.output_semantic_index[vs.num_inputs] = i - VERT_RESULT_VAR0; } + vs.num_outputs++; } }