<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 7, 2016 at 12:45 AM, Michael Schellenberger Costa <span dir="ltr"><<a href="mailto:mschellenbergercosta@googlemail.com" target="_blank">mschellenbergercosta@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jason,<br>
<div><div class="h5"><br>
Am 07.09.2016 um 00:17 schrieb Jason Ekstrand:<br>
> We had two almost identical copies of this code and they were both broken<br>
> but in different ways. The previous two commits fixed both of them. This<br>
> one just unifies them so that it's easier to handle in the future.<br>
><br>
> Signed-off-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
> ---<br>
> src/compiler/spirv/spirv_to_<wbr>nir.c | 99 +++++++++++++++++-------------<wbr>---------<br>
> 1 file changed, 43 insertions(+), 56 deletions(-)<br>
><br>
> diff --git a/src/compiler/spirv/spirv_to_<wbr>nir.c b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
> index 0d6a70e..e91a7b2 100644<br>
> --- a/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
> +++ b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
> @@ -1589,6 +1589,47 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,<br>
> nir_builder_instr_insert(&b-><wbr>nb, &instr->instr);<br>
> }<br>
><br>
> +static void<br>
> +fill_common_atomic_sources(<wbr>struct vtn_builder *b, SpvOp opcode,<br>
> + const uint32_t *w, nir_src *src)<br>
> +{<br>
> + switch (opcode) {<br>
> + case SpvOpAtomicIIncrement:<br>
> + src[0] = nir_src_for_ssa(nir_imm_int(&<wbr>b->nb, 1));<br>
> + break;<br>
> +<br>
> + case SpvOpAtomicIDecrement:<br>
> + src[0] = nir_src_for_ssa(nir_imm_int(&<wbr>b->nb, -1));<br>
> + break;<br>
> +<br>
> + case SpvOpAtomicISub:<br>
> + src[0] =<br>
> + nir_src_for_ssa(nir_ineg(&b-><wbr>nb, vtn_ssa_value(b, w[6])->def));<br>
> + break;<br>
> +<br>
> + case SpvOpAtomicCompareExchange:<br>
> + src[0] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[8])->def);<br>
> + src[1] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[7])->def);<br>
> + break;<br>
> + /* Fall through */<br>
</div></div>That fall through seems wrong.<br></blockquote><div><br></div><div>Thanks. You're right. I just pushed a commit which removes the erroneous comment.<br><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888">--Michael<br>
</font></span><div class="HOEnZb"><div class="h5">> +<br>
> + case SpvOpAtomicExchange:<br>
> + case SpvOpAtomicIAdd:<br>
> + case SpvOpAtomicSMin:<br>
> + case SpvOpAtomicUMin:<br>
> + case SpvOpAtomicSMax:<br>
> + case SpvOpAtomicUMax:<br>
> + case SpvOpAtomicAnd:<br>
> + case SpvOpAtomicOr:<br>
> + case SpvOpAtomicXor:<br>
> + src[0] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[6])->def);<br>
> + break;<br>
> +<br>
> + default:<br>
> + unreachable("Invalid SPIR-V atomic");<br>
> + }<br>
> +}<br>
> +<br>
> static nir_ssa_def *<br>
> get_image_coord(struct vtn_builder *b, uint32_t value)<br>
> {<br>
> @@ -1729,13 +1770,9 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,<br>
> case SpvOpImageWrite:<br>
> intrin->src[2] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[3])->def);<br>
> break;<br>
> +<br>
> case SpvOpAtomicIIncrement:<br>
> - intrin->src[2] = nir_src_for_ssa(nir_imm_int(&<wbr>b->nb, 1));<br>
> - break;<br>
> case SpvOpAtomicIDecrement:<br>
> - intrin->src[2] = nir_src_for_ssa(nir_imm_int(&<wbr>b->nb, -1));<br>
> - break;<br>
> -<br>
> case SpvOpAtomicExchange:<br>
> case SpvOpAtomicIAdd:<br>
> case SpvOpAtomicSMin:<br>
> @@ -1745,16 +1782,7 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,<br>
> case SpvOpAtomicAnd:<br>
> case SpvOpAtomicOr:<br>
> case SpvOpAtomicXor:<br>
> - intrin->src[2] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[6])->def);<br>
> - break;<br>
> -<br>
> - case SpvOpAtomicCompareExchange:<br>
> - intrin->src[2] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[8])->def);<br>
> - intrin->src[3] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[7])->def);<br>
> - break;<br>
> -<br>
> - case SpvOpAtomicISub:<br>
> - intrin->src[2] = nir_src_for_ssa(nir_ineg(&b-><wbr>nb, vtn_ssa_value(b, w[6])->def));<br>
> + fill_common_atomic_sources(b, opcode, w, &intrin->src[2]);<br>
> break;<br>
><br>
> default:<br>
> @@ -1829,47 +1857,6 @@ get_shared_nir_atomic_op(SpvOp opcode)<br>
> }<br>
><br>
> static void<br>
> -fill_common_atomic_sources(<wbr>struct vtn_builder *b, SpvOp opcode,<br>
> - const uint32_t *w, nir_src *src)<br>
> -{<br>
> - switch (opcode) {<br>
> - case SpvOpAtomicIIncrement:<br>
> - src[0] = nir_src_for_ssa(nir_imm_int(&<wbr>b->nb, 1));<br>
> - break;<br>
> -<br>
> - case SpvOpAtomicIDecrement:<br>
> - src[0] = nir_src_for_ssa(nir_imm_int(&<wbr>b->nb, -1));<br>
> - break;<br>
> -<br>
> - case SpvOpAtomicISub:<br>
> - src[0] =<br>
> - nir_src_for_ssa(nir_ineg(&b-><wbr>nb, vtn_ssa_value(b, w[6])->def));<br>
> - break;<br>
> -<br>
> - case SpvOpAtomicCompareExchange:<br>
> - src[0] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[8])->def);<br>
> - src[1] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[7])->def);<br>
> - break;<br>
> - /* Fall through */<br>
> -<br>
> - case SpvOpAtomicExchange:<br>
> - case SpvOpAtomicIAdd:<br>
> - case SpvOpAtomicSMin:<br>
> - case SpvOpAtomicUMin:<br>
> - case SpvOpAtomicSMax:<br>
> - case SpvOpAtomicUMax:<br>
> - case SpvOpAtomicAnd:<br>
> - case SpvOpAtomicOr:<br>
> - case SpvOpAtomicXor:<br>
> - src[0] = nir_src_for_ssa(vtn_ssa_value(<wbr>b, w[6])->def);<br>
> - break;<br>
> -<br>
> - default:<br>
> - unreachable("Invalid SPIR-V atomic");<br>
> - }<br>
> -}<br>
> -<br>
> -static void<br>
> vtn_handle_ssbo_or_shared_<wbr>atomic(struct vtn_builder *b, SpvOp opcode,<br>
> const uint32_t *w, unsigned count)<br>
> {<br>
><br>
</div></div></blockquote></div><br></div></div>