From 96d5d06f2bbe39e189a183f22298ec6c0474ff35 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Wed, 27 Apr 2011 18:11:48 -0400 Subject: [PATCH] d3dx9: D3DXCreateMesh rejects declarations with non-zero streams. --- dlls/d3dx9_36/mesh.c | 4 ++++ dlls/d3dx9_36/tests/mesh.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c index abcdcc8df1b..432db1d5012 100644 --- a/dlls/d3dx9_36/mesh.c +++ b/dlls/d3dx9_36/mesh.c @@ -1132,6 +1132,7 @@ HRESULT WINAPI D3DXCreateMesh(DWORD numfaces, DWORD numvertices, DWORD options, D3DFORMAT index_format = D3DFMT_INDEX16; DWORD vertex_usage = 0; D3DPOOL vertex_pool = D3DPOOL_DEFAULT; + int i; TRACE("(%d, %d, %x, %p, %p, %p)\n", numfaces, numvertices, options, declaration, device, mesh); @@ -1141,6 +1142,9 @@ HRESULT WINAPI D3DXCreateMesh(DWORD numfaces, DWORD numvertices, DWORD options, { return D3DERR_INVALIDCALL; } + for (i = 0; declaration[i].Stream != 0xff; i++) + if (declaration[i].Stream != 0) + return D3DERR_INVALIDCALL; if (options & D3DXMESH_32BIT) index_format = D3DFMT_INDEX32; diff --git a/dlls/d3dx9_36/tests/mesh.c b/dlls/d3dx9_36/tests/mesh.c index 570e186a97b..88ac59cc978 100644 --- a/dlls/d3dx9_36/tests/mesh.c +++ b/dlls/d3dx9_36/tests/mesh.c @@ -1036,6 +1036,12 @@ static void D3DXCreateMeshTest(void) D3DDECL_END(), }; + static const D3DVERTEXELEMENT9 decl3[] = { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {1, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, + D3DDECL_END(), + }; + hr = D3DXCreateMesh(0, 0, 0, NULL, NULL, NULL); ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); @@ -1213,6 +1219,10 @@ static void D3DXCreateMeshTest(void) d3dxmesh->lpVtbl->Release(d3dxmesh); } + /* Test a declaration with multiple streams. */ + hr = D3DXCreateMesh(1, 3, D3DXMESH_MANAGED, decl3, device, &d3dxmesh); + ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + IDirect3DDevice9_Release(device); IDirect3D9_Release(d3d); DestroyWindow(wnd);