ac/nir: generate correct instruction for atomic min/max on unsigned images
authorMatthew Nicholls <mnicholls@feralinteractive.com>
Wed, 25 Oct 2017 13:20:43 +0000 (14:20 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 25 Oct 2017 18:52:58 +0000 (20:52 +0200)
v2: fix silly typo

Cc: "17.2 17.3" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_nir_to_llvm.c

index 3d635d420644dd70fc5a0fe2a39bd48b506e5c58..06937d684be2023903685b3ccfeee7931ecbd904 100644 (file)
@@ -3667,15 +3667,17 @@ static LLVMValueRef visit_image_atomic(struct ac_nir_context *ctx,
        LLVMValueRef i1true = LLVMConstInt(ctx->ac.i1, 1, false);
        MAYBE_UNUSED int length;
 
+       bool is_unsigned = glsl_get_sampler_result_type(type) == GLSL_TYPE_UINT;
+
        switch (instr->intrinsic) {
        case nir_intrinsic_image_atomic_add:
                atomic_name = "add";
                break;
        case nir_intrinsic_image_atomic_min:
-               atomic_name = "smin";
+               atomic_name = is_unsigned ? "umin" : "smin";
                break;
        case nir_intrinsic_image_atomic_max:
-               atomic_name = "smax";
+               atomic_name = is_unsigned ? "umax" : "smax";
                break;
        case nir_intrinsic_image_atomic_and:
                atomic_name = "and";