Mesa (master): ac/llvm: add support for texturing with clamped LOD
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu May 14 12:21:43 UTC 2020
Module: Mesa
Branch: master
Commit: 0d63a1a84d409d08fd6c6f8a0c569b2620d6a600
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d63a1a84d409d08fd6c6f8a0c569b2620d6a600
Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date: Mon May 11 16:51:33 2020 +0200
ac/llvm: add support for texturing with clamped LOD
This is a requirement for the shaderResourceMinLod feature which
allows to clamp LOD. This uses all image_sample_*_cl variants.
All dEQP-VK.glsl.texture_functions.texture*clamp.* pass.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4989>
---
src/amd/llvm/ac_llvm_build.c | 9 ++++++++-
src/amd/llvm/ac_llvm_build.h | 1 +
src/amd/llvm/ac_nir_to_llvm.c | 3 +++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index 0066a885c95..ebcb91bd4b3 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -2373,6 +2373,9 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
(a->lod ? 1 : 0) +
(a->level_zero ? 1 : 0) +
(a->derivs[0] ? 1 : 0) <= 1);
+ assert((a->min_lod ? 1 : 0) +
+ (a->lod ? 1 : 0) +
+ (a->level_zero ? 1 : 0) <= 1);
if (a->opcode == ac_image_get_lod) {
switch (dim) {
@@ -2428,6 +2431,9 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
args[num_args++] = LLVMBuildBitCast(ctx->builder, a->coords[i], coord_type, "");
if (a->lod)
args[num_args++] = LLVMBuildBitCast(ctx->builder, a->lod, coord_type, "");
+ if (a->min_lod)
+ args[num_args++] = LLVMBuildBitCast(ctx->builder, a->min_lod, coord_type, "");
+
overload[num_overloads++] = sample ? ".f32" : ".i32";
args[num_args++] = a->resource;
@@ -2481,7 +2487,7 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
char intr_name[96];
snprintf(intr_name, sizeof(intr_name),
"llvm.amdgcn.image.%s%s" /* base name */
- "%s%s%s" /* sample/gather modifiers */
+ "%s%s%s%s" /* sample/gather modifiers */
".%s.%s%s%s%s", /* dimension and type overloads */
name, atomic_subop,
a->compare ? ".c" : "",
@@ -2489,6 +2495,7 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
lod_suffix ? ".l" :
a->derivs[0] ? ".d" :
a->level_zero ? ".lz" : "",
+ a->min_lod ? ".cl" : "",
a->offset ? ".o" : "",
dimname,
atomic ? "i32" : "v4f32",
diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h
index 2c6142e76f9..703f7ea31cc 100644
--- a/src/amd/llvm/ac_llvm_build.h
+++ b/src/amd/llvm/ac_llvm_build.h
@@ -561,6 +561,7 @@ struct ac_image_args {
LLVMValueRef derivs[6];
LLVMValueRef coords[4];
LLVMValueRef lod; // also used by ac_image_get_resinfo
+ LLVMValueRef min_lod;
};
LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index d3489614d4c..6f0d253d9c7 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -4468,6 +4468,9 @@ static void visit_tex(struct ac_nir_context *ctx, nir_tex_instr *instr)
case nir_tex_src_ddy:
ddy = get_src(ctx, instr->src[i].src);
break;
+ case nir_tex_src_min_lod:
+ args.min_lod = get_src(ctx, instr->src[i].src);
+ break;
case nir_tex_src_texture_offset:
case nir_tex_src_sampler_offset:
case nir_tex_src_plane:
More information about the mesa-commit
mailing list