ac/nir: fix GLSL imageSamples()
authorMarek Olšák <marek.olsak@amd.com>
Mon, 16 Sep 2019 23:39:40 +0000 (19:39 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 30 Sep 2019 18:21:42 +0000 (14:21 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/common/ac_nir_to_llvm.c

index 781f9ae1258a9633affcfcbf252eea937713bad2..ea7bf91b79bc673cf626ee0dfa53091a66ea957d 100644 (file)
@@ -2778,29 +2778,11 @@ static LLVMValueRef visit_image_atomic(struct ac_nir_context *ctx,
 }
 
 static LLVMValueRef visit_image_samples(struct ac_nir_context *ctx,
-                                       const nir_intrinsic_instr *instr,
-                                       bool bindless)
+                                       const nir_intrinsic_instr *instr)
 {
-       enum glsl_sampler_dim dim;
-       bool is_array;
-       if (bindless) {
-               dim = nir_intrinsic_image_dim(instr);
-               is_array = nir_intrinsic_image_array(instr);
-       } else {
-               const struct glsl_type *type = get_image_deref(instr)->type;
-               dim = glsl_get_sampler_dim(type);
-               is_array = glsl_sampler_type_is_array(type);
-       }
+       LLVMValueRef rsrc = get_image_descriptor(ctx, instr, AC_DESC_IMAGE, false);
 
-       struct ac_image_args args = { 0 };
-       args.dim = ac_get_sampler_dim(ctx->ac.chip_class, dim, is_array);
-       args.dmask = 0xf;
-       args.resource = get_image_descriptor(ctx, instr, AC_DESC_IMAGE, false);
-       args.opcode = ac_image_get_resinfo;
-       args.lod = ctx->ac.i32_0;
-       args.attributes = AC_FUNC_ATTR_READNONE;
-
-       return ac_build_image_opcode(&ctx->ac, &args);
+       return ac_build_image_get_sample_count(&ctx->ac, rsrc);
 }
 
 static LLVMValueRef visit_image_size(struct ac_nir_context *ctx,
@@ -3446,10 +3428,8 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
                visit_store_shared(ctx, instr);
                break;
        case nir_intrinsic_bindless_image_samples:
-               result = visit_image_samples(ctx, instr, true);
-               break;
        case nir_intrinsic_image_deref_samples:
-               result = visit_image_samples(ctx, instr, false);
+               result = visit_image_samples(ctx, instr);
                break;
        case nir_intrinsic_bindless_image_load:
                result = visit_image_load(ctx, instr, true);