d3dx9: CloneMesh test and improvements
stefandoesinger at gmx.at
Fri Aug 19 07:20:37 CDT 2011
-----BEGIN PGP SIGNED MESSAGE-----
Am 19.08.2011 um 14:04 schrieb Michael Mc Donnell:
> 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?
Yes, unless Microsoft changed this again.
> 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 ?
Sort of. It doesn't copy the old data, it just gives you a fresh, uninitialized block of memory. So if you read from the pointer you get from a DISCARD lock you'll get garbage.
> 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
> updated patch.
Right, the buffer is newly created in CloneMesh. Just not using DISCARD is the best fix then.
>> 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.
Most likely yes. I haven't looked at the details. If the buffer is new in those situations as well just don't pass any flags, otherwise pass DISCARD if you lock a dynamic buffer and are going to rewrite the entire buffer contents.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
-----END PGP SIGNATURE-----
More information about the wine-devel