[Mesa-dev] [PATCH 3/4] st/mesa: add atomic AoA support

Dave Airlie airlied at gmail.com
Fri Feb 5 03:40:29 UTC 2016


reuse the sampler deref handling code to do the same
thing for atomics.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index c36edc9..294248f 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3159,19 +3159,19 @@ glsl_to_tgsi_visitor::visit_atomic_counter_intrinsic(ir_call *ir)
 
    /* Calculate the surface offset */
    st_src_reg offset;
-   ir_dereference_array *deref_array = deref->as_dereference_array();
+   unsigned array_size = 0, base = 0, index = 0;
 
-   if (deref_array) {
-      offset = get_temp(glsl_type::uint_type);
-
-      deref_array->array_index->accept(this);
+   get_deref_offsets(deref, &array_size, &base, &index, &offset);
 
+   if (offset.file != PROGRAM_UNDEFINED) {
+      emit_asm(ir, TGSI_OPCODE_ADD, st_dst_reg(offset),
+               offset, st_src_reg_for_int(index));
       emit_asm(ir, TGSI_OPCODE_MUL, st_dst_reg(offset),
-               this->result, st_src_reg_for_int(ATOMIC_COUNTER_SIZE));
+               offset, st_src_reg_for_int(ATOMIC_COUNTER_SIZE));
       emit_asm(ir, TGSI_OPCODE_ADD, st_dst_reg(offset),
                offset, st_src_reg_for_int(location->data.offset));
    } else {
-      offset = st_src_reg_for_int(location->data.offset);
+      offset = st_src_reg_for_int(location->data.offset + index * ATOMIC_COUNTER_SIZE);
    }
 
    ir->return_deref->accept(this);
@@ -3545,7 +3545,10 @@ glsl_to_tgsi_visitor::get_deref_offsets(ir_dereference *ir,
    *array_size = 1;
    calc_deref_offsets(ir, ir, array_size, index, reladdr, &location);
 
-   *base = this->shader_program->UniformStorage[location].opaque[shader].index;
+   if (location != 0xffffffff)
+      *base = this->shader_program->UniformStorage[location].opaque[shader].index;
+   else
+      *base = 0;
    *index += *base;
 }
 
-- 
2.5.0



More information about the mesa-dev mailing list