From 651e8bfaee90870d430a7fb045382a803037c260 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 8 May 2017 18:39:36 +0300 Subject: [PATCH] d3dx9: Add 'log' preshader opcode. Signed-off-by: Paul Gofman Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- dlls/d3dx9_36/preshader.c | 12 ++++++++++++ dlls/d3dx9_36/tests/effect.c | 2 ++ 2 files changed, 14 insertions(+) diff --git a/dlls/d3dx9_36/preshader.c b/dlls/d3dx9_36/preshader.c index a4e5e3a252a..fbd99ac58f9 100644 --- a/dlls/d3dx9_36/preshader.c +++ b/dlls/d3dx9_36/preshader.c @@ -33,6 +33,7 @@ enum pres_ops PRESHADER_OP_RCP, PRESHADER_OP_FRC, PRESHADER_OP_EXP, + PRESHADER_OP_LOG, PRESHADER_OP_RSQ, PRESHADER_OP_SIN, PRESHADER_OP_COS, @@ -95,6 +96,16 @@ static double pres_rsq(double *args, int n) return 1.0 / sqrt(v); } static double pres_exp(double *args, int n) {return pow(2.0, args[0]);} +static double pres_log(double *args, int n) +{ + double v; + + v = fabs(args[0]); + if (v == 0.0) + return 0.0; + else + return log2(v); +} #define PRES_OPCODE_MASK 0x7ff00000 #define PRES_OPCODE_SHIFT 20 @@ -124,6 +135,7 @@ static const struct op_info pres_op_info[] = {0x103, "rcp", 1, 0, pres_rcp}, /* PRESHADER_OP_RCP */ {0x104, "frc", 1, 0, pres_frc}, /* PRESHADER_OP_FRC */ {0x105, "exp", 1, 0, pres_exp}, /* PRESHADER_OP_EXP */ + {0x106, "log", 1, 0, pres_log}, /* PRESHADER_OP_LOG */ {0x107, "rsq", 1, 0, pres_rsq}, /* PRESHADER_OP_RSQ */ {0x108, "sin", 1, 0, pres_sin}, /* PRESHADER_OP_SIN */ {0x109, "cos", 1, 0, pres_cos}, /* PRESHADER_OP_COS */ diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 7b39e31195d..a1cdfc2c83f 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -4554,6 +4554,8 @@ static void test_effect_preshader_ops(IDirect3DDevice9 *device) { {"exp", 0x10500001, 1, {0x3f800000, 0x3f800000, 0x3e5edc66, 0x7f800000}, {0.0f, -0.0f, -2.2f, 3.402823466e+38f}, {1.0f, 2.0f, -3.0f, 4.0f}}, + {"log", 0x10600001, 1, {0, 0x40000000, 0x3f9199b7, 0x43000000}, + {0.0f, 4.0f, -2.2f, 3.402823466e+38f}, {1.0f, 2.0f, -3.0f, 4.0f}}, {"0 * INF", 0x20500004, 2, {0xffc00000, 0xffc00000, 0xc0d33334, 0x7f800000}, {0.0f, -0.0f, -2.2f, 3.402823466e+38f}, {INFINITY, INFINITY, 3.0f, 4.0f}}, };