Your patches have dos line endings (i.e. "\r\n") which causes git apply to fail, although the patch command only gives a warning.


@@ -208,6 +221,12 @@ static DWORD WINAPI ID3DXMeshImpl_GetNumBytesPerVertex(ID3DXMesh *iface)
    TRACE("iface (%p)\n", This);
+    if (!This->vertex_declaration)
+    {
+        WARN("Can't get number of bytes per vertex of an invalid vertex declaration.\n");
+        return E_FAIL;
+    }

GetNumBytesPerVertex returns a DWORD not an HRESULT, so I wouldn't expect E_FAIL to ever be returned? Unusual behaviour like this should be covered by a test.


+    /* An application can pass an invalid declaration to UpdateSemantics and
+     * still expect D3D_OK (see tests). If the declaration is invalid, then
+     * subsequent calls to GetDeclaration, GetNumBytesPerVertex, and DrawSubset,
+     * which use the declaration, will fail.
+     */

D3DXCreateMesh fails when the declaration contains a non-zero Stream value. I would expect UpdateSemantics to be as strict as D3DXCreateMesh, otherwise a test could validate the different behaviour.

You tested a declaration with larger fields, but not with the vertex size being smaller or greater. (E.g. Try removing the last field, or appending a field.)

I did some testing and couldn't get GetDeclaration or GetNumBytesPerVertex to fail on windows.  DrawSubset did seem to fail after UpdateSemantics is called with a declaration that causes CreateVertexDeclaration to fail. This suggests that the native implementation probably just stores the D3DVERTEXELEMENT9 array and calls CreateVertexDeclaration on DrawSubset. You can probably cache the created vertex declaration and release it on UpdateSemantics for performance.