tgsi/scan: add uses_derivatives (v2)
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 1 Jun 2016 11:17:29 +0000 (13:17 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 7 Jun 2016 21:45:17 +0000 (23:45 +0200)
v2:
- TG4 does not calculate derivatives (Ilia)
- also handle SAMPLE* instructions (Roland)

Cc: 12.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
Reviewed-by: Brian Paul <brianp@vmware.com> (v1)
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h

index 1baf031d73e42ffd133a2e67e2ec86dfa86c3249..98d86fc37a6e77f4efcb11af82fe344da156651e 100644 (file)
@@ -68,6 +68,33 @@ is_texture_inst(unsigned opcode)
            tgsi_get_opcode_info(opcode)->is_tex);
 }
 
+
+/**
+ * Is the opcode an instruction which computes a derivative explicitly or
+ * implicitly?
+ */
+static bool
+computes_derivative(unsigned opcode)
+{
+   if (tgsi_get_opcode_info(opcode)->is_tex) {
+      return opcode != TGSI_OPCODE_TG4 &&
+             opcode != TGSI_OPCODE_TXD &&
+             opcode != TGSI_OPCODE_TXF &&
+             opcode != TGSI_OPCODE_TXL &&
+             opcode != TGSI_OPCODE_TXL2 &&
+             opcode != TGSI_OPCODE_TXQ &&
+             opcode != TGSI_OPCODE_TXQ_LZ &&
+             opcode != TGSI_OPCODE_TXQS;
+   }
+
+   return opcode == TGSI_OPCODE_DDX || opcode == TGSI_OPCODE_DDX_FINE ||
+          opcode == TGSI_OPCODE_DDY || opcode == TGSI_OPCODE_DDY_FINE ||
+          opcode == TGSI_OPCODE_SAMPLE ||
+          opcode == TGSI_OPCODE_SAMPLE_B ||
+          opcode == TGSI_OPCODE_SAMPLE_C;
+}
+
+
 static void
 scan_instruction(struct tgsi_shader_info *info,
                  const struct tgsi_full_instruction *fullinst,
@@ -263,6 +290,9 @@ scan_instruction(struct tgsi_shader_info *info,
    if (is_mem_inst)
       info->num_memory_instructions++;
 
+   if (computes_derivative(fullinst->Instruction.Opcode))
+      info->uses_derivatives = true;
+
    info->num_instructions++;
 }
      
index 31adce7a6031fc858ef1b0c9ea6f45703d08dab4..f7eefa4d186b2920b8e3fa0e8535ab53e2a9ffb4 100644 (file)
@@ -115,6 +115,7 @@ struct tgsi_shader_info
    boolean writes_memory; /**< contains stores or atomics to buffers or images */
    boolean is_msaa_sampler[PIPE_MAX_SAMPLERS];
    boolean uses_doubles; /**< uses any of the double instructions */
+   boolean uses_derivatives;
    unsigned clipdist_writemask;
    unsigned culldist_writemask;
    unsigned num_written_culldistance;