=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3dx9: Implement volume texture filtering in D3DXFilterTexture.
Alexandre Julliard
julliard at winehq.org
Mon Jul 16 14:14:29 CDT 2012
Module: wine
Branch: master
Commit: ffe36a3894356f6e23107eb7f0fd1c87d0d71f14
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ffe36a3894356f6e23107eb7f0fd1c87d0d71f14
Author: Józef Kucia <joseph.kucia at gmail.com>
Date: Fri Jul 13 17:21:55 2012 +0200
d3dx9: Implement volume texture filtering in D3DXFilterTexture.
---
dlls/d3dx9_36/tests/texture.c | 27 ++++++++++++++++++++++
dlls/d3dx9_36/texture.c | 49 ++++++++++++++++++++++++++++++++++++----
2 files changed, 71 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c
index 44bf235..95e1dc5 100644
--- a/dlls/d3dx9_36/tests/texture.c
+++ b/dlls/d3dx9_36/tests/texture.c
@@ -751,6 +751,7 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device)
{
IDirect3DTexture9 *tex;
IDirect3DCubeTexture9 *cubetex;
+ IDirect3DVolumeTexture9 *voltex;
HRESULT hr;
hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 5, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex, NULL);
@@ -835,6 +836,32 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device)
else
skip("Failed to create texture\n");
+ /* Volume texture test */
+ hr = IDirect3DDevice9_CreateVolumeTexture(device, 256, 256, 4, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &voltex, NULL);
+ if (SUCCEEDED(hr))
+ {
+ DWORD level_count = IDirect3DVolumeTexture9_GetLevelCount(voltex);
+
+ hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_FILTER_NONE);
+ ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
+
+ hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_DEFAULT);
+ ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
+
+ hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_FILTER_BOX);
+ ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
+
+ hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, level_count - 1, D3DX_DEFAULT);
+ ok(hr == D3D_OK, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3D_OK);
+
+ hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, level_count, D3DX_DEFAULT);
+ ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
+
+ IDirect3DVolumeTexture9_Release(voltex);
+ }
+ else
+ skip("Failed to create volume texture\n");
+
/* Test textures with D3DUSAGE_AUTOGENMIPMAP usage */
if (!is_autogenmipmap_supported(device, D3DRTYPE_TEXTURE))
{
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index 91f97c2..ec9bad9 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -61,8 +61,8 @@ static HRESULT get_surface(D3DRESOURCETYPE type, LPDIRECT3DBASETEXTURE9 tex,
}
}
-HRESULT WINAPI D3DXFilterTexture(LPDIRECT3DBASETEXTURE9 texture,
- CONST PALETTEENTRY *palette,
+HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture,
+ const PALETTEENTRY *palette,
UINT srclevel,
DWORD filter)
{
@@ -70,7 +70,7 @@ HRESULT WINAPI D3DXFilterTexture(LPDIRECT3DBASETEXTURE9 texture,
HRESULT hr;
D3DRESOURCETYPE type;
- TRACE("(%p, %p, %d, %d)\n", texture, palette, srclevel, filter);
+ TRACE("(%p, %p, %u, %#x)\n", texture, palette, srclevel, filter);
if (!texture)
return D3DERR_INVALIDCALL;
@@ -137,9 +137,48 @@ HRESULT WINAPI D3DXFilterTexture(LPDIRECT3DBASETEXTURE9 texture,
return D3D_OK;
}
+ case D3DRTYPE_VOLUMETEXTURE:
+ {
+ D3DVOLUME_DESC desc;
+ int level, level_count;
+ IDirect3DVolume9 *top_volume, *mip_volume;
+ IDirect3DVolumeTexture9 *volume_texture = (IDirect3DVolumeTexture9*) texture;
+
+ IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, srclevel, &desc);
+
+ if (filter == D3DX_DEFAULT)
+ {
+ if (is_pow2(desc.Width) && is_pow2(desc.Height) && is_pow2(desc.Depth))
+ filter = D3DX_FILTER_BOX;
+ else
+ filter = D3DX_FILTER_BOX | D3DX_FILTER_DITHER;
+ }
+
+ hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, srclevel, &top_volume);
+ if (FAILED(hr))
+ return hr;
+
+ level_count = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
+ for (level = srclevel + 1; level < level_count; level++)
+ {
+ IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, level, &mip_volume);
+ hr = D3DXLoadVolumeFromVolume(mip_volume, palette, NULL, top_volume, palette, NULL, filter, 0);
+ IDirect3DVolume9_Release(top_volume);
+ top_volume = mip_volume;
+
+ if (FAILED(hr))
+ break;
+ }
+
+ IDirect3DVolume9_Release(top_volume);
+ if (FAILED(hr))
+ return hr;
+
+ return D3D_OK;
+ }
+
default:
- FIXME("Implement volume texture filtering\n");
- return E_NOTIMPL;
+ return D3DERR_INVALIDCALL;
}
}
More information about the wine-cvs
mailing list