direct compute with c#

Is it possible to use direct compute with c# 2010 (and if so, where are samples, getting started tutorials, etc.)

I’ve never heard of a way. If you’re working in .NET, the current best solution is to write your device kernels with CUDA, compile them to .cubin or .ptx, and use P/Invoke with the CUDA driver or runtime to call them.

There are currently no .NET bindings for DirectX 10/11 made by Microsoft, not even the XNA stuff. That’s what Wiki says at least (http://en.wikipedia.org/wiki/DirectX#.NET_Framework).

Apparently there’s a third party Open Source solution, SlimDX (http://en.wikipedia.org/wiki/SlimDX), that supports Dx 10.1 and has beta support for Dx 11. They note “Although Direct3D 11 support is available, it’s new and minimally tested. It would be a good idea to stick with the current Subversion source tree of SlimDX if you’re working with it.”. I don’t know if that support includes compute shaders.

One does not simply walk into P/Invoke. It’s a horrid wasteland, many a soul ventured there never to come back. Think twice about entering and have your trusty sword and debugger ready if you do.

You might also try C++/CLI; this .NET Frankenstein interfaces with native C/C++ fairly seamlessly (at the expense of producing code that is a mangled mix of native binary and managed IL) and you should be able to use Dx from there. CUDA not so much (it doesn’t work with /MD). OpenCL might work.

Hi there,

have a look at SlimDX at http://slimdx.org/
It’s a full DirectX 9, 10 and 11 wrapper in managed C++ which then can be used directly in C#.

And here is a link to a DirectCompute example in C#:
http://recreationstudios.blogspot.com/2010…er-example.html

I’ve been using SlimDX now for about 2 years and I have to say, these guys rock… very quick in updating SlimDX when a new version of the DirectX SDK comes out, quick on fixes and if you go to the DirectX forum on gamedev.net, they respond to questions and are very helpful… plus you get the full source in case you want to mess with it, though in the two years I’ve used it, I haven’t found a need for that.

Happy Managed SuperComputing…

Hi there,

have a look at SlimDX at http://slimdx.org/
It’s a full DirectX 9, 10 and 11 wrapper in managed C++ which then can be used directly in C#.

And here is a link to a DirectCompute example in C#:
http://recreationstudios.blogspot.com/2010…er-example.html

I’ve been using SlimDX now for about 2 years and I have to say, these guys rock… very quick in updating SlimDX when a new version of the DirectX SDK comes out, quick on fixes and if you go to the DirectX forum on gamedev.net, they respond to questions and are very helpful… plus you get the full source in case you want to mess with it, though in the two years I’ve used it, I haven’t found a need for that.

Happy Managed SuperComputing…

Thanks for sharing the post with us.

Web Development Services

Thanks for sharing the post with us.

Web Development Services

You can also check out GPU.NET. We’re releasing the beta in a couple of weeks, and you’ll be able to write pure C# and run it on your GPU (nothing else required, just compile and run!)

You can also check out GPU.NET. We’re releasing the beta in a couple of weeks, and you’ll be able to write pure C# and run it on your GPU (nothing else required, just compile and run!)

You can also use Windows API Codepack but only after applying fix1 and fix2 I provided.

You can also use Windows API Codepack but only after applying fix1 and fix2 I provided.

SlimDX is probably the answer to your question.

If you wanted something more cross platform you might want to look at OpenTK (OpenGL wrapper) and Cloo (OpenCl)

This site has many examples this being one of the more advanced

http://www.cmsoft.com.br/index.php?option=com_content&view=category&layout=blog&id=99&Itemid=150

I’m guessing you could use Cloo with OpenCL’s DirectX integration but then you would need something like SlimDX anyway and at that stage you may as well go DirectCompute as well.

Hi Big_Mac,

Great information thanks for sharing…

Miha Markic you are right. I am using c# in the same format you have discussed here. This works.


Georgia Driving Record |Online Traffic School |Drivers Ed Online">

Hey Big_Mac thanks for sharing a work round for time being… before we shift into Direct3D


Joshua’s Law | DDS Practice Test