diff options
author | Antia Puentes <[email protected]> | 2018-02-22 13:50:23 +0100 |
---|---|---|
committer | Alejandro Piñeiro <[email protected]> | 2018-07-03 12:41:46 +0200 |
commit | fbcebfc5bf191f6018a8e17ca26e47cbfdf5e40c (patch) | |
tree | 983d0c4e763ada4aa9f806e57277bf3778fb132c /src/compiler/glsl | |
parent | 6677e131b806b10754adcb7cf3f427a7fcc2aa09 (diff) |
nir: Fix OpAtomicCounterIDecrement for uniform atomic counters
From the SPIR-V 1.0 specification, section 3.32.18, "Atomic
Instructions":
"OpAtomicIDecrement:
<skip>
The instruction's result is the Original Value."
However, we were implementing it, for uniform atomic counters, as a
pre-decrement operation, as was the one available from GLSL.
Renamed the former nir intrinsic 'atomic_counter_dec*' to
'atomic_counter_pre_dec*' for clarification purposes, as it implements
a pre-decrement operation as specified for GLSL. From GLSL 4.50 spec,
section 8.10, "Atomic Counter Functions":
"uint atomicCounterDecrement (atomic_uint c)
Atomically
1. decrements the counter for c, and
2. returns the value resulting from the decrement operation.
These two steps are done atomically with respect to the atomic
counter functions in this table."
Added a new nir intrinsic 'atomic_counter_post_dec*' which implements
a post-decrement operation as required by SPIR-V.
v2: (Timothy Arceri)
* Add extra spec quotes on commit message
* Use "post" instead "pos" to avoid confusion with "position"
Signed-off-by: Antia Puentes <[email protected]>
Signed-off-by: Alejandro Piñeiro <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r-- | src/compiler/glsl/gl_nir_lower_atomics.c | 8 | ||||
-rw-r--r-- | src/compiler/glsl/glsl_to_nir.cpp | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/glsl/gl_nir_lower_atomics.c b/src/compiler/glsl/gl_nir_lower_atomics.c index 293730966fd..36e273c45d2 100644 --- a/src/compiler/glsl/gl_nir_lower_atomics.c +++ b/src/compiler/glsl/gl_nir_lower_atomics.c @@ -53,8 +53,12 @@ lower_deref_instr(nir_builder *b, nir_intrinsic_instr *instr, op = nir_intrinsic_atomic_counter_inc; break; - case nir_intrinsic_atomic_counter_dec_deref: - op = nir_intrinsic_atomic_counter_dec; + case nir_intrinsic_atomic_counter_pre_dec_deref: + op = nir_intrinsic_atomic_counter_pre_dec; + break; + + case nir_intrinsic_atomic_counter_post_dec_deref: + op = nir_intrinsic_atomic_counter_post_dec; break; case nir_intrinsic_atomic_counter_add_deref: diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index d3a3fb9b085..2d76c7e6cfe 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -630,7 +630,7 @@ nir_visitor::visit(ir_call *ir) op = nir_intrinsic_atomic_counter_inc_deref; break; case ir_intrinsic_atomic_counter_predecrement: - op = nir_intrinsic_atomic_counter_dec_deref; + op = nir_intrinsic_atomic_counter_pre_dec_deref; break; case ir_intrinsic_atomic_counter_add: op = nir_intrinsic_atomic_counter_add_deref; @@ -831,7 +831,7 @@ nir_visitor::visit(ir_call *ir) switch (op) { case nir_intrinsic_atomic_counter_read_deref: case nir_intrinsic_atomic_counter_inc_deref: - case nir_intrinsic_atomic_counter_dec_deref: + case nir_intrinsic_atomic_counter_pre_dec_deref: case nir_intrinsic_atomic_counter_add_deref: case nir_intrinsic_atomic_counter_min_deref: case nir_intrinsic_atomic_counter_max_deref: |