i965/fs: Return zero from fs_inst::components_read for non-present sources.
authorFrancisco Jerez <currojerez@riseup.net>
Sat, 13 Aug 2016 01:33:58 +0000 (18:33 -0700)
committerFrancisco Jerez <currojerez@riseup.net>
Tue, 16 Aug 2016 23:31:59 +0000 (16:31 -0700)
This makes it easier for the caller to find out how many scalar
components are actually read by the instruction.  As a bonus we no
longer need to special-case BAD_FILE in the implementation of
fs_inst::regs_read.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.cpp

index f23608966a0fc559ba5be3f3d252fd08b20d57b5..1842d56786d13edc18b65423e995cc93070e1243 100644 (file)
@@ -715,6 +715,10 @@ fs_inst::is_partial_write() const
 unsigned
 fs_inst::components_read(unsigned i) const
 {
+   /* Return zero if the source is not present. */
+   if (src[i].file == BAD_FILE)
+      return 0;
+
    switch (opcode) {
    case FS_OPCODE_LINTERP:
       if (i == 0)
@@ -895,11 +899,10 @@ fs_inst::regs_read(int arg) const
    }
 
    switch (src[arg].file) {
-   case BAD_FILE:
-      return 0;
    case UNIFORM:
    case IMM:
       return 1;
+   case BAD_FILE:
    case ARF:
    case FIXED_GRF:
    case VGRF: