From 52a050ea0ae0197529082dcbaee7353f10795b0c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 19 May 2020 12:18:52 +1000 Subject: [PATCH] llvmpipe: add support for indirect texture access. This hooks up the sampler switch statement generator to the llvmpipe sampler interface. Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/drivers/llvmpipe/lp_tex_sample.c | 25 ++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index d0e6d99082c..0b1d7198e8f 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -360,10 +360,27 @@ lp_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, return; } - lp_build_sample_soa(&sampler->dynamic_state.static_state[texture_index].texture_state, - &sampler->dynamic_state.static_state[sampler_index].sampler_state, - &sampler->dynamic_state.base, - gallivm, params); + if (params->texture_index_offset) { + struct lp_build_sample_array_switch switch_info; + memset(&switch_info, 0, sizeof(switch_info)); + LLVMValueRef unit = LLVMBuildAdd(gallivm->builder, params->texture_index_offset, + lp_build_const_int32(gallivm, texture_index), ""); + lp_build_sample_array_init_soa(&switch_info, gallivm, params, unit, + 0, sampler->nr_samplers); + + for (unsigned i = 0; i < sampler->nr_samplers; i++) { + lp_build_sample_array_case_soa(&switch_info, i, + &sampler->dynamic_state.static_state[i].texture_state, + &sampler->dynamic_state.static_state[i].sampler_state, + &sampler->dynamic_state.base); + } + lp_build_sample_array_fini_soa(&switch_info); + } else { + lp_build_sample_soa(&sampler->dynamic_state.static_state[texture_index].texture_state, + &sampler->dynamic_state.static_state[sampler_index].sampler_state, + &sampler->dynamic_state.base, + gallivm, params); + } } /** -- 2.30.2