From: Paul Gofman Subject: [PATCH 3/3] d3dx9/tests: Add more tests for preshader relative addressing. Message-Id: <20170323150659.8025-3-gofmanp@gmail.com> Date: Thu, 23 Mar 2017 18:06:59 +0300 In-Reply-To: <20170323150659.8025-1-gofmanp@gmail.com> References: <20170323150659.8025-1-gofmanp@gmail.com> Signed-off-by: Paul Gofman --- dlls/d3dx9_36/tests/effect.c | 147 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 622a8d5..4ab25f0 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -4957,6 +4957,152 @@ static void test_effect_commitchanges(IDirect3DDevice9 *device) effect->lpVtbl->Release(effect); } +static void test_effect_preshader_relative_addressing(IDirect3DDevice9 *device) +{ + static const struct + { + D3DXVECTOR4 opvect2; + D3DXVECTOR4 g_ivect; + unsigned int result[4]; + } + test_out_of_bounds_index[] = + { + {{1.0f, 2.0f, 3.0f, 4.0f}, {101.f, 101.f, 101.f, 101.f}, {0x447ac000, 0x42ca0000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {3333.f, 1094.f, 2222.f, 3333.f}, {0, 0x450ae000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {3333.f, 1094.f, 2222.f, 1.f}, {0, 0x450ae000, 0x45bb9800, 0x453b9000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {1.f, 1094.f, 2222.f, 3333.f}, {0, 0x450ae000, 0, 0x453ba000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {1111.f, 1094.f, 2222.f, 1111.f}, {0, 0x450ae000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {1111.f, 1094.f, 2222.f, 3333.f}, {0, 0x450ae000, 0, 0}}, + {{-1111.f, 1094.f, -2222.f, -3333.f}, {4.f, 3.f, 2.f, 1.f}, {0x447ac000, 0, 0x45bb9800, 0x453bc000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-1.f, -1.f, -1.f, -1.f}, {0, 0xbf800000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-2.f, -2.f, -2.f, -2.f}, {0, 0xc0000000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-3.f, -3.f, -3.f, -3.f}, {0, 0xc0400000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-4.f, -4.f, -4.f, -4.f}, {0, 0xc0800000, 0xc1000000, 0xc1000000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-5.f, -5.f, -5.f, -5.f}, {0, 0xc0a00000, 0x40400000, 0x40400000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-6.f, -6.f, -6.f, -6.f}, {0, 0xc0c00000, 0x44fa6000, 0x44fa6000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-7.f, -7.f, -7.f, -7.f}, {0x447b0000, 0xc0e00000, 0x45bb9800, 0x45bb9800}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-8.f, -8.f, -8.f, -8.f}, {0x447ac000, 0xc1000000, 0x457a3000, 0x457a3000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-9.f, -9.f, -9.f, -9.f}, {0x447a8000, 0xc1100000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-10.f, -10.f, -10.f, -10.f}, {0x447a4000, 0xc1200000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-11.f, -11.f, -11.f, -11.f}, {0, 0xc1300000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-12.f, -12.f, -12.f, -12.f}, {0, 0xc1400000, 0xc1c00000, 0xc1c00000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {5.f, 5.f, 5.f, 5.f}, {0, 0x40a00000, 0, 0}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-1111.f, 1094.f, -2222.f, -3333.f}, {0x447ac000, 0xc50ae000, 0x40400000, 0x453bb000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-3333.f, 1094.f, -2222.f, -1111.f}, {0x447ac000, 0xc50ae000, 0x45bb9800, 0x453bb000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-3333.f, 1094.f, -2222.f, -3333.f}, {0x447ac000, 0xc50ae000, 0x40400000, 0x40400000}}, + {{1.0f, 2.0f, 3.0f, 4.0f}, {-1111.f, 1094.f, -2222.f, -1111.f}, {0x447ac000, 0xc50ae000, 0x45bb9800, 0x45bb9800}}, + }; + static const struct + { + unsigned int zw[2]; + } + test_index_range[] = + { + {0x457a3000, 0x457a3000}, + {0x45bb9800, 0x459c5800}, + {0x44fa6000, 0x453bb000}, + {0x40400000, 0x44fa6000}, + {0xcf000000, 0xcefffff0}, + {0, 0x44fa4000}, + {0, 0x44fa4000}, + {0, 0x44fa4000}, + }; + static const D3DLIGHT9 light_filler = {D3DLIGHT_POINT, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, + {1.0f, 1.0f, 1.0f, 1.0f}}; + + ID3DXEffect *effect; + HRESULT hr; + unsigned int j, passes_count; + int i; + D3DXVECTOR4 fvect; + D3DLIGHT9 light; + const float *v; + + hr = D3DXCreateEffect(device, test_effect_preshader_effect_blob, sizeof(test_effect_preshader_effect_blob), + NULL, NULL, 0, NULL, &effect, NULL); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + hr = effect->lpVtbl->Begin(effect, &passes_count, 0); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + hr = effect->lpVtbl->BeginPass(effect, 0); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + fvect.x = 1001.f; fvect.y = 1002.f; fvect.z = 1003.f; fvect.w = 1004.f; + hr = effect->lpVtbl->SetVector(effect, "opvect1", &fvect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + fvect.x = 2001.f; fvect.y = 2002.f; fvect.z = 2003.f; fvect.w = 2004.f; + hr = effect->lpVtbl->SetVector(effect, "g_Selector[0]", &fvect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + fvect.x = 3001.f; fvect.y = 3002.f; fvect.z = 3003.f; fvect.w = 3004.f; + hr = effect->lpVtbl->SetVector(effect, "g_Selector[1]", &fvect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + v = &light.Specular.r; + for (i = 0; i < ARRAY_SIZE(test_out_of_bounds_index); ++i) + { + hr = effect->lpVtbl->SetVector(effect, "opvect2", &test_out_of_bounds_index[i].opvect2); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + hr = effect->lpVtbl->SetVector(effect, "g_iVect", &test_out_of_bounds_index[i].g_ivect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + hr = IDirect3DDevice9_SetLight(device, 1, &light_filler); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + hr = effect->lpVtbl->CommitChanges(effect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + hr = IDirect3DDevice9_GetLight(device, 1, &light); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + for (j = 0; j < 4; ++j) + { + ok(compare_float(v[j], ((const float *)test_out_of_bounds_index[i].result)[j], 0), + "Test %u, component %u, expected %#x (%g), got %#x (%g).\n", + i, j, test_out_of_bounds_index[i].result[j], + ((const float *)test_out_of_bounds_index[i].result)[j], + ((const unsigned int *)v)[j], v[j]); + } + } + + hr = effect->lpVtbl->SetVector(effect, "opvect2", &test_out_of_bounds_index[7].opvect2); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + hr = effect->lpVtbl->SetVector(effect, "g_iVect", &test_out_of_bounds_index[7].g_ivect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + hr = IDirect3DDevice9_SetLight(device, 1, &light_filler); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + fvect = test_out_of_bounds_index[i].g_ivect; + for (i = -100; i < 100; ++i) + { + fvect.w = i; + hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + hr = effect->lpVtbl->CommitChanges(effect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + hr = IDirect3DDevice9_GetLight(device, 1, &light); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + for (j = 0; j < 2; ++j) + { + ok(compare_float(v[j + 2], ((const float *)test_index_range[(unsigned int)i & 7].zw)[j], 0), + "Test %u, component %u, expected %#x (%g), got %#x (%g).\n", + i, j, test_index_range[(unsigned int)i & 7].zw[j], + ((const float *)test_index_range[(unsigned int)i & 7].zw)[j], + ((const unsigned int *)v)[j + 2], v[j + 2]); + } + } + + hr = effect->lpVtbl->EndPass(effect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + hr = effect->lpVtbl->End(effect); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + effect->lpVtbl->Release(effect); +} + START_TEST(effect) { HWND wnd; @@ -5002,6 +5148,7 @@ START_TEST(effect) test_effect_isparameterused(device); test_effect_out_of_bounds_selector(device); test_effect_commitchanges(device); + test_effect_preshader_relative_addressing(device); count = IDirect3DDevice9_Release(device); ok(count == 0, "The device was not properly freed: refcount %u\n", count); -- 2.9.3