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: 3fb229e010 ("ac,radeonsi: load VS inputs at the call site of nir_intrinsic_load_input")
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/12835>
This commit is contained in:
Samuel Pitoiset 2021-09-13 16:48:41 +02:00 committed by Marge Bot
parent 7d5aea9edf
commit 3a26dfe761

View file

@ -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, "");
}
}