MFnMesh deformer with CUDA

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  05 May 2013
MFnMesh deformer with CUDA


I created a deformer and accelerated bottlenecks with CUDA. However, I'm not sure how to overcome the costly the cpu/gpu memory transfer. What I currently do is:

1. MFnMesh_getPoints(P).
2. Upload P to gpu memory.
3. Run the deformer cuda kernel.
4. Download the result from the gpu memory to P.
5. MFnMesh_setPoints(P).
6. MFnMesh_updateSurface(), which redraws the mesh by uploading P again to the gpu in the background.

All the redundant transfers of P from gpu to cpu are costly. Is there away to update the opengl structure that is associated with the mesh vertices directly?
  05 May 2013
I have no idea how it all works with cuda. But I'm quite interested.

May I ask if you did openMP or thread pooling multithreading before implementing in cuda? How fast was it before and with multithreading and with cuda?

Maybe you can have a look at the openSubdiv repository, they have massive geometry data as well which needs to be drawn on the screen.
__________________ -
  05 May 2013
I use OpenMP when I can, since it's quite effortless to add it. Also it's enough for me, such that I don't remember the last time I employed a thread pool.

CUDA is an art, and you need to be quite an expert to beat the cpu (with openmp). Usually I don't bother, since it's quite a hassle, but if you are in dire need for more speed, then usually this is the only option that might help. In my deformer I only used the off-the-shelf cublas, which Nvidia's experts were kind enough to provide. Meaning, first look if some expert already wrote a cuda library to what you are doing, and it should be quite straight forward to use it.
I don't exactly remember the performance boost of using cublas vs. cpu in my deformer, but I think it's a factor of ~2. In any case the cuda manual should contain comparison graphs. Usually the factor is much higher, depends on the task at hand.

I guess instead of MFnMesh, I could always write my own object that renders opengl (sharing a buffer with cuda), and it might even be the easiest solution (maybe derive from MFnMesh and override the draw?). It's seems that OpenSubdiv might provide such a solution and more. I'm not sure I would have time to play with it, but it does look interesting.
  05 May 2013
What do you do with deformed object? Do you want only to show it in viewport?

If you only want to show it in viewport than have a look at simpleGL example in CUDA SDK I guess it might be helpfull.

If you need to pass the deformed mesh to another node than you probably have no choice than transfer the mesh from host to device and back. Or you can make custom attribute, something like GPUmesh, so you would pass a pointer to the GPU memory.
  05 May 2013
I already found an example how to access from a kernel a VBO, but an official example from the cuda sdk is the best.

Optimally I would like to have a mesh with the standard capabilities such as editing components and connecting to other nodes, but with additional feature that I can edit the vertex array directly on the GPU, when all I require is to update the view (e.g. in my deformer). Meaning, for all the rest of the operations it should behave normally, and I have no problem with transferring data to the host.
So it would be cumbersome to work with a node that can just draw itself, and doesn't have the standard mesh interface. I am thinking more in the direction of overriding the draw method of MFnMesh (and yet again, I wish maya was an open source).
  05 May 2013
I smell a lot of trouble there. It wouldn't be sufficient to only overwrite draw function. You would have to write your whole new GPUmesh object and editing tools for it. I guess there is no problem with that but good luck a lot of work to be done.
  05 May 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 01:07 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.