r300g: clean up vs/fs tabs

Instead of vs_tab, we use vs_output_tab and it's local now. fs_tab hasn't
been used anywhere, so I removed it and r300_update_fs_tab too.
This commit is contained in:
Marek Olšák 2009-11-21 05:51:13 +01:00 committed by Corbin Simpson
parent 435c495549
commit 3a2cd66af8
2 changed files with 25 additions and 94 deletions

View file

@ -223,11 +223,6 @@ struct r300_texture {
struct r300_vertex_info {
/* Parent class */
struct vertex_info vinfo;
/* Map of vertex attributes into PVS memory for HW TCL,
* or GA memory for SW TCL. */
int vs_tab[16];
/* Map of rasterizer attributes from GB through RS to US. */
int fs_tab[16];
/* R300_VAP_PROG_STREAK_CNTL_[0-7] */
uint32_t vap_prog_stream_cntl[8];

View file

@ -61,12 +61,12 @@ int r300_shader_key_compare(void* key1, void* key2) {
(shader_key1->fs == shader_key2->fs);
}
/* Set up the vs_tab and routes. */
static void r300_vs_tab_routes(struct r300_context* r300,
struct r300_vertex_info* vformat)
/* Set up the vs_output_tab and routes. */
static void r300_vs_output_tab_routes(struct r300_context* r300,
struct r300_vertex_info* vformat,
int* vs_output_tab)
{
struct vertex_info* vinfo = &vformat->vinfo;
int* tab = vformat->vs_tab;
boolean pos = FALSE, psize = FALSE, fog = FALSE;
int i, texs = 0, cols = 0;
struct tgsi_shader_info* info = &r300->fs->info;
@ -79,23 +79,23 @@ static void r300_vs_tab_routes(struct r300_context* r300,
switch (info->input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
pos = TRUE;
tab[i] = 0;
vs_output_tab[i] = 0;
break;
case TGSI_SEMANTIC_COLOR:
tab[i] = 2 + cols;
vs_output_tab[i] = 2 + cols;
cols++;
break;
case TGSI_SEMANTIC_PSIZE:
assert(psize == FALSE);
psize = TRUE;
tab[i] = 15;
vs_output_tab[i] = 15;
break;
case TGSI_SEMANTIC_FOG:
assert(fog == FALSE);
fog = TRUE;
/* Fall through */
case TGSI_SEMANTIC_GENERIC:
tab[i] = 6 + texs;
vs_output_tab[i] = 6 + texs;
texs++;
break;
default:
@ -122,11 +122,11 @@ static void r300_vs_tab_routes(struct r300_context* r300,
* for HW TCL case it could be generated by vertex shader */
if (!pos) {
/* Make room for the position attribute
* at the beginning of the tab. */
* at the beginning of the vs_output_tab. */
for (i = 15; i > 0; i--) {
tab[i] = tab[i-1];
vs_output_tab[i] = vs_output_tab[i-1];
}
tab[0] = 0;
vs_output_tab[0] = 0;
}
/* Position. */
@ -229,34 +229,34 @@ static void r300_vertex_psc(struct r300_context* r300,
/* Update the PSC tables for SW TCL, using Draw. */
static void r300_swtcl_vertex_psc(struct r300_context* r300,
struct r300_vertex_info* vformat)
struct r300_vertex_info* vformat,
int* vs_output_tab)
{
struct vertex_info* vinfo = &vformat->vinfo;
int* tab = vformat->vs_tab;
uint16_t type, swizzle;
enum pipe_format format;
unsigned i, attrib_count;
/* For each Draw attribute, route it to the fragment shader according
* to the tab. */
* to the vs_output_tab. */
attrib_count = vinfo->num_attribs;
DBG(r300, DBG_DRAW, "r300: attrib count: %d\n", attrib_count);
for (i = 0; i < attrib_count; i++) {
DBG(r300, DBG_DRAW, "r300: attrib: offset %d, interp %d, size %d,"
" tab %d\n", vinfo->attrib[i].src_index,
" vs_output_tab %d\n", vinfo->attrib[i].src_index,
vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit,
tab[i]);
vs_output_tab[i]);
}
for (i = 0; i < attrib_count; i++) {
/* Make sure we have a proper destination for our attribute. */
assert(tab[i] != -1);
assert(vs_output_tab[i] != -1);
format = draw_translate_vinfo_format(vinfo->attrib[i].emit);
/* Obtain the type of data in this attribute. */
type = r300_translate_vertex_data_type(format) |
tab[i] << R300_DST_VEC_LOC_SHIFT;
vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT;
/* Obtain the swizzle for this attribute. Note that the default
* swizzle in the hardware is not XYZW! */
@ -280,68 +280,6 @@ static void r300_swtcl_vertex_psc(struct r300_context* r300,
(R300_LAST_VEC << (i & 1 ? 16 : 0));
}
/* Set up the mappings from GB to US, for RS block. */
static void r300_update_fs_tab(struct r300_context* r300,
struct r300_vertex_info* vformat)
{
struct tgsi_shader_info* info = &r300->fs->info;
int i, cols = 0, texs = 0, cols_emitted = 0;
int* tab = vformat->fs_tab;
for (i = 0; i < 16; i++) {
tab[i] = -1;
}
assert(info->num_inputs <= 16);
for (i = 0; i < info->num_inputs; i++) {
switch (info->input_semantic_name[i]) {
case TGSI_SEMANTIC_COLOR:
tab[i] = INTERP_LINEAR;
cols++;
break;
case TGSI_SEMANTIC_POSITION:
case TGSI_SEMANTIC_PSIZE:
debug_printf("r300: Implementation error: Can't use "
"pos attribs in fragshader yet!\n");
/* Pass through for now */
case TGSI_SEMANTIC_FOG:
case TGSI_SEMANTIC_GENERIC:
tab[i] = INTERP_PERSPECTIVE;
break;
default:
debug_printf("r300: Unknown vertex input %d\n",
info->input_semantic_name[i]);
break;
}
}
/* Now that we know where everything is... */
DBG(r300, DBG_DRAW, "r300: fp input count: %d\n", info->num_inputs);
for (i = 0; i < info->num_inputs; i++) {
switch (tab[i]) {
case INTERP_LINEAR:
DBG(r300, DBG_DRAW, "r300: attrib: "
"stack offset %d, color, tab %d\n",
i, cols_emitted);
tab[i] = cols_emitted;
cols_emitted++;
break;
case INTERP_PERSPECTIVE:
DBG(r300, DBG_DRAW, "r300: attrib: "
"stack offset %d, texcoord, tab %d\n",
i, cols + texs);
tab[i] = cols + texs;
texs++;
break;
case -1:
debug_printf("r300: Implementation error: Bad fp interp!\n");
default:
break;
}
}
}
/* Set up the RS block. This is the part of the chipset that actually does
* the rasterization of vertices into fragments. This is also the part of the
* chipset that locks up if any part of it is even slightly wrong. */
@ -456,8 +394,13 @@ static void r300_update_derived_shader_state(struct r300_context* r300)
struct r300_screen* r300screen = r300_screen(r300->context.screen);
struct r300_vertex_info* vformat;
struct r300_rs_block* rs_block;
int vs_output_tab[16];
int i;
for (i = 0; i < 16; i++) {
vs_output_tab[i] = -1;
}
/*
struct r300_shader_key* key;
struct r300_shader_derived_value* value;
@ -488,21 +431,14 @@ static void r300_update_derived_shader_state(struct r300_context* r300)
vformat = CALLOC_STRUCT(r300_vertex_info);
rs_block = CALLOC_STRUCT(r300_rs_block);
for (i = 0; i < 16; i++) {
vformat->vs_tab[i] = -1;
vformat->fs_tab[i] = -1;
}
r300_vs_tab_routes(r300, vformat);
r300_vs_output_tab_routes(r300, vformat, vs_output_tab);
if (r300screen->caps->has_tcl) {
r300_vertex_psc(r300, vformat);
} else {
r300_swtcl_vertex_psc(r300, vformat);
r300_swtcl_vertex_psc(r300, vformat, vs_output_tab);
}
r300_update_fs_tab(r300, vformat);
r300_update_rs_block(r300, rs_block);
FREE(r300->vertex_info);