From d3a584defec988faa09960adea90545399440827 Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Wed, 1 Jun 2016 13:17:29 +0200 Subject: tgsi/scan: add uses_derivatives (v2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v2: - TG4 does not calculate derivatives (Ilia) - also handle SAMPLE* instructions (Roland) Cc: 12.0 Reviewed-by: Marek Olšák (v1) Reviewed-by: Brian Paul (v1) Reviewed-by: Ilia Mirkin Reviewed-by: Roland Scheidegger --- src/gallium/auxiliary/tgsi/tgsi_scan.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/gallium/auxiliary/tgsi/tgsi_scan.c') diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c index 1baf031d73e..98d86fc37a6 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.c +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c @@ -68,6 +68,33 @@ is_texture_inst(unsigned opcode) tgsi_get_opcode_info(opcode)->is_tex); } + +/** + * Is the opcode an instruction which computes a derivative explicitly or + * implicitly? + */ +static bool +computes_derivative(unsigned opcode) +{ + if (tgsi_get_opcode_info(opcode)->is_tex) { + return opcode != TGSI_OPCODE_TG4 && + opcode != TGSI_OPCODE_TXD && + opcode != TGSI_OPCODE_TXF && + opcode != TGSI_OPCODE_TXL && + opcode != TGSI_OPCODE_TXL2 && + opcode != TGSI_OPCODE_TXQ && + opcode != TGSI_OPCODE_TXQ_LZ && + opcode != TGSI_OPCODE_TXQS; + } + + return opcode == TGSI_OPCODE_DDX || opcode == TGSI_OPCODE_DDX_FINE || + opcode == TGSI_OPCODE_DDY || opcode == TGSI_OPCODE_DDY_FINE || + opcode == TGSI_OPCODE_SAMPLE || + opcode == TGSI_OPCODE_SAMPLE_B || + opcode == TGSI_OPCODE_SAMPLE_C; +} + + static void scan_instruction(struct tgsi_shader_info *info, const struct tgsi_full_instruction *fullinst, @@ -263,6 +290,9 @@ scan_instruction(struct tgsi_shader_info *info, if (is_mem_inst) info->num_memory_instructions++; + if (computes_derivative(fullinst->Instruction.Opcode)) + info->uses_derivatives = true; + info->num_instructions++; } -- cgit v1.2.3