From a0ce09b4b2a3063e49a02de3d12096cf462d10a3 Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Tue, 10 Jan 2017 15:35:27 +0100 Subject: amd/common: unify cube map coordinate handling between radeonsi and radv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code is taken from a combination of radv (for the more basic functions, to avoid gallivm dependencies) and radeonsi (for the new and improved derivative calculations). v2: add 0.5 offset to tex coords only after derivative calculation v3: - really only touch the first three coordinates - rebase on the removal of the 1.5 --> 0.5 offset change Reviewed-by: Bas Nieuwenhuizen (v2) Reviewed-by: Marek Olšák --- src/gallium/drivers/radeonsi/si_shader.c | 6 +++++- src/gallium/drivers/radeonsi/si_shader_internal.h | 2 ++ src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/gallium/drivers/radeonsi') diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 6f0f414cdad..c24d82ddaea 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -4606,7 +4606,11 @@ static void tex_fetch_args( target == TGSI_TEXTURE_CUBE_ARRAY || target == TGSI_TEXTURE_SHADOWCUBE || target == TGSI_TEXTURE_SHADOWCUBE_ARRAY) - si_prepare_cube_coords(bld_base, emit_data, coords, derivs); + ac_prepare_cube_coords(&ctx->ac, + opcode == TGSI_OPCODE_TXD, + target == TGSI_TEXTURE_CUBE_ARRAY || + target == TGSI_TEXTURE_SHADOWCUBE_ARRAY, + coords, derivs); if (opcode == TGSI_OPCODE_TXD) for (int i = 0; i < num_deriv_channels * 2; i++) diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h index 8d6a40b1644..6b3ac171f7a 100644 --- a/src/gallium/drivers/radeonsi/si_shader_internal.h +++ b/src/gallium/drivers/radeonsi/si_shader_internal.h @@ -28,6 +28,7 @@ #include "gallivm/lp_bld_init.h" #include "gallivm/lp_bld_tgsi.h" #include "tgsi/tgsi_parse.h" +#include "ac_llvm_util.h" #include #include @@ -48,6 +49,7 @@ struct si_llvm_flow; struct si_shader_context { struct lp_build_tgsi_soa_context soa; struct gallivm_state gallivm; + struct ac_llvm_context ac; struct si_shader *shader; struct si_screen *screen; diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c index 3e0f7c4f769..8c8b4266e12 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c @@ -1266,6 +1266,10 @@ void si_llvm_context_init(struct si_shader_context *ctx, ctx->gallivm.builder = lp_create_builder(ctx->gallivm.context, unsafe_fpmath); + ac_llvm_context_init(&ctx->ac, ctx->gallivm.context); + ctx->ac.module = ctx->gallivm.module; + ctx->ac.builder = ctx->gallivm.builder; + struct lp_build_tgsi_context *bld_base = &ctx->soa.bld_base; bld_base->info = info; -- cgit v1.2.3