CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-04-2013, 03:08 AM   #1
zoharl
A newbie
 
zoharl's Avatar
portfolio
Zohar
Wellington, New Zealand
 
Join Date: Mar 2009
Posts: 1,821
MFnMesh deformer with CUDA

Hi,

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?
 
Old 05-04-2013, 09:56 AM   #2
haggi
Expert
3d freelancer
 
Join Date: Apr 2004
Posts: 1,064
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.
__________________
www.renderwiki.com - www.openmaya.net
 
Old 05-04-2013, 10:34 AM   #3
zoharl
A newbie
 
zoharl's Avatar
portfolio
Zohar
Wellington, New Zealand
 
Join Date: Mar 2009
Posts: 1,821
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.
 
Old 05-15-2013, 12:56 AM   #4
zoharl
A newbie
 
zoharl's Avatar
portfolio
Zohar
Wellington, New Zealand
 
Join Date: Mar 2009
Posts: 1,821
 
Old 05-16-2013, 12:42 PM   #5
lecopivo
New Member
portfolio
s
none
nasdg, Albania
 
Join Date: Dec 2011
Posts: 17
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.
 
Old 05-16-2013, 04:09 PM   #6
zoharl
A newbie
 
zoharl's Avatar
portfolio
Zohar
Wellington, New Zealand
 
Join Date: Mar 2009
Posts: 1,821
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).
 
Old 05-24-2013, 06:13 PM   #7
lecopivo
New Member
portfolio
s
none
nasdg, Albania
 
Join Date: Dec 2011
Posts: 17
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.
 
Old 05-24-2013, 06:13 PM   #8
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 11:30 PM.


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