nir: Allow var_mem_global in nir_lower_vars_to_explicit_types
[mesa.git] / src / compiler / glsl / lower_distance.cpp
index 9858503e028ab0136b841becd6c255deee748e10..b4e730c64fbd7280717d45c2ddba2fe9cb1802d5 100644 (file)
@@ -50,6 +50,7 @@
 #include "ir_rvalue_visitor.h"
 #include "ir.h"
 #include "program/prog_instruction.h" /* For WRITEMASK_* */
+#include "main/mtypes.h"
 
 #define GLSL_CLIP_VAR_NAME "gl_ClipDistanceMESA"
 
@@ -167,7 +168,6 @@ lower_distance_visitor::visit(ir_variable *ir)
       /* Clone the old var so that we inherit all of its properties */
       *new_var = ir->clone(ralloc_parent(ir), NULL);
       (*new_var)->name = ralloc_strdup(*new_var, GLSL_CLIP_VAR_NAME);
-      (*new_var)->data.max_array_access = new_size - 1;
       (*new_var)->data.location = VARYING_SLOT_CLIP_DIST0;
 
       if (!ir->type->fields.array->is_array()) {
@@ -182,6 +182,7 @@ lower_distance_visitor::visit(ir_variable *ir)
                   this->shader_stage == MESA_SHADER_GEOMETRY)));
 
          assert (ir->type->fields.array == glsl_type::float_type);
+         (*new_var)->data.max_array_access = new_size - 1;
 
          /* And change the properties that we need to change */
          (*new_var)->type = glsl_type::get_array_instance(glsl_type::vec4_type,
@@ -235,7 +236,8 @@ lower_distance_visitor::create_indices(ir_rvalue *old_index,
       old_index = new(ctx) ir_expression(ir_unop_u2i, old_index);
    }
 
-   ir_constant *old_index_constant = old_index->constant_expression_value();
+   ir_constant *old_index_constant =
+      old_index->constant_expression_value(ctx);
    if (old_index_constant) {
       /* gl_ClipDistance is being accessed via a constant index.  Don't bother
        * creating expressions to calculate the lowered indices.  Just create
@@ -648,7 +650,7 @@ lower_distance_visitor_counter::visit(ir_variable *ir)
 }
 
 void
-lower_distance_visitor_counter::handle_rvalue(ir_rvalue **rv)
+lower_distance_visitor_counter::handle_rvalue(ir_rvalue **)
 {
    return;
 }