directx bindings problem
evilrat
evilrat666 at gmail.com
Sun Oct 6 22:50:42 PDT 2013
On Sunday, 6 October 2013 at 16:45:59 UTC, Benjamin Thaut wrote:
> Am 06.10.2013 07:25, schrieb evilrat:
>> oh, on the second thought after some tests, i encountered
>> major ABI(or
>> should i say MS 'optimization'?) mismatch which requires
>> almost any
>> function to be wrapped within C++ code to work, i doubt it
>> would ever
>> costs such efforts for me.
>>
>> so i'm tired off both C++ and D. and programming in general.
>> hate hate
>> hate ...
>
> Whats the ABI mismatch?
a simple example is dxgi.present which takes 2 uint's.
here is the same code for C++ and D.
--------------------------
MSVC++ 2012 disasm
g_pSwapChain->Present( 0, 0 );
00CC1DC7 mov esi,esp
00CC1DC9 push 0
00CC1DCB push 0
00CC1DCD mov eax,dword ptr ds:[00CC9160h]
00CC1DD2 mov ecx,dword ptr [eax]
00CC1DD4 mov edx,dword ptr ds:[0CC9160h]
00CC1DDA push edx
00CC1DDB mov eax,dword ptr [ecx+20h]
00CC1DDE call eax
00CC1DE0 cmp esi,esp
00CC1DE2 call __RTC_CheckEsp (0CC117Ch)
(last call i think is just for debug in visual studio)
--------------------------
DMD 2.063.2 disasm
g_pSwapChain.Present( 0, 0 );
0042CD91 push 0
0042CD93 push 0
0042CD95 mov eax,dword ptr ds:[0050C120h]
0042CD9A mov ecx,dword ptr fs:[2Ch]
0042CDA1 mov edx,dword ptr [ecx+eax*4]
0042CDA4 mov ebx,dword ptr [edx+48h]
0042CDAA mov esi,dword ptr [ebx]
0042CDAC push esi
0042CDAD mov eax,dword ptr [esi]
0042CDAF call dword ptr [eax+20h]
(crashes on call)
so what's exactly happens here, it stores some string(?), it
pushes args according to stdcall, move pointers to registers and
calls this method. since my asm is quite sucks i can only think
it expects eax to be func ptr? but how then it returns HRESULT?
i simply made a wrapper function which takes g_pSwapChain ptr,
this 2 uint's and simply call that method on a C++ side, so all
pointers are correct.
now i really don't know what the problem, maybe this is just
2.063.2 broken?
More information about the Digitalmars-d-learn
mailing list