Re: Must copy static const D3DVERTEXELEMENT9 into dynamically alllocated D3DVERTEXELEMENT9 * before pointer passed correctly in Wine?
2010/9/7 misha680 misha...@gmail.com Sorry for reposting - apparently my original nabble link did not work :( --- Dear All: Sorry to bother... I am working on a D3DXCreateMesh/ID3DXMesh patch, and I encountered a very strange error. Specifically, it seems that when passing a LPD3DVERTEXELEMENT9 * parameter to D3DXCreateMesh, a) in Windows - one can create static const D3DVERTEXELEMENT9 decl1[3] = { {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 0xC, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, D3DDECL_END(), }; and pass (LPD3DVERTEXELEMENT9 *)decl1 directly. b) in Wine tests - I must first allocate a D3DVERTELEMENT9 *, then call HeapAlloc, and finally copy my original decl1 and pass decl (pointer to newly allocated structure) for it to work. Any ideas? Here is my git diff http://wine.1045685.n5.nabble.com/file/n2805603/patch patch Thx Misha -- View this message in context: http://wine.1045685.n5.nabble.com/Must-copy-static-const-D3DVERTEXELEMENT9-into-dynamically-alllocated-D3DVERTEXELEMENT9-before-pointe-tp2805603p2805603.html Sent from the Wine - Devel mailing list archive at Nabble.com. Hi Misha, It's currently a stub in wine [1] and tests are using a static const D3DVERTEXELEMENT9 array as parameter [2] so it should be because of your modified D3DXCreateMesh implementation which isn't visible in your patch. [1] http://source.winehq.org/git/wine.git/?a=blob;f=dlls/d3dx9_36/mesh.c#l586 [2] http://source.winehq.org/git/wine.git/?a=blob;f=dlls/d3dx9_36/tests/mesh.c#l988 -- Nicolas Le Cam
Re: Must copy static const D3DVERTEXELEMENT9 into dynamically alllocated D3DVERTEXELEMENT9 * before pointer passed correctly in Wine?
Take a good look at the function's prototype.
Re: Must copy static const D3DVERTEXELEMENT9 into dynamically alllocated D3DVERTEXELEMENT9 * before pointer passed correctly in Wine?
My apologies if my first patch was unclear. Here is a slightly modified git diff http://wine.1045685.n5.nabble.com/file/n2806011/patch patch along with the relevant make test output http://wine.1045685.n5.nabble.com/file/n2806011/maketestoutput maketestoutput The relevant part of the make test output: ../../../tools/runtest -q -P wine -M d3dx9_36.dll -T ../../.. -p d3dx9_36_test.exe.so mesh.c touch mesh.ok 0x684e7c86 (nil) 0x32fcf8 0x123170 And the relevant statements are, in test/mesh.c: D3DVERTEXELEMENT9 *decl; static const D3DVERTEXELEMENT9 decl1[3] = { {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 0xC, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, D3DDECL_END(), }; hr = D3DXCreateMesh(1, 3, D3DXMESH_MANAGED, (LPD3DVERTEXELEMENT9 *)decl1, NULL, d3dxmesh); todo_wine ok(hr == D3DERR_INVALIDCALL, Got result %x, expected %x (D3DERR_INVALIDCALL)\n, hr, D3DERR_INVALIDCALL); decl = HeapAlloc(GetProcessHeap(), 0, sizeof(decl1)); if (!decl) { skip(Couldn't create declaration copy\n); return; } memcpy(decl, decl1, sizeof(decl1)); hr = D3DXCreateMesh(1, 3, D3DXMESH_MANAGED, decl, NULL, d3dxmesh); todo_wine ok(hr == D3DERR_INVALIDCALL, Got result %x, expected %x (D3DERR_INVALIDCALL)\n, hr, D3DERR_INVALIDCALL); return; and in mesh.c: HRESULT WINAPI D3DXCreateMesh(DWORD numfaces, DWORD numvertices, DWORD options, CONST LPD3DVERTEXELEMENT9 *declaration, LPDIRECT3DDEVICE9 device, LPD3DXMESH *mesh) { printf(%p %p\n, declaration, *declaration); Now LPD3DVERTEXELEMENT9 is a D3DVERTEXELEMENT9 *, http://msdn.microsoft.com/en-us/library/bb172630%28VS.85%29.aspx so LPD3DVERTEXELEMENT9 * is a D3DVERTEXELEMENT9 **, and to get at the underlying D3DVERTEXELEMENT9 array, I believe I need to access *declaration, e.g., (*declaration)[0], [1], etc. Notably, if I use the HeapAlloc + memcpy approach, the test _fail_ in Windows (I only tried once fyi), so at the moment it seems like one thing works in Wine, another in Windows. Thank you Misha -- View this message in context: http://wine.1045685.n5.nabble.com/Must-copy-static-const-D3DVERTEXELEMENT9-into-dynamically-alllocated-D3DVERTEXELEMENT9-before-pointe-tp2805603p2806011.html Sent from the Wine - Devel mailing list archive at Nabble.com.
Re: Must copy static const D3DVERTEXELEMENT9 into dynamically alllocated D3DVERTEXELEMENT9 * before pointer passed correctly in Wine?
On 7 September 2010 14:43, misha680 misha...@gmail.com wrote: LPD3DVERTEXELEMENT9 is a D3DVERTEXELEMENT9 *, http://msdn.microsoft.com/en-us/library/bb172630%28VS.85%29.aspx so LPD3DVERTEXELEMENT9 * is a D3DVERTEXELEMENT9 **, and to get at the Well yes, but why do you think that makes sense as an argument to D3DXCreateMesh()? Did you check the prototype against the SDK?
Re: Must copy static const D3DVERTEXELEMENT9 into dynamically alllocated D3DVERTEXELEMENT9 * before pointer passed correctly in Wine?
On Tue, 2010-09-07 at 15:56 +0200, Henri Verbeet wrote: On 7 September 2010 14:43, misha680 misha...@gmail.com wrote: LPD3DVERTEXELEMENT9 is a D3DVERTEXELEMENT9 *, http://msdn.microsoft.com/en-us/library/bb172630%28VS.85%29.aspx so LPD3DVERTEXELEMENT9 * is a D3DVERTEXELEMENT9 **, and to get at the Well yes, but why do you think that makes sense as an argument to D3DXCreateMesh()? Did you check the prototype against the SDK? Thank you. Will take a look later today. Misha
Must copy static const D3DVERTEXELEMENT9 into dynamically alllocated D3DVERTEXELEMENT9 * before pointer passed correctly in Wine?
Dear All: Sorry to bother... I am working on a D3DXCreateMesh/ID3DXMesh patch, and I encountered a very strange error. Specifically, it seems that when passing a LPD3DVERTEXELEMENT9 * parameter to D3DXCreateMesh, a) in Windows - one can create static const D3DVERTEXELEMENT9 decl1[3] = { {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 0xC, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, D3DDECL_END(), }; and pass (LPD3DVERTEXELEMENT9 *)decl1 directly. b) in Wine tests - I must first allocate a D3DVERTELEMENT9 *, then call HeapAlloc, and finally copy my original decl1 and pass decl (pointer to newly allocated structure) for it to work. Any ideas? Here is my git diff http://wine.1045685.n5.nabble.com/file/n2805542/patch patch Thx Misha -- View this message in context: http://wine.1045685.n5.nabble.com/Must-copy-static-const-D3DVERTEXELEMENT9-into-dynamically-alllocated-D3DVERTEXELEMENT9-before-pointe-tp2805542p2805542.html Sent from the Wine - Devel mailing list archive at Nabble.com.
Must copy static const D3DVERTEXELEMENT9 into dynamically alllocated D3DVERTEXELEMENT9 * before pointer passed correctly in Wine?
Sorry for reposting - apparently my original nabble link did not work :( --- Dear All: Sorry to bother... I am working on a D3DXCreateMesh/ID3DXMesh patch, and I encountered a very strange error. Specifically, it seems that when passing a LPD3DVERTEXELEMENT9 * parameter to D3DXCreateMesh, a) in Windows - one can create static const D3DVERTEXELEMENT9 decl1[3] = { {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 0xC, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, D3DDECL_END(), }; and pass (LPD3DVERTEXELEMENT9 *)decl1 directly. b) in Wine tests - I must first allocate a D3DVERTELEMENT9 *, then call HeapAlloc, and finally copy my original decl1 and pass decl (pointer to newly allocated structure) for it to work. Any ideas? Here is my git diff http://wine.1045685.n5.nabble.com/file/n2805603/patch patch Thx Misha -- View this message in context: http://wine.1045685.n5.nabble.com/Must-copy-static-const-D3DVERTEXELEMENT9-into-dynamically-alllocated-D3DVERTEXELEMENT9-before-pointe-tp2805603p2805603.html Sent from the Wine - Devel mailing list archive at Nabble.com.