D3DLOCK

A combination of zero or more locking options that describe the type of lock to perform.

#define Description
D3DLOCK_DISCARD The application overwrites (with a write-only operation) every location within the locked surface. This is a valid option when using dynamic textures, dynamic vertex buffers, and dynamic index buffers. You may not use this option to update a portion of a surface.

For vertex and index buffers, the application discards the entire buffer. A pointer to a new memory area is returned so that the direct memory access (DMA) and rendering from the previous area do not stall.

For textures, the application overwrites (with a write-only operation) every location within the region being locked.

D3DLOCK_DONOTWAIT Allows an application to gain back CPU cycles if the driver cannot lock the surface immediately. If this flag is set and the driver cannot lock the surface immediately, the lock call will return D3DERR_WASSTILLDRAWING. This flag can only be used when locking a surface created using IDirect3DDevice9::CreateOffscreenPlainSurface, IDirect3DDevice9::CreateRenderTarget, or IDirect3DDevice9::CreateDepthStencilSurface. This flag can also be used with a back buffer.
D3DLOCK_NO_DIRTY_UPDATE By default, a lock on a resource adds a dirty region to that resource. This option prevents any changes to the dirty state of the resource. Applications should use this option when they have additional information about the set of regions changed during the lock operation.
D3DLOCK_NOOVERWRITE The application promises not to overwrite any data in the vertex and index buffers. Specifying this flag allows the driver to return immediately and continue rendering, using this buffer. If this flag is not used, the driver must finish rendering before returning from locking.
D3DLOCK_NOSYSLOCK

The default behavior of a video memory lock is to reserve a system-wide critical section, guaranteeing that no display mode changes will occur for the duration of the lock. This option causes the system-wide critical section not to be held for the duration of the lock.

The lock operation is time consuming, but can enable the system to perform other duties, such as moving the mouse cursor. This option is useful for long-duration locks, such as the lock of the back buffer for software rendering that would otherwise adversely affect system responsiveness.

D3DLOCK_READONLY The application will not write to the buffer. This enables resources stored in non-native formats to save the recompression step when unlocking.

Constant Information

Header d3d9types.h
Minimum operating system Windows 98

See Also

IDirect3DCubeTexture9::LockRect, IDirect3DIndexBuffer9::Lock, IDirect3DSurface9::LockRect, IDirect3DTexture9::LockRect, IDirect3DVertexBuffer9::Lock, IDirect3DVolume9::LockBox, IDirect3DVolumeTexture9::LockBox, ID3DXBaseMesh::LockIndexBuffer, ID3DXBaseMesh::LockVertexBuffer, ID3DXBaseMesh::LockVertexBuffer, ID3DXMesh::LockAttributeBuffer, ID3DXPatchMesh::LockAttributeBuffer, ID3DXPatchMesh::LockIndexBuffer, ID3DXPatchMesh::LockVertexBuffer