d3dx9: Implement D3DXCheckCubeTextureRequirements.
This commit is contained in:
parent
a875f38301
commit
6933766531
|
@ -4,7 +4,7 @@
|
||||||
@ stdcall D3DXAssembleShaderFromResourceA(long str ptr ptr long ptr ptr)
|
@ stdcall D3DXAssembleShaderFromResourceA(long str ptr ptr long ptr ptr)
|
||||||
@ stdcall D3DXAssembleShaderFromResourceW(long wstr ptr ptr long ptr ptr)
|
@ stdcall D3DXAssembleShaderFromResourceW(long wstr ptr ptr long ptr ptr)
|
||||||
@ stdcall D3DXBoxBoundProbe(ptr ptr ptr ptr)
|
@ stdcall D3DXBoxBoundProbe(ptr ptr ptr ptr)
|
||||||
@ stub D3DXCheckCubeTextureRequirements
|
@ stdcall D3DXCheckCubeTextureRequirements(ptr ptr ptr long ptr ptr)
|
||||||
@ stdcall D3DXCheckTextureRequirements(ptr ptr ptr ptr long ptr ptr)
|
@ stdcall D3DXCheckTextureRequirements(ptr ptr ptr ptr long ptr ptr)
|
||||||
@ stdcall D3DXCheckVersion(long long)
|
@ stdcall D3DXCheckVersion(long long)
|
||||||
@ stub D3DXCheckVolumeTextureRequirements
|
@ stub D3DXCheckVolumeTextureRequirements
|
||||||
|
|
|
@ -92,11 +92,6 @@ 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(width == 1, "Returned width %d, expected %d\n", width, 1);
|
ok(width == 1, "Returned width %d, expected %d\n", width, 1);
|
||||||
|
|
||||||
width = D3DX_DEFAULT;
|
|
||||||
hr = D3DXCheckTextureRequirements(device, &width, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
|
|
||||||
ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
|
||||||
ok(width == 256, "Returned width %d, expected %d\n", width, 256);
|
|
||||||
|
|
||||||
width = 0xFFFFFFFE;
|
width = 0xFFFFFFFE;
|
||||||
hr = D3DXCheckTextureRequirements(device, &width, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
|
hr = D3DXCheckTextureRequirements(device, &width, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
|
||||||
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);
|
||||||
|
@ -196,6 +191,87 @@ static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
|
||||||
IDirect3D9_Release(d3d);
|
IDirect3D9_Release(d3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_D3DXCheckCubeTextureRequirements(IDirect3DDevice9 *device)
|
||||||
|
{
|
||||||
|
UINT size, mipmaps;
|
||||||
|
D3DFORMAT format;
|
||||||
|
D3DCAPS9 caps;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
IDirect3DDevice9_GetDeviceCaps(device, &caps);
|
||||||
|
|
||||||
|
/* general tests */
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, D3DX_DEFAULT, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(NULL, NULL, NULL, D3DX_DEFAULT, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
|
||||||
|
|
||||||
|
/* size */
|
||||||
|
size = D3DX_DEFAULT;
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, &size, NULL, 0, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(size == 256, "Returned size %d, expected %d\n", size, 256);
|
||||||
|
|
||||||
|
/* mipmaps */
|
||||||
|
size = 64;
|
||||||
|
mipmaps = 9;
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, &size, &mipmaps, 0, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
|
||||||
|
|
||||||
|
size = 284;
|
||||||
|
mipmaps = 20;
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, &size, &mipmaps, 0, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(mipmaps == 10, "Returned mipmaps %d, expected %d\n", mipmaps, 10);
|
||||||
|
|
||||||
|
size = 63;
|
||||||
|
mipmaps = 9;
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, &size, &mipmaps, 0, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(mipmaps == 7, "Returned mipmaps %d, expected %d\n", mipmaps, 7);
|
||||||
|
|
||||||
|
mipmaps = 0;
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, &mipmaps, 0, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(mipmaps == 9, "Returned mipmaps %d, expected %d\n", mipmaps, 9);
|
||||||
|
|
||||||
|
/* usage */
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, D3DUSAGE_WRITEONLY, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, D3DUSAGE_DONOTCLIP, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, D3DUSAGE_POINTS, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, D3DUSAGE_RTPATCHES, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, D3DUSAGE_NPATCHES, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3DERR_INVALIDCALL, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
|
||||||
|
|
||||||
|
/* format */
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, 0, NULL, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
|
||||||
|
format = D3DFMT_UNKNOWN;
|
||||||
|
hr = D3DXCheckCubeTextureRequirements(device, NULL, NULL, 0, &format, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements 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 = D3DXCheckCubeTextureRequirements(device, NULL, NULL, 0, &format, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements 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 = D3DXCheckCubeTextureRequirements(device, NULL, NULL, 0, &format, D3DPOOL_DEFAULT);
|
||||||
|
ok(hr == D3D_OK, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_D3DXCreateTexture(IDirect3DDevice9 *device)
|
static void test_D3DXCreateTexture(IDirect3DDevice9 *device)
|
||||||
{
|
{
|
||||||
IDirect3DTexture9 *texture;
|
IDirect3DTexture9 *texture;
|
||||||
|
@ -498,6 +574,7 @@ START_TEST(texture)
|
||||||
}
|
}
|
||||||
|
|
||||||
test_D3DXCheckTextureRequirements(device);
|
test_D3DXCheckTextureRequirements(device);
|
||||||
|
test_D3DXCheckCubeTextureRequirements(device);
|
||||||
test_D3DXCreateTexture(device);
|
test_D3DXCreateTexture(device);
|
||||||
test_D3DXFilterTexture(device);
|
test_D3DXFilterTexture(device);
|
||||||
|
|
||||||
|
|
|
@ -343,6 +343,46 @@ cleanup:
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI D3DXCheckCubeTextureRequirements(LPDIRECT3DDEVICE9 device,
|
||||||
|
UINT *size,
|
||||||
|
UINT *miplevels,
|
||||||
|
DWORD usage,
|
||||||
|
D3DFORMAT *format,
|
||||||
|
D3DPOOL pool)
|
||||||
|
{
|
||||||
|
D3DCAPS9 caps;
|
||||||
|
UINT s = (size && *size) ? *size : 256;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
TRACE("(%p, %p, %p, %u, %p, %u)\n", device, size, miplevels, usage, format, pool);
|
||||||
|
|
||||||
|
if (s == D3DX_DEFAULT)
|
||||||
|
s = 256;
|
||||||
|
|
||||||
|
if (!device || FAILED(IDirect3DDevice9_GetDeviceCaps(device, &caps)))
|
||||||
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
|
if (!(caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP))
|
||||||
|
return D3DERR_NOTAVAILABLE;
|
||||||
|
|
||||||
|
/* ensure width/height is power of 2 */
|
||||||
|
if ((caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) && (!is_pow2(s)))
|
||||||
|
s = make_pow2(s);
|
||||||
|
|
||||||
|
hr = D3DXCheckTextureRequirements(device, &s, &s, miplevels, usage, format, pool);
|
||||||
|
|
||||||
|
if (!(caps.TextureCaps & D3DPTEXTURECAPS_MIPCUBEMAP))
|
||||||
|
{
|
||||||
|
if(miplevels)
|
||||||
|
*miplevels = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
*size = s;
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT WINAPI D3DXCreateTexture(LPDIRECT3DDEVICE9 pDevice,
|
HRESULT WINAPI D3DXCreateTexture(LPDIRECT3DDEVICE9 pDevice,
|
||||||
UINT width,
|
UINT width,
|
||||||
UINT height,
|
UINT height,
|
||||||
|
|
Loading…
Reference in New Issue