From ad30e4545b4f8b9cbcd0223266a2a461290f4143 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 1 Feb 2013 11:15:43 -0700 Subject: [PATCH] tgsi: add support for new SQRT opcode --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 14 ++++++++++++++ src/gallium/auxiliary/tgsi/tgsi_exec.h | 2 ++ src/gallium/auxiliary/tgsi/tgsi_info.c | 2 +- src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 9f226c4ec7d..1220478f9d2 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -342,6 +342,16 @@ micro_rsq(union tgsi_exec_channel *dst, dst->f[3] = 1.0f / sqrtf(fabsf(src->f[3])); } +static void +micro_sqrt(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src) +{ + dst->f[0] = sqrtf(fabsf(src->f[0])); + dst->f[1] = sqrtf(fabsf(src->f[1])); + dst->f[2] = sqrtf(fabsf(src->f[2])); + dst->f[3] = sqrtf(fabsf(src->f[3])); +} + static void micro_seq(union tgsi_exec_channel *dst, const union tgsi_exec_channel *src0, @@ -3562,6 +3572,10 @@ exec_instruction( exec_vector_trinary(mach, inst, micro_cnd, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; + case TGSI_OPCODE_SQRT: + exec_vector_unary(mach, inst, micro_sqrt, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); + break; + case TGSI_OPCODE_DP2A: exec_dp2a(mach, inst); break; diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index fbd28a24339..1a7d979ca21 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -441,6 +441,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param) return 1; case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: return PIPE_MAX_SAMPLERS; + case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: + return 1; default: return 0; } diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index 458bc69d169..94b6f60ca89 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -57,7 +57,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 1, 2, 0, 0, 0, 0, COMP, "SUB", TGSI_OPCODE_SUB }, { 1, 3, 0, 0, 0, 0, COMP, "LRP", TGSI_OPCODE_LRP }, { 1, 3, 0, 0, 0, 0, COMP, "CND", TGSI_OPCODE_CND }, - { 0, 0, 0, 0, 0, 0, NONE, "", 20 }, /* removed */ + { 1, 1, 0, 0, 0, 0, REPL, "SQRT", TGSI_OPCODE_SQRT }, { 1, 3, 0, 0, 0, 0, REPL, "DP2A", TGSI_OPCODE_DP2A }, { 0, 0, 0, 0, 0, 0, NONE, "", 22 }, /* removed */ { 0, 0, 0, 0, 0, 0, NONE, "", 23 }, /* removed */ diff --git a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h index 96b864f50d0..75e27a666f1 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h +++ b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h @@ -60,6 +60,7 @@ OP13(MAD) OP12(SUB) OP13(LRP) OP13(CND) +OP11(SQRT) OP13(DP2A) OP11(FRC) OP13(CLAMP) -- 2.30.2