ac/nir: implement nir_intrinsic_shader_clock with device scope
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 20 May 2020 08:07:26 +0000 (10:07 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 24 May 2020 18:37:58 +0000 (20:37 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5117>

src/amd/llvm/ac_llvm_build.c
src/amd/llvm/ac_llvm_build.h
src/amd/llvm/ac_nir_to_llvm.c

index db953019edd6f0b58309db943ea9b44bf118a469..ef4c95e5673a02c1dfc87f13ede5960091c79afe 100644 (file)
@@ -457,9 +457,10 @@ ac_build_optimization_barrier(struct ac_llvm_context *ctx,
 }
 
 LLVMValueRef
-ac_build_shader_clock(struct ac_llvm_context *ctx)
+ac_build_shader_clock(struct ac_llvm_context *ctx, nir_scope scope)
 {
-       LLVMValueRef tmp = ac_build_intrinsic(ctx, "llvm.amdgcn.s.memtime", ctx->i64, NULL, 0, 0);
+       const char *name = scope == NIR_SCOPE_DEVICE ? "llvm.amdgcn.s.memrealtime" : "llvm.amdgcn.s.memtime";
+       LLVMValueRef tmp = ac_build_intrinsic(ctx, name, ctx->i64, NULL, 0, 0);
        return LLVMBuildBitCast(ctx->builder, tmp, ctx->v2i32, "");
 }
 
index 703f7ea31ccd2411d7204488e13711fb61dec408..a4777f12f0783e0d13cfdb5d39e8e9f371cc6e96 100644 (file)
@@ -181,7 +181,8 @@ void ac_build_s_barrier(struct ac_llvm_context *ctx);
 void ac_build_optimization_barrier(struct ac_llvm_context *ctx,
                                   LLVMValueRef *pvgpr);
 
-LLVMValueRef ac_build_shader_clock(struct ac_llvm_context *ctx);
+LLVMValueRef ac_build_shader_clock(struct ac_llvm_context *ctx,
+                                  nir_scope scope);
 
 LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value);
 LLVMValueRef ac_get_i1_sgpr_mask(struct ac_llvm_context *ctx,
index 27fd64ef6c01fd16b40aaccc5a9f1738b23aded9..e6f4e79aa58a3afaaa3a99a500f464e804b48243 100644 (file)
@@ -3864,7 +3864,8 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
                result = visit_image_size(ctx, instr, false);
                break;
        case nir_intrinsic_shader_clock:
-               result = ac_build_shader_clock(&ctx->ac);
+               result = ac_build_shader_clock(&ctx->ac,
+                                              nir_intrinsic_memory_scope(instr));
                break;
        case nir_intrinsic_discard:
        case nir_intrinsic_discard_if: