From 3a26dfe761343b39bdcd9b60a7d071e5fb93e3bf Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 13 Sep 2021 16:48:41 +0200 Subject: [PATCH] radv/llvm: fix vertex input fetches with 16-bit floats Not ideal but ac/llvm and RADV works with integers, so passing a 16-bit float type would break more than it helps. Fixes a few CTS with 16-bit float IO. Fixes: 3fb229e010f ("ac,radeonsi: load VS inputs at the call site of nir_intrinsic_load_input") Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_nir_to_llvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 2990e7c3c05..c9d922e4af9 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -790,7 +790,7 @@ load_vs_input(struct radv_shader_context *ctx, unsigned driver_location, LLVMTyp for (unsigned chan = 0; chan < 4; chan++) { LLVMValueRef llvm_chan = LLVMConstInt(ctx->ac.i32, chan, false); out[chan] = LLVMBuildExtractElement(ctx->ac.builder, input, llvm_chan, ""); - if (dest_type == ctx->ac.f16) { + if (dest_type == ctx->ac.i16 && is_float) { out[chan] = LLVMBuildBitCast(ctx->ac.builder, out[chan], ctx->ac.f32, ""); out[chan] = LLVMBuildFPTrunc(ctx->ac.builder, out[chan], ctx->ac.f16, ""); } @@ -800,7 +800,7 @@ load_vs_input(struct radv_shader_context *ctx, unsigned driver_location, LLVMTyp for (unsigned chan = 0; chan < 4; chan++) { out[chan] = ac_to_integer(&ctx->ac, out[chan]); - if (dest_type == ctx->ac.i16) + if (dest_type == ctx->ac.i16 && !is_float) out[chan] = LLVMBuildTrunc(ctx->ac.builder, out[chan], ctx->ac.i16, ""); } }