[Mesa-dev] [FLAG-DAY-PREP 7/9] nir: use nir_tex_*_var() accessors
Rob Clark
robdclark at gmail.com
Thu Mar 15 14:28:06 UTC 2018
---
src/compiler/nir/nir_instr_set.c | 2 +-
src/compiler/nir/nir_lower_samplers.c | 6 ++++--
src/compiler/nir/nir_remove_dead_variables.c | 14 ++++++--------
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c
index 9cb9ed43e8b..efc9f973839 100644
--- a/src/compiler/nir/nir_instr_set.c
+++ b/src/compiler/nir/nir_instr_set.c
@@ -437,7 +437,7 @@ instr_can_rewrite(nir_instr *instr)
nir_tex_instr *tex = nir_instr_as_tex(instr);
/* Don't support un-lowered sampler derefs currently. */
- if (tex->texture || tex->sampler)
+ if (nir_tex_texture_var(tex) || nir_tex_sampler_var(tex))
return false;
return true;
diff --git a/src/compiler/nir/nir_lower_samplers.c b/src/compiler/nir/nir_lower_samplers.c
index 9aa4a9e967f..b0e7be17040 100644
--- a/src/compiler/nir/nir_lower_samplers.c
+++ b/src/compiler/nir/nir_lower_samplers.c
@@ -90,14 +90,16 @@ static bool
lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_program,
gl_shader_stage stage, nir_builder *b)
{
- if (instr->texture == NULL)
+ nir_variable *tex = nir_tex_texture_var(instr);
+
+ if (tex == NULL)
return false;
/* In GLSL, we only fill out the texture field. The sampler is inferred */
assert(instr->sampler == NULL);
instr->texture_index = 0;
- unsigned location = instr->texture->var->data.location;
+ unsigned location = tex->data.location;
unsigned array_elements = 1;
nir_ssa_def *indirect = NULL;
diff --git a/src/compiler/nir/nir_remove_dead_variables.c b/src/compiler/nir/nir_remove_dead_variables.c
index ebd56bc413c..24f7cdffca7 100644
--- a/src/compiler/nir/nir_remove_dead_variables.c
+++ b/src/compiler/nir/nir_remove_dead_variables.c
@@ -82,15 +82,13 @@ add_var_use_call(nir_call_instr *instr, struct set *live)
static void
add_var_use_tex(nir_tex_instr *instr, struct set *live)
{
- if (instr->texture != NULL) {
- nir_variable *var = instr->texture->var;
- _mesa_set_add(live, var);
- }
+ nir_variable *tex = nir_tex_texture_var(instr);
+ if (tex)
+ _mesa_set_add(live, tex);
- if (instr->sampler != NULL) {
- nir_variable *var = instr->sampler->var;
- _mesa_set_add(live, var);
- }
+ nir_variable *samp = nir_tex_sampler_var(instr);
+ if (samp)
+ _mesa_set_add(live, samp);
}
static void
--
2.14.3
More information about the mesa-dev
mailing list