Mesh output preview doesn't discard primitives whose all vertices have a zero W component set in clip space
In the case of the app I'm working with, the affected triangles have all their X, Y and Z components set to ridiculously high values, while Ws are zeroed out. Such primitives are dropped during clipping, so the preview should not be taking them into account.
I'm having a hard time visualising the problem. If the triangles have W zeroed out, shouldn't it all come out in the maths that they're still zeroed after reprojection for the preview so they'll still be clipped? Or am I missing something.
Pictures speak louder than words, so check out the trace at https://www.dropbox.com/s/ye9r07hvnycrbv4/capture.zip?dl=0 . The problem can be repro'ed by selecting the glMultIDrawArraysIndirect() invocation, and by switching to the WASD mode. This gives us:

..and if you try moving around the scene, everything goes haywire.
Oh I see, I thought the vertex shader was culling primitives by transforming them to something that is clipped, but the data is actually in the mesh input.
The main problem here is the calculated bounding box is huge (which is the blue lines), and the length of the bounding box diagonal is used to calculate the default camera speed. If you open the settings menu (
) and set the camera speed to something sensible, it works better:

As to fixing this... I'm not sure what the way to go is. Because it's vertex input I have no way of knowing that the primitives will be clipped - for all I know the vertex shader will transform them to something sensible, and there's no guarantee that w of the position actually corresponds to the output. I'm leaning towards saying this is "garbage in, garbage out".
I could perhaps discard invalid values when calculating the bounding box, but then you have to ask the question of "what is invalid" - the values in this case aren't FLT_MAX or -FLT_MAX, they're 0xdddddddd. It's easy to recognise from the hex pattern but as floats I'm very wary of adding some kind of "oh no-one will have verts this large" number. I've already clamp the camera speed, it doesn't go higher than 1000, but e.g. this could be a sensible value if someone's mesh is in mm units so I don't want to reduce this upper bound.
The only thing I did notice is that when you reset the view on VS Output it doesn't reset and choose a sensible camera speed for the output frustum which has I believe correctly detected the near/far plane. I can fix that, but for the input I'm not sure exactly what you would propose to even change?
Agreed, VS Input should remain a black-box for RenderDoc. It makes sense to never make any hard assumptions as to what space the vertices are expressed in, whether or not they are compressed, and so on. A potential enhancement here would be to let the user somehow tell RenderDoc what assertions it can make in regard to the vertex data, but the number of hints the tool would eventually expose to the user would become unmaintanable, so I guess it's better to stay where we are.
VS Output is another story though. Getting the issues you found fixed sounds like a good task for Monday or sth :-)
It's a minor change, just when you click the autofit/reset buttons on VS output to set the camera speed as well.
There's an issue that's been open for a while #162 which I was planning to solve by having custom vertex transform shaders in an analogous way to the custom texture decode shaders for the tex viewer. The idea then would likely be that the shader would be defined not directly as an entry point but just as a function like float4 transform_vertex(float4 vert), so it could either be wrapped as a VS to render the preview, or wrapped as a CS to calculate the bounding box.
Checking this again today this seems to have been fixed sometime in the last almost 2 years (I'm very good at looking at bugs in a timely fashion...). At least the vertex output fits and sets a speed properly, the input is still running into problems with 0xdddddddd positions although not quite as badly as before.