Question

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.

Was it helpful?

Solution

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).

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top