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 <brianp@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24066>
This commit is contained in:
Dave Airlie 2023-07-10 15:39:35 +10:00 committed by Marge Bot
parent e43804ba65
commit 70f49c78cc
3 changed files with 6 additions and 0 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;
}