天天看点

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.

继续阅读