[2/3] radv: scan if shaders use derivatives texture instructions

Submitted by Samuel Pitoiset on May 10, 2018, 9:43 a.m.

Details

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

Not browsing as part of any series.

Commit Message

Samuel Pitoiset May 10, 2018, 9:43 a.m.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
---
 src/amd/vulkan/radv_shader.h      |  1 +
 src/amd/vulkan/radv_shader_info.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h
index c28407352a..f8826f41ef 100644
--- a/src/amd/vulkan/radv_shader.h
+++ b/src/amd/vulkan/radv_shader.h
@@ -160,6 +160,7 @@  struct radv_shader_info {
 		bool prim_id_input;
 		bool layer_input;
 		bool uses_kill;
+		bool uses_derivatives;
 	} ps;
 	struct {
 		bool uses_grid_size;
diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c
index 4e6dbea5ac..81b763bc23 100644
--- a/src/amd/vulkan/radv_shader_info.c
+++ b/src/amd/vulkan/radv_shader_info.c
@@ -263,6 +263,34 @@  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_shader *nir, const nir_alu_instr *instr,
+		struct radv_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
@@ -277,6 +305,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, nir_instr_as_alu(instr), info);
+			break;
 		default:
 			break;
 		}