Update your bookmarks! This blog is now hosted on http://xoofx.com/blog

Wednesday, December 1, 2010

Official release of SharpDX 1.0

After three months of intense development, I'm really excited to announce the availability of SharpDX 1.0 , a new platform independent .Net managed DirectX API, directly generated from DirectX SDK headers.

This first version can be considered as stable. The Direct3D10 / Direct3D10.1 API has been entirely tested on a large 3D engine that was using previously SlimDX (thanks patapom!). Migration was quite straightforward, with tiny minor changes to the engine's code.

The key features and benefits of this new API are:
  • API is generated from DirectX SDK headers : meaning a complete and reliable API and an easy support for future API.
  • Full support for the following DirectX API:
    • Direct3D10
    • Direct3D10.1
    • Direct3D11
    • Direct2D1 (including custom rendering, tessellation callbacks)
    • DirectWrite (including custom client callbacks)
    • D3DCompiler
    • DXGI
    • DXGI 1.1
    • DirectSound
    • XAudio2
    • XAPO
    • An integrated math API directly ported from SlimMath
  • Pure managed .NET API, platform independent : assemblies are compiled with AnyCpu target. You can run your code on a x64 or a x86 machine with the same assemblies, without recompiling your project.
  • Lightweight individual assemblies : a core assembly - SharpDX - containing common classes and an assembly for each subgroup API (Direct3D10, Direct3D11, DXGI, D3DCompiler...etc.). Assemblies are also lightweight.
  • C++/CLI Speed : the framework is using a genuine way to avoid any C++/CLI while still achieving comparable performance.
  • API naming convention mostly compatible with SlimDX API.
  • Raw DirectX object life management : No overhead of ObjectTable or RCW mechanism, the API is using direct native management with classic COM method "Release".
  • Easily mergeable / obfuscatable : If you need to obfuscate SharpDX assemblies, they are easily obfusctable due to the fact the framework is not using any mixed assemblies. You can also merge SharpDX assemblies into a single exe using with tool like ILMerge.
You will also find a growing collection of samples in the Samples Gallery of SharpDX. Most notably with some additional support for Direct2D1 and DirectWrite client callbacks.

Instead of providing a monolithic assembly, SharpDX is providing lightweight individual and interdependent assemblies. All SharpDX assemblies are dependent from the core SharpDX assembly. You just need to add the required assemblies to your project, without embedding the whole DirectX API stack. Here is a chart that explains SharpDX assembly dependencies:

Next versions will provide support for DirectInput, XInput, X3DAudio, XACT3.

About performance

Someone asked me how SharpDX compares to SlimDX in terms of performance. Here is a micro-benchmark on two methods, ID3D10Device1::GetFeatureLevel (alias Device.FeatureLevel) and ID3D10Device::CheckCounterInfo (alias Device.GetCounterCapabilities).

The test consist of 100,000,000 calls on each methods (inside a for, with (10 calls to device.FeatureLevel) * 10,000,000 times) and is repeated 10 times and averaged. Repeated two times.
Method SlimDX SharpDX SharpDX vs SlimDX
device.FeatureLevel 3700 3650 1,37%
device.GetCounterCapabilities() 4684 4259 9,98%

For FeatureLevel, the test was sometimes around +/-0.5%.
For GetCounterCapabilities(), the main difference between SharpDX and SlimDX implementation is that SlimDX perform a copy from the native struct to .Net struct while SharpDX is directly passing a pointer to the .Net struct.

This test is of course a micro benchmark and doesn't reflect a real-world usage. Some part of the API could be in favor of SlimDX, but I'm pretty confident that SharpDX is much more consistent in the way structures are passed to the native functions, avoiding as much as possible marshaling structures that doesn't need any custom marshaling (unlike SlimDX that is performing most of a time a marshaling between .Net/Native structure, besides they are binary compatible).


Finally, I'm going to be able to use this project to make some demos with it! Next target is to develop a XNA like based framework based on SharpDX.Direct3D11.

Stay tuned!


  1. Will it work on Linux?

  2. >> Will it work on Linux?
    You mean working with Mono and Wine?
    Don't know much about those projects and their interaction... At least, SharpDX assemblies are pure managed (and not mixed) so it could work, but I'm not sure.

  3. Very nice. I'm really hanging out for DirectInput as it's nigh on impossible to get Mono compatible force feedback in .net (even just on windows, I'm using Unity)

  4. @Cam, thanks! Sure that DirectInput is going to be integrated in SharpDX soon. I'm still working on a higher level API on top of SharpDX, but I will add other missing APIs in next version.

  5. btw ergon is pretty remarkable :) I show my students stuff like that and make them guess how big it is :D

  6. Congrats for the release. Good luck with this project

  7. really cool project! just out of curiosity: what is the primary reason for supporting mono given that directx is windows only anyways?

  8. @pragmascript, some people are using Unity and would like to have access to some API under windows, others are using Mono as a cross platform 3D dev, and DirectX is the main backend under windows.

  9. You rock! I just want to express how great is your port of DirectX compare to other managed APIs. Your blog is awesome as well. Pleasant to read, well structured articles.

  10. Have you done any profiling of matrix operations compared to SlimDX? I think that SlimDX implements the matrix operations purely im managed code so that there are no calls into DirectX to perform matrix operations. I suppose that SharpDX does call into DirectX for those operations so it will take the managed->unmanaged->managed performance hit. I would be interested in knowing what the performance difference is because if it is much I might pull the SlimDX matrix operations into my application and use SharpDX for other DirectX stuff. Thanks.

  11. @Gari, SharpDX math is an import from SlimMath which is purely managed which was probably a port of SlimDX math (with some unmanaged functions translated to managed). 
    But some operations would still be more efficient even with an unmanaged optimized version and the associated managed-to-unmanaged transition.
    Though SharpDX will probably get some performance improvements for math operations, as there are still lots of opportunities to speed up things, it is in the pipeline of things to come in 2012.

  12. Thanks for the explanation. That is really great to hear. I am really loving SharpDX.


Comments are disabled

Note: Only a member of this blog may post a comment.