Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do DirectX Textures share/reduce Address Space of the (32 Bit) Application?

Tags:

32-bit

directx

Imagine this:

  • a 32 bit application which has 2 GB address space and can therefore allocate at max 2 GB of memory (let fragmentation beside)
  • a Graphic card with 1 GB of graphics memory

When the application uses e.g. 1.5 GB of memory, can it allocate another 1 GB of textures? It would use in sum 2.5 GB of memory which is not possible for the 32 bit application itself.

AFAIK textures are only mapped into the address space of the application when it "locks" the texture to get a pointer to the memory. So my assumption is the address space is only needed during the lock. As only some textures are locked it shouldn't consume the whole address space.

like image 341
Steffen Binas Avatar asked Nov 28 '25 03:11

Steffen Binas


1 Answers

When the application uses e.g. 1.5 GB of memory, can it allocate another 1 GB of textures?

There is no simple answer to this because textures can be allocated in video memory but they can be on system memory too.

So it depends on the usage.

Take this constructor and note the Pool parameter:

public Texture(
    Device device,
    int width,
    int height,
    int numLevels,
    Usage usage,
    Format format,
    Pool pool
)

If you choose Pool.VideoMemory then the data is placed in video memory and only a few members using a few bytes are stored in system memory. If you choose Pool.SystemMemory then of course you use memory allocation space.

When you get the surface pointer of a video memory texture and use lock bits:

surface->LockRect(&bits,0,0)

You are actually allocating a new variable in local memory called bits. So the answer to this type of texture is still no. Another variable uses memory allocation space and that is the variable you get bits back into.

DX textures allocated on the VideoMemory Pool use only a few bytes of system memory for allocation.

Hope that helps, Mars.

like image 154
Marino Šimić Avatar answered Dec 02 '25 05:12

Marino Šimić