Jump to content
  • Advertisement
Sign in to follow this  
SeanO'Brien

DirectCompute

This topic is 2472 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to make use of the GPU as part of a project of mine. I've looked into both CUDA and OpenCL, but the lack of information showing you how to introduce these into a project is shocking. Even their dedicated forum groups are dead. So now, I'm looking into DirectCompute.

From what I can tell, it's simply a new type of shader file that makes use of HLSL. My question is this, does my program (aside from being DirectX 10 / 11 ) need it's structure changed?

I mean, is it simply a case of creating the CS file, setting in the project like I would any other shader, and watch the magic happen?

Any information on this would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
I've never used Direct Compute so I can't help you there, but I've used CUDA. I found it annoying to set up, but once it was working very easy to use. Its also come a long way since I used it a few years ago. A good place to start is here: http://developer.nvidia.com/cuda-toolkit. Not that this directly answers your question, but perhaps it will help ;)

Share this post


Link to post
Share on other sites
Compute shaders have to compiled into a binary form by a special compiler. This compiler is available at runtime via D3DCompile, or it it's packed as a command-line executable called fxc.exe (included in the DirectX SDK, or the Windows 8 SDK). Most games precompile shaders because they will have lots of them, and some of them can take a little while to compile. However depending on your needs it might be fine to just compile at runtime from a text file. Since they use a different compiler you don't actually need to add them to your visual studio project. However it is possible to add them and set up a custom build rule that uses fxc.exe to compile them. Then at runtime you use your shaders by creating D3D11 device + context using the API, and then you bind your shader + constants + input/output buffers to the context and call Dispatch to execute the shader.

Based on your needs, you might be interested in checking out C++ AMP instead. It's basically a framework that lets you write special C++ code which then gets executed on the GPU using DirectCompute. It might make things a lot easier for you if you're not familar with D3D and shaders.

Share this post


Link to post
Share on other sites
As you can see from this slide #17 from the following Microsoft

http://channel9.msdn...uting-and-C-AMP

Cuda and OpenCL is pretty low level so that's why you will find it hard to find any good tutorials on it.
I've just started working with OpenCL and used this book and couldn't believe how much work it was just to simple programs up and running compared to DirectX, OpenGL, Allegro, SDL, etc number of other stuff I have worked with!

So it looks like Microsoft is introducing C++ AMP to make it easier.
Haven't had a chance to work with it so not sure if it makes anything easier.

Well if you are using C# have you tried this OpenCL tutorial?
http://www.cmsoft.com.br/index.php?option=com_content&view=category&layout=blog&id=41&Itemid=75

Looks easier than using the OpenCL language.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!