Common D3D buffer flag

Source: Internet
Author: User

Usage flag
D3DUSAGE_DEPTHSTENCIL // This vertex buffer is the vertex depth mask buffer, and the memory pool must be D3DPOOL_DEFAULT. This type is generally stored in the video memory.


D3DUSAGE_SOFTWAREPROCESSING// Software vertex Processing


D3DUSAGE_WRITEONLY// The buffer zone only supports vertex writing and does not require large-part reading.


D3DUSAGE_DYNAMIC// Dynamic vertex buffer (AGP memory)


Pool memory Pool flag
D3DPOOL_DEFAULT

Resources are stored in the memory that is most suitable for access to a given resource. This is usually memory display, including local memory display and AGP memory. D3DPOOL_DEFAULT is different from D3DPOOL_MANAGED and D3DPOOL_SYSTEMMEM, it indicates that resources are stored in the memory that is most suitable for device access. D3DPOOL_DEFAULT indicates that D3DPOOL_MANAGED and D3DPOOL_SYSTEMMEM will never be used as alternative types of resource memory, texture resources allocated using D3DPOOL_DEFAULT cannot be locked unless the texture is a dynamic texture or a private FOURCC
Driver format. To access texture resources that cannot be specified, you must use the following function:

IDirect3DDevice9: UpdateSurface

IDirect3DDevice9: UpdateTexture

IDirect3DDevice9: GetFrontBufferData

IDirect3DDevice9: GetRenderTargetData

For most applications, using D3DPOOL_MANAGED is a better choice. Some textures created in pixel format unique to driver cannot be identified by Direct3D runtime, and can also be locked. Unlike texture, swap chain back buffers, render targets, vertex buffers, and index
Buffers can be locked. when the device is lost, all resources created using D3DPOOL_DEFAULT must be released before the Reset function is called. If the memory is insufficient when you use D3DPOOL_DEFAULT to create resources, therefore, managed resource will release some memory space to meet the needs.



D3DPOOL_MANAGED 

Resources are automatically copied to the memory that the device can access on demand. Managed resources are backed up by system memory. Therefore, you do not need to re-create a device when it is lost. Managed resources can be locked, and only the memory backed up by the system can be directly modified. Direct3D copies the changes to the memory accessible to the device as needed.


D3DPOOL_SYSTEMMEN

Resources are allocated to memory that cannot be directly accessed by devices. These memories consume system RAM but do not reduce paging RAM. These resources do not need to be rebuilt when the device is lost. This type of resource can also be locked and can be used as the IDirect3DDevice9: UpdateSurface or IDirect3DDevice9: UpdateTexture source. Both functions are operated on resources of the D3DPOOL_DEFAULT type.


D3DPOOL_SCRATCH

Resources are allocated in system RAM and do not need to be rebuilt when the device is lost. This type of resource is not limited by the device size and format. Therefore, such resources cannot be used by Direct3D devices, nor can they be set to textures or Render targets. However, such resources can also be created, locked, and copied.


D3DPOOL_FORCE_DWORD

/Force this type to be compiled into the 32bit size without this value. Some compilers will compile this enumeration type into a non-32bit type, and this value is not used yet

All memory types apply to all resource types, including Vertex Buffers, Index Buffers, textures, and Surfaces.

The following table shows the compatibility between the memory type and usage of resources. x indicates compatibility.


Resource pools of different objects in the same resource cannot be mixed (mip levels in a mipmap), and cannot be changed when a resource pool is selected.

For most static resources, the application should use D3DPOOL_MANAGED, because this makes the application do not have to handle device loss. This is especially beneficial for systems with a unified memory architecture (UMA. Other dynamic resource types are not suitable for D3DPOOL_MANAGED. In fact, index buffers and vertex buffers cannot be created using D3DPOOL_MANAGED and D3DUSAGE_DYNAMIC at the same time.

For dynamic textures, sometimes a pair of memory is required. One is the memory allocated by D3DPOOL_DEFAULT, and the other is the system memory allocated by D3DPOOL_SYSTEMMEM. You can use the locking method to modify the texture in the system memory, and use the IDirect3DDevice9: UpdateTexture function to update the modification to the video memory.



Lock flag

D3DLOCK_DISCARD// Rewrite the lock buffer content. The object is Dynamic, such as Dynamic Texture and Dynamic.
Vertex buffer and so on. When modifying data, you can use the original data for rendering. When the data in the modification is complete, after Unlock is called, the new buffer data is rendered.


D3DLOCK_NO_DIRTY_UPDATE
// By default, a Dirty flag is set for the region when the buffer is locked. This attribute does not set the Dirty flag for this region. It is used when there are special needs for the buffer zone.


3DLOCK_NOSYSLOCK// Add a critical lock to the buffer zone to avoid changing the display mode parameters when reading and writing data. it takes some time to execute the Lock () function. By default, Direct3D suspends other display operations until the execution of the Lock () function ends. Setting the D3DLOCK_NOSYSLOCK attribute allows Direct3D to execute other display operations while locking the buffer, such as moving the mouse.


D3DLOCK_READONLY// This vertex buffer can only be used for reading


D3DLOCK_NOOVERWRITE
// Add data to the Buffer and continue rendering when modifying the data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.