summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/tgsi/tgsi_scan.c
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-06-01 16:27:36 +0100
committerJosé Fonseca <jfonseca@vmware.com>2010-06-01 16:39:03 +0100
commitabe4f3d1aa68aec70d329447abc890b3eaaba9cb (patch)
tree6dd3c252a7abea638458494bba6417e7d8fe512a /src/gallium/auxiliary/tgsi/tgsi_scan.c
parentd9c6ebb4fec0059734d94767ea7fe99c848693a5 (diff)
tgsi: Determine which shader input channels are effectively.
TGSI's UsageMask flag is never set. We can move this logic into tgsi_ureg, but there there are still cases where's not used, so this seems a better place for now.
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_scan.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_scan.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index e0c5d3d3d6..7ee272b949 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -36,6 +36,7 @@
#include "util/u_math.h"
#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_util.h"
#include "tgsi/tgsi_scan.h"
@@ -84,19 +85,21 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
{
const struct tgsi_full_instruction *fullinst
= &parse.FullToken.FullInstruction;
+ uint i;
assert(fullinst->Instruction.Opcode < TGSI_OPCODE_LAST);
info->opcode_count[fullinst->Instruction.Opcode]++;
- /* check if we read the frag shader FOG or FACE inputs */
- if (procType == TGSI_PROCESSOR_FRAGMENT) {
- uint i;
- for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
- const struct tgsi_full_src_register *src =
- &fullinst->Src[i];
+ for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
+ const struct tgsi_full_src_register *src =
+ &fullinst->Src[i];
+ int ind = src->Register.Index;
+
+ /* check if we read the frag shader FOG or FACE inputs */
+ if (procType == TGSI_PROCESSOR_FRAGMENT) {
if (src->Register.File == TGSI_FILE_INPUT ||
src->Register.File == TGSI_FILE_SYSTEM_VALUE) {
- const int ind = src->Register.Index;
+ assert(ind >= 0);
if (info->input_semantic_name[ind] == TGSI_SEMANTIC_FOG) {
info->uses_fogcoord = TRUE;
}
@@ -105,6 +108,21 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
}
}
}
+
+ /* Mark which inputs are effectively used */
+ if (src->Register.File == TGSI_FILE_INPUT) {
+ unsigned usage_mask;
+ usage_mask = tgsi_util_get_inst_usage_mask(fullinst, i);
+ if (src->Register.Indirect) {
+ for (ind = 0; ind < info->num_inputs; ++ind) {
+ info->input_usage_mask[ind] |= usage_mask;
+ }
+ } else {
+ assert(ind >= 0);
+ assert(ind < PIPE_MAX_SHADER_INPUTS);
+ info->input_usage_mask[ind] |= usage_mask;
+ }
+ }
}
info->num_instructions++;