Does direct3d initialize a newly created texture

383 views Asked by At

if you create a new empty texture e.g. with

IDirect3DDevice9::CreateTexture or D3DXCreateTexture

Is it guaranteed to be filled with zeros - as it appears to me by testing? Does anybody have a link to a statement from microsoft about this? I could not find anything.

2

There are 2 answers

0
ssube On BEST ANSWER

No, there is no stated guarantee (that I've ever seen). In fact, I've seen a good bit of the opposite behavior: data from previous (deallocated) textures and seemingly random data appearing.

However, the behavior between textures differs greatly depending on where the texture is allocated in the format. Allocating in system memory or with some of the shared pools could cause the data to be zeroed out, if the CPU so desires. Typically, when allocating in video memory, this does not occur. There may also be differences between IDirect3DDevice9::CreateTexture and D3DXCreateTexture; D3DX often does more initialization or provides options for such.

If you are seeing the texture appear zero-filled, that may be due to debug builds or a fresh system. Run some other graphics applications and then try running a release build (make sure your system is not set to D3D debug mode).

0
Unknown1987 On

If you look at the DXGI API and DX10+ DDI the driver has many opportunities to zero fill requested memory by DXGI/D3D. That being said as no API guarantees are made about memory being zero filled, I would not rely on it.