diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 21f41def5be..2b9c391023a 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -225,6 +225,15 @@ static void pres_rcp(float **args, unsigned int n, const struct preshader_instr retval[i] = 1.0f / args[0][i]; } +static void pres_frc(float **args, unsigned int n, const struct preshader_instr *instr) +{ + float *retval = args[1]; + unsigned int i; + + for (i = 0; i < instr->comp_count; ++i) + retval[i] = args[0][i] - floor(args[0][i]); +} + static void pres_sin(float **args, unsigned int n, const struct preshader_instr *instr) { float *retval = args[1]; @@ -323,6 +332,7 @@ static const struct preshader_op_info preshader_ops[] = { { 0x101, "neg", pres_neg }, { 0x103, "rcp", pres_rcp }, + { 0x104, "frc", pres_frc }, { 0x108, "sin", pres_sin }, { 0x109, "cos", pres_cos }, { 0x133, "ftou", pres_ftou }, diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index bdaf07be434..a2892efec70 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -8175,13 +8175,17 @@ technique10 tech { SetBlendState( NULL, 1.0f / g_var, 0 ); } + pass p7 + { + SetBlendState( NULL, frac(g_var), 0 ); + } } #endif static DWORD fx_test_value_expression[] = { - 0x43425844, 0xd2081c75, 0x0e089a32, 0xcda030e3, 0xc28f5c06, 0x00000001, 0x00000f2e, 0x00000001, - 0x00000024, 0x30315846, 0x00000f02, 0xfeff1001, 0x00000001, 0x00000002, 0x00000001, 0x00000000, - 0x00000000, 0x00000000, 0x00000001, 0x00000c8e, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x43425844, 0x52c4c6e1, 0x3efe62d7, 0xce564377, 0x35213200, 0x00000001, 0x00001075, 0x00000001, + 0x00000024, 0x30315846, 0x00001049, 0xfeff1001, 0x00000001, 0x00000002, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x00000d99, 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, @@ -8283,26 +8287,41 @@ static DWORD fx_test_value_expression[] = 0x00010000, 0x00011030, 0x00000000, 0x00020000, 0x00020000, 0x00000000, 0x00040000, 0x00020000, 0x00010000, 0x00011030, 0x00000000, 0x00020000, 0x00030000, 0x00000000, 0x00040000, 0x00030000, 0xf0f00000, 0x0f0ff0f0, 0xffff0f0f, 0x00010000, 0x00020000, 0x00000000, 0x00010000, 0x00020000, - 0x00000000, 0x00040000, 0x00200000, 0x00000000, 0x00020000, 0xffff0000, 0x0000ffff, 0x00300000, - 0x00140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00360000, 0x00140000, - 0x00000000, 0x00100000, 0x00000000, 0x00000000, 0x00000000, 0x006b0000, 0x004f0000, 0x00000000, - 0xffff0000, 0x0001ffff, 0x00190000, 0x00000000, 0x00060000, 0x00740000, 0x00000000, 0x01640000, - 0x00070000, 0x00000000, 0x01690000, 0x00030000, 0x00000000, 0x000a0000, 0x00000000, 0x00060000, - 0x016c0000, 0x000b0000, 0x00000000, 0x00010000, 0x03b40000, 0x00020000, 0x00000000, 0x00010000, - 0x03c00000, 0x03cc0000, 0x00030000, 0x00000000, 0x000a0000, 0x00000000, 0x00060000, 0x03cf0000, - 0x000b0000, 0x00000000, 0x00010000, 0x05230000, 0x00020000, 0x00000000, 0x00010000, 0x052f0000, - 0x053b0000, 0x00030000, 0x00000000, 0x000a0000, 0x00000000, 0x00060000, 0x053e0000, 0x000b0000, - 0x00000000, 0x00010000, 0x076e0000, 0x00020000, 0x00000000, 0x00010000, 0x077a0000, 0x07860000, - 0x00030000, 0x00000000, 0x000a0000, 0x00000000, 0x00060000, 0x07890000, 0x000b0000, 0x00000000, - 0x00010000, 0x08b10000, 0x00020000, 0x00000000, 0x00010000, 0x08bd0000, 0x08c90000, 0x00030000, - 0x00000000, 0x000a0000, 0x00000000, 0x00060000, 0x08cc0000, 0x000b0000, 0x00000000, 0x00010000, - 0x09f40000, 0x00020000, 0x00000000, 0x00010000, 0x0a000000, 0x0a0c0000, 0x00030000, 0x00000000, - 0x000a0000, 0x00000000, 0x00060000, 0x0a0f0000, 0x000b0000, 0x00000000, 0x00010000, 0x0b0b0000, - 0x00020000, 0x00000000, 0x00010000, 0x0b170000, 0x0b230000, 0x00030000, 0x00000000, 0x000a0000, - 0x00000000, 0x00060000, 0x0b260000, 0x000b0000, 0x00000000, 0x00010000, 0x0c760000, 0x00020000, - 0x00000000, 0x00010000, 0x0c820000, 0x00000000, + 0x00000000, 0x37700000, 0x0000ec00, 0x42584400, 0x67aa4243, 0xe24a7796, 0x86419cce, 0xdf743a20, + 0x000001e1, 0x0000ec00, 0x00000300, 0x00002c00, 0x0000a800, 0x0000b400, 0x41544300, 0x00007442, + 0x00001c00, 0x00004b00, 0x58040000, 0x00000146, 0x00001c00, 0x00010000, 0x00004800, 0x00003000, + 0x00000200, 0x00000100, 0x00003800, 0x00000000, 0x765f6700, 0xab007261, 0x030001ab, 0x04000100, + 0x00000100, 0x00000000, 0x00787400, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, + 0x65646168, 0x6f432072, 0x6c69706d, 0x31207265, 0x00312e30, 0x494c43ab, 0x00000434, 0x00000000, + 0x4c584600, 0x00003043, 0x00000100, 0x40000400, 0x00000110, 0x00000000, 0x00000200, 0x00000000, + 0x00000000, 0x00000400, 0x00000000, 0xf0f0f000, 0x0f0f0ff0, 0x00ffff0f, 0x00000100, 0x00000200, + 0x00000000, 0x00000100, 0x00000200, 0x00000000, 0x00000400, 0x00002000, 0x00000000, 0x00000200, + 0xffffff00, 0x000000ff, 0x00003000, 0x00001400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00003600, 0x00001400, 0x00000000, 0x00001000, 0x00000000, 0x00000000, 0x00000000, + 0x00006b00, 0x00004f00, 0x00000000, 0xffffff00, 0x000001ff, 0x00001900, 0x00000000, 0x00000600, + 0x00007400, 0x00000000, 0x00016400, 0x00000800, 0x00000000, 0x00016900, 0x00000300, 0x00000000, + 0x00000a00, 0x00000000, 0x00000600, 0x00016c00, 0x00000b00, 0x00000000, 0x00000100, 0x0003b400, + 0x00000200, 0x00000000, 0x00000100, 0x0003c000, 0x0003cc00, 0x00000300, 0x00000000, 0x00000a00, + 0x00000000, 0x00000600, 0x0003cf00, 0x00000b00, 0x00000000, 0x00000100, 0x00052300, 0x00000200, + 0x00000000, 0x00000100, 0x00052f00, 0x00053b00, 0x00000300, 0x00000000, 0x00000a00, 0x00000000, + 0x00000600, 0x00053e00, 0x00000b00, 0x00000000, 0x00000100, 0x00076e00, 0x00000200, 0x00000000, + 0x00000100, 0x00077a00, 0x00078600, 0x00000300, 0x00000000, 0x00000a00, 0x00000000, 0x00000600, + 0x00078900, 0x00000b00, 0x00000000, 0x00000100, 0x0008b100, 0x00000200, 0x00000000, 0x00000100, + 0x0008bd00, 0x0008c900, 0x00000300, 0x00000000, 0x00000a00, 0x00000000, 0x00000600, 0x0008cc00, + 0x00000b00, 0x00000000, 0x00000100, 0x0009f400, 0x00000200, 0x00000000, 0x00000100, 0x000a0000, + 0x000a0c00, 0x00000300, 0x00000000, 0x00000a00, 0x00000000, 0x00000600, 0x000a0f00, 0x00000b00, + 0x00000000, 0x00000100, 0x000b0b00, 0x00000200, 0x00000000, 0x00000100, 0x000b1700, 0x000b2300, + 0x00000300, 0x00000000, 0x00000a00, 0x00000000, 0x00000600, 0x000b2600, 0x00000b00, 0x00000000, + 0x00000100, 0x000c7600, 0x00000200, 0x00000000, 0x00000100, 0x000c8200, 0x000c8e00, 0x00000300, + 0x00000000, 0x00000a00, 0x00000000, 0x00000600, 0x000c9100, 0x00000b00, 0x00000000, 0x00000100, + 0x000d8100, 0x00000200, 0x00000000, 0x00000100, 0x000d8d00, 0x00000000, }; +static float get_frc(float v) +{ + return v - floor(v); +} + static void test_effect_value_expression(void) { ID3D10EffectVectorVariable *g_var, *g_var2; @@ -8423,6 +8442,25 @@ static void test_effect_value_expression(void) ok(blend_factor[3] == 1.0f / 5.0f, "Got unexpected blend_factor[3] %.8e.\n", blend_factor[3]); ok(!sample_mask, "Got unexpected sample_mask %#x.\n", sample_mask); + /* frc */ + pass = t->lpVtbl->GetPassByName(t, "p7"); + ok(pass->lpVtbl->IsValid(pass), "Expected valid pass.\n"); + + f[0] = 0.0f; f[1] = 3.1f; f[2] = -4.2f; f[3] = 0.1f; + 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] == get_frc(f[0]), "Got unexpected blend_factor[0] %.8e.\n", blend_factor[0]); + ok(blend_factor[1] == get_frc(f[1]), "Got unexpected blend_factor[1] %.8e.\n", blend_factor[1]); + ok(blend_factor[2] == get_frc(f[2]), "Got unexpected blend_factor[2] %.8e.\n", blend_factor[2]); + ok(blend_factor[3] == get_frc(f[3]), "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);