[Mesa-dev] [PATCH 24/29] i965/fs: Revisit NIR atomic counter intrinsic translation.
Francisco Jerez
currojerez at riseup.net
Sat May 2 08:29:51 PDT 2015
v2: Drop VEC4 suport.
---
src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 58 +++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 16 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 555987d..1443ef0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -26,8 +26,11 @@
#include "glsl/nir/glsl_to_nir.h"
#include "program/prog_to_nir.h"
#include "brw_fs.h"
+#include "brw_fs_surface_builder.h"
#include "brw_nir.h"
+using namespace brw;
+
void
fs_visitor::emit_nir_code()
{
@@ -1288,25 +1291,48 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
case nir_intrinsic_atomic_counter_inc:
case nir_intrinsic_atomic_counter_dec:
case nir_intrinsic_atomic_counter_read: {
- unsigned surf_index = prog_data->binding_table.abo_start +
- (unsigned) instr->const_index[0];
- fs_reg offset = fs_reg(get_nir_src(instr->src[0]));
+ using namespace surface_access;
+
+ const bool uses_kill = (stage == MESA_SHADER_FRAGMENT &&
+ ((brw_wm_prog_data *)prog_data)->uses_kill);
+ fs_builder bld(devinfo, mem_ctx, alloc, instructions,
+ dispatch_width, stage, uses_kill);
+
+ /* Get the arguments of the atomic intrinsic. */
+ const fs_reg offset(get_nir_src(instr->src[0]));
+ const fs_reg surface(stage_prog_data->binding_table.abo_start +
+ instr->const_index[0]);
+
+ /* Get some metadata from the atomic intrinsic. */
+ const unsigned rsize = (nir_intrinsic_infos[instr->intrinsic].has_dest ?
+ 1 : 0);
+ fs_reg tmp;
+ /* Emit a surface read or atomic op. */
switch (instr->intrinsic) {
- case nir_intrinsic_atomic_counter_inc:
- emit_untyped_atomic(BRW_AOP_INC, surf_index, dest, offset,
- fs_reg(), fs_reg());
- break;
- case nir_intrinsic_atomic_counter_dec:
- emit_untyped_atomic(BRW_AOP_PREDEC, surf_index, dest, offset,
- fs_reg(), fs_reg());
- break;
- case nir_intrinsic_atomic_counter_read:
- emit_untyped_surface_read(surf_index, dest, offset);
- break;
- default:
- unreachable("Unreachable");
+ case nir_intrinsic_atomic_counter_read:
+ tmp = surface_access::emit_untyped_read(bld, surface, offset, 1, 1);
+ break;
+
+ case nir_intrinsic_atomic_counter_inc:
+ tmp = surface_access::emit_untyped_atomic(
+ bld, surface, offset, fs_reg(),
+ fs_reg(), 1, rsize, BRW_AOP_INC);
+ break;
+
+ case nir_intrinsic_atomic_counter_dec:
+ tmp = surface_access::emit_untyped_atomic(
+ bld, surface, offset, fs_reg(),
+ fs_reg(), 1, rsize, BRW_AOP_PREDEC);
+ break;
+
+ default:
+ unreachable("Unreachable");
}
+
+ /* Assign the result. */
+ if (rsize)
+ bld.MOV(get_nir_dest(instr->dest), tmp);
break;
}
--
2.3.5
More information about the mesa-dev
mailing list