<div dir="ltr">On 2 December 2013 11:39, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Until now atomic counter built-ins were handled in a way that<br>
prevented the visitor from encountering atomic counter IR variables<br>
and dereferences directly.  In the new surface lowering code it's<br>
going to be more convenient to be able to call back into the visitor<br>
to let it handle the ugly details of atomic counter array<br>
dereferences, and it will make sharing the rest of the atomic<br>
intrinsic handling code easier.<br></blockquote><div><br></div><div>The commit message should note that this patch fixes the fs part of the regression to atomic counters introduced by patch 10, by re-introducing the call to brw_mark_surface_used().<br>
 <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 102 ++++++++++++++++-----------<br>
 1 file changed, 60 insertions(+), 42 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
index b5957c6..d65809f 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
@@ -102,34 +102,40 @@ fs_visitor::visit(ir_variable *ir)<br>
         }<br>
       }<br>
    } else if (ir->mode == ir_var_uniform) {<br>
-      int param_index = uniforms;<br>
-<br>
-      /* Thanks to the lower_ubo_reference pass, we will see only<br>
-       * ir_binop_ubo_load expressions and not ir_dereference_variable for UBO<br>
-       * variables, so no need for them to be in variable_ht.<br>
-       *<br>
-       * Atomic counters take no uniform storage, no need to do<br>
-       * anything here.<br>
-       */<br>
-      if (ir->is_in_uniform_block() || ir->type->contains_atomic())<br>
+      if (ir->is_in_uniform_block()) {<br>
+         /* Thanks to the lower_ubo_reference pass, we will see only<br>
+          * ir_binop_ubo_load expressions and not ir_dereference_variable for UBO<br>
+          * variables, so no need for them to be in variable_ht.<br>
+          */<br>
          return;<br>
<br>
-      if (dispatch_width == 16) {<br>
-        if (!variable_storage(ir)) {<br>
-           fail("Failed to find uniform '%s' in 16-wide\n", ir->name);<br>
-        }<br>
-        return;<br>
-      }<br>
+      } else if (ir->type->contains_atomic()) {<br>
+         reg = new(this->mem_ctx) fs_reg(ir->atomic.offset);<br>
+<br>
+         brw_mark_surface_used(stage_prog_data,<br>
+                               stage_prog_data->binding_table.abo_start +<br>
+                               ir->atomic.buffer_index);<br>
<br>
-      param_size[param_index] = type_size(ir->type);<br>
-      if (!strncmp(ir->name, "gl_", 3)) {<br>
-        setup_builtin_uniform_values(ir);<br>
       } else {<br>
-        setup_uniform_values(ir);<br>
-      }<br>
+         int param_index = uniforms;<br>
<br>
-      reg = new(this->mem_ctx) fs_reg(UNIFORM, param_index);<br>
-      reg->type = brw_type_for_base_type(ir->type);<br>
+         if (dispatch_width == 16) {<br>
+            if (!variable_storage(ir)) {<br>
+               fail("Failed to find uniform '%s' in 16-wide\n", ir->name);<br>
+            }<br>
+            return;<br>
+         }<br>
+<br>
+         param_size[param_index] = type_size(ir->type);<br>
+         if (!strncmp(ir->name, "gl_", 3)) {<br>
+            setup_builtin_uniform_values(ir);<br>
+         } else {<br>
+            setup_uniform_values(ir);<br>
+         }<br>
+<br>
+         reg = new(this->mem_ctx) fs_reg(UNIFORM, param_index);<br>
+         reg->type = brw_type_for_base_type(ir->type);<br>
+      }<br>
<br>
    } else if (ir->mode == ir_var_system_value) {<br>
       if (ir->location == SYSTEM_VALUE_SAMPLE_POS) {<br>
@@ -182,31 +188,43 @@ fs_visitor::visit(ir_dereference_array *ir)<br>
    src = this->result;<br>
    src.type = brw_type_for_base_type(ir->type);<br>
<br>
-   if (constant_index) {<br>
-      assert(src.file == UNIFORM || src.file == GRF);<br>
-      src.reg_offset += constant_index->value.i[0] * element_size;<br>
-   } else {<br>
-      /* Variable index array dereference.  We attach the variable index<br>
-       * component to the reg as a pointer to a register containing the<br>
-       * offset.  Currently only uniform arrays are supported in this patch,<br>
-       * and that reladdr pointer is resolved by<br>
-       * move_uniform_array_access_to_pull_constants().  All other array types<br>
-       * are lowered by lower_variable_index_to_cond_assign().<br>
-       */<br>
+   if (ir->array->type->contains_atomic()) {<br>
+      fs_reg tmp(this, glsl_type::uint_type);<br>
+<br>
       ir->array_index->accept(this);<br>
<br>
-      fs_reg index_reg;<br>
-      index_reg = fs_reg(this, glsl_type::int_type);<br>
-      emit(BRW_OPCODE_MUL, index_reg, this->result, fs_reg(element_size));<br>
+      emit(MUL(tmp, this->result, ATOMIC_COUNTER_SIZE));<br>
+      emit(ADD(tmp, tmp, src));<br>
+      this->result = tmp;<br>
+<br></blockquote><div><br></div><div>I believe we need a call to brw_mark_surface_used() here too.<br><br></div><div>With those issues addressed, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div></div></div></div>