tgsi: clean up tgsi_scan_shader() function

Replace "fulldecl->Semantic.Name/Index" with semName/semIndex.
Simplify if/else logic for TGSI_FILE_OUTPUT code.
Remove old comment.
Fix indentation.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
This commit is contained in:
Brian Paul 2013-08-05 08:19:36 -06:00
parent 95829e2029
commit 3e4b5c6c9c

View file

@ -152,6 +152,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
for (reg = fulldecl->Range.First;
reg <= fulldecl->Range.Last;
reg++) {
unsigned semName = fulldecl->Semantic.Name;
unsigned semIndex = fulldecl->Semantic.Index;
/* only first 32 regs will appear in this bitfield */
info->file_mask[file] |= (1 << reg);
@ -159,82 +161,81 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
info->file_max[file] = MAX2(info->file_max[file], (int)reg);
if (file == TGSI_FILE_INPUT) {
info->input_semantic_name[reg] = (ubyte)fulldecl->Semantic.Name;
info->input_semantic_index[reg] = (ubyte)fulldecl->Semantic.Index;
info->input_semantic_name[reg] = (ubyte) semName;
info->input_semantic_index[reg] = (ubyte) semIndex;
info->input_interpolate[reg] = (ubyte)fulldecl->Interp.Interpolate;
info->input_centroid[reg] = (ubyte)fulldecl->Interp.Centroid;
info->input_cylindrical_wrap[reg] = (ubyte)fulldecl->Interp.CylindricalWrap;
info->num_inputs++;
if (procType == TGSI_PROCESSOR_FRAGMENT) {
if (fulldecl->Semantic.Name == TGSI_SEMANTIC_POSITION)
if (semName == TGSI_SEMANTIC_POSITION)
info->reads_position = TRUE;
else if (fulldecl->Semantic.Name == TGSI_SEMANTIC_PRIMID)
else if (semName == TGSI_SEMANTIC_PRIMID)
info->uses_primid = TRUE;
else if (fulldecl->Semantic.Name == TGSI_SEMANTIC_FACE)
else if (semName == TGSI_SEMANTIC_FACE)
info->uses_frontface = TRUE;
}
}
else if (file == TGSI_FILE_SYSTEM_VALUE) {
unsigned index = fulldecl->Range.First;
unsigned semName = fulldecl->Semantic.Name;
info->system_value_semantic_name[index] = semName;
info->num_system_values = MAX2(info->num_system_values,
index + 1);
/*
info->system_value_semantic_name[info->num_system_values++] =
fulldecl->Semantic.Name;
*/
if (fulldecl->Semantic.Name == TGSI_SEMANTIC_INSTANCEID) {
if (semName == TGSI_SEMANTIC_INSTANCEID) {
info->uses_instanceid = TRUE;
}
else if (fulldecl->Semantic.Name == TGSI_SEMANTIC_VERTEXID) {
else if (semName == TGSI_SEMANTIC_VERTEXID) {
info->uses_vertexid = TRUE;
} else if (fulldecl->Semantic.Name == TGSI_SEMANTIC_PRIMID) {
}
else if (semName == TGSI_SEMANTIC_PRIMID) {
info->uses_primid = TRUE;
}
}
else if (file == TGSI_FILE_OUTPUT) {
info->output_semantic_name[reg] = (ubyte)fulldecl->Semantic.Name;
info->output_semantic_index[reg] = (ubyte)fulldecl->Semantic.Index;
info->output_semantic_name[reg] = (ubyte) semName;
info->output_semantic_index[reg] = (ubyte) semIndex;
info->num_outputs++;
if ((procType == TGSI_PROCESSOR_VERTEX || procType == TGSI_PROCESSOR_GEOMETRY) &&
fulldecl->Semantic.Name == TGSI_SEMANTIC_CLIPDIST) {
info->num_written_clipdistance += util_bitcount(fulldecl->Declaration.UsageMask);
}
if ((procType == TGSI_PROCESSOR_VERTEX || procType == TGSI_PROCESSOR_GEOMETRY) &&
fulldecl->Semantic.Name == TGSI_SEMANTIC_CULLDIST) {
info->num_written_culldistance += util_bitcount(fulldecl->Declaration.UsageMask);
}
/* extra info for special outputs */
if (procType == TGSI_PROCESSOR_FRAGMENT &&
fulldecl->Semantic.Name == TGSI_SEMANTIC_POSITION)
info->writes_z = TRUE;
if (procType == TGSI_PROCESSOR_FRAGMENT &&
fulldecl->Semantic.Name == TGSI_SEMANTIC_STENCIL)
info->writes_stencil = TRUE;
if (procType == TGSI_PROCESSOR_VERTEX &&
fulldecl->Semantic.Name == TGSI_SEMANTIC_EDGEFLAG) {
info->writes_edgeflag = TRUE;
if (procType == TGSI_PROCESSOR_VERTEX ||
procType == TGSI_PROCESSOR_GEOMETRY) {
if (semName == TGSI_SEMANTIC_CLIPDIST) {
info->num_written_clipdistance +=
util_bitcount(fulldecl->Declaration.UsageMask);
}
else if (semName == TGSI_SEMANTIC_CULLDIST) {
info->num_written_culldistance +=
util_bitcount(fulldecl->Declaration.UsageMask);
}
}
if (procType == TGSI_PROCESSOR_GEOMETRY &&
fulldecl->Semantic.Name ==
TGSI_SEMANTIC_VIEWPORT_INDEX) {
info->writes_viewport_index = TRUE;
if (procType == TGSI_PROCESSOR_FRAGMENT) {
if (semName == TGSI_SEMANTIC_POSITION) {
info->writes_z = TRUE;
}
else if (semName == TGSI_SEMANTIC_STENCIL) {
info->writes_stencil = TRUE;
}
}
if (procType == TGSI_PROCESSOR_GEOMETRY &&
fulldecl->Semantic.Name ==
TGSI_SEMANTIC_LAYER) {
info->writes_layer = TRUE;
if (procType == TGSI_PROCESSOR_VERTEX) {
if (semName == TGSI_SEMANTIC_EDGEFLAG) {
info->writes_edgeflag = TRUE;
}
}
if (procType == TGSI_PROCESSOR_GEOMETRY) {
if (semName == TGSI_SEMANTIC_VIEWPORT_INDEX) {
info->writes_viewport_index = TRUE;
}
else if (semName == TGSI_SEMANTIC_LAYER) {
info->writes_layer = TRUE;
}
}
}
}
}
}
break;