agi icon indicating copy to clipboard operation
agi copied to clipboard

Indexed Draw reports Index Count as Vertex Count

Open alecazam opened this issue 2 years ago • 2 comments

Environment information:

  • AGI version: 2022-3.0.1:d7f82c3dda2df3d81e7b67157da8668c4242511c
  • Host OS: macOS If tracing on Android:
  • Device model: S10e
  • Android Version: Android 12

Bug description I'm looking at vkCmdDrawIndexed calls and the vertexCount = 3 x primCount. That implies the draws are unwelded, but their not. There's a lot of vert sharing that is reflected in the Apple GPU capture. This data needs to be accurate, or else flagged that it's just an estimate.

I tried exporting a draw to Obj from the Geometry panel, and it was completely unwelded and had no vertices shared unlike the original model. So that made me question whether our data was welded at all. But Apple Gpu capture shows the shared indices.

Reproduction steps Capture any scene with indexed draws, and look at the Performance panel. Note that the primitiveCount, Byte Count, etc are not correct for shared indices which is why we're using indexing in the first place.

Stacktrace N/A

Screenshots image

Additional debugging information

alecazam avatar Jun 08 '22 19:06 alecazam

This is especially problematic on Android, since every draw call copies the entire transformed vb (vertex shader output) to the parameter buffer. So if we have multiple indices sparsely referencing the same vb, this overflows the parameter buffer when sharing indices.

alecazam avatar Jun 08 '22 19:06 alecazam

Hi, thanks for filing the issue. Based on https://github.com/google/agi/blob/master/gapis/api/vulkan/profile_static_analysis.go#L263 we calculate the primitiveCount based on the and the indexBuffer (in the case of DrawIndexed). The misunderstanding here seems to be from how we set the Vertex Count as the count of indices for DrawIndexed (You can confirm that the vertex count corresponds to the indices count in the geometry pane, which is why vertex count = primitive count x 3)

image

Thanks for flagging this, we can definitely add more clarification to avoid confusion in the future

I tried exporting a draw to Obj from the Geometry panel, and it was completely unwelded and had no vertices shared unlike the original model. So that made me question whether our data was welded at all. But Apple Gpu capture shows the shared indices.

I don't have the most visibility in this part of the codebase, but will try to find out the answer for you.

ttanatb avatar Jun 09 '22 18:06 ttanatb