[Mono-dev] Managed DirectX

Brian Crowell mono-devel at fluggo.com
Thu Oct 26 15:14:59 EDT 2006

Jon Chambers wrote:
> all currently. A brief benchmark showed COM Interop on mono running at 
> about 5x slower than on .Net. I'm sure that will get better if I spend 
> some time working on that (but I'd rather get some other features 
> working first). I don't know how this compares to the icall example you 
> posted.

A better way to phrase my question, I guess, is "will COM Interop performance ever be close enough to a custom icall to make it a viable solution?"

Funny thing... I just did a small performance comparison. I created an IDirect3D9 in both C# (via COM interop) and C++/CLI (with the DX9 headers and /clr:pure), and then called the GetAdapterCount() function 1,000,000 times.

While the application was under the debugger, the RCW won out over the icall by some 50%. Running the programs directly gave the opposite result, which is what I expected, but I guess that shows the importance of running outside the debugger.

But based on this comparison, I expect that RCW would probably never be as fast as an icall. It would certainly be possible to do the whole thing via COM Interop, and a well-designed DirectX application will try to make as few calls as possible. If Mono had a C++ compiler available, I'd advocate that, but without it, it's a toss-up as to whether it's worth implementing the whole thing in C#.

Just for grins, I've attached the sources to my C++ and C# tests.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Class1.cs
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061026/b41fd8cb/attachment.pl 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: DxCppCli.cpp
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061026/b41fd8cb/attachment-0001.pl 

More information about the Mono-devel-list mailing list