Jump to content
  • Advertisement
Sign in to follow this  
Heodox

OpenGL Skinning in software

This topic is 3816 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'm trying to implement model skinning in software opengl (not using shaders). The animation works, the problem is the speed, first it was done directly by calling glbegin/glend , and using glVertex... This was SLOW (~10 fps), now i implemented it with glDrawArrays and it is still prety slow (~25 fps). the skin data is stored along with vertex data in standard shader skinning format (one bone_index vec4, and one weight_index vec4) I'm wondering what would be the best/fastes way of doing this?

Share this post


Link to post
Share on other sites
Advertisement
Get a profiler and figure out where the bottleneck is. It's possible that your GPU is faster at transforming verts than your CPU is.

Why are you trying to do software skinning? How long was it taking the GPU to skin the verts? Was the bottleneck really the transform?

Share this post


Link to post
Share on other sites
Quote:
Original post by RDragon1
Get a profiler and figure out where the bottleneck is. It's possible that your GPU is faster at transforming verts than your CPU is.




i think the biggest bottle neck is that i calculate every vertex like this on CPU:

v += mat[ind1] * original_v * weight1
v += mat[ind2] * original_v * weight2
v += mat[ind3] * original_v * weight3
v += mat[ind4] * original_v * weight4

but if i remove this (the model is not moving) i still get prety bad results (200-400-600 fps, very jumpy ), also i get very jumpy results for display lists 200-400-800 fps.

Quote:
Original post by RDragon1
Why are you trying to do software skinning? How long was it taking the GPU to skin the verts? Was the bottleneck really the transform?


I'm trying to add as much compatibility to the engine as i can (this would mainly be character animation without shaders), the skinning on gpu is not implemented yet but i know it will be fast (did it on last project).

I belive the bottlenect mostly to be transform, but i also now think there is something else slowing it down.


also what profiler would you recomend? (i'm using visual studio 2008 if that is of any importance)

Share this post


Link to post
Share on other sites
You would need to optimize it with some intrinsics or inline assembly SSE.

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
You would need to optimize it with some intrinsics or inline assembly SSE.


It's unlikely to give you a huge boost to frame rates though, chances are the bottlenecks are 1) the amount of memory that needs to be read/written 2) the time it takes to upload the vertex array to the graphics card. SSE might give you slightly better performance, however simply using openMP and a #pragma omp parallel for would be a better idea. Better still would be to utilise data compression for the vtx data to minimise the amount of data you need to read.

Quote:

I belive the bottlenect mostly to be transform, but i also now think there is something else slowing it down.


Software skinning shouldn't be that slow, i can do around 1 million verts at playable frame rates (though it is admittedly heavily optimised and multi-threaded). I suspect you have something nasty going on such as a floating point exception or division by zero. Try turning on all exceptions in your debugger and see if anything gets triggered. Alternatively vtune would probably be able to identify the problem (probably the best tool for this job - assuming you have an intel processor).

Share this post


Link to post
Share on other sites
Quick *profiling* could be also disabling all drawing and check CPU only fps. This way you can quickly confirm if it is CPU or transfer/GPU bottleneck.

Share this post


Link to post
Share on other sites
Quote:
Original post by MaR_dev
Quick *profiling* could be also disabling all drawing and check CPU only fps. This way you can quickly confirm if it is CPU or transfer/GPU bottleneck.


The fps doesn't change if i turn off the the draw calls, so it is purely cpu bottleneck.

I've managed to do a couple optimizations and now debug version has 45 fps and release version 350 fps.

I see one more big optimization that i can do is to compress vertex data (as suggested by RobTheBloke), but else from that i can't see anything more i can do (profiler showed me some stupid stuff i did, and now that is removed)

Share this post


Link to post
Share on other sites
Quote:
Original post by Heodox
The fps doesn't change if i turn off the the draw calls, so it is purely cpu bottleneck.


Disable all rendering (and buffer swapping), then you'll have a true indication of the performance. Don't forget that any SwapBuffers call takes a fairly long time to complete..... probably longer than your skinning computation.

I'd also try experimenting with openMP to do something like:


#pragma omp parallel for
for(int i=0;i<num_verts;++i)
{
v = 0;
v += mat[ind1] * original_v * weight1
v += mat[ind2] * original_v * weight2
v += mat[ind3] * original_v * weight3
v += mat[ind4] * original_v * weight4
}


For small data sets, you should see an improvement (i.e. if the skin/vtx data fits nicely in CPU cache) - assuming of course you have a dual or quad core CPU... (make sure you enable openMP in your project settings...)

If you mesh data is large, you won't see any difference and compression is your only option.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!