Mesa (main): ac: add per output is_16bit flag to ac_shader_abi
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 8 09:06:30 UTC 2022
Module: Mesa
Branch: main
Commit: 196c4ebe1a1f008c6a450ffc7155c7e793c60f4f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=196c4ebe1a1f008c6a450ffc7155c7e793c60f4f
Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date: Tue Jul 5 12:26:00 2022 +0200
ac: add per output is_16bit flag to ac_shader_abi
Outputs are always f32 except for FS that may use unpacked f16.
Store this information here to make it available to later processing.
Reviewed-by: Mihai Preda <mhpreda at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17361>
---
src/amd/llvm/ac_nir_to_llvm.c | 5 +++--
src/amd/llvm/ac_shader_abi.h | 2 ++
src/gallium/drivers/radeonsi/si_shader_llvm.c | 4 +++-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index 53f6242ae33..bd974d29816 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -5377,8 +5377,9 @@ void ac_handle_shader_output_decl(struct ac_llvm_context *ctx, struct ac_shader_
LLVMTypeRef type = is_16bit ? ctx->f16 : ctx->f32;
for (unsigned i = 0; i < attrib_count; ++i) {
for (unsigned chan = 0; chan < 4; chan++) {
- abi->outputs[ac_llvm_reg_index_soa(output_loc + i, chan)] =
- ac_build_alloca_undef(ctx, type, "");
+ int idx = ac_llvm_reg_index_soa(output_loc + i, chan);
+ abi->outputs[idx] = ac_build_alloca_undef(ctx, type, "");
+ abi->is_16bit[idx] = is_16bit;
}
}
}
diff --git a/src/amd/llvm/ac_shader_abi.h b/src/amd/llvm/ac_shader_abi.h
index ee9e17a88d0..390d694bf74 100644
--- a/src/amd/llvm/ac_shader_abi.h
+++ b/src/amd/llvm/ac_shader_abi.h
@@ -38,7 +38,9 @@
* radv to share a compiler backend.
*/
struct ac_shader_abi {
+ /* Each entry is a pointer to a f32 or a f16 value (only possible for FS) */
LLVMValueRef outputs[AC_LLVM_MAX_OUTPUTS * 4];
+ bool is_16bit[AC_LLVM_MAX_OUTPUTS * 4];
/* These input registers sometimes need to be fixed up. */
LLVMValueRef vertex_id;
diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c b/src/gallium/drivers/radeonsi/si_shader_llvm.c
index a02e1ace0e9..b6023f47241 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c
@@ -1062,8 +1062,10 @@ bool si_llvm_translate_nir(struct si_shader_context *ctx, struct si_shader *shad
nir_alu_type_get_type_size(ctx->shader->selector->info.output_type[i]) == 16)
type = ctx->ac.f16;
- for (unsigned j = 0; j < 4; j++)
+ for (unsigned j = 0; j < 4; j++) {
ctx->abi.outputs[i * 4 + j] = ac_build_alloca_undef(&ctx->ac, type, "");
+ ctx->abi.is_16bit[i * 4 + j] = type == ctx->ac.f16;
+ }
}
ac_nir_translate(&ctx->ac, &ctx->abi, &ctx->args, nir);
More information about the mesa-commit
mailing list