From 70f49c78cc73be0dfe96fbc68bfc07e17466db39 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 10 Jul 2023 15:39:35 +1000 Subject: [PATCH] llvmpipe/linear/tgsi: calculate num_texs properly for nir. This is a bit hacky, but it does the right thing and counts the number of textures instructions so the linear path can work for multiple textures. Reviewed-by: Brian Paul Part-of: --- src/gallium/auxiliary/nir/nir_to_tgsi_info.c | 2 ++ src/gallium/drivers/llvmpipe/lp_state_fs.c | 1 + src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c | 3 +++ 3 files changed, 6 insertions(+) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c index 72d87a8ef3f..d8d5d0e16d8 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c @@ -193,6 +193,8 @@ static void scan_instruction(const struct nir_shader *nir, switch (tex->op) { case nir_texop_tex: + info->opcode_count[TGSI_OPCODE_TEX]++; + FALLTHROUGH; case nir_texop_txb: case nir_texop_lod: info->uses_derivatives = true; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index f6143aaee54..eddfadd81bd 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -3992,6 +3992,7 @@ llvmpipe_create_fs_state(struct pipe_context *pipe, NIR_PASS_V(nir, nir_lower_fragcolor, nir->info.fs.color_is_dual_source ? 1 : 8); nir_tgsi_scan_shader(nir, &shader->info.base, true); + shader->info.num_texs = shader->info.base.opcode_count[TGSI_OPCODE_TEX]; } shader->draw_data = draw_create_fragment_shader(llvmpipe->draw, templ); diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c b/src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c index 574a287a07a..88f06f7cb32 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c @@ -512,10 +512,13 @@ static bool llvmpipe_nir_is_linear_compat(struct nir_shader *shader, struct lp_tgsi_info *info) { + int num_tex = info->num_texs; + info->num_texs = 0; nir_foreach_function_impl(impl, shader) { if (!llvmpipe_nir_fn_is_linear_compat(shader, impl, info)) return false; } + info->num_texs = num_tex; return true; }