spirv: fix 64 bit atomic inc and dec
authorKarol Herbst <kherbst@redhat.com>
Sat, 22 Aug 2020 11:48:35 +0000 (13:48 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 1 Sep 2020 18:47:30 +0000 (18:47 +0000)
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstran.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6433>

src/compiler/spirv/spirv_to_nir.c

index 4d7f9f2f8c3243bbec4d90d8735d06f2249c25c3..3a886ce6556a1996780176b3630f0433a8059680 100644 (file)
@@ -2889,13 +2889,16 @@ static void
 fill_common_atomic_sources(struct vtn_builder *b, SpvOp opcode,
                            const uint32_t *w, nir_src *src)
 {
+   const struct glsl_type *type = vtn_get_type(b, w[1])->type;
+   unsigned bit_size = glsl_get_bit_size(type);
+
    switch (opcode) {
    case SpvOpAtomicIIncrement:
-      src[0] = nir_src_for_ssa(nir_imm_int(&b->nb, 1));
+      src[0] = nir_src_for_ssa(nir_imm_intN_t(&b->nb, 1, bit_size));
       break;
 
    case SpvOpAtomicIDecrement:
-      src[0] = nir_src_for_ssa(nir_imm_int(&b->nb, -1));
+      src[0] = nir_src_for_ssa(nir_imm_intN_t(&b->nb, -1, bit_size));
       break;
 
    case SpvOpAtomicISub: