[Mesa-dev] [RFC PATCH 7/9] ac/shader: scan if shaders use derivatives texture instructions
Samuel Pitoiset
samuel.pitoiset at gmail.com
Thu Mar 8 14:08:09 UTC 2018
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/amd/common/ac_shader_info.c | 30 ++++++++++++++++++++++++++++++
src/amd/common/ac_shader_info.h | 1 +
2 files changed, 31 insertions(+)
diff --git a/src/amd/common/ac_shader_info.c b/src/amd/common/ac_shader_info.c
index c495879280..55b87cb96a 100644
--- a/src/amd/common/ac_shader_info.c
+++ b/src/amd/common/ac_shader_info.c
@@ -183,6 +183,33 @@ gather_tex_info(const nir_shader *nir, const nir_tex_instr *instr,
mark_sampler_desc(instr->sampler->var, info);
if (instr->texture)
mark_sampler_desc(instr->texture->var, info);
+
+ switch (instr->op) {
+ case nir_texop_tex:
+ case nir_texop_txb:
+ case nir_texop_lod:
+ info->ps.uses_derivatives = true;
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+gather_alu_info(const nir_alu_instr *instr, struct ac_shader_info *info)
+{
+ switch (instr->op) {
+ case nir_op_fddx:
+ case nir_op_fddy:
+ case nir_op_fddx_fine:
+ case nir_op_fddy_fine:
+ case nir_op_fddx_coarse:
+ case nir_op_fddy_coarse:
+ info->ps.uses_derivatives = true;
+ break;
+ default:
+ break;
+ }
}
static void
@@ -197,6 +224,9 @@ gather_info_block(const nir_shader *nir, const nir_block *block,
case nir_instr_type_tex:
gather_tex_info(nir, nir_instr_as_tex(instr), info);
break;
+ case nir_instr_type_alu:
+ gather_alu_info(nir_instr_as_alu(instr), info);
+ break;
default:
break;
}
diff --git a/src/amd/common/ac_shader_info.h b/src/amd/common/ac_shader_info.h
index 8e1102c081..ce62865825 100644
--- a/src/amd/common/ac_shader_info.h
+++ b/src/amd/common/ac_shader_info.h
@@ -65,6 +65,7 @@ struct ac_shader_info {
bool uses_persp_center;
uint32_t flat_shaded_mask;
bool uses_kill;
+ bool uses_derivatives;
} ps;
struct {
bool uses_grid_size;
--
2.16.2
More information about the mesa-dev
mailing list