d3dx9: Add 'log' preshader opcode.

Signed-off-by: Paul Gofman <gofmanp@gmail.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2017-05-08 18:39:36 +03:00 committed by Alexandre Julliard
parent 6a06baee60
commit 651e8bfaee
2 changed files with 14 additions and 0 deletions

View File

@ -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 */

View File

@ -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}},
};