Sign in to follow this  
Brisco

How to determine size of textures (in bytes)

Recommended Posts

Hello! I have a question about textures in DirectX... I need to know the size of a texture - or better, the size of every mip level considering the used format. This is no problem for uncompressed textures, I simply determine the dimensions of a mip level and multiply them with the bytes that are required per pixel for the specified format... but what about compressed textures? I think there should be a way to determine the required memory?

Share this post


Link to post
Share on other sites
If you know the initial size I believe the sizes work in the following manner
Eg.

256 x 256
128 x 128
64 x 64

That's how it will work, you will also want to specify the number of mipmap levels to create...

Eg.
From the SDK Docs.
"The following example shows how your application can call the IDirect3DDevice9::CreateTexture method to build a chain of five mipmap levels: 256x256, 128x128, 64x64, 32x32, and 16x16.

// This code example assumes that m_d3dDevice is a
// valid pointer to a IDirect3DDevice9 interface

IDirect3DTexture9 * pMipMap;
m_pD3DDevice->CreateTexture(256, 256, 5, 0, D3DFMT_R8G8B8,
D3DPOOL_MANAGED, &pMipMap);

"

Hope this helps a bit.

Share this post


Link to post
Share on other sites
That's right, but it doesn't help me to get the exact size in bytes of a compressed texture. In fact, I know the size of any mip level - and as long as the texture is not compressed, I also know the size in bytes because it can be easily calculated by width*height*bytesperpixel.

My goal is, to lock a texture and write the complete data into a file in my own format, this is part of an object persistence framework I have written, but to do this, I need to know the exact size in bytes.

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