diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/pipe/draw/draw_arrays.c | 9 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_clip.c | 4 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_flatshade.c | 8 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_private.h | 3 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_twoside.c | 8 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex.h | 83 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_fpc_emit.c | 9 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_fpc_translate.c | 39 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state_derived.c | 96 | ||||
-rw-r--r-- | src/mesa/pipe/p_state.h | 4 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_prim_setup.c | 17 | ||||
-rwxr-xr-x | src/mesa/pipe/softpipe/sp_quad_fs.c | 3 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_derived.c | 72 | ||||
-rw-r--r-- | src/mesa/pipe/tgsi/core/tgsi_token.h | 41 | ||||
-rw-r--r-- | src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c | 84 | ||||
-rw-r--r-- | src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h | 25 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_fs.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 3 |
18 files changed, 228 insertions, 286 deletions
diff --git a/src/mesa/pipe/draw/draw_arrays.c b/src/mesa/pipe/draw/draw_arrays.c index 784eb3f2e6..f6bf174dc0 100644 --- a/src/mesa/pipe/draw/draw_arrays.c +++ b/src/mesa/pipe/draw/draw_arrays.c @@ -78,6 +78,7 @@ emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format) vinfo->slot_to_attrib[n] = vfAttr; if (n >= 2) { /* the first two slots are the vertex header & clippos */ + assert(vfAttr < Elements(vinfo->attrib_to_slot)); vinfo->attrib_to_slot[vfAttr] = n - 2; } /*printf("Vertex slot %d = vfattrib %d\n", n, vfAttr);*/ @@ -128,16 +129,16 @@ draw_set_vertex_attributes( struct draw_context *draw, struct vertex_info *vinfo = &draw->vertex_info; unsigned i; - assert(slot_to_vf_attr[0] == VF_ATTRIB_POS); + assert(slot_to_vf_attr[0] == TGSI_ATTRIB_POS); memset(vinfo, 0, sizeof(*vinfo)); /* * First three attribs are always the same: header, clip pos, winpos */ - emit_vertex_attr(vinfo, VF_ATTRIB_VERTEX_HEADER, FORMAT_1F); - emit_vertex_attr(vinfo, VF_ATTRIB_CLIP_POS, FORMAT_4F); - emit_vertex_attr(vinfo, VF_ATTRIB_POS, FORMAT_4F_VIEWPORT); + emit_vertex_attr(vinfo, TGSI_ATTRIB_VERTEX_HEADER, FORMAT_1F); + emit_vertex_attr(vinfo, TGSI_ATTRIB_CLIP_POS, FORMAT_4F); + emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_4F_VIEWPORT); /* * Remaining attribs (color, texcoords, etc) diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c index 1c2491d2c6..f46f4e3de6 100644 --- a/src/mesa/pipe/draw/draw_clip.c +++ b/src/mesa/pipe/draw/draw_clip.c @@ -380,8 +380,8 @@ static void clip_begin( struct draw_stage *stage ) /* sanity checks. If these fail, review the clip/interp code! */ assert(stage->draw->vertex_info.num_attribs >= 3); - assert(stage->draw->vertex_info.slot_to_attrib[0] == VF_ATTRIB_VERTEX_HEADER); - assert(stage->draw->vertex_info.slot_to_attrib[1] == VF_ATTRIB_CLIP_POS); + assert(stage->draw->vertex_info.slot_to_attrib[0] == TGSI_ATTRIB_VERTEX_HEADER); + assert(stage->draw->vertex_info.slot_to_attrib[1] == TGSI_ATTRIB_CLIP_POS); /* Hacky bitmask to use when we hit CLIP_USER_BIT: */ diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c index 34588c83b6..d8db1f748c 100644 --- a/src/mesa/pipe/draw/draw_flatshade.c +++ b/src/mesa/pipe/draw/draw_flatshade.c @@ -72,10 +72,10 @@ static INLINE void copy_colors( struct draw_stage *stage, const struct flatshade_stage *flatshade = flatshade_stage(stage); const unsigned *lookup = flatshade->lookup; - copy_attr( lookup[VF_ATTRIB_COLOR0], dst, src ); - copy_attr( lookup[VF_ATTRIB_COLOR1], dst, src ); - copy_attr( lookup[VF_ATTRIB_BFC0], dst, src ); - copy_attr( lookup[VF_ATTRIB_BFC1], dst, src ); + copy_attr( lookup[TGSI_ATTRIB_COLOR0], dst, src ); + copy_attr( lookup[TGSI_ATTRIB_COLOR1], dst, src ); + copy_attr( lookup[TGSI_ATTRIB_BFC0], dst, src ); + copy_attr( lookup[TGSI_ATTRIB_BFC1], dst, src ); } diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index 531bb2e254..c5d4c62f71 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -61,7 +61,8 @@ struct vertex_header { float data[][4]; /* Note variable size */ }; -#define MAX_VERTEX_SIZE ((2 + FRAG_ATTRIB_MAX) * 4 * sizeof(float)) +/* XXX This is too large */ +#define MAX_VERTEX_SIZE ((2 + TGSI_ATTRIB_MAX) * 4 * sizeof(float)) diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c index 822cadd61f..4fd87786f8 100644 --- a/src/mesa/pipe/draw/draw_twoside.c +++ b/src/mesa/pipe/draw/draw_twoside.c @@ -79,12 +79,12 @@ static struct vertex_header *copy_bfc( struct twoside_stage *twoside, { struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx ); - copy_color( twoside->lookup[VF_ATTRIB_COLOR0], - twoside->lookup[VF_ATTRIB_BFC0], + copy_color( twoside->lookup[TGSI_ATTRIB_COLOR0], + twoside->lookup[TGSI_ATTRIB_BFC0], tmp ); - copy_color( twoside->lookup[VF_ATTRIB_COLOR1], - twoside->lookup[VF_ATTRIB_BFC1], + copy_color( twoside->lookup[TGSI_ATTRIB_COLOR1], + twoside->lookup[TGSI_ATTRIB_BFC1], tmp ); return tmp; diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 3262431487..0e15ea89a2 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -33,84 +33,7 @@ #ifndef DRAW_VERTEX_H #define DRAW_VERTEX_H - -/*** - *** XXX There's a lot of legacy tokens here that'll eventually go away. - *** (at least we don't include vf/vf.h anymore) - ***/ - - -enum { - VF_ATTRIB_POS = 0, - VF_ATTRIB_WEIGHT = 1, - VF_ATTRIB_NORMAL = 2, - VF_ATTRIB_COLOR0 = 3, - VF_ATTRIB_COLOR1 = 4, - VF_ATTRIB_FOG = 5, - VF_ATTRIB_COLOR_INDEX = 6, - VF_ATTRIB_EDGEFLAG = 7, - VF_ATTRIB_TEX0 = 8, - VF_ATTRIB_TEX1 = 9, - VF_ATTRIB_TEX2 = 10, - VF_ATTRIB_TEX3 = 11, - VF_ATTRIB_TEX4 = 12, - VF_ATTRIB_TEX5 = 13, - VF_ATTRIB_TEX6 = 14, - VF_ATTRIB_TEX7 = 15, - VF_ATTRIB_VAR0 = 16, - VF_ATTRIB_VAR1 = 17, - VF_ATTRIB_VAR2 = 18, - VF_ATTRIB_VAR3 = 19, - VF_ATTRIB_VAR4 = 20, - VF_ATTRIB_VAR5 = 21, - VF_ATTRIB_VAR6 = 22, - VF_ATTRIB_VAR7 = 23, - VF_ATTRIB_POINTSIZE = 24, - VF_ATTRIB_BFC0 = 25, - VF_ATTRIB_BFC1 = 26, - VF_ATTRIB_CLIP_POS = 27, - VF_ATTRIB_VERTEX_HEADER = 28, - VF_ATTRIB_MAX = 29 -}; - -#define MAX_VARYING 8 -enum -{ - FRAG_ATTRIB_WPOS = 0, - FRAG_ATTRIB_COL0 = 1, - FRAG_ATTRIB_COL1 = 2, - FRAG_ATTRIB_FOGC = 3, - FRAG_ATTRIB_TEX0 = 4, - FRAG_ATTRIB_TEX1 = 5, - FRAG_ATTRIB_TEX2 = 6, - FRAG_ATTRIB_TEX3 = 7, - FRAG_ATTRIB_TEX4 = 8, - FRAG_ATTRIB_TEX5 = 9, - FRAG_ATTRIB_TEX6 = 10, - FRAG_ATTRIB_TEX7 = 11, - FRAG_ATTRIB_VAR0 = 12, /**< shader varying */ - FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) -}; - -#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) -#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) -#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) -#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) -#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) - - - -#define MAX_DRAW_BUFFERS 4 - -enum -{ - FRAG_RESULT_COLR = 0, - FRAG_RESULT_COLH = 1, - FRAG_RESULT_DEPR = 2, - FRAG_RESULT_DATA0 = 3, - FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) -}; - +#include "pipe/tgsi/core/tgsi_attribs.h" #define MAX_VERT_ATTRIBS 12 /* OK? */ @@ -127,10 +50,10 @@ enum struct vertex_info { uint num_attribs; - uint hwfmt[2]; /**< hardware format info for this format */ + uint hwfmt[4]; /**< hardware format info for this format */ uint attr_mask; /**< mask of VF_ATTR_ bits */ uint slot_to_attrib[MAX_VERT_ATTRIBS]; - uint attrib_to_slot[VF_ATTRIB_MAX]; + uint attrib_to_slot[TGSI_ATTRIB_MAX]; uint interp_mode[MAX_VERT_ATTRIBS]; uint format[MAX_VERT_ATTRIBS]; /**< FORMAT_x */ uint size; /**< total vertex size in dwords */ diff --git a/src/mesa/pipe/i915simple/i915_fpc_emit.c b/src/mesa/pipe/i915simple/i915_fpc_emit.c index f062885f8a..c8d36435d9 100644 --- a/src/mesa/pipe/i915simple/i915_fpc_emit.c +++ b/src/mesa/pipe/i915simple/i915_fpc_emit.c @@ -353,23 +353,14 @@ i915_emit_param4fv(struct i915_fp_compile * p, const float * values) return UREG(REG_TYPE_CONST, fp->param[i].reg); } -#if 0 - if (fp->nr_constants == I915_MAX_CONSTANT || - fp->nr_params == I915_MAX_CONSTANT) { -#else if (p->constants->nr_constants == I915_MAX_CONSTANT || fp->nr_params == I915_MAX_CONSTANT) { -#endif i915_program_error(p, "i915_emit_param4fv: out of constants\n"); return 0; } { -#if 0 - int reg = fp->nr_constants++; -#else int reg = p->constants->nr_constants++; -#endif int i = fp->nr_params++; assert (p->constant_flags[reg] == 0); diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c index be3de0f3f4..e7315d2263 100644 --- a/src/mesa/pipe/i915simple/i915_fpc_translate.c +++ b/src/mesa/pipe/i915simple/i915_fpc_translate.c @@ -154,31 +154,31 @@ src_vector(struct i915_fp_compile *p, index = p->vertex_info->slot_to_attrib[index]; switch (index) { - case VF_ATTRIB_POS: + case TGSI_ATTRIB_POS: assert(p->wpos_tex != -1); src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL); break; - case VF_ATTRIB_COLOR0: + case TGSI_ATTRIB_COLOR0: src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL); break; - case VF_ATTRIB_COLOR1: + case TGSI_ATTRIB_COLOR1: src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ); src = swizzle(src, X, Y, Z, ONE); break; - case VF_ATTRIB_FOG: + case TGSI_ATTRIB_FOG: src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W); src = swizzle(src, W, W, W, W); break; - case VF_ATTRIB_TEX0: - case VF_ATTRIB_TEX1: - case VF_ATTRIB_TEX2: - case VF_ATTRIB_TEX3: - case VF_ATTRIB_TEX4: - case VF_ATTRIB_TEX5: - case VF_ATTRIB_TEX6: - case VF_ATTRIB_TEX7: + case TGSI_ATTRIB_TEX0: + case TGSI_ATTRIB_TEX1: + case TGSI_ATTRIB_TEX2: + case TGSI_ATTRIB_TEX3: + case TGSI_ATTRIB_TEX4: + case TGSI_ATTRIB_TEX5: + case TGSI_ATTRIB_TEX6: + case TGSI_ATTRIB_TEX7: src = i915_emit_decl(p, REG_TYPE_T, - T_TEX0 + (index - VF_ATTRIB_TEX0), + T_TEX0 + (index - TGSI_ATTRIB_TEX0), D0_CHANNEL_ALL); break; default: @@ -237,9 +237,9 @@ get_result_vector(struct i915_fp_compile *p, switch (dest->DstRegister.File) { case TGSI_FILE_OUTPUT: switch (dest->DstRegister.Index) { - case 1: /*COLOR*/ /*FRAG_RESULT_COLR:*/ + case TGSI_ATTRIB_COLOR0: return UREG(REG_TYPE_OC, 0); - case 0: /*DEPTH*/ /*FRAG_RESULT_DEPR:*/ + case TGSI_ATTRIB_POS: return UREG(REG_TYPE_OD, 0); default: i915_program_error(p, "Bad inst->DstReg.Index"); @@ -989,14 +989,15 @@ i915_fini_compile(struct i915_context *i915, struct i915_fp_compile *p) static void i915_find_wpos_space(struct i915_fp_compile *p) { - const uint inputs = p->shader->inputs_read | FRAG_BIT_WPOS; /*XXX hack*/ + const uint inputs + = p->shader->inputs_read | (1 << TGSI_ATTRIB_POS); /*XXX hack*/ uint i; p->wpos_tex = -1; - if (inputs & FRAG_BIT_WPOS) { + if (inputs & (1 << TGSI_ATTRIB_POS)) { for (i = 0; i < I915_TEX_UNITS; i++) { - if ((inputs & (FRAG_BIT_TEX0 << i)) == 0) { + if ((inputs & (1 << (TGSI_ATTRIB_TEX0 + i))) == 0) { p->wpos_tex = i; return; } @@ -1017,7 +1018,7 @@ i915_find_wpos_space(struct i915_fp_compile *p) static void i915_fixup_depth_write(struct i915_fp_compile *p) { - if (p->shader->outputs_written & (1<<FRAG_RESULT_DEPR)) { + if (p->shader->outputs_written & (1 << TGSI_ATTRIB_POS)) { 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 e8c7dfba6f..426d43f288 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -35,32 +35,6 @@ #include "i915_fpc.h" - -static const unsigned frag_to_vf[FRAG_ATTRIB_MAX] = -{ - VF_ATTRIB_POS, - VF_ATTRIB_COLOR0, - VF_ATTRIB_COLOR1, - VF_ATTRIB_FOG, - VF_ATTRIB_TEX0, - VF_ATTRIB_TEX1, - VF_ATTRIB_TEX2, - VF_ATTRIB_TEX3, - VF_ATTRIB_TEX4, - VF_ATTRIB_TEX5, - VF_ATTRIB_TEX6, - VF_ATTRIB_TEX7, - VF_ATTRIB_VAR0, - VF_ATTRIB_VAR1, - VF_ATTRIB_VAR2, - VF_ATTRIB_VAR3, - VF_ATTRIB_VAR4, - VF_ATTRIB_VAR5, - VF_ATTRIB_VAR6, - VF_ATTRIB_VAR7, -}; - - static INLINE void emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format) { @@ -118,44 +92,45 @@ static void calculate_vertex_layout( struct i915_context *i915 ) { const unsigned inputsRead = i915->fs.inputs_read; struct vertex_info *vinfo = &i915->current.vertex_info; - uint i; memset(vinfo, 0, sizeof(*vinfo)); /* TODO - Figure out if we need to do perspective divide, etc. */ - emit_vertex_attr(vinfo, VF_ATTRIB_POS, FORMAT_3F); + + /* pos */ + emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_3F); vinfo->hwfmt[0] |= S4_VFMT_XYZ; - - /* Pull in the rest of the attributes. They are all in float4 - * format. Future optimizations could be to keep some attributes - * as fixed point or ubyte format. - */ - for (i = 1; i < FRAG_ATTRIB_TEX0; i++) { - if (inputsRead & (1 << i)) { - assert(i < Elements(frag_to_vf)); - if (i915->setup.flatshade - && (i == FRAG_ATTRIB_COL0 || i == FRAG_ATTRIB_COL1)) { - emit_vertex_attr(vinfo, frag_to_vf[i], FORMAT_4UB); - } - else { - emit_vertex_attr(vinfo, frag_to_vf[i], FORMAT_4UB); - } - vinfo->hwfmt[0] |= S4_VFMT_COLOR; - } + + /* color0 */ + if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { + emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, FORMAT_4UB); + vinfo->hwfmt[0] |= S4_VFMT_COLOR; } - for (i = FRAG_ATTRIB_TEX0; i <= FRAG_ATTRIB_TEX7/*MAX*/; i++) { - uint hwtc; - if (inputsRead & (1 << i)) { - hwtc = TEXCOORDFMT_4D; - assert(i < sizeof(frag_to_vf) / sizeof(frag_to_vf[0])); - emit_vertex_attr(vinfo, frag_to_vf[i], FORMAT_4F); - } - else { - hwtc = TEXCOORDFMT_NOT_PRESENT; + /* color 1 */ + if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) { + assert(0); /* untested */ + emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1, FORMAT_4UB); + vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG; + } + + /* XXX fog? */ + + /* texcoords */ + { + uint i; + for (i = TGSI_ATTRIB_TEX0; i <= TGSI_ATTRIB_TEX7; i++) { + uint hwtc; + if (inputsRead & (1 << i)) { + emit_vertex_attr(vinfo, i, FORMAT_4F); + hwtc = TEXCOORDFMT_4D; + } + else { + hwtc = TEXCOORDFMT_NOT_PRESENT; + } + vinfo->hwfmt[1] |= hwtc << ((i - TGSI_ATTRIB_TEX0) * 4); } - vinfo->hwfmt[1] |= hwtc << ((i - FRAG_ATTRIB_TEX0) * 4); } /* Additional attributes required for setup: Just twosided @@ -163,12 +138,11 @@ static void calculate_vertex_layout( struct i915_context *i915 ) * the vertex header. */ if (i915->setup.light_twoside) { - if (inputsRead & FRAG_BIT_COL0) { - emit_vertex_attr(vinfo, VF_ATTRIB_BFC0, FORMAT_OMIT); - } - - if (inputsRead & FRAG_BIT_COL1) { - emit_vertex_attr(vinfo, VF_ATTRIB_BFC1, FORMAT_OMIT); + if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { + emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, FORMAT_OMIT); + } + if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) { + emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC1, FORMAT_OMIT); } } diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index d29b85117b..e562a8d058 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -125,8 +125,8 @@ struct pipe_constant_buffer { struct pipe_shader_state { - unsigned inputs_read; /**< FRAG/VERT_ATTRIB_x */ - unsigned outputs_written; /**< FRAG/VERT_RESULT_x */ + unsigned inputs_read; /**< TGSI_ATTRIB_ bits */ + unsigned outputs_written; /**< TGSI_ATTRIB_ bits */ const struct tgsi_token *tokens; }; diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index f779deac28..e8ed548cf0 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -40,10 +40,7 @@ #include "pipe/draw/draw_private.h" #include "pipe/p_util.h" - -/** XXX remove */ -#define FRAG_ATTRIB_WPOS 0 -#define FRAG_ATTRIB_MAX 13 +#include "pipe/draw/draw_vertex.h" /** @@ -82,7 +79,7 @@ struct setup_stage { float oneoverarea; - struct tgsi_interp_coef coef[FRAG_ATTRIB_MAX]; + struct tgsi_interp_coef coef[TGSI_ATTRIB_MAX]; struct quad_header quad; struct { @@ -369,7 +366,7 @@ static void const_coeff( struct setup_stage *setup, unsigned slot, unsigned i ) { - assert(slot < FRAG_ATTRIB_MAX); + assert(slot < TGSI_ATTRIB_MAX); assert(i <= 3); setup->coef[slot].dadx[i] = 0; @@ -394,7 +391,7 @@ static void tri_linear_coeff( struct setup_stage *setup, float a = setup->ebot.dy * majda - botda * setup->emaj.dy; float b = setup->emaj.dx * botda - majda * setup->ebot.dx; - assert(slot < FRAG_ATTRIB_MAX); + assert(slot < TGSI_ATTRIB_MAX); assert(i <= 3); setup->coef[slot].dadx[i] = a * setup->oneoverarea; @@ -445,7 +442,7 @@ static void tri_persp_coeff( struct setup_stage *setup, float a = setup->ebot.dy * majda - botda * setup->emaj.dy; float b = setup->emaj.dx * botda - majda * setup->ebot.dx; - assert(slot < FRAG_ATTRIB_MAX); + assert(slot < TGSI_ATTRIB_MAX); assert(i <= 3); setup->coef[slot].dadx[i] = a * setup->oneoverarea; @@ -891,8 +888,8 @@ setup_point(struct draw_stage *stage, struct prim_header *prim) const float halfSize = 0.5f * setup->softpipe->setup.point_size; const boolean round = setup->softpipe->setup.point_smooth; const struct vertex_header *v0 = prim->v[0]; - const float x = v0->data[FRAG_ATTRIB_WPOS][0]; - const float y = v0->data[FRAG_ATTRIB_WPOS][1]; + const float x = v0->data[TGSI_ATTRIB_POS][0]; + const float y = v0->data[TGSI_ATTRIB_POS][1]; unsigned slot, j; /* For points, all interpolants are constant-valued. diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index 8a419c9ac7..8d41e09465 100755 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -34,6 +34,7 @@ #include "pipe/p_util.h" #include "pipe/p_defines.h" +#include "pipe/tgsi/core/tgsi_attribs.h" #include "sp_context.h" #include "sp_headers.h" @@ -138,7 +139,7 @@ shade_quad( /* store result color */ memcpy( quad->outputs.color, - &machine.Outputs[1].xyzw[0].f[0], + &machine.Outputs[TGSI_ATTRIB_COLOR0].xyzw[0].f[0], sizeof( quad->outputs.color ) ); #if 0 diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index af230111dc..5c119ec8cd 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -33,41 +33,43 @@ #include "sp_context.h" #include "sp_state.h" +#include "pipe/tgsi/core/tgsi_attribs.h" -#define EMIT_ATTR( VF_ATTR, FRAG_ATTR, INTERP ) \ + +#define EMIT_ATTR( ATTR, FRAG_ATTR, INTERP ) \ do { \ - slot_to_vf_attr[softpipe->nr_attrs] = VF_ATTR; \ - softpipe->vf_attr_to_slot[VF_ATTR] = softpipe->nr_attrs; \ + slot_to_vf_attr[softpipe->nr_attrs] = ATTR; \ + softpipe->vf_attr_to_slot[ATTR] = softpipe->nr_attrs; \ softpipe->fp_attr_to_slot[FRAG_ATTR] = softpipe->nr_attrs; \ softpipe->interp[softpipe->nr_attrs] = INTERP; \ softpipe->nr_attrs++; \ - attr_mask |= (1 << (VF_ATTR)); \ + attr_mask |= (1 << (ATTR)); \ } while (0) static const unsigned frag_to_vf[PIPE_ATTRIB_MAX] = { - VF_ATTRIB_POS, - VF_ATTRIB_COLOR0, - VF_ATTRIB_COLOR1, - VF_ATTRIB_FOG, - VF_ATTRIB_TEX0, - VF_ATTRIB_TEX1, - VF_ATTRIB_TEX2, - VF_ATTRIB_TEX3, - VF_ATTRIB_TEX4, - VF_ATTRIB_TEX5, - VF_ATTRIB_TEX6, - VF_ATTRIB_TEX7, - VF_ATTRIB_VAR0, - VF_ATTRIB_VAR1, - VF_ATTRIB_VAR2, - VF_ATTRIB_VAR3, - VF_ATTRIB_VAR4, - VF_ATTRIB_VAR5, - VF_ATTRIB_VAR6, - VF_ATTRIB_VAR7, + TGSI_ATTRIB_POS, + TGSI_ATTRIB_COLOR0, + TGSI_ATTRIB_COLOR1, + TGSI_ATTRIB_FOG, + TGSI_ATTRIB_TEX0, + TGSI_ATTRIB_TEX1, + TGSI_ATTRIB_TEX2, + TGSI_ATTRIB_TEX3, + TGSI_ATTRIB_TEX4, + TGSI_ATTRIB_TEX5, + TGSI_ATTRIB_TEX6, + TGSI_ATTRIB_TEX7, + TGSI_ATTRIB_VAR0, + TGSI_ATTRIB_VAR1, + TGSI_ATTRIB_VAR2, + TGSI_ATTRIB_VAR3, + TGSI_ATTRIB_VAR4, + TGSI_ATTRIB_VAR5, + TGSI_ATTRIB_VAR6, + TGSI_ATTRIB_VAR7, }; @@ -79,7 +81,7 @@ static const unsigned frag_to_vf[PIPE_ATTRIB_MAX] = static void calculate_vertex_layout( struct softpipe_context *softpipe ) { const unsigned inputsRead = softpipe->fs.inputs_read; - unsigned slot_to_vf_attr[VF_ATTRIB_MAX]; + unsigned slot_to_vf_attr[TGSI_ATTRIB_MAX]; unsigned attr_mask = 0x0; unsigned i; @@ -87,7 +89,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) * fragment position (XYZW). */ if (softpipe->depth_test.enabled || - (inputsRead & (1 << FRAG_ATTRIB_WPOS))) + (inputsRead & (1 << TGSI_ATTRIB_POS))) softpipe->need_z = TRUE; else softpipe->need_z = FALSE; @@ -95,7 +97,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) /* Need W if we do any perspective-corrected interpolation or the * fragment program uses the fragment position. */ - if (inputsRead & (1 << FRAG_ATTRIB_WPOS)) + if (inputsRead & (1 << TGSI_ATTRIB_POS)) softpipe->need_w = TRUE; else softpipe->need_w = FALSE; @@ -109,24 +111,24 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) /* TODO - Figure out if we need to do perspective divide, etc. */ - EMIT_ATTR(VF_ATTRIB_POS, FRAG_ATTRIB_WPOS, INTERP_LINEAR); + EMIT_ATTR(TGSI_ATTRIB_POS, TGSI_ATTRIB_POS, INTERP_LINEAR); /* Pull in the rest of the attributes. They are all in float4 * format. Future optimizations could be to keep some attributes * as fixed point or ubyte format. */ - for (i = 1; i < FRAG_ATTRIB_TEX0; i++) { + for (i = 1; i < TGSI_ATTRIB_TEX0; i++) { if (inputsRead & (1 << i)) { assert(i < sizeof(frag_to_vf) / sizeof(frag_to_vf[0])); if (softpipe->setup.flatshade - && (i == FRAG_ATTRIB_COL0 || i == FRAG_ATTRIB_COL1)) + && (i == TGSI_ATTRIB_COLOR0 || i == TGSI_ATTRIB_COLOR1)) EMIT_ATTR(frag_to_vf[i], i, INTERP_CONSTANT); else EMIT_ATTR(frag_to_vf[i], i, INTERP_LINEAR); } } - for (i = FRAG_ATTRIB_TEX0; i < FRAG_ATTRIB_MAX; i++) { + for (i = TGSI_ATTRIB_TEX0; i < TGSI_ATTRIB_MAX; i++) { if (inputsRead & (1 << i)) { assert(i < sizeof(frag_to_vf) / sizeof(frag_to_vf[0])); EMIT_ATTR(frag_to_vf[i], i, INTERP_PERSPECTIVE); @@ -141,12 +143,12 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) * the vertex header. */ if (softpipe->setup.light_twoside) { - if (inputsRead & FRAG_BIT_COL0) { - EMIT_ATTR(VF_ATTRIB_BFC0, FRAG_ATTRIB_MAX, 0); /* XXX: mark as discarded after setup */ + if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { + EMIT_ATTR(TGSI_ATTRIB_BFC0, TGSI_ATTRIB_MAX, 0); /* XXX: mark as discarded after setup */ } - if (inputsRead & FRAG_BIT_COL1) { - EMIT_ATTR(VF_ATTRIB_BFC1, FRAG_ATTRIB_MAX, 0); /* XXX: discard after setup */ + if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) { + EMIT_ATTR(TGSI_ATTRIB_BFC1, TGSI_ATTRIB_MAX, 0); /* XXX: discard after setup */ } } diff --git a/src/mesa/pipe/tgsi/core/tgsi_token.h b/src/mesa/pipe/tgsi/core/tgsi_token.h index a12a2d7370..ca53071a60 100644 --- a/src/mesa/pipe/tgsi/core/tgsi_token.h +++ b/src/mesa/pipe/tgsi/core/tgsi_token.h @@ -1478,47 +1478,6 @@ struct tgsi_dst_register_ext_predicate }; -/** - * The specific values here are not important. - */ -enum { - TGSI_ATTRIB_POS = 0, - TGSI_ATTRIB_WEIGHT = 1, - TGSI_ATTRIB_NORMAL = 2, - TGSI_ATTRIB_COLOR0 = 3, - TGSI_ATTRIB_COLOR1 = 4, - TGSI_ATTRIB_FOG = 5, - TGSI_ATTRIB_COLOR_INDEX = 6, /* XXX omit? */ - TGSI_ATTRIB_EDGEFLAG = 7, - TGSI_ATTRIB_TEX0 = 8, - TGSI_ATTRIB_TEX1 = 9, - TGSI_ATTRIB_TEX2 = 10, - TGSI_ATTRIB_TEX3 = 11, - TGSI_ATTRIB_TEX4 = 12, - TGSI_ATTRIB_TEX5 = 13, - TGSI_ATTRIB_TEX6 = 14, - TGSI_ATTRIB_TEX7 = 15, - TGSI_ATTRIB_VAR0 = 16, - TGSI_ATTRIB_VAR1 = 17, - TGSI_ATTRIB_VAR2 = 18, - TGSI_ATTRIB_VAR3 = 19, - TGSI_ATTRIB_VAR4 = 20, - TGSI_ATTRIB_VAR5 = 21, - TGSI_ATTRIB_VAR6 = 22, - TGSI_ATTRIB_VAR7 = 23, - TGSI_ATTRIB_POINTSIZE = 24, - TGSI_ATTRIB_BFC0 = 25, - TGSI_ATTRIB_BFC1 = 26, - TGSI_ATTRIB_CLIP_POS = 27, - TGSI_ATTRIB_VERTEX_HEADER = 28, - TGSI_ATTRIB_MAX = 29 -}; - - -#define TGSI_MAX_TEXTURE 8 -#define TGSI_MAX_VARYING 8 - - #if defined __cplusplus } // extern "C" #endif // defined __cplusplus diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index dfb263ebdc..993d220c50 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -1,5 +1,7 @@ #include "tgsi_platform.h"
#include "tgsi_mesa.h"
+#include "pipe/tgsi/core/tgsi_attribs.h"
+#include "pipe/tgsi/mesa/mesa_to_tgsi.h"
#define TGSI_DEBUG 1
@@ -7,8 +9,8 @@ /**
* Convert a VERT_ATTRIB_x to a TGSI_ATTRIB_y
*/
-static GLuint
-translate_vertex_input(GLuint attrib)
+uint
+tgsi_mesa_translate_vertex_input(GLuint attrib)
{
/* XXX these could be implemented with array lookups too.... */
switch (attrib) {
@@ -70,8 +72,8 @@ translate_vertex_input(GLuint attrib) /**
* Convert VERT_RESULT_x to TGSI_ATTRIB_y
*/
-static GLuint
-translate_vertex_ouput(GLuint attrib)
+uint
+tgsi_mesa_translate_vertex_output(GLuint attrib)
{
switch (attrib) {
case VERT_RESULT_HPOS:
@@ -130,8 +132,8 @@ translate_vertex_ouput(GLuint attrib) /**
* Convert a FRAG_ATTRIB_x to a TGSI_ATTRIB_y
*/
-static GLuint
-translate_fragment_input(GLuint attrib)
+uint
+tgsi_mesa_translate_fragment_input(GLuint attrib)
{
switch (attrib) {
case FRAG_ATTRIB_WPOS:
@@ -184,8 +186,8 @@ translate_fragment_input(GLuint attrib) /**
* Convert FRAG_RESULT_x to TGSI_ATTRIB_y
*/
-static GLuint
-translate_fragment_output(GLuint attrib)
+uint
+tgsi_mesa_translate_fragment_output(GLuint attrib)
{
switch (attrib) {
case FRAG_RESULT_DEPR:
@@ -209,6 +211,68 @@ translate_fragment_output(GLuint attrib) }
+uint
+tgsi_mesa_translate_vertex_input_mask(GLbitfield mask)
+{
+ uint tgsiMask = 0x0;
+ uint i;
+ for (i = 0; i < VERT_ATTRIB_MAX && mask; i++) {
+ if (mask & (1 << i)) {
+ tgsiMask |= 1 << tgsi_mesa_translate_vertex_input(i);
+ }
+ mask &= ~(1 << i);
+ }
+ return tgsiMask;
+}
+
+
+uint
+tgsi_mesa_translate_vertex_output_mask(GLbitfield mask)
+{
+ uint tgsiMask = 0x0;
+ uint i;
+ for (i = 0; i < VERT_RESULT_MAX && mask; i++) {
+ if (mask & (1 << i)) {
+ tgsiMask |= 1 << tgsi_mesa_translate_vertex_output(i);
+ }
+ mask &= ~(1 << i);
+ }
+ return tgsiMask;
+}
+
+uint
+tgsi_mesa_translate_fragment_input_mask(GLbitfield mask)
+{
+ uint tgsiMask = 0x0;
+ uint i;
+ for (i = 0; i < FRAG_ATTRIB_MAX && mask; i++) {
+ if (mask & (1 << i)) {
+ tgsiMask |= 1 << tgsi_mesa_translate_fragment_input(i);
+ }
+ mask &= ~(1 << i);
+ }
+ return tgsiMask;
+}
+
+
+uint
+tgsi_mesa_translate_fragment_output_mask(GLbitfield mask)
+{
+ uint tgsiMask = 0x0;
+ uint i;
+ for (i = 0; i < FRAG_RESULT_MAX && mask; i++) {
+ if (mask & (1 << i)) {
+ tgsiMask |= 1 << tgsi_mesa_translate_fragment_output(i);
+ }
+ mask &= ~(1 << i);
+ }
+ return tgsiMask;
+}
+
+
+
+
+
/*
* Map mesa register file to TGSI register file.
@@ -290,11 +354,11 @@ map_register_file_index( * color results -> index 1, 2, ...
*/
if( index == FRAG_RESULT_DEPR ) {
- mapped_index = 0;
+ mapped_index = TGSI_ATTRIB_POS;
}
else {
assert( index == FRAG_RESULT_COLR );
- mapped_index = index + 1;
+ mapped_index = TGSI_ATTRIB_COLOR0;
}
}
else {
diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h index 9256318997..fda3fa397f 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h @@ -19,6 +19,31 @@ tgsi_mesa_compile_vp_program( struct tgsi_token *tokens,
GLuint maxTokens );
+uint
+tgsi_mesa_translate_vertex_input(GLuint attrib);
+
+uint
+tgsi_mesa_translate_vertex_output(GLuint attrib);
+
+uint
+tgsi_mesa_translate_fragment_input(GLuint attrib);
+
+uint
+tgsi_mesa_translate_fragment_output(GLuint attrib);
+
+uint
+tgsi_mesa_translate_vertex_input_mask(GLbitfield mask);
+
+uint
+tgsi_mesa_translate_vertex_output_mask(GLbitfield mask);
+
+uint
+tgsi_mesa_translate_fragment_input_mask(GLbitfield mask);
+
+uint
+tgsi_mesa_translate_fragment_output_mask(GLbitfield mask);
+
+
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index 019b6457e0..a34a227ac0 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -110,8 +110,10 @@ static void update_fs( struct st_context *st ) /* update pipe state */ memset( &fs, 0, sizeof(fs) ); - fs.inputs_read = fp->Base.Base.InputsRead; - fs.outputs_written = fp->Base.Base.OutputsWritten; + fs.inputs_read + = tgsi_mesa_translate_fragment_input_mask(fp->Base.Base.InputsRead); + fs.outputs_written + = tgsi_mesa_translate_fragment_output_mask(fp->Base.Base.OutputsWritten); fs.tokens = &fp->tokens[0]; if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0 || diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index e3690deb5a..69b985e405 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -348,7 +348,8 @@ clear_with_quad(GLcontext *ctx, stfp = make_color_shader(st); } memset(&fs, 0, sizeof(fs)); - fs.inputs_read = stfp->Base.Base.InputsRead; + fs.inputs_read = tgsi_mesa_translate_fragment_input_mask(stfp->Base.Base.InputsRead); + fs.outputs_written = tgsi_mesa_translate_fragment_output_mask(stfp->Base.Base.OutputsWritten); fs.tokens = &stfp->tokens[0]; pipe->set_fs_state(pipe, &fs); } |