• 14
• 15
• 9
• 10
• 9

# D3DUSAGE_RENDERTARGET and power of 2 textures

This topic is 4119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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);



##### Share on other sites
You don't need to respect the power of 2 caps for render-target textures if I recall correctly.