Sign in to follow this  
Ebola0001

how to check texture capabilities

Recommended Posts

hey guys im using directx 9 and was wondering how large a texture the video card supports? my program uses a 2048 x 2048 map and runs fine on my desktop. It will run on my laptop, but it is much much slower. i guess my question is if the texture is too large, will directx resize it or will it just not work. the second part is what is the largest texture suggested anymore?

Share this post


Link to post
Share on other sites
For your second question, you could use this online Direct3D caps wizard to see what modern hardware supports. I think 9 series radeon's support at most 2048x2048 and geforce has supported up to 4096x4096 for a while.

For the first, I would expect creation of the texture to fail, but I am not completely sure as I haven't tested it [smile]

Regards,
ViLiO

Share this post


Link to post
Share on other sites
If the requested size is too large, the call will probably fail with D3DERR_INVALIDCALL or D3DERR_INVALIDPARAM. You can test that by trying to create a 65536x65536 texture or something and see what the function returns.

You can determine the largest texture the card supports by querying the caps like so:

LPDIRECT3D9 pD3D; // Your D3D pointer (Assume this is some valid pointer)
D3DCAPS9 theCaps;
HRESULT hResult = pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &theCaps);
if(FAILED(hResult))
{
// Something is very wrong
// Handle error (Probably exit app)
}



After that code, the maximum texture size will be in theCaps.MaxTextureWidth and theCaps.MaxTextureHeight. Most cards these days support non-square textures, but if you're targetting old hardware or if you just want completeness, it may be worthwhile checking if theCaps.TextureCaps contains D3DPTEXTURECAPS_SQUAREONLY. If it does, you can only create square textures.

D3DX will try to work around the limits of the device - it'll make power-of-2 textures where needed, and it'll make square textures where needed. As far as I know, it won't cope with textures that are too large though.

EDIT: Assuming a 32-bit texture, 2048x2048 will be 16MB. With mip-maps, you're looking much larger. Unless this is for a sprite sheet of some sort that will be staying in VRAM for a long period of time, I'd recommend breaking it down into several smaller textures. This will also allow your app to run on lower end cards.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this