summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro PiƱeiro <[email protected]>2015-06-16 22:03:17 +0200
committerJason Ekstrand <[email protected]>2015-08-03 09:40:48 -0700
commit98d07022f5312967bdfd54069869c8d6c65117a7 (patch)
treec547ef222f59e1b30ca406c89d0681fe29071b6c
parente6cafb5dfdef8d8d25ee1e3375304cf35897d1f7 (diff)
i965/nir/vec4: Implement atomic counter intrinsics (read, inc and dec)
The implementation is based on its fs_nir counterpart. Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_nir.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index ff218a50807..497732e92df 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -551,9 +551,32 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
case nir_intrinsic_atomic_counter_read:
case nir_intrinsic_atomic_counter_inc:
- case nir_intrinsic_atomic_counter_dec:
- /* @TODO: Not yet implemented */
+ case nir_intrinsic_atomic_counter_dec: {
+ unsigned surf_index = prog_data->base.binding_table.abo_start +
+ (unsigned) instr->const_index[0];
+ src_reg offset = get_nir_src(instr->src[0], nir_type_int,
+ instr->num_components);
+ dest = get_nir_dest(instr->dest);
+
+ switch (instr->intrinsic) {
+ case nir_intrinsic_atomic_counter_inc:
+ emit_untyped_atomic(BRW_AOP_INC, surf_index, dest, offset,
+ src_reg(), src_reg());
+ break;
+ case nir_intrinsic_atomic_counter_dec:
+ emit_untyped_atomic(BRW_AOP_PREDEC, surf_index, dest, offset,
+ src_reg(), src_reg());
+ break;
+ case nir_intrinsic_atomic_counter_read:
+ emit_untyped_surface_read(surf_index, dest, offset);
+ break;
+ default:
+ unreachable("Unreachable");
+ }
+
+ brw_mark_surface_used(stage_prog_data, surf_index);
break;
+ }
case nir_intrinsic_load_ubo_indirect:
/* fallthrough */