d3dx9: Add 'div' 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-19 14:56:37 +03:00 committed by Alexandre Julliard
parent 2f47898953
commit cd62062673
2 changed files with 8 additions and 0 deletions

View File

@ -47,6 +47,7 @@ enum pres_ops
PRESHADER_OP_ADD, PRESHADER_OP_ADD,
PRESHADER_OP_MUL, PRESHADER_OP_MUL,
PRESHADER_OP_ATAN2, PRESHADER_OP_ATAN2,
PRESHADER_OP_DIV,
PRESHADER_OP_CMP, PRESHADER_OP_CMP,
PRESHADER_OP_DOT, PRESHADER_OP_DOT,
PRESHADER_OP_DOTSWIZ6, PRESHADER_OP_DOTSWIZ6,
@ -134,6 +135,10 @@ static double pres_acos(double *args, int n) {return to_signed_nan(acos(args[0])
static double pres_atan(double *args, int n) {return atan(args[0]);} static double pres_atan(double *args, int n) {return atan(args[0]);}
static double pres_atan2(double *args, int n) {return atan2(args[0], args[1]);} static double pres_atan2(double *args, int n) {return atan2(args[0], args[1]);}
/* According to the test results 'div' operation always returns 0. Compiler does not seem to ever
* generate it, using rcp + mul instead, so probably it is not implemented in native d3dx. */
static double pres_div(double *args, int n) {return 0.0;}
#define PRES_OPCODE_MASK 0x7ff00000 #define PRES_OPCODE_MASK 0x7ff00000
#define PRES_OPCODE_SHIFT 20 #define PRES_OPCODE_SHIFT 20
#define PRES_SCALAR_FLAG 0x80000000 #define PRES_SCALAR_FLAG 0x80000000
@ -176,6 +181,7 @@ static const struct op_info pres_op_info[] =
{0x204, "add", 2, 0, pres_add}, /* PRESHADER_OP_ADD */ {0x204, "add", 2, 0, pres_add}, /* PRESHADER_OP_ADD */
{0x205, "mul", 2, 0, pres_mul}, /* PRESHADER_OP_MUL */ {0x205, "mul", 2, 0, pres_mul}, /* PRESHADER_OP_MUL */
{0x206, "atan2", 2, 0, pres_atan2}, /* PRESHADER_OP_ATAN2 */ {0x206, "atan2", 2, 0, pres_atan2}, /* PRESHADER_OP_ATAN2 */
{0x208, "div", 2, 0, pres_div}, /* PRESHADER_OP_DIV */
{0x300, "cmp", 3, 0, pres_cmp}, /* PRESHADER_OP_CMP */ {0x300, "cmp", 3, 0, pres_cmp}, /* PRESHADER_OP_CMP */
{0x500, "dot", 2, 1, pres_dot}, /* PRESHADER_OP_DOT */ {0x500, "dot", 2, 1, pres_dot}, /* PRESHADER_OP_DOT */
{0x70e, "d3ds_dotswiz", 6, 0, pres_dotswiz6}, /* PRESHADER_OP_DOTSWIZ6 */ {0x70e, "d3ds_dotswiz", 6, 0, pres_dotswiz6}, /* PRESHADER_OP_DOTSWIZ6 */

View File

@ -4566,6 +4566,8 @@ static void test_effect_preshader_ops(IDirect3DDevice9 *device)
{-0.3f, 0.0f, -0.0f, NAN}, {0.0f, -0.0f, 0.0f, 1.0f}}, {-0.3f, 0.0f, -0.0f, NAN}, {0.0f, -0.0f, 0.0f, 1.0f}},
{"atan2 test #2", 0x20600004, 2, {0xbfc90fdb, 0, 0xc0490fdb, 0}, {"atan2 test #2", 0x20600004, 2, {0xbfc90fdb, 0, 0xc0490fdb, 0},
{-0.3f, 0.0f, -0.0f, -0.0f}, {-0.0f, 0.0f, -0.0f, 1.0f}}, {-0.3f, 0.0f, -0.0f, -0.0f}, {-0.0f, 0.0f, -0.0f, 1.0f}},
{"div", 0x20800004, 2, {0, 0, 0, 0},
{-0.3f, 0.0f, -2.2f, NAN}, {0.0f, -0.0f, -3.0f, 1.0f}},
{"0 * INF", 0x20500004, 2, {0xffc00000, 0xffc00000, 0xc0d33334, 0x7f800000}, {"0 * INF", 0x20500004, 2, {0xffc00000, 0xffc00000, 0xc0d33334, 0x7f800000},
{0.0f, -0.0f, -2.2f, 3.402823466e+38f}, {INFINITY, INFINITY, 3.0f, 4.0f}}, {0.0f, -0.0f, -2.2f, 3.402823466e+38f}, {INFINITY, INFINITY, 3.0f, 4.0f}},
}; };