Sign in to follow this  
Maarten Baert

[Direct3D] software vs hardware vertex processing

Recommended Posts

Hardware vertex processing is a lot faster than software vertex processing, but it's also very limited (maximum number of lights, for example) and the capabilities depend on the type of video card used. So I was wondering, is it a good idea to use hardware vertex processing without lighting, and just do the lighting calculations myself? That way the GPU handles the simple matrix transformations and the CPU handles the lighting calculations. Is this a good idea or is this even slower than normal software vertex processing?

Share this post


Link to post
Share on other sites
If you're looking to have tons of lights affecting each object, consider doing your lighting in a deferred shading / deferred lighting style, which decouples the geometry from the lighting.

Otherwise, yes, you'll run into hardware limits trying to stuff the data for every light through a vertex shader. ~4-8 is probably feasible, though.

Share this post


Link to post
Share on other sites
Hardware vertex processing would be by far the better option unless you are talking about some seriously old / low-end graphics hardware. Remember that doing vertex processing in SW: a) can make you CPU bound, and b) will require you to stream vertices across the PCIE bus, which can easily become a limiter.

If you want a lot of lights, there is deferred shading as RDragon1 mentioned. Also if you have a large amount of unclipped geometry data (approx. num_vertices > pixels * back_to_front_overdraw_factor), it may even be more efficient do to the lighting calculations in the pixel shader (not to mention the better image quality you would get by interpolating normals instead of lit-vertex colors).

Share this post


Link to post
Share on other sites
You can pretty much assume vertex shader 2.0 support as a base and even 3.0 would be a very reasonable target. So you're not too limited in features. If you require tons of lights, you might want to consider alternate lighting models, such as PRT. In any case, it's not a good idea to do any heavy calculations on the CPU at runtime. GPU's deal a lot better with large amounts of vector math.

Share this post


Link to post
Share on other sites
Quote:
Original post by Maarten Baert
Hardware vertex processing is a lot faster than software vertex processing, but it's also very limited (maximum number of lights, for example) and the capabilities depend on the type of video card used. So I was wondering, is it a good idea to use hardware vertex processing without lighting, and just do the lighting calculations myself? That way the GPU handles the simple matrix transformations and the CPU handles the lighting calculations. Is this a good idea or is this even slower than normal software vertex processing?


Only if your target is, say, DirectX 6 level hardware. Even then, probably not. Use shaders.

Share this post


Link to post
Share on other sites
Thanks everyone, your replies have really helped me.

One more question: is the method I mentioned still useful to calculate vertex lighting for static models (like the terrain), or should I just use shaders everywhere?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this