d3d9: Improve IDirect3DDevice9::SetFVF() code flow.

This commit is contained in:
Henri Verbeet 2009-03-06 08:43:49 +01:00 committed by Alexandre Julliard
parent aa3027a604
commit 09f21f3fd8
1 changed files with 22 additions and 17 deletions

View File

@ -1507,26 +1507,31 @@ static IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This,
static HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface, DWORD FVF) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr = S_OK;
IDirect3DVertexDeclaration9 *decl;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d9_cs);
if (0 != FVF) {
IDirect3DVertexDeclaration9* pDecl = getConvertedDecl(This, FVF);
if(!pDecl) {
/* Any situation when this should happen, except out of memory? */
ERR("Failed to create a converted vertex declaration\n");
LeaveCriticalSection(&d3d9_cs);
return D3DERR_DRIVERINTERNALERROR;
}
hr = IDirect3DDevice9Impl_SetVertexDeclaration(iface, pDecl);
if (hr != S_OK) {
LeaveCriticalSection(&d3d9_cs);
return hr;
}
if (!FVF)
{
WARN("%#x is not a valid FVF\n", FVF);
return D3D_OK;
}
EnterCriticalSection(&d3d9_cs);
decl = getConvertedDecl(This, FVF);
if (!decl)
{
/* Any situation when this should happen, except out of memory? */
ERR("Failed to create a converted vertex declaration\n");
LeaveCriticalSection(&d3d9_cs);
return D3DERR_DRIVERINTERNALERROR;
}
hr = IDirect3DDevice9Impl_SetVertexDeclaration(iface, decl);
if (FAILED(hr)) ERR("Failed to set vertex declaration\n");
LeaveCriticalSection(&d3d9_cs);
return hr;