From 9fd180394bddbb2abd7edb39852b1419249be450 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alejandro=20Pi=C3=B1eiro?= Date: Wed, 22 Apr 2020 23:32:47 +0200 Subject: [PATCH] nir: add nir_tex_instr_need_sampler helper That is basically nir_tex_instr sampler_index documentation comment expressed as a helper. Reviewed-by: Eric Anholt Part-of: --- src/compiler/nir/nir.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 105e09347b5..04088fc99fa 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1949,6 +1949,30 @@ typedef struct { unsigned sampler_index; } nir_tex_instr; +/* + * Returns true if the texture operation requires a sampler as a general rule, + * see the documentation of sampler_index. + * + * Note that the specific hw/driver backend could require to a sampler + * object/configuration packet in any case, for some other reason. + */ +static inline bool +nir_tex_instr_need_sampler(const nir_tex_instr *instr) +{ + switch (instr->op) { + case nir_texop_txf: + case nir_texop_txf_ms: + case nir_texop_txs: + case nir_texop_lod: + case nir_texop_query_levels: + case nir_texop_texture_samples: + case nir_texop_samples_identical: + return false; + default: + return true; + } +} + static inline unsigned nir_tex_instr_dest_size(const nir_tex_instr *instr) { -- 2.30.2