Sign in to follow this  
galapogos22

IDirect3DTexture9::GetLevelDesc levels

Recommended Posts

galapogos22    385
Just a quick question. When using IDirect3DTexture9::GetLevelDesc I am not sure what the UINT Level is for. I have been using 0 as a value and it seems to give good information about the texture in general but i would appreciate clarification on this texture Level value. HRESULT GetLevelDesc( UINT Level, D3DSURFACE_DESC * pDesc ); Is it something to do with IDirect3DTexture9::GetSurfaceLevel which i have not used as i am not sure what its about at all. All i am doing is retreiving some information about a texture. Also as an aside when looking at the MSDN info for IDirect3DTexture9::GetSurfaceLevel there is the folowing remark:-
Quote:
Calling this method will increase the internal reference count on the IDirect3DSurface9 interface. Failure to call IUnknown::Release when finished using this IDirect3DSurface9 interface results in a memory leak.
This confuses me evan more. Is the 'internal reference count on the IDirect3DSurface9 interface' the same thing as the 'UINT Level' in IDirect3DTexture9::GetLevelDesc?

Share this post


Link to post
Share on other sites
sirob    1181
A DirectX texture is actually a collection of surfaces. Each surface is a single "image", which might be what you think of when you hear the word "texture".

The use of multiple surfaces per texture is actually quite common. MIP mapping uses a decreasing-size-chain-of-surfaces. Each surface is half* the size of the previous. (* half is in each direction, width is half, and height is half)

Also, Cube textures and Volume textures have several actual surfaces (6 for cube + possible MIP maps and any number you specify for volume textures).

GetLevelDesc returns the description of a specific level. 0 is the first level, so for a normal 2d texture, this will be the largest MIP map, which is probably what you're looking for anyways. Though, you can get information for any level you want.

For Cube or Volume textures, locking a different level might make more sense.

As for GetSurfaceLevel, this returns an interface to the actual surface. This is a DX object, which means it's a COM object, and as such, it has a reference count. When you get the interface back from GetSurfaceLevel, the ref count is incremented for you. This means that when you're done with the surface you got from GetSurfaceLevel, you need to call Release on it, otherwise it will never actually be deleted (and you get a memory leak).

Hope this helps.

Share this post


Link to post
Share on other sites
galapogos22    385
Yes that did help imensly! thank you.

I assume GetSurfaceLevel() is used to get a handle of a surface (ie one of the mip map levels) as opposed to using all surfaces (the Texture as i think of it).

Is there an easy way of finding out what is on each level of the texture - the texture i was looking at is mip mapped - and if it is a volume/cubic texture what level is what surface?

Awesome - this is a whole new area for me to play with.

Thanks again.

Regards

galapogos

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