nir: Make nir_gather_info collect a uses_fddx_fddy flag.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 26 Oct 2017 22:19:25 +0000 (15:19 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 30 Oct 2017 03:52:20 +0000 (20:52 -0700)
i965 turns fddx/fddy into their coarse/fine variants based on the
ctx->Hint.FragmentShaderDerivative setting.  It needs to know whether
this can impact a shader in order to better guess NOS settings.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_gather_info.c
src/compiler/shader_info.h

index 7ae3ecc4425214058cdb95ccc130006e8d8b5dd0..13cdae39eca41454c53d2122675436f1dc6155f9 100644 (file)
@@ -280,11 +280,27 @@ gather_tex_info(nir_tex_instr *instr, nir_shader *shader)
    }
 }
 
+static void
+gather_alu_info(nir_alu_instr *instr, nir_shader *shader)
+{
+   switch (instr->op) {
+   case nir_op_fddx:
+   case nir_op_fddy:
+      shader->info.uses_fddx_fddy = true;
+      break;
+   default:
+      break;
+   }
+}
+
 static void
 gather_info_block(nir_block *block, nir_shader *shader)
 {
    nir_foreach_instr(instr, block) {
       switch (instr->type) {
+      case nir_instr_type_alu:
+         gather_alu_info(nir_instr_as_alu(instr), shader);
+         break;
       case nir_instr_type_intrinsic:
          gather_intrinsic_info(nir_instr_as_intrinsic(instr), shader);
          break;
index cd044d8609460fcb965d4c805a404b05a93f73ed..5f14ad19df7d8d745fd943a05390a7ddd811915c 100644 (file)
@@ -73,6 +73,13 @@ typedef struct shader_info {
    /** Bitfield of which textures are used by texelFetch() */
    uint32_t textures_used_by_txf;
 
+   /**
+    * True if this shader uses the fddx/fddy opcodes.
+    *
+    * Note that this does not include the "fine" and "coarse" variants.
+    */
+   bool uses_fddx_fddy;
+
    /* The size of the gl_ClipDistance[] array, if declared. */
    unsigned clip_distance_array_size;