diff options
author | Brian Paul <[email protected]> | 2013-02-01 11:16:22 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2013-02-04 09:33:44 -0700 |
commit | 2d367e40d98b4084a28e4c6a97ffd234984f9eca (patch) | |
tree | 7a7bc8faf7ef11933ea9f933f45cc27864184e0f /src/gallium/auxiliary/gallivm | |
parent | ad30e4545b4f8b9cbcd0223266a2a461290f4143 (diff) |
gallivm: implement support for SQRT opcode
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_limits.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 33 |
3 files changed, 37 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h b/src/gallium/auxiliary/gallivm/lp_bld_limits.h index 30bed1ba31f..29bb9e3974f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h @@ -110,6 +110,8 @@ gallivm_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/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 489884906cc..f9bd2c68985 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -309,6 +309,8 @@ struct lp_build_tgsi_context * should compute 1 / sqrt (src0.x) */ struct lp_build_tgsi_action rsq_action; + struct lp_build_tgsi_action sqrt_action; + const struct tgsi_shader_info *info; lp_build_emit_fetch_fn emit_fetch_funcs[TGSI_FILE_COUNT]; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c index 8159bebc89b..41ddd9923f4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c @@ -648,6 +648,26 @@ const struct lp_build_tgsi_action rsq_action = { }; +/* TGSI_OPCODE_SQRT */ + +static void +sqrt_emit( + const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + if (bld_base->sqrt_action.emit) { + bld_base->sqrt_action.emit(&bld_base->sqrt_action, bld_base, emit_data); + } else { + emit_data->output[emit_data->chan] = bld_base->base.undef; + } +} + +const struct lp_build_tgsi_action sqrt_action = { + scalar_unary_fetch_args, /* fetch_args */ + sqrt_emit /* emit */ +}; + /* TGSI_OPCODE_SCS */ static void scs_emit( @@ -839,6 +859,7 @@ lp_set_default_actions(struct lp_build_tgsi_context * bld_base) bld_base->op_actions[TGSI_OPCODE_LIT] = lit_action; bld_base->op_actions[TGSI_OPCODE_LOG] = log_action; bld_base->op_actions[TGSI_OPCODE_RSQ] = rsq_action; + bld_base->op_actions[TGSI_OPCODE_SQRT] = sqrt_action; bld_base->op_actions[TGSI_OPCODE_POW] = pow_action; bld_base->op_actions[TGSI_OPCODE_SCS] = scs_action; bld_base->op_actions[TGSI_OPCODE_XPD] = xpd_action; @@ -1322,6 +1343,17 @@ recip_sqrt_emit_cpu( emit_data->args[0]); } +static void +sqrt_emit_cpu( + const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + emit_data->output[emit_data->chan] = lp_build_sqrt(&bld_base->base, + emit_data->args[0]); +} + + /* TGSI_OPCODE_ROUND (CPU Only) */ static void round_emit_cpu( @@ -1665,6 +1697,7 @@ lp_set_default_actions_cpu( bld_base->op_actions[TGSI_OPCODE_TRUNC].emit = trunc_emit_cpu; bld_base->rsq_action.emit = recip_sqrt_emit_cpu; + bld_base->sqrt_action.emit = sqrt_emit_cpu; bld_base->op_actions[TGSI_OPCODE_UADD].emit = uadd_emit_cpu; bld_base->op_actions[TGSI_OPCODE_UDIV].emit = udiv_emit_cpu; |