From: Alejandro PiƱeiro Date: Wed, 22 Apr 2020 21:32:47 +0000 (+0200) Subject: nir: add nir_tex_instr_need_sampler helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9fd180394bddbb2abd7edb39852b1419249be450;p=mesa.git 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: --- 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) {