Commit c1843c87 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dx9: Implement D3DXCheckVolumeTextureRequirements.

parent 363d180a
......@@ -7,7 +7,7 @@
@ stdcall D3DXCheckCubeTextureRequirements(ptr ptr ptr long ptr ptr)
@ stdcall D3DXCheckTextureRequirements(ptr ptr ptr ptr long ptr ptr)
@ stdcall D3DXCheckVersion(long long)
@ stub D3DXCheckVolumeTextureRequirements
@ stdcall D3DXCheckVolumeTextureRequirements(ptr ptr ptr ptr ptr long ptr ptr)
@ stub D3DXCleanMesh
@ stdcall D3DXColorAdjustContrast(ptr ptr float)
@ stdcall D3DXColorAdjustSaturation(ptr ptr float)
......
......@@ -278,6 +278,114 @@ static void test_D3DXCheckCubeTextureRequirements(IDirect3DDevice9 *device)
ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
}
static void test_D3DXCheckVolumeTextureRequirements(IDirect3DDevice9 *device)
{
UINT width, height, depth, mipmaps;
D3DFORMAT format;
D3DCAPS9 caps;
HRESULT hr;
IDirect3DDevice9_GetDeviceCaps(device, &caps);
if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP))
{
skip("No volume textures support\n");
return;
}
/* general tests */
hr = D3DXCheckVolumeTextureRequirements(device, NULL, NULL, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
hr = D3DXCheckVolumeTextureRequirements(device, NULL, NULL, NULL, NULL, D3DX_DEFAULT, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
hr = D3DXCheckVolumeTextureRequirements(NULL, NULL, NULL, NULL, NULL, D3DX_DEFAULT, NULL, D3DPOOL_DEFAULT);
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
/* width, height, depth */
width = height = depth = D3DX_DEFAULT;
hr = D3DXCheckVolumeTextureRequirements(device, &width, &height, &depth, NULL, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(width == 256, "Returned width %d, expected %d\n", width, 256);
ok(height == 256, "Returned height %d, expected %d\n", height, 256);
ok(depth == 1, "Returned depth %d, expected %d\n", depth, 1);
width = D3DX_DEFAULT;
hr = D3DXCheckVolumeTextureRequirements(device, &width, NULL, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(width == 256, "Returned width %d, expected %d\n", width, 256);
width = D3DX_DEFAULT; height = 0; depth = 0;
hr = D3DXCheckVolumeTextureRequirements(device, &width, &height, &depth, NULL, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(width == 1, "Returned width %d, expected %d\n", width, 1);
ok(height == 1, "Returned height %d, expected %d\n", height, 1);
ok(depth == 1, "Returned height %d, expected %d\n", depth, 1);
width = 0; height = 0; depth = 0;
hr = D3DXCheckVolumeTextureRequirements(device, &width, &height, &depth, NULL, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(width == 1, "Returned width %d, expected %d\n", width, 1);
ok(height == 1, "Returned height %d, expected %d\n", height, 1);
ok(depth == 1, "Returned height %d, expected %d\n", depth, 1);
width = 0;
hr = D3DXCheckVolumeTextureRequirements(device, &width, NULL, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(width == 1, "Returned width %d, expected %d\n", width, 1);
width = 0xFFFFFFFE;
hr = D3DXCheckVolumeTextureRequirements(device, &width, NULL, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(width == caps.MaxVolumeExtent, "Returned width %d, expected %d\n", width, caps.MaxVolumeExtent);
/* format */
hr = D3DXCheckVolumeTextureRequirements(device, NULL, NULL, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
format = D3DFMT_UNKNOWN;
hr = D3DXCheckVolumeTextureRequirements(device, NULL, NULL, NULL, NULL, 0, &format, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
format = D3DX_DEFAULT;
hr = D3DXCheckVolumeTextureRequirements(device, NULL, NULL, NULL, NULL, 0, &format, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
format = D3DFMT_R8G8B8;
hr = D3DXCheckVolumeTextureRequirements(device, NULL, NULL, NULL, NULL, 0, &format, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
/* mipmaps */
if (!(caps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP))
{
skip("No volume textures mipmapping support\n");
return;
}
width = height = depth = 64;
mipmaps = 9;
hr = D3DXCheckVolumeTextureRequirements(device, &width, &height, &depth, &mipmaps, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
width = 284;
height = 143;
depth = 55;
mipmaps = 20;
hr = D3DXCheckVolumeTextureRequirements(device, &width, &height, &depth, &mipmaps, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(mipmaps == 10, "Returned mipmaps %d, expected %d\n", mipmaps, 10);
mipmaps = 0;
hr = D3DXCheckVolumeTextureRequirements(device, NULL, NULL, NULL, &mipmaps, 0, NULL, D3DPOOL_DEFAULT);
ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
}
static void test_D3DXCreateTexture(IDirect3DDevice9 *device)
{
IDirect3DTexture9 *texture;
......@@ -581,6 +689,7 @@ START_TEST(texture)
test_D3DXCheckTextureRequirements(device);
test_D3DXCheckCubeTextureRequirements(device);
test_D3DXCheckVolumeTextureRequirements(device);
test_D3DXCreateTexture(device);
test_D3DXFilterTexture(device);
......
......@@ -383,6 +383,80 @@ HRESULT WINAPI D3DXCheckCubeTextureRequirements(LPDIRECT3DDEVICE9 device,
return hr;
}
HRESULT WINAPI D3DXCheckVolumeTextureRequirements(LPDIRECT3DDEVICE9 device,
UINT *width,
UINT *height,
UINT *depth,
UINT *miplevels,
DWORD usage,
D3DFORMAT *format,
D3DPOOL pool)
{
D3DCAPS9 caps;
UINT w = width ? *width : D3DX_DEFAULT;
UINT h = height ? *height : D3DX_DEFAULT;
UINT d = (depth && *depth) ? *depth : 1;
HRESULT hr;
TRACE("(%p, %p, %p, %p, %p, %u, %p, %u)\n", device, width, height, depth, miplevels,
usage, format, pool);
if (!device || FAILED(IDirect3DDevice9_GetDeviceCaps(device, &caps)))
return D3DERR_INVALIDCALL;
if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP))
return D3DERR_NOTAVAILABLE;
hr = D3DXCheckTextureRequirements(device, &w, &h, NULL, usage, format, pool);
if (d == D3DX_DEFAULT)
d = 1;
/* ensure width/height is power of 2 */
if ((caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP_POW2) &&
(!is_pow2(w) || !is_pow2(h) || !is_pow2(d)))
{
w = make_pow2(w);
h = make_pow2(h);
d = make_pow2(d);
}
if (w > caps.MaxVolumeExtent)
w = caps.MaxVolumeExtent;
if (h > caps.MaxVolumeExtent)
h = caps.MaxVolumeExtent;
if (d > caps.MaxVolumeExtent)
d = caps.MaxVolumeExtent;
if (miplevels)
{
if (!(caps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP))
*miplevels = 1;
else
{
UINT max_mipmaps = 1;
UINT max_dimen = max(max(w, h), d);
while (max_dimen > 1)
{
max_dimen >>= 1;
max_mipmaps++;
}
if (*miplevels == 0 || *miplevels > max_mipmaps)
*miplevels = max_mipmaps;
}
}
if (width)
*width = w;
if (height)
*height = h;
if (depth)
*depth = d;
return hr;
}
HRESULT WINAPI D3DXCreateTexture(LPDIRECT3DDEVICE9 pDevice,
UINT width,
UINT height,
......
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