tgsi/scan: count memory instructions
authorMarek Olšák <marek.olsak@amd.com>
Sun, 21 Feb 2016 23:23:10 +0000 (00:23 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 29 Feb 2016 23:11:32 +0000 (00:11 +0100)
for radeonsi

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h

index 4f85d2fda6794255c6d1c30d2bb9e63b2dd7c024..8e24cc626bda77f8ae1ea56cf4132116ae930cdd 100644 (file)
 #include "tgsi/tgsi_scan.h"
 
 
+static bool
+is_memory_file(unsigned file)
+{
+   return file == TGSI_FILE_SAMPLER ||
+          file == TGSI_FILE_SAMPLER_VIEW ||
+          file == TGSI_FILE_IMAGE ||
+          file == TGSI_FILE_BUFFER;
+}
+
 
 static void
 scan_instruction(struct tgsi_shader_info *info,
@@ -50,6 +59,7 @@ scan_instruction(struct tgsi_shader_info *info,
                  unsigned *current_depth)
 {
    unsigned i;
+   bool is_mem_inst = false;
 
    assert(fullinst->Instruction.Opcode < TGSI_OPCODE_LAST);
    info->opcode_count[fullinst->Instruction.Opcode]++;
@@ -181,6 +191,9 @@ scan_instruction(struct tgsi_shader_info *info,
             info->is_msaa_sampler[src->Register.Index] = TRUE;
          }
       }
+
+      if (is_memory_file(src->Register.File))
+         is_mem_inst = true;
    }
 
    /* check for indirect register writes */
@@ -190,8 +203,14 @@ scan_instruction(struct tgsi_shader_info *info,
          info->indirect_files |= (1 << dst->Register.File);
          info->indirect_files_written |= (1 << dst->Register.File);
       }
+
+      if (is_memory_file(dst->Register.File))
+         is_mem_inst = true;
    }
 
+   if (is_mem_inst)
+      info->num_memory_instructions++;
+
    info->num_instructions++;
 }
      
index 0541255764c0cd7d2587d1f2dc409771f8b1bf4d..d65dec71888ade525eda3e76ec91df8d939cbb11 100644 (file)
@@ -74,6 +74,7 @@ struct tgsi_shader_info
 
    uint immediate_count; /**< number of immediates declared */
    uint num_instructions;
+   uint num_memory_instructions; /**< sampler, buffer, and image instructions */
 
    uint opcode_count[TGSI_OPCODE_LAST];  /**< opcode histogram */