[Mesa-dev] [PATCH 145/133] nir/variable: Remove the constant_value field

Jason Ekstrand jason at jlekstrand.net
Fri Dec 19 17:02:26 PST 2014


This was a left-over relic of GLSL IR that we aren't using for anything.
If we ever want that value again, we can add it back, but NIR constant
folding should be just as good as GLSL IR's if not better pretty soon, so
I'm not worried about it.
---
 src/glsl/nir/glsl_to_nir.cpp |  6 ++----
 src/glsl/nir/nir.h           | 14 ++------------
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index bed4741..39cc55b 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -343,7 +343,6 @@ nir_visitor::visit(ir_variable *ir)
       var->state_slots = NULL;
    }
 
-   var->constant_value = constant_copy(ir->constant_value, var);
    var->constant_initializer = constant_copy(ir->constant_initializer, var);
 
    var->interface_type = ir->get_interface_type();
@@ -1750,8 +1749,8 @@ nir_visitor::visit(ir_constant *ir)
 {
    /*
     * We don't know if this variable is an an array or struct that gets
-    * dereferenced, so do the safe thing an make it a variable and return a
-    * dereference.
+    * dereferenced, so do the safe thing an make it a variable with a
+    * constant initializer and return a dereference.
     */
 
    nir_variable *var = ralloc(this->shader, nir_variable);
@@ -1759,7 +1758,6 @@ nir_visitor::visit(ir_constant *ir)
    var->type = ir->type;
    var->data.mode = nir_var_local;
    var->data.read_only = true;
-   var->constant_value = constant_copy(ir, var);
    var->constant_initializer = constant_copy(ir, var);
    exec_list_push_tail(&this->impl->locals, &var->node);
 
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index f46c8b1..70831ad 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -200,8 +200,8 @@ typedef struct {
       /**
        * Was an initial binding explicitly set in the shader?
        *
-       * If so, constant_value contains an integer ir_constant representing the
-       * initial binding point.
+       * If so, constant_initializer contains an integer nir_constant
+       * representing the initial binding point.
        */
       unsigned explicit_binding:1;
 
@@ -343,17 +343,7 @@ typedef struct {
    /*@}*/
 
    /**
-    * Value assigned in the initializer of a variable declared "const"
-    */
-   nir_constant *constant_value;
-
-   /**
     * Constant expression assigned in the initializer of the variable
-    *
-    * \warning
-    * This field and \c ::constant_value are distinct.  Even if the two fields
-    * refer to constants with the same value, they must point to separate
-    * objects.
     */
    nir_constant *constant_initializer;
 
-- 
2.2.0



More information about the mesa-dev mailing list