Module: Mesa
Branch: master
Commit: 9740c8a8aa5497d02a589ccaca3783056199fbe0
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9740c8a8aa5497d02a589ccaca3783056199fbe0

Author: Timothy Arceri <tarc...@itsqueeze.com>
Date:   Tue Feb 13 17:00:40 2018 +1100

ac: implement nir_intrinsic_image_samples

Fixes cts test:
KHR-GL45.shader_texture_image_samples_tests.image_functional_test

Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/amd/common/ac_nir_to_llvm.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index dc551172d9..7f0bb05862 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3781,6 +3781,26 @@ static LLVMValueRef visit_image_atomic(struct 
ac_nir_context *ctx,
        return ac_build_intrinsic(&ctx->ac, intrinsic_name, ctx->ac.i32, 
params, param_count, 0);
 }
 
+static LLVMValueRef visit_image_samples(struct ac_nir_context *ctx,
+                                       const nir_intrinsic_instr *instr)
+{
+       const nir_variable *var = instr->variables[0]->var;
+       const struct glsl_type *type = glsl_without_array(var->type);
+       bool da = glsl_sampler_type_is_array(type) ||
+                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE ||
+                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_3D;
+
+       struct ac_image_args args = { 0 };
+       args.da = da;
+       args.dmask = 0xf;
+       args.resource = get_sampler_desc(ctx, instr->variables[0],
+                                        AC_DESC_IMAGE, NULL, true, false);
+       args.opcode = ac_image_get_resinfo;
+       args.addr = ctx->ac.i32_0;
+
+       return ac_build_image_opcode(&ctx->ac, &args);
+}
+
 static LLVMValueRef visit_image_size(struct ac_nir_context *ctx,
                                     const nir_intrinsic_instr *instr)
 {
@@ -4479,6 +4499,9 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
        case nir_intrinsic_store_shared:
                visit_store_shared(ctx, instr);
                break;
+       case nir_intrinsic_image_samples:
+               result = visit_image_samples(ctx, instr);
+               break;
        case nir_intrinsic_image_load:
                result = visit_image_load(ctx, instr);
                break;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to