Commit ffe36a38 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3dx9: Implement volume texture filtering in D3DXFilterTexture.

parent e8bfaf17
...@@ -751,6 +751,7 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device) ...@@ -751,6 +751,7 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device)
{ {
IDirect3DTexture9 *tex; IDirect3DTexture9 *tex;
IDirect3DCubeTexture9 *cubetex; IDirect3DCubeTexture9 *cubetex;
IDirect3DVolumeTexture9 *voltex;
HRESULT hr; HRESULT hr;
hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 5, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex, NULL); hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 5, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex, NULL);
...@@ -835,6 +836,32 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device) ...@@ -835,6 +836,32 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device)
else else
skip("Failed to create texture\n"); 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 */ /* Test textures with D3DUSAGE_AUTOGENMIPMAP usage */
if (!is_autogenmipmap_supported(device, D3DRTYPE_TEXTURE)) if (!is_autogenmipmap_supported(device, D3DRTYPE_TEXTURE))
{ {
......
...@@ -61,8 +61,8 @@ static HRESULT get_surface(D3DRESOURCETYPE type, LPDIRECT3DBASETEXTURE9 tex, ...@@ -61,8 +61,8 @@ static HRESULT get_surface(D3DRESOURCETYPE type, LPDIRECT3DBASETEXTURE9 tex,
} }
} }
HRESULT WINAPI D3DXFilterTexture(LPDIRECT3DBASETEXTURE9 texture, HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture,
CONST PALETTEENTRY *palette, const PALETTEENTRY *palette,
UINT srclevel, UINT srclevel,
DWORD filter) DWORD filter)
{ {
...@@ -70,7 +70,7 @@ HRESULT WINAPI D3DXFilterTexture(LPDIRECT3DBASETEXTURE9 texture, ...@@ -70,7 +70,7 @@ HRESULT WINAPI D3DXFilterTexture(LPDIRECT3DBASETEXTURE9 texture,
HRESULT hr; HRESULT hr;
D3DRESOURCETYPE type; D3DRESOURCETYPE type;
TRACE("(%p, %p, %d, %d)\n", texture, palette, srclevel, filter); TRACE("(%p, %p, %u, %#x)\n", texture, palette, srclevel, filter);
if (!texture) if (!texture)
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
...@@ -137,9 +137,48 @@ HRESULT WINAPI D3DXFilterTexture(LPDIRECT3DBASETEXTURE9 texture, ...@@ -137,9 +137,48 @@ HRESULT WINAPI D3DXFilterTexture(LPDIRECT3DBASETEXTURE9 texture,
return D3D_OK; 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: default:
FIXME("Implement volume texture filtering\n"); return D3DERR_INVALIDCALL;
return E_NOTIMPL;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment