Mesa (master): nir: Make nir_gather_info collect a uses_fddx_fddy flag.

Kenneth Graunke kwg at kemper.freedesktop.org
Mon Oct 30 03:59:17 UTC 2017


Module: Mesa
Branch: master
Commit: 86c68bb88618c5138a22bbbcfe6137d29f9f5f67
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=86c68bb88618c5138a22bbbcfe6137d29f9f5f67

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Thu Oct 26 15:19:25 2017 -0700

nir: Make nir_gather_info collect a uses_fddx_fddy flag.

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 at jlekstrand.net>

---

 src/compiler/nir/nir_gather_info.c | 16 ++++++++++++++++
 src/compiler/shader_info.h         |  7 +++++++
 2 files changed, 23 insertions(+)

diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index 7ae3ecc442..13cdae39ec 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -281,10 +281,26 @@ 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;
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index cd044d8609..5f14ad19df 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -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;
 




More information about the mesa-commit mailing list