Sign in to follow this  
Rompa

Shader LOD and SetStreamSource

Recommended Posts

Rompa    307
I was wondering if someone had some answers to the following questions, hopefully with experience through a use case: 1) I want to support some nice shader LOD without necessarily changing my geometry. The aim is to make it cheaper to render stuff in the distance (no kidding). I thought that perhaps I could have one stream with pos,nrm,tex and another with tangent (and optional bitangent or handedness factor for derivation via cross product with normal). To switch to the lower LOD, I wouldn't need to change vertex buffers, only vertex declarations (how expensive are these?), shaders and only use stream 0. This also means for cards that won't have normal mapping due to performance, I simply don't load that data and don't need to waste time populating meshes on load with components stripped out. Thoughts? 2) I would like to put all my vertices of some large models in one vertex buffer and use SetStreamSource to simply change the offset and vertex stride, but NOT change the vertex buffer. I have the offset and stride calculated in my tool offline so that's easy, but I'm thinking that some drivers may be "dumb" and assume I'm swapping a vertex buffer and do some nasty stall or re-upload my VB or something equally bad for performance rather than simply adjust an offset value within the driver. Thoughts? I do appologise for not testing all this myself, but (1) I sincerely don't have time on my current project and (2) I thought perhaps these techniques and associated discussion may prove useful for others. Thanks a heap!

Share this post


Link to post
Share on other sites
ET3D    810
Quote:
Original post by Rompa
I was wondering if someone had some answers to the following questions, hopefully with experience through a use case:

1) I want to support some nice shader LOD without necessarily changing my geometry. The aim is to make it cheaper to render stuff in the distance (no kidding). I thought that perhaps I could have one stream with pos,nrm,tex and another with tangent (and optional bitangent or handedness factor for derivation via cross product with normal). To switch to the lower LOD, I wouldn't need to change vertex buffers, only vertex declarations (how expensive are these?), shaders and only use stream 0. This also means for cards that won't have normal mapping due to performance, I simply don't load that data and don't need to waste time populating meshes on load with components stripped out. Thoughts?

Why not use just one buffer and one declaration? Your shader can ignore the data that's not relevant. That's likely to be easier to play with.

Quote:
2) I would like to put all my vertices of some large models in one vertex buffer and use SetStreamSource to simply change the offset and vertex stride, but NOT change the vertex buffer. I have the offset and stride calculated in my tool offline so that's easy, but I'm thinking that some drivers may be "dumb" and assume I'm swapping a vertex buffer and do some nasty stall or re-upload my VB or something equally bad for performance rather than simply adjust an offset value within the driver. Thoughts?

Even if a driver might do something like that, it'd still be no worse than changing vertex buffers, so you should be able to use this method without worrying that it'd be detrimental to performance. That said, too large buffers (many MB) are said to be slower than reasonably sized ones (a few MB) so it's a better idea to put the vertices of the small models into one buffer, and not too many large ones.

Share this post


Link to post
Share on other sites
I personally came to the conclusion that bothering with shader LOD is fairly pointless. Why? Well, if you're going to down-shift your shader detail, why wouldn't you also be using a lower-LOD mesh? The two can just be bound together, including any adjustments to draw state. Any hardware that can't handle "advanced" techniques like normal mapping are also probably not going to have the geometry throughput to handle higher polycount models either, so anybody with that class of card just never sees LOD0.

Anyways, those were my thoughts.

Share this post


Link to post
Share on other sites
Rompa    307
Quote:
Why not use just one buffer and one declaration? Your shader can ignore the data that's not relevant. That's likely to be easier to play with.

Mainly due to bus bandwidth, I'm trying to keep the vertices as small as possible where ever possible. Your experience is that a fatter vertex size doesn't matter so much?

Quote:
Any hardware that can't handle "advanced" techniques like normal mapping are also probably not going to have the geometry throughput to handle higher polycount models either, so anybody with that class of card just never sees LOD0.

A good point, well made - noted :-)

Share this post


Link to post
Share on other sites
sirob    1181
Quote:
Original post by Rompa
Quote:
Why not use just one buffer and one declaration? Your shader can ignore the data that's not relevant. That's likely to be easier to play with.

Mainly due to bus bandwidth, I'm trying to keep the vertices as small as possible where ever possible. Your experience is that a fatter vertex size doesn't matter so much?

It certainly might matter, but there's just no point bending over backwards trying to fix something that might not even be an issue. If, when you're done writing it, you determine this to be a bottleneck, you can then make changes to improve on the situtation. Until that happens, there's no point in attempting to fix it.

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