freedreno/ir3: do better job of marking convergence points
[mesa.git] / src / compiler / glsl / opt_tree_grafting.cpp
index 83effb7424cb04d942b7284f1b74241d9a614757..6b5d93af66162380fef12003d3cdf560ecb9acc6 100644 (file)
@@ -232,7 +232,7 @@ ir_tree_grafting_visitor::visit_enter(ir_call *ir)
 ir_visitor_status
 ir_tree_grafting_visitor::visit_enter(ir_expression *ir)
 {
-   for (unsigned int i = 0; i < ir->get_num_operands(); i++) {
+   for (unsigned int i = 0; i < ir->num_operands; i++) {
       if (do_graft(&ir->operands[i]))
         return visit_stop;
    }
@@ -267,7 +267,7 @@ ir_tree_grafting_visitor::visit_enter(ir_texture *ir)
    if (do_graft(&ir->coordinate) ||
        do_graft(&ir->projector) ||
        do_graft(&ir->offset) ||
-       do_graft(&ir->shadow_comparitor))
+       do_graft(&ir->shadow_comparator))
         return visit_stop;
 
    switch (ir->op) {
@@ -361,11 +361,26 @@ tree_grafting_basic_block(ir_instruction *bb_first,
       if (!lhs_var)
         continue;
 
-   if (lhs_var->data.mode == ir_var_function_out ||
-       lhs_var->data.mode == ir_var_function_inout ||
-       lhs_var->data.mode == ir_var_shader_out ||
-       lhs_var->data.mode == ir_var_shader_storage)
-      continue;
+      if (lhs_var->data.mode == ir_var_function_out ||
+          lhs_var->data.mode == ir_var_function_inout ||
+          lhs_var->data.mode == ir_var_shader_out ||
+          lhs_var->data.mode == ir_var_shader_storage ||
+          lhs_var->data.mode == ir_var_shader_shared)
+         continue;
+
+      if (lhs_var->data.precise)
+         continue;
+
+      /* Do not graft sampler and image variables. This is a workaround to
+       * st/glsl_to_tgsi being unable to handle expression parameters to image
+       * intrinsics.
+       *
+       * Note that if this is ever fixed, we still need to skip grafting when
+       * any image layout qualifiers (including the image format) are set,
+       * since we must not lose those.
+       */
+      if (lhs_var->type->is_sampler() || lhs_var->type->is_image())
+         continue;
 
       ir_variable_refcount_entry *entry = info->refs->get_variable_entry(lhs_var);