ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2020
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
27 participants
239 discussions
Start a n
N
ew thread
[reactos] 11/74: [WINESYNC]d3dx9/tests: Fix a couple of ok() messages.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4cecd21f9a8dd58a2bdf6…
commit 4cecd21f9a8dd58a2bdf67b37f8dad9f1218d83d Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Jan 4 01:48:04 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [WINESYNC]d3dx9/tests: Fix a couple of ok() messages. Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 5a5beba6c4e3bc53790e3a31916d0aaf57dc19b8 by Matteo Bruni <mbruni(a)codeweavers.com> --- modules/rostests/winetests/d3dx9_36/effect.c | 4 ++-- sdk/tools/winesync/d3dx9.cfg | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/rostests/winetests/d3dx9_36/effect.c b/modules/rostests/winetests/d3dx9_36/effect.c index 423d3b8d5c6..efede15f076 100644 --- a/modules/rostests/winetests/d3dx9_36/effect.c +++ b/modules/rostests/winetests/d3dx9_36/effect.c @@ -343,7 +343,7 @@ static void test_create_effect_and_pool(IDirect3DDevice9 *device) hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3DXEffectPool, (void **)&pool2); ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); - ok(pool == pool2, "Release failed, got %p, expected %p\n", pool2, pool); + ok(pool == pool2, "Got effect pool %p, expected %p.\n", pool2, pool); count = pool2->lpVtbl->Release(pool2); ok(count == 1, "Release failed, got %u, expected 1\n", count); @@ -359,7 +359,7 @@ static void test_create_effect_and_pool(IDirect3DDevice9 *device) hr = effect->lpVtbl->GetPool(effect, &pool); ok(hr == D3D_OK, "GetPool failed, got %x, expected 0 (D3D_OK)\n", hr); - ok(pool == pool2, "GetPool failed, got %p, expected %p\n", pool2, pool); + ok(pool == pool2, "Got effect pool %p, expected %p.\n", pool2, pool); count = pool2->lpVtbl->Release(pool2); ok(count == 2, "Release failed, got %u, expected 2\n", count); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index a71df076c17..a4992d55f94 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -33,4 +33,4 @@ files: include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h tags: - wine: 64b6bb4d4a54642434594f0df2afcd2e90b2a0a8 + wine: 5a5beba6c4e3bc53790e3a31916d0aaf57dc19b8
4 years, 10 months
1
0
0
0
[reactos] 10/74: [WINESYNC]d3dx9/tests: Expect plain render target creation to work.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f4fb1884a82c2b4cc1379…
commit f4fb1884a82c2b4cc1379c7414ef755606869186 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Jan 4 01:48:04 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [WINESYNC]d3dx9/tests: Expect plain render target creation to work. Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 64b6bb4d4a54642434594f0df2afcd2e90b2a0a8 by Matteo Bruni <mbruni(a)codeweavers.com> --- modules/rostests/winetests/d3dx9_36/surface.c | 21 ++++++++++++--------- sdk/tools/winesync/d3dx9.cfg | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/rostests/winetests/d3dx9_36/surface.c b/modules/rostests/winetests/d3dx9_36/surface.c index 6cb1ddb73ce..b7c52a28b0f 100644 --- a/modules/rostests/winetests/d3dx9_36/surface.c +++ b/modules/rostests/winetests/d3dx9_36/surface.c @@ -847,21 +847,24 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) /* non-lockable render target */ hr = IDirect3DDevice9_CreateRenderTarget(device, 256, 256, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &newsurf, NULL); - if (SUCCEEDED(hr)) { - hr = D3DXLoadSurfaceFromSurface(surf, NULL, NULL, newsurf, NULL, NULL, D3DX_FILTER_NONE, 0); - ok(hr == D3D_OK, "D3DXLoadSurfaceFromSurface returned %#x, expected %#x\n", hr, D3D_OK); - - IDirect3DSurface9_Release(newsurf); - } else skip("Failed to create render target surface\n"); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + hr = D3DXLoadSurfaceFromSurface(surf, NULL, NULL, newsurf, NULL, NULL, D3DX_FILTER_NONE, 0); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + IDirect3DSurface9_Release(newsurf); /* non-lockable multisampled render target */ hr = IDirect3DDevice9_CreateRenderTarget(device, 256, 256, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &newsurf, NULL); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr)) + { hr = D3DXLoadSurfaceFromSurface(surf, NULL, NULL, newsurf, NULL, NULL, D3DX_FILTER_NONE, 0); - ok(hr == D3D_OK, "D3DXLoadSurfaceFromSurface returned %#x, expected %#x\n", hr, D3D_OK); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); IDirect3DSurface9_Release(newsurf); - } else skip("Failed to create multisampled render target.\n"); + } + else + { + skip("Failed to create multisampled render target.\n"); + } hr = IDirect3DDevice9_GetRenderTarget(device, 0, &newsurf); ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderTarget returned %#x, expected %#x.\n", hr, D3D_OK); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 5c969fbf05a..a71df076c17 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -33,4 +33,4 @@ files: include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h tags: - wine: 65956ae50a136fe8467a0332c7495f36617a16dc + wine: 64b6bb4d4a54642434594f0df2afcd2e90b2a0a8
4 years, 10 months
1
0
0
0
[reactos] 09/74: [WINESYNC]d3dx9: Use {lock|unlock}_surface() in D3DXLoadSurfaceFromMemory().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=083cd9a957f9740cc4e86…
commit 083cd9a957f9740cc4e861201fa135510c2d568d Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Jan 4 01:48:04 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [WINESYNC]d3dx9: Use {lock|unlock}_surface() in D3DXLoadSurfaceFromMemory(). Signed-off-by: Paul Gofman <gofmanp(a)gmail.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 65956ae50a136fe8467a0332c7495f36617a16dc by Paul Gofman <gofmanp(a)gmail.com> --- dll/directx/wine/d3dx9_36/surface.c | 48 +++++++------------------------------ sdk/tools/winesync/d3dx9.cfg | 2 +- 2 files changed, 9 insertions(+), 41 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index 23e8f7691f2..cae80a8689b 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -1822,8 +1822,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, DWORD filter, D3DCOLOR color_key) { const struct pixel_format_desc *srcformatdesc, *destformatdesc; - IDirect3DSurface9 *surface = dst_surface; - IDirect3DDevice9 *device; + IDirect3DSurface9 *surface; D3DSURFACE_DESC surfdesc; D3DLOCKED_RECT lockrect; struct volume src_size, dst_size; @@ -1883,25 +1882,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, return E_NOTIMPL; } - if (surfdesc.Pool == D3DPOOL_DEFAULT && !(surfdesc.Usage & D3DUSAGE_DYNAMIC)) - { - IDirect3DSurface9_GetDevice(dst_surface, &device); - hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, surfdesc.Width, - surfdesc.Height, surfdesc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL); - IDirect3DDevice9_Release(device); - if (FAILED(hr)) - { - WARN("Failed to create staging surface, hr %#x.\n", hr); - return D3DERR_INVALIDCALL; - } - } - - if (FAILED(IDirect3DSurface9_LockRect(surface, &lockrect, dst_rect, 0))) - { - if (surface != dst_surface) - IDirect3DSurface9_Release(surface); - return D3DXERR_INVALIDDATA; - } + if (FAILED(hr = lock_surface(dst_surface, &lockrect, &surface, TRUE))) + return hr; if (src_format == surfdesc.Format && dst_size.width == src_size.width @@ -1916,8 +1898,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, && src_size.height != surfdesc.Height)) { WARN("Source rect %s is misaligned.\n", wine_dbgstr_rect(src_rect)); - hr = D3DXERR_INVALIDDATA; - goto done; + unlock_surface(dst_surface, &lockrect, surface, FALSE); + return D3DXERR_INVALIDDATA; } copy_pixels(src_memory, src_pitch, 0, lockrect.pBits, lockrect.Pitch, 0, @@ -1929,8 +1911,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, || !is_conversion_to_supported(destformatdesc)) { FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format); - hr = E_NOTIMPL; - goto done; + unlock_surface(dst_surface, &lockrect, surface, FALSE); + return E_NOTIMPL; } if ((filter & 0xf) == D3DX_FILTER_NONE) @@ -1950,21 +1932,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, } } - hr = D3D_OK; -done: - IDirect3DSurface9_UnlockRect(surface); - if (surface != dst_surface) - { - if (SUCCEEDED(hr)) - { - IDirect3DSurface9_GetDevice(dst_surface, &device); - hr = IDirect3DDevice9_UpdateSurface(device, surface, NULL, dst_surface, NULL); - IDirect3DDevice9_Release(device); - } - IDirect3DSurface9_Release(surface); - } - - return hr; + return unlock_surface(dst_surface, &lockrect, surface, TRUE); } /************************************************************ diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 746b3659388..5c969fbf05a 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -33,4 +33,4 @@ files: include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h tags: - wine: 092c14b9d86ee1e96e465908cc524ec85988d0ff + wine: 65956ae50a136fe8467a0332c7495f36617a16dc
4 years, 10 months
1
0
0
0
[reactos] 08/74: [WINESYNC]d3dx9: Use temporary surface in D3DXSaveSurfaceToFileInMemory() for unmappable textures.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a1f2064705d8a0a58c409…
commit a1f2064705d8a0a58c4090e42a32abd70831a323 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Jan 4 01:48:04 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [WINESYNC]d3dx9: Use temporary surface in D3DXSaveSurfaceToFileInMemory() for unmappable textures. Fixes a regression triggered by commit 949dbbd31f450178c90ea8267097a975b77c3219. Signed-off-by: Paul Gofman <gofmanp(a)gmail.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 092c14b9d86ee1e96e465908cc524ec85988d0ff by Paul Gofman <gofmanp(a)gmail.com> --- dll/directx/wine/d3dx9_36/surface.c | 20 ++++++------- modules/rostests/winetests/d3dx9_36/surface.c | 43 ++++++++++++++++++++++++--- sdk/tools/winesync/d3dx9.cfg | 2 +- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index faac1419517..23e8f7691f2 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -530,6 +530,7 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur BYTE *pixels; struct volume volume; const struct pixel_format_desc *pixel_format; + IDirect3DSurface9 *temp_surface; if (src_rect) { @@ -569,7 +570,7 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur return hr; } - hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, NULL, D3DLOCK_READONLY); + hr = lock_surface(src_surface, &locked_rect, &temp_surface, FALSE); if (FAILED(hr)) { ID3DXBuffer_Release(buffer); @@ -582,7 +583,7 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur copy_pixels(locked_rect.pBits, locked_rect.Pitch, 0, pixels, dst_pitch, 0, &volume, pixel_format); - IDirect3DSurface9_UnlockRect(src_surface); + unlock_surface(src_surface, &locked_rect, temp_surface, FALSE); *dst_buffer = buffer; return D3D_OK; @@ -2124,6 +2125,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE WICPixelFormatGUID wic_pixel_format; D3DFORMAT d3d_pixel_format; D3DSURFACE_DESC src_surface_desc; + IDirect3DSurface9 *temp_surface; D3DLOCKED_RECT locked_rect; int width, height; STATSTG stream_stats; @@ -2131,7 +2133,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE ID3DXBuffer *buffer; DWORD size; - TRACE("(%p, %#x, %p, %p, %s)\n", + TRACE("dst_buffer %p, file_format %#x, src_surface %p, src_palette %p, src_rect %s.\n", dst_buffer, file_format, src_surface, src_palette, wine_dbgstr_rect(src_rect)); if (!dst_buffer || !src_surface) return D3DERR_INVALIDCALL; @@ -2225,16 +2227,14 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE if (SUCCEEDED(hr) && d3d_pixel_format != D3DFMT_UNKNOWN) { TRACE("Using pixel format %s %#x\n", debugstr_guid(&wic_pixel_format), d3d_pixel_format); - if (src_surface_desc.Format == d3d_pixel_format) /* Simple copy */ { - hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, src_rect, D3DLOCK_READONLY); - if (FAILED(hr)) + if (FAILED(hr = lock_surface(src_surface, &locked_rect, &temp_surface, FALSE))) goto cleanup; IWICBitmapFrameEncode_WritePixels(frame, height, locked_rect.Pitch, height * locked_rect.Pitch, locked_rect.pBits); - IDirect3DSurface9_UnlockRect(src_surface); + unlock_surface(src_surface, &locked_rect, temp_surface, FALSE); } else /* Pixel format conversion */ { @@ -2264,16 +2264,14 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE hr = E_OUTOFMEMORY; goto cleanup; } - - hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, src_rect, D3DLOCK_READONLY); - if (FAILED(hr)) + if (FAILED(hr = lock_surface(src_surface, &locked_rect, &temp_surface, FALSE))) { HeapFree(GetProcessHeap(), 0, dst_data); goto cleanup; } convert_argb_pixels(locked_rect.pBits, locked_rect.Pitch, 0, &size, src_format_desc, dst_data, dst_pitch, 0, &size, dst_format_desc, 0, NULL); - IDirect3DSurface9_UnlockRect(src_surface); + unlock_surface(src_surface, &locked_rect, temp_surface, FALSE); IWICBitmapFrameEncode_WritePixels(frame, height, dst_pitch, dst_pitch * height, dst_data); HeapFree(GetProcessHeap(), 0, dst_data); diff --git a/modules/rostests/winetests/d3dx9_36/surface.c b/modules/rostests/winetests/d3dx9_36/surface.c index d3450722ef7..6cb1ddb73ce 100644 --- a/modules/rostests/winetests/d3dx9_36/surface.c +++ b/modules/rostests/winetests/d3dx9_36/surface.c @@ -1253,16 +1253,30 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device) { - HRESULT hr; - RECT rect; - ID3DXBuffer *buffer; - IDirect3DSurface9 *surface; + static const struct + { + DWORD usage; + D3DPOOL pool; + } + test_access_types[] = + { + {0, D3DPOOL_MANAGED}, + {0, D3DPOOL_DEFAULT}, + {D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT}, + }; + struct { DWORD magic; struct dds_header header; BYTE *data; } *dds; + IDirect3DSurface9 *surface; + IDirect3DTexture9 *texture; + ID3DXBuffer *buffer; + unsigned int i; + HRESULT hr; + RECT rect; hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 4, 4, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, NULL); if (FAILED(hr)) { @@ -1317,6 +1331,27 @@ static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device) ID3DXBuffer_Release(buffer); IDirect3DSurface9_Release(surface); + + for (i = 0; i < ARRAY_SIZE(test_access_types); ++i) + { + hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 0, test_access_types[i].usage, + D3DFMT_A8R8G8B8, test_access_types[i].pool, &texture, NULL); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i); + + hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i); + + hr = D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_DDS, surface, NULL, NULL); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i); + ID3DXBuffer_Release(buffer); + + hr = D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_BMP, surface, NULL, NULL); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i); + ID3DXBuffer_Release(buffer); + + IDirect3DSurface9_Release(surface); + IDirect3DTexture9_Release(texture); + } } static void test_D3DXSaveSurfaceToFile(IDirect3DDevice9 *device) diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index dd03a62177b..746b3659388 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -33,4 +33,4 @@ files: include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h tags: - wine: ce090114340fe6ce9314f543a1389de9bdc6df14 + wine: 092c14b9d86ee1e96e465908cc524ec85988d0ff
4 years, 10 months
1
0
0
0
[reactos] 07/74: [WINESYNC]d3dx9: Do not ignore surface map failure in D3DXSaveSurfaceToFileInMemory().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9e1d68edb042b6a59c37b…
commit 9e1d68edb042b6a59c37bab990ee29f8940c324a Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Jan 4 01:48:04 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [WINESYNC]d3dx9: Do not ignore surface map failure in D3DXSaveSurfaceToFileInMemory(). Signed-off-by: Paul Gofman <gofmanp(a)gmail.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id ce090114340fe6ce9314f543a1389de9bdc6df14 by Paul Gofman <gofmanp(a)gmail.com> --- dll/directx/wine/d3dx9_36/surface.c | 22 ++++++++++++---------- sdk/tools/winesync/d3dx9.cfg | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index a6eb5482f71..faac1419517 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -2229,12 +2229,12 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE if (src_surface_desc.Format == d3d_pixel_format) /* Simple copy */ { hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, src_rect, D3DLOCK_READONLY); - if (SUCCEEDED(hr)) - { - IWICBitmapFrameEncode_WritePixels(frame, height, - locked_rect.Pitch, height * locked_rect.Pitch, locked_rect.pBits); - IDirect3DSurface9_UnlockRect(src_surface); - } + if (FAILED(hr)) + goto cleanup; + + IWICBitmapFrameEncode_WritePixels(frame, height, + locked_rect.Pitch, height * locked_rect.Pitch, locked_rect.pBits); + IDirect3DSurface9_UnlockRect(src_surface); } else /* Pixel format conversion */ { @@ -2266,12 +2266,14 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE } hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, src_rect, D3DLOCK_READONLY); - if (SUCCEEDED(hr)) + if (FAILED(hr)) { - convert_argb_pixels(locked_rect.pBits, locked_rect.Pitch, 0, &size, src_format_desc, - dst_data, dst_pitch, 0, &size, dst_format_desc, 0, NULL); - IDirect3DSurface9_UnlockRect(src_surface); + HeapFree(GetProcessHeap(), 0, dst_data); + goto cleanup; } + convert_argb_pixels(locked_rect.pBits, locked_rect.Pitch, 0, &size, src_format_desc, + dst_data, dst_pitch, 0, &size, dst_format_desc, 0, NULL); + IDirect3DSurface9_UnlockRect(src_surface); IWICBitmapFrameEncode_WritePixels(frame, height, dst_pitch, dst_pitch * height, dst_data); HeapFree(GetProcessHeap(), 0, dst_data); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 8045ddd8fda..dd03a62177b 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -33,4 +33,4 @@ files: include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h tags: - wine: 61e7e6ec1bf5d13d4cafa883ac74fe987c339740 + wine: ce090114340fe6ce9314f543a1389de9bdc6df14
4 years, 10 months
1
0
0
0
[reactos] 06/74: [WINESYNC]d3dx9/tests: Add test for D3DXFillVolumeTexture() with default pool texture.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=95d6d1b3d173618390094…
commit 95d6d1b3d17361839009449e50f438b799d1c5f7 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Jan 4 01:48:04 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [WINESYNC]d3dx9/tests: Add test for D3DXFillVolumeTexture() with default pool texture. Signed-off-by: Paul Gofman <gofmanp(a)gmail.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 61e7e6ec1bf5d13d4cafa883ac74fe987c339740 by Paul Gofman <gofmanp(a)gmail.com> --- modules/rostests/winetests/d3dx9_36/texture.c | 8 +++++++- sdk/tools/winesync/d3dx9.cfg | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/rostests/winetests/d3dx9_36/texture.c b/modules/rostests/winetests/d3dx9_36/texture.c index 1a92a85b63e..6c25a158118 100644 --- a/modules/rostests/winetests/d3dx9_36/texture.c +++ b/modules/rostests/winetests/d3dx9_36/texture.c @@ -1423,8 +1423,14 @@ static void test_D3DXFillVolumeTexture(IDirect3DDevice9 *device) size = 4; hr = IDirect3DDevice9_CreateVolumeTexture(device, size, size, size, 0, 0, D3DFMT_A8R8G8B8, - D3DPOOL_MANAGED, &tex, NULL); + D3DPOOL_DEFAULT, &tex, NULL); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + hr = D3DXFillVolumeTexture(tex, fillfunc_volume, NULL); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + IDirect3DVolumeTexture9_Release(tex); + hr = IDirect3DDevice9_CreateVolumeTexture(device, size, size, size, 0, 0, D3DFMT_A8R8G8B8, + D3DPOOL_MANAGED, &tex, NULL); if (SUCCEEDED(hr)) { hr = D3DXFillVolumeTexture(tex, fillfunc_volume, NULL); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 8bc93affa53..8045ddd8fda 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -33,4 +33,4 @@ files: include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h tags: - wine: 4e44d74afb12b40f673e3be0a91cd523013544cd + wine: 61e7e6ec1bf5d13d4cafa883ac74fe987c339740
4 years, 10 months
1
0
0
0
[reactos] 05/74: [WINESYNC]d3dx9: Use temporary surface in D3DXFillTexture() for unmappable textures.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b8714c31cd1f923516934…
commit b8714c31cd1f9235169341bee057ff4ef8fa7213 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Jan 4 01:48:04 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [WINESYNC]d3dx9: Use temporary surface in D3DXFillTexture() for unmappable textures. Fixes a regression triggered by commit 949dbbd31f450178c90ea8267097a975b77c3219. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=46453
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 4e44d74afb12b40f673e3be0a91cd523013544cd by Paul Gofman <gofmanp(a)gmail.com> --- dll/directx/wine/d3dx9_36/d3dx9_private.h | 4 + dll/directx/wine/d3dx9_36/surface.c | 47 ++++++++---- dll/directx/wine/d3dx9_36/texture.c | 28 +++++-- modules/rostests/winetests/d3dx9_36/texture.c | 106 ++++++++++++++++++-------- sdk/tools/winesync/d3dx9.cfg | 2 +- 5 files changed, 135 insertions(+), 52 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/d3dx9_private.h b/dll/directx/wine/d3dx9_36/d3dx9_private.h index 696b1859492..1c1613024dc 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_private.h +++ b/dll/directx/wine/d3dx9_36/d3dx9_private.h @@ -121,6 +121,10 @@ HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *d const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN; HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN; +HRESULT lock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock, + IDirect3DSurface9 **temp_surface, BOOL write) DECLSPEC_HIDDEN; +HRESULT unlock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock, + IDirect3DSurface9 *temp_surface, BOOL update) DECLSPEC_HIDDEN; unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN; float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN; diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index 2d00cd1dcdc..a6eb5482f71 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -199,49 +199,70 @@ static const struct { { 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000, D3DFMT_X8B8G8R8 }, }; -static HRESULT lock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock, - IDirect3DSurface9 **temp_surface) +HRESULT lock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock, + IDirect3DSurface9 **temp_surface, BOOL write) { IDirect3DDevice9 *device; D3DSURFACE_DESC desc; + DWORD lock_flag; HRESULT hr; + lock_flag = write ? D3DLOCK_DISCARD : D3DLOCK_READONLY; *temp_surface = NULL; - if (FAILED(hr = IDirect3DSurface9_LockRect(surface, lock, NULL, D3DLOCK_READONLY))) + if (FAILED(hr = IDirect3DSurface9_LockRect(surface, lock, NULL, lock_flag))) { IDirect3DSurface9_GetDevice(surface, &device); IDirect3DSurface9_GetDesc(surface, &desc); - if (FAILED(hr = IDirect3DDevice9_CreateRenderTarget(device, desc.Width, desc.Height, - desc.Format, D3DMULTISAMPLE_NONE, 0, TRUE, temp_surface, NULL))) + + hr = write ? IDirect3DDevice9_CreateOffscreenPlainSurface(device, desc.Width, desc.Height, + desc.Format, D3DPOOL_SYSTEMMEM, temp_surface, NULL) + : IDirect3DDevice9_CreateRenderTarget(device, desc.Width, desc.Height, + desc.Format, D3DMULTISAMPLE_NONE, 0, TRUE, temp_surface, NULL); + if (FAILED(hr)) { + WARN("Failed to create temporary surface, surface %p, format %#x," + " usage %#x, pool %#x, write %#x, width %u, height %u.\n", + surface, desc.Format, desc.Usage, desc.Pool, write, desc.Width, desc.Height); IDirect3DDevice9_Release(device); return hr; } - if (SUCCEEDED(hr = IDirect3DDevice9_StretchRect(device, surface, NULL, *temp_surface, NULL, D3DTEXF_NONE))) - hr = IDirect3DSurface9_LockRect(*temp_surface, lock, NULL, D3DLOCK_READONLY); + if (write || SUCCEEDED(hr = IDirect3DDevice9_StretchRect(device, surface, NULL, + *temp_surface, NULL, D3DTEXF_NONE))) + hr = IDirect3DSurface9_LockRect(*temp_surface, lock, NULL, lock_flag); + IDirect3DDevice9_Release(device); if (FAILED(hr)) { - WARN("Failed to lock surface %p, usage %#x, pool %#x.\n", - surface, desc.Usage, desc.Pool); + WARN("Failed to lock surface %p, write %#x, usage %#x, pool %#x.\n", + surface, write, desc.Usage, desc.Pool); IDirect3DSurface9_Release(*temp_surface); *temp_surface = NULL; return hr; } + TRACE("Created temporary surface %p.\n", surface); } return hr; } -static HRESULT unlock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock, - IDirect3DSurface9 *temp_surface) +HRESULT unlock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock, + IDirect3DSurface9 *temp_surface, BOOL update) { + IDirect3DDevice9 *device; HRESULT hr; if (!temp_surface) return IDirect3DSurface9_UnlockRect(surface); hr = IDirect3DSurface9_UnlockRect(temp_surface); + if (update) + { + IDirect3DSurface9_GetDevice(surface, &device); + if (FAILED(hr = IDirect3DDevice9_UpdateSurface(device, temp_surface, NULL, surface, NULL))) + WARN("Updating surface failed, hr %#x, surface %p, temp_surface %p.\n", + hr, surface, temp_surface); + IDirect3DDevice9_Release(device); + } IDirect3DSurface9_Release(temp_surface); return hr; } @@ -2026,13 +2047,13 @@ HRESULT WINAPI D3DXLoadSurfaceFromSurface(IDirect3DSurface9 *dst_surface, src_rect = &s; } - if (FAILED(lock_surface(src_surface, &lock, &temp_surface))) + if (FAILED(lock_surface(src_surface, &lock, &temp_surface, FALSE))) return D3DXERR_INVALIDDATA; hr = D3DXLoadSurfaceFromMemory(dst_surface, dst_palette, dst_rect, lock.pBits, src_desc.Format, lock.Pitch, src_palette, src_rect, filter, color_key); - if (FAILED(unlock_surface(src_surface, &lock, temp_surface))) + if (FAILED(unlock_surface(src_surface, &lock, temp_surface, FALSE))) return D3DXERR_INVALIDDATA; return hr; diff --git a/dll/directx/wine/d3dx9_36/texture.c b/dll/directx/wine/d3dx9_36/texture.c index 0f53d95bf1f..e2dfab84205 100644 --- a/dll/directx/wine/d3dx9_36/texture.c +++ b/dll/directx/wine/d3dx9_36/texture.c @@ -1323,6 +1323,7 @@ static inline void fill_texture(const struct pixel_format_desc *format, BYTE *po HRESULT WINAPI D3DXFillTexture(struct IDirect3DTexture9 *texture, LPD3DXFILL2D function, void *funcdata) { + IDirect3DSurface9 *surface, *temp_surface; DWORD miplevels; DWORD m, x, y; D3DSURFACE_DESC desc; @@ -1331,26 +1332,34 @@ HRESULT WINAPI D3DXFillTexture(struct IDirect3DTexture9 *texture, LPD3DXFILL2D f D3DXVECTOR2 coord, size; const struct pixel_format_desc *format; BYTE *data; + HRESULT hr; - if (texture == NULL || function == NULL) + TRACE("texture %p, function %p, funcdata %p.\n", texture, function, funcdata); + + if (!texture || !function) return D3DERR_INVALIDCALL; miplevels = IDirect3DBaseTexture9_GetLevelCount(texture); for (m = 0; m < miplevels; m++) { - if (FAILED(IDirect3DTexture9_GetLevelDesc(texture, m, &desc))) - return D3DERR_INVALIDCALL; + if (FAILED(hr = IDirect3DTexture9_GetLevelDesc(texture, m, &desc))) + return hr; format = get_format_info(desc.Format); if (format->type != FORMAT_ARGB && format->type != FORMAT_ARGBF16 && format->type != FORMAT_ARGBF) { - FIXME("Unsupported texture format %#x\n", desc.Format); + FIXME("Unsupported texture format %#x.\n", desc.Format); return D3DERR_INVALIDCALL; } - if (FAILED(IDirect3DTexture9_LockRect(texture, m, &lock_rect, NULL, D3DLOCK_DISCARD))) - return D3DERR_INVALIDCALL; + if (FAILED(hr = IDirect3DTexture9_GetSurfaceLevel(texture, m, &surface))) + return hr; + if (FAILED(hr = lock_surface(surface, &lock_rect, &temp_surface, TRUE))) + { + IDirect3DSurface9_Release(surface); + return hr; + } size.x = 1.0f / desc.Width; size.y = 1.0f / desc.Height; @@ -1372,7 +1381,12 @@ HRESULT WINAPI D3DXFillTexture(struct IDirect3DTexture9 *texture, LPD3DXFILL2D f fill_texture(format, data + y * lock_rect.Pitch + x * format->bytes_per_pixel, &value); } } - IDirect3DTexture9_UnlockRect(texture, m); + if (FAILED(hr = unlock_surface(surface, &lock_rect, temp_surface, TRUE))) + { + IDirect3DSurface9_Release(surface); + return hr; + } + IDirect3DSurface9_Release(surface); } return D3D_OK; diff --git a/modules/rostests/winetests/d3dx9_36/texture.c b/modules/rostests/winetests/d3dx9_36/texture.c index 79cddc73ab6..1a92a85b63e 100644 --- a/modules/rostests/winetests/d3dx9_36/texture.c +++ b/modules/rostests/winetests/d3dx9_36/texture.c @@ -1007,59 +1007,103 @@ static void WINAPI fillfunc(D3DXVECTOR4 *value, const D3DXVECTOR2 *texcoord, static void test_D3DXFillTexture(IDirect3DDevice9 *device) { + static const struct + { + DWORD usage; + D3DPOOL pool; + } + test_access_types[] = + { + {0, D3DPOOL_MANAGED}, + {0, D3DPOOL_DEFAULT}, + {D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT}, + }; + IDirect3DTexture9 *tex; HRESULT hr; D3DLOCKED_RECT lock_rect; DWORD x, y, m; DWORD v[4], e[4]; DWORD value, expected, size, pitch; + unsigned int i; - size = 4; - hr = IDirect3DDevice9_CreateTexture(device, size, size, 0, 0, D3DFMT_A8R8G8B8, - D3DPOOL_MANAGED, &tex, NULL); - - if (SUCCEEDED(hr)) + for (i = 0; i < ARRAY_SIZE(test_access_types); ++i) { + size = 4; + hr = IDirect3DDevice9_CreateTexture(device, size, size, 0, test_access_types[i].usage, + D3DFMT_A8R8G8B8, test_access_types[i].pool, &tex, NULL); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i); + hr = D3DXFillTexture(tex, fillfunc, NULL); - ok(hr == D3D_OK, "D3DXFillTexture returned %#x, expected %#x\n", hr, D3D_OK); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i); for (m = 0; m < 3; m++) { - hr = IDirect3DTexture9_LockRect(tex, m, &lock_rect, NULL, D3DLOCK_READONLY); - ok(hr == D3D_OK, "Couldn't lock the texture, error %#x\n", hr); - if (SUCCEEDED(hr)) + IDirect3DSurface9 *src_surface, *temp_surface; + + hr = IDirect3DTexture9_GetSurfaceLevel(tex, m, &src_surface); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m); + temp_surface = src_surface; + + if (FAILED(hr = IDirect3DSurface9_LockRect(src_surface, &lock_rect, NULL, D3DLOCK_READONLY))) { - pitch = lock_rect.Pitch / sizeof(DWORD); - for (y = 0; y < size; y++) + hr = IDirect3DDevice9_CreateRenderTarget(device, size, size, + D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &temp_surface, NULL); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m); + hr = IDirect3DDevice9_StretchRect(device, src_surface, NULL, temp_surface, NULL, D3DTEXF_NONE); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m); + hr = IDirect3DSurface9_LockRect(temp_surface, &lock_rect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Unexpected hr %#x, i %u, m %u.\n", hr, i, m); + } + + pitch = lock_rect.Pitch / sizeof(DWORD); + for (y = 0; y < size; y++) + { + for (x = 0; x < size; x++) { - for (x = 0; x < size; x++) - { - value = ((DWORD *)lock_rect.pBits)[y * pitch + x]; - v[0] = (value >> 24) & 0xff; - v[1] = (value >> 16) & 0xff; - v[2] = (value >> 8) & 0xff; - v[3] = value & 0xff; - - e[0] = 0xff; - e[1] = (x + 0.5f) / size * 255.0f + 0.5f; - e[2] = (y + 0.5f) / size * 255.0f + 0.5f; - e[3] = 255.0f / size + 0.5f; - expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3]; + value = ((DWORD *)lock_rect.pBits)[y * pitch + x]; + v[0] = (value >> 24) & 0xff; + v[1] = (value >> 16) & 0xff; + v[2] = (value >> 8) & 0xff; + v[3] = value & 0xff; + + e[0] = 0xff; + e[1] = (x + 0.5f) / size * 255.0f + 0.5f; + e[2] = (y + 0.5f) / size * 255.0f + 0.5f; + e[3] = 255.0f / size + 0.5f; + expected = e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3]; - ok(color_match(v, e), - "Texel at (%u, %u) doesn't match: %#x, expected %#x\n", - x, y, value, expected); - } + ok(color_match(v, e), + "Texel at (%u, %u) doesn't match: %#x, expected %#x, i %u, m %u.\n", + x, y, value, expected, i, m); } - IDirect3DTexture9_UnlockRect(tex, m); } + IDirect3DSurface9_UnlockRect(temp_surface); + if (temp_surface != src_surface) + IDirect3DSurface9_Release(temp_surface); + IDirect3DSurface9_Release(src_surface); size >>= 1; } + IDirect3DTexture9_Release(tex); + } + + hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, D3DUSAGE_DEPTHSTENCIL, + D3DFMT_D16_LOCKABLE, D3DPOOL_DEFAULT, &tex, NULL); + if (hr == D3D_OK) + { + hr = D3DXFillTexture(tex, fillfunc, NULL); + todo_wine ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + IDirect3DTexture9_Release(tex); + } + hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, D3DUSAGE_DEPTHSTENCIL, + D3DFMT_D16, D3DPOOL_DEFAULT, &tex, NULL); + if (hr == D3D_OK) + { + hr = D3DXFillTexture(tex, fillfunc, NULL); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); IDirect3DTexture9_Release(tex); } - else - skip("Failed to create texture\n"); hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 1, 0, D3DFMT_A1R5G5B5, D3DPOOL_MANAGED, &tex, NULL); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index ff99278963a..8bc93affa53 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -33,4 +33,4 @@ files: include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h tags: - wine: 33be8439fc95ca8f005bd3a2b6790c101842c02e + wine: 4e44d74afb12b40f673e3be0a91cd523013544cd
4 years, 10 months
1
0
0
0
[reactos] 04/74: [WINESYNC]d3dx9: Factor out {lock|unlock}_surface() functions.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b50ef9007cbec00929ebe…
commit b50ef9007cbec00929ebe7c2fba2676657c56f54 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Jan 4 01:48:04 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [WINESYNC]d3dx9: Factor out {lock|unlock}_surface() functions. Signed-off-by: Paul Gofman <gofmanp(a)gmail.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 33be8439fc95ca8f005bd3a2b6790c101842c02e by Paul Gofman <gofmanp(a)gmail.com> --- dll/directx/wine/d3dx9_36/surface.c | 75 +++++++++++++++++++++++++------------ sdk/tools/winesync/d3dx9.cfg | 36 ++++++++++++++++++ 2 files changed, 88 insertions(+), 23 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index 11a0ee1a2fe..2d00cd1dcdc 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -199,6 +199,53 @@ static const struct { { 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000, D3DFMT_X8B8G8R8 }, }; +static HRESULT lock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock, + IDirect3DSurface9 **temp_surface) +{ + IDirect3DDevice9 *device; + D3DSURFACE_DESC desc; + HRESULT hr; + + *temp_surface = NULL; + if (FAILED(hr = IDirect3DSurface9_LockRect(surface, lock, NULL, D3DLOCK_READONLY))) + { + IDirect3DSurface9_GetDevice(surface, &device); + IDirect3DSurface9_GetDesc(surface, &desc); + if (FAILED(hr = IDirect3DDevice9_CreateRenderTarget(device, desc.Width, desc.Height, + desc.Format, D3DMULTISAMPLE_NONE, 0, TRUE, temp_surface, NULL))) + { + IDirect3DDevice9_Release(device); + return hr; + } + + if (SUCCEEDED(hr = IDirect3DDevice9_StretchRect(device, surface, NULL, *temp_surface, NULL, D3DTEXF_NONE))) + hr = IDirect3DSurface9_LockRect(*temp_surface, lock, NULL, D3DLOCK_READONLY); + IDirect3DDevice9_Release(device); + if (FAILED(hr)) + { + WARN("Failed to lock surface %p, usage %#x, pool %#x.\n", + surface, desc.Usage, desc.Pool); + IDirect3DSurface9_Release(*temp_surface); + *temp_surface = NULL; + return hr; + } + } + return hr; +} + +static HRESULT unlock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock, + IDirect3DSurface9 *temp_surface) +{ + HRESULT hr; + + if (!temp_surface) + return IDirect3DSurface9_UnlockRect(surface); + + hr = IDirect3DSurface9_UnlockRect(temp_surface); + IDirect3DSurface9_Release(temp_surface); + return hr; +} + static D3DFORMAT dds_rgb_to_d3dformat(const struct dds_pixel_format *pixel_format) { unsigned int i; @@ -1924,7 +1971,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromSurface(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, IDirect3DSurface9 *src_surface, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key) { - IDirect3DSurface9 *surface = src_surface; + IDirect3DSurface9 *temp_surface; D3DTEXTUREFILTERTYPE d3d_filter; IDirect3DDevice9 *device; D3DSURFACE_DESC src_desc; @@ -1979,32 +2026,14 @@ HRESULT WINAPI D3DXLoadSurfaceFromSurface(IDirect3DSurface9 *dst_surface, src_rect = &s; } - if (FAILED(IDirect3DSurface9_LockRect(surface, &lock, NULL, D3DLOCK_READONLY))) - { - IDirect3DSurface9_GetDevice(src_surface, &device); - if (FAILED(IDirect3DDevice9_CreateRenderTarget(device, src_desc.Width, src_desc.Height, - src_desc.Format, D3DMULTISAMPLE_NONE, 0, TRUE, &surface, NULL))) - { - IDirect3DDevice9_Release(device); - return D3DXERR_INVALIDDATA; - } - - if (SUCCEEDED(hr = IDirect3DDevice9_StretchRect(device, src_surface, NULL, surface, NULL, D3DTEXF_NONE))) - hr = IDirect3DSurface9_LockRect(surface, &lock, NULL, D3DLOCK_READONLY); - IDirect3DDevice9_Release(device); - if (FAILED(hr)) - { - IDirect3DSurface9_Release(surface); - return D3DXERR_INVALIDDATA; - } - } + if (FAILED(lock_surface(src_surface, &lock, &temp_surface))) + return D3DXERR_INVALIDDATA; hr = D3DXLoadSurfaceFromMemory(dst_surface, dst_palette, dst_rect, lock.pBits, src_desc.Format, lock.Pitch, src_palette, src_rect, filter, color_key); - IDirect3DSurface9_UnlockRect(surface); - if (surface != src_surface) - IDirect3DSurface9_Release(surface); + if (FAILED(unlock_surface(src_surface, &lock, temp_surface))) + return D3DXERR_INVALIDDATA; return hr; } diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg new file mode 100644 index 00000000000..ff99278963a --- /dev/null +++ b/sdk/tools/winesync/d3dx9.cfg @@ -0,0 +1,36 @@ +directories: + dlls/d3dx9_24: dll/directx/wine/d3dx9_24 + dlls/d3dx9_25: dll/directx/wine/d3dx9_25 + dlls/d3dx9_26: dll/directx/wine/d3dx9_26 + dlls/d3dx9_27: dll/directx/wine/d3dx9_27 + dlls/d3dx9_28: dll/directx/wine/d3dx9_28 + dlls/d3dx9_29: dll/directx/wine/d3dx9_29 + dlls/d3dx9_30: dll/directx/wine/d3dx9_30 + dlls/d3dx9_31: dll/directx/wine/d3dx9_31 + dlls/d3dx9_32: dll/directx/wine/d3dx9_32 + dlls/d3dx9_33: dll/directx/wine/d3dx9_33 + dlls/d3dx9_34: dll/directx/wine/d3dx9_34 + dlls/d3dx9_35: dll/directx/wine/d3dx9_35 + dlls/d3dx9_36: dll/directx/wine/d3dx9_36 + dlls/d3dx9_36/tests: modules/rostests/winetests/d3dx9_36 + dlls/d3dx9_37: dll/directx/wine/d3dx9_37 + dlls/d3dx9_38: dll/directx/wine/d3dx9_38 + dlls/d3dx9_39: dll/directx/wine/d3dx9_39 + dlls/d3dx9_40: dll/directx/wine/d3dx9_40 + dlls/d3dx9_41: dll/directx/wine/d3dx9_41 + dlls/d3dx9_42: dll/directx/wine/d3dx9_42 + dlls/d3dx9_43: dll/directx/wine/d3dx9_43 +files: + include/d3dx9.h: sdk/include/dxsdk/d3dx9.h + include/d3dx9anim.h: sdk/include/dxsdk/d3dx9anim.h + include/d3dx9core.h: sdk/include/dxsdk/d3dx9core.h + include/d3dx9effect.h: sdk/include/dxsdk/d3dx9effect.h + include/d3dx9math.h: sdk/include/dxsdk/d3dx9math.h + include/d3dx9math.inl: sdk/include/dxsdk/d3dx9math.inl + include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h + include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h + include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h + include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h + include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h +tags: + wine: 33be8439fc95ca8f005bd3a2b6790c101842c02e
4 years, 10 months
1
0
0
0
[reactos] 03/74: [D3DX9_36_WINETEST] Import from wine 4.0
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e404e9ee2f5d5b7e00a8b…
commit e404e9ee2f5d5b7e00a8b45fd5b2f7f143ff4ec4 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Dec 24 09:31:48 2019 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [D3DX9_36_WINETEST] Import from wine 4.0 --- modules/rostests/winetests/CMakeLists.txt | 1 + modules/rostests/winetests/d3dx9_36/CMakeLists.txt | 25 + modules/rostests/winetests/d3dx9_36/asm.c | 583 + modules/rostests/winetests/d3dx9_36/bmp1x1.bmp | Bin 0 -> 58 bytes modules/rostests/winetests/d3dx9_36/core.c | 1310 +++ modules/rostests/winetests/d3dx9_36/effect.c | 8030 +++++++++++++ modules/rostests/winetests/d3dx9_36/line.c | 155 + modules/rostests/winetests/d3dx9_36/math.c | 3687 ++++++ modules/rostests/winetests/d3dx9_36/mesh.c | 11256 +++++++++++++++++++ modules/rostests/winetests/d3dx9_36/res.vsh | 2 + modules/rostests/winetests/d3dx9_36/resources.h | 28 + modules/rostests/winetests/d3dx9_36/rsrc.rc | 31 + modules/rostests/winetests/d3dx9_36/shader.c | 6592 +++++++++++ modules/rostests/winetests/d3dx9_36/surface.c | 1465 +++ modules/rostests/winetests/d3dx9_36/testlist.c | 32 + modules/rostests/winetests/d3dx9_36/texture.c | 2264 ++++ modules/rostests/winetests/d3dx9_36/volume.c | 306 + modules/rostests/winetests/d3dx9_36/xfile.c | 389 + 18 files changed, 36156 insertions(+) diff --git a/modules/rostests/winetests/CMakeLists.txt b/modules/rostests/winetests/CMakeLists.txt index 8bb0f90d9f4..c4553c5a09c 100644 --- a/modules/rostests/winetests/CMakeLists.txt +++ b/modules/rostests/winetests/CMakeLists.txt @@ -35,6 +35,7 @@ add_subdirectory(cryptnet) add_subdirectory(cryptui) add_subdirectory(d3dcompiler_43) add_subdirectory(d3drm) +add_subdirectory(d3dx9_36) add_subdirectory(devenum) add_subdirectory(dinput) add_subdirectory(dinput8) diff --git a/modules/rostests/winetests/d3dx9_36/CMakeLists.txt b/modules/rostests/winetests/d3dx9_36/CMakeLists.txt new file mode 100644 index 00000000000..2a1dab147b7 --- /dev/null +++ b/modules/rostests/winetests/d3dx9_36/CMakeLists.txt @@ -0,0 +1,25 @@ + +add_executable(d3dx9_36_winetest + asm.c + core.c + effect.c + line.c + math.c + mesh.c + shader.c + surface.c + texture.c + volume.c + xfile.c + testlist.c + rsrc.rc) +target_compile_definitions(d3dx9_36_winetest PRIVATE -DUSE_WINE_TODOS -D__WINESRC__ -Disnan=_isnan) +if(MSVC) + # Disable warning C4477 (printf format warnings) + target_compile_options(d3dx9_36_winetest PRIVATE "/wd4477") +endif() + +target_link_libraries(d3dx9_36_winetest uuid dxguid) +set_module_type(d3dx9_36_winetest win32cui) +add_importlibs(d3dx9_36_winetest d3dx9_36 d3d9 user32 gdi32 msvcrt kernel32) +add_rostests_file(TARGET d3dx9_36_winetest) diff --git a/modules/rostests/winetests/d3dx9_36/asm.c b/modules/rostests/winetests/d3dx9_36/asm.c new file mode 100644 index 00000000000..4087bd89b09 --- /dev/null +++ b/modules/rostests/winetests/d3dx9_36/asm.c @@ -0,0 +1,583 @@ +/* + * Copyright (C) 2008 Stefan Dösinger + * Copyright (C) 2009 Matteo Bruni + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ +#define COBJMACROS +#define CONST_VTABLE +#include "wine/test.h" + +#include <d3dx9.h> + +#include "resources.h" + +static char temp_path[MAX_PATH]; + +static BOOL create_file(const char *filename, const char *data, const unsigned int size, char *out_path) +{ + DWORD written; + HANDLE hfile; + char path[MAX_PATH]; + + if (!*temp_path) + GetTempPathA(sizeof(temp_path), temp_path); + + strcpy(path, temp_path); + strcat(path, filename); + hfile = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + if (hfile == INVALID_HANDLE_VALUE) + return FALSE; + + if (WriteFile(hfile, data, size, &written, NULL)) + { + CloseHandle(hfile); + + if (out_path) + strcpy(out_path, path); + return TRUE; + } + + CloseHandle(hfile); + return FALSE; +} + +static void delete_file(const char *filename) +{ + char path[MAX_PATH]; + + strcpy(path, temp_path); + strcat(path, filename); + DeleteFileA(path); +} + +static BOOL create_directory(const char *name) +{ + char path[MAX_PATH]; + + strcpy(path, temp_path); + strcat(path, name); + return CreateDirectoryA(path, NULL); +} + +static void delete_directory(const char *name) +{ + char path[MAX_PATH]; + + strcpy(path, temp_path); + strcat(path, name); + RemoveDirectoryA(path); +} + +static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE include_type, + const char *filename, const void *parent_data, const void **data, UINT *bytes) +{ + char *buffer; + static const char shader[] = + "#include \"incl.vsh\"\n" + "mov REGISTER, v0\n"; + static const char include[] = "#define REGISTER r0\nvs.1.1\n"; + static const char include2[] = "#include \"incl3.vsh\"\n"; + static const char include3[] = "vs.1.1\n"; + + trace("filename %s.\n", filename); + trace("parent_data %p: %s.\n", parent_data, parent_data ? (char *)parent_data : "(null)"); + + if (!strcmp(filename, "shader.vsh")) + { + buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(shader)); + memcpy(buffer, shader, sizeof(shader)); + *bytes = sizeof(shader); + } + else if (!strcmp(filename, "incl.vsh")) + { + buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include)); + memcpy(buffer, include, sizeof(include)); + *bytes = sizeof(include); + /* This is included from the first D3DXAssembleShader with non-null ID3DXInclude test + * (parent_data == NULL) and from shader.vsh / shader[] (with matching parent_data). + * Allow both cases. */ + ok(parent_data == NULL || !strncmp(shader, parent_data, strlen(shader)), "wrong parent_data value\n"); + } + else if (!strcmp(filename, "incl2.vsh")) + { + buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include2)); + memcpy(buffer, include2, sizeof(include2)); + *bytes = sizeof(include2); + } + else if (!strcmp(filename, "incl3.vsh")) + { + buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include3)); + memcpy(buffer, include3, sizeof(include3)); + *bytes = sizeof(include3); + /* Also check for the correct parent_data content */ + ok(parent_data != NULL && !strncmp(include2, parent_data, strlen(include2)), "wrong parent_data value\n"); + } + else if (!strcmp(filename, "include/incl3.vsh")) + { + buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include)); + memcpy(buffer, include, sizeof(include)); + *bytes = sizeof(include); + ok(!parent_data, "wrong parent_data value\n"); + } + else + { + ok(0, "Unexpected #include for file %s.\n", filename); + return D3DERR_INVALIDCALL; + } + *data = buffer; + return S_OK; +} + +static HRESULT WINAPI testD3DXInclude_close(ID3DXInclude *iface, const void *data) +{ + HeapFree(GetProcessHeap(), 0, (void *)data); + return S_OK; +} + +static const struct ID3DXIncludeVtbl D3DXInclude_Vtbl = { + testD3DXInclude_open, + testD3DXInclude_close +}; + +struct D3DXIncludeImpl { + ID3DXInclude ID3DXInclude_iface; +}; + +static void assembleshader_test(void) +{ + static const char test1[] = + "vs.1.1\n" + "mov DEF2, v0\n"; + static const char testincl[] = + "#define REGISTER r0\n" + "vs.1.1\n"; + static const char testshader[] = + "#include \"incl.vsh\"\n" + "mov REGISTER, v0\n"; + static const char testshader2[] = + "#include \"incl2.vsh\"\n" + "mov REGISTER, v0\n"; + static const char testshader3[] = + "#include \"include/incl3.vsh\"\n" + "mov REGISTER, v0\n"; + static const char testincl3[] = + "#include \"incl4.vsh\"\n"; + static const char testincl4_ok[] = + "#define REGISTER r0\n" + "vs.1.1\n"; + static const char testincl4_wrong[] = + "#error \"wrong include\"\n"; + HRESULT hr; + ID3DXBuffer *shader, *messages; + static const D3DXMACRO defines[] = { + { + "DEF1", "10 + 15" + }, + { + "DEF2", "r0" + }, + { + NULL, NULL + } + }; + struct D3DXIncludeImpl include; + char shader_vsh_path[MAX_PATH], shader3_vsh_path[MAX_PATH]; + static const WCHAR shader_filename_w[] = {'s','h','a','d','e','r','.','v','s','h',0}; + + /* pDefines test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShader(test1, strlen(test1), + defines, NULL, D3DXSHADER_SKIPVALIDATION, + &shader, &messages); + ok(hr == D3D_OK, "pDefines test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* NULL messages test */ + shader = NULL; + hr = D3DXAssembleShader(test1, strlen(test1), + defines, NULL, D3DXSHADER_SKIPVALIDATION, + &shader, NULL); + ok(hr == D3D_OK, "NULL messages test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(shader) ID3DXBuffer_Release(shader); + + /* NULL shader test */ + messages = NULL; + hr = D3DXAssembleShader(test1, strlen(test1), + defines, NULL, D3DXSHADER_SKIPVALIDATION, + NULL, &messages); + ok(hr == D3D_OK, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + + /* pInclude test */ + shader = NULL; + messages = NULL; + include.ID3DXInclude_iface.lpVtbl = &D3DXInclude_Vtbl; + hr = D3DXAssembleShader(testshader, strlen(testshader), NULL, &include.ID3DXInclude_iface, + D3DXSHADER_SKIPVALIDATION, &shader, &messages); + ok(hr == D3D_OK, "pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* "unexpected #include file from memory" test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShader(testshader, strlen(testshader), + NULL, NULL, D3DXSHADER_SKIPVALIDATION, + &shader, &messages); + ok(hr == D3DXERR_INVALIDDATA, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* recursive #include test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShader(testshader2, strlen(testshader2), NULL, &include.ID3DXInclude_iface, + D3DXSHADER_SKIPVALIDATION, &shader, &messages); + ok(hr == D3D_OK, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("recursive D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* #include with a path. */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShader(testshader3, strlen(testshader3), NULL, &include.ID3DXInclude_iface, + D3DXSHADER_SKIPVALIDATION, &shader, &messages); + ok(hr == D3D_OK, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000ffff); + if (messages) + { + trace("Path search D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if (shader) + ID3DXBuffer_Release(shader); + + if (create_file("shader.vsh", testshader, sizeof(testshader) - 1, shader_vsh_path)) + { + create_file("incl.vsh", testincl, sizeof(testincl) - 1, NULL); + + /* D3DXAssembleShaderFromFile + #include test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShaderFromFileA(shader_vsh_path, + NULL, NULL, D3DXSHADER_SKIPVALIDATION, + &shader, &messages); + ok(hr == D3D_OK, "D3DXAssembleShaderFromFile test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* D3DXAssembleShaderFromFile + pInclude test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShaderFromFileA("shader.vsh", NULL, &include.ID3DXInclude_iface, + D3DXSHADER_SKIPVALIDATION, &shader, &messages); + ok(hr == D3D_OK, "D3DXAssembleShaderFromFile + pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + create_file("shader3.vsh", testshader3, sizeof(testshader3) - 1, shader3_vsh_path); + create_file("incl4.vsh", testincl4_wrong, sizeof(testincl4_wrong) - 1, NULL); + if (create_directory("include")) + { + create_file("include\\incl3.vsh", testincl3, sizeof(testincl3) - 1, NULL); + create_file("include\\incl4.vsh", testincl4_ok, sizeof(testincl4_ok) - 1, NULL); + + /* path search #include test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShaderFromFileA(shader3_vsh_path, NULL, NULL, + D3DXSHADER_SKIPVALIDATION, + &shader, &messages); + ok(hr == D3D_OK, "D3DXAssembleShaderFromFile path search test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShaderFromFile path search messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + } else skip("Couldn't create \"include\" directory\n"); + + delete_file("shader.vsh"); + delete_file("incl.vsh"); + delete_file("shader3.vsh"); + delete_file("incl4.vsh"); + delete_file("include\\incl3.vsh"); + delete_file("include\\incl4.vsh"); + delete_directory("include"); + + /* The main shader is also to be loaded through the ID3DXInclude object. */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShaderFromFileA("shader.vsh", NULL, &include.ID3DXInclude_iface, + D3DXSHADER_SKIPVALIDATION, &shader, &messages); + ok(hr == D3D_OK, "D3DXAssembleShaderFromFile + pInclude main shader test failed with error 0x%x - %d\n", + hr, hr & 0x0000ffff); + if (messages) + { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if (shader) + ID3DXBuffer_Release(shader); + + shader = NULL; + messages = NULL; + hr = D3DXAssembleShaderFromFileW(shader_filename_w, NULL, &include.ID3DXInclude_iface, + D3DXSHADER_SKIPVALIDATION, &shader, &messages); + ok(hr == D3D_OK, "D3DXAssembleShaderFromFile + pInclude main shader test failed with error 0x%x - %d\n", + hr, hr & 0x0000ffff); + if (messages) + { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if (shader) + ID3DXBuffer_Release(shader); + } else skip("Couldn't create \"shader.vsh\"\n"); + + /* NULL shader tests */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShader(NULL, 0, + NULL, NULL, D3DXSHADER_SKIPVALIDATION, + &shader, &messages); + ok(hr == D3DXERR_INVALIDDATA, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + shader = NULL; + messages = NULL; + hr = D3DXAssembleShaderFromFileA("nonexistent.vsh", + NULL, NULL, D3DXSHADER_SKIPVALIDATION, + &shader, &messages); + ok(hr == D3DXERR_INVALIDDATA || hr == E_FAIL, /* I get this on WinXP */ + "D3DXAssembleShaderFromFile nonexistent file test failed with error 0x%x - %d\n", + hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShaderFromFile messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* D3DXAssembleShaderFromResource test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShaderFromResourceA(NULL, MAKEINTRESOURCEA(IDB_ASMSHADER), + NULL, NULL, D3DXSHADER_SKIPVALIDATION, + &shader, &messages); + ok(hr == D3D_OK, "D3DXAssembleShaderFromResource test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShaderFromResource messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* D3DXAssembleShaderFromResource with missing shader resource test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShaderFromResourceA(NULL, "notexisting", + NULL, NULL, D3DXSHADER_SKIPVALIDATION, + &shader, &messages); + ok(hr == D3DXERR_INVALIDDATA, "D3DXAssembleShaderFromResource NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXAssembleShaderFromResource messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); +} + +static void d3dxpreprocess_test(void) +{ + static const char testincl[] = + "#define REGISTER r0\n" + "vs.1.1\n"; + static const char testshader[] = + "#include \"incl.vsh\"\n" + "mov REGISTER, v0\n"; + static const char testshader3[] = + "#include \"include/incl3.vsh\"\n" + "mov REGISTER, v0\n"; + static const char testincl3[] = + "#include \"incl4.vsh\"\n"; + static const char testincl4_ok[] = + "#define REGISTER r0\n" + "vs.1.1\n"; + static const char testincl4_wrong[] = + "#error \"wrong include\"\n"; + HRESULT hr; + ID3DXBuffer *shader, *messages; + char shader_vsh_path[MAX_PATH], shader3_vsh_path[MAX_PATH]; + static struct D3DXIncludeImpl include = {{&D3DXInclude_Vtbl}}; + static const WCHAR shader_filename_w[] = {'s','h','a','d','e','r','.','v','s','h',0}; + + if (create_file("shader.vsh", testshader, sizeof(testshader) - 1, shader_vsh_path)) + { + create_file("incl.vsh", testincl, sizeof(testincl) - 1, NULL); + create_file("shader3.vsh", testshader3, sizeof(testshader3) - 1, shader3_vsh_path); + create_file("incl4.vsh", testincl4_wrong, sizeof(testincl4_wrong) - 1, NULL); + if (create_directory("include")) + { + create_file("include\\incl3.vsh", testincl3, sizeof(testincl3) - 1, NULL); + create_file("include\\incl4.vsh", testincl4_ok, sizeof(testincl4_ok) - 1, NULL); + + /* path search #include test */ + shader = NULL; + messages = NULL; + hr = D3DXPreprocessShaderFromFileA(shader3_vsh_path, NULL, NULL, + &shader, &messages); + ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile path search test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXPreprocessShaderFromFile path search messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + } else skip("Couldn't create \"include\" directory\n"); + + /* D3DXPreprocessShaderFromFile + #include test */ + shader = NULL; + messages = NULL; + hr = D3DXPreprocessShaderFromFileA(shader_vsh_path, + NULL, NULL, + &shader, &messages); + ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXPreprocessShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* D3DXPreprocessShaderFromFile + pInclude test */ + shader = NULL; + messages = NULL; + hr = D3DXPreprocessShaderFromFileA("shader.vsh", NULL, &include.ID3DXInclude_iface, + &shader, &messages); + ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile + pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXPreprocessShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + delete_file("shader.vsh"); + delete_file("incl.vsh"); + delete_file("shader3.vsh"); + delete_file("incl4.vsh"); + delete_file("include\\incl3.vsh"); + delete_file("include\\incl4.vsh"); + delete_directory("include"); + + /* The main shader is also to be loaded through the ID3DXInclude object. */ + shader = NULL; + messages = NULL; + hr = D3DXPreprocessShaderFromFileA("shader.vsh", NULL, &include.ID3DXInclude_iface, + &shader, &messages); + ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile + pInclude main shader test failed with error 0x%x - %d\n", + hr, hr & 0x0000ffff); + if (messages) + { + trace("D3DXPreprocessShaderFromFile messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if (shader) + ID3DXBuffer_Release(shader); + + shader = NULL; + messages = NULL; + hr = D3DXPreprocessShaderFromFileW(shader_filename_w, NULL, &include.ID3DXInclude_iface, + &shader, &messages); + ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile + pInclude main shader test failed with error 0x%x - %d\n", + hr, hr & 0x0000ffff); + if (messages) + { + trace("D3DXPreprocessShaderFromFile messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if (shader) + ID3DXBuffer_Release(shader); + } else skip("Couldn't create \"shader.vsh\"\n"); + + /* NULL shader tests */ + shader = NULL; + messages = NULL; + hr = D3DXPreprocessShaderFromFileA("nonexistent.vsh", + NULL, NULL, + &shader, &messages); + ok(hr == D3DXERR_INVALIDDATA || hr == E_FAIL, /* I get this on WinXP */ + "D3DXPreprocessShaderFromFile nonexistent file test failed with error 0x%x - %d\n", + hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXPreprocessShaderFromFile messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* D3DXPreprocessShaderFromResource test */ + shader = NULL; + messages = NULL; + hr = D3DXPreprocessShaderFromResourceA(NULL, MAKEINTRESOURCEA(IDB_ASMSHADER), + NULL, NULL, + &shader, &messages); + ok(hr == D3D_OK, "D3DXPreprocessShaderFromResource test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXPreprocessShaderFromResource messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); + + /* D3DXPreprocessShaderFromResource with missing shader resource test */ + shader = NULL; + messages = NULL; + hr = D3DXPreprocessShaderFromResourceA(NULL, "notexisting", + NULL, NULL, + &shader, &messages); + ok(hr == D3DXERR_INVALIDDATA, "D3DXPreprocessShaderFromResource NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if(messages) { + trace("D3DXPreprocessShaderFromResource messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if(shader) ID3DXBuffer_Release(shader); +} + +START_TEST(asm) +{ + assembleshader_test(); + + d3dxpreprocess_test(); +} diff --git a/modules/rostests/winetests/d3dx9_36/bmp1x1.bmp b/modules/rostests/winetests/d3dx9_36/bmp1x1.bmp new file mode 100644 index 00000000000..7f87ecf450e Binary files /dev/null and b/modules/rostests/winetests/d3dx9_36/bmp1x1.bmp differ diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c new file mode 100644 index 00000000000..fa874a5ef51 --- /dev/null +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -0,0 +1,1310 @@ +/* + * Tests for the D3DX9 core interfaces + * + * Copyright 2009 Tony Wasserka + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS +#include "wine/test.h" +#include <dxerr9.h> +#include "d3dx9core.h" + +static inline int get_ref(IUnknown *obj) +{ + IUnknown_AddRef(obj); + return IUnknown_Release(obj); +} + +#define check_ref(obj, exp) _check_ref(__LINE__, obj, exp) +static inline void _check_ref(unsigned int line, IUnknown *obj, int exp) +{ + int ref = get_ref(obj); + ok_(__FILE__, line)(exp == ref, "Invalid refcount. Expected %d, got %d\n", exp, ref); +} + +#define check_release(obj, exp) _check_release(__LINE__, obj, exp) +static inline void _check_release(unsigned int line, IUnknown *obj, int exp) +{ + int ref = IUnknown_Release(obj); + ok_(__FILE__, line)(ref == exp, "Invalid refcount. Expected %d, got %d\n", exp, ref); +} + +#define admitted_error 0.0001f +static inline void check_mat(D3DXMATRIX got, D3DXMATRIX exp) +{ + int i, j, equal=1; + for (i=0; i<4; i++) + for (j=0; j<4; j++) + if (fabs(U(exp).m[i][j]-U(got).m[i][j]) > admitted_error) + equal=0; + + ok(equal, "Got matrix\n\t(%f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f)\n" + "Expected matrix=\n\t(%f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f)\n", + U(got).m[0][0],U(got).m[0][1],U(got).m[0][2],U(got).m[0][3], + U(got).m[1][0],U(got).m[1][1],U(got).m[1][2],U(got).m[1][3], + U(got).m[2][0],U(got).m[2][1],U(got).m[2][2],U(got).m[2][3], + U(got).m[3][0],U(got).m[3][1],U(got).m[3][2],U(got).m[3][3], + U(exp).m[0][0],U(exp).m[0][1],U(exp).m[0][2],U(exp).m[0][3], + U(exp).m[1][0],U(exp).m[1][1],U(exp).m[1][2],U(exp).m[1][3], + U(exp).m[2][0],U(exp).m[2][1],U(exp).m[2][2],U(exp).m[2][3], + U(exp).m[3][0],U(exp).m[3][1],U(exp).m[3][2],U(exp).m[3][3]); +} + +static void test_ID3DXBuffer(void) +{ + ID3DXBuffer *buffer; + HRESULT hr; + ULONG count; + DWORD size; + + hr = D3DXCreateBuffer(10, NULL); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateBuffer failed, got %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateBuffer(0, &buffer); + ok(hr == D3D_OK, "D3DXCreateBuffer failed, got %#x, expected %#x\n", hr, D3D_OK); + + size = ID3DXBuffer_GetBufferSize(buffer); + ok(!size, "GetBufferSize failed, got %u, expected %u\n", size, 0); + + count = ID3DXBuffer_Release(buffer); + ok(!count, "ID3DXBuffer has %u references left\n", count); + + hr = D3DXCreateBuffer(3, &buffer); + ok(hr == D3D_OK, "D3DXCreateBuffer failed, got %#x, expected %#x\n", hr, D3D_OK); + + size = ID3DXBuffer_GetBufferSize(buffer); + ok(size == 3, "GetBufferSize failed, got %u, expected %u\n", size, 3); + + count = ID3DXBuffer_Release(buffer); + ok(!count, "ID3DXBuffer has %u references left\n", count); +} + +static void test_ID3DXSprite(IDirect3DDevice9 *device) +{ + ID3DXSprite *sprite; + IDirect3D9 *d3d; + IDirect3DDevice9 *cmpdev; + IDirect3DTexture9 *tex1, *tex2; + D3DXMATRIX mat, cmpmat; + D3DVIEWPORT9 vp; + RECT rect; + D3DXVECTOR3 pos, center; + HRESULT hr; + + IDirect3DDevice9_GetDirect3D(device, &d3d); + hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8); + IDirect3D9_Release(d3d); + ok (hr == D3D_OK, "D3DFMT_A8R8G8B8 not supported\n"); + if (FAILED(hr)) return; + + hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex1, NULL); + ok (hr == D3D_OK, "Failed to create first texture (error code: %#x)\n", hr); + if (FAILED(hr)) return; + + hr = IDirect3DDevice9_CreateTexture(device, 32, 32, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex2, NULL); + ok (hr == D3D_OK, "Failed to create second texture (error code: %#x)\n", hr); + if (FAILED(hr)) { + IDirect3DTexture9_Release(tex1); + return; + } + + /* Test D3DXCreateSprite */ + hr = D3DXCreateSprite(device, NULL); + ok (hr == D3DERR_INVALIDCALL, "D3DXCreateSprite returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateSprite(NULL, &sprite); + ok (hr == D3DERR_INVALIDCALL, "D3DXCreateSprite returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateSprite(device, &sprite); + ok (hr == D3D_OK, "D3DXCreateSprite returned %#x, expected %#x\n", hr, D3D_OK); + + + /* Test ID3DXSprite_GetDevice */ + hr = ID3DXSprite_GetDevice(sprite, NULL); + ok (hr == D3DERR_INVALIDCALL, "GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXSprite_GetDevice(sprite, &cmpdev); /* cmpdev == NULL */ + ok (hr == D3D_OK, "GetDevice returned %#x, expected %#x\n", hr, D3D_OK); + + hr = ID3DXSprite_GetDevice(sprite, &cmpdev); /* cmpdev != NULL */ + ok (hr == D3D_OK, "GetDevice returned %#x, expected %#x\n", hr, D3D_OK); + + IDirect3DDevice9_Release(device); + IDirect3DDevice9_Release(device); + + + /* Test ID3DXSprite_GetTransform */ + hr = ID3DXSprite_GetTransform(sprite, NULL); + ok (hr == D3DERR_INVALIDCALL, "GetTransform returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXSprite_GetTransform(sprite, &mat); + ok (hr == D3D_OK, "GetTransform returned %#x, expected %#x\n", hr, D3D_OK); + if(SUCCEEDED(hr)) { + D3DXMATRIX identity; + D3DXMatrixIdentity(&identity); + check_mat(mat, identity); + } + + /* Test ID3DXSprite_SetTransform */ + /* Set a transform and test if it gets returned correctly */ + U(mat).m[0][0]=2.1f; U(mat).m[0][1]=6.5f; U(mat).m[0][2]=-9.6f; U(mat).m[0][3]=1.7f; + U(mat).m[1][0]=4.2f; U(mat).m[1][1]=-2.5f; U(mat).m[1][2]=2.1f; U(mat).m[1][3]=5.5f; + U(mat).m[2][0]=-2.6f; U(mat).m[2][1]=0.3f; U(mat).m[2][2]=8.6f; U(mat).m[2][3]=8.4f; + U(mat).m[3][0]=6.7f; U(mat).m[3][1]=-5.1f; U(mat).m[3][2]=6.1f; U(mat).m[3][3]=2.2f; + + hr = ID3DXSprite_SetTransform(sprite, NULL); + ok (hr == D3DERR_INVALIDCALL, "SetTransform returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXSprite_SetTransform(sprite, &mat); + ok (hr == D3D_OK, "SetTransform returned %#x, expected %#x\n", hr, D3D_OK); + if(SUCCEEDED(hr)) { + hr=ID3DXSprite_GetTransform(sprite, &cmpmat); + if(SUCCEEDED(hr)) check_mat(cmpmat, mat); + else skip("GetTransform returned %#x\n", hr); + } + + /* Test ID3DXSprite_SetWorldViewLH/RH */ + todo_wine { + hr = ID3DXSprite_SetWorldViewLH(sprite, &mat, &mat); + ok (hr == D3D_OK, "SetWorldViewLH returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_SetWorldViewLH(sprite, NULL, &mat); + ok (hr == D3D_OK, "SetWorldViewLH returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_SetWorldViewLH(sprite, &mat, NULL); + ok (hr == D3D_OK, "SetWorldViewLH returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_SetWorldViewLH(sprite, NULL, NULL); + ok (hr == D3D_OK, "SetWorldViewLH returned %#x, expected %#x\n", hr, D3D_OK); + + hr = ID3DXSprite_SetWorldViewRH(sprite, &mat, &mat); + ok (hr == D3D_OK, "SetWorldViewRH returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_SetWorldViewRH(sprite, NULL, &mat); + ok (hr == D3D_OK, "SetWorldViewRH returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_SetWorldViewRH(sprite, &mat, NULL); + ok (hr == D3D_OK, "SetWorldViewRH returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_SetWorldViewRH(sprite, NULL, NULL); + ok (hr == D3D_OK, "SetWorldViewRH returned %#x, expected %#x\n", hr, D3D_OK); + } + IDirect3DDevice9_BeginScene(device); + + /* Test ID3DXSprite_Begin*/ + hr = ID3DXSprite_Begin(sprite, 0); + ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK); + + IDirect3DDevice9_GetTransform(device, D3DTS_WORLD, &mat); + D3DXMatrixIdentity(&cmpmat); + check_mat(mat, cmpmat); + + IDirect3DDevice9_GetTransform(device, D3DTS_VIEW, &mat); + check_mat(mat, cmpmat); + + IDirect3DDevice9_GetTransform(device, D3DTS_PROJECTION, &mat); + IDirect3DDevice9_GetViewport(device, &vp); + D3DXMatrixOrthoOffCenterLH(&cmpmat, vp.X+0.5f, (float)vp.Width+vp.X+0.5f, (float)vp.Height+vp.Y+0.5f, vp.Y+0.5f, vp.MinZ, vp.MaxZ); + check_mat(mat, cmpmat); + + /* Test ID3DXSprite_Flush and ID3DXSprite_End */ + hr = ID3DXSprite_Flush(sprite); + ok (hr == D3D_OK, "Flush returned %#x, expected %#x\n", hr, D3D_OK); + + hr = ID3DXSprite_End(sprite); + ok (hr == D3D_OK, "End returned %#x, expected %#x\n", hr, D3D_OK); + + hr = ID3DXSprite_Flush(sprite); /* May not be called before next Begin */ + ok (hr == D3DERR_INVALIDCALL, "Flush returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXSprite_End(sprite); + ok (hr == D3DERR_INVALIDCALL, "End returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + /* Test ID3DXSprite_Draw */ + hr = ID3DXSprite_Begin(sprite, 0); + ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK); + + if(FAILED(hr)) skip("Couldn't ID3DXSprite_Begin, can't test ID3DXSprite_Draw\n"); + else { /* Feed the sprite batch */ + int texref1, texref2; + + SetRect(&rect, 53, 12, 142, 165); + pos.x = 2.2f; pos.y = 4.5f; pos.z = 5.1f; + center.x = 11.3f; center.y = 3.4f; center.z = 1.2f; + + texref1 = get_ref((IUnknown*)tex1); + texref2 = get_ref((IUnknown*)tex2); + + hr = ID3DXSprite_Draw(sprite, NULL, &rect, ¢er, &pos, D3DCOLOR_XRGB(255, 255, 255)); + ok (hr == D3DERR_INVALIDCALL, "Draw returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXSprite_Draw(sprite, tex1, &rect, ¢er, &pos, D3DCOLOR_XRGB(255, 255, 255)); + ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Draw(sprite, tex2, &rect, ¢er, &pos, D3DCOLOR_XRGB( 3, 45, 66)); + ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Draw(sprite, tex1, NULL, ¢er, &pos, D3DCOLOR_XRGB(255, 255, 255)); + ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Draw(sprite, tex1, &rect, NULL, &pos, D3DCOLOR_XRGB(255, 255, 255)); + ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Draw(sprite, tex1, &rect, ¢er, NULL, D3DCOLOR_XRGB(255, 255, 255)); + ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Draw(sprite, tex1, NULL, NULL, NULL, 0); + ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK); + + check_ref((IUnknown*)tex1, texref1+5); check_ref((IUnknown*)tex2, texref2+1); + hr = ID3DXSprite_Flush(sprite); + ok (hr == D3D_OK, "Flush returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Flush(sprite); /* Flushing twice should work */ + ok (hr == D3D_OK, "Flush returned %#x, expected %#x\n", hr, D3D_OK); + check_ref((IUnknown*)tex1, texref1); check_ref((IUnknown*)tex2, texref2); + + hr = ID3DXSprite_End(sprite); + ok (hr == D3D_OK, "End returned %#x, expected %#x\n", hr, D3D_OK); + } + + /* Test ID3DXSprite_OnLostDevice and ID3DXSprite_OnResetDevice */ + /* Both can be called twice */ + hr = ID3DXSprite_OnLostDevice(sprite); + ok (hr == D3D_OK, "OnLostDevice returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_OnLostDevice(sprite); + ok (hr == D3D_OK, "OnLostDevice returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_OnResetDevice(sprite); + ok (hr == D3D_OK, "OnResetDevice returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_OnResetDevice(sprite); + ok (hr == D3D_OK, "OnResetDevice returned %#x, expected %#x\n", hr, D3D_OK); + + /* Make sure everything works like before */ + hr = ID3DXSprite_Begin(sprite, 0); + ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Draw(sprite, tex2, &rect, ¢er, &pos, D3DCOLOR_XRGB(255, 255, 255)); + ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Flush(sprite); + ok (hr == D3D_OK, "Flush returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_End(sprite); + ok (hr == D3D_OK, "End returned %#x, expected %#x\n", hr, D3D_OK); + + /* OnResetDevice makes the interface "forget" the Begin call */ + hr = ID3DXSprite_Begin(sprite, 0); + ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_OnResetDevice(sprite); + ok (hr == D3D_OK, "OnResetDevice returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_End(sprite); + ok (hr == D3DERR_INVALIDCALL, "End returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + IDirect3DDevice9_EndScene(device); + check_release((IUnknown*)sprite, 0); + check_release((IUnknown*)tex2, 0); + check_release((IUnknown*)tex1, 0); +} + +static void test_ID3DXFont(IDirect3DDevice9 *device) +{ + static const WCHAR testW[] = {'t','e','s','t',0}; + static const struct + { + int font_height; + unsigned int expected_size; + unsigned int expected_levels; + } + tests[] = + { + { 6, 128, 4 }, + { 8, 128, 4 }, + { 10, 256, 5 }, + { 12, 256, 5 }, + { 72, 256, 8 }, + }; + const unsigned int size = ARRAY_SIZE(testW); + D3DXFONT_DESCA desc; + ID3DXSprite *sprite; + int ref, i, height; + ID3DXFont *font; + HRESULT hr; + RECT rect; + + /* D3DXCreateFont */ + ref = get_ref((IUnknown*)device); + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); + check_ref((IUnknown*)device, ref + 1); + check_release((IUnknown*)font, 0); + check_ref((IUnknown*)device, ref); + + hr = D3DXCreateFontA(device, 0, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); + ID3DXFont_Release(font); + + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, NULL, &font); + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); + ID3DXFont_Release(font); + + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "", &font); + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); + ID3DXFont_Release(font); + + hr = D3DXCreateFontA(NULL, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", NULL); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateFontA(NULL, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", NULL); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + + /* D3DXCreateFontIndirect */ + desc.Height = 12; + desc.Width = 0; + desc.Weight = FW_DONTCARE; + desc.MipLevels = 0; + desc.Italic = FALSE; + desc.CharSet = DEFAULT_CHARSET; + desc.OutputPrecision = OUT_DEFAULT_PRECIS; + desc.Quality = DEFAULT_QUALITY; + desc.PitchAndFamily = DEFAULT_PITCH; + strcpy(desc.FaceName, "Arial"); + hr = D3DXCreateFontIndirectA(device, &desc, &font); + ok(hr == D3D_OK, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr, D3D_OK); + ID3DXFont_Release(font); + + hr = D3DXCreateFontIndirectA(NULL, &desc, &font); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateFontIndirectA(device, NULL, &font); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateFontIndirectA(device, &desc, NULL); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + + /* ID3DXFont_GetDevice */ + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + if(SUCCEEDED(hr)) { + IDirect3DDevice9 *bufdev; + + hr = ID3DXFont_GetDevice(font, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + ref = get_ref((IUnknown*)device); + hr = ID3DXFont_GetDevice(font, &bufdev); + ok(hr == D3D_OK, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3D_OK); + check_release((IUnknown*)bufdev, ref); + + ID3DXFont_Release(font); + } else skip("Failed to create a ID3DXFont object\n"); + + + /* ID3DXFont_GetDesc */ + hr = D3DXCreateFontA(device, 12, 8, FW_BOLD, 2, TRUE, ANSI_CHARSET, OUT_RASTER_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH, "Arial", &font); + if(SUCCEEDED(hr)) { + hr = ID3DXFont_GetDescA(font, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXFont_GetDescA(font, &desc); + ok(hr == D3D_OK, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3D_OK); + + ok(desc.Height == 12, "ID3DXFont_GetDesc returned font height %d, expected %d\n", desc.Height, 12); + ok(desc.Width == 8, "ID3DXFont_GetDesc returned font width %d, expected %d\n", desc.Width, 8); + ok(desc.Weight == FW_BOLD, "ID3DXFont_GetDesc returned font weight %d, expected %d\n", desc.Weight, FW_BOLD); + ok(desc.MipLevels == 2, "ID3DXFont_GetDesc returned font miplevels %d, expected %d\n", desc.MipLevels, 2); + ok(desc.Italic == TRUE, "ID3DXFont_GetDesc says Italic was %d, but Italic should be %d\n", desc.Italic, TRUE); + ok(desc.CharSet == ANSI_CHARSET, "ID3DXFont_GetDesc returned font charset %d, expected %d\n", desc.CharSet, ANSI_CHARSET); + ok(desc.OutputPrecision == OUT_RASTER_PRECIS, "ID3DXFont_GetDesc returned an output precision of %d, expected %d\n", desc.OutputPrecision, OUT_RASTER_PRECIS); + ok(desc.Quality == ANTIALIASED_QUALITY, "ID3DXFont_GetDesc returned font quality %d, expected %d\n", desc.Quality, ANTIALIASED_QUALITY); + ok(desc.PitchAndFamily == VARIABLE_PITCH, "ID3DXFont_GetDesc returned pitch and family %d, expected %d\n", desc.PitchAndFamily, VARIABLE_PITCH); + ok(strcmp(desc.FaceName, "Arial") == 0, "ID3DXFont_GetDesc returned facename \"%s\", expected \"%s\"\n", desc.FaceName, "Arial"); + + ID3DXFont_Release(font); + } else skip("Failed to create a ID3DXFont object\n"); + + + /* ID3DXFont_GetDC + ID3DXFont_GetTextMetrics */ + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + if(SUCCEEDED(hr)) { + HDC hdc; + + hdc = ID3DXFont_GetDC(font); + ok(hdc != NULL, "ID3DXFont_GetDC returned an invalid handle\n"); + if(hdc) { + TEXTMETRICA metrics, expmetrics; + BOOL ret; + + ret = ID3DXFont_GetTextMetricsA(font, &metrics); + ok(ret, "ID3DXFont_GetTextMetricsA failed\n"); + ret = GetTextMetricsA(hdc, &expmetrics); + ok(ret, "GetTextMetricsA failed\n"); + + ok(metrics.tmHeight == expmetrics.tmHeight, "Returned height %d, expected %d\n", metrics.tmHeight, expmetrics.tmHeight); + ok(metrics.tmAscent == expmetrics.tmAscent, "Returned ascent %d, expected %d\n", metrics.tmAscent, expmetrics.tmAscent); + ok(metrics.tmDescent == expmetrics.tmDescent, "Returned descent %d, expected %d\n", metrics.tmDescent, expmetrics.tmDescent); + ok(metrics.tmInternalLeading == expmetrics.tmInternalLeading, "Returned internal leading %d, expected %d\n", metrics.tmInternalLeading, expmetrics.tmInternalLeading); + ok(metrics.tmExternalLeading == expmetrics.tmExternalLeading, "Returned external leading %d, expected %d\n", metrics.tmExternalLeading, expmetrics.tmExternalLeading); + ok(metrics.tmAveCharWidth == expmetrics.tmAveCharWidth, "Returned average char width %d, expected %d\n", metrics.tmAveCharWidth, expmetrics.tmAveCharWidth); + ok(metrics.tmMaxCharWidth == expmetrics.tmMaxCharWidth, "Returned maximum char width %d, expected %d\n", metrics.tmMaxCharWidth, expmetrics.tmMaxCharWidth); + ok(metrics.tmWeight == expmetrics.tmWeight, "Returned weight %d, expected %d\n", metrics.tmWeight, expmetrics.tmWeight); + ok(metrics.tmOverhang == expmetrics.tmOverhang, "Returned overhang %d, expected %d\n", metrics.tmOverhang, expmetrics.tmOverhang); + ok(metrics.tmDigitizedAspectX == expmetrics.tmDigitizedAspectX, "Returned digitized x aspect %d, expected %d\n", metrics.tmDigitizedAspectX, expmetrics.tmDigitizedAspectX); + ok(metrics.tmDigitizedAspectY == expmetrics.tmDigitizedAspectY, "Returned digitized y aspect %d, expected %d\n", metrics.tmDigitizedAspectY, expmetrics.tmDigitizedAspectY); + ok(metrics.tmFirstChar == expmetrics.tmFirstChar, "Returned first char %d, expected %d\n", metrics.tmFirstChar, expmetrics.tmFirstChar); + ok(metrics.tmLastChar == expmetrics.tmLastChar, "Returned last char %d, expected %d\n", metrics.tmLastChar, expmetrics.tmLastChar); + ok(metrics.tmDefaultChar == expmetrics.tmDefaultChar, "Returned default char %d, expected %d\n", metrics.tmDefaultChar, expmetrics.tmDefaultChar); + ok(metrics.tmBreakChar == expmetrics.tmBreakChar, "Returned break char %d, expected %d\n", metrics.tmBreakChar, expmetrics.tmBreakChar); + ok(metrics.tmItalic == expmetrics.tmItalic, "Returned italic %d, expected %d\n", metrics.tmItalic, expmetrics.tmItalic); + ok(metrics.tmUnderlined == expmetrics.tmUnderlined, "Returned underlined %d, expected %d\n", metrics.tmUnderlined, expmetrics.tmUnderlined); + ok(metrics.tmStruckOut == expmetrics.tmStruckOut, "Returned struck out %d, expected %d\n", metrics.tmStruckOut, expmetrics.tmStruckOut); + ok(metrics.tmPitchAndFamily == expmetrics.tmPitchAndFamily, "Returned pitch and family %d, expected %d\n", metrics.tmPitchAndFamily, expmetrics.tmPitchAndFamily); + ok(metrics.tmCharSet == expmetrics.tmCharSet, "Returned charset %d, expected %d\n", metrics.tmCharSet, expmetrics.tmCharSet); + } + ID3DXFont_Release(font); + } else skip("Failed to create a ID3DXFont object\n"); + + + /* ID3DXFont_PreloadText */ + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + if(SUCCEEDED(hr)) { + todo_wine { + hr = ID3DXFont_PreloadTextA(font, NULL, -1); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXFont_PreloadTextA(font, NULL, 0); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadTextA(font, NULL, 1); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXFont_PreloadTextA(font, "test", -1); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK); + + hr = ID3DXFont_PreloadTextW(font, NULL, -1); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXFont_PreloadTextW(font, NULL, 0); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadTextW(font, NULL, 1); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXFont_PreloadTextW(font, testW, -1); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK); + } + + check_release((IUnknown*)font, 0); + } else skip("Failed to create a ID3DXFont object\n"); + + + /* ID3DXFont_GetGlyphData, ID3DXFont_PreloadGlyphs, ID3DXFont_PreloadCharacters */ + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + if(SUCCEEDED(hr)) { + char c; + HDC hdc; + DWORD ret; + HRESULT hr; + RECT blackbox; + POINT cellinc; + IDirect3DTexture9 *texture; + + hdc = ID3DXFont_GetDC(font); + + todo_wine { + hr = ID3DXFont_GetGlyphData(font, 0, NULL, &blackbox, &cellinc); + ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_GetGlyphData(font, 0, &texture, NULL, &cellinc); + if(SUCCEEDED(hr)) check_release((IUnknown*)texture, 1); + ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_GetGlyphData(font, 0, &texture, &blackbox, NULL); + if(SUCCEEDED(hr)) check_release((IUnknown*)texture, 1); + ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + } + hr = ID3DXFont_PreloadCharacters(font, 'b', 'a'); + ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadGlyphs(font, 1, 0); + todo_wine ok(hr == D3D_OK, "ID3DXFont_PreloadGlyphs returned %#x, expected %#x\n", hr, D3D_OK); + + hr = ID3DXFont_PreloadCharacters(font, 'a', 'a'); + ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK); + + for(c = 'b'; c <= 'z'; c++) { + WORD glyph; + + ret = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); + ok(ret != GDI_ERROR, "GetGlyphIndicesA failed\n"); + + hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); + todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + if(SUCCEEDED(hr)) { + DWORD levels; + D3DSURFACE_DESC desc; + + levels = IDirect3DTexture9_GetLevelCount(texture); + ok(levels == 5, "Got levels %u, expected %u\n", levels, 5); + hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc); + ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n"); + ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8); + ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0); + ok(desc.Width == 256, "Got width %u, expected %u\n", desc.Width, 256); + ok(desc.Height == 256, "Got height %u, expected %u\n", desc.Height, 256); + ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED); + + check_release((IUnknown*)texture, 1); + } + } + + hr = ID3DXFont_PreloadCharacters(font, 'a', 'z'); + ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK); + + check_release((IUnknown*)font, 0); + } else skip("Failed to create a ID3DXFont object\n"); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + HDC hdc; + DWORD ret; + HRESULT hr; + WORD glyph; + char c = 'a'; + IDirect3DTexture9 *texture; + + hr = D3DXCreateFontA(device, tests[i].font_height, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, + OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + if(FAILED(hr)) { + skip("Failed to create a ID3DXFont object\n"); + continue; + } + + hdc = ID3DXFont_GetDC(font); + + ret = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); + ok(ret != GDI_ERROR, "GetGlyphIndicesA failed\n"); + + hr = ID3DXFont_GetGlyphData(font, glyph, &texture, NULL, NULL); + todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + if(SUCCEEDED(hr)) { + DWORD levels; + D3DSURFACE_DESC desc; + + levels = IDirect3DTexture9_GetLevelCount(texture); + ok(levels == tests[i].expected_levels, "Got levels %u, expected %u\n", + levels, tests[i].expected_levels); + hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc); + ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n"); + ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8); + ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0); + ok(desc.Width == tests[i].expected_size, "Got width %u, expected %u\n", + desc.Width, tests[i].expected_size); + ok(desc.Height == tests[i].expected_size, "Got height %u, expected %u\n", + desc.Height, tests[i].expected_size); + ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED); + + IDirect3DTexture9_Release(texture); + } + + /* ID3DXFontImpl_DrawText */ + D3DXCreateSprite(device, &sprite); + SetRect(&rect, 0, 0, 640, 480); + + IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0); + + IDirect3DDevice9_BeginScene(device); + hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_ALPHABLEND); + ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + todo_wine + { + height = ID3DXFont_DrawTextW(font, sprite, testW, -1, &rect, DT_TOP, 0xffffffff); + ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); + height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_TOP, 0xffffffff); + ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); + height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_RIGHT, 0xffffffff); + ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); + height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP, + 0xffffffff); + ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); + } + + SetRectEmpty(&rect); + height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, + DT_LEFT | DT_CALCRECT, 0xffffffff); + todo_wine ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); + ok(!rect.left, "Got unexpected rect left %d.\n", rect.left); + ok(!rect.top, "Got unexpected rect top %d.\n", rect.top); + todo_wine ok(rect.right, "Got unexpected rect right %d.\n", rect.right); + todo_wine ok(rect.bottom == tests[i].font_height, "Got unexpected rect bottom %d.\n", rect.bottom); + + hr = ID3DXSprite_End(sprite); + ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + IDirect3DDevice9_EndScene(device); + ID3DXSprite_Release(sprite); + + ID3DXFont_Release(font); + } +} + +static void test_D3DXCreateRenderToSurface(IDirect3DDevice9 *device) +{ + int i; + HRESULT hr; + ULONG ref_count; + D3DXRTS_DESC desc; + ID3DXRenderToSurface *render = (void *)0xdeadbeef; + static const D3DXRTS_DESC tests[] = + { + { 0, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN }, + { 256, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN }, + { 256, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_D24S8 }, + { 256, 256, D3DFMT_UNKNOWN, FALSE, D3DFMT_R8G8B8 }, + { 0, 0, D3DFMT_UNKNOWN, FALSE, D3DFMT_UNKNOWN }, + { -1, -1, MAKEFOURCC('B','A','D','F'), TRUE, MAKEFOURCC('B','A','D','F') } + }; + + hr = D3DXCreateRenderToSurface(NULL /* device */, 256, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, &render); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + ok(render == (void *)0xdeadbeef, "Got %p, expected %p\n", render, (void *)0xdeadbeef); + + hr = D3DXCreateRenderToSurface(device, 256, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, NULL /* out */); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + for (i = 0; i < ARRAY_SIZE(tests); i++) + { + hr = D3DXCreateRenderToSurface(device, tests[i].Width, tests[i].Height, tests[i].Format, tests[i].DepthStencil, + tests[i].DepthStencilFormat, &render); + ok(hr == D3D_OK, "%d: D3DXCreateRenderToSurface returned %#x, expected %#x\n", i, hr, D3D_OK); + if (SUCCEEDED(hr)) + { + hr = ID3DXRenderToSurface_GetDesc(render, &desc); + ok(hr == D3D_OK, "%d: GetDesc failed %#x\n", i, hr); + if (SUCCEEDED(hr)) + { + ok(desc.Width == tests[i].Width, "%d: Got width %u, expected %u\n", i, desc.Width, tests[i].Width); + ok(desc.Height == tests[i].Height, "%d: Got height %u, expected %u\n", i, desc.Height, tests[i].Height); + ok(desc.Format == tests[i].Format, "%d: Got format %#x, expected %#x\n", i, desc.Format, tests[i].Format); + ok(desc.DepthStencil == tests[i].DepthStencil, "%d: Got depth stencil %d, expected %d\n", + i, desc.DepthStencil, tests[i].DepthStencil); + ok(desc.DepthStencilFormat == tests[i].DepthStencilFormat, "%d: Got depth stencil format %#x, expected %#x\n", + i, desc.DepthStencilFormat, tests[i].DepthStencilFormat); + } + ID3DXRenderToSurface_Release(render); + } + } + + /* check device ref count */ + ref_count = get_ref((IUnknown *)device); + hr = D3DXCreateRenderToSurface(device, 0, 0, D3DFMT_UNKNOWN, FALSE, D3DFMT_UNKNOWN, &render); + check_ref((IUnknown *)device, ref_count + 1); + if (SUCCEEDED(hr)) ID3DXRenderToSurface_Release(render); +} + +/* runs a set of tests for the ID3DXRenderToSurface interface created with given parameters */ +static void check_ID3DXRenderToSurface(IDirect3DDevice9 *device, UINT width, UINT height, D3DFORMAT format, + BOOL depth_stencil, D3DFORMAT depth_stencil_format, BOOL render_target) +{ + HRESULT hr; + D3DFORMAT fmt; + HRESULT expected_value; + IDirect3DSurface9 *surface; + ID3DXRenderToSurface *render; + D3DVIEWPORT9 viewport = { 0, 0, width, height, 0.0, 1.0 }; + + hr = D3DXCreateRenderToSurface(device, width, height, format, depth_stencil, depth_stencil_format, &render); + if (FAILED(hr)) + { + skip("Failed to create ID3DXRenderToSurface\n"); + return; + } + + if (render_target) + hr = IDirect3DDevice9_CreateRenderTarget(device, width, height, format, D3DMULTISAMPLE_NONE, 0, FALSE, &surface, NULL); + else + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height, format, D3DPOOL_DEFAULT, &surface, NULL); + if (FAILED(hr)) + { + skip("Failed to create surface\n"); + ID3DXRenderToSurface_Release(render); + return; + } + + /* viewport */ + hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport); + ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK); + check_ref((IUnknown *)surface, 2); + if (SUCCEEDED(hr)) ID3DXRenderToSurface_EndScene(render, D3DX_FILTER_NONE); + + /* invalid viewport */ + viewport.Width = 2 * width; + hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + viewport.X = width / 2; + viewport.Width = width; + hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + viewport.X = width; + viewport.Width = width; + hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + /* rendering to a part of a surface is only allowed for render target surfaces */ + expected_value = render_target ? D3D_OK : D3DERR_INVALIDCALL; + + viewport.X = 0; + viewport.Width = width / 2; + hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport); + ok(hr == expected_value, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, expected_value); + if (SUCCEEDED(hr)) ID3DXRenderToSurface_EndScene(render, D3DX_FILTER_NONE); + + viewport.X = width / 2; + viewport.Width = width - width / 2; + hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport); + ok(hr == expected_value, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, expected_value); + if (SUCCEEDED(hr)) ID3DXRenderToSurface_EndScene(render, D3DX_FILTER_NONE); + + check_release((IUnknown *)surface, 0); + + /* surfaces with different sizes */ + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width / 2, width / 2, format, D3DPOOL_DEFAULT, &surface, NULL); + if (FAILED(hr)) + { + skip("Failed to create surface\n"); + ID3DXRenderToSurface_Release(render); + return; + } + hr = ID3DXRenderToSurface_BeginScene(render, surface, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + check_release((IUnknown *)surface, 0); + + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2 * width, 2 * height, format, D3DPOOL_DEFAULT, &surface, NULL); + if (FAILED(hr)) + { + skip("Failed to create surface\n"); + ID3DXRenderToSurface_Release(render); + return; + } + hr = ID3DXRenderToSurface_BeginScene(render, surface, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + viewport.X = 0; + viewport.Y = 0; + viewport.Width = width; + viewport.Height = height; + hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + check_release((IUnknown *)surface, 0); + + /* surfaces with different formats */ + for (fmt = D3DFMT_A8R8G8B8; fmt <= D3DFMT_X8R8G8B8; fmt++) + { + HRESULT expected_result = (fmt != format) ? D3DERR_INVALIDCALL : D3D_OK; + + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height, fmt, D3DPOOL_DEFAULT, &surface, NULL); + if (FAILED(hr)) + { + skip("Failed to create surface\n"); + continue; + } + + hr = ID3DXRenderToSurface_BeginScene(render, surface, NULL); + ok(hr == expected_result, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, expected_result); + + if (SUCCEEDED(hr)) ID3DXRenderToSurface_EndScene(render, D3DX_FILTER_NONE); + check_release((IUnknown *)surface, 0); + } + + check_release((IUnknown *)render, 0); +} + +struct device_state +{ + IDirect3DSurface9 *render_target; + IDirect3DSurface9 *depth_stencil; + D3DVIEWPORT9 viewport; +}; + +static void release_device_state(struct device_state *state) +{ + if (state->render_target) IDirect3DSurface9_Release(state->render_target); + if (state->depth_stencil) IDirect3DSurface9_Release(state->depth_stencil); + memset(state, 0, sizeof(*state)); +} + +static HRESULT retrieve_device_state(IDirect3DDevice9 *device, struct device_state *state) +{ + HRESULT hr; + + memset(state, 0, sizeof(*state)); + + hr = IDirect3DDevice9_GetRenderTarget(device, 0, &state->render_target); + if (FAILED(hr)) goto cleanup; + + hr = IDirect3DDevice9_GetDepthStencilSurface(device, &state->depth_stencil); + if (hr == D3DERR_NOTFOUND) + state->depth_stencil = NULL; + else if (FAILED(hr)) + goto cleanup; + + hr = IDirect3DDevice9_GetViewport(device, &state->viewport); + if (SUCCEEDED(hr)) return hr; + +cleanup: + release_device_state(state); + return hr; +} + +static HRESULT apply_device_state(IDirect3DDevice9 *device, struct device_state *state) +{ + HRESULT hr; + HRESULT status = D3D_OK; + + hr = IDirect3DDevice9_SetRenderTarget(device, 0, state->render_target); + if (FAILED(hr)) status = hr; + + hr = IDirect3DDevice9_SetDepthStencilSurface(device, state->depth_stencil); + if (FAILED(hr)) status = hr; + + hr = IDirect3DDevice9_SetViewport(device, &state->viewport); + if (FAILED(hr)) status = hr; + + return status; +} + +static void compare_device_state(struct device_state *state1, struct device_state *state2, BOOL equal) +{ + BOOL cmp; + const char *message = equal ? "differs" : "is the same"; + + cmp = state1->render_target == state2->render_target; + ok(equal ? cmp : !cmp, "Render target %s %p, %p\n", message, state1->render_target, state2->render_target); + + cmp = state1->depth_stencil == state2->depth_stencil; + ok(equal ? cmp : !cmp, "Depth stencil surface %s %p, %p\n", message, state1->depth_stencil, state2->depth_stencil); + + cmp = state1->viewport.X == state2->viewport.X && state1->viewport.Y == state2->viewport.Y + && state1->viewport.Width == state2->viewport.Width && state1->viewport.Height == state2->viewport.Height; + ok(equal ? cmp : !cmp, "Viewport %s (%u, %u, %u, %u), (%u, %u, %u, %u)\n", message, + state1->viewport.X, state1->viewport.Y, state1->viewport.Width, state1->viewport.Height, + state2->viewport.X, state2->viewport.Y, state2->viewport.Width, state2->viewport.Height); +} + +static void test_ID3DXRenderToSurface_device_state(IDirect3DDevice9 *device) +{ + HRESULT hr; + IDirect3DSurface9 *surface = NULL; + ID3DXRenderToSurface *render = NULL; + struct device_state pre_state; + struct device_state current_state; + IDirect3DSurface9 *depth_stencil_surface; + + /* make sure there is a depth stencil surface present */ + hr = IDirect3DDevice9_GetDepthStencilSurface(device, &depth_stencil_surface); + if (SUCCEEDED(hr)) + { + IDirect3DSurface9_Release(depth_stencil_surface); + depth_stencil_surface = NULL; + } + else if (hr == D3DERR_NOTFOUND) + { + hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 256, 256, D3DFMT_D24X8, + D3DMULTISAMPLE_NONE, 0, TRUE, &depth_stencil_surface, NULL); + if (SUCCEEDED(hr)) IDirect3DDevice9_SetDepthStencilSurface(device, depth_stencil_surface); + } + + if (FAILED(hr)) + { + skip("Failed to create depth stencil surface\n"); + return; + } + + hr = IDirect3DDevice9_CreateRenderTarget(device, 256, 256, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, + FALSE, &surface, NULL); + if (FAILED(hr)) + { + skip("Failed to create render target\n"); + goto cleanup; + } + + hr = retrieve_device_state(device, &pre_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + + hr = D3DXCreateRenderToSurface(device, 256, 256, D3DFMT_A8R8G8B8, TRUE, D3DFMT_D24X8, &render); + ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK); + if (SUCCEEDED(hr)) + { + hr = ID3DXRenderToSurface_BeginScene(render, surface, NULL); + ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK); + + hr = retrieve_device_state(device, ¤t_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + compare_device_state(¤t_state, &pre_state, FALSE); + release_device_state(¤t_state); + + hr = ID3DXRenderToSurface_EndScene(render, D3DX_FILTER_NONE); + ok(hr == D3D_OK, "ID3DXRenderToSurface::EndScene returned %#x, expected %#x\n", hr, D3D_OK); + + hr = retrieve_device_state(device, ¤t_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + compare_device_state(¤t_state, &pre_state, TRUE); + release_device_state(¤t_state); + + check_release((IUnknown *)render, 0); + } + + hr = D3DXCreateRenderToSurface(device, 256, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, &render); + if (SUCCEEDED(hr)) + { + hr = ID3DXRenderToSurface_BeginScene(render, surface, NULL); + ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK); + + hr = retrieve_device_state(device, ¤t_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + compare_device_state(¤t_state, &pre_state, FALSE); + release_device_state(¤t_state); + + hr = ID3DXRenderToSurface_EndScene(render, D3DX_FILTER_NONE); + ok(hr == D3D_OK, "ID3DXRenderToSurface::EndScene returned %#x, expected %#x\n", hr, D3D_OK); + + hr = retrieve_device_state(device, ¤t_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + compare_device_state(¤t_state, &pre_state, TRUE); + release_device_state(¤t_state); + + hr = ID3DXRenderToSurface_BeginScene(render, surface, NULL); + ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK); + + hr = retrieve_device_state(device, ¤t_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + compare_device_state(¤t_state, &pre_state, FALSE); + release_device_state(¤t_state); + + check_release((IUnknown *)render, 0); + + /* if EndScene isn't called, the device state isn't restored */ + hr = retrieve_device_state(device, ¤t_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + compare_device_state(¤t_state, &pre_state, FALSE); + release_device_state(¤t_state); + + hr = apply_device_state(device, &pre_state); + ok(SUCCEEDED(hr), "Failed to restore previous device state\n"); + + IDirect3DDevice9_EndScene(device); + } + + release_device_state(&pre_state); + +cleanup: + if (depth_stencil_surface) + { + IDirect3DDevice9_SetDepthStencilSurface(device, NULL); + IDirect3DSurface9_Release(depth_stencil_surface); + } + + if (surface) check_release((IUnknown *)surface, 0); +} + +static void test_ID3DXRenderToSurface(IDirect3DDevice9 *device) +{ + int i; + HRESULT hr; + ULONG ref_count; + IDirect3DDevice9 *out_device; + ID3DXRenderToSurface *render; + IDirect3DSurface9 *surface; + D3DVIEWPORT9 viewport = { 0, 0, 256, 256, 0.0, 1.0 }; + D3DXRTS_DESC tests[] = { + { 256, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN }, + { 256, 256, D3DFMT_A8R8G8B8, TRUE, D3DFMT_D24S8 }, + { 256, 256, D3DFMT_A8R8G8B8, TRUE, D3DFMT_D24X8 }, + { 512, 512, D3DFMT_X8R8G8B8, FALSE, D3DFMT_X8R8G8B8 }, + { 1024, 1024, D3DFMT_X8R8G8B8, TRUE, D3DFMT_D24S8 } + }; + + hr = D3DXCreateRenderToSurface(device, 256, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, &render); + ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK); + if (FAILED(hr)) return; + + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 256, 256, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL); + if (SUCCEEDED(hr)) + { + ID3DXRenderToSurface *render_surface; + + /* GetDevice */ + hr = ID3DXRenderToSurface_GetDevice(render, NULL /* device */); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + ref_count = get_ref((IUnknown *)device); + hr = ID3DXRenderToSurface_GetDevice(render, &out_device); + ok(hr == D3D_OK, "ID3DXRenderToSurface::GetDevice returned %#x, expected %#x\n", hr, D3D_OK); + check_release((IUnknown *)out_device, ref_count); + + /* BeginScene and EndScene */ + hr = ID3DXRenderToSurface_EndScene(render, D3DX_FILTER_NONE); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::EndScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXRenderToSurface_BeginScene(render, NULL /* surface */, &viewport); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + ref_count = get_ref((IUnknown *)surface); + hr = ID3DXRenderToSurface_BeginScene(render, surface, NULL); + ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK); + if (SUCCEEDED(hr)) + { + check_ref((IUnknown *)surface, ref_count + 1); + + hr = ID3DXRenderToSurface_BeginScene(render, surface, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXRenderToSurface_EndScene(render, D3DX_FILTER_NONE); + ok(hr == D3D_OK, "ID3DXRenderToSurface::EndScene returned %#x, expected %#x\n", hr, D3D_OK); + + check_ref((IUnknown *)surface, ref_count); + } + + /* error handling is deferred to BeginScene */ + hr = D3DXCreateRenderToSurface(device, 256, 256, D3DFMT_A8R8G8B8, TRUE, D3DFMT_UNKNOWN, &render_surface); + ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXRenderToSurface_BeginScene(render_surface, surface, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + check_release((IUnknown *)render_surface, 0); + + check_release((IUnknown *)surface, 0); + } + else skip("Failed to create surface\n"); + + check_release((IUnknown *)render, 0); + + for (i = 0; i < ARRAY_SIZE(tests); i++) + { + check_ID3DXRenderToSurface(device, tests[i].Width, tests[i].Height, tests[i].Format, tests[i].DepthStencil, tests[i].DepthStencilFormat, TRUE); + check_ID3DXRenderToSurface(device, tests[i].Width, tests[i].Height, tests[i].Format, tests[i].DepthStencil, tests[i].DepthStencilFormat, FALSE); + } + + test_ID3DXRenderToSurface_device_state(device); +} + +static void test_D3DXCreateRenderToEnvMap(IDirect3DDevice9 *device) +{ + int i; + HRESULT hr; + ULONG ref_count; + D3DXRTE_DESC desc; + ID3DXRenderToEnvMap *render; + static const struct { + D3DXRTE_DESC parameters; + D3DXRTE_DESC expected_values; + } tests[] = { + { { 0, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN }, { 1, 1, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN } }, + { { 256, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN }, { 256, 9, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN } }, + { { 256, 4, D3DFMT_A8R8G8B8, FALSE, D3DFMT_D24S8 }, { 256, 4, D3DFMT_A8R8G8B8, FALSE, D3DFMT_D24S8 } }, + { { 256, 256, D3DFMT_UNKNOWN, FALSE, D3DFMT_R8G8B8 }, { 256, 9, D3DFMT_A8R8G8B8, FALSE, D3DFMT_R8G8B8 } }, + { { -1, -1, D3DFMT_A8R8G8B8, TRUE, D3DFMT_DXT1 }, { 256, 9, D3DFMT_A8R8G8B8, TRUE, D3DFMT_DXT1 } }, + { { 256, 1, D3DFMT_X8R8G8B8, TRUE, D3DFMT_UNKNOWN }, { 256, 1, D3DFMT_X8R8G8B8, TRUE, D3DFMT_UNKNOWN } } + }; + + for (i = 0; i < ARRAY_SIZE(tests); i++) + { + const D3DXRTE_DESC *parameters = &tests[i].parameters; + const D3DXRTE_DESC *expected = &tests[i].expected_values; + hr = D3DXCreateRenderToEnvMap(device, parameters->Size, parameters->MipLevels, parameters->Format, + parameters->DepthStencil, parameters->DepthStencilFormat, &render); + ok(hr == D3D_OK, "%d: D3DXCreateRenderToEnvMap returned %#x, expected %#x\n", i, hr, D3D_OK); + if (SUCCEEDED(hr)) + { + hr = ID3DXRenderToEnvMap_GetDesc(render, &desc); + ok(hr == D3D_OK, "%d: GetDesc failed %#x\n", i, hr); + if (SUCCEEDED(hr)) + { + ok(desc.Size == expected->Size, "%d: Got size %u, expected %u\n", i, desc.Size, expected->Size); + ok(desc.MipLevels == expected->MipLevels, "%d: Got miplevels %u, expected %u\n", i, desc.MipLevels, expected->MipLevels); + ok(desc.Format == expected->Format, "%d: Got format %#x, expected %#x\n", i, desc.Format, expected->Format); + ok(desc.DepthStencil == expected->DepthStencil, "%d: Got depth stencil %d, expected %d\n", + i, expected->DepthStencil, expected->DepthStencil); + ok(desc.DepthStencilFormat == expected->DepthStencilFormat, "%d: Got depth stencil format %#x, expected %#x\n", + i, expected->DepthStencilFormat, expected->DepthStencilFormat); + } + check_release((IUnknown *)render, 0); + } + } + + /* check device ref count */ + ref_count = get_ref((IUnknown *)device); + hr = D3DXCreateRenderToEnvMap(device, 0, 0, D3DFMT_UNKNOWN, FALSE, D3DFMT_UNKNOWN, &render); + check_ref((IUnknown *)device, ref_count + 1); + if (SUCCEEDED(hr)) ID3DXRenderToEnvMap_Release(render); +} + +static void test_ID3DXRenderToEnvMap_cube_map(IDirect3DDevice9 *device) +{ + HRESULT hr; + IDirect3DCubeTexture9 *cube_texture = NULL; + ID3DXRenderToEnvMap *render = NULL; + struct device_state pre_state; + struct device_state current_state; + + hr = IDirect3DDevice9_CreateCubeTexture(device, 256, 0, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, + &cube_texture, NULL); + if (FAILED(hr)) + { + skip("Failed to create cube texture\n"); + return; + } + + hr = retrieve_device_state(device, &pre_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + + hr = D3DXCreateRenderToEnvMap(device, 256, 0, D3DFMT_A8R8G8B8, TRUE, D3DFMT_D24X8, &render); + ok(hr == D3D_OK, "D3DCreateRenderToEnvMap returned %#x, expected %#x\n", hr, D3D_OK); + if (SUCCEEDED(hr)) + { + DWORD face; + + hr = ID3DXRenderToEnvMap_End(render, D3DX_FILTER_NONE); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::End returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXRenderToEnvMap_BeginCube(render, cube_texture); + ok(hr == D3D_OK, "ID3DXRenderToEnvMap::BeginCube returned %#x, expected %#x\n", hr, D3D_OK); + + hr = retrieve_device_state(device, ¤t_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + compare_device_state(¤t_state, &pre_state, TRUE); + release_device_state(¤t_state); + + for (face = D3DCUBEMAP_FACE_POSITIVE_X; face <= D3DCUBEMAP_FACE_NEGATIVE_Z; face++) + { + hr = ID3DXRenderToEnvMap_Face(render, face, D3DX_FILTER_POINT); + ok(hr == D3D_OK, "ID3DXRenderToEnvMap::Face returned %#x, expected %#x\n", hr, D3D_OK); + + hr = retrieve_device_state(device, ¤t_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + compare_device_state(¤t_state, &pre_state, FALSE); + release_device_state(¤t_state); + } + + hr = ID3DXRenderToEnvMap_End(render, D3DX_FILTER_POINT); + ok(hr == D3D_OK, "ID3DXRenderToEnvMap::End returned %#x, expected %#x\n", hr, D3D_OK); + + hr = retrieve_device_state(device, ¤t_state); + ok(SUCCEEDED(hr), "Failed to retrieve device state\n"); + compare_device_state(¤t_state, &pre_state, TRUE); + release_device_state(¤t_state); + + check_release((IUnknown *)render, 0); + } + + release_device_state(&pre_state); + + check_release((IUnknown *)cube_texture, 0); +} + +static void test_ID3DXRenderToEnvMap(IDirect3DDevice9 *device) +{ + HRESULT hr; + ID3DXRenderToEnvMap *render; + IDirect3DSurface9 *depth_stencil_surface; + + hr = D3DXCreateRenderToEnvMap(device, 256, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, &render); + if (SUCCEEDED(hr)) + { + ULONG ref_count; + IDirect3DDevice9 *out_device; + + hr = ID3DXRenderToEnvMap_GetDesc(render, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::GetDesc returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXRenderToEnvMap_GetDevice(render, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + ref_count = get_ref((IUnknown *)device); + hr = ID3DXRenderToEnvMap_GetDevice(render, &out_device); + ok(hr == D3D_OK, "ID3DXRenderToEnvMap::GetDevice returned %#x, expected %#x\n", hr, D3D_OK); + ok(out_device == device, "ID3DXRenderToEnvMap::GetDevice returned different device\n"); + check_release((IUnknown *)device, ref_count); + + hr = ID3DXRenderToEnvMap_End(render, D3DX_FILTER_NONE); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::End returned %#x, expected %#x\n", hr, D3D_OK); + + hr = ID3DXRenderToEnvMap_BeginCube(render, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::BeginCube returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXRenderToEnvMap_BeginHemisphere(render, NULL, NULL); + todo_wine ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::BeginHemisphere returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXRenderToEnvMap_BeginParabolic(render, NULL, NULL); + todo_wine ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::BeginParabolic returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXRenderToEnvMap_BeginSphere(render, NULL); + todo_wine ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::BeginSphere returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + check_release((IUnknown *)render, 0); + } else skip("Failed to create ID3DXRenderToEnvMap\n"); + + /* make sure there is a depth stencil surface present */ + hr = IDirect3DDevice9_GetDepthStencilSurface(device, &depth_stencil_surface); + if (SUCCEEDED(hr)) + { + IDirect3DSurface9_Release(depth_stencil_surface); + depth_stencil_surface = NULL; + } + else if (hr == D3DERR_NOTFOUND) + { + hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 256, 256, D3DFMT_D24X8, + D3DMULTISAMPLE_NONE, 0, TRUE, &depth_stencil_surface, NULL); + if (SUCCEEDED(hr)) IDirect3DDevice9_SetDepthStencilSurface(device, depth_stencil_surface); + } + + if (FAILED(hr)) + { + skip("Failed to create depth stencil surface\n"); + return; + } + + test_ID3DXRenderToEnvMap_cube_map(device); + + if (depth_stencil_surface) + { + IDirect3DDevice9_SetDepthStencilSurface(device, NULL); + IDirect3DSurface9_Release(depth_stencil_surface); + } +} + +START_TEST(core) +{ + HWND wnd; + IDirect3D9 *d3d; + IDirect3DDevice9 *device; + D3DPRESENT_PARAMETERS d3dpp; + HRESULT hr; + + if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0, + 640, 480, NULL, NULL, NULL, NULL))) + { + skip("Couldn't create application window\n"); + return; + } + if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION))) + { + skip("Couldn't create IDirect3D9 object\n"); + DestroyWindow(wnd); + return; + } + + ZeroMemory(&d3dpp, sizeof(d3dpp)); + d3dpp.Windowed = TRUE; + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &device); + if(FAILED(hr)) { + skip("Failed to create IDirect3DDevice9 object %#x\n", hr); + IDirect3D9_Release(d3d); + DestroyWindow(wnd); + return; + } + + test_ID3DXBuffer(); + test_ID3DXSprite(device); + test_ID3DXFont(device); + test_D3DXCreateRenderToSurface(device); + test_ID3DXRenderToSurface(device); + test_D3DXCreateRenderToEnvMap(device); + test_ID3DXRenderToEnvMap(device); + + check_release((IUnknown*)device, 0); + check_release((IUnknown*)d3d, 0); + if (wnd) DestroyWindow(wnd); +} diff --git a/modules/rostests/winetests/d3dx9_36/effect.c b/modules/rostests/winetests/d3dx9_36/effect.c new file mode 100644 index 00000000000..423d3b8d5c6 --- /dev/null +++ b/modules/rostests/winetests/d3dx9_36/effect.c @@ -0,0 +1,8030 @@ +/* + * Copyright 2010 Christian Costa + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS +#include "initguid.h" +#include <limits.h> +#include "wine/test.h" +#include "d3dx9.h" + +#ifndef INFINITY +static inline float __port_infinity(void) +{ + static const unsigned __inf_bytes = 0x7f800000; + return *(const float *)&__inf_bytes; +} +#define INFINITY __port_infinity() +#endif /* INFINITY */ + +#ifndef NAN +static float get_nan(void) +{ + DWORD nan = 0x7fc00000; + + return *(float *)&nan; +} +#define NAN get_nan() +#endif + +/* helper functions */ +static BOOL compare_float(FLOAT f, FLOAT g, UINT ulps) +{ + INT x = *(INT *)&f; + INT y = *(INT *)&g; + + if (x < 0) + x = INT_MIN - x; + if (y < 0) + y = INT_MIN - y; + + if (abs(x - y) > ulps) + return FALSE; + + return TRUE; +} + +static inline INT get_int(D3DXPARAMETER_TYPE type, const void *data) +{ + INT i; + + switch (type) + { + case D3DXPT_FLOAT: + i = *(FLOAT *)data; + break; + + case D3DXPT_INT: + i = *(INT *)data; + break; + + case D3DXPT_BOOL: + i = *(BOOL *)data; + break; + + default: + i = 0; + ok(0, "Unhandled type %x.\n", type); + break; + } + + return i; +} + +static inline float get_float(D3DXPARAMETER_TYPE type, const void *data) +{ + float f; + + switch (type) + { + case D3DXPT_FLOAT: + f = *(FLOAT *)data; + break; + + case D3DXPT_INT: + f = *(INT *)data; + break; + + case D3DXPT_BOOL: + f = *(BOOL *)data; + break; + + default: + f = 0.0f; + ok(0, "Unhandled type %x.\n", type); + break; + } + + return f; +} + +static inline BOOL get_bool(const void *data) +{ + return !!*(BOOL *)data; +} + +static void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype) +{ + switch (outtype) + { + case D3DXPT_FLOAT: + *(FLOAT *)outdata = get_float(intype, indata); + break; + + case D3DXPT_BOOL: + *(BOOL *)outdata = get_bool(indata); + break; + + case D3DXPT_INT: + *(INT *)outdata = get_int(intype, indata); + break; + + case D3DXPT_PIXELSHADER: + case D3DXPT_VERTEXSHADER: + case D3DXPT_TEXTURE2D: + case D3DXPT_STRING: + *(INT *)outdata = 0x12345678; + break; + + default: + ok(0, "Unhandled type %x.\n", outtype); + *(INT *)outdata = 0; + break; + } +} + +static IDirect3DDevice9 *create_device(HWND *window) +{ + D3DPRESENT_PARAMETERS present_parameters = { 0 }; + IDirect3DDevice9 *device; + IDirect3D9 *d3d; + HRESULT hr; + HWND wnd; + + *window = NULL; + + if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0, + 640, 480, NULL, NULL, NULL, NULL))) + { + skip("Couldn't create application window.\n"); + return NULL; + } + + if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION))) + { + skip("Couldn't create IDirect3D9 object.\n"); + DestroyWindow(wnd); + return NULL; + } + + present_parameters.Windowed = TRUE; + present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; + hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, + &present_parameters, &device); + IDirect3D9_Release(d3d); + if (FAILED(hr)) + { + skip("Failed to create IDirect3DDevice9 object %#x.\n", hr); + DestroyWindow(wnd); + return NULL; + } + + *window = wnd; + return device; +} + +static char temp_path[MAX_PATH]; + +static BOOL create_file(const char *filename, const char *data, const unsigned int size, char *out_path) +{ + DWORD written; + HANDLE hfile; + char path[MAX_PATH]; + + if (!*temp_path) + GetTempPathA(sizeof(temp_path), temp_path); + + strcpy(path, temp_path); + strcat(path, filename); + hfile = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + if (hfile == INVALID_HANDLE_VALUE) + return FALSE; + + if (WriteFile(hfile, data, size, &written, NULL)) + { + CloseHandle(hfile); + + if (out_path) + strcpy(out_path, path); + return TRUE; + } + + CloseHandle(hfile); + return FALSE; +} + +static void delete_file(const char *filename) +{ + char path[MAX_PATH]; + + strcpy(path, temp_path); + strcat(path, filename); + DeleteFileA(path); +} + +static BOOL create_directory(const char *name) +{ + char path[MAX_PATH]; + + strcpy(path, temp_path); + strcat(path, name); + return CreateDirectoryA(path, NULL); +} + +static void delete_directory(const char *name) +{ + char path[MAX_PATH]; + + strcpy(path, temp_path); + strcat(path, name); + RemoveDirectoryA(path); +} + +static const char effect_desc[] = +"Technique\n" +"{\n" +"}\n"; + +static void test_create_effect_and_pool(IDirect3DDevice9 *device) +{ + HRESULT hr; + ID3DXEffect *effect; + ID3DXBaseEffect *base; + ULONG count; + IDirect3DDevice9 *device2; + ID3DXEffectStateManager *manager = (ID3DXEffectStateManager *)0xdeadbeef; + ID3DXEffectPool *pool = (ID3DXEffectPool *)0xdeadbeef, *pool2; + + hr = D3DXCreateEffect(NULL, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, NULL, NULL); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateEffect(device, NULL, 0, NULL, NULL, 0, NULL, NULL, NULL); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateEffect(device, effect_desc, 0, NULL, NULL, 0, NULL, NULL, NULL); + ok(hr == E_FAIL, "Got result %x, expected %x (D3DXERR_INVALIDDATA)\n", hr, E_FAIL); + + hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); + + hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, &effect, NULL); + todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); + if (FAILED(hr)) + { + skip("Failed to compile effect, skipping test.\n"); + return; + } + + hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3DXBaseEffect, (void **)&base); + ok(hr == E_NOINTERFACE, "QueryInterface failed, got %x, expected %x (E_NOINTERFACE)\n", hr, E_NOINTERFACE); + + hr = effect->lpVtbl->GetStateManager(effect, NULL); + ok(hr == D3DERR_INVALIDCALL, "GetStateManager failed, got %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetStateManager(effect, &manager); + ok(hr == D3D_OK, "GetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr); + ok(!manager, "GetStateManager failed, got %p\n", manager); + + /* this works, but it is not recommended! */ + hr = effect->lpVtbl->SetStateManager(effect, (ID3DXEffectStateManager *)device); + ok(hr == D3D_OK, "SetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr); + + hr = effect->lpVtbl->GetStateManager(effect, &manager); + ok(hr == D3D_OK, "GetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr); + ok(manager != NULL, "GetStateManager failed\n"); + + IDirect3DDevice9_AddRef(device); + count = IDirect3DDevice9_Release(device); + ok(count == 4, "Release failed, got %u, expected 4\n", count); + + count = IUnknown_Release(manager); + ok(count == 3, "Release failed, got %u, expected 3\n", count); + + hr = effect->lpVtbl->SetStateManager(effect, NULL); + ok(hr == D3D_OK, "SetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr); + + hr = effect->lpVtbl->GetPool(effect, &pool); + ok(hr == D3D_OK, "GetPool failed, got %x, expected 0 (D3D_OK)\n", hr); + ok(!pool, "GetPool failed, got %p\n", pool); + + hr = effect->lpVtbl->GetPool(effect, NULL); + ok(hr == D3DERR_INVALIDCALL, "GetPool failed, got %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetDevice(effect, &device2); + ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); + + hr = effect->lpVtbl->GetDevice(effect, NULL); + ok(hr == D3DERR_INVALIDCALL, "GetDevice failed, got %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + count = IDirect3DDevice9_Release(device2); + ok(count == 2, "Release failed, got %u, expected 2\n", count); + + count = effect->lpVtbl->Release(effect); + ok(count == 0, "Release failed %u\n", count); + + hr = D3DXCreateEffectPool(NULL); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateEffectPool(&pool); + ok(hr == S_OK, "Got result %x, expected 0 (S_OK)\n", hr); + + count = pool->lpVtbl->Release(pool); + ok(count == 0, "Release failed %u\n", count); + + hr = D3DXCreateEffectPool(&pool); + ok(hr == S_OK, "Got result %x, expected 0 (S_OK)\n", hr); + + hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, pool, NULL, NULL); + ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); + + hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3DXEffectPool, (void **)&pool2); + ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); + ok(pool == pool2, "Release failed, got %p, expected %p\n", pool2, pool); + + count = pool2->lpVtbl->Release(pool2); + ok(count == 1, "Release failed, got %u, expected 1\n", count); + + hr = IDirect3DDevice9_QueryInterface(device, &IID_IDirect3DDevice9, (void **)&device2); + ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); + + count = IDirect3DDevice9_Release(device2); + ok(count == 1, "Release failed, got %u, expected 1\n", count); + + hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, pool, &effect, NULL); + ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); + + hr = effect->lpVtbl->GetPool(effect, &pool); + ok(hr == D3D_OK, "GetPool failed, got %x, expected 0 (D3D_OK)\n", hr); + ok(pool == pool2, "GetPool failed, got %p, expected %p\n", pool2, pool); + + count = pool2->lpVtbl->Release(pool2); + ok(count == 2, "Release failed, got %u, expected 2\n", count); + + count = effect->lpVtbl->Release(effect); + ok(count == 0, "Release failed %u\n", count); + + count = pool->lpVtbl->Release(pool); + ok(count == 0, "Release failed %u\n", count); +} + +static void test_create_effect_compiler(void) +{ + HRESULT hr; + ID3DXEffectCompiler *compiler, *compiler2; + ID3DXBaseEffect *base; + IUnknown *unknown; + ULONG count; + + hr = D3DXCreateEffectCompiler(NULL, 0, NULL, NULL, 0, &compiler, NULL); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateEffectCompiler(NULL, 0, NULL, NULL, 0, NULL, NULL); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateEffectCompiler(effect_desc, 0, NULL, NULL, 0, &compiler, NULL); + ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK); + if (FAILED(hr)) + { + skip("D3DXCreateEffectCompiler failed, skipping test.\n"); + return; + } + + count = compiler->lpVtbl->Release(compiler); + ok(count == 0, "Release failed %u\n", count); + + hr = D3DXCreateEffectCompiler(effect_desc, 0, NULL, NULL, 0, NULL, NULL); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateEffectCompiler(NULL, sizeof(effect_desc), NULL, NULL, 0, &compiler, NULL); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateEffectCompiler(NULL, sizeof(effect_desc), NULL, NULL, 0, NULL, NULL); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateEffectCompiler(effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, NULL); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + + hr = D3DXCreateEffectCompiler(effect_desc, sizeof(effect_desc), NULL, NULL, 0, &compiler, NULL); + ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK); + + hr = compiler->lpVtbl->QueryInterface(compiler, &IID_ID3DXBaseEffect, (void **)&base); + ok(hr == E_NOINTERFACE, "QueryInterface failed, got %x, expected %x (E_NOINTERFACE)\n", hr, E_NOINTERFACE); + + hr = compiler->lpVtbl->QueryInterface(compiler, &IID_ID3DXEffectCompiler, (void **)&compiler2); + ok(hr == D3D_OK, "QueryInterface failed, got %x, expected %x (D3D_OK)\n", hr, D3D_OK); + + hr = compiler->lpVtbl->QueryInterface(compiler, &IID_IUnknown, (void **)&unknown); + ok(hr == D3D_OK, "QueryInterface failed, got %x, expected %x (D3D_OK)\n", hr, D3D_OK); + + count = unknown->lpVtbl->Release(unknown); + ok(count == 2, "Release failed, got %u, expected %u\n", count, 2); + + count = compiler2->lpVtbl->Release(compiler2); + ok(count == 1, "Release failed, got %u, expected %u\n", count, 1); + + count = compiler->lpVtbl->Release(compiler); + ok(count == 0, "Release failed %u\n", count); +} + +/* + * Parameter value test + */ +struct test_effect_parameter_value_result +{ + const char *full_name; + D3DXPARAMETER_DESC desc; + UINT value_offset; /* start position for the value in the blob */ +}; + +/* + * fxc.exe /Tfx_2_0 + */ +#if 0 +float f = 0.1; +float1 f1 = {1.1}; +float2 f2 = {2.1, 2.2}; +float3 f3 = {3.1, 3.2, 3.3}; +float4 f4 = {4.1, 4.2, 4.3, 4.4}; +float1x1 f11 = {11.1}; +float1x2 f12 = {12.1, 12.2}; +float1x3 f13 = {13.1, 13.2, 13.3}; +float1x4 f14 = {14.1, 14.2, 14.3, 14.4}; +float2x1 f21 = {{21.11, 21.21}}; +float2x2 f22 = {{22.11, 22.21}, {22.12, 22.22}}; +float2x3 f23 = {{23.11, 23.21}, {23.12, 23.22}, {23.13, 23.23}}; +float2x4 f24 = {{24.11, 24.21}, {24.12, 24.22}, {24.13, 24.23}, {24.14, 24.24}}; +float3x1 f31 = {{31.11, 31.21, 31.31}}; +float3x2 f32 = {{32.11, 32.21, 32.31}, {32.12, 32.22, 32.32}}; +float3x3 f33 = {{33.11, 33.21, 33.31}, {33.12, 33.22, 33.32}, + {33.13, 33.23, 33.33}}; +float3x4 f34 = {{34.11, 34.21, 34.31}, {34.12, 34.22, 34.32}, + {34.13, 34.23, 34.33}, {34.14, 34.24, 34.34}}; +float4x1 f41 = {{41.11, 41.21, 41.31, 41.41}}; +float4x2 f42 = {{42.11, 42.21, 42.31, 42.41}, {42.12, 42.22, 42.32, 42.42}}; +float4x3 f43 = {{43.11, 43.21, 43.31, 43.41}, {43.12, 43.22, 43.32, 43.42}, + {43.13, 43.23, 43.33, 43.43}}; +float4x4 f44 = {{44.11, 44.21, 44.31, 44.41}, {44.12, 44.22, 44.32, 44.42}, + {44.13, 44.23, 44.33, 44.43}, {44.14, 44.24, 44.34, 44.44}}; +float f_2[2] = {0.101, 0.102}; +float1 f1_2[2] = {{1.101}, {1.102}}; +float2 f2_2[2] = {{2.101, 2.201}, {2.102, 2.202}}; +float3 f3_2[2] = {{3.101, 3.201, 3.301}, {3.102, 3.202, 3.302}}; +float4 f4_2[2] = {{4.101, 4.201, 4.301, 4.401}, {4.102, 4.202, 4.302, 4.402}}; +float1x1 f11_2[2] = {{11.101}, {11.102}}; +float1x2 f12_2[2] = {{12.101, 12.201}, {12.102, 12.202}}; +float1x3 f13_2[2] = {{13.101, 13.201, 13.301}, {13.102, 13.202, 13.302}}; +float1x4 f14_2[2] = {{14.101, 14.201, 14.301, 14.401}, {14.102, 14.202, 14.302, 14.402}}; +float2x1 f21_2[2] = {{{21.1101, 21.2101}}, {{21.1102, 21.2102}}}; +float2x2 f22_2[2] = {{{22.1101, 22.2101}, {22.1201, 22.2201}}, {{22.1102, 22.2102}, {22.1202, 22.2202}}}; +float2x3 f23_2[2] = {{{23.1101, 23.2101}, {23.1201, 23.2201}, {23.1301, 23.2301}}, {{23.1102, 23.2102}, + {23.1202, 23.2202}, {23.1302, 23.2302}}}; +float2x4 f24_2[2] = {{{24.1101, 24.2101}, {24.1201, 24.2201}, {24.1301, 24.2301}, {24.1401, 24.2401}}, + {{24.1102, 24.2102}, {24.1202, 24.2202}, {24.1302, 24.2302}, {24.1402, 24.2402}}}; +float3x1 f31_2[2] = {{{31.1101, 31.2101, 31.3101}}, {{31.1102, 31.2102, 31.3102}}}; +float3x2 f32_2[2] = {{{32.1101, 32.2101, 32.3101}, {32.1201, 32.2201, 32.3201}}, + {{32.1102, 32.2102, 32.3102}, {32.1202, 32.2202, 32.3202}}}; +float3x3 f33_2[2] = {{{33.1101, 33.2101, 33.3101}, {33.1201, 33.2201, 33.3201}, + {33.1301, 33.2301, 33.3301}}, {{33.1102, 33.2102, 33.3102}, {33.1202, 33.2202, 33.3202}, + {33.1302, 33.2302, 33.3302}}}; +float3x4 f34_2[2] = {{{34.1101, 34.2101, 34.3101}, {34.1201, 34.2201, 34.3201}, + {34.1301, 34.2301, 34.3301}, {34.1401, 34.2401, 34.3401}}, {{34.1102, 34.2102, 34.3102}, + {34.1202, 34.2202, 34.3202}, {34.1302, 34.2302, 34.3302}, {34.1402, 34.2402, 34.3402}}}; +float4x1 f41_2[2] = {{{41.1101, 41.2101, 41.3101, 41.4101}}, {{41.1102, 41.2102, 41.3102, 41.4102}}}; +float4x2 f42_2[2] = {{{42.1101, 42.2101, 42.3101, 42.4101}, {42.1201, 42.2201, 42.3201, 42.4201}}, + {{42.1102, 42.2102, 42.3102, 42.4102}, {42.1202, 42.2202, 42.3202, 42.4202}}}; +float4x3 f43_2[2] = {{{43.1101, 43.2101, 43.3101, 43.4101}, {43.1201, 43.2201, 43.3201, 43.4201}, + {43.1301, 43.2301, 43.3301, 43.4301}}, {{43.1102, 43.2102, 43.3102, 43.4102}, + {43.1202, 43.2202, 43.3202, 43.4202}, {43.1302, 43.2302, 43.3302, 43.4302}}}; +float4x4 f44_2[2] = {{{44.1101, 44.2101, 44.3101, 44.4101}, {44.1201, 44.2201, 44.3201, 44.4201}, + {44.1301, 44.2301, 44.3301, 44.4301}, {44.1401, 44.2401, 44.3401, 44.4401}}, + {{44.1102, 44.2102, 44.3102, 44.4102}, {44.1202, 44.2202, 44.3202, 44.4202}, + {44.1302, 44.2302, 44.3302, 44.4302}, {44.1402, 44.2402, 44.3402, 44.4402}}}; +technique t { pass p { } } +#endif +static const DWORD test_effect_parameter_value_blob_float[] = +{ +0xfeff0901, 0x00000b80, 0x00000000, 0x00000003, 0x00000000, 0x00000024, 0x00000000, 0x00000000, +0x00000001, 0x00000001, 0x3dcccccd, 0x00000002, 0x00000066, 0x00000003, 0x00000001, 0x0000004c, +0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x3f8ccccd, 0x00000003, 0x00003166, 0x00000003, +0x00000001, 0x00000078, 0x00000000, 0x00000000, 0x00000002, 0x00000001, 0x40066666, 0x400ccccd, +0x00000003, 0x00003266, 0x00000003, 0x00000001, 0x000000a8, 0x00000000, 0x00000000, 0x00000003, +0x00000001, 0x40466666, 0x404ccccd, 0x40533333, 0x00000003, 0x00003366, 0x00000003, 0x00000001, +0x000000dc, 0x00000000, 0x00000000, 0x00000004, 0x00000001, 0x40833333, 0x40866666, 0x4089999a, +0x408ccccd, 0x00000003, 0x00003466, 0x00000003, 0x00000002, 0x00000104, 0x00000000, 0x00000000, +0x00000001, 0x00000001, 0x4131999a, 0x00000004, 0x00313166, 0x00000003, 0x00000002, 0x00000130, +0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x4141999a, 0x41433333, 0x00000004, 0x00323166, +0x00000003, 0x00000002, 0x00000160, 0x00000000, 0x00000000, 0x00000001, 0x00000003, 0x4151999a, +0x41533333, 0x4154cccd, 0x00000004, 0x00333166, 0x00000003, 0x00000002, 0x00000194, 0x00000000, +0x00000000, 0x00000001, 0x00000004, 0x4161999a, 0x41633333, 0x4164cccd, 0x41666666, 0x00000004, +0x00343166, 0x00000003, 0x00000002, 0x000001c0, 0x00000000, 0x00000000, 0x00000002, 0x00000001, +0x41a8e148, 0x41a9ae14, 0x00000004, 0x00313266, 0x00000003, 0x00000002, 0x000001f4, 0x00000000, +0x00000000, 0x00000002, 0x00000002, 0x41b0e148, 0x41b1ae14, 0x41b0f5c3, 0x41b1c28f, 0x00000004, +0x00323266, 0x00000003, 0x00000002, 0x00000230, 0x00000000, 0x00000000, 0x00000002, 0x00000003, +0x41b8e148, 0x41b9ae14, 0x41b8f5c3, 0x41b9c28f, 0x41b90a3d, 0x41b9d70a, 0x00000004, 0x00333266, +0x00000003, 0x00000002, 0x00000274, 0x00000000, 0x00000000, 0x00000002, 0x00000004, 0x41c0e148, +0x41c1ae14, 0x41c0f5c3, 0x41c1c28f, 0x41c10a3d, 0x41c1d70a, 0x41c11eb8, 0x41c1eb85, 0x00000004, +0x00343266, 0x00000003, 0x00000002, 0x000002a4, 0x00000000, 0x00000000, 0x00000003, 0x00000001, +0x41f8e148, 0x41f9ae14, 0x41fa7ae1, 0x00000004, 0x00313366, 0x00000003, 0x00000002, 0x000002e0, +0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x420070a4, 0x4200d70a, 0x42013d71, 0x42007ae1, +0x4200e148, 0x420147ae, 0x00000004, 0x00323366, 0x00000003, 0x00000002, 0x00000328, 0x00000000, +0x00000000, 0x00000003, 0x00000003, 0x420470a4, 0x4204d70a, 0x42053d71, 0x42047ae1, 0x4204e148, +0x420547ae, 0x4204851f, 0x4204eb85, 0x420551ec, 0x00000004, 0x00333366, 0x00000003, 0x00000002, +0x0000037c, 0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x420870a4, 0x4208d70a, 0x42093d71, +0x42087ae1, 0x4208e148, 0x420947ae, 0x4208851f, 0x4208eb85, 0x420951ec, 0x42088f5c, 0x4208f5c3, +0x42095c29, 0x00000004, 0x00343366, 0x00000003, 0x00000002, 0x000003b0, 0x00000000, 0x00000000, +0x00000004, 0x00000001, 0x422470a4, 0x4224d70a, 0x42253d71, 0x4225a3d7, 0x00000004, 0x00313466, +0x00000003, 0x00000002, 0x000003f4, 0x00000000, 0x00000000, 0x00000004, 0x00000002, 0x422870a4, +0x4228d70a, 0x42293d71, 0x4229a3d7, 0x42287ae1, 0x4228e148, 0x422947ae, 0x4229ae14, 0x00000004, +0x00323466, 0x00000003, 0x00000002, 0x00000448, 0x00000000, 0x00000000, 0x00000004, 0x00000003, +0x422c70a4, 0x422cd70a, 0x422d3d71, 0x422da3d7, 0x422c7ae1, 0x422ce148, 0x422d47ae, 0x422dae14, +0x422c851f, 0x422ceb85, 0x422d51ec, 0x422db852, 0x00000004, 0x00333466, 0x00000003, 0x00000002, +0x000004ac, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x423070a4, 0x4230d70a, 0x42313d71, +0x4231a3d7, 0x42307ae1, 0x4230e148, 0x423147ae, 0x4231ae14, 0x4230851f, 0x4230eb85, 0x423151ec, +0x4231b852, 0x42308f5c, 0x4230f5c3, 0x42315c29, 0x4231c28f, 0x00000004, 0x00343466, 0x00000003, +0x00000000, 0x000004d8, 0x00000000, 0x00000002, 0x00000001, 0x00000001, 0x3dced917, 0x3dd0e560, +0x00000004, 0x00325f66, 0x00000003, 0x00000001, 0x00000504, 0x00000000, 0x00000002, 0x00000001, +0x00000001, 0x3f8ced91, 0x3f8d0e56, 0x00000005, 0x325f3166, 0x00000000, 0x00000003, 0x00000001, +0x0000053c, 0x00000000, 0x00000002, 0x00000002, 0x00000001, 0x400676c9, 0x400cdd2f, 0x4006872b, +0x400ced91, 0x00000005, 0x325f3266, 0x00000000, 0x00000003, 0x00000001, 0x0000057c, 0x00000000, +0x00000002, 0x00000003, 0x00000001, 0x404676c9, 0x404cdd2f, 0x40534396, 0x4046872b, 0x404ced91, +0x405353f8, 0x00000005, 0x325f3366, 0x00000000, 0x00000003, 0x00000001, 0x000005c4, 0x00000000, +0x00000002, 0x00000004, 0x00000001, 0x40833b64, 0x40866e98, 0x4089a1cb, 0x408cd4fe, 0x40834396, +0x408676c9, 0x4089a9fc, 0x408cdd2f, 0x00000005, 0x325f3466, 0x00000000, 0x00000003, 0x00000002, +0x000005f4, 0x00000000, 0x00000002, 0x00000001, 0x00000001, 0x41319db2, 0x4131a1cb, 0x00000006, +0x5f313166, 0x00000032, 0x00000003, 0x00000002, 0x0000062c, 0x00000000, 0x00000002, 0x00000001, +0x00000002, 0x41419db2, 0x4143374c, 0x4141a1cb, 0x41433b64, 0x00000006, 0x5f323166, 0x00000032, +0x00000003, 0x00000002, 0x0000066c, 0x00000000, 0x00000002, 0x00000001, 0x00000003, 0x41519db2, +0x4153374c, 0x4154d0e5, 0x4151a1cb, 0x41533b64, 0x4154d4fe, 0x00000006, 0x5f333166, 0x00000032, +0x00000003, 0x00000002, 0x000006b4, 0x00000000, 0x00000002, 0x00000001, 0x00000004, 0x41619db2, +0x4163374c, 0x4164d0e5, 0x41666a7f, 0x4161a1cb, 0x41633b64, 0x4164d4fe, 0x41666e98, 0x00000006, +0x5f343166, 0x00000032, 0x00000003, 0x00000002, 0x000006ec, 0x00000000, 0x00000002, 0x00000002, +0x00000001, 0x41a8e17c, 0x41a9ae49, 0x41a8e1b1, 0x41a9ae7d, 0x00000006, 0x5f313266, 0x00000032, +0x00000003, 0x00000002, 0x00000734, 0x00000000, 0x00000002, 0x00000002, 0x00000002, 0x41b0e17c, +0x41b1ae49, 0x41b0f5f7, 0x41b1c2c4, 0x41b0e1b1, 0x41b1ae7d, 0x41b0f62b, 0x41b1c2f8, 0x00000006, +0x5f323266, 0x00000032, 0x00000003, 0x00000002, 0x0000078c, 0x00000000, 0x00000002, 0x00000002, +0x00000003, 0x41b8e17c, 0x41b9ae49, 0x41b8f5f7, 0x41b9c2c4, 0x41b90a72, 0x41b9d73f, 0x41b8e1b1, +0x41b9ae7d, 0x41b8f62b, 0x41b9c2f8, 0x41b90aa6, 0x41b9d773, 0x00000006, 0x5f333266, 0x00000032, +0x00000003, 0x00000002, 0x000007f4, 0x00000000, 0x00000002, 0x00000002, 0x00000004, 0x41c0e17c, +0x41c1ae49, 0x41c0f5f7, 0x41c1c2c4, 0x41c10a72, 0x41c1d73f, 0x41c11eed, 0x41c1ebba, 0x41c0e1b1, +0x41c1ae7d, 0x41c0f62b, 0x41c1c2f8, 0x41c10aa6, 0x41c1d773, 0x41c11f21, 0x41c1ebee, 0x00000006, +0x5f343266, 0x00000032, 0x00000003, 0x00000002, 0x00000834, 0x00000000, 0x00000002, 0x00000003, +0x00000001, 0x41f8e17c, 0x41f9ae49, 0x41fa7b16, 0x41f8e1b1, 0x41f9ae7d, 0x41fa7b4a, 0x00000006, +0x5f313366, 0x00000032, 0x00000003, 0x00000002, 0x0000088c, 0x00000000, 0x00000002, 0x00000003, +0x00000002, 0x420070be, 0x4200d724, 0x42013d8b, 0x42007afb, 0x4200e162, 0x420147c8, 0x420070d8, +0x4200d73f, 0x42013da5, 0x42007b16, 0x4200e17c, 0x420147e3, 0x00000006, 0x5f323366, 0x00000032, +0x00000003, 0x00000002, 0x000008fc, 0x00000000, 0x00000002, 0x00000003, 0x00000003, 0x420470be, +0x4204d724, 0x42053d8b, 0x42047afb, 0x4204e162, 0x420547c8, 0x42048539, 0x4204eb9f, 0x42055206, +0x420470d8, 0x4204d73f, 0x42053da5, 0x42047b16, 0x4204e17c, 0x420547e3, 0x42048553, 0x4204ebba, +0x42055220, 0x00000006, 0x5f333366, 0x00000032, 0x00000003, 0x00000002, 0x00000984, 0x00000000, +0x00000002, 0x00000003, 0x00000004, 0x420870be, 0x4208d724, 0x42093d8b, 0x42087afb, 0x4208e162, +0x420947c8, 0x42088539, 0x4208eb9f, 0x42095206, 0x42088f76, 0x4208f5dd, 0x42095c43, 0x420870d8, +0x4208d73f, 0x42093da5, 0x42087b16, 0x4208e17c, 0x420947e3, 0x42088553, 0x4208ebba, 0x42095220, +0x42088f91, 0x4208f5f7, 0x42095c5d, 0x00000006, 0x5f343366, 0x00000032, 0x00000003, 0x00000002, +0x000009cc, 0x00000000, 0x00000002, 0x00000004, 0x00000001, 0x422470be, 0x4224d724, 0x42253d8b, +0x4225a3f1, 0x422470d8, 0x4224d73f, 0x42253da5, 0x4225a40b, 0x00000006, 0x5f313466, 0x00000032, +0x00000003, 0x00000002, 0x00000a34, 0x00000000, 0x00000002, 0x00000004, 0x00000002, 0x422870be, +0x4228d724, 0x42293d8b, 0x4229a3f1, 0x42287afb, 0x4228e162, 0x422947c8, 0x4229ae2f, 0x422870d8, +0x4228d73f, 0x42293da5, 0x4229a40b, 0x42287b16, 0x4228e17c, 0x422947e3, 0x4229ae49, 0x00000006, +0x5f323466, 0x00000032, 0x00000003, 0x00000002, 0x00000abc, 0x00000000, 0x00000002, 0x00000004, +0x00000003, 0x422c70be, 0x422cd724, 0x422d3d8b, 0x422da3f1, 0x422c7afb, 0x422ce162, 0x422d47c8, +0x422dae2f, 0x422c8539, 0x422ceb9f, 0x422d5206, 0x422db86c, 0x422c70d8, 0x422cd73f, 0x422d3da5, +0x422da40b, 0x422c7b16, 0x422ce17c, 0x422d47e3, 0x422dae49, 0x422c8553, 0x422cebba, 0x422d5220, +0x422db886, 0x00000006, 0x5f333466, 0x00000032, 0x00000003, 0x00000002, 0x00000b64, 0x00000000, +0x00000002, 0x00000004, 0x00000004, 0x423070be, 0x4230d724, 0x42313d8b, 0x4231a3f1, 0x42307afb, +0x4230e162, 0x423147c8, 0x4231ae2f, 0x42308539, 0x4230eb9f, 0x42315206, 0x4231b86c, 0x42308f76, +0x4230f5dd, 0x42315c43, 0x4231c2aa, 0x423070d8, 0x4230d73f, 0x42313da5, 0x4231a40b, 0x42307b16, +0x4230e17c, 0x423147e3, 0x4231ae49, 0x42308553, 0x4230ebba, 0x42315220, 0x4231b886, 0x42308f91, +0x4230f5f7, 0x42315c5d, 0x4231c2c4, 0x00000006, 0x5f343466, 0x00000032, 0x00000002, 0x00000070, +0x00000002, 0x00000074, 0x0000002a, 0x00000001, 0x00000001, 0x00000001, 0x00000004, 0x00000020, +0x00000000, 0x00000000, 0x0000002c, 0x00000048, 0x00000000, 0x00000000, 0x00000054, 0x00000070, +0x00000000, 0x00000000, 0x00000080, 0x0000009c, 0x00000000, 0x00000000, 0x000000b0, 0x000000cc, +0x00000000, 0x00000000, 0x000000e4, 0x00000100, 0x00000000, 0x00000000, 0x0000010c, 0x00000128, +0x00000000, 0x00000000, 0x00000138, 0x00000154, 0x00000000, 0x00000000, 0x00000168, 0x00000184, +0x00000000, 0x00000000, 0x0000019c, 0x000001b8, 0x00000000, 0x00000000, 0x000001c8, 0x000001e4, +0x00000000, 0x00000000, 0x000001fc, 0x00000218, 0x00000000, 0x00000000, 0x00000238, 0x00000254, +0x00000000, 0x00000000, 0x0000027c, 0x00000298, 0x00000000, 0x00000000, 0x000002ac, 0x000002c8, +0x00000000, 0x00000000, 0x000002e8, 0x00000304, 0x00000000, 0x00000000, 0x00000330, 0x0000034c, +0x00000000, 0x00000000, 0x00000384, 0x000003a0, 0x00000000, 0x00000000, 0x000003b8, 0x000003d4, +0x00000000, 0x00000000, 0x000003fc, 0x00000418, 0x00000000, 0x00000000, 0x00000450, 0x0000046c, +0x00000000, 0x00000000, 0x000004b4, 0x000004d0, 0x00000000, 0x00000000, 0x000004e0, 0x000004fc, +0x00000000, 0x00000000, 0x00000510, 0x0000052c, 0x00000000, 0x00000000, 0x00000548, 0x00000564, +0x00000000, 0x00000000, 0x00000588, 0x000005a4, 0x00000000, 0x00000000, 0x000005d0, 0x000005ec, +0x00000000, 0x00000000, 0x00000600, 0x0000061c, 0x00000000, 0x00000000, 0x00000638, 0x00000654, +0x00000000, 0x00000000, 0x00000678, 0x00000694, 0x00000000, 0x00000000, 0x000006c0, 0x000006dc, +0x00000000, 0x00000000, 0x000006f8, 0x00000714, 0x00000000, 0x00000000, 0x00000740, 0x0000075c, +0x00000000, 0x00000000, 0x00000798, 0x000007b4, 0x00000000, 0x00000000, 0x00000800, 0x0000081c, +0x00000000, 0x00000000, 0x00000840, 0x0000085c, 0x00000000, 0x00000000, 0x00000898, 0x000008b4, +0x00000000, 0x00000000, 0x00000908, 0x00000924, 0x00000000, 0x00000000, 0x00000990, 0x000009ac, +0x00000000, 0x00000000, 0x000009d8, 0x000009f4, 0x00000000, 0x00000000, 0x00000a40, 0x00000a5c, +0x00000000, 0x00000000, 0x00000ac8, 0x00000ae4, 0x00000000, 0x00000000, 0x00000b78, 0x00000000, +0x00000001, 0x00000b70, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +struct test_effect_parameter_value_result test_effect_parameter_value_result_float[] = +{ + {"f", {"f", NULL, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 0, 0, 0, 0, 4}, 10}, + {"f1", {"f1", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 1, 0, 0, 0, 0, 4}, 20}, + {"f2", {"f2", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 2, 0, 0, 0, 0, 8}, 30}, + {"f3", {"f3", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 3, 0, 0, 0, 0, 12}, 41}, + {"f4", {"f4", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 0, 0, 0, 0, 16}, 53}, + {"f11", {"f11", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 1, 1, 0, 0, 0, 0, 4}, 66}, + {"f12", {"f12", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 1, 2, 0, 0, 0, 0, 8}, 76}, + {"f13", {"f13", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 1, 3, 0, 0, 0, 0, 12}, 87}, + {"f14", {"f14", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 1, 4, 0, 0, 0, 0, 16}, 99}, + {"f21", {"f21", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 2, 1, 0, 0, 0, 0, 8}, 112}, + {"f22", {"f22", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 2, 2, 0, 0, 0, 0, 16}, 123}, + {"f23", {"f23", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 2, 3, 0, 0, 0, 0, 24}, 136}, + {"f24", {"f24", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 2, 4, 0, 0, 0, 0, 32}, 151}, + {"f31", {"f31", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 1, 0, 0, 0, 0, 12}, 168}, + {"f32", {"f32", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 2, 0, 0, 0, 0, 24}, 180}, + {"f33", {"f33", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 3, 0, 0, 0, 0, 36}, 195}, + {"f34", {"f34", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 4, 0, 0, 0, 0, 48}, 213}, + {"f41", {"f41", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 1, 0, 0, 0, 0, 16}, 234}, + {"f42", {"f42", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 2, 0, 0, 0, 0, 32}, 247}, + {"f43", {"f43", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 3, 0, 0, 0, 0, 48}, 264}, + {"f44", {"f44", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 4, 0, 0, 0, 0, 64}, 285}, + {"f_2", {"f_2", NULL, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 2, 0, 0, 0, 8}, 310}, + {"f1_2", {"f1_2", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 1, 2, 0, 0, 0, 8}, 321}, + {"f2_2", {"f2_2", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 2, 2, 0, 0, 0, 16}, 333}, + {"f3_2", {"f3_2", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 3, 2, 0, 0, 0, 24}, 347}, + {"f4_2", {"f4_2", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 2, 0, 0, 0, 32}, 363}, + {"f11_2", {"f11_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 1, 1, 2, 0, 0, 0, 8}, 381}, + {"f12_2", {"f12_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 1, 2, 2, 0, 0, 0, 16}, 393}, + {"f13_2", {"f13_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 1, 3, 2, 0, 0, 0, 24}, 407}, + {"f14_2", {"f14_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 1, 4, 2, 0, 0, 0, 32}, 423}, + {"f21_2", {"f21_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 2, 1, 2, 0, 0, 0, 16}, 441}, + {"f22_2", {"f22_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 2, 2, 2, 0, 0, 0, 32}, 455}, + {"f23_2", {"f23_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 2, 3, 2, 0, 0, 0, 48}, 473}, + {"f24_2", {"f24_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 2, 4, 2, 0, 0, 0, 64}, 495}, + {"f31_2", {"f31_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 1, 2, 0, 0, 0, 24}, 521}, + {"f32_2", {"f32_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 2, 2, 0, 0, 0, 48}, 537}, + {"f33_2", {"f33_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 3, 2, 0, 0, 0, 72}, 559}, + {"f34_2", {"f34_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 4, 2, 0, 0, 0, 96}, 587}, + {"f41_2", {"f41_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 1, 2, 0, 0, 0, 32}, 621}, + {"f42_2", {"f42_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 2, 2, 0, 0, 0, 64}, 639}, + {"f43_2", {"f43_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 3, 2, 0, 0, 0, 96}, 665}, + {"f44_2", {"f44_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 4, 2, 0, 0, 0, 128}, 699}, +}; + +/* + * fxc.exe /Tfx_2_0 + */ +#if 0 +int i = 1; +int1 i1 = {11}; +int2 i2 = {21, 22}; +int3 i3 = {31, 32, 33}; +int4 i4 = {41, 42, 43, 44}; +int1x1 i11 = {111}; +int1x2 i12 = {121, 122}; +int1x3 i13 = {131, 132, 133}; +int1x4 i14 = {141, 142, 143, 144}; +int2x1 i21 = {{2111, 2121}}; +int2x2 i22 = {{2211, 2221}, {2212, 2222}}; +int2x3 i23 = {{2311, 2321}, {2312, 2322}, {2313, 2323}}; +int2x4 i24 = {{2411, 2421}, {2412, 2422}, {2413, 2423}, {2414, 2424}}; +int3x1 i31 = {{3111, 3121, 3131}}; +int3x2 i32 = {{3211, 3221, 3231}, {3212, 3222, 3232}}; +int3x3 i33 = {{3311, 3321, 3331}, {3312, 3322, 3332}, + {3313, 3323, 3333}}; +int3x4 i34 = {{3411, 3421, 3431}, {3412, 3422, 3432}, + {3413, 3423, 3433}, {3414, 3424, 3434}}; +int4x1 i41 = {{4111, 4121, 4131, 4141}}; +int4x2 i42 = {{4211, 4221, 4231, 4241}, {4212, 4222, 4232, 4242}}; +int4x3 i43 = {{4311, 4321, 4331, 4341}, {4312, 4322, 4332, 4342}, + {4313, 4323, 4333, 4343}}; +int4x4 i44 = {{4411, 4421, 4431, 4441}, {4412, 4422, 4432, 4442}, + {4413, 4423, 4433, 4443}, {4414, 4424, 4434, 4444}}; +int i_2[2] = {0101, 0102}; +int1 i1_2[2] = {{1101}, {1102}}; +int2 i2_2[2] = {{2101, 2201}, {2102, 2202}}; +int3 i3_2[2] = {{3101, 3201, 3301}, {3102, 3202, 3302}}; +int4 i4_2[2] = {{4101, 4201, 4301, 4401}, {4102, 4202, 4302, 4402}}; +int1x1 i11_2[2] = {{11101}, {11102}}; +int1x2 i12_2[2] = {{12101, 12201}, {12102, 12202}}; +int1x3 i13_2[2] = {{13101, 13201, 13301}, {13102, 13202, 13302}}; +int1x4 i14_2[2] = {{14101, 14201, 14301, 14401}, {14102, 14202, 14302, 14402}}; +int2x1 i21_2[2] = {{{211101, 212101}}, {{211102, 212102}}}; +int2x2 i22_2[2] = {{{221101, 222101}, {221201, 222201}}, {{221102, 222102}, {221202, 222202}}}; +int2x3 i23_2[2] = {{{231101, 232101}, {231201, 232201}, {231301, 232301}}, {{231102, 232102}, + {231202, 232202}, {231302, 232302}}}; +int2x4 i24_2[2] = {{{241101, 242101}, {241201, 242201}, {241301, 242301}, {241401, 242401}}, + {{241102, 242102}, {241202, 242202}, {241302, 242302}, {241402, 242402}}}; +int3x1 i31_2[2] = {{{311101, 312101, 313101}}, {{311102, 312102, 313102}}}; +int3x2 i32_2[2] = {{{321101, 322101, 323101}, {321201, 322201, 323201}}, + {{321102, 322102, 323102}, {321202, 322202, 323202}}}; +int3x3 i33_2[2] = {{{331101, 332101, 333101}, {331201, 332201, 333201}, + {331301, 332301, 333301}}, {{331102, 332102, 333102}, {331202, 332202, 333202}, + {331302, 332302, 333302}}}; +int3x4 i34_2[2] = {{{341101, 342101, 343101}, {341201, 342201, 343201}, + {341301, 342301, 343301}, {341401, 342401, 343401}}, {{341102, 342102, 343102}, + {341202, 342202, 343202}, {341302, 342302, 343302}, {341402, 342402, 343402}}}; +int4x1 i41_2[2] = {{{411101, 412101, 413101, 414101}}, {{411102, 412102, 413102, 414102}}}; +int4x2 i42_2[2] = {{{421101, 422101, 423101, 424101}, {421201, 422201, 423201, 424201}}, + {{421102, 422102, 423102, 424102}, {421202, 422202, 423202, 424202}}}; +int4x3 i43_2[2] = {{{431101, 432101, 433101, 434101}, {431201, 432201, 433201, 434201}, + {431301, 432301, 433301, 434301}}, {{431102, 432102, 433102, 434102}, + {431202, 432202, 433202, 434202}, {431302, 432302, 433302, 434302}}}; +int4x4 i44_2[2] = {{{441101, 442101, 443101, 444101}, {441201, 442201, 443201, 444201}, + {441301, 442301, 443301, 444301}, {441401, 442401, 443401, 444401}}, + {{441102, 442102, 443102, 444102}, {441202, 442202, 443202, 444202}, + {441302, 442302, 443302, 444302}, {441402, 442402, 443402, 444402}}}; +technique t { pass p { } } +#endif +static const DWORD test_effect_parameter_value_blob_int[] = +{ +0xfeff0901, 0x00000b80, 0x00000000, 0x00000002, 0x00000000, 0x00000024, 0x00000000, 0x00000000, +0x00000001, 0x00000001, 0x00000001, 0x00000002, 0x00000069, 0x00000002, 0x00000001, 0x0000004c, +0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x0000000b, 0x00000003, 0x00003169, 0x00000002, +0x00000001, 0x00000078, 0x00000000, 0x00000000, 0x00000002, 0x00000001, 0x00000015, 0x00000016, +0x00000003, 0x00003269, 0x00000002, 0x00000001, 0x000000a8, 0x00000000, 0x00000000, 0x00000003, +0x00000001, 0x0000001f, 0x00000020, 0x00000021, 0x00000003, 0x00003369, 0x00000002, 0x00000001, +0x000000dc, 0x00000000, 0x00000000, 0x00000004, 0x00000001, 0x00000029, 0x0000002a, 0x0000002b, +0x0000002c, 0x00000003, 0x00003469, 0x00000002, 0x00000002, 0x00000104, 0x00000000, 0x00000000, +0x00000001, 0x00000001, 0x0000006f, 0x00000004, 0x00313169, 0x00000002, 0x00000002, 0x00000130, +0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x00000079, 0x0000007a, 0x00000004, 0x00323169, +0x00000002, 0x00000002, 0x00000160, 0x00000000, 0x00000000, 0x00000001, 0x00000003, 0x00000083, +0x00000084, 0x00000085, 0x00000004, 0x00333169, 0x00000002, 0x00000002, 0x00000194, 0x00000000, +0x00000000, 0x00000001, 0x00000004, 0x0000008d, 0x0000008e, 0x0000008f, 0x00000090, 0x00000004, +0x00343169, 0x00000002, 0x00000002, 0x000001c0, 0x00000000, 0x00000000, 0x00000002, 0x00000001, +0x0000083f, 0x00000849, 0x00000004, 0x00313269, 0x00000002, 0x00000002, 0x000001f4, 0x00000000, +0x00000000, 0x00000002, 0x00000002, 0x000008a3, 0x000008ad, 0x000008a4, 0x000008ae, 0x00000004, +0x00323269, 0x00000002, 0x00000002, 0x00000230, 0x00000000, 0x00000000, 0x00000002, 0x00000003, +0x00000907, 0x00000911, 0x00000908, 0x00000912, 0x00000909, 0x00000913, 0x00000004, 0x00333269, +0x00000002, 0x00000002, 0x00000274, 0x00000000, 0x00000000, 0x00000002, 0x00000004, 0x0000096b, +0x00000975, 0x0000096c, 0x00000976, 0x0000096d, 0x00000977, 0x0000096e, 0x00000978, 0x00000004, +0x00343269, 0x00000002, 0x00000002, 0x000002a4, 0x00000000, 0x00000000, 0x00000003, 0x00000001, +0x00000c27, 0x00000c31, 0x00000c3b, 0x00000004, 0x00313369, 0x00000002, 0x00000002, 0x000002e0, +0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000c8b, 0x00000c95, 0x00000c9f, 0x00000c8c, +0x00000c96, 0x00000ca0, 0x00000004, 0x00323369, 0x00000002, 0x00000002, 0x00000328, 0x00000000, +0x00000000, 0x00000003, 0x00000003, 0x00000cef, 0x00000cf9, 0x00000d03, 0x00000cf0, 0x00000cfa, +0x00000d04, 0x00000cf1, 0x00000cfb, 0x00000d05, 0x00000004, 0x00333369, 0x00000002, 0x00000002, +0x0000037c, 0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x00000d53, 0x00000d5d, 0x00000d67, +0x00000d54, 0x00000d5e, 0x00000d68, 0x00000d55, 0x00000d5f, 0x00000d69, 0x00000d56, 0x00000d60, +0x00000d6a, 0x00000004, 0x00343369, 0x00000002, 0x00000002, 0x000003b0, 0x00000000, 0x00000000, +0x00000004, 0x00000001, 0x0000100f, 0x00001019, 0x00001023, 0x0000102d, 0x00000004, 0x00313469, +0x00000002, 0x00000002, 0x000003f4, 0x00000000, 0x00000000, 0x00000004, 0x00000002, 0x00001073, +0x0000107d, 0x00001087, 0x00001091, 0x00001074, 0x0000107e, 0x00001088, 0x00001092, 0x00000004, +0x00323469, 0x00000002, 0x00000002, 0x00000448, 0x00000000, 0x00000000, 0x00000004, 0x00000003, +0x000010d7, 0x000010e1, 0x000010eb, 0x000010f5, 0x000010d8, 0x000010e2, 0x000010ec, 0x000010f6, +0x000010d9, 0x000010e3, 0x000010ed, 0x000010f7, 0x00000004, 0x00333469, 0x00000002, 0x00000002, +0x000004ac, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x0000113b, 0x00001145, 0x0000114f, +0x00001159, 0x0000113c, 0x00001146, 0x00001150, 0x0000115a, 0x0000113d, 0x00001147, 0x00001151, +0x0000115b, 0x0000113e, 0x00001148, 0x00001152, 0x0000115c, 0x00000004, 0x00343469, 0x00000002, +0x00000000, 0x000004d8, 0x00000000, 0x00000002, 0x00000001, 0x00000001, 0x00000041, 0x00000042, +0x00000004, 0x00325f69, 0x00000002, 0x00000001, 0x00000504, 0x00000000, 0x00000002, 0x00000001, +0x00000001, 0x0000044d, 0x0000044e, 0x00000005, 0x325f3169, 0x00000000, 0x00000002, 0x00000001, +0x0000053c, 0x00000000, 0x00000002, 0x00000002, 0x00000001, 0x00000835, 0x00000899, 0x00000836, +0x0000089a, 0x00000005, 0x325f3269, 0x00000000, 0x00000002, 0x00000001, 0x0000057c, 0x00000000, +0x00000002, 0x00000003, 0x00000001, 0x00000c1d, 0x00000c81, 0x00000ce5, 0x00000c1e, 0x00000c82, +0x00000ce6, 0x00000005, 0x325f3369, 0x00000000, 0x00000002, 0x00000001, 0x000005c4, 0x00000000, +0x00000002, 0x00000004, 0x00000001, 0x00001005, 0x00001069, 0x000010cd, 0x00001131, 0x00001006, +0x0000106a, 0x000010ce, 0x00001132, 0x00000005, 0x325f3469, 0x00000000, 0x00000002, 0x00000002, +0x000005f4, 0x00000000, 0x00000002, 0x00000001, 0x00000001, 0x00002b5d, 0x00002b5e, 0x00000006, +0x5f313169, 0x00000032, 0x00000002, 0x00000002, 0x0000062c, 0x00000000, 0x00000002, 0x00000001, +0x00000002, 0x00002f45, 0x00002fa9, 0x00002f46, 0x00002faa, 0x00000006, 0x5f323169, 0x00000032, +0x00000002, 0x00000002, 0x0000066c, 0x00000000, 0x00000002, 0x00000001, 0x00000003, 0x0000332d, +0x00003391, 0x000033f5, 0x0000332e, 0x00003392, 0x000033f6, 0x00000006, 0x5f333169, 0x00000032, +0x00000002, 0x00000002, 0x000006b4, 0x00000000, 0x00000002, 0x00000001, 0x00000004, 0x00003715, +0x00003779, 0x000037dd, 0x00003841, 0x00003716, 0x0000377a, 0x000037de, 0x00003842, 0x00000006, +0x5f343169, 0x00000032, 0x00000002, 0x00000002, 0x000006ec, 0x00000000, 0x00000002, 0x00000002, +0x00000001, 0x0003389d, 0x00033c85, 0x0003389e, 0x00033c86, 0x00000006, 0x5f313269, 0x00000032, +0x00000002, 0x00000002, 0x00000734, 0x00000000, 0x00000002, 0x00000002, 0x00000002, 0x00035fad, +0x00036395, 0x00036011, 0x000363f9, 0x00035fae, 0x00036396, 0x00036012, 0x000363fa, 0x00000006, +0x5f323269, 0x00000032, 0x00000002, 0x00000002, 0x0000078c, 0x00000000, 0x00000002, 0x00000002, +0x00000003, 0x000386bd, 0x00038aa5, 0x00038721, 0x00038b09, 0x00038785, 0x00038b6d, 0x000386be, +0x00038aa6, 0x00038722, 0x00038b0a, 0x00038786, 0x00038b6e, 0x00000006, 0x5f333269, 0x00000032, +0x00000002, 0x00000002, 0x000007f4, 0x00000000, 0x00000002, 0x00000002, 0x00000004, 0x0003adcd, +0x0003b1b5, 0x0003ae31, 0x0003b219, 0x0003ae95, 0x0003b27d, 0x0003aef9, 0x0003b2e1, 0x0003adce, +0x0003b1b6, 0x0003ae32, 0x0003b21a, 0x0003ae96, 0x0003b27e, 0x0003aefa, 0x0003b2e2, 0x00000006, +0x5f343269, 0x00000032, 0x00000002, 0x00000002, 0x00000834, 0x00000000, 0x00000002, 0x00000003, +0x00000001, 0x0004bf3d, 0x0004c325, 0x0004c70d, 0x0004bf3e, 0x0004c326, 0x0004c70e, 0x00000006, +0x5f313369, 0x00000032, 0x00000002, 0x00000002, 0x0000088c, 0x00000000, 0x00000002, 0x00000003, +0x00000002, 0x0004e64d, 0x0004ea35, 0x0004ee1d, 0x0004e6b1, 0x0004ea99, 0x0004ee81, 0x0004e64e, +0x0004ea36, 0x0004ee1e, 0x0004e6b2, 0x0004ea9a, 0x0004ee82, 0x00000006, 0x5f323369, 0x00000032, +0x00000002, 0x00000002, 0x000008fc, 0x00000000, 0x00000002, 0x00000003, 0x00000003, 0x00050d5d, +0x00051145, 0x0005152d, 0x00050dc1, 0x000511a9, 0x00051591, 0x00050e25, 0x0005120d, 0x000515f5, +0x00050d5e, 0x00051146, 0x0005152e, 0x00050dc2, 0x000511aa, 0x00051592, 0x00050e26, 0x0005120e, +0x000515f6, 0x00000006, 0x5f333369, 0x00000032, 0x00000002, 0x00000002, 0x00000984, 0x00000000, +0x00000002, 0x00000003, 0x00000004, 0x0005346d, 0x00053855, 0x00053c3d, 0x000534d1, 0x000538b9, +0x00053ca1, 0x00053535, 0x0005391d, 0x00053d05, 0x00053599, 0x00053981, 0x00053d69, 0x0005346e, +0x00053856, 0x00053c3e, 0x000534d2, 0x000538ba, 0x00053ca2, 0x00053536, 0x0005391e, 0x00053d06, +0x0005359a, 0x00053982, 0x00053d6a, 0x00000006, 0x5f343369, 0x00000032, 0x00000002, 0x00000002, +0x000009cc, 0x00000000, 0x00000002, 0x00000004, 0x00000001, 0x000645dd, 0x000649c5, 0x00064dad, +0x00065195, 0x000645de, 0x000649c6, 0x00064dae, 0x00065196, 0x00000006, 0x5f313469, 0x00000032, +0x00000002, 0x00000002, 0x00000a34, 0x00000000, 0x00000002, 0x00000004, 0x00000002, 0x00066ced, +0x000670d5, 0x000674bd, 0x000678a5, 0x00066d51, 0x00067139, 0x00067521, 0x00067909, 0x00066cee, +0x000670d6, 0x000674be, 0x000678a6, 0x00066d52, 0x0006713a, 0x00067522, 0x0006790a, 0x00000006, +0x5f323469, 0x00000032, 0x00000002, 0x00000002, 0x00000abc, 0x00000000, 0x00000002, 0x00000004, +0x00000003, 0x000693fd, 0x000697e5, 0x00069bcd, 0x00069fb5, 0x00069461, 0x00069849, 0x00069c31, +0x0006a019, 0x000694c5, 0x000698ad, 0x00069c95, 0x0006a07d, 0x000693fe, 0x000697e6, 0x00069bce, +0x00069fb6, 0x00069462, 0x0006984a, 0x00069c32, 0x0006a01a, 0x000694c6, 0x000698ae, 0x00069c96, +0x0006a07e, 0x00000006, 0x5f333469, 0x00000032, 0x00000002, 0x00000002, 0x00000b64, 0x00000000, +0x00000002, 0x00000004, 0x00000004, 0x0006bb0d, 0x0006bef5, 0x0006c2dd, 0x0006c6c5, 0x0006bb71, +0x0006bf59, 0x0006c341, 0x0006c729, 0x0006bbd5, 0x0006bfbd, 0x0006c3a5, 0x0006c78d, 0x0006bc39, +0x0006c021, 0x0006c409, 0x0006c7f1, 0x0006bb0e, 0x0006bef6, 0x0006c2de, 0x0006c6c6, 0x0006bb72, +0x0006bf5a, 0x0006c342, 0x0006c72a, 0x0006bbd6, 0x0006bfbe, 0x0006c3a6, 0x0006c78e, 0x0006bc3a, +0x0006c022, 0x0006c40a, 0x0006c7f2, 0x00000006, 0x5f343469, 0x00000032, 0x00000002, 0x00000070, +0x00000002, 0x00000074, 0x0000002a, 0x00000001, 0x00000001, 0x00000001, 0x00000004, 0x00000020, +0x00000000, 0x00000000, 0x0000002c, 0x00000048, 0x00000000, 0x00000000, 0x00000054, 0x00000070, +0x00000000, 0x00000000, 0x00000080, 0x0000009c, 0x00000000, 0x00000000, 0x000000b0, 0x000000cc, +0x00000000, 0x00000000, 0x000000e4, 0x00000100, 0x00000000, 0x00000000, 0x0000010c, 0x00000128, +0x00000000, 0x00000000, 0x00000138, 0x00000154, 0x00000000, 0x00000000, 0x00000168, 0x00000184, +0x00000000, 0x00000000, 0x0000019c, 0x000001b8, 0x00000000, 0x00000000, 0x000001c8, 0x000001e4, +0x00000000, 0x00000000, 0x000001fc, 0x00000218, 0x00000000, 0x00000000, 0x00000238, 0x00000254, +0x00000000, 0x00000000, 0x0000027c, 0x00000298, 0x00000000, 0x00000000, 0x000002ac, 0x000002c8, +0x00000000, 0x00000000, 0x000002e8, 0x00000304, 0x00000000, 0x00000000, 0x00000330, 0x0000034c, +0x00000000, 0x00000000, 0x00000384, 0x000003a0, 0x00000000, 0x00000000, 0x000003b8, 0x000003d4, +0x00000000, 0x00000000, 0x000003fc, 0x00000418, 0x00000000, 0x00000000, 0x00000450, 0x0000046c, +0x00000000, 0x00000000, 0x000004b4, 0x000004d0, 0x00000000, 0x00000000, 0x000004e0, 0x000004fc, +0x00000000, 0x00000000, 0x00000510, 0x0000052c, 0x00000000, 0x00000000, 0x00000548, 0x00000564, +0x00000000, 0x00000000, 0x00000588, 0x000005a4, 0x00000000, 0x00000000, 0x000005d0, 0x000005ec, +0x00000000, 0x00000000, 0x00000600, 0x0000061c, 0x00000000, 0x00000000, 0x00000638, 0x00000654, +0x00000000, 0x00000000, 0x00000678, 0x00000694, 0x00000000, 0x00000000, 0x000006c0, 0x000006dc, +0x00000000, 0x00000000, 0x000006f8, 0x00000714, 0x00000000, 0x00000000, 0x00000740, 0x0000075c, +0x00000000, 0x00000000, 0x00000798, 0x000007b4, 0x00000000, 0x00000000, 0x00000800, 0x0000081c, +0x00000000, 0x00000000, 0x00000840, 0x0000085c, 0x00000000, 0x00000000, 0x00000898, 0x000008b4, +0x00000000, 0x00000000, 0x00000908, 0x00000924, 0x00000000, 0x00000000, 0x00000990, 0x000009ac, +0x00000000, 0x00000000, 0x000009d8, 0x000009f4, 0x00000000, 0x00000000, 0x00000a40, 0x00000a5c, +0x00000000, 0x00000000, 0x00000ac8, 0x00000ae4, 0x00000000, 0x00000000, 0x00000b78, 0x00000000, +0x00000001, 0x00000b70, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +struct test_effect_parameter_value_result test_effect_parameter_value_result_int[] = +{ + {"i", {"i", NULL, D3DXPC_SCALAR, D3DXPT_INT, 1, 1, 0, 0, 0, 0, 4}, 10}, + {"i1", {"i1", NULL, D3DXPC_VECTOR, D3DXPT_INT, 1, 1, 0, 0, 0, 0, 4}, 20}, + {"i2", {"i2", NULL, D3DXPC_VECTOR, D3DXPT_INT, 1, 2, 0, 0, 0, 0, 8}, 30}, + {"i3", {"i3", NULL, D3DXPC_VECTOR, D3DXPT_INT, 1, 3, 0, 0, 0, 0, 12}, 41}, + {"i4", {"i4", NULL, D3DXPC_VECTOR, D3DXPT_INT, 1, 4, 0, 0, 0, 0, 16}, 53}, + {"i11", {"i11", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 1, 1, 0, 0, 0, 0, 4}, 66}, + {"i12", {"i12", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 1, 2, 0, 0, 0, 0, 8}, 76}, + {"i13", {"i13", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 1, 3, 0, 0, 0, 0, 12}, 87}, + {"i14", {"i14", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 1, 4, 0, 0, 0, 0, 16}, 99}, + {"i21", {"i21", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 2, 1, 0, 0, 0, 0, 8}, 112}, + {"i22", {"i22", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 2, 2, 0, 0, 0, 0, 16}, 123}, + {"i23", {"i23", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 2, 3, 0, 0, 0, 0, 24}, 136}, + {"i24", {"i24", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 2, 4, 0, 0, 0, 0, 32}, 151}, + {"i31", {"i31", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 3, 1, 0, 0, 0, 0, 12}, 168}, + {"i32", {"i32", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 3, 2, 0, 0, 0, 0, 24}, 180}, + {"i33", {"i33", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 3, 3, 0, 0, 0, 0, 36}, 195}, + {"i34", {"i34", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 3, 4, 0, 0, 0, 0, 48}, 213}, + {"i41", {"i41", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 4, 1, 0, 0, 0, 0, 16}, 234}, + {"i42", {"i42", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 4, 2, 0, 0, 0, 0, 32}, 247}, + {"i43", {"i43", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 4, 3, 0, 0, 0, 0, 48}, 264}, + {"i44", {"i44", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 4, 4, 0, 0, 0, 0, 64}, 285}, + {"i_2", {"i_2", NULL, D3DXPC_SCALAR, D3DXPT_INT, 1, 1, 2, 0, 0, 0, 8}, 310}, + {"i1_2", {"i1_2", NULL, D3DXPC_VECTOR, D3DXPT_INT, 1, 1, 2, 0, 0, 0, 8}, 321}, + {"i2_2", {"i2_2", NULL, D3DXPC_VECTOR, D3DXPT_INT, 1, 2, 2, 0, 0, 0, 16}, 333}, + {"i3_2", {"i3_2", NULL, D3DXPC_VECTOR, D3DXPT_INT, 1, 3, 2, 0, 0, 0, 24}, 347}, + {"i4_2", {"i4_2", NULL, D3DXPC_VECTOR, D3DXPT_INT, 1, 4, 2, 0, 0, 0, 32}, 363}, + {"i11_2", {"i11_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 1, 1, 2, 0, 0, 0, 8}, 381}, + {"i12_2", {"i12_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 1, 2, 2, 0, 0, 0, 16}, 393}, + {"i13_2", {"i13_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 1, 3, 2, 0, 0, 0, 24}, 407}, + {"i14_2", {"i14_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 1, 4, 2, 0, 0, 0, 32}, 423}, + {"i21_2", {"i21_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 2, 1, 2, 0, 0, 0, 16}, 441}, + {"i22_2", {"i22_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 2, 2, 2, 0, 0, 0, 32}, 455}, + {"i23_2", {"i23_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 2, 3, 2, 0, 0, 0, 48}, 473}, + {"i24_2", {"i24_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 2, 4, 2, 0, 0, 0, 64}, 495}, + {"i31_2", {"i31_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 3, 1, 2, 0, 0, 0, 24}, 521}, + {"i32_2", {"i32_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 3, 2, 2, 0, 0, 0, 48}, 537}, + {"i33_2", {"i33_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 3, 3, 2, 0, 0, 0, 72}, 559}, + {"i34_2", {"i34_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 3, 4, 2, 0, 0, 0, 96}, 587}, + {"i41_2", {"i41_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 4, 1, 2, 0, 0, 0, 32}, 621}, + {"i42_2", {"i42_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 4, 2, 2, 0, 0, 0, 64}, 639}, + {"i43_2", {"i43_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 4, 3, 2, 0, 0, 0, 96}, 665}, + {"i44_2", {"i44_2", NULL, D3DXPC_MATRIX_ROWS, D3DXPT_INT, 4, 4, 2, 0, 0, 0, 128}, 699}, +}; + +/* + * fxc.exe /Tfx_2_0 + */ +#if 0 +string s = "test"; +string s_2[2] = {"test1", "test2"}; +texture2D tex; +Vertexshader v; +Vertexshader v_2[2]; +Pixelshader p; +Pixelshader p_2[2]; +technique t { pass p { } } +#endif +static const DWORD test_effect_parameter_value_blob_object[] = +{ +0xfeff0901, 0x00000100, 0x00000000, 0x00000004, 0x00000004, 0x0000001c, 0x00000000, 0x00000000, +0x00000001, 0x00000002, 0x00000073, 0x00000004, 0x00000004, 0x00000040, 0x00000000, 0x00000002, +0x00000002, 0x00000003, 0x00000004, 0x00325f73, 0x00000007, 0x00000004, 0x00000060, 0x00000000, +0x00000000, 0x00000004, 0x00000004, 0x00786574, 0x00000010, 0x00000004, 0x00000080, 0x00000000, +0x00000000, 0x00000005, 0x00000002, 0x00000076, 0x00000010, 0x00000004, 0x000000a4, 0x00000000, +0x00000002, 0x00000006, 0x00000007, 0x00000004, 0x00325f76, 0x0000000f, 0x00000004, 0x000000c4, +0x00000000, 0x00000000, 0x00000008, 0x00000002, 0x00000070, 0x0000000f, 0x00000004, 0x000000e8, +0x00000000, 0x00000002, 0x00000009, 0x0000000a, 0x00000004, 0x00325f70, 0x00000002, 0x00000070, +0x00000002, 0x00000074, 0x00000007, 0x00000001, 0x00000007, 0x0000000b, 0x00000004, 0x00000018, +0x00000000, 0x00000000, 0x00000024, 0x00000038, 0x00000000, 0x00000000, 0x00000048, 0x0000005c, +0x00000000, 0x00000000, 0x00000068, 0x0000007c, 0x00000000, 0x00000000, 0x00000088, 0x0000009c, +0x00000000, 0x00000000, 0x000000ac, 0x000000c0, 0x00000000, 0x00000000, 0x000000cc, 0x000000e0, +0x00000000, 0x00000000, 0x000000f8, 0x00000000, 0x00000001, 0x000000f0, 0x00000000, 0x00000000, +0x0000000a, 0x00000000, 0x00000009, 0x00000000, 0x0000000a, 0x00000000, 0x00000008, 0x00000000, +0x00000006, 0x00000000, 0x00000007, 0x00000000, 0x00000005, 0x00000000, 0x00000004, 0x00000000, +0x00000002, 0x00000006, 0x74736574, 0x00000031, 0x00000003, 0x00000006, 0x74736574, 0x00000032, +0x00000001, 0x00000005, 0x74736574, 0x00000000, +}; + +struct test_effect_parameter_value_result test_effect_parameter_value_result_object[] = +{ + {"s", {"s", NULL, D3DXPC_OBJECT, D3DXPT_STRING, 0, 0, 0, 0, 0, 0, sizeof(void *)}, 0}, + {"s_2", {"s_2", NULL, D3DXPC_OBJECT, D3DXPT_STRING, 0, 0, 2, 0, 0, 0, 2 * sizeof(void *)}, 0}, + {"tex", {"tex", NULL, D3DXPC_OBJECT, D3DXPT_TEXTURE2D, 0, 0, 0, 0, 0, 0, sizeof(void *)}, 0}, + {"v", {"v", NULL, D3DXPC_OBJECT, D3DXPT_VERTEXSHADER, 0, 0, 0, 0, 0, 0, sizeof(void *)}, 0}, + {"v_2", {"v_2", NULL, D3DXPC_OBJECT, D3DXPT_VERTEXSHADER, 0, 0, 2, 0, 0, 0, 2 * sizeof(void *)}, 0}, + {"p", {"p", NULL, D3DXPC_OBJECT, D3DXPT_PIXELSHADER, 0, 0, 0, 0, 0, 0, sizeof(void *)}, 0}, + {"p_2", {"p_2", NULL, D3DXPC_OBJECT, D3DXPT_PIXELSHADER, 0, 0, 2, 0, 0, 0, 2 * sizeof(void *)}, 0}, +}; + +/* + * fxc.exe /Tfx_2_0 + */ +#if 0 +float3 f3 = {-3.1, 153.2, 283.3}; +float3 f3min = {-31.1, -31.2, -31.3}; +float3 f3max = {320.1, 320.2, 320.3}; +float4 f4 = {-4.1, 154.2, 284.3, 34.4}; +float4 f4min = {-41.1, -41.2, -41.3, -41.4}; +float4 f4max = {420.1, 42.20, 420.3, 420.4}; +technique t { pass p { } } +#endif +static const DWORD test_effect_parameter_value_blob_special[] = +{ +0xfeff0901, 0x00000150, 0x00000000, 0x00000003, 0x00000001, 0x0000002c, 0x00000000, 0x00000000, +0x00000003, 0x00000001, 0xc0466666, 0x43193333, 0x438da666, 0x00000003, 0x00003366, 0x00000003, +0x00000001, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0xc1f8cccd, 0xc1f9999a, +0xc1fa6666, 0x00000006, 0x696d3366, 0x0000006e, 0x00000003, 0x00000001, 0x00000090, 0x00000000, +0x00000000, 0x00000003, 0x00000001, 0x43a00ccd, 0x43a0199a, 0x43a02666, 0x00000006, 0x616d3366, +0x00000078, 0x00000003, 0x00000001, 0x000000c8, 0x00000000, 0x00000000, 0x00000004, 0x00000001, +0xc0833333, 0x431a3333, 0x438e2666, 0x4209999a, 0x00000003, 0x00003466, 0x00000003, 0x00000001, +0x000000fc, 0x00000000, 0x00000000, 0x00000004, 0x00000001, 0xc2246666, 0xc224cccd, 0xc2253333, +0xc225999a, 0x00000006, 0x696d3466, 0x0000006e, 0x00000003, 0x00000001, 0x00000134, 0x00000000, +0x00000000, 0x00000004, 0x00000001, 0x43d20ccd, 0x4228cccd, 0x43d22666, 0x43d23333, 0x00000006, +0x616d3466, 0x00000078, 0x00000002, 0x00000070, 0x00000002, 0x00000074, 0x00000006, 0x00000001, +0x00000001, 0x00000001, 0x00000004, 0x00000020, 0x00000000, 0x00000000, 0x00000034, 0x00000050, +0x00000000, 0x00000000, 0x00000068, 0x00000084, 0x00000000, 0x00000000, 0x0000009c, 0x000000b8, +0x00000000, 0x00000000, 0x000000d0, 0x000000ec, 0x00000000, 0x00000000, 0x00000108, 0x00000124, +0x00000000, 0x00000000, 0x00000148, 0x00000000, 0x00000001, 0x00000140, 0x00000000, 0x00000000, +0x00000000, 0x00000000, +}; + +struct test_effect_parameter_value_result test_effect_parameter_value_result_special[] = +{ + {"f3", {"f3", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 3, 0, 0, 0, 0, 12}, 10}, + {"f3min", {"f3min", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 3, 0, 0, 0, 0, 12}, 22}, + {"f3max", {"f3max", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 3, 0, 0, 0, 0, 12}, 35}, + {"f4", {"f4", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 0, 0, 0, 0, 16}, 48}, + {"f4min", {"f4min", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 0, 0, 0, 0, 16}, 61}, + {"f4max", {"f4max", NULL, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 0, 0, 0, 0, 16}, 75}, +}; + +#define ADD_PARAMETER_VALUE(x) {\ + test_effect_parameter_value_blob_ ## x,\ + sizeof(test_effect_parameter_value_blob_ ## x),\ + test_effect_parameter_value_result_ ## x,\ + ARRAY_SIZE(test_effect_parameter_value_result_ ## x),\ +} + +static const struct +{ + const DWORD *blob; + UINT blob_size; + const struct test_effect_parameter_value_result *res; + UINT res_count; +} +test_effect_parameter_value_data[] = +{ + ADD_PARAMETER_VALUE(float), + ADD_PARAMETER_VALUE(int), + ADD_PARAMETER_VALUE(object), + ADD_PARAMETER_VALUE(special), +}; + +#undef ADD_PARAMETER_VALUE + +/* Multiple of 16 to cover complete matrices */ +#define EFFECT_PARAMETER_VALUE_ARRAY_SIZE 48 +/* Constants for special INT/FLOAT conversation */ +#define INT_FLOAT_MULTI 255.0f +#define INT_FLOAT_MULTI_INVERSE (1/INT_FLOAT_MULTI) + +static void test_effect_parameter_value_GetValue(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + DWORD value[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + HRESULT hr; + UINT l; + + memset(value, 0xab, sizeof(value)); + hr = effect->lpVtbl->GetValue(effect, parameter, value, res_desc->Bytes); + if (res_desc->Class == D3DXPC_SCALAR + || res_desc->Class == D3DXPC_VECTOR + || res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s: GetValue failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + + for (l = 0; l < res_desc->Bytes / sizeof(*value); ++l) + { + ok(value[l] == res_value[l], "%u - %s: GetValue value[%u] failed, got %#x, expected %#x\n", + i, res_full_name, l, value[l], res_value[l]); + } + + for (l = res_desc->Bytes / sizeof(*value); l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) + { + ok(value[l] == 0xabababab, "%u - %s: GetValue value[%u] failed, got %#x, expected %#x\n", + i, res_full_name, l, value[l], 0xabababab); + } + } + else if (res_desc->Class == D3DXPC_OBJECT) + { + switch (res_desc->Type) + { + case D3DXPT_PIXELSHADER: + case D3DXPT_VERTEXSHADER: + case D3DXPT_TEXTURE2D: + ok(hr == D3D_OK, "%u - %s: GetValue failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + + for (l = 0; l < (res_desc->Elements ? res_desc->Elements : 1); ++l) + { + IUnknown *unk = *((IUnknown **)value + l); + if (unk) IUnknown_Release(unk); + } + break; + + case D3DXPT_STRING: + ok(hr == D3D_OK, "%u - %s: GetValue failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + break; + + default: + ok(0, "Type is %u, this should not happen!\n", res_desc->Type); + break; + } + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetValue failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) + { + ok(value[l] == 0xabababab, "%u - %s: GetValue value[%u] failed, got %#x, expected %#x\n", + i, res_full_name, l, value[l], 0xabababab); + } + } +} + +static void test_effect_parameter_value_GetBool(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + BOOL bvalue = 0xabababab; + HRESULT hr; + + hr = effect->lpVtbl->GetBool(effect, parameter, &bvalue); + if (!res_desc->Elements && res_desc->Rows == 1 && res_desc->Columns == 1) + { + ok(hr == D3D_OK, "%u - %s: GetBool failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + ok(bvalue == get_bool(res_value), "%u - %s: GetBool bvalue failed, got %#x, expected %#x\n", + i, res_full_name, bvalue, get_bool(res_value)); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBool failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + ok(bvalue == 0xabababab, "%u - %s: GetBool bvalue failed, got %#x, expected %#x\n", + i, res_full_name, bvalue, 0xabababab); + } +} + +static void test_effect_parameter_value_GetBoolArray(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + BOOL bavalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + HRESULT hr; + UINT l, err = 0; + + memset(bavalue, 0xab, sizeof(bavalue)); + hr = effect->lpVtbl->GetBoolArray(effect, parameter, bavalue, res_desc->Bytes / sizeof(*bavalue)); + if (res_desc->Class == D3DXPC_SCALAR + || res_desc->Class == D3DXPC_VECTOR + || res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s: GetBoolArray failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + + for (l = 0; l < res_desc->Bytes / sizeof(*bavalue); ++l) + { + if (bavalue[l] != get_bool(&res_value[l])) ++err; + } + + for (l = res_desc->Bytes / sizeof(*bavalue); l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) + { + if (bavalue[l] != 0xabababab) ++err; + } + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBoolArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (bavalue[l] != 0xabababab) ++err; + } + ok(!err, "%u - %s: GetBoolArray failed with %u errors\n", i, res_full_name, err); +} + +static void test_effect_parameter_value_GetInt(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + INT ivalue = 0xabababab; + HRESULT hr; + + hr = effect->lpVtbl->GetInt(effect, parameter, &ivalue); + if (!res_desc->Elements && res_desc->Columns == 1 && res_desc->Rows == 1) + { + ok(hr == D3D_OK, "%u - %s: GetInt failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + ok(ivalue == get_int(res_desc->Type, res_value), "%u - %s: GetInt ivalue failed, got %i, expected %i\n", + i, res_full_name, ivalue, get_int(res_desc->Type, res_value)); + } + else if(!res_desc->Elements && res_desc->Type == D3DXPT_FLOAT && + ((res_desc->Class == D3DXPC_VECTOR && res_desc->Columns != 2) || + (res_desc->Class == D3DXPC_MATRIX_ROWS && res_desc->Rows != 2 && res_desc->Columns == 1))) + { + INT tmp; + + ok(hr == D3D_OK, "%u - %s: GetInt failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + + tmp = (INT)(min(max(0.0f, *((FLOAT *)res_value + 2)), 1.0f) * INT_FLOAT_MULTI); + tmp += ((INT)(min(max(0.0f, *((FLOAT *)res_value + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8; + tmp += ((INT)(min(max(0.0f, *((FLOAT *)res_value + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16; + if (res_desc->Columns * res_desc->Rows > 3) + { + tmp += ((INT)(min(max(0.0f, *((FLOAT *)res_value + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24; + } + + ok(ivalue == tmp, "%u - %s: GetInt ivalue failed, got %x, expected %x\n", + i, res_full_name, ivalue, tmp); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetInt failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + ok(ivalue == 0xabababab, "%u - %s: GetInt ivalue failed, got %i, expected %i\n", + i, res_full_name, ivalue, 0xabababab); + } +} + +static void test_effect_parameter_value_GetIntArray(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + INT iavalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + HRESULT hr; + UINT l, err = 0; + + memset(iavalue, 0xab, sizeof(iavalue)); + hr = effect->lpVtbl->GetIntArray(effect, parameter, iavalue, res_desc->Bytes / sizeof(*iavalue)); + if (res_desc->Class == D3DXPC_SCALAR + || res_desc->Class == D3DXPC_VECTOR + || res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s: GetIntArray failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + + for (l = 0; l < res_desc->Bytes / sizeof(*iavalue); ++l) + { + if (iavalue[l] != get_int(res_desc->Type, &res_value[l])) ++err; + } + + for (l = res_desc->Bytes / sizeof(*iavalue); l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) + { + if (iavalue[l] != 0xabababab) ++err; + } + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetIntArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (iavalue[l] != 0xabababab) ++err; + } + ok(!err, "%u - %s: GetIntArray failed with %u errors\n", i, res_full_name, err); +} + +static void test_effect_parameter_value_GetFloat(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + DWORD cmp = 0xabababab; + FLOAT fvalue = *(FLOAT *)&cmp; + + hr = effect->lpVtbl->GetFloat(effect, parameter, &fvalue); + if (!res_desc->Elements && res_desc->Columns == 1 && res_desc->Rows == 1) + { + ok(hr == D3D_OK, "%u - %s: GetFloat failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + ok(compare_float(fvalue, get_float(res_desc->Type, res_value), 512), "%u - %s: GetFloat fvalue failed, got %f, expected %f\n", + i, res_full_name, fvalue, get_float(res_desc->Type, res_value)); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloat failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + ok(fvalue == *(FLOAT *)&cmp, "%u - %s: GetFloat fvalue failed, got %f, expected %f\n", + i, res_full_name, fvalue, *(FLOAT *)&cmp); + } +} + +static void test_effect_parameter_value_GetFloatArray(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + FLOAT favalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + HRESULT hr; + UINT l, err = 0; + DWORD cmp = 0xabababab; + + memset(favalue, 0xab, sizeof(favalue)); + hr = effect->lpVtbl->GetFloatArray(effect, parameter, favalue, res_desc->Bytes / sizeof(*favalue)); + if (res_desc->Class == D3DXPC_SCALAR + || res_desc->Class == D3DXPC_VECTOR + || res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s: GetFloatArray failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + + for (l = 0; l < res_desc->Bytes / sizeof(*favalue); ++l) + { + if (!compare_float(favalue[l], get_float(res_desc->Type, &res_value[l]), 512)) ++err; + } + + for (l = res_desc->Bytes / sizeof(*favalue); l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) + { + if (favalue[l] != *(FLOAT *)&cmp) ++err; + } + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloatArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (favalue[l] != *(FLOAT *)&cmp) ++err; + } + ok(!err, "%u - %s: GetFloatArray failed with %u errors\n", i, res_full_name, err); +} + +static void test_effect_parameter_value_GetVector(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + DWORD cmp = 0xabababab; + FLOAT fvalue[4]; + UINT l, err = 0; + + memset(fvalue, 0xab, sizeof(fvalue)); + hr = effect->lpVtbl->GetVector(effect, parameter, (D3DXVECTOR4 *)&fvalue); + if (!res_desc->Elements && + (res_desc->Class == D3DXPC_SCALAR || res_desc->Class == D3DXPC_VECTOR) && + res_desc->Type == D3DXPT_INT && res_desc->Bytes == 4) + { + DWORD tmp; + + ok(hr == D3D_OK, "%u - %s: GetVector failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + + tmp = (DWORD)(*(fvalue + 2) * INT_FLOAT_MULTI); + tmp += ((DWORD)(*(fvalue + 1) * INT_FLOAT_MULTI)) << 8; + tmp += ((DWORD)(*fvalue * INT_FLOAT_MULTI)) << 16; + tmp += ((DWORD)(*(fvalue + 3) * INT_FLOAT_MULTI)) << 24; + + if (*res_value != tmp) ++err; + } + else if (!res_desc->Elements && (res_desc->Class == D3DXPC_SCALAR || res_desc->Class == D3DXPC_VECTOR)) + { + ok(hr == D3D_OK, "%u - %s: GetVector failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + + for (l = 0; l < res_desc->Columns; ++l) + { + if (!compare_float(fvalue[l], get_float(res_desc->Type, &res_value[l]), 512)) ++err; + } + + for (l = res_desc->Columns; l < 4; ++l) if (fvalue[l] != 0.0f) ++err; + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetVector failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < 4; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + ok(!err, "%u - %s: GetVector failed with %u errors\n", i, res_full_name, err); +} + +static void test_effect_parameter_value_GetVectorArray(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + DWORD cmp = 0xabababab; + FLOAT fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + UINT l, k, element, err = 0; + + for (element = 0; element <= res_desc->Elements + 1; ++element) + { + memset(fvalue, 0xab, sizeof(fvalue)); + hr = effect->lpVtbl->GetVectorArray(effect, parameter, (D3DXVECTOR4 *)&fvalue, element); + if (!element) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetVectorArray failed, got %#x, expected %#x\n", i, res_full_name, element, hr, D3D_OK); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else if (element <= res_desc->Elements && res_desc->Class == D3DXPC_VECTOR) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetVectorArray failed, got %#x, expected %#x\n", i, res_full_name, element, hr, D3D_OK); + + for (k = 0; k < element; ++k) + { + for (l = 0; l < res_desc->Columns; ++l) + { + if (!compare_float(fvalue[l + k * 4], get_float(res_desc->Type, + &res_value[l + k * res_desc->Columns]), 512)) + ++err; + } + + for (l = res_desc->Columns; l < 4; ++l) if (fvalue[l + k * 4] != 0.0f) ++err; + } + + for (l = element * 4; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s[%u]: GetVectorArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + ok(!err, "%u - %s[%u]: GetVectorArray failed with %u errors\n", i, res_full_name, element, err); + } +} + +static void test_effect_parameter_value_GetMatrix(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + union + { + DWORD d; + float f; + } cmp; + float fvalue[16]; + UINT l, k, err = 0; + + cmp.d = 0xabababab; + memset(fvalue, 0xab, sizeof(fvalue)); + hr = effect->lpVtbl->GetMatrix(effect, parameter, (D3DXMATRIX *)&fvalue); + if (!res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s: GetMatrix failed, got %#x, expected %#x.\n", i, res_full_name, hr, D3D_OK); + + for (k = 0; k < 4; ++k) + { + for (l = 0; l < 4; ++l) + { + if (k < res_desc->Columns && l < res_desc->Rows) + { + if (!compare_float(fvalue[l * 4 + k], get_float(res_desc->Type, + &res_value[l * res_desc->Columns + k]), 512)) + ++err; + } + else if (fvalue[l * 4 + k] != 0.0f) ++err; + } + } + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrix failed, got %#x, expected %#x.\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < ARRAY_SIZE(fvalue); ++l) + if (fvalue[l] != cmp.f) + ++err; + } + ok(!err, "%u - %s: GetMatrix failed with %u errors.\n", i, res_full_name, err); +} + +static void test_effect_parameter_value_GetMatrixArray(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + DWORD cmp = 0xabababab; + FLOAT fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + UINT l, k, m, element, err = 0; + + for (element = 0; element <= res_desc->Elements + 1; ++element) + { + memset(fvalue, 0xab, sizeof(fvalue)); + hr = effect->lpVtbl->GetMatrixArray(effect, parameter, (D3DXMATRIX *)&fvalue, element); + if (!element) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixArray failed, got %#x, expected %#x\n", i, res_full_name, element, hr, D3D_OK); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else if (element <= res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixArray failed, got %#x, expected %#x\n", i, res_full_name, element, hr, D3D_OK); + + for (m = 0; m < element; ++m) + { + for (k = 0; k < 4; ++k) + { + for (l = 0; l < 4; ++l) + { + if (k < res_desc->Columns && l < res_desc->Rows) + { + if (!compare_float(fvalue[m * 16 + l * 4 + k], get_float(res_desc->Type, + &res_value[m * res_desc->Columns * res_desc->Rows + l * res_desc->Columns + k]), 512)) + ++err; + } + else if (fvalue[m * 16 + l * 4 + k] != 0.0f) ++err; + } + } + } + + for (l = element * 16; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s[%u]: GetMatrixArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + ok(!err, "%u - %s[%u]: GetMatrixArray failed with %u errors\n", i, res_full_name, element, err); + } +} + +static void test_effect_parameter_value_GetMatrixPointerArray(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + DWORD cmp = 0xabababab; + FLOAT fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + D3DXMATRIX *matrix_pointer_array[sizeof(fvalue)/sizeof(D3DXMATRIX)]; + UINT l, k, m, element, err = 0; + + for (element = 0; element <= res_desc->Elements + 1; ++element) + { + memset(fvalue, 0xab, sizeof(fvalue)); + for (l = 0; l < element; ++l) + { + matrix_pointer_array[l] = (D3DXMATRIX *)&fvalue[l * sizeof(**matrix_pointer_array) / sizeof(FLOAT)]; + } + hr = effect->lpVtbl->GetMatrixPointerArray(effect, parameter, matrix_pointer_array, element); + if (!element) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3D_OK); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else if (element <= res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3D_OK); + + for (m = 0; m < element; ++m) + { + for (k = 0; k < 4; ++k) + { + for (l = 0; l < 4; ++l) + { + if (k < res_desc->Columns && l < res_desc->Rows) + { + if (!compare_float(fvalue[m * 16 + l * 4 + k], get_float(res_desc->Type, + &res_value[m * res_desc->Columns * res_desc->Rows + l * res_desc->Columns + k]), 512)) + ++err; + } + else if (fvalue[m * 16 + l * 4 + k] != 0.0f) ++err; + } + } + } + + for (l = element * 16; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else + { + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + + ok(hr == D3DERR_INVALIDCALL, "%u - %s[%u]: GetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3DERR_INVALIDCALL); + } + ok(!err, "%u - %s[%u]: GetMatrixPointerArray failed with %u errors\n", i, res_full_name, element, err); + } +} + +static void test_effect_parameter_value_GetMatrixTranspose(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + union + { + DWORD d; + float f; + } cmp; + float fvalue[16]; + UINT l, k, err = 0; + + cmp.d = 0xabababab; + memset(fvalue, 0xab, sizeof(fvalue)); + hr = effect->lpVtbl->GetMatrixTranspose(effect, parameter, (D3DXMATRIX *)&fvalue); + if (!res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x.\n", i, res_full_name, hr, D3D_OK); + + for (k = 0; k < 4; ++k) + { + for (l = 0; l < 4; ++l) + { + if (k < res_desc->Columns && l < res_desc->Rows) + { + if (!compare_float(fvalue[l + k * 4], get_float(res_desc->Type, + &res_value[l * res_desc->Columns + k]), 512)) + ++err; + } + else if (fvalue[l + k * 4] != 0.0f) ++err; + } + } + } + else if (!res_desc->Elements && (res_desc->Class == D3DXPC_VECTOR || res_desc->Class == D3DXPC_SCALAR)) + { + ok(hr == D3D_OK, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x.\n", i, res_full_name, hr, D3D_OK); + + for (k = 0; k < 4; ++k) + { + for (l = 0; l < 4; ++l) + { + if (k < res_desc->Columns && l < res_desc->Rows) + { + if (!compare_float(fvalue[l * 4 + k], get_float(res_desc->Type, + &res_value[l * res_desc->Columns + k]), 512)) + ++err; + } + else if (fvalue[l * 4 + k] != 0.0f) ++err; + } + } + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x.\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < ARRAY_SIZE(fvalue); ++l) + if (fvalue[l] != cmp.f) + ++err; + } + ok(!err, "%u - %s: GetMatrixTranspose failed with %u errors.\n", i, res_full_name, err); +} + +static void test_effect_parameter_value_GetMatrixTransposeArray(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + DWORD cmp = 0xabababab; + FLOAT fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + UINT l, k, m, element, err = 0; + + for (element = 0; element <= res_desc->Elements + 1; ++element) + { + memset(fvalue, 0xab, sizeof(fvalue)); + hr = effect->lpVtbl->GetMatrixTransposeArray(effect, parameter, (D3DXMATRIX *)&fvalue, element); + if (!element) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixTransposeArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3D_OK); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else if (element <= res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixTransposeArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3D_OK); + + for (m = 0; m < element; ++m) + { + for (k = 0; k < 4; ++k) + { + for (l = 0; l < 4; ++l) + { + if (k < res_desc->Columns && l < res_desc->Rows) + { + if (!compare_float(fvalue[m * 16 + l + k * 4], get_float(res_desc->Type, + &res_value[m * res_desc->Columns * res_desc->Rows + l * res_desc->Columns + k]), 512)) + ++err; + } + else if (fvalue[m * 16 + l + k * 4] != 0.0f) ++err; + } + } + } + + for (l = element * 16; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s[%u]: GetMatrixTransposeArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + ok(!err, "%u - %s[%u]: GetMatrixTransposeArray failed with %u errors\n", i, res_full_name, element, err); + } +} + +static void test_effect_parameter_value_GetMatrixTransposePointerArray(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + DWORD cmp = 0xabababab; + FLOAT fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + D3DXMATRIX *matrix_pointer_array[sizeof(fvalue)/sizeof(D3DXMATRIX)]; + UINT l, k, m, element, err = 0; + + for (element = 0; element <= res_desc->Elements + 1; ++element) + { + memset(fvalue, 0xab, sizeof(fvalue)); + for (l = 0; l < element; ++l) + { + matrix_pointer_array[l] = (D3DXMATRIX *)&fvalue[l * sizeof(**matrix_pointer_array) / sizeof(FLOAT)]; + } + hr = effect->lpVtbl->GetMatrixTransposePointerArray(effect, parameter, matrix_pointer_array, element); + if (!element) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3D_OK); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else if (element <= res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS) + { + ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3D_OK); + + for (m = 0; m < element; ++m) + { + for (k = 0; k < 4; ++k) + { + for (l = 0; l < 4; ++l) + { + if (k < res_desc->Columns && l < res_desc->Rows) + { + if (!compare_float(fvalue[m * 16 + l + k * 4], get_float(res_desc->Type, + &res_value[m * res_desc->Columns * res_desc->Rows + l * res_desc->Columns + k]), 512)) + ++err; + } + else if (fvalue[m * 16 + l + k * 4] != 0.0f) ++err; + } + } + } + + for (l = element * 16; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s[%u]: GetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, element, hr, D3DERR_INVALIDCALL); + + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; + } + ok(!err, "%u - %s[%u]: GetMatrixTransposePointerArray failed with %u errors\n", i, res_full_name, element, err); + } +} + +static void test_effect_parameter_value_GetTestGroup(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + test_effect_parameter_value_GetValue(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetBool(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetBoolArray(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetInt(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetIntArray(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetFloat(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetFloatArray(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetVector(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetVectorArray(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetMatrix(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetMatrixArray(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetMatrixPointerArray(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetMatrixTranspose(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetMatrixTransposeArray(res, effect, res_value, parameter, i); + test_effect_parameter_value_GetMatrixTransposePointerArray(res, effect, res_value, parameter, i); +} + +static void test_effect_parameter_value_ResetValue(const struct test_effect_parameter_value_result *res, + ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) +{ + const D3DXPARAMETER_DESC *res_desc = &res->desc; + const char *res_full_name = res->full_name; + HRESULT hr; + + if (res_desc->Class == D3DXPC_SCALAR + || res_desc->Class == D3DXPC_VECTOR + || res_desc->Class == D3DXPC_MATRIX_ROWS) + { + hr = effect->lpVtbl->SetValue(effect, parameter, res_value, res_desc->Bytes); + ok(hr == D3D_OK, "%u - %s: SetValue failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + /* nothing to do */ + switch (res_desc->Type) + { + case D3DXPT_PIXELSHADER: + case D3DXPT_VERTEXSHADER: + case D3DXPT_TEXTURE2D: + case D3DXPT_STRING: + break; + + default: + ok(0, "Type is %u, this should not happen!\n", res_desc->Type); + break; + } + } +} + +static void test_effect_parameter_value(IDirect3DDevice9 *device) +{ + unsigned int effect_count = ARRAY_SIZE(test_effect_parameter_value_data), i; + + for (i = 0; i < effect_count; ++i) + { + const struct test_effect_parameter_value_result *res = test_effect_parameter_value_data[i].res; + UINT res_count = test_effect_parameter_value_data[i].res_count; + const DWORD *blob = test_effect_parameter_value_data[i].blob; + UINT blob_size = test_effect_parameter_value_data[i].blob_size; + HRESULT hr; + ID3DXEffect *effect; + D3DXEFFECT_DESC edesc; + ULONG count; + UINT k; + + hr = D3DXCreateEffect(device, blob, blob_size, NULL, NULL, 0, NULL, &effect, NULL); + ok(hr == D3D_OK, "%u: D3DXCreateEffect failed, got %#x, expected %#x\n", i, hr, D3D_OK); + + hr = effect->lpVtbl->GetDesc(effect, &edesc); + ok(hr == D3D_OK, "%u: GetDesc failed, got %#x, expected %#x\n", i, hr, D3D_OK); + ok(edesc.Parameters == res_count, "%u: Parameters failed, got %u, expected %u\n", + i, edesc.Parameters, res_count); + + for (k = 0; k < res_count; ++k) + { + const D3DXPARAMETER_DESC *res_desc = &res[k].desc; + const char *res_full_name = res[k].full_name; + UINT res_value_offset = res[k].value_offset; + D3DXHANDLE parameter; + D3DXPARAMETER_DESC pdesc; + BOOL bvalue = TRUE; + INT ivalue = 42; + FLOAT fvalue = 2.71828f; + DWORD input_value[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + DWORD expected_value[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; + UINT l, n, m, element; + const D3DXMATRIX *matrix_pointer_array[sizeof(input_value)/sizeof(D3DXMATRIX)]; + + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, res_full_name); + ok(parameter != NULL, "%u - %s: GetParameterByName failed\n", i, res_full_name); + + hr = effect->lpVtbl->GetParameterDesc(effect, parameter, &pdesc); + ok(hr == D3D_OK, "%u - %s: GetParameterDesc failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + + ok(res_desc->Name ? !strcmp(pdesc.Name, res_desc->Name) : !pdesc.Name, + "%u - %s: GetParameterDesc Name failed, got \"%s\", expected \"%s\"\n", + i, res_full_name, pdesc.Name, res_desc->Name); + ok(res_desc->Semantic ? !strcmp(pdesc.Semantic, res_desc->Semantic) : !pdesc.Semantic, + "%u - %s: GetParameterDesc Semantic failed, got \"%s\", expected \"%s\"\n", + i, res_full_name, pdesc.Semantic, res_desc->Semantic); + ok(res_desc->Class == pdesc.Class, "%u - %s: GetParameterDesc Class failed, got %#x, expected %#x\n", + i, res_full_name, pdesc.Class, res_desc->Class); + ok(res_desc->Type == pdesc.Type, "%u - %s: GetParameterDesc Type failed, got %#x, expected %#x\n", + i, res_full_name, pdesc.Type, res_desc->Type); + ok(res_desc->Rows == pdesc.Rows, "%u - %s: GetParameterDesc Rows failed, got %u, expected %u\n", + i, res_full_name, pdesc.Rows, res_desc->Rows); + ok(res_desc->Columns == pdesc.Columns, "%u - %s: GetParameterDesc Columns failed, got %u, expected %u\n", + i, res_full_name, pdesc.Columns, res_desc->Columns); + ok(res_desc->Elements == pdesc.Elements, "%u - %s: GetParameterDesc Elements failed, got %u, expected %u\n", + i, res_full_name, pdesc.Elements, res_desc->Elements); + ok(res_desc->Annotations == pdesc.Annotations, "%u - %s: GetParameterDesc Annotations failed, got %u, expected %u\n", + i, res_full_name, pdesc.Annotations, res_desc->Annotations); + ok(res_desc->StructMembers == pdesc.StructMembers, "%u - %s: GetParameterDesc StructMembers failed, got %u, expected %u\n", + i, res_full_name, pdesc.StructMembers, res_desc->StructMembers); + ok(res_desc->Flags == pdesc.Flags, "%u - %s: GetParameterDesc Flags failed, got %u, expected %u\n", + i, res_full_name, pdesc.Flags, res_desc->Flags); + ok(res_desc->Bytes == pdesc.Bytes, "%u - %s: GetParameterDesc Bytes, got %u, expected %u\n", + i, res_full_name, pdesc.Bytes, res_desc->Bytes); + + /* check size */ + ok(EFFECT_PARAMETER_VALUE_ARRAY_SIZE >= res_desc->Bytes / 4 + + (res_desc->Elements ? res_desc->Bytes / 4 / res_desc->Elements : 0), + "%u - %s: Warning: Array size too small\n", i, res_full_name); + + test_effect_parameter_value_GetTestGroup(&res[k], effect, &blob[res_value_offset], parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + test_effect_parameter_value_GetTestGroup(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* + * check invalid calls + * These will crash: + * effect->lpVtbl->SetBoolArray(effect, parameter, NULL, res_desc->Bytes / sizeof(BOOL)); + * effect->lpVtbl->SetIntArray(effect, parameter, NULL, res_desc->Bytes / sizeof(INT)); + * effect->lpVtbl->SetFloatArray(effect, parameter, NULL, res_desc->Bytes / sizeof(FLOAT)); + * effect->lpVtbl->SetVector(effect, parameter, NULL); + * effect->lpVtbl->SetVectorArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + * effect->lpVtbl->SetMatrix(effect, parameter, NULL); + * effect->lpVtbl->GetMatrix(effect, parameter, NULL); + * effect->lpVtbl->SetMatrixArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + * effect->lpVtbl->SetMatrixPointerArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + * effect->lpVtbl->SetMatrixTranspose(effect, parameter, NULL); + * effect->lpVtbl->SetMatrixTransposeArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + * effect->lpVtbl->SetMatrixTransposePointerArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + * effect->lpVtbl->GetValue(effect, parameter, NULL, res_desc->Bytes); + * effect->lpVtbl->SetValue(effect, parameter, NULL, res_desc->Bytes); + */ + hr = effect->lpVtbl->SetBool(effect, NULL, bvalue); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetBool failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetBool(effect, NULL, &bvalue); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBool failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetBool(effect, parameter, NULL); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBool failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetBoolArray(effect, NULL, (BOOL *)input_value, res_desc->Bytes / sizeof(BOOL)); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetBoolArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetBoolArray(effect, NULL, (BOOL *)input_value, res_desc->Bytes / sizeof(BOOL)); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBoolArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetBoolArray(effect, parameter, NULL, res_desc->Bytes / sizeof(BOOL)); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBoolArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetInt(effect, NULL, ivalue); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetInt failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetInt(effect, NULL, &ivalue); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetInt failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetInt(effect, parameter, NULL); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetInt failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetIntArray(effect, NULL, (INT *)input_value, res_desc->Bytes / sizeof(INT)); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetIntArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetIntArray(effect, NULL, (INT *)input_value, res_desc->Bytes / sizeof(INT)); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetIntArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetIntArray(effect, parameter, NULL, res_desc->Bytes / sizeof(INT)); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetIntArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetFloat(effect, NULL, fvalue); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetFloat failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetFloat(effect, NULL, &fvalue); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloat failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetFloat(effect, parameter, NULL); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloat failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetFloatArray(effect, NULL, (FLOAT *)input_value, res_desc->Bytes / sizeof(FLOAT)); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetFloatArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetFloatArray(effect, NULL, (FLOAT *)input_value, res_desc->Bytes / sizeof(FLOAT)); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloatArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetFloatArray(effect, parameter, NULL, res_desc->Bytes / sizeof(FLOAT)); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloatArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetVector(effect, NULL, (D3DXVECTOR4 *)input_value); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetVector failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetVector(effect, NULL, (D3DXVECTOR4 *)input_value); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetVector failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetVector(effect, parameter, NULL); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetVector failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetVectorArray(effect, NULL, (D3DXVECTOR4 *)input_value, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetVectorArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetVectorArray(effect, NULL, (D3DXVECTOR4 *)input_value, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetVectorArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetVectorArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetVectorArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetMatrix(effect, NULL, (D3DXMATRIX *)input_value); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrix failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrix(effect, NULL, (D3DXMATRIX *)input_value); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrix failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetMatrixArray(effect, NULL, (D3DXMATRIX *)input_value, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixArray(effect, NULL, (D3DXMATRIX *)input_value, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetMatrixPointerArray(effect, NULL, matrix_pointer_array, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetMatrixPointerArray(effect, NULL, matrix_pointer_array, 0); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixPointerArray(effect, NULL, NULL, 0); + ok(hr == D3D_OK, "%u - %s: GetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3D_OK); + + hr = effect->lpVtbl->GetMatrixPointerArray(effect, NULL, NULL, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixPointerArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetMatrixTranspose(effect, NULL, (D3DXMATRIX *)input_value); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixTranspose failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixTranspose(effect, NULL, (D3DXMATRIX *)input_value); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixTranspose(effect, parameter, NULL); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetMatrixTransposeArray(effect, NULL, (D3DXMATRIX *)input_value, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixTransposeArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixTransposeArray(effect, NULL, (D3DXMATRIX *)input_value, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixTransposeArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixTransposeArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixTransposeArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetMatrixTransposePointerArray(effect, NULL, matrix_pointer_array, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetMatrixTransposePointerArray(effect, NULL, matrix_pointer_array, 0); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixTransposePointerArray(effect, NULL, NULL, 0); + ok(hr == D3D_OK, "%u - %s: GetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3D_OK); + + hr = effect->lpVtbl->GetMatrixTransposePointerArray(effect, NULL, NULL, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetMatrixTransposePointerArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetValue(effect, NULL, input_value, res_desc->Bytes); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetValue failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->SetValue(effect, parameter, input_value, res_desc->Bytes - 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetValue failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetValue(effect, NULL, input_value, res_desc->Bytes); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetValue failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + hr = effect->lpVtbl->GetValue(effect, parameter, input_value, res_desc->Bytes - 1); + ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetValue failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + + test_effect_parameter_value_GetTestGroup(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetBool */ + bvalue = 5; + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetBool(effect, parameter, bvalue); + if (!res_desc->Elements && res_desc->Rows == 1 && res_desc->Columns == 1) + { + bvalue = TRUE; + set_number(expected_value, res_desc->Type, &bvalue, D3DXPT_BOOL); + ok(hr == D3D_OK, "%u - %s: SetBool failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetBool failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetBoolArray */ + *input_value = 1; + for (l = 1; l < res_desc->Bytes / sizeof(*input_value); ++l) + { + *(input_value + l) = *(input_value + l - 1) + 1; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetBoolArray(effect, parameter, (BOOL *)input_value, res_desc->Bytes / sizeof(*input_value)); + if (res_desc->Class == D3DXPC_SCALAR + || res_desc->Class == D3DXPC_VECTOR + || res_desc->Class == D3DXPC_MATRIX_ROWS) + { + for (l = 0; l < res_desc->Bytes / sizeof(*input_value); ++l) + { + set_number(expected_value + l, res_desc->Type, input_value + l, D3DXPT_BOOL); + } + ok(hr == D3D_OK, "%u - %s: SetBoolArray failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetBoolArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetInt */ + ivalue = 0x1fbf02ff; + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetInt(effect, parameter, ivalue); + if (!res_desc->Elements && res_desc->Rows == 1 && res_desc->Columns == 1) + { + set_number(expected_value, res_desc->Type, &ivalue, D3DXPT_INT); + ok(hr == D3D_OK, "%u - %s: SetInt failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else if(!res_desc->Elements && res_desc->Type == D3DXPT_FLOAT && + ((res_desc->Class == D3DXPC_VECTOR && res_desc->Columns != 2) || + (res_desc->Class == D3DXPC_MATRIX_ROWS && res_desc->Rows != 2 && res_desc->Columns == 1))) + { + FLOAT tmp = ((ivalue & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE; + set_number(expected_value, res_desc->Type, &tmp, D3DXPT_FLOAT); + tmp = ((ivalue & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE; + set_number(expected_value + 1, res_desc->Type, &tmp, D3DXPT_FLOAT); + tmp = (ivalue & 0xff) * INT_FLOAT_MULTI_INVERSE; + set_number(expected_value + 2, res_desc->Type, &tmp, D3DXPT_FLOAT); + tmp = ((ivalue & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE; + set_number(expected_value + 3, res_desc->Type, &tmp, D3DXPT_FLOAT); + + ok(hr == D3D_OK, "%u - %s: SetInt failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetInt failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetIntArray */ + *input_value = 123456; + for (l = 0; l < res_desc->Bytes / sizeof(*input_value); ++l) + { + *(input_value + l) = *(input_value + l - 1) + 23; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetIntArray(effect, parameter, (INT *)input_value, res_desc->Bytes / sizeof(*input_value)); + if (res_desc->Class == D3DXPC_SCALAR + || res_desc->Class == D3DXPC_VECTOR + || res_desc->Class == D3DXPC_MATRIX_ROWS) + { + for (l = 0; l < res_desc->Bytes / sizeof(*input_value); ++l) + { + set_number(expected_value + l, res_desc->Type, input_value + l, D3DXPT_INT); + } + ok(hr == D3D_OK, "%u - %s: SetIntArray failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetIntArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetFloat */ + fvalue = 1.33; + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetFloat(effect, parameter, fvalue); + if (!res_desc->Elements && res_desc->Rows == 1 && res_desc->Columns == 1) + { + set_number(expected_value, res_desc->Type, &fvalue, D3DXPT_FLOAT); + ok(hr == D3D_OK, "%u - %s: SetFloat failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetFloat failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetFloatArray */ + fvalue = 1.33; + for (l = 0; l < res_desc->Bytes / sizeof(fvalue); ++l) + { + *(input_value + l) = *(DWORD *)&fvalue; + fvalue += 1.12; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetFloatArray(effect, parameter, (FLOAT *)input_value, res_desc->Bytes / sizeof(*input_value)); + if (res_desc->Class == D3DXPC_SCALAR + || res_desc->Class == D3DXPC_VECTOR + || res_desc->Class == D3DXPC_MATRIX_ROWS) + { + for (l = 0; l < res_desc->Bytes / sizeof(*input_value); ++l) + { + set_number(expected_value + l, res_desc->Type, input_value + l, D3DXPT_FLOAT); + } + ok(hr == D3D_OK, "%u - %s: SetFloatArray failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetFloatArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetVector */ + fvalue = -1.33; + for (l = 0; l < 4; ++l) + { + *(input_value + l) = *(DWORD *)&fvalue; + fvalue += 1.12; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetVector(effect, parameter, (D3DXVECTOR4 *)input_value); + if (!res_desc->Elements && + (res_desc->Class == D3DXPC_SCALAR + || res_desc->Class == D3DXPC_VECTOR)) + { + /* only values between 0 and INT_FLOAT_MULTI are valid */ + if (res_desc->Type == D3DXPT_INT && res_desc->Bytes == 4) + { + *expected_value = (DWORD)(max(min(*(FLOAT *)(input_value + 2), 1.0f), 0.0f) * INT_FLOAT_MULTI); + *expected_value += ((DWORD)(max(min(*(FLOAT *)(input_value + 1), 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 8; + *expected_value += ((DWORD)(max(min(*(FLOAT *)input_value, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 16; + *expected_value += ((DWORD)(max(min(*(FLOAT *)(input_value + 3), 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 24; + } + else + { + for (l = 0; l < 4; ++l) + { + set_number(expected_value + l, res_desc->Type, input_value + l, D3DXPT_FLOAT); + } + } + ok(hr == D3D_OK, "%u - %s: SetVector failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetVector failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetVectorArray */ + for (element = 0; element < res_desc->Elements + 1; ++element) + { + fvalue = 1.33; + for (l = 0; l < element * 4; ++l) + { + *(input_value + l) = *(DWORD *)&fvalue; + fvalue += 1.12; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetVectorArray(effect, parameter, (D3DXVECTOR4 *)input_value, element); + if (res_desc->Elements && res_desc->Class == D3DXPC_VECTOR && element <= res_desc->Elements) + { + for (m = 0; m < element; ++m) + { + for (l = 0; l < res_desc->Columns; ++l) + { + set_number(expected_value + m * res_desc->Columns + l, res_desc->Type, input_value + m * 4 + l, D3DXPT_FLOAT); + } + } + ok(hr == D3D_OK, "%u - %s: SetVectorArray failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetVectorArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + } + + /* SetMatrix */ + fvalue = 1.33; + for (l = 0; l < 16; ++l) + { + *(input_value + l) = *(DWORD *)&fvalue; + fvalue += 1.12; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetMatrix(effect, parameter, (D3DXMATRIX *)input_value); + if (!res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS) + { + for (l = 0; l < 4; ++l) + { + for (m = 0; m < 4; ++m) + { + if (m < res_desc->Rows && l < res_desc->Columns) + set_number(expected_value + l + m * res_desc->Columns, res_desc->Type, + input_value + l + m * 4, D3DXPT_FLOAT); + } + + } + ok(hr == D3D_OK, "%u - %s: SetMatrix failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrix failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetMatrixArray */ + for (element = 0; element < res_desc->Elements + 1; ++element) + { + fvalue = 1.33; + for (l = 0; l < element * 16; ++l) + { + *(input_value + l) = *(DWORD *)&fvalue; + fvalue += 1.12; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetMatrixArray(effect, parameter, (D3DXMATRIX *)input_value, element); + if (res_desc->Class == D3DXPC_MATRIX_ROWS && element <= res_desc->Elements) + { + for (n = 0; n < element; ++n) + { + for (l = 0; l < 4; ++l) + { + for (m = 0; m < 4; ++m) + { + if (m < res_desc->Rows && l < res_desc->Columns) + set_number(expected_value + l + m * res_desc->Columns + n * res_desc->Columns * res_desc->Rows, + res_desc->Type, input_value + l + m * 4 + n * 16, D3DXPT_FLOAT); + } + + } + } + ok(hr == D3D_OK, "%u - %s: SetMatrixArray failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + } + + /* SetMatrixPointerArray */ + for (element = 0; element < res_desc->Elements + 1; ++element) + { + fvalue = 1.33; + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) + { + *(input_value + l) = *(DWORD *)&fvalue; + fvalue += 1.12; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + for (l = 0; l < element; ++l) + { + matrix_pointer_array[l] = (D3DXMATRIX *)&input_value[l * sizeof(**matrix_pointer_array) / sizeof(FLOAT)]; + } + hr = effect->lpVtbl->SetMatrixPointerArray(effect, parameter, matrix_pointer_array, element); + if (res_desc->Class == D3DXPC_MATRIX_ROWS && res_desc->Elements >= element) + { + for (n = 0; n < element; ++n) + { + for (l = 0; l < 4; ++l) + { + for (m = 0; m < 4; ++m) + { + if (m < res_desc->Rows && l < res_desc->Columns) + set_number(expected_value + l + m * res_desc->Columns + n * res_desc->Columns * res_desc->Rows, + res_desc->Type, input_value + l + m * 4 + n * 16, D3DXPT_FLOAT); + } + + } + } + ok(hr == D3D_OK, "%u - %s: SetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixPointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + } + + /* SetMatrixTranspose */ + fvalue = 1.33; + for (l = 0; l < 16; ++l) + { + *(input_value + l) = *(DWORD *)&fvalue; + fvalue += 1.12; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetMatrixTranspose(effect, parameter, (D3DXMATRIX *)input_value); + if (!res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS) + { + for (l = 0; l < 4; ++l) + { + for (m = 0; m < 4; ++m) + { + if (m < res_desc->Rows && l < res_desc->Columns) + set_number(expected_value + l + m * res_desc->Columns, res_desc->Type, + input_value + l * 4 + m, D3DXPT_FLOAT); + } + + } + ok(hr == D3D_OK, "%u - %s: SetMatrixTranspose failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixTranspose failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + + /* SetMatrixTransposeArray */ + for (element = 0; element < res_desc->Elements + 1; ++element) + { + fvalue = 1.33; + for (l = 0; l < element * 16; ++l) + { + *(input_value + l) = *(DWORD *)&fvalue; + fvalue += 1.12; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + hr = effect->lpVtbl->SetMatrixTransposeArray(effect, parameter, (D3DXMATRIX *)input_value, element); + if (res_desc->Class == D3DXPC_MATRIX_ROWS && element <= res_desc->Elements) + { + for (n = 0; n < element; ++n) + { + for (l = 0; l < 4; ++l) + { + for (m = 0; m < 4; ++m) + { + if (m < res_desc->Rows && l < res_desc->Columns) + set_number(expected_value + l + m * res_desc->Columns + n * res_desc->Columns * res_desc->Rows, + res_desc->Type, input_value + l * 4 + m + n * 16, D3DXPT_FLOAT); + } + + } + } + ok(hr == D3D_OK, "%u - %s: SetMatrixTransposeArray failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixTransposeArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + } + + /* SetMatrixTransposePointerArray */ + for (element = 0; element < res_desc->Elements + 1; ++element) + { + fvalue = 1.33; + for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) + { + *(input_value + l) = *(DWORD *)&fvalue; + fvalue += 1.12; + } + memcpy(expected_value, &blob[res_value_offset], res_desc->Bytes); + for (l = 0; l < element; ++l) + { + matrix_pointer_array[l] = (D3DXMATRIX *)&input_value[l * sizeof(**matrix_pointer_array) / sizeof(FLOAT)]; + } + hr = effect->lpVtbl->SetMatrixTransposePointerArray(effect, parameter, matrix_pointer_array, element); + if (res_desc->Class == D3DXPC_MATRIX_ROWS && res_desc->Elements >= element) + { + for (n = 0; n < element; ++n) + { + for (l = 0; l < 4; ++l) + { + for (m = 0; m < 4; ++m) + { + if (m < res_desc->Rows && l < res_desc->Columns) + set_number(expected_value + l + m * res_desc->Columns + n * res_desc->Columns * res_desc->Rows, + res_desc->Type, input_value + l * 4 + m + n * 16, D3DXPT_FLOAT); + } + + } + } + ok(hr == D3D_OK, "%u - %s: SetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3D_OK); + } + else + { + ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixTransposePointerArray failed, got %#x, expected %#x\n", + i, res_full_name, hr, D3DERR_INVALIDCALL); + } + test_effect_parameter_value_GetTestGroup(&res[k], effect, expected_value, parameter, i); + test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i); + } + } + + count = effect->lpVtbl->Release(effect); + ok(!count, "Release failed %u\n", count); + } +} + +static void test_effect_setvalue_object(IDirect3DDevice9 *device) +{ + static const char expected_string[] = "test_string_1"; + static const char expected_string2[] = "test_longer_string_2"; + static const char *expected_string_array[] = {expected_string, expected_string2}; + const char *string_array[ARRAY_SIZE(expected_string_array)]; + const char *string, *string2; + IDirect3DTexture9 *texture_set; + IDirect3DTexture9 *texture; + D3DXHANDLE parameter; + ID3DXEffect *effect; + unsigned int i; + ULONG count; + HRESULT hr; + + hr = D3DXCreateEffect(device, test_effect_parameter_value_blob_object, + sizeof(test_effect_parameter_value_blob_object), NULL, NULL, 0, NULL, &effect, NULL); + ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); + + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "tex"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + texture = NULL; + hr = D3DXCreateTexture(device, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, 0, D3DPOOL_DEFAULT, &texture); + ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); + hr = effect->lpVtbl->SetValue(effect, parameter, &texture, sizeof(texture)); + ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); + texture_set = NULL; + hr = effect->lpVtbl->GetValue(effect, parameter, &texture_set, sizeof(texture_set)); + ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); + ok(texture == texture_set, "Texture does not match.\n"); + + count = IDirect3DTexture9_Release(texture_set); + ok(count == 2, "Got reference count %u, expected 2.\n", count); + texture_set = NULL; + hr = effect->lpVtbl->SetValue(effect, parameter, &texture_set, sizeof(texture_set)); + ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); + count = IDirect3DTexture9_Release(texture); + ok(!count, "Got reference count %u, expected 0.\n", count); + + hr = effect->lpVtbl->SetString(effect, "s", expected_string); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + string = NULL; + hr = effect->lpVtbl->GetString(effect, "s", &string); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + hr = effect->lpVtbl->GetString(effect, "s", &string2); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + ok(string != expected_string, "String pointers are the same.\n"); + ok(string == string2, "String pointers differ.\n"); + ok(!strcmp(string, expected_string), "Unexpected string '%s'.\n", string); + + string = expected_string2; + hr = effect->lpVtbl->SetValue(effect, "s", &string, sizeof(string) - 1); + ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr); + hr = effect->lpVtbl->SetValue(effect, "s", &string, sizeof(string)); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + hr = effect->lpVtbl->SetValue(effect, "s", &string, sizeof(string) * 2); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + string = NULL; + hr = effect->lpVtbl->GetValue(effect, "s", &string, sizeof(string)); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + ok(string != expected_string2, "String pointers are the same.\n"); + ok(!strcmp(string, expected_string2), "Unexpected string '%s'.\n", string); + + hr = effect->lpVtbl->SetValue(effect, "s_2", expected_string_array, + sizeof(expected_string_array)); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + hr = effect->lpVtbl->GetValue(effect, "s_2", string_array, + sizeof(string_array)); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + for (i = 0; i < ARRAY_SIZE(expected_string_array); ++i) + { + ok(!strcmp(string_array[i], expected_string_array[i]), "Unexpected string '%s', i %u.\n", + string_array[i], i); + } + effect->lpVtbl->Release(effect); +} + +/* + * fxc.exe /Tfx_2_0 + */ +#if 0 +float a = 2.1; +float b[1]; +float c <float d = 3;>; +struct {float e;} f; +float g <float h[1] = {3};>; +struct s {float j;}; +float i <s k[1] = {4};>; +technique t <s l[1] = {5};> { pass p <s m[1] = {6};> { } } +#endif +static const DWORD test_effect_variable_names_blob[] = +{ +0xfeff0901, 0x0000024c, 0x00000000, 0x00000003, 0x00000000, 0x00000024, 0x00000000, 0x00000000, +0x00000001, 0x00000001, 0x40066666, 0x00000002, 0x00000061, 0x00000003, 0x00000000, 0x0000004c, +0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000002, 0x00000062, 0x00000003, +0x00000000, 0x0000009c, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x40400000, +0x00000003, 0x00000000, 0x00000094, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000002, +0x00000064, 0x00000002, 0x00000063, 0x00000000, 0x00000005, 0x000000dc, 0x00000000, 0x00000000, +0x00000001, 0x00000003, 0x00000000, 0x000000e4, 0x00000000, 0x00000000, 0x00000001, 0x00000001, +0x00000000, 0x00000002, 0x00000066, 0x00000002, 0x00000065, 0x00000003, 0x00000000, 0x00000134, +0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x40400000, 0x00000003, 0x00000000, +0x0000012c, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000002, 0x00000068, 0x00000002, +0x00000067, 0x00000003, 0x00000000, 0x000001a4, 0x00000000, 0x00000000, 0x00000001, 0x00000001, +0x00000000, 0x40800000, 0x00000000, 0x00000005, 0x00000194, 0x00000000, 0x00000001, 0x00000001, +0x00000003, 0x00000000, 0x0000019c, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000002, +0x0000006b, 0x00000002, 0x0000006a, 0x00000002, 0x00000069, 0x40a00000, 0x00000000, 0x00000005, +0x000001e4, 0x00000000, 0x00000001, 0x00000001, 0x00000003, 0x00000000, 0x000001ec, 0x00000000, +0x00000000, 0x00000001, 0x00000001, 0x00000002, 0x0000006c, 0x00000002, 0x0000006a, 0x40c00000, +0x00000000, 0x00000005, 0x0000022c, 0x00000000, 0x00000001, 0x00000001, 0x00000003, 0x00000000, +0x00000234, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000002, 0x0000006d, 0x00000002, +0x0000006a, 0x00000002, 0x00000070, 0x00000002, 0x00000074, 0x00000006, 0x00000001, 0x00000001, +0x00000001, 0x00000004, 0x00000020, 0x00000000, 0x00000000, 0x0000002c, 0x00000048, 0x00000000, +0x00000000, 0x00000054, 0x00000070, 0x00000000, 0x00000001, 0x00000078, 0x00000074, 0x000000a4, +0x000000d8, 0x00000000, 0x00000000, 0x000000ec, 0x00000108, 0x00000000, 0x00000001, 0x00000110, +0x0000010c, 0x0000013c, 0x00000158, 0x00000000, 0x00000001, 0x00000160, 0x0000015c, 0x00000244, +0x00000001, 0x00000001, 0x000001b0, 0x000001ac, 0x0000023c, 0x00000001, 0x00000000, 0x000001f8, +0x000001f4, 0x00000000, 0x00000000, +}; + +static void test_effect_variable_names(IDirect3DDevice9 *device) +{ + ID3DXEffect *effect; + ULONG count; + HRESULT hr; + D3DXHANDLE parameter, p; + + hr = D3DXCreateEffect(device, test_effect_variable_names_blob, + sizeof(test_effect_variable_names_blob), NULL, NULL, 0, NULL, &effect, NULL); + ok(hr == D3D_OK, "D3DXCreateEffect failed, got %#x, expected %#x\n", hr, D3D_OK); + + /* + * check invalid calls + * This will crash: + * effect->lpVtbl->GetAnnotationByName(effect, "invalid1", "invalid2"); + */ + p = effect->lpVtbl->GetParameterByName(effect, NULL, NULL); + ok(p == NULL, "GetParameterByName failed, got %p, expected %p\n", p, NULL); + + p = effect->lpVtbl->GetParameterByName(effect, NULL, "invalid1"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "invalid1", NULL); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "invalid1", "invalid2"); + ok(p == NULL, "GetParameterByName failed, got %p, expected %p\n", p, NULL); + + /* float a; */ + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "a"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "a", NULL); + ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter); + + /* members */ + p = effect->lpVtbl->GetParameterByName(effect, NULL, "a."); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a.", NULL); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a", "."); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, NULL, "a.invalid"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a.invalid", NULL); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a", ".invalid"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a.", "invalid"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a", "invalid"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + /* elements */ + p = effect->lpVtbl->GetParameterByName(effect, NULL, "a[]"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a[]", NULL); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, NULL, "a[0]"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a[0]", NULL); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a", "[0]"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterElement(effect, "a", 0); + ok(p == NULL, "GetParameterElement failed, got %p\n", p); + + /* annotations */ + p = effect->lpVtbl->GetParameterByName(effect, NULL, "a@"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a@", NULL); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a", "@invalid"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a@", "invalid"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, NULL, "a@invalid"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "a@invalid", NULL); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetAnnotationByName(effect, "a", NULL); + ok(p == NULL, "GetAnnotationByName failed, got %p\n", p); + + p = effect->lpVtbl->GetAnnotationByName(effect, "a", "invalid"); + ok(p == NULL, "GetAnnotationByName failed, got %p\n", p); + + p = effect->lpVtbl->GetAnnotation(effect, "a", 0); + ok(p == NULL, "GetAnnotation failed, got %p\n", p); + + /* float b[1]; */ + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "b"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "b", NULL); + ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter); + + /* elements */ + p = effect->lpVtbl->GetParameterByName(effect, NULL, "b[]"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "b[0]"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "b[0]", NULL); + ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetParameterElement(effect, "b", 0); + ok(parameter == p, "GetParameterElement failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "b", "[0]"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, NULL, "b[1]"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterElement(effect, "b", 1); + ok(p == NULL, "GetParameterElement failed, got %p\n", p); + + /* float c <float d = 3;>; */ + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "c"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "c", NULL); + ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter); + + /* annotations */ + p = effect->lpVtbl->GetParameterByName(effect, "c", "@d"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "c@", "d"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, NULL, "c@invalid"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "c@invalid", NULL); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetAnnotationByName(effect, "c", NULL); + ok(p == NULL, "GetAnnotationByName failed, got %p\n", p); + + p = effect->lpVtbl->GetAnnotationByName(effect, "c", "invalid"); + ok(p == NULL, "GetAnnotationByName failed, got %p\n", p); + + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "c@d"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "c@d", NULL); + ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetAnnotationByName(effect, "c", "d"); + ok(parameter == p, "GetAnnotationByName failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetAnnotation(effect, "c", 0); + ok(parameter == p, "GetAnnotation failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetAnnotation(effect, "c", 1); + ok(p == NULL, "GetAnnotation failed, got %p\n", p); + + /* struct {float e;} f; */ + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "f"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "f", NULL); + ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter); + + /* members */ + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "f.e"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "f.e", NULL); + ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "f", "e"); + ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetParameterByName(effect, "f", ".e"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "f.", "e"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, "f.invalid", NULL); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + p = effect->lpVtbl->GetParameterByName(effect, NULL, "f.invalid"); + ok(p == NULL, "GetParameterByName failed, got %p\n", p); + + /* float g <float h[1] = {3};>; */ + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "g@h[0]"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + p = effect->lpVtbl->GetAnnotationByName(effect, "g", "h[0]"); + ok(parameter == p, "GetAnnotationByName failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetParameterElement(effect, "g@h", 0); + ok(parameter == p, "GetParameterElement failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetParameterElement(effect, effect->lpVtbl->GetAnnotation(effect, "g", 0), 0); + ok(parameter == p, "GetParameterElement failed, got %p, expected %p\n", p, parameter); + + /* struct s {float j;}; float i <s k[1] = {4};>; */ + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "i(a)k[0].j"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + p = effect->lpVtbl->GetAnnotationByName(effect, "i", "k[0].j"); + ok(parameter == p, "GetAnnotationByName failed, got %p, expected %p\n", p, parameter); + + p = effect->lpVtbl->GetParameterByName(effect, effect->lpVtbl->GetParameterElement(effect, "i@k", 0), "j"); + ok(parameter == p, "GetParameterElement failed, got %p, expected %p\n", p, parameter); + + /* technique t <s l[1] = {5};> */ + parameter = effect->lpVtbl->GetAnnotationByName(effect, "t", "l[0].j"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + /* pass p <s m[1] = {6};> */ + parameter = effect->lpVtbl->GetAnnotationByName(effect, effect->lpVtbl->GetPassByName(effect, "t", "p"), "m[0].j"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + count = effect->lpVtbl->Release(effect); + ok(!count, "Release failed %u\n", count); +} + +static void test_effect_compilation_errors(IDirect3DDevice9 *device) +{ + ID3DXEffect *effect; + ID3DXBuffer *compilation_errors; + HRESULT hr; + + /* Test binary effect */ + compilation_errors = (ID3DXBuffer*)0xdeadbeef; + hr = D3DXCreateEffect(NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, &compilation_errors); + ok(hr == D3DERR_INVALIDCALL, "D3DXCreateEffect failed, got %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + ok(!compilation_errors, "Returned %p\n", compilation_errors); + + compilation_errors = (ID3DXBuffer*)0xdeadbeef; + hr = D3DXCreateEffect(device, test_effect_variable_names_blob, + sizeof(test_effect_variable_names_blob), NULL, NULL, 0, NULL, &effect, &compilation_errors); + ok(hr == D3D_OK, "D3DXCreateEffect failed, got %#x, expected %#x\n", hr, D3D_OK); + ok(!compilation_errors, "Returned %p\n", compilation_errors); + effect->lpVtbl->Release(effect); +} + +/* + * fxc.exe /Tfx_2_0 + */ +#if 0 +vertexshader vs_arr1[2] = +{ + asm + { + vs_1_1 + def c0, 1, 1, 1, 1 + mov oPos, c0 + }, + asm + { + vs_2_0 + def c0, 2, 2, 2, 2 + mov oPos, c0 + } +}; + +sampler sampler1 = + sampler_state + { + MipFilter = LINEAR; + }; + +float4x4 camera : VIEW = {4.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0, 0.0,0.0,0.0,6.0}; +technique tech0 +{ + pass p0 + { + vertexshader = vs_arr1[1]; + VertexShaderConstant1[3] = {2,2,2,2}; + BlendOp = 2; + AlphaOp[3] = 4; + ZEnable = true; + WorldTransform[1]={2.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0, 0.0,0.0,0.0,4.0}; + ViewTransform=(camera); + LightEnable[2] = TRUE; + LightType[2] = POINT; + LightPosition[2] = {4.0f, 5.0f, 6.0f}; + Sampler[1] = sampler1; + } +} +#endif +static const DWORD test_effect_states_effect_blob[] = +{ + 0xfeff0901, 0x000002e8, 0x00000000, 0x00000010, 0x00000004, 0x00000020, 0x00000000, 0x00000002, + 0x00000001, 0x00000002, 0x00000008, 0x615f7376, 0x00317272, 0x0000000a, 0x00000004, 0x00000074, + 0x00000000, 0x00000000, 0x00000002, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000001, 0x00000001, 0x000000ab, 0x00000100, 0x00000044, 0x00000040, 0x00000009, + 0x706d6173, 0x3172656c, 0x00000000, 0x00000003, 0x00000002, 0x000000e0, 0x000000ec, 0x00000000, + 0x00000004, 0x00000004, 0x40800000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x40c00000, 0x00000007, 0x656d6163, 0x00006172, 0x00000005, 0x57454956, 0x00000000, + 0x00000003, 0x00000010, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x40000000, 0x40000000, + 0x40000000, 0x40000000, 0x00000003, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000004, + 0x00000001, 0x00000002, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x00000004, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x00000001, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x40000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x40800000, 0x00000003, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000003, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000001, + 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000001, + 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x40800000, + 0x40a00000, 0x40c00000, 0x00000003, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000003, + 0x00000001, 0x00000000, 0x0000000a, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000003, + 0x00003070, 0x00000006, 0x68636574, 0x00000030, 0x00000003, 0x00000001, 0x00000005, 0x00000004, + 0x00000004, 0x00000018, 0x00000000, 0x00000000, 0x0000002c, 0x00000060, 0x00000000, 0x00000000, + 0x00000084, 0x000000a0, 0x00000000, 0x00000000, 0x000002dc, 0x00000000, 0x00000001, 0x000002d4, + 0x00000000, 0x0000000b, 0x00000092, 0x00000000, 0x000000fc, 0x000000f8, 0x00000098, 0x00000003, + 0x00000120, 0x00000110, 0x0000004b, 0x00000000, 0x00000140, 0x0000013c, 0x0000006b, 0x00000003, + 0x00000160, 0x0000015c, 0x00000000, 0x00000000, 0x00000180, 0x0000017c, 0x0000007d, 0x00000001, + 0x000001dc, 0x0000019c, 0x0000007c, 0x00000000, 0x00000238, 0x000001f8, 0x00000091, 0x00000002, + 0x00000258, 0x00000254, 0x00000084, 0x00000002, 0x00000278, 0x00000274, 0x00000088, 0x00000002, + 0x000002a0, 0x00000294, 0x000000b2, 0x00000001, 0x000002c0, 0x000002bc, 0x00000002, 0x00000003, + 0x00000001, 0x0000002c, 0xfffe0101, 0x00000051, 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000, + 0x3f800000, 0x00000001, 0xc00f0000, 0xa0e40000, 0x0000ffff, 0x00000002, 0x0000002c, 0xfffe0200, + 0x05000051, 0xa00f0000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x02000001, 0xc00f0000, + 0xa0e40000, 0x0000ffff, 0x00000000, 0x00000000, 0xffffffff, 0x0000000a, 0x00000001, 0x00000009, + 0x706d6173, 0x3172656c, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000006, 0x00000000, + 0x0000016c, 0x46580200, 0x0030fffe, 0x42415443, 0x0000001c, 0x0000008b, 0x46580200, 0x00000001, + 0x0000001c, 0x20000100, 0x00000088, 0x00000030, 0x00000002, 0x00000004, 0x00000038, 0x00000048, + 0x656d6163, 0xab006172, 0x00030003, 0x00040004, 0x00000001, 0x00000000, 0x40800000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40c00000, 0x4d007874, 0x6f726369, + 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072, + 0x392e3932, 0x332e3235, 0x00313131, 0x0002fffe, 0x54494c43, 0x00000000, 0x0024fffe, 0x434c5846, + 0x00000004, 0x10000004, 0x00000001, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000004, + 0x00000000, 0x10000004, 0x00000001, 0x00000000, 0x00000002, 0x00000004, 0x00000000, 0x00000004, + 0x00000004, 0x10000004, 0x00000001, 0x00000000, 0x00000002, 0x00000008, 0x00000000, 0x00000004, + 0x00000008, 0x10000004, 0x00000001, 0x00000000, 0x00000002, 0x0000000c, 0x00000000, 0x00000004, + 0x0000000c, 0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, + 0x00000001, 0x0000000b, 0x615f7376, 0x5b317272, 0x00005d31, +}; +#define TEST_EFFECT_STATES_VSHADER_POS 271 + +static void test_effect_states(IDirect3DDevice9 *device) +{ + D3DMATRIX test_mat = + {{{ + -1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f + }}}; + D3DMATRIX test_mat_camera = + {{{ ... 31295 lines suppressed ...
4 years, 10 months
1
0
0
0
[reactos] 02/74: [D3DX9_36] Revert wine staged patches
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c530f34e79886d1408570…
commit c530f34e79886d1408570f8239b52d5482747a33 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 20 11:53:44 2019 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Feb 26 18:19:18 2020 +0100 [D3DX9_36] Revert wine staged patches --- dll/directx/wine/d3dx9_24/d3dx9_24.spec | 4 +- dll/directx/wine/d3dx9_25/d3dx9_25.spec | 4 +- dll/directx/wine/d3dx9_26/d3dx9_26.spec | 4 +- dll/directx/wine/d3dx9_27/d3dx9_27.spec | 4 +- dll/directx/wine/d3dx9_28/d3dx9_28.spec | 4 +- dll/directx/wine/d3dx9_29/d3dx9_29.spec | 4 +- dll/directx/wine/d3dx9_30/d3dx9_30.spec | 4 +- dll/directx/wine/d3dx9_31/d3dx9_31.spec | 4 +- dll/directx/wine/d3dx9_32/d3dx9_32.spec | 4 +- dll/directx/wine/d3dx9_33/d3dx9_33.spec | 4 +- dll/directx/wine/d3dx9_34/d3dx9_34.spec | 4 +- dll/directx/wine/d3dx9_35/d3dx9_35.spec | 4 +- dll/directx/wine/d3dx9_36/d3dx9.cmake | 2 +- dll/directx/wine/d3dx9_36/d3dx9_36.spec | 4 +- dll/directx/wine/d3dx9_36/d3dx9_private.h | 4 - dll/directx/wine/d3dx9_36/effect.c | 4 +- dll/directx/wine/d3dx9_36/font.c | 246 ++------------------ dll/directx/wine/d3dx9_36/math.c | 24 +- dll/directx/wine/d3dx9_36/mesh.c | 56 +---- dll/directx/wine/d3dx9_36/preshader.c | 2 + dll/directx/wine/d3dx9_36/shader.c | 365 +----------------------------- dll/directx/wine/d3dx9_36/skin.c | 108 +-------- dll/directx/wine/d3dx9_36/surface.c | 203 +---------------- dll/directx/wine/d3dx9_36/texture.c | 13 +- dll/directx/wine/d3dx9_36/util.c | 1 - dll/directx/wine/d3dx9_37/d3dx9_37.spec | 4 +- dll/directx/wine/d3dx9_38/d3dx9_38.spec | 4 +- dll/directx/wine/d3dx9_39/d3dx9_39.spec | 4 +- dll/directx/wine/d3dx9_40/d3dx9_40.spec | 4 +- dll/directx/wine/d3dx9_41/d3dx9_41.spec | 4 +- dll/directx/wine/d3dx9_42/d3dx9_42.spec | 4 +- dll/directx/wine/d3dx9_43/d3dx9_43.spec | 4 +- 32 files changed, 96 insertions(+), 1012 deletions(-) diff --git a/dll/directx/wine/d3dx9_24/d3dx9_24.spec b/dll/directx/wine/d3dx9_24/d3dx9_24.spec index 387e2535cae..d4e741884b9 100644 --- a/dll/directx/wine/d3dx9_24/d3dx9_24.spec +++ b/dll/directx/wine/d3dx9_24/d3dx9_24.spec @@ -20,7 +20,7 @@ @ stdcall D3DXComputeBoundingSphere(ptr long long ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -226,7 +226,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_25/d3dx9_25.spec b/dll/directx/wine/d3dx9_25/d3dx9_25.spec index a214b94d2b4..5375c07690a 100644 --- a/dll/directx/wine/d3dx9_25/d3dx9_25.spec +++ b/dll/directx/wine/d3dx9_25/d3dx9_25.spec @@ -20,7 +20,7 @@ @ stdcall D3DXComputeBoundingSphere(ptr long long ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -226,7 +226,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_26/d3dx9_26.spec b/dll/directx/wine/d3dx9_26/d3dx9_26.spec index b706e75be8b..c17f97f04a9 100644 --- a/dll/directx/wine/d3dx9_26/d3dx9_26.spec +++ b/dll/directx/wine/d3dx9_26/d3dx9_26.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -230,7 +230,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_27/d3dx9_27.spec b/dll/directx/wine/d3dx9_27/d3dx9_27.spec index b706e75be8b..c17f97f04a9 100644 --- a/dll/directx/wine/d3dx9_27/d3dx9_27.spec +++ b/dll/directx/wine/d3dx9_27/d3dx9_27.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -230,7 +230,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_28/d3dx9_28.spec b/dll/directx/wine/d3dx9_28/d3dx9_28.spec index 6efb8715423..5b267c14599 100644 --- a/dll/directx/wine/d3dx9_28/d3dx9_28.spec +++ b/dll/directx/wine/d3dx9_28/d3dx9_28.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -230,7 +230,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_29/d3dx9_29.spec b/dll/directx/wine/d3dx9_29/d3dx9_29.spec index 6efb8715423..5b267c14599 100644 --- a/dll/directx/wine/d3dx9_29/d3dx9_29.spec +++ b/dll/directx/wine/d3dx9_29/d3dx9_29.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -230,7 +230,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_30/d3dx9_30.spec b/dll/directx/wine/d3dx9_30/d3dx9_30.spec index 53434dad39e..dc9ea939416 100644 --- a/dll/directx/wine/d3dx9_30/d3dx9_30.spec +++ b/dll/directx/wine/d3dx9_30/d3dx9_30.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -230,7 +230,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_31/d3dx9_31.spec b/dll/directx/wine/d3dx9_31/d3dx9_31.spec index 69dbcc09d8c..4dec8f58d0d 100644 --- a/dll/directx/wine/d3dx9_31/d3dx9_31.spec +++ b/dll/directx/wine/d3dx9_31/d3dx9_31.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -227,7 +227,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_32/d3dx9_32.spec b/dll/directx/wine/d3dx9_32/d3dx9_32.spec index 1e7f9b398d3..7b6d62df3e7 100644 --- a/dll/directx/wine/d3dx9_32/d3dx9_32.spec +++ b/dll/directx/wine/d3dx9_32/d3dx9_32.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -227,7 +227,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_33/d3dx9_33.spec b/dll/directx/wine/d3dx9_33/d3dx9_33.spec index 1e7f9b398d3..7b6d62df3e7 100644 --- a/dll/directx/wine/d3dx9_33/d3dx9_33.spec +++ b/dll/directx/wine/d3dx9_33/d3dx9_33.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -227,7 +227,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_34/d3dx9_34.spec b/dll/directx/wine/d3dx9_34/d3dx9_34.spec index 1e7f9b398d3..7b6d62df3e7 100644 --- a/dll/directx/wine/d3dx9_34/d3dx9_34.spec +++ b/dll/directx/wine/d3dx9_34/d3dx9_34.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -227,7 +227,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_35/d3dx9_35.spec b/dll/directx/wine/d3dx9_35/d3dx9_35.spec index 1e7f9b398d3..7b6d62df3e7 100644 --- a/dll/directx/wine/d3dx9_35/d3dx9_35.spec +++ b/dll/directx/wine/d3dx9_35/d3dx9_35.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -227,7 +227,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_36/d3dx9.cmake b/dll/directx/wine/d3dx9_36/d3dx9.cmake index 06347a08353..5f206cf6377 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9.cmake +++ b/dll/directx/wine/d3dx9_36/d3dx9.cmake @@ -35,7 +35,7 @@ function(add_d3dx9_target __version) set_module_type(${module} win32dll) add_dependencies(${module} d3d_idl_headers) target_link_libraries(${module} dxguid wine) - add_importlibs(${module} d3dcompiler_43 d3dxof d3dwine user32 ole32 gdi32 msvcrt kernel32 ntdll) + add_importlibs(${module} d3dcompiler_43 d3dxof user32 ole32 gdi32 msvcrt kernel32 ntdll) add_pch(${module} ../d3dx9_36/precomp.h SOURCE) add_cd_file(TARGET ${module} DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36.spec b/dll/directx/wine/d3dx9_36/d3dx9_36.spec index 1e035f76c1a..692321d9065 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36.spec +++ b/dll/directx/wine/d3dx9_36/d3dx9_36.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -229,7 +229,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_36/d3dx9_private.h b/dll/directx/wine/d3dx9_36/d3dx9_private.h index 7a4d882a8b6..696b1859492 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_private.h +++ b/dll/directx/wine/d3dx9_36/d3dx9_private.h @@ -121,8 +121,6 @@ HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *d const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN; HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN; -HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, - const PALETTEENTRY *src_palette) DECLSPEC_HIDDEN; unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN; float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN; @@ -406,6 +404,4 @@ struct ctab_constant { const struct ctab_constant *d3dx_shader_get_ctab_constant(ID3DXConstantTable *iface, D3DXHANDLE constant) DECLSPEC_HIDDEN; -HRESULT create_dummy_skin(ID3DXSkinInfo **iface) DECLSPEC_HIDDEN; - #endif /* __WINE_D3DX9_PRIVATE_H */ diff --git a/dll/directx/wine/d3dx9_36/effect.c b/dll/directx/wine/d3dx9_36/effect.c index 8c2b499cd7b..33197de9bd1 100644 --- a/dll/directx/wine/d3dx9_36/effect.c +++ b/dll/directx/wine/d3dx9_36/effect.c @@ -4511,9 +4511,7 @@ static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect *iface, if (!device) return D3DERR_INVALIDCALL; - iface->lpVtbl->AddRef(iface); - *effect = iface; - return S_OK; + return E_NOTIMPL; } #if D3DX_SDK_VERSION >= 27 diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 05e490fd2a5..418a3be3328 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -35,29 +35,8 @@ struct d3dx_font HDC hdc; HFONT hfont; - - UINT tex_width; - UINT tex_height; - IDirect3DTexture9 *texture; - HBITMAP bitmap; - BYTE *bits; }; -/* Returns the smallest power of 2 which is greater than or equal to num */ -static UINT make_pow2(UINT num) -{ - UINT result = 1; - - /* In the unlikely event somebody passes a large value, make sure we don't enter an infinite loop */ - if (num >= 0x80000000) - return 0x80000000; - - while (result < num) - result <<= 1; - - return result; -} - static inline struct d3dx_font *impl_from_ID3DXFont(ID3DXFont *iface) { return CONTAINING_RECORD(iface, struct d3dx_font, ID3DXFont_iface); @@ -84,27 +63,19 @@ static HRESULT WINAPI ID3DXFontImpl_QueryInterface(ID3DXFont *iface, REFIID riid static ULONG WINAPI ID3DXFontImpl_AddRef(ID3DXFont *iface) { struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref = InterlockedIncrement(&This->ref); - + ULONG ref=InterlockedIncrement(&This->ref); TRACE("%p increasing refcount to %u\n", iface, ref); - return ref; } static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface) { struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref = InterlockedDecrement(&This->ref); + ULONG ref=InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u\n", iface, ref); - if (!ref) - { - if (This->texture) - { - IDirect3DTexture9_Release(This->texture); - DeleteObject(This->bitmap); - } + if(ref==0) { DeleteObject(This->hfont); DeleteDC(This->hdc); IDirect3DDevice9_Release(This->device); @@ -207,187 +178,17 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR * static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, const char *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - LPWSTR stringW; - INT countW, ret = 0; - - TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n", + FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color); - - if (!string || count == 0) - return 0; - - if (count < 0) - count = -1; - - countW = MultiByteToWideChar(CP_ACP, 0, string, count, NULL, 0); - stringW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)); - if (stringW) - { - MultiByteToWideChar(CP_ACP, 0, string, count, stringW, countW); - ret = ID3DXFont_DrawTextW(iface, sprite, stringW, countW, rect, format, color); - HeapFree(GetProcessHeap(), 0, stringW); - } - - return ret; + return 1; } static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); - RECT calc_rect; - INT height; - - TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n", + FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color); - - if (!string || count == 0) - return 0; - - if (count < 0) - count = lstrlenW(string); - - /* Strip terminating NULL characters */ - while (count > 0 && !string[count-1]) - count--; - - if (rect) - calc_rect = *rect; - - height = DrawTextW(This->hdc, string, count, &calc_rect, format | DT_CALCRECT); - - if (format & DT_CALCRECT) - { - if (rect) - *rect = calc_rect; - return height; - } - - if (format & DT_CENTER) - { - UINT new_width = calc_rect.right - calc_rect.left; - calc_rect.left = (rect->right + rect->left - new_width) / 2; - calc_rect.right = calc_rect.left + new_width; - } - - if (height && (calc_rect.left < calc_rect.right)) - { - D3DLOCKED_RECT locked_rect; - D3DXVECTOR3 position; - UINT text_width, text_height; - RECT text_rect; - ID3DXSprite *target = sprite; - HRESULT hr; - int i, j; - - /* Get rect position and dimensions */ - position.x = calc_rect.left; - position.y = calc_rect.top; - position.z = 0; - text_width = calc_rect.right - calc_rect.left; - text_height = calc_rect.bottom - calc_rect.top; - text_rect.left = 0; - text_rect.top = 0; - text_rect.right = text_width; - text_rect.bottom = text_height; - - /* We need to flush as it seems all draws in the begin/end sequence use only the latest updated texture */ - if (sprite) - ID3DXSprite_Flush(sprite); - - /* Extend texture and DIB section to contain text */ - if ((text_width > This->tex_width) || (text_height > This->tex_height)) - { - BITMAPINFOHEADER header; - - if (text_width > This->tex_width) - This->tex_width = make_pow2(text_width); - if (text_height > This->tex_height) - This->tex_height = make_pow2(text_height); - - if (This->texture) - { - IDirect3DTexture9_Release(This->texture); - DeleteObject(This->bitmap); - } - - hr = D3DXCreateTexture(This->device, This->tex_width, This->tex_height, 1, 0, - D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &This->texture); - if (FAILED(hr)) - { - This->texture = NULL; - return 0; - } - - header.biSize = sizeof(header); - header.biWidth = This->tex_width; - header.biHeight = -This->tex_height; - header.biPlanes = 1; - header.biBitCount = 32; - header.biCompression = BI_RGB; - header.biSizeImage = sizeof(DWORD) * This->tex_width * This->tex_height; - header.biXPelsPerMeter = 0; - header.biYPelsPerMeter = 0; - header.biClrUsed = 0; - header.biClrImportant = 0; - - This->bitmap = CreateDIBSection(This->hdc, (const BITMAPINFO*)&header, - DIB_RGB_COLORS, (void**)&This->bits, NULL, 0); - if (!This->bitmap) - { - IDirect3DTexture9_Release(This->texture); - This->texture = NULL; - return 0; - } - - SelectObject(This->hdc, This->bitmap); - } - - if (FAILED(IDirect3DTexture9_LockRect(This->texture, 0, &locked_rect, &text_rect, D3DLOCK_DISCARD))) - return 0; - - /* Clear rect */ - for (i = 0; i < text_height; i++) - memset(This->bits + i * This->tex_width * sizeof(DWORD), 0, - text_width * sizeof(DWORD)); - - DrawTextW(This->hdc, string, count, &text_rect, format); - - /* All RGB components are equal so take one as alpha and set RGB - * color to white, so it can be modulated with color parameter */ - for (i = 0; i < text_height; i++) - { - DWORD *src = (DWORD *)This->bits + i * This->tex_width; - DWORD *dst = (DWORD *)((BYTE *)locked_rect.pBits + i * locked_rect.Pitch); - for (j = 0; j < text_width; j++) - { - *dst++ = (*src++ << 24) | 0xFFFFFF; - } - } - - IDirect3DTexture9_UnlockRect(This->texture, 0); - - if (!sprite) - { - hr = D3DXCreateSprite(This->device, &target); - if (FAILED(hr)) - return 0; - ID3DXSprite_Begin(target, 0); - } - - hr = target->lpVtbl->Draw(target, This->texture, &text_rect, NULL, &position, color); - - if (!sprite) - { - ID3DXSprite_End(target); - ID3DXSprite_Release(target); - } - - if (FAILED(hr)) - return 0; - } - - return height; + return 1; } static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(ID3DXFont *iface) @@ -500,55 +301,46 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_ TRACE("(%p, %p, %p)\n", device, desc, font); - if (!device || !desc || !font) return D3DERR_INVALIDCALL; - - TRACE("desc: %d %d %d %d %d %d %d %d %d %s\n", desc->Height, desc->Width, desc->Weight, desc->MipLevels, desc->Italic, - desc->CharSet, desc->OutputPrecision, desc->Quality, desc->PitchAndFamily, debugstr_w(desc->FaceName)); + if( !device || !desc || !font ) return D3DERR_INVALIDCALL; - /* The device MUST support D3DFMT_A8R8G8B8 */ + /* the device MUST support D3DFMT_A8R8G8B8 */ IDirect3DDevice9_GetDirect3D(device, &d3d); IDirect3DDevice9_GetCreationParameters(device, &cpars); IDirect3DDevice9_GetDisplayMode(device, 0, &mode); hr = IDirect3D9_CheckDeviceFormat(d3d, cpars.AdapterOrdinal, cpars.DeviceType, mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8); - if (FAILED(hr)) - { + if(FAILED(hr)) { IDirect3D9_Release(d3d); return D3DXERR_INVALIDDATA; } IDirect3D9_Release(d3d); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct d3dx_font)); - if (!object) - { - *font = NULL; + object = HeapAlloc(GetProcessHeap(), 0, sizeof(struct d3dx_font)); + if(object==NULL) { + *font=NULL; return E_OUTOFMEMORY; } object->ID3DXFont_iface.lpVtbl = &D3DXFont_Vtbl; - object->ref = 1; - object->device = device; - object->desc = *desc; + object->ref=1; + object->device=device; + object->desc=*desc; object->hdc = CreateCompatibleDC(NULL); - if (!object->hdc) - { + if( !object->hdc ) { HeapFree(GetProcessHeap(), 0, object); return D3DXERR_INVALIDDATA; } object->hfont = CreateFontW(desc->Height, desc->Width, 0, 0, desc->Weight, desc->Italic, FALSE, FALSE, desc->CharSet, desc->OutputPrecision, CLIP_DEFAULT_PRECIS, desc->Quality, desc->PitchAndFamily, desc->FaceName); - if (!object->hfont) - { + if( !object->hfont ) { DeleteDC(object->hdc); HeapFree(GetProcessHeap(), 0, object); return D3DXERR_INVALIDDATA; } SelectObject(object->hdc, object->hfont); - SetTextColor(object->hdc, 0x00ffffff); - SetBkColor(object->hdc, 0x00000000); IDirect3DDevice9_AddRef(device); - *font = &object->ID3DXFont_iface; + *font=&object->ID3DXFont_iface; return D3D_OK; } diff --git a/dll/directx/wine/d3dx9_36/math.c b/dll/directx/wine/d3dx9_36/math.c index 03ccbd04e18..8909c3c6b25 100644 --- a/dll/directx/wine/d3dx9_36/math.c +++ b/dll/directx/wine/d3dx9_36/math.c @@ -794,34 +794,24 @@ D3DXMATRIX* WINAPI D3DXMatrixTransformation(D3DXMATRIX *pout, const D3DXVECTOR3 D3DXMatrixTranslation(&m1, -psc.x, -psc.y, -psc.z); - if ( !pscalingrotation || !pscaling ) + if ( !pscalingrotation ) { D3DXMatrixIdentity(&m2); D3DXMatrixIdentity(&m4); } else { - D3DXQUATERNION temp; - D3DXMatrixRotationQuaternion(&m4, pscalingrotation); - temp.w = pscalingrotation->w; - temp.x = -pscalingrotation->x; - temp.y = -pscalingrotation->y; - temp.z = -pscalingrotation->z; - D3DXMatrixRotationQuaternion(&m2, &temp); + D3DXMatrixInverse(&m2, NULL, &m4); } - if ( !pscaling ) - D3DXMatrixIdentity(&m3); - else - D3DXMatrixScaling(&m3, pscaling->x, pscaling->y, pscaling->z); + if ( !pscaling ) D3DXMatrixIdentity(&m3); + else D3DXMatrixScaling(&m3, pscaling->x, pscaling->y, pscaling->z); - if ( !protation ) - D3DXMatrixIdentity(&m6); - else - D3DXMatrixRotationQuaternion(&m6, protation); + if ( !protation ) D3DXMatrixIdentity(&m6); + else D3DXMatrixRotationQuaternion(&m6, protation); - D3DXMatrixTranslation(&m5, psc.x - prc.x, psc.y - prc.y, psc.z - prc.z); + D3DXMatrixTranslation(&m5, psc.x - prc.x, psc.y - prc.y, psc.z - prc.z); D3DXMatrixTranslation(&m7, prc.x + pt.x, prc.y + pt.y, prc.z + pt.z); D3DXMatrixMultiply(&m1, &m1, &m2); D3DXMatrixMultiply(&m1, &m1, &m3); diff --git a/dll/directx/wine/d3dx9_36/mesh.c b/dll/directx/wine/d3dx9_36/mesh.c index b1d9f68ade1..acbb2477670 100644 --- a/dll/directx/wine/d3dx9_36/mesh.c +++ b/dll/directx/wine/d3dx9_36/mesh.c @@ -1695,7 +1695,11 @@ static HRESULT WINAPI d3dx9_mesh_OptimizeInplace(ID3DXMesh *iface, DWORD flags, if (FAILED(hr)) goto cleanup; } else if (flags & D3DXMESHOPT_ATTRSORT) { if (!(flags & D3DXMESHOPT_IGNOREVERTS)) + { FIXME("D3DXMESHOPT_ATTRSORT vertex reordering not implemented.\n"); + hr = E_NOTIMPL; + goto cleanup; + } hr = iface->lpVtbl->LockAttributeBuffer(iface, 0, &attrib_buffer); if (FAILED(hr)) goto cleanup; @@ -3328,13 +3332,6 @@ static HRESULT parse_mesh(ID3DXFileData *filedata, struct mesh_data *mesh_data, goto end; } - if ((provide_flags & PROVIDE_SKININFO) && !mesh_data->skin_info) - { - hr = create_dummy_skin(&mesh_data->skin_info); - if (FAILED(hr)) - goto end; - } - hr = D3D_OK; end: @@ -7189,33 +7186,6 @@ cleanup: return hr; } - -/************************************************************************* - * D3DXOptimizeVertices (D3DX9_36.@) - */ -HRESULT WINAPI D3DXOptimizeVertices(const void *indices, UINT num_faces, - UINT num_vertices, BOOL indices_are_32bit, DWORD *vertex_remap) -{ - UINT i; - - FIXME("indices %p, num_faces %u, num_vertices %u, indices_are_32bit %#x, vertex_remap %p semi-stub.\n", - indices, num_faces, num_vertices, indices_are_32bit, vertex_remap); - - if (!vertex_remap) - { - WARN("vertex remap pointer is NULL.\n"); - return D3DERR_INVALIDCALL; - } - - for (i = 0; i < num_vertices; i++) - { - vertex_remap[i] = i; - } - - return D3D_OK; -} - - /************************************************************************* * D3DXOptimizeFaces (D3DX9_36.@) * @@ -7539,24 +7509,6 @@ done: return hr; } -/************************************************************************* - * D3DXComputeTangent (D3DX9_36.@) - */ -HRESULT WINAPI D3DXComputeTangent(ID3DXMesh *mesh, DWORD stage_idx, DWORD tangent_idx, - DWORD binorm_idx, DWORD wrap, const DWORD *adjacency) -{ - TRACE("mesh %p, stage_idx %d, tangent_idx %d, binorm_idx %d, wrap %d, adjacency %p.\n", - mesh, stage_idx, tangent_idx, binorm_idx, wrap, adjacency); - - return D3DXComputeTangentFrameEx( mesh, D3DDECLUSAGE_TEXCOORD, stage_idx, - ( binorm_idx == D3DX_DEFAULT ) ? D3DX_DEFAULT : D3DDECLUSAGE_BINORMAL, - binorm_idx, - ( tangent_idx == D3DX_DEFAULT ) ? D3DX_DEFAULT : D3DDECLUSAGE_TANGENT, - tangent_idx, D3DX_DEFAULT, 0, - ( wrap ? D3DXTANGENT_WRAP_UV : 0 ) | D3DXTANGENT_GENERATE_IN_PLACE | D3DXTANGENT_ORTHOGONALIZE_FROM_U, - adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL); -} - /************************************************************************* * D3DXComputeNormals (D3DX9_36.@) */ diff --git a/dll/directx/wine/d3dx9_36/preshader.c b/dll/directx/wine/d3dx9_36/preshader.c index 9a1562a548c..1c38cff751d 100644 --- a/dll/directx/wine/d3dx9_36/preshader.c +++ b/dll/directx/wine/d3dx9_36/preshader.c @@ -26,9 +26,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx); +#ifdef __REACTOS__ /* ReactOS FIXME: Insect */ #define fmin min #define fmax max +#endif enum pres_ops { diff --git a/dll/directx/wine/d3dx9_36/shader.c b/dll/directx/wine/d3dx9_36/shader.c index fc0f503c697..e8ce3dd796c 100644 --- a/dll/directx/wine/d3dx9_36/shader.c +++ b/dll/directx/wine/d3dx9_36/shader.c @@ -1,7 +1,6 @@ /* * Copyright 2008 Luis Busquets * Copyright 2009 Matteo Bruni - * Copyright 2010, 2013, 2016 Christian Costa * Copyright 2011 Travis Athougies * * This library is free software; you can redistribute it and/or @@ -21,7 +20,6 @@ #include "config.h" #include "wine/port.h" -#include <stdio.h> #include "d3dx9_private.h" #include "d3dcommon.h" @@ -441,41 +439,6 @@ HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO } } - /* Filter out D3DCompile warning messages that are not present with D3DCompileShader */ - if (SUCCEEDED(hr) && error_msgs && *error_msgs) - { - char *messages = ID3DXBuffer_GetBufferPointer(*error_msgs); - DWORD size = ID3DXBuffer_GetBufferSize(*error_msgs); - - /* Ensure messages are null terminated for safe processing */ - if (size) messages[size - 1] = 0; - - while (size > 1) - { - char *prev, *next; - - /* Warning has the form "warning X3206: ... implicit truncation of vector type" - but we only search for "X3206:" in case d3dcompiler_43 has localization */ - prev = next = strstr(messages, "X3206:"); - if (!prev) break; - - /* get pointer to beginning and end of current line */ - while (prev > messages && *(prev - 1) != '\n') prev--; - while (next < messages + size - 1 && *next != '\n') next++; - if (next < messages + size - 1 && *next == '\n') next++; - - memmove(prev, next, messages + size - next); - size -= (next - prev); - } - - /* Only return a buffer if the resulting string is not empty as some apps depend on that */ - if (size <= 1) - { - ID3DXBuffer_Release(*error_msgs); - *error_msgs = NULL; - } - } - return hr; } @@ -2177,334 +2140,10 @@ HRESULT WINAPI D3DXGetShaderSamplers(const DWORD *byte_code, const char **sample return D3D_OK; } - -static const char *decl_usage[] = { "position", "blendweight", "blendindices", "normal", "psize", "texcoord", - "tangent", "binormal", "tessfactor", "positiont", "color" }; - -static const char *tex_type[] = { "", "1d", "2d", "cube", "volume" }; - -static int add_modifier(char *buffer, DWORD param) -{ - char *buf = buffer; - DWORD dst_mod = param & D3DSP_DSTMOD_MASK; - - if (dst_mod & D3DSPDM_SATURATE) - buf += sprintf(buf, "_sat"); - if (dst_mod & D3DSPDM_PARTIALPRECISION) - buf += sprintf(buf, "_pp"); - if (dst_mod & D3DSPDM_MSAMPCENTROID) - buf += sprintf(buf, "_centroid"); - - return buf - buffer; -} - -static int add_register(char *buffer, DWORD param, BOOL dst, BOOL ps) -{ - char *buf = buffer; - DWORD reg_type = ((param & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2) - | ((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); - DWORD reg_num = param & D3DSP_REGNUM_MASK; - - if (reg_type == D3DSPR_INPUT) - buf += sprintf(buf, "v%d", reg_num); - else if (reg_type == D3DSPR_CONST) - buf += sprintf(buf, "c%d", reg_num); - else if (reg_type == D3DSPR_TEMP) - buf += sprintf(buf, "r%d", reg_num); - else if (reg_type == D3DSPR_ADDR) - buf += sprintf(buf, "%s%d", ps ? "t" : "a", reg_num); - else if (reg_type == D3DSPR_SAMPLER) - buf += sprintf(buf, "s%d", reg_num); - else if (reg_type == D3DSPR_RASTOUT) - buf += sprintf(buf, "oPos"); - else if (reg_type == D3DSPR_COLOROUT) - buf += sprintf(buf, "oC%d", reg_num); - else if (reg_type == D3DSPR_TEXCRDOUT) - buf += sprintf(buf, "oT%d", reg_num); - else if (reg_type == D3DSPR_ATTROUT) - buf += sprintf(buf, "oD%d", reg_num); - else - buf += sprintf(buf, "? (%d)", reg_type); - - if (dst) - { - if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) - { - buf += sprintf(buf, ".%s%s%s%s", param & D3DSP_WRITEMASK_0 ? "x" : "", - param & D3DSP_WRITEMASK_1 ? "y" : "", - param & D3DSP_WRITEMASK_2 ? "z" : "", - param & D3DSP_WRITEMASK_3 ? "w" : ""); - } - } - else - { - if ((param & D3DVS_SWIZZLE_MASK) != D3DVS_NOSWIZZLE) - { - if ( ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_X | D3DVS_Y_X | D3DVS_Z_X | D3DVS_W_X)) || - ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_Y | D3DVS_Y_Y | D3DVS_Z_Y | D3DVS_W_Y)) || - ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_Z | D3DVS_Y_Z | D3DVS_Z_Z | D3DVS_W_Z)) || - ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_W | D3DVS_Y_W | D3DVS_Z_W | D3DVS_W_W)) ) - buf += sprintf(buf, ".%c", 'w' + (((param >> D3DVS_SWIZZLE_SHIFT) + 1) & 0x3)); - else - buf += sprintf(buf, ".%c%c%c%c", 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+0)) + 1) & 0x3), - 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+2)) + 1) & 0x3), - 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+4)) + 1) & 0x3), - 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+6)) + 1) & 0x3)); - } - } - - return buf - buffer; -} - -struct instr_info -{ - DWORD opcode; - const char *name; - int length; - int (*function)(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps); - WORD min_version; - WORD max_version; -}; - -static int instr_comment(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - *ptr += 1 + ((**ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT); - return 0; -} - -static int instr_def(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - int len = sprintf(buffer, " def c%d, %g, %g, %g, %g\n", *(*ptr+1) & D3DSP_REGNUM_MASK, - (double)*(float*)(*ptr+2), (double)*(float*)(*ptr+3), - (double)*(float*)(*ptr+4), (double)*(float*)(*ptr+5)); - *ptr += 6; - return len; -} - -static int instr_dcl(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - DWORD param1 = *++*ptr; - DWORD param2 = *++*ptr; - DWORD usage = (param1 & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT; - DWORD usage_index = (param1 & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT; - char *buf = buffer; - - buf += sprintf(buf, " dcl"); - if (ps) - { - if (param1 & D3DSP_TEXTURETYPE_MASK) - buf += sprintf(buf, "_%s", (usage <= D3DSTT_VOLUME) ? - tex_type[(param1 & D3DSP_TEXTURETYPE_MASK) >> D3DSP_TEXTURETYPE_SHIFT] : "???"); - } - else - { - buf += sprintf(buf, "_%s", (usage <= D3DDECLUSAGE_COLOR) ? decl_usage[usage] : "???"); - if (usage_index) - buf += sprintf(buf, "%d", usage_index); - } - - buf += add_modifier(buf, param2); - buf += sprintf(buf, " "); - buf += add_register(buf, param2, TRUE, TRUE); - buf += sprintf(buf, "\n"); - (*ptr)++; - return buf - buffer; -} - -static int instr_generic(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - char *buf = buffer; - int j; - - buf += sprintf(buf, " %s", info->name); - (*ptr)++; - - if (info->length) - { - buf += add_modifier(buf, **ptr); - - for (j = 0; j < info->length; j++) - { - buf += sprintf(buf, "%s ", j ? "," : ""); - - if ((j != 0) && ((**ptr & D3DSP_SRCMOD_MASK) != D3DSPSM_NONE)) - { - if ((**ptr & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG) - buf += sprintf(buf, "-"); - else - buf += sprintf(buf, "*"); - } - - buf += add_register(buf, **ptr, j == 0, ps); - - if (*(*ptr)++ & D3DVS_ADDRESSMODE_MASK) - { - buf += sprintf(buf, "["); - buf += add_register(buf, **ptr, FALSE, FALSE); - buf += sprintf(buf, "]"); - (*ptr)++; - } - } - } - buf += sprintf(buf, "\n"); - return buf - buffer; -} - -const struct instr_info instructions[] = -{ - { D3DSIO_NOP, "nop", 0, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_MOV, "mov", 2, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_ADD, "add", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_SUB, "sub", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_MAD, "mad", 4, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_MUL, "mul", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_RCP, "rcp", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_RSQ, "rsq", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_DP3, "dp3", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_DP4, "dp4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 1.2 for PS */ - { D3DSIO_MIN, "min", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_MAX, "max", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_SLT, "slt", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_SGE, "sge", 3, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_EXP, "exp", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_LOG, "log", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_LIT, "lit", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_DST, "dst", 3, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_LRP, "lrp", 4, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for VS */ - { D3DSIO_FRC, "frc", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M4x4, "m4x4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M4x3, "m4x3", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M3x4, "m3x4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M3x3, "m3x3", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M3x2, "m3x2", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_CALL, "call", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_CALLNZ, "callnz", 2, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_LOOP, "loop", 2, instr_generic, 0x0200, 0xFFFF }, /* >= 3.0 for PS */ - { D3DSIO_RET, "ret", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_ENDLOOP, "endloop", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 3.0 for PS */ - { D3DSIO_LABEL, "label", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_DCL, "dcl", 1, instr_dcl, 0x0100, 0xFFFF }, - { D3DSIO_POW, "pow", 3, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_CRS, "crs", 3, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_SGN, "sgn", 4, instr_generic, 0x0200, 0xFFFF }, /* VS only */ - { D3DSIO_ABS, "abs", 2, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_NRM, "nrm", 2, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_SINCOS, "sincos", 4, instr_generic, 0x0200, 0x02FF }, - { D3DSIO_SINCOS, "sincos", 2, instr_generic, 0x0300, 0xFFFF }, - { D3DSIO_REP, "rep", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_ENDREP, "endrep", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_IF, "if", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_IFC, "if_comp", 2, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_ELSE, "else", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_ENDIF, "endif", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_BREAK, "break", 0, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_BREAKC, "break_comp", 2, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_MOVA, "mova", 2, instr_generic, 0x0200, 0xFFFF }, /* VS only */ - { D3DSIO_DEFB, "defb", 2, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_DEFI, "defi", 2, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_TEXCOORD, "texcoord", 1, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXCOORD, "texcrd", 2, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_TEXKILL, "texkill", 1, instr_generic, 0x0100, 0xFFFF }, /* PS only */ - { D3DSIO_TEX, "tex", 1, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEX, "texld", 2, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_TEX, "texld", 3, instr_generic, 0x0200, 0xFFFF }, /* PS only */ - { D3DSIO_TEXBEM, "texbem", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXBEML, "texbeml", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXREG2AR, "texreg2ar", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXREG2GB, "texreg2gb", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x2PAD, "texm3x2pad", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x2TEX, "texm3x2tex", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3PAD, "texm3x3pad", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3TEX, "texm3x3tex", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3DIFF, "texm3x3diff", 2, instr_generic, 0x0100, 0xFFFF }, /* PS only - Not documented */ - { D3DSIO_TEXM3x3SPEC, "texm3x3spec", 3, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3VSPEC, "texm3x3vspec", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_EXPP, "expp", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_LOGP, "logp", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_CND, "cnd", 4, instr_generic, 0x0100, 0x0104 }, /* PS only */ - { D3DSIO_DEF, "def", 5, instr_def, 0x0100, 0xFFFF }, - { D3DSIO_TEXREG2RGB, "texreg2rgb", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXDP3TEX, "texdp3tex", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x2DEPTH, "texm3x2depth", 2, instr_generic, 0x0103, 0x0103 }, /* PS only */ - { D3DSIO_TEXDP3, "texdp3", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3, "texm3x3", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXDEPTH, "texdepth", 1, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_CMP, "cmp", 4, instr_generic, 0x0102, 0xFFFF }, /* PS only */ - { D3DSIO_BEM, "bem", 3, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_DP2ADD, "dp2add", 4, instr_generic, 0x0200, 0xFFFF }, /* PS only */ - { D3DSIO_DSX, "dsx", 2, instr_generic, 0x0201, 0xFFFF }, /* PS only */ - { D3DSIO_DSY, "dsy", 2, instr_generic, 0x0201, 0xFFFF }, /* PS only */ - { D3DSIO_TEXLDD, "texldd", 5, instr_generic, 0x0201, 0xFFFF }, /* PS only - not existing for 2.b */ - { D3DSIO_SETP, "setp_comp", 3, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_TEXLDL, "texldl", 3, instr_generic, 0x0300, 0xFFFF }, - { D3DSIO_BREAKP, "breakp", 1, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_PHASE, "phase", 0, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_COMMENT, "", 0, instr_comment, 0x0100, 0xFFFF } -}; - HRESULT WINAPI D3DXDisassembleShader(const DWORD *shader, BOOL colorcode, const char *comments, ID3DXBuffer **disassembly) { - DWORD *ptr = (DWORD *)shader; - char *buffer, *buf; - UINT capacity = 4096; - BOOL ps; - WORD version; - HRESULT hr; - - TRACE("%p %d %s %p\n", shader, colorcode, debugstr_a(comments), disassembly); - - if (!shader || !disassembly) - return D3DERR_INVALIDCALL; - - buf = buffer = HeapAlloc(GetProcessHeap(), 0, capacity); - if (!buffer) - return E_OUTOFMEMORY; - - ps = (*ptr >> 16) & 1; - version = *ptr & 0xFFFF; - buf += sprintf(buf, " %s_%d_%d\n", ps ? "ps" : "vs", D3DSHADER_VERSION_MAJOR(*ptr), D3DSHADER_VERSION_MINOR(*ptr)); - ptr++; - - while (*ptr != D3DSIO_END) - { - DWORD index; - - if ((buf - buffer + 128) > capacity) - { - UINT count = buf - buffer; - char *new_buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, capacity * 2); - if (!new_buffer) - { - HeapFree(GetProcessHeap(), 0, buffer); - return E_OUTOFMEMORY; - } - capacity *= 2; - buffer = new_buffer; - buf = buffer + count; - } - - for (index = 0; index < sizeof(instructions)/sizeof(instructions[0]); index++) - if (((*ptr & D3DSI_OPCODE_MASK) == instructions[index].opcode) && - (version >= instructions[index].min_version) && (version <= instructions[index].max_version)) - break; - - if (index != sizeof(instructions)/sizeof(instructions[0])) - { - buf += instructions[index].function(&(instructions[index]), &ptr, buf, ps); - } - else - { - buf += sprintf(buf, " ??? (Unknown opcode %x)\n", *ptr); - while (*++ptr & (1u << 31)); - } - } - - hr = D3DXCreateBuffer(buf - buffer + 1 , disassembly); - if (SUCCEEDED(hr)) - strcpy(ID3DXBuffer_GetBufferPointer(*disassembly), buffer); - HeapFree(GetProcessHeap(), 0, buffer); - - return hr; + FIXME("%p %d %s %p: stub\n", shader, colorcode, debugstr_a(comments), disassembly); + return E_OUTOFMEMORY; } struct d3dx9_texture_shader diff --git a/dll/directx/wine/d3dx9_36/skin.c b/dll/directx/wine/d3dx9_36/skin.c index 0a305a99236..f197d33582a 100644 --- a/dll/directx/wine/d3dx9_36/skin.c +++ b/dll/directx/wine/d3dx9_36/skin.c @@ -2,7 +2,6 @@ * Skin Info operations specific to D3DX9. * * Copyright (C) 2011 Dylan Smith - * Copyright (C) 2013 Christian Costa * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -95,7 +94,7 @@ static ULONG WINAPI d3dx9_skin_info_Release(ID3DXSkinInfo *iface) HeapFree(GetProcessHeap(), 0, skin->bones[i].vertices); HeapFree(GetProcessHeap(), 0, skin->bones[i].weights); } - if (skin->bones) HeapFree(GetProcessHeap(), 0, skin->bones); + HeapFree(GetProcessHeap(), 0, skin->bones); HeapFree(GetProcessHeap(), 0, skin); } @@ -378,89 +377,10 @@ static HRESULT WINAPI d3dx9_skin_info_GetDeclaration(ID3DXSkinInfo *iface, static HRESULT WINAPI d3dx9_skin_info_UpdateSkinnedMesh(ID3DXSkinInfo *iface, const D3DXMATRIX *bone_transforms, const D3DXMATRIX *bone_inv_transpose_transforms, const void *src_vertices, void *dst_vertices) { - struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface); - DWORD size = D3DXGetFVFVertexSize(skin->fvf); - DWORD i, j; - - TRACE("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p\n", - skin, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices); - - if (bone_inv_transpose_transforms) - FIXME("Skinning vertices with two position elements not supported\n"); - - if ((skin->fvf & D3DFVF_POSITION_MASK) != D3DFVF_XYZ) { - FIXME("Vertex type %#x not supported\n", skin->fvf & D3DFVF_POSITION_MASK); - return E_FAIL; - } - - /* Reset all positions */ - for (i = 0; i < skin->num_vertices; i++) { - D3DXVECTOR3 *position = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * i); - position->x = 0.0f; - position->y = 0.0f; - position->z = 0.0f; - } - - /* Update positions that are influenced by bones */ - for (i = 0; i < skin->num_bones; i++) { - D3DXMATRIX bone_inverse, matrix; - - D3DXMatrixInverse(&bone_inverse, NULL, &skin->bones[i].transform); - D3DXMatrixMultiply(&matrix, &bone_transforms[i], &bone_inverse); - D3DXMatrixMultiply(&matrix, &matrix, &skin->bones[i].transform); - - for (j = 0; j < skin->bones[i].num_influences; j++) { - D3DXVECTOR3 position; - D3DXVECTOR3 *position_src = (D3DXVECTOR3*)((BYTE*)src_vertices + size * skin->bones[i].vertices[j]); - D3DXVECTOR3 *position_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * skin->bones[i].vertices[j]); - FLOAT weight = skin->bones[i].weights[j]; - - D3DXVec3TransformCoord(&position, position_src, &matrix); - position_dest->x += weight * position.x; - position_dest->y += weight * position.y; - position_dest->z += weight * position.z; - } - } - - if (skin->fvf & D3DFVF_NORMAL) { - /* Reset all normals */ - for (i = 0; i < skin->num_vertices; i++) { - D3DXVECTOR3 *normal = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * i + sizeof(D3DXVECTOR3)); - normal->x = 0.0f; - normal->y = 0.0f; - normal->z = 0.0f; - } - - /* Update normals that are influenced by bones */ - for (i = 0; i < skin->num_bones; i++) { - D3DXMATRIX bone_inverse, matrix; - - D3DXMatrixInverse(&bone_inverse, NULL, &skin->bones[i].transform); - D3DXMatrixMultiply(&matrix, &skin->bones[i].transform, &bone_transforms[i]); - - for (j = 0; j < skin->bones[i].num_influences; j++) { - D3DXVECTOR3 normal; - D3DXVECTOR3 *normal_src = (D3DXVECTOR3*)((BYTE*)src_vertices + size * skin->bones[i].vertices[j] + sizeof(D3DXVECTOR3)); - D3DXVECTOR3 *normal_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * skin->bones[i].vertices[j] + sizeof(D3DXVECTOR3)); - FLOAT weight = skin->bones[i].weights[j]; - - D3DXVec3TransformNormal(&normal, normal_src, &bone_inverse); - D3DXVec3TransformNormal(&normal, &normal, &matrix); - normal_dest->x += weight * normal.x; - normal_dest->y += weight * normal.y; - normal_dest->z += weight * normal.z; - } - } - - /* Normalize all normals that are influenced by bones*/ - for (i = 0; i < skin->num_vertices; i++) { - D3DXVECTOR3 *normal_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + (i * size) + sizeof(D3DXVECTOR3)); - if ((normal_dest->x != 0.0f) && (normal_dest->y != 0.0f) && (normal_dest->z != 0.0f)) - D3DXVec3Normalize(normal_dest, normal_dest); - } - } + FIXME("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p stub!\n", + iface, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices); - return D3D_OK; + return E_NOTIMPL; } static HRESULT WINAPI d3dx9_skin_info_ConvertToBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in, @@ -575,23 +495,3 @@ HRESULT WINAPI D3DXCreateSkinInfoFVF(DWORD num_vertices, DWORD fvf, DWORD num_bo return D3DXCreateSkinInfo(num_vertices, declaration, num_bones, skin_info); } - -HRESULT create_dummy_skin(ID3DXSkinInfo **iface) -{ - static const D3DVERTEXELEMENT9 empty_declaration = D3DDECL_END(); - struct d3dx9_skin_info *object = NULL; - - object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object)); - if (!object) return E_OUTOFMEMORY; - - object->ID3DXSkinInfo_iface.lpVtbl = &d3dx9_skin_info_vtbl; - object->ref = 1; - object->num_vertices = 0; - object->num_bones = 0; - object->vertex_declaration[0] = empty_declaration; - object->fvf = 0; - object->bones = NULL; - - *iface = &object->ID3DXSkinInfo_iface; - return D3D_OK; -} diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index ed82bcfbbdb..11a0ee1a2fe 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -27,8 +27,6 @@ #include "ole2.h" #include "wincodec.h" -#include "wine/wined3d.h" - WINE_DEFAULT_DEBUG_CHANNEL(d3dx); @@ -112,7 +110,6 @@ static const GUID *d3dformat_to_wic_guid(D3DFORMAT format) #define DDS_PF_RGB 0x40 #define DDS_PF_YUV 0x200 #define DDS_PF_LUMINANCE 0x20000 -#define DDS_PF_BUMPLUMINANCE 0x40000 #define DDS_PF_BUMPDUDV 0x80000 struct dds_pixel_format @@ -268,17 +265,6 @@ static D3DFORMAT dds_bump_to_d3dformat(const struct dds_pixel_format *pixel_form return D3DFMT_UNKNOWN; } -static D3DFORMAT dds_bump_luminance_to_d3dformat(const struct dds_pixel_format *pixel_format) -{ - if (pixel_format->bpp == 32 && pixel_format->rmask == 0x000000ff && pixel_format->gmask == 0x0000ff00 - && pixel_format->bmask == 0x00ff0000) - return D3DFMT_X8L8V8U8; - - WARN("Unknown bump pixel format (%u, %#x, %#x, %#x, %#x)\n", pixel_format->bpp, - pixel_format->rmask, pixel_format->gmask, pixel_format->bmask, pixel_format->amask); - return D3DFMT_UNKNOWN; -} - static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pixel_format) { TRACE("pixel_format: size %u, flags %#x, fourcc %#x, bpp %u.\n", pixel_format->size, @@ -296,8 +282,6 @@ static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pi return dds_alpha_to_d3dformat(pixel_format); if (pixel_format->flags & DDS_PF_BUMPDUDV) return dds_bump_to_d3dformat(pixel_format); - if (pixel_format->flags & DDS_PF_BUMPLUMINANCE) - return dds_bump_luminance_to_d3dformat(pixel_format); WARN("Unknown pixel format (flags %#x, fourcc %#x, bpp %u, r %#x, g %#x, b %#x, a %#x)\n", pixel_format->flags, pixel_format->fourcc, pixel_format->bpp, @@ -328,14 +312,6 @@ static HRESULT d3dformat_to_dds_pixel_format(struct dds_pixel_format *pixel_form } } - /* Reuse dds_fourcc_to_d3dformat as D3DFORMAT and FOURCC are DWORD with same values */ - if (dds_fourcc_to_d3dformat(d3dformat) != D3DFMT_UNKNOWN) - { - pixel_format->flags |= DDS_PF_FOURCC; - pixel_format->fourcc = d3dformat; - return D3D_OK; - } - WARN("Unknown pixel format %#x\n", d3dformat); return E_NOTIMPL; } @@ -544,68 +520,6 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur return D3D_OK; } -static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, - int face, UINT level, struct IDirect3DSurface9 **surf) -{ - switch (type) - { - case D3DRTYPE_TEXTURE: - return IDirect3DTexture9_GetSurfaceLevel((IDirect3DTexture9*) tex, level, surf); - case D3DRTYPE_CUBETEXTURE: - return IDirect3DCubeTexture9_GetCubeMapSurface((IDirect3DCubeTexture9*) tex, face, level, surf); - default: - ERR("Unexpected texture type\n"); - return E_NOTIMPL; - } -} - -HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette) -{ - HRESULT hr; - D3DRESOURCETYPE type; - UINT mip_levels; - IDirect3DSurface9 *surface; - - type = IDirect3DBaseTexture9_GetType(src_texture); - - if ((type != D3DRTYPE_TEXTURE) && (type != D3DRTYPE_CUBETEXTURE) && (type != D3DRTYPE_VOLUMETEXTURE)) - return D3DERR_INVALIDCALL; - - if (type == D3DRTYPE_CUBETEXTURE) - { - FIXME("Cube texture not supported yet\n"); - return E_NOTIMPL; - } - else if (type == D3DRTYPE_VOLUMETEXTURE) - { - FIXME("Volume texture not supported yet\n"); - return E_NOTIMPL; - } - - mip_levels = IDirect3DTexture9_GetLevelCount(src_texture); - - if (mip_levels > 1) - { - FIXME("Mipmap not supported yet\n"); - return E_NOTIMPL; - } - - if (src_palette) - { - FIXME("Saving surfaces with palettized pixel formats not implemented yet\n"); - return E_NOTIMPL; - } - - hr = get_surface(type, src_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface); - - if (SUCCEEDED(hr)) - { - hr = save_dds_surface_to_memory(dst_buffer, surface, NULL); - IDirect3DSurface9_Release(surface); - } - - return hr; -} HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) @@ -973,24 +887,6 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, } } - /* For 32 bpp BMP, windowscodecs.dll never returns a format with alpha while - * d3dx9_xx.dll returns one if at least 1 pixel has a non zero alpha component */ - if (SUCCEEDED(hr) && (info->Format == D3DFMT_X8R8G8B8) && (info->ImageFileFormat == D3DXIFF_BMP)) { - DWORD size = sizeof(DWORD) * info->Width * info->Height; - BYTE *buffer = HeapAlloc(GetProcessHeap(), 0, size); - hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, sizeof(DWORD) * info->Width, size, buffer); - if (SUCCEEDED(hr)) { - DWORD i; - for (i = 0; i < info->Width * info->Height; i++) { - if (buffer[i*4+3]) { - info->Format = D3DFMT_A8R8G8B8; - break; - } - } - } - HeapFree(GetProcessHeap(), 0, buffer); - } - if (frame) IWICBitmapFrameDecode_Release(frame); @@ -1819,24 +1715,6 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic } } -typedef BOOL (*dxtn_conversion_func)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, - enum wined3d_format_id format, unsigned int w, unsigned int h); - -static dxtn_conversion_func get_dxtn_conversion_func(D3DFORMAT format, BOOL encode) -{ - switch (format) - { - case D3DFMT_DXT1: - return encode ? wined3d_dxt1_encode : wined3d_dxt1_decode; - case D3DFMT_DXT3: - return encode ? wined3d_dxt3_encode : wined3d_dxt3_decode; - case D3DFMT_DXT5: - return encode ? wined3d_dxt5_encode : wined3d_dxt5_decode; - default: - return NULL; - } -} - /************************************************************ * D3DXLoadSurfaceFromMemory * @@ -1875,14 +1753,12 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, DWORD filter, D3DCOLOR color_key) { const struct pixel_format_desc *srcformatdesc, *destformatdesc; - void *tmp_src_memory = NULL, *tmp_dst_memory = NULL; - dxtn_conversion_func pre_convert = NULL, post_convert = NULL; IDirect3DSurface9 *surface = dst_surface; IDirect3DDevice9 *device; D3DSURFACE_DESC surfdesc; D3DLOCKED_RECT lockrect; struct volume src_size, dst_size; - HRESULT hr = D3D_OK; + HRESULT hr; TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s, %#x, 0x%08x)\n", dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_memory, src_format, @@ -1980,65 +1856,18 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, } else /* Stretching or format conversion. */ { - UINT tmp_src_pitch, tmp_dst_pitch; - - pre_convert = get_dxtn_conversion_func(srcformatdesc->format, FALSE); - post_convert = get_dxtn_conversion_func(destformatdesc->format, TRUE); - - if ((!pre_convert && !is_conversion_from_supported(srcformatdesc)) || - (!post_convert && !is_conversion_to_supported(destformatdesc))) + if (!is_conversion_from_supported(srcformatdesc) + || !is_conversion_to_supported(destformatdesc)) { FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format); hr = E_NOTIMPL; goto done; } - /* handle pre-conversion */ - if (pre_convert) - { - tmp_src_memory = HeapAlloc(GetProcessHeap(), 0, src_size.width * src_size.height * sizeof(DWORD)); - if (!tmp_src_memory) - { - hr = E_OUTOFMEMORY; - goto done; - } - tmp_src_pitch = src_size.width * sizeof(DWORD); - if (!pre_convert(src_memory, tmp_src_memory, src_pitch, tmp_src_pitch, - WINED3DFMT_B8G8R8A8_UNORM, src_size.width, src_size.height)) - { - hr = E_FAIL; - goto done; - } - srcformatdesc = get_format_info(D3DFMT_A8R8G8B8); - } - else - { - tmp_src_memory = (void *)src_memory; - tmp_src_pitch = src_pitch; - } - - /* handle post-conversion */ - if (post_convert) - { - tmp_dst_memory = HeapAlloc(GetProcessHeap(), 0, dst_size.width * dst_size.height * sizeof(DWORD)); - if (!tmp_dst_memory) - { - hr = E_OUTOFMEMORY; - goto done; - } - tmp_dst_pitch = dst_size.width * sizeof(DWORD); - destformatdesc = get_format_info(D3DFMT_A8R8G8B8); - } - else - { - tmp_dst_memory = lockrect.pBits; - tmp_dst_pitch = lockrect.Pitch; - } - if ((filter & 0xf) == D3DX_FILTER_NONE) { - convert_argb_pixels(tmp_src_memory, tmp_src_pitch, 0, &src_size, srcformatdesc, - tmp_dst_memory, tmp_dst_pitch, 0, &dst_size, destformatdesc, color_key, src_palette); + convert_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc, + lockrect.pBits, lockrect.Pitch, 0, &dst_size, destformatdesc, color_key, src_palette); } else /* if ((filter & 0xf) == D3DX_FILTER_POINT) */ { @@ -2047,22 +1876,12 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, /* Always apply a point filter until D3DX_FILTER_LINEAR, * D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */ - point_filter_argb_pixels(tmp_src_memory, tmp_src_pitch, 0, &src_size, srcformatdesc, - tmp_dst_memory, tmp_dst_pitch, 0, &dst_size, destformatdesc, color_key, src_palette); - } - - /* handle post-conversion */ - if (post_convert) - { - if (!post_convert(tmp_dst_memory, lockrect.pBits, tmp_dst_pitch, lockrect.Pitch, - WINED3DFMT_B8G8R8A8_UNORM, dst_size.width, dst_size.height)) - { - hr = E_FAIL; - goto done; - } + point_filter_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc, + lockrect.pBits, lockrect.Pitch, 0, &dst_size, destformatdesc, color_key, src_palette); } } + hr = D3D_OK; done: IDirect3DSurface9_UnlockRect(surface); if (surface != dst_surface) @@ -2074,12 +1893,6 @@ done: IDirect3DDevice9_Release(device); } IDirect3DSurface9_Release(surface); - - if (pre_convert) - HeapFree(GetProcessHeap(), 0, tmp_src_memory); - if (post_convert) - HeapFree(GetProcessHeap(), 0, tmp_dst_memory); - IDirect3DSurface9_UnlockRect(dst_surface); } return hr; diff --git a/dll/directx/wine/d3dx9_36/texture.c b/dll/directx/wine/d3dx9_36/texture.c index 7a84d8c12a1..0f53d95bf1f 100644 --- a/dll/directx/wine/d3dx9_36/texture.c +++ b/dll/directx/wine/d3dx9_36/texture.c @@ -335,10 +335,10 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN if (fmt->block_width != 1 || fmt->block_height != 1) { - if (w % fmt->block_width) - w += fmt->block_width - w % fmt->block_width; - if (h % fmt->block_height) - h += fmt->block_height - h % fmt->block_height; + if (w < fmt->block_width) + w = fmt->block_width; + if (h < fmt->block_height) + h = fmt->block_height; } if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w))) @@ -1892,7 +1892,10 @@ HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE if (!dst_buffer || !src_texture) return D3DERR_INVALIDCALL; if (file_format == D3DXIFF_DDS) - return save_dds_texture_to_memory(dst_buffer, src_texture, src_palette); + { + FIXME("DDS file format isn't supported yet\n"); + return E_NOTIMPL; + } type = IDirect3DBaseTexture9_GetType(src_texture); switch (type) diff --git a/dll/directx/wine/d3dx9_36/util.c b/dll/directx/wine/d3dx9_36/util.c index 029e50073c3..af71250b785 100644 --- a/dll/directx/wine/d3dx9_36/util.c +++ b/dll/directx/wine/d3dx9_36/util.c @@ -90,7 +90,6 @@ static const struct pixel_format_desc formats[] = {D3DFMT_G32R32F, { 0, 32, 32, 0}, { 0, 0, 32, 0}, 8, 1, 1, 8, FORMAT_ARGBF, NULL, NULL }, {D3DFMT_A32B32G32R32F, {32, 32, 32, 32}, {96, 0, 32, 64}, 16, 1, 1, 16, FORMAT_ARGBF, NULL, NULL }, {D3DFMT_P8, { 8, 8, 8, 8}, { 0, 0, 0, 0}, 1, 1, 1, 1, FORMAT_INDEX, NULL, index_to_rgba}, - {D3DFMT_X8L8V8U8, { 0, 8, 8, 8}, { 0, 0, 8, 16}, 4, 1, 1, 4, FORMAT_ARGB, NULL, NULL }, /* marks last element */ {D3DFMT_UNKNOWN, { 0, 0, 0, 0}, { 0, 0, 0, 0}, 0, 1, 1, 0, FORMAT_UNKNOWN, NULL, NULL }, }; diff --git a/dll/directx/wine/d3dx9_37/d3dx9_37.spec b/dll/directx/wine/d3dx9_37/d3dx9_37.spec index 1e035f76c1a..692321d9065 100644 --- a/dll/directx/wine/d3dx9_37/d3dx9_37.spec +++ b/dll/directx/wine/d3dx9_37/d3dx9_37.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -229,7 +229,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_38/d3dx9_38.spec b/dll/directx/wine/d3dx9_38/d3dx9_38.spec index 1e035f76c1a..692321d9065 100644 --- a/dll/directx/wine/d3dx9_38/d3dx9_38.spec +++ b/dll/directx/wine/d3dx9_38/d3dx9_38.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -229,7 +229,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_39/d3dx9_39.spec b/dll/directx/wine/d3dx9_39/d3dx9_39.spec index 1e035f76c1a..692321d9065 100644 --- a/dll/directx/wine/d3dx9_39/d3dx9_39.spec +++ b/dll/directx/wine/d3dx9_39/d3dx9_39.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -229,7 +229,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_40/d3dx9_40.spec b/dll/directx/wine/d3dx9_40/d3dx9_40.spec index 1e035f76c1a..692321d9065 100644 --- a/dll/directx/wine/d3dx9_40/d3dx9_40.spec +++ b/dll/directx/wine/d3dx9_40/d3dx9_40.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -229,7 +229,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_41/d3dx9_41.spec b/dll/directx/wine/d3dx9_41/d3dx9_41.spec index 1e035f76c1a..692321d9065 100644 --- a/dll/directx/wine/d3dx9_41/d3dx9_41.spec +++ b/dll/directx/wine/d3dx9_41/d3dx9_41.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -229,7 +229,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_42/d3dx9_42.spec b/dll/directx/wine/d3dx9_42/d3dx9_42.spec index 6be1e96b7f4..936ae902dea 100644 --- a/dll/directx/wine/d3dx9_42/d3dx9_42.spec +++ b/dll/directx/wine/d3dx9_42/d3dx9_42.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -222,7 +222,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_43/d3dx9_43.spec b/dll/directx/wine/d3dx9_43/d3dx9_43.spec index 6be1e96b7f4..936ae902dea 100644 --- a/dll/directx/wine/d3dx9_43/d3dx9_43.spec +++ b/dll/directx/wine/d3dx9_43/d3dx9_43.spec @@ -24,7 +24,7 @@ @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) @ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -222,7 +222,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr)
4 years, 10 months
1
0
0
0
← Newer
1
...
5
6
7
8
9
10
11
...
24
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Results per page:
10
25
50
100
200