Shader LOD and SetStreamSource

Started by
3 comments, last by sirob 17 years, 1 month ago
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!
Advertisement
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.
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.
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 :-)
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.
Sirob Yes.» - status: Work-O-Rama.

This topic is closed to new replies.

Advertisement