Force textures into texture memory

Force textures into texture memory

Post by Sebastian » Sun, 27 Nov 2005 01:16:34


Hi,

I'm creating a bunch of "unsigned short" textures using

m_d3d9_device->CreateTexture(
width[i],
height[i],
1,
D3DUSAGE_DYNAMIC,
D3DFMT_L16,
D3DPOOL_DEFAULT,
&m_proj_tex_array[i],
NULL
)

I suspect the texture go to AGP memory instead of texture memory on the
GPU. Is there a way to query an entry in m_proj_tex_array if it resides
in AGP or texture memory?

Moreover, is there a way to force textures in GPU texture memory (and
fail if there is none left, instead of using AGP memory)? Something like
D3DPOOL_GPU? It seems there is not better choice than D3DPOOL_DEFAULT.

Another guess I have is that the textures go to AGP memory because of
the D3DUSAGE_DYNAMIC flag. I use this flag to be able to lock / memcpy /
unlock the texture instead of calling D3DXLoadSurfaceFromMemory, because
memcpy seems much faster. If i change D3DUSAGE_DYNAMIC to 0, would that
guarantee my textures to go to GPU texture memory?

Thanks.

--
Sebastian Schuberth
(remove "NOSP" and "M" from my e-mail address)
 
 
 

Force textures into texture memory

Post by Eyal Tele » Mon, 28 Nov 2005 18:35:48

There's typically no need to define textures in the default pool
(unless they are render targets, for example). Textures in the managed
pool can be locked even if they're not dynamic.

Dynamic textures are those which can change several times per frame,
and typically get thrown after use. If your texture gets updated only
once per frame or less, you can typically make it a non-dynamic
texture in the managed pool.

Direct3D offers no direct control over the location of textures. In
fact, even Direct3D doesn't have full control, since the drivers can
override things. It's more likely, though, that if your texture is not
dynamic, it will be loaded to the card. For mangaged textures (and any
resources) you can call PreLoad() to get the texture into card memory,
but it's not guaranteed, either.

In short, use the managed pool and non-dynamic textures unless they
really change a lot, and you should get decent behaviour.

Eyal

 
 
 

Force textures into texture memory

Post by Sebastian » Mon, 28 Nov 2005 19:22:50

Thanks a lot for your answer, I will try that. So is there also no way
to get to know where texture was put after creating / uploading it (even
if it's too late then anyways)?

--
Sebastian Schuberth
(Remove "NOSP" and "M" from my e-mail address)
 
 
 

Force textures into texture memory

Post by Eyal Tele » Mon, 28 Nov 2005 19:35:52


No. You may be able to find documents on IHV sites about texture
placement. I remember that there was some old doc on NVIDIA's site
which described where textures were placed and when they were loaded,
but don't know how to find it or whether it's still relevant with new
drivers.

Eyal