D3DPOOL

关于D3DPOOL的翻译

注:D3DPOOL在D3D资源管理中有着重要的意义,我们必须弄清楚自己创建的资源在什么地方,才能知道在设备丢失的时候,哪些需要重建;在优化渲染的时候,哪些是瓶颈。下在是DX SDK文档中对于D3DPOOL的介绍,我在看的时候顺便翻译了过来。 希望给不方便看英文文档的朋友一些帮助。

由于本人英语能力有限,故在翻译的时候,给出了原文。方便个别单词的对照。

另外,D3DUSAGE也是和资源紧密相关的内容。朋友FancyBit对其作了翻译,也贴于下部。

Defines the memory class that holds the buffers for a resource.
这句不用翻译

typedef enum D3DPOOL

{

D3DPOOL_DEFAULT = 0,

D3DPOOL_MANAGED = 1,

D3DPOOL_SYSTEMMEM = 2,

D3DPOOL_SCRATCH = 3,

D3DPOOL_FORCE_DWORD = 0x7fffffff,

} D3DPOOL, *LPD3DPOOL;
Constants 常量


D3DPOOL_DEFAULT

Resources are placed in the memory pool most appropriate for the set of usages requested for the given resource. This is usually video memory, including both local video memory and AGP memory. The D3DPOOL_DEFAULT pool is separate from D3DPOOL_MANAGED and D3DPOOL_SYTEMMEM, and it specifies that the resource is placed in the preferred memory for device access. Note that D3DPOOL_DEFAULT never indicates that either D3DPOOL_MANAGED or D3DPOOL_SYSTEMMEM should be chosen as the memory pool type for this resource. Textures placed in the D3DPOOL_DEFAULT pool cannot be locked unless they are dynamic textures or they are private, FOURCC, driver formats. To access unlockable textures, you must use functions such as IDirect3DDevice9::UpdateSurface, IDirect3DDevice9::UpdateTexture, IDirect3DDevice9::GetFrontBufferData, and IDirect3DDevice9::GetRenderTargetData. D3DPOOL_MANAGED is probably a better choice than D3DPOOL_DEFAULT for most applications. Note that some textures created in driver-proprietary pixel formats, unknown to the Direct3D runtime, can be locked. Also note that - unlike textures - swap chain back buffers, render targets, vertex buffers, and index buffers can be locked. When a device is lost, resources created using D3DPOOL_DEFAULT must be released before calling IDirect3DDevice9::Reset. For more information, see Lost Devices.
When creating resources with D3DPOOL_DEFAULT, if video card memory is already committed, managed resources will be evicted to free enough memory to satisfy the request.


资源被放入内存池中多半是为了给被请求的资源腾出使用的空间。 通常是显存,包括显卡道内存中的AGP部分。D3DPOOL_DEFAULT 是从MANGED和SYSTEMMEM中分离出来的。它指明了被放入此中的资源是用来被设备访问。注意,D3DPOOL_DEFAULT 没有意味着MANAGED或SYSTEMMEM将会被选择用来存储资源,这是一个独立的部分。放入D3DPOOL_DEFAULT 中的纹理不可以被LOCK除非是动态纹理或是私有纹理。FOURCC,驱动格式,为了访问未锁定的纹理,我们必须用IDirect3DDevice9::UpdateSurface, IDirect3DDevice9::UpdateTexture, IDirect3DDevice9::GetFrontBufferData, and IDirect3DDevice9::GetRenderTargetData.函数。显然,对于许多应用程序来说,MANAGED是更好的选择。
注意,许多纹理是以私有的格式创建的。运行时D3D并不知道。是可以被加锁的。同时应该注意,不像纹理,交换链后台缓冲区,渲染目标,顶点缓冲,索引缓冲是可以被加锁的。当设备丢失的时候,使用D3DPOOL_DEFAULT 创建的资源必须要在调用Reset之前释放。可以参看D3D的LostDevice.
当使用D3DPOOL_DEFAULT 创建资源,并且显卡的内存有限的时候,MANAGED中的资源将会被清除以释放足够的内存来满足需求。

D3DPOOL_MANAGED
Resources are copied automatically to device-accessible memory as needed. Managed resources are backed by system memory and do not need to be recreated when a device is lost. See Managing Resources for more information. Managed resources can be locked. Only the system-memory copy is directly modified. Direct3D copies your changes to driver-accessible memory as needed.


在MANAGED中的当有需要的时候,会被自动复制到设备的可访问内存。MANAGED资源在系统内存中是有备份的,于是当设备丢失的时候,不需要重新创建。参见Managing Resources 。MANAGED资源可以被加锁,只有系统内存中的备份是直接被修改的。当有必要的时候,D3D复制你所修改的内容到系统可访问区


D3DPOOL_SYSTEMMEM
Resources are placed in memory that is not typically accessible by the Direct3D device. This memory allocation consumes system RAM but does not reduce pageable RAM. These resources do not need to be recreated when a device is lost. Resources in this pool can be locked and can be used as the source for a IDirect3DDevice9::UpdateSurface or IDirect3DDevice9::UpdateTexture operation to a memory resource created with D3DPOOL_DEFAULT.


被放置在SYSTMMEM中的资源是典型地不可被3D直接访问的。这种内存分配消耗系统的RAM但是不减少RAM的可用页。在设备丢失的时候,这些资源不需要再次创建。在这个内存池中的资源可以被加锁,可以被用来让IDirect3DDevice9::UpdateSurface or IDirect3DDevice9::UpdateTexture 去操作以D3DPOOL_DEFAULT. 方式创建的资源


D3DPOOL_SCRATCH
Resources are placed in system RAM and do not need to be recreated when a device is lost. These resources are not bound by device size or format restrictions. Because of this, these resources cannot be accessed by the Direct3D device nor set as textures or render targets. However, these resources can always be created, locked, and copied.


这种资源被放在系统的RAM中,设备丢失时候不用重新创建。这种资源不受设备大小和格式的限制。为此,这种资源不能被D3D访问,也不能设置为纹理或渲染目标。但是,这种资源总是可以被创建,加锁和复制。


D3DPOOL_FORCE_DWORD
Forces this enumeration to compile to 32 bits in size. Without this value, some compilers would allow this enumeration to compile to a size other than 32 bits. This value is not used.
强制编译器使用32位来编译这个枚举量。若没有这个值,一些编译器将允许这个枚举以非32位的方式编译。这个值未被使用。


Remarks 评论
All pool types are valid with all resources. This includes: vertex buffers, index buffers, textures, and surfaces.
所有的内存池类型对所有的资源有效。包括:顶点缓冲,索引缓冲,纹理,表面。


剩下的一些内容就是各种类型的资源对各种渲染目标的效性。参见SDK


以下为FancyBit对D3DUSAGE的翻译,由于和D3DPOOL关联较强,故贴在

此里,十分感谢FancyBit


他的主页是:http://hi.baidu.com/148332727 希望大家多多交流,共同进步


资源的使用的方式

D3DUSAGE_RENDERTARGET 此纹理或表面作为一个渲染目标被创建,只能分配在D3DPOOL_DEFAULT的显卡内存中

D3DUSAGE_AUTOGENMIPMAP 资源会自动生成多精度(多层次细节)纹理(mipmap)(Direct3D 9). 不支持volume textures 和深度表面/深度纹理(凹凸贴图). 这个usage 不支持系统内存中的资源(用D3DPOOL_SYSTEMMEM参数创建的资源).

D3DUSAGE_DEPTHSTENCIL 此资源将会是一个深度缓冲,只能用D3DPOOL_DEFAULT分配.

D3DUSAGE_DMAP The resource will be a displacement map. ???

D3DUSAGE_DONOTCLIP 顶点缓冲区内容不需要裁减. 当被渲染的缓冲区设置此位时,D3DRS_CLIPPING 渲染器状态必须设置为false.

D3DUSAGE_DYNAMIC 设置此位表示顶点缓冲需要动态的内存使用。这对驱动程序很有用因为它使得驱动程序可以决定把缓冲区放在哪里。一般的,静态顶端缓冲放置在显存儿动态缓冲防止在AGP内存中。注意如果你没有指定该标志位,那么顶点缓冲默认就是静态的。

D3DUSAGE_DYNAMIC会被强制设置,当D3DLOCK_DISCARD 和 D3DLOCK_NOOVERWRITE 锁标志一起使用. 因此, D3DLOCK_DISCARD and D3DLOCK_NOOVERWRITE 只对使用 D3DUSAGE_DYNAMIC创建的顶点缓冲有用.更多参见Managing Resources (Direct3D 9).

更多关于动态顶点缓冲的信息,参见Performance Optimizations (Direct3D 9).

D3DUSAGE_DYNAMIC 和 D3DPOOL_MANAGED不兼容. See D3DPOOL.

纹理也可以使用D3DUSAGE_DYNAMIC.当然, 托管的纹理不能使用 D3DUSAGE_DYNAMIC. 关于动态纹理的信息,参见 Using Dynamic Textures.

D3DUSAGE_WRITEONLY
用于顶点缓冲和索引缓冲
通知系统程序只想顶点和索引缓冲中写入数据。使用这个标记可以让驱动程序选择让写入和渲染操作效率最佳的内存分配方式。启用此特性后尝试从内存缓冲中读取数据的操作会失败。只对使用D3DPOOL_DEFAULT分配在显存中的数据有效。

D3DUSAGE_RTPATCHES Set to indicate that the vertex buffer is to be used for drawing high-order primitives. ???

D3DUSAGE_NONSECURE 允许创建的表面被另一个程序用一个无安全性的共享句柄打开,只在D3D9EX使用

D3DUSAGE_TEXTAPI D3D9EX专用 略

用于:
IDirect3DDevice9::CreateCubeTexture
IDirect3DDevice9::CreateDepthStencilSurface
IDirect3DDevice9::CreateIndexBuffer
IDirect3DDevice9::CreateOffscreenPlainSurface
IDirect3DDevice9::CreateRenderTarget
IDirect3DDevice9::CreateTexture
IDirect3DDevice9::CreateVertexBuffer
IDirect3DDevice9::CreateVolumeTexture
D3DXCreatexxx texturing functions

你可能感兴趣的:(D3DPOOL)