d3dx9: Correctly handle D3DUSAGE_AUTOGENMIPMAP in D3DXCheckTextureRequirements.
This commit is contained in:
parent
979099a441
commit
dfc085b684
|
@ -85,6 +85,29 @@ static const unsigned char dds_volume_map[] = {
|
||||||
0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab
|
0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
D3DCAPS9 caps;
|
||||||
|
IDirect3D9 *d3d9;
|
||||||
|
D3DDISPLAYMODE mode;
|
||||||
|
D3DDEVICE_CREATION_PARAMETERS params;
|
||||||
|
|
||||||
|
IDirect3DDevice9_GetDeviceCaps(device, &caps);
|
||||||
|
IDirect3DDevice9_GetDirect3D(device, &d3d9);
|
||||||
|
IDirect3DDevice9_GetCreationParameters(device, ¶ms);
|
||||||
|
IDirect3DDevice9_GetDisplayMode(device, 0, &mode);
|
||||||
|
|
||||||
|
if (!(caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
hr = IDirect3D9_CheckDeviceFormat(d3d9, params.AdapterOrdinal, params.DeviceType,
|
||||||
|
mode.Format, D3DUSAGE_AUTOGENMIPMAP, resource_type, D3DFMT_A8R8G8B8);
|
||||||
|
|
||||||
|
IDirect3D9_Release(d3d9);
|
||||||
|
return SUCCEEDED(hr);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
|
static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
|
||||||
{
|
{
|
||||||
UINT width, height, mipmaps;
|
UINT width, height, mipmaps;
|
||||||
|
@ -199,6 +222,29 @@ static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
|
||||||
ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
|
ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
|
||||||
|
|
||||||
|
/* mipmaps when D3DUSAGE_AUTOGENMIPMAP is set */
|
||||||
|
if (is_autogenmipmap_supported(device, D3DRTYPE_TEXTURE))
|
||||||
|
{
|
||||||
|
mipmaps = 0;
|
||||||
|
hr = D3DXCheckTextureRequirements(device, NULL, NULL, &mipmaps, D3DUSAGE_AUTOGENMIPMAP, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
|
||||||
|
mipmaps = 1;
|
||||||
|
hr = D3DXCheckTextureRequirements(device, NULL, NULL, &mipmaps, D3DUSAGE_AUTOGENMIPMAP, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
|
||||||
|
mipmaps = 2;
|
||||||
|
hr = D3DXCheckTextureRequirements(device, NULL, NULL, &mipmaps, D3DUSAGE_AUTOGENMIPMAP, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
|
||||||
|
mipmaps = 6;
|
||||||
|
hr = D3DXCheckTextureRequirements(device, NULL, NULL, &mipmaps, D3DUSAGE_AUTOGENMIPMAP, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
skip("No D3DUSAGE_AUTOGENMIPMAP support for textures\n");
|
||||||
|
|
||||||
/* usage */
|
/* usage */
|
||||||
hr = D3DXCheckTextureRequirements(device, NULL, NULL, NULL, D3DUSAGE_WRITEONLY, NULL, D3DPOOL_DEFAULT);
|
hr = D3DXCheckTextureRequirements(device, NULL, NULL, NULL, D3DUSAGE_WRITEONLY, NULL, D3DPOOL_DEFAULT);
|
||||||
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
|
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
|
||||||
|
@ -322,6 +368,16 @@ static void test_D3DXCheckCubeTextureRequirements(IDirect3DDevice9 *device)
|
||||||
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
|
ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
|
||||||
|
|
||||||
|
if (is_autogenmipmap_supported(device, D3DRTYPE_CUBETEXTURE))
|
||||||
|
{
|
||||||
|
mipmaps = 3;
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, &mipmaps, D3DUSAGE_AUTOGENMIPMAP, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(mipmaps == 0, "Returned mipmaps %d, expected %d\n", mipmaps, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
skip("No D3DUSAGE_AUTOGENMIPMAP support for cube textures\n");
|
||||||
|
|
||||||
/* usage */
|
/* usage */
|
||||||
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, D3DUSAGE_WRITEONLY, NULL, D3DPOOL_DEFAULT);
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, D3DUSAGE_WRITEONLY, NULL, D3DPOOL_DEFAULT);
|
||||||
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
|
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
|
||||||
|
|
|
@ -216,7 +216,12 @@ HRESULT WINAPI D3DXCheckTextureRequirements(LPDIRECT3DDEVICE9 device,
|
||||||
*height = h;
|
*height = h;
|
||||||
|
|
||||||
/* miplevels */
|
/* miplevels */
|
||||||
if (miplevels)
|
if (miplevels && (usage & D3DUSAGE_AUTOGENMIPMAP))
|
||||||
|
{
|
||||||
|
if (*miplevels > 1)
|
||||||
|
*miplevels = 0;
|
||||||
|
}
|
||||||
|
else if (miplevels)
|
||||||
{
|
{
|
||||||
UINT max_mipmaps = 1;
|
UINT max_mipmaps = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue