nir: Add a nir_tex_instr_has_implicit_derivatives helper
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 7 Jun 2019 22:58:15 +0000 (17:58 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Tue, 23 Jul 2019 18:40:41 +0000 (13:40 -0500)
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/nir/nir.h
src/compiler/nir/nir_opt_gcm.c

index c6c9e2b53473d16142724d7d61896e40e7135561..e224f03ea998c4b85607dcec288acf02e9aeb9b2 100644 (file)
@@ -1783,6 +1783,19 @@ nir_tex_instr_is_query(const nir_tex_instr *instr)
    }
 }
 
+static inline bool
+nir_tex_instr_has_implicit_derivative(const nir_tex_instr *instr)
+{
+   switch (instr->op) {
+   case nir_texop_tex:
+   case nir_texop_txb:
+   case nir_texop_lod:
+      return true;
+   default:
+      return false;
+   }
+}
+
 static inline nir_alu_type
 nir_tex_instr_src_type(const nir_tex_instr *instr, unsigned src)
 {
index aeae2ad6401074146cbc4c1285706e6cad657425..eb8b9ee65834ccc2d2ea1db86ae9482d6fd418ac 100644 (file)
@@ -133,18 +133,8 @@ gcm_pin_instructions_block(nir_block *block, struct gcm_state *state)
          break;
 
       case nir_instr_type_tex:
-         switch (nir_instr_as_tex(instr)->op) {
-         case nir_texop_tex:
-         case nir_texop_txb:
-         case nir_texop_lod:
-            /* These two take implicit derivatives so they need to be pinned */
+         if (nir_tex_instr_has_implicit_derivative(nir_instr_as_tex(instr)))
             instr->pass_flags = GCM_INSTR_PINNED;
-            break;
-
-         default:
-            instr->pass_flags = 0;
-            break;
-         }
          break;
 
       case nir_instr_type_load_const: