From 2861ce933b7485a69deb562728d8e88c79de97fc Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 29 Sep 2023 13:42:03 +0200 Subject: [PATCH] d3d10/effect: Add support for 'ceil' instruction. Signed-off-by: Nikolay Sivov --- dlls/d3d10/effect.c | 12 +++ dlls/d3d10/tests/effect.c | 173 +++++++++++++++++++++++++++----------- 2 files changed, 134 insertions(+), 51 deletions(-) diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 9f66645c0a1..e2e2066ac13 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -343,6 +343,17 @@ static void pres_ftob(float **args, unsigned int n, const struct preshader_instr } } +/* Only first source component is used. */ +static void pres_ceil(float **args, unsigned int n, const struct preshader_instr *instr) +{ + float value = ceilf(args[0][0]); + float *retval = args[1]; + unsigned int i; + + for (i = 0; i < instr->comp_count; ++i) + retval[i] = value; +} + static void pres_min(float **args, unsigned int n, const struct preshader_instr *instr) { float *retval = args[2]; @@ -622,6 +633,7 @@ static const struct preshader_op_info preshader_ops[] = { 0x131, "utof", pres_utof }, { 0x133, "ftou", pres_ftou }, { 0x137, "ftob", pres_ftob }, + { 0x13a, "ceil", pres_ceil }, { 0x200, "min", pres_min }, { 0x201, "max", pres_max }, { 0x204, "add", pres_add }, diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index b242c0f74cf..228ddda4487 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -8272,13 +8272,17 @@ technique10 tech { SetBlendState( NULL, g_var4.x >= g_var4.y ? 0 : (g_var4.y < g_var4.z ? 1 : 2), 0 ); } + pass p22 + { + SetBlendState( NULL, ceil(g_var), 0 ); + } } #endif static DWORD fx_test_value_expression[] = { - 0x43425844, 0x483c26a6, 0xa784dafb, 0x921ba9a9, 0x1d2bb725, 0x00000001, 0x00002e7c, 0x00000001, - 0x00000024, 0x30315846, 0x00002e50, 0xfeff1001, 0x00000001, 0x00000004, 0x00000001, 0x00000000, - 0x00000000, 0x00000000, 0x00000001, 0x00002820, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x43425844, 0x8fe0502a, 0x2ff204ae, 0xca809c53, 0x4027206e, 0x00000001, 0x00002fc4, 0x00000001, + 0x00000024, 0x30315846, 0x00002f98, 0xfeff1001, 0x00000001, 0x00000004, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x0000292c, 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, 0x746e6900, 0x003d0034, 0x00010000, @@ -8600,54 +8604,65 @@ static DWORD fx_test_value_expression[] = 0x00000002, 0x00000000, 0x00000007, 0x00000004, 0x00000000, 0x00000004, 0x00000002, 0x30100001, 0x00000003, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x00000000, 0x00000007, 0x00000004, 0x00000000, 0x00000004, 0x00000003, 0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff, - 0x00000001, 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000000, 0x00000004, 0x00000040, - 0x00000000, 0x00000004, 0xffffffff, 0x00000000, 0x00000030, 0x00000014, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000036, 0x00000014, 0x00000000, 0x00000010, 0x00000000, - 0x00000000, 0x00000000, 0x0000005e, 0x00000042, 0x00000000, 0x00000020, 0x00000000, 0x00000000, - 0x00000000, 0x00000087, 0x0000006b, 0x00000000, 0x00000030, 0x00000000, 0x00000000, 0x00000000, - 0x000000bc, 0x000000a0, 0x00000000, 0xffffffff, 0x00000001, 0x00000019, 0x00000000, 0x00000006, - 0x000000c5, 0x00000000, 0x000001b5, 0x00000016, 0x00000000, 0x000001ba, 0x00000003, 0x00000000, - 0x0000000a, 0x00000000, 0x00000006, 0x000001bd, 0x0000000b, 0x00000000, 0x00000001, 0x00000405, - 0x00000002, 0x00000000, 0x00000001, 0x00000411, 0x0000041d, 0x00000003, 0x00000000, 0x0000000a, - 0x00000000, 0x00000006, 0x00000420, 0x0000000b, 0x00000000, 0x00000001, 0x00000574, 0x00000002, - 0x00000000, 0x00000001, 0x00000580, 0x0000058c, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, - 0x00000006, 0x0000058f, 0x0000000b, 0x00000000, 0x00000001, 0x000007bf, 0x00000002, 0x00000000, - 0x00000001, 0x000007cb, 0x000007d7, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, - 0x000007da, 0x0000000b, 0x00000000, 0x00000001, 0x00000902, 0x00000002, 0x00000000, 0x00000001, - 0x0000090e, 0x0000091a, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x0000091d, - 0x0000000b, 0x00000000, 0x00000001, 0x00000a45, 0x00000002, 0x00000000, 0x00000001, 0x00000a51, - 0x00000a5d, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00000a60, 0x0000000b, - 0x00000000, 0x00000001, 0x00000b5c, 0x00000002, 0x00000000, 0x00000001, 0x00000b68, 0x00000b74, - 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00000b77, 0x0000000b, 0x00000000, - 0x00000001, 0x00000cc7, 0x00000002, 0x00000000, 0x00000001, 0x00000cd3, 0x00000cdf, 0x00000003, - 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00000ce2, 0x0000000b, 0x00000000, 0x00000001, - 0x00000dd2, 0x00000002, 0x00000000, 0x00000001, 0x00000dde, 0x00000dea, 0x00000003, 0x00000000, - 0x0000000a, 0x00000000, 0x00000006, 0x00000ded, 0x0000000b, 0x00000000, 0x00000001, 0x00000fe9, - 0x00000002, 0x00000000, 0x00000001, 0x00000ff5, 0x00001001, 0x00000003, 0x00000000, 0x0000000a, - 0x00000000, 0x00000006, 0x00001004, 0x0000000b, 0x00000000, 0x00000001, 0x00001180, 0x00000002, - 0x00000000, 0x00000001, 0x0000118c, 0x00001198, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, - 0x00000006, 0x0000119c, 0x0000000b, 0x00000000, 0x00000001, 0x0000136c, 0x00000002, 0x00000000, - 0x00000001, 0x00001378, 0x00001384, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, - 0x00001388, 0x0000000b, 0x00000000, 0x00000001, 0x00001504, 0x00000002, 0x00000000, 0x00000001, - 0x00001510, 0x0000151c, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00001520, - 0x0000000b, 0x00000000, 0x00000001, 0x0000169c, 0x00000002, 0x00000000, 0x00000001, 0x000016a8, - 0x000016b4, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x000016b8, 0x0000000b, - 0x00000000, 0x00000001, 0x00001834, 0x00000002, 0x00000000, 0x00000001, 0x00001840, 0x0000184c, - 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00001850, 0x0000000b, 0x00000000, - 0x00000001, 0x000019cc, 0x00000002, 0x00000000, 0x00000001, 0x000019d8, 0x000019e4, 0x00000003, - 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x000019e8, 0x0000000b, 0x00000000, 0x00000001, - 0x00001b38, 0x00000002, 0x00000000, 0x00000001, 0x00001b44, 0x00001b50, 0x00000003, 0x00000000, - 0x0000000a, 0x00000000, 0x00000006, 0x00001b54, 0x0000000b, 0x00000000, 0x00000001, 0x00001ca4, - 0x00000002, 0x00000000, 0x00000001, 0x00001cb0, 0x00001cbc, 0x00000003, 0x00000000, 0x0000000a, - 0x00000000, 0x00000006, 0x00001cc0, 0x0000000b, 0x00000000, 0x00000001, 0x00001e10, 0x00000002, - 0x00000000, 0x00000001, 0x00001e1c, 0x00001e28, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, - 0x00000006, 0x00001e2c, 0x0000000b, 0x00000000, 0x00000001, 0x00001fac, 0x00000002, 0x00000000, - 0x00000001, 0x00001fb8, 0x00001fc4, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, - 0x00001fc8, 0x0000000b, 0x00000000, 0x00000001, 0x0000229c, 0x00000002, 0x00000000, 0x00000001, - 0x000022a8, 0x000022b4, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x000022b8, - 0x0000000b, 0x00000000, 0x00000001, 0x0000259c, 0x00000002, 0x00000000, 0x00000001, 0x000025a8, - 0x000025b4, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x000025b8, 0x0000000b, - 0x00000000, 0x00000001, 0x00002808, 0x00000002, 0x00000000, 0x00000001, 0x00002814, + 0x00000001, 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000000, 0x00323270, 0x000000ec, + 0x43425844, 0xc95f99d5, 0x429f3bc7, 0xe63b88c0, 0x6af83630, 0x00000001, 0x000000ec, 0x00000003, + 0x0000002c, 0x000000a8, 0x000000b4, 0x42415443, 0x00000074, 0x0000001c, 0x0000004b, 0x46580400, + 0x00000001, 0x0000001c, 0x00000100, 0x00000048, 0x00000030, 0x00000002, 0x00000001, 0x00000038, + 0x00000000, 0x61765f67, 0xabab0072, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x4d007874, + 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, + 0x30312072, 0xab00312e, 0x34494c43, 0x00000004, 0x00000000, 0x434c5846, 0x00000030, 0x00000001, + 0x13a00004, 0x00000001, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000004, 0x00000000, + 0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff, 0x00000001, 0x00000002, 0x00000000, 0x00000001, 0x00000002, + 0x00000000, 0x00000004, 0x00000040, 0x00000000, 0x00000004, 0xffffffff, 0x00000000, 0x00000030, + 0x00000014, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000036, 0x00000014, + 0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x0000005e, 0x00000042, 0x00000000, + 0x00000020, 0x00000000, 0x00000000, 0x00000000, 0x00000087, 0x0000006b, 0x00000000, 0x00000030, + 0x00000000, 0x00000000, 0x00000000, 0x000000bc, 0x000000a0, 0x00000000, 0xffffffff, 0x00000001, + 0x00000019, 0x00000000, 0x00000006, 0x000000c5, 0x00000000, 0x000001b5, 0x00000017, 0x00000000, + 0x000001ba, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x000001bd, 0x0000000b, + 0x00000000, 0x00000001, 0x00000405, 0x00000002, 0x00000000, 0x00000001, 0x00000411, 0x0000041d, + 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00000420, 0x0000000b, 0x00000000, + 0x00000001, 0x00000574, 0x00000002, 0x00000000, 0x00000001, 0x00000580, 0x0000058c, 0x00000003, + 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x0000058f, 0x0000000b, 0x00000000, 0x00000001, + 0x000007bf, 0x00000002, 0x00000000, 0x00000001, 0x000007cb, 0x000007d7, 0x00000003, 0x00000000, + 0x0000000a, 0x00000000, 0x00000006, 0x000007da, 0x0000000b, 0x00000000, 0x00000001, 0x00000902, + 0x00000002, 0x00000000, 0x00000001, 0x0000090e, 0x0000091a, 0x00000003, 0x00000000, 0x0000000a, + 0x00000000, 0x00000006, 0x0000091d, 0x0000000b, 0x00000000, 0x00000001, 0x00000a45, 0x00000002, + 0x00000000, 0x00000001, 0x00000a51, 0x00000a5d, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, + 0x00000006, 0x00000a60, 0x0000000b, 0x00000000, 0x00000001, 0x00000b5c, 0x00000002, 0x00000000, + 0x00000001, 0x00000b68, 0x00000b74, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, + 0x00000b77, 0x0000000b, 0x00000000, 0x00000001, 0x00000cc7, 0x00000002, 0x00000000, 0x00000001, + 0x00000cd3, 0x00000cdf, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00000ce2, + 0x0000000b, 0x00000000, 0x00000001, 0x00000dd2, 0x00000002, 0x00000000, 0x00000001, 0x00000dde, + 0x00000dea, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00000ded, 0x0000000b, + 0x00000000, 0x00000001, 0x00000fe9, 0x00000002, 0x00000000, 0x00000001, 0x00000ff5, 0x00001001, + 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00001004, 0x0000000b, 0x00000000, + 0x00000001, 0x00001180, 0x00000002, 0x00000000, 0x00000001, 0x0000118c, 0x00001198, 0x00000003, + 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x0000119c, 0x0000000b, 0x00000000, 0x00000001, + 0x0000136c, 0x00000002, 0x00000000, 0x00000001, 0x00001378, 0x00001384, 0x00000003, 0x00000000, + 0x0000000a, 0x00000000, 0x00000006, 0x00001388, 0x0000000b, 0x00000000, 0x00000001, 0x00001504, + 0x00000002, 0x00000000, 0x00000001, 0x00001510, 0x0000151c, 0x00000003, 0x00000000, 0x0000000a, + 0x00000000, 0x00000006, 0x00001520, 0x0000000b, 0x00000000, 0x00000001, 0x0000169c, 0x00000002, + 0x00000000, 0x00000001, 0x000016a8, 0x000016b4, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, + 0x00000006, 0x000016b8, 0x0000000b, 0x00000000, 0x00000001, 0x00001834, 0x00000002, 0x00000000, + 0x00000001, 0x00001840, 0x0000184c, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, + 0x00001850, 0x0000000b, 0x00000000, 0x00000001, 0x000019cc, 0x00000002, 0x00000000, 0x00000001, + 0x000019d8, 0x000019e4, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x000019e8, + 0x0000000b, 0x00000000, 0x00000001, 0x00001b38, 0x00000002, 0x00000000, 0x00000001, 0x00001b44, + 0x00001b50, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00001b54, 0x0000000b, + 0x00000000, 0x00000001, 0x00001ca4, 0x00000002, 0x00000000, 0x00000001, 0x00001cb0, 0x00001cbc, + 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00001cc0, 0x0000000b, 0x00000000, + 0x00000001, 0x00001e10, 0x00000002, 0x00000000, 0x00000001, 0x00001e1c, 0x00001e28, 0x00000003, + 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00001e2c, 0x0000000b, 0x00000000, 0x00000001, + 0x00001fac, 0x00000002, 0x00000000, 0x00000001, 0x00001fb8, 0x00001fc4, 0x00000003, 0x00000000, + 0x0000000a, 0x00000000, 0x00000006, 0x00001fc8, 0x0000000b, 0x00000000, 0x00000001, 0x0000229c, + 0x00000002, 0x00000000, 0x00000001, 0x000022a8, 0x000022b4, 0x00000003, 0x00000000, 0x0000000a, + 0x00000000, 0x00000006, 0x000022b8, 0x0000000b, 0x00000000, 0x00000001, 0x0000259c, 0x00000002, + 0x00000000, 0x00000001, 0x000025a8, 0x000025b4, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, + 0x00000006, 0x000025b8, 0x0000000b, 0x00000000, 0x00000001, 0x00002808, 0x00000002, 0x00000000, + 0x00000001, 0x00002814, 0x00002820, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, + 0x00002824, 0x0000000b, 0x00000000, 0x00000001, 0x00002914, 0x00000002, 0x00000000, 0x00000001, + 0x00002920, }; static float get_frc(float v) @@ -9120,6 +9135,62 @@ static void test_effect_value_expression(void) ok(blend_factor[idx] == 1.0f, "Got unexpected blend_factor[%u] %.8e.\n", idx, blend_factor[idx]); ok(!sample_mask, "Got unexpected sample_mask %#x.\n", sample_mask); + /* ceil() */ + pass = t->lpVtbl->GetPassByName(t, "p22"); + ok(pass->lpVtbl->IsValid(pass), "Expected valid pass.\n"); + + set_vec4(f, 1.1f, -2.3f, 3.5f, -4.5f); + 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); + for (idx = 0; idx < ARRAY_SIZE(blend_factor); ++idx) + ok(blend_factor[idx] == 2.0f, "Got unexpected blend_factor[%u] %.8e.\n", idx, blend_factor[idx]); + ok(!sample_mask, "Got unexpected sample_mask %#x.\n", sample_mask); + + set_vec4(f, -2.3f, 1.1f, 3.5f, -4.5f); + 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); + for (idx = 0; idx < ARRAY_SIZE(blend_factor); ++idx) + ok(blend_factor[idx] == -2.0f, "Got unexpected blend_factor[%u] %.8e.\n", idx, blend_factor[idx]); + ok(!sample_mask, "Got unexpected sample_mask %#x.\n", sample_mask); + + set_vec4(f, 3.5f, -2.3f, 1.1f, -4.5f); + 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); + for (idx = 0; idx < ARRAY_SIZE(blend_factor); ++idx) + ok(blend_factor[idx] == 4.0f, "Got unexpected blend_factor[%u] %.8e.\n", idx, blend_factor[idx]); + ok(!sample_mask, "Got unexpected sample_mask %#x.\n", sample_mask); + + set_vec4(f, -4.5f, -2.3f, 3.5f, 1.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); + for (idx = 0; idx < ARRAY_SIZE(blend_factor); ++idx) + ok(blend_factor[idx] == -4.0f, "Got unexpected blend_factor[%u] %.8e.\n", idx, blend_factor[idx]); + ok(!sample_mask, "Got unexpected sample_mask %#x.\n", sample_mask); + effect->lpVtbl->Release(effect); refcount = ID3D10Device_Release(device);