ByteWidth:缓冲区的大小(以字节为单位)
D3D11_USAGE:标识渲染期间的预期资源使用。该用法直接反映CPU和/或图形处理单元(GPU)是否可访问资源
typedef enum D3D11_USAGE { D3D11_USAGE_DEFAULT, D3D11_USAGE_IMMUTABLE, D3D11_USAGE_DYNAMIC, D3D11_USAGE_STAGING } ; D3D11_USAGE_DEFAULT需要GPU进行读写访问的资源。这可能是最常见的使用选择。D3D11_USAGE_IMMUTABLE只能由GPU读取的资源。它不能由GPU写入,并且CPU根本无法访问。这种类型的资源在创建时必须初始化,因为它在创建后无法更改。D3D11_USAGE_DYNAMICGPU(只读)和CPU(仅写入)可访问的资源。对于将由CPU至少每帧更新一次的资源,动态资源是一个不错的选择。要更新动态资源,请使用Map方法。有关如何使用动态资源的信息,请参见如何:使用动态资源。
D3D11_USAGE_STAGING支持从GPU到CPU的数据传输(复制)的资源。BindFlags:确定缓冲区如何绑定到管道
CPUAccessFlags:CPU访问标志
MiscFlags:杂项标志
StructureByteStride:缓冲区表示结构化缓冲区时缓冲区结构中每个元素的大小(以字节为单位)
Useful for geometry that is loaded once ,IMMUTABLE flag at creation time
Data that is streamed in from disk,but is expected to last for “awhile”,Reuse these; stream into them
DEFAULT flag at creation time
UpdateSubresource to update
Fire-and-forget data ● E.g. Particle systems ● Almost certainly lives in system RAM ● DYNAMIC flag at create time ● Prefer Map/Unmap to update these ● UpdateSubresource involves an extra copy
These are different than other buffers in D3D11. ● The GPU can deal with many of them in flight at once ● Create with DYNAMIC ● Map/DISCARD to Update ● More on these in a bit
● New informal class of Buffer ● Used for (e.g.) UI/Text ● Things that are dynamic, but few vertices each—and may need to be updated on odd schedules ● DYNAMIC flag at creation time ● Transient Buffers are part of a new class of buffer Treat Buffer as a Memory Heap,with a twist ● On CPU, Freed memory available now ● On GPU, Freed memory is available when GPU is finished with it ● Assume memory is in use until told otherwise ● Determine when GPU must be finished with Freed memory, then return to the “really free” list
TypeUsage (e.g)Create FlagUpdate Method“Forever”Level BSPsIMMUTABLECannot UpdateLong-LivedCharactersDEFAULTUpdateSubResourceTransientUI/TextDYNAMICCTransientBufferTemporaryParticlesDYNAMICMap/NO_OVERWRITEConstantMaterial PropsDYNAMICMap/DISCARD
