d3dx9: CloneMesh test and improvements
Michael Mc Donnell
michael at mcdonnell.dk
Fri Aug 19 07:04:59 CDT 2011
On Thu, Aug 18, 2011 at 8:05 PM, Stefan Dösinger <stefandoesinger at gmx.at> wrote:
> I noticed one small issue:
> On Saturday 13 August 2011 12:22:03 Michael Mc Donnell wrote:
>> +static HRESULT convert_vertex_buffer(ID3DXMesh *mesh_dst, ID3DXMesh
>> + hr = mesh_dst->lpVtbl->LockVertexBuffer(mesh_dst, D3DLOCK_DISCARD,
> On paper, D3DLOCK_DISCARD is only valid on D3DUSAGE_DYNAMIC buffers. Wine and
> Windows <= WinVista don't enforce this. Win7 does, and it broke some apps that
Ok I see that in dlls/d3d9/tests/buffers.c. So it will fail to lock on
Win7 if D3DLOCK_DISCARD is specified and the vertex buffer wasn't
created with D3DUSAGE_DYNAMIC?
Am I correct in D3DLOCK_DISCARD makes a copy of the vertex buffer so
that the video card can keep reading the old one, and the old vertex
buffer memory is released after the video card releases its lock ?
In that case it does not make sense to use D3DLOCK_DISCARD at all in
CloneMesh, as the video card has not begun to use the new vertex
buffer, and it will just add memory overhead. The easiest fix would be
to just pass 0 instead of D3DLOCK_DISCARD. I've done that in the
> I noticed a few more D3DLOCK_DISCARD locks in the mesh.c code.
I guess the other methods should check the mesh options for
D3DXMESH_DYNAMIC, D3DXMESH_VB_DYNAMIC, and D3DXMESH_IB_DYNAMIC 
before using D3DLOCK_DISCARD? I'll write patches for those.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 18703 bytes
Desc: not available
More information about the wine-devel