Mesa (master): nir: add how_declared to nir_variable.data

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 13 14:30:36 UTC 2018


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

Author: Alejandro Piñeiro <apinheiro at igalia.com>
Date:   Tue May  8 08:58:59 2018 +0200

nir: add how_declared to nir_variable.data

Equivalent to the already existing how_declared at GLSL IR. The only
difference is that we are not adding all the declaration_type
available on GLSL, only the one that we will use on the short term. We
would add more mode if needed on the future.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/compiler/nir/nir.c                       |  1 +
 src/compiler/nir/nir.h                       | 24 ++++++++++++++++++++++++
 src/compiler/nir/nir_lower_wpos_ytransform.c |  2 +-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index a849664134..5e76654ca3 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -162,6 +162,7 @@ nir_variable_create(nir_shader *shader, nir_variable_mode mode,
    var->name = ralloc_strdup(var, name);
    var->type = type;
    var->data.mode = mode;
+   var->data.how_declared = nir_var_declared_normally;
 
    if ((mode == nir_var_shader_in &&
         shader->info.stage != MESA_SHADER_VERTEX) ||
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index bca6a32c95..1ccbccc8bb 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -163,6 +163,22 @@ typedef enum {
 } nir_depth_layout;
 
 /**
+ * Enum keeping track of how a variable was declared.
+ */
+typedef enum {
+   /**
+    * Normal declaration.
+    */
+   nir_var_declared_normally = 0,
+
+   /**
+    * Variable is implicitly generated by the compiler and should not be
+    * visible via the API.
+    */
+   nir_var_hidden,
+} nir_var_declaration_type;
+
+/**
  * Either a uniform, global variable, shader input, or shader output. Based on
  * ir_variable - it should be easy to translate between the two.
  */
@@ -350,6 +366,14 @@ typedef struct nir_variable {
       unsigned xfb_stride;
 
       /**
+       * How the variable was declared.  See nir_var_declaration_type.
+       *
+       * This is used to detect variables generated by the compiler, so should
+       * not be visible via the API.
+       */
+      unsigned how_declared:2;
+
+      /**
        * ARB_shader_image_load_store qualifiers.
        */
       struct {
diff --git a/src/compiler/nir/nir_lower_wpos_ytransform.c b/src/compiler/nir/nir_lower_wpos_ytransform.c
index fc61beb787..444e211b68 100644
--- a/src/compiler/nir/nir_lower_wpos_ytransform.c
+++ b/src/compiler/nir/nir_lower_wpos_ytransform.c
@@ -61,7 +61,7 @@ get_transform(lower_wpos_ytransform_state *state)
       var->state_slots[0].swizzle = SWIZZLE_XYZW;
       memcpy(var->state_slots[0].tokens, state->options->state_tokens,
              sizeof(var->state_slots[0].tokens));
-
+      var->data.how_declared = nir_var_hidden;
       state->transform = var;
    }
    return nir_load_var(&state->b, state->transform);




More information about the mesa-commit mailing list