[RFC,7/9] ac/shader: scan if shaders use derivatives texture instructions

Submitted by Samuel Pitoiset on March 8, 2018, 2:08 p.m.

Details

Message ID 20180308140811.8538-7-samuel.pitoiset@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Samuel Pitoiset March 8, 2018, 2:08 p.m.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
---
 src/amd/common/ac_shader_info.c | 30 ++++++++++++++++++++++++++++++
 src/amd/common/ac_shader_info.h |  1 +
 2 files changed, 31 insertions(+)

Patch hide | download patch | download mbox

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;