Commit 6cb65804 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3d10/effect: Add 'div' instruction support for expressions.

parent 08e8f284
......@@ -294,6 +294,15 @@ static void pres_mul(float **args, unsigned int n, const struct preshader_instr
retval[i] = args[0][instr->scalar ? 0 : i] * args[1][i];
}
static void pres_div(float **args, unsigned int n, const struct preshader_instr *instr)
{
float *retval = args[2];
unsigned int i;
for (i = 0; i < instr->comp_count; ++i)
retval[i] = args[0][instr->scalar ? 0 : i] / args[1][i];
}
struct preshader_op_info
{
int opcode;
......@@ -312,6 +321,7 @@ static const struct preshader_op_info preshader_ops[] =
{ 0x201, "max", pres_max },
{ 0x204, "add", pres_add },
{ 0x205, "mul", pres_mul },
{ 0x208, "div", pres_div },
};
static int __cdecl preshader_op_compare(const void *a, const void *b)
......
......@@ -8167,13 +8167,17 @@ technique10 tech
{
SetBlendState( NULL, max(g_var.x, g_var2), 0 );
}
pass p5
{
SetBlendState( NULL, g_var.x / g_var, 0 );
}
}
#endif
static DWORD fx_test_value_expression[] =
{
0x43425844, 0xf580dcc6, 0xa9d229ae, 0x14b1f1d5, 0x3c8c456c, 0x00000001, 0x00000c34, 0x00000001,
0x00000024, 0x30315846, 0x00000c08, 0xfeff1001, 0x00000001, 0x00000002, 0x00000001, 0x00000000,
0x00000000, 0x00000000, 0x00000001, 0x00000a0c, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x43425844, 0xb3aa52e8, 0x866f7138, 0xbdef210c, 0xdf2ba297, 0x00000001, 0x00000d87, 0x00000001,
0x00000024, 0x30315846, 0x00000d5b, 0xfeff1001, 0x00000001, 0x00000002, 0x00000001, 0x00000000,
0x00000000, 0x00000000, 0x00000001, 0x00000b23, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x6f6c4724,
0x736c6162, 0x6f6c6600, 0x00347461, 0x0000000d, 0x00000001, 0x00000000, 0x00000010, 0x00000010,
0x00000010, 0x0000210a, 0x61765f67, 0x5f670072, 0x32726176, 0x70654400, 0x74536874, 0x69636e65,
......@@ -8255,20 +8259,31 @@ static DWORD fx_test_value_expression[] =
0x00000004, 0x00000000, 0x434c5846, 0x0000003c, 0x00000001, 0xa0100004, 0x00000002, 0x00000000,
0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000004, 0x00000000, 0x00000004, 0x00000000,
0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff, 0x00000001, 0x00000002, 0x00000000, 0x00000001, 0x00000002,
0x00000000, 0x00000004, 0x00000020, 0x00000000, 0x00000002, 0xffffffff, 0x00000000, 0x00000030,
0x00000014, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000036, 0x00000014,
0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x0000006b, 0x0000004f, 0x00000000,
0xffffffff, 0x00000001, 0x00000019, 0x00000000, 0x00000006, 0x00000074, 0x00000000, 0x00000164,
0x00000005, 0x00000000, 0x00000169, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006,
0x0000016c, 0x0000000b, 0x00000000, 0x00000001, 0x000003b4, 0x00000002, 0x00000000, 0x00000001,
0x000003c0, 0x000003cc, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x000003cf,
0x0000000b, 0x00000000, 0x00000001, 0x00000523, 0x00000002, 0x00000000, 0x00000001, 0x0000052f,
0x0000053b, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x0000053e, 0x0000000b,
0x00000000, 0x00000001, 0x0000076e, 0x00000002, 0x00000000, 0x00000001, 0x0000077a, 0x00000786,
0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00000789, 0x0000000b, 0x00000000,
0x00000001, 0x000008b1, 0x00000002, 0x00000000, 0x00000001, 0x000008bd, 0x000008c9, 0x00000003,
0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x000008cc, 0x0000000b, 0x00000000, 0x00000001,
0x000009f4, 0x00000002, 0x00000000, 0x00000001, 0x00000a00,
0x00000000, 0xf8003570, 0x44000000, 0x93434258, 0x0bf74bf8, 0x9e3d094d, 0xfff013f9, 0x0199d86f,
0xf8000000, 0x03000000, 0x2c000000, 0xa8000000, 0xb4000000, 0x43000000, 0x74424154, 0x1c000000,
0x4b000000, 0x00000000, 0x01465804, 0x1c000000, 0x00000000, 0x48000001, 0x30000000, 0x02000000,
0x01000000, 0x38000000, 0x00000000, 0x67000000, 0x7261765f, 0x01abab00, 0x01000300, 0x01000400,
0x00000000, 0x74000000, 0x694d0078, 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320,
0x20726564, 0x706d6f43, 0x72656c69, 0x2e303120, 0x43ab0031, 0x0434494c, 0x00000000, 0x46000000,
0x3c434c58, 0x01000000, 0x04000000, 0x02a08000, 0x00000000, 0x02000000, 0x00000000, 0x00000000,
0x02000000, 0x00000000, 0x00000000, 0x04000000, 0x00000000, 0xf0000000, 0x0ff0f0f0, 0xff0f0f0f,
0x010000ff, 0x02000000, 0x00000000, 0x01000000, 0x02000000, 0x00000000, 0x04000000, 0x20000000,
0x00000000, 0x02000000, 0xff000000, 0x00ffffff, 0x30000000, 0x14000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x36000000, 0x14000000, 0x00000000, 0x10000000, 0x00000000,
0x00000000, 0x00000000, 0x6b000000, 0x4f000000, 0x00000000, 0xff000000, 0x01ffffff, 0x19000000,
0x00000000, 0x06000000, 0x74000000, 0x00000000, 0x64000000, 0x06000001, 0x00000000, 0x69000000,
0x03000001, 0x00000000, 0x0a000000, 0x00000000, 0x06000000, 0x6c000000, 0x0b000001, 0x00000000,
0x01000000, 0xb4000000, 0x02000003, 0x00000000, 0x01000000, 0xc0000000, 0xcc000003, 0x03000003,
0x00000000, 0x0a000000, 0x00000000, 0x06000000, 0xcf000000, 0x0b000003, 0x00000000, 0x01000000,
0x23000000, 0x02000005, 0x00000000, 0x01000000, 0x2f000000, 0x3b000005, 0x03000005, 0x00000000,
0x0a000000, 0x00000000, 0x06000000, 0x3e000000, 0x0b000005, 0x00000000, 0x01000000, 0x6e000000,
0x02000007, 0x00000000, 0x01000000, 0x7a000000, 0x86000007, 0x03000007, 0x00000000, 0x0a000000,
0x00000000, 0x06000000, 0x89000000, 0x0b000007, 0x00000000, 0x01000000, 0xb1000000, 0x02000008,
0x00000000, 0x01000000, 0xbd000000, 0xc9000008, 0x03000008, 0x00000000, 0x0a000000, 0x00000000,
0x06000000, 0xcc000000, 0x0b000008, 0x00000000, 0x01000000, 0xf4000000, 0x02000009, 0x00000000,
0x01000000, 0x00000000, 0x0c00000a, 0x0300000a, 0x00000000, 0x0a000000, 0x00000000, 0x06000000,
0x0f000000, 0x0b00000a, 0x00000000, 0x01000000, 0x0b000000, 0x0200000b, 0x00000000, 0x01000000,
0x17000000, 0x0000000b,
};
static void test_effect_value_expression(void)
......@@ -8353,6 +8368,25 @@ static void test_effect_value_expression(void)
ok(blend_factor[3] == 1.0f, "Got unexpected blend_factor[3] %.8e.\n", blend_factor[3]);
ok(!sample_mask, "Got unexpected sample_mask %#x.\n", sample_mask);
/* div */
pass = t->lpVtbl->GetPassByName(t, "p5");
ok(pass->lpVtbl->IsValid(pass), "Expected valid pass.\n");
f[0] = 1.0f; f[1] = 2.0f; f[2] = 3.0f; f[3] = 4.0f;
hr = g_var->lpVtbl->SetFloatVector(g_var, f);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = pass->lpVtbl->Apply(pass, 0);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ID3D10Device_OMGetBlendState(device, &blend_state, blend_factor, &sample_mask);
ok(!blend_state, "Unexpected blend state %p.\n", blend_state);
ok(blend_factor[0] == 1.0f, "Got unexpected blend_factor[0] %.8e.\n", blend_factor[0]);
ok(blend_factor[1] == 1.0f / 2.0f, "Got unexpected blend_factor[1] %.8e.\n", blend_factor[1]);
ok(blend_factor[2] == 1.0f / 3.0f, "Got unexpected blend_factor[2] %.8e.\n", blend_factor[2]);
ok(blend_factor[3] == 1.0f / 4.0f, "Got unexpected blend_factor[3] %.8e.\n", blend_factor[3]);
ok(!sample_mask, "Got unexpected sample_mask %#x.\n", sample_mask);
/* Mutable state objects. */
v = effect->lpVtbl->GetVariableByName(effect, "ds_state");
ds = v->lpVtbl->AsDepthStencil(v);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment