[PATCH 3/9] d3dx9: Add 'asin' preshader opcode.
Paul Gofman
gofmanp at gmail.com
Mon May 8 10:39:37 CDT 2017
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
dlls/d3dx9_36/preshader.c | 25 +++++++++++++++++++++++++
dlls/d3dx9_36/tests/effect.c | 2 ++
2 files changed, 27 insertions(+)
diff --git a/dlls/d3dx9_36/preshader.c b/dlls/d3dx9_36/preshader.c
index b442581..4aeb53f 100644
--- a/dlls/d3dx9_36/preshader.c
+++ b/dlls/d3dx9_36/preshader.c
@@ -37,6 +37,7 @@ enum pres_ops
PRESHADER_OP_RSQ,
PRESHADER_OP_SIN,
PRESHADER_OP_COS,
+ PRESHADER_OP_ASIN,
PRESHADER_OP_MIN,
PRESHADER_OP_MAX,
PRESHADER_OP_LT,
@@ -51,6 +52,28 @@ enum pres_ops
typedef double (*pres_op_func)(double *args, int n);
+/* is_nan() does not work (by design) if compiled with gcc -ffinite-math-only option which is implied by
+ * -ffast_math. */
+static BOOL pres_is_nan(double v)
+{
+ return (*(ULONG64 *)&v & 0x7ff8000000000000) == 0x7ff8000000000000;
+}
+
+static double to_signed_nan(double v)
+{
+ static const union
+ {
+ ULONG64 ulong64_value;
+ double double_value;
+ }
+ signed_nan =
+ {
+ 0xfff8000000000000
+ };
+
+ return pres_is_nan(v) ? signed_nan.double_value : v;
+}
+
static double pres_mov(double *args, int n) {return args[0];}
static double pres_add(double *args, int n) {return args[0] + args[1];}
static double pres_mul(double *args, int n) {return args[0] * args[1];}
@@ -106,6 +129,7 @@ static double pres_log(double *args, int n)
else
return log2(v);
}
+static double pres_asin(double *args, int n) {return to_signed_nan(asin(args[0]));}
#define PRES_OPCODE_MASK 0x7ff00000
#define PRES_OPCODE_SHIFT 20
@@ -139,6 +163,7 @@ static const struct op_info pres_op_info[] =
{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 */
+ {0x10a, "asin", 1, 0, pres_asin}, /* PRESHADER_OP_ASIN */
{0x200, "min", 2, 0, pres_min}, /* PRESHADER_OP_MIN */
{0x201, "max", 2, 0, pres_max}, /* PRESHADER_OP_MAX */
{0x202, "lt", 2, 0, pres_lt }, /* PRESHADER_OP_LT */
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c
index 6c9e75c..741ffdd 100644
--- a/dlls/d3dx9_36/tests/effect.c
+++ b/dlls/d3dx9_36/tests/effect.c
@@ -4556,6 +4556,8 @@ static void test_effect_preshader_ops(IDirect3DDevice9 *device)
{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}},
+ {"asin", 0x10a00001, 1, {0xbe9c00ad, 0xffc00000, 0xffc00000, 0xffc00000},
+ {-0.3f, 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}},
};
--
2.9.3
More information about the wine-patches
mailing list