Sign in to follow this  
domin

D3DUSAGE_RENDERTARGET and power of 2 textures

Recommended Posts

Hi, if I create a texture with D3DUSAGE_RENDERTARGET usage it is still needed to keep its dimension of power of two? I have checked MS samples and they once create texture like that - just taking width and height from backbuffer (PostProcess sample):
pd3dDevice->CreateTexture(pBackBufferSurfaceDesc->Width,
                          pBackBufferSurfaceDesc->Height,
                          1,
                          D3DUSAGE_RENDERTARGET,
                          D3DFMT_A8R8G8B8,
                          D3DPOOL_DEFAULT,
                          &pRT[t],
                          NULL);

... but in other sample (VMR9Allocator) they first check if device has D3DPTEXTURECAPS_POW2 set and if yes they rounded tex dimensions to power of two:
if (d3dcaps.TextureCaps & D3DPTEXTURECAPS_POW2)
{
    DWORD dwWidth = 1;
    DWORD dwHeight = 1;

    while( dwWidth < lpAllocInfo->dwWidth )
        dwWidth = dwWidth << 1;

    while( dwHeight < lpAllocInfo->dwHeight )
        dwHeight = dwHeight << 1;

[...]

    lpAllocInfo->dwWidth = dwWidth;
    lpAllocInfo->dwHeight = dwHeight;
}

... and then create the render target text with this dimensions:
m_D3DDev->CreateTexture(lpAllocInfo->dwWidth,
                        lpAllocInfo->dwHeight,
                        1,
                        D3DUSAGE_RENDERTARGET, 
                        dm.Format, 
                        D3DPOOL_DEFAULT, 
                        &m_privateTexture, NULL);

So, I'm little confused with this... Please help.

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