summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2018-04-18 13:34:25 -0700
committerIan Romanick <[email protected]>2018-08-22 20:31:32 -0700
commit0842655ac654cf3090d2543ec955c967c38d2d03 (patch)
tree1a38e175926697238ef002f0af651730661d4a3a /src/compiler/nir
parent69ce7baa9e0dd598aad80f559719fdf14928038e (diff)
nir: Add floating point atomic min, max, and compare-swap instrinsics
Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir_intrinsics.py11
-rw-r--r--src/compiler/nir/nir_lower_atomics_to_ssbo.c6
-rw-r--r--src/compiler/nir/nir_lower_io.c9
3 files changed, 24 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py
index 836cb34d74a..8c9bc3bbc9a 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -359,6 +359,9 @@ intrinsic("deref_atomic_xor", src_comp=[1, 1], dest_comp=1)
intrinsic("deref_atomic_exchange", src_comp=[1, 1], dest_comp=1)
intrinsic("deref_atomic_comp_swap", src_comp=[1, 1, 1], dest_comp=1)
intrinsic("deref_atomic_fadd", src_comp=[1, 1], dest_comp=1)
+intrinsic("deref_atomic_fmin", src_comp=[1, 1], dest_comp=1)
+intrinsic("deref_atomic_fmax", src_comp=[1, 1], dest_comp=1)
+intrinsic("deref_atomic_fcomp_swap", src_comp=[1, 1, 1], dest_comp=1)
# SSBO atomic intrinsics
#
@@ -385,7 +388,10 @@ intrinsic("ssbo_atomic_or", src_comp=[1, 1, 1], dest_comp=1)
intrinsic("ssbo_atomic_xor", src_comp=[1, 1, 1], dest_comp=1)
intrinsic("ssbo_atomic_exchange", src_comp=[1, 1, 1], dest_comp=1)
intrinsic("ssbo_atomic_comp_swap", src_comp=[1, 1, 1, 1], dest_comp=1)
-intrinsic("ssbo_atomic_fadd", src_comp=[1, 1, 1], dest_comp=1)
+intrinsic("ssbo_atomic_fadd", src_comp=[1, 1, 1], dest_comp=1)
+intrinsic("ssbo_atomic_fmin", src_comp=[1, 1, 1], dest_comp=1)
+intrinsic("ssbo_atomic_fmax", src_comp=[1, 1, 1], dest_comp=1)
+intrinsic("ssbo_atomic_fcomp_swap", src_comp=[1, 1, 1, 1], dest_comp=1)
# CS shared variable atomic intrinsics
#
@@ -412,6 +418,9 @@ intrinsic("shared_atomic_xor", src_comp=[1, 1], dest_comp=1, indices=[BASE])
intrinsic("shared_atomic_exchange", src_comp=[1, 1], dest_comp=1, indices=[BASE])
intrinsic("shared_atomic_comp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
intrinsic("shared_atomic_fadd", src_comp=[1, 1], dest_comp=1, indices=[BASE])
+intrinsic("shared_atomic_fmin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
+intrinsic("shared_atomic_fmax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
+intrinsic("shared_atomic_fcomp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
def system_value(name, dest_comp, indices=[]):
intrinsic("load_" + name, [], dest_comp, indices,
diff --git a/src/compiler/nir/nir_lower_atomics_to_ssbo.c b/src/compiler/nir/nir_lower_atomics_to_ssbo.c
index 72686624329..c165a03b141 100644
--- a/src/compiler/nir/nir_lower_atomics_to_ssbo.c
+++ b/src/compiler/nir/nir_lower_atomics_to_ssbo.c
@@ -58,6 +58,9 @@ lower_instr(nir_intrinsic_instr *instr, unsigned ssbo_offset, nir_builder *b)
case nir_intrinsic_ssbo_atomic_exchange:
case nir_intrinsic_ssbo_atomic_comp_swap:
case nir_intrinsic_ssbo_atomic_fadd:
+ case nir_intrinsic_ssbo_atomic_fmin:
+ case nir_intrinsic_ssbo_atomic_fmax:
+ case nir_intrinsic_ssbo_atomic_fcomp_swap:
case nir_intrinsic_store_ssbo:
case nir_intrinsic_load_ssbo:
case nir_intrinsic_get_buffer_size:
@@ -140,7 +143,8 @@ lower_instr(nir_intrinsic_instr *instr, unsigned ssbo_offset, nir_builder *b)
new_instr->src[0] = nir_src_for_ssa(buffer);
nir_src_copy(&new_instr->src[1], &instr->src[0], new_instr);
nir_src_copy(&new_instr->src[2], &instr->src[1], new_instr);
- if (op == nir_intrinsic_ssbo_atomic_comp_swap)
+ if (op == nir_intrinsic_ssbo_atomic_comp_swap ||
+ op == nir_intrinsic_ssbo_atomic_fcomp_swap)
nir_src_copy(&new_instr->src[3], &instr->src[2], new_instr);
break;
}
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index 3d4451e3602..c418433aa52 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -281,6 +281,9 @@ lower_atomic(nir_intrinsic_instr *intrin, struct lower_io_state *state,
OP(atomic_or)
OP(atomic_xor)
OP(atomic_fadd)
+ OP(atomic_fmin)
+ OP(atomic_fmax)
+ OP(atomic_fcomp_swap)
#undef OP
default:
unreachable("Invalid atomic");
@@ -382,6 +385,9 @@ nir_lower_io_block(nir_block *block,
case nir_intrinsic_deref_atomic_exchange:
case nir_intrinsic_deref_atomic_comp_swap:
case nir_intrinsic_deref_atomic_fadd:
+ case nir_intrinsic_deref_atomic_fmin:
+ case nir_intrinsic_deref_atomic_fmax:
+ case nir_intrinsic_deref_atomic_fcomp_swap:
/* We can lower the io for this nir instrinsic */
break;
case nir_intrinsic_interp_deref_at_centroid:
@@ -444,6 +450,9 @@ nir_lower_io_block(nir_block *block,
case nir_intrinsic_deref_atomic_exchange:
case nir_intrinsic_deref_atomic_comp_swap:
case nir_intrinsic_deref_atomic_fadd:
+ case nir_intrinsic_deref_atomic_fmin:
+ case nir_intrinsic_deref_atomic_fmax:
+ case nir_intrinsic_deref_atomic_fcomp_swap:
assert(vertex_index == NULL);
replacement = lower_atomic(intrin, state, var, offset);
break;