天天看點

D3D VertexBuffer

格式使用 D3DVERTEXBUFFER_DESC  的 D3DFMT_VERTEXDATA  The Format member is set to D3DFMT_VERTEXDATA to indicate that this is a vertex buffer

D3DUSAGE_WRITEONLY  保證快速改寫資料和渲染,如果讀的話會使系統慢

If this flag is not specified, it is assumed that applications perform read and write operations on the data within the vertex buffer.

大緩沖區用D3DPOOL_SYSTEMMEM 防止顯存記憶體交換

D3DFVF_XYZ 忽略D3DUSAGE_DONOTCLIP相對于D3DFVF_XYZRHW , 有D3DUSAGE_DONOTCLIP會讓VB變大

USAGE:

D3DLOCK_DISCARD and D3DLOCK_NOOVERWRITE are valid only on vertex buffers created with D3DUSAGE_DYNAMIC

D3DUSAGE_DYNAMIC and D3DPOOL_MANAGED are incompatible and should not be used together. See D3DPOOL.

D3DUSAGE_RENDERTARGET can only be used with D3DPOOL_DEFAULT.

D3DUSAGE_SOFTWAREPROCESSING If this flag is used, vertex processing is done in software. If this flag is not used, vertex processing is done in hardware.

The D3DUSAGE_SOFTWAREPROCESSING flag can be set when mixed-mode or software vertex processing

D3DUSAGE_WRITEONLY may suffer a severe performance penalty. D3DUSAGE_WRITEONLY only affects the performance of D3DPOOL_DEFAULT buffers.

WRITEONLY 隻對D3DPOOL_DEFAULT 有影響

Managing Resources:za

在記憶體和顯存中,頻繁寫入的資料不建議用managed,RenderTarget不能用,因為一改就會寫記憶體.如果要通路,用:

If CPU access of the data contained in a render target is needed, the data must be copied to a resource created in D3DPOOL_SYSTEMMEM using IDirect3DDevice9::UpdateTexture, or IDirect3DDevice9::UpdateSurface

裝置丢失:

裝置丢失在present fail後RELEASE 等  IDirect3DDevice9::TestCooperativeLevel 測試恢複RESET CREATE

在Note that these cases are the only instance of D3DERR_DEVICELOST outside of the IDirect3DDevice9::Present, IDirect3DDevice9::TestCooperativeLevel, and IDirect3DDevice9::Reset methods.之外感覺裝置丢失的隻有IDirect3DDevice9::ValidateDevice. IDirect3DQuery9::GetData IDirect3DDevice9::GetFrontBufferDataIDirect3DDevice9::CreateAdditionalSwapChain

In Direct3D 9, vertex shaders and pixel shaders don't need to be re-created after reset

vertex sampler

  • As in pixel shaders, if multielement textures are supported, D3DSAMP_ELEMENTINDEX is used to figure out which element to sample from.
  • The state D3DSAMP_DMAPOFFSET is ignored for these stages.
  • Use CheckDeviceFormat with D3DUSAGE_QUERY_VERTEXTEXTURE" to query a texture to see if it can be used as a vertex texture.
  • VertexTextureFilterCaps indicates what kind of filters are allowed at the vertex texture samplers. D3DPTFILTERCAPS_MINFANISOTROPIC and D3DPTFILTERCAPS_MAGFANISOTROPIC are disallowed.

    Member of the D3DMULTISAMPLE_TYPE enumerated type, which describes the multisampling buffer type. This parameter specifies the antialiasing type for this render target. When this surface is passed to IDirect3DDevice9::SetRenderTarget, its multisample type must be the same as that of the depth-stencil set by IDirect3DDevice9::SetDepthStencilSurface.

繼續閱讀