Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize meshopt_computeMeshletBounds #17

Merged
merged 1 commit into from
Mar 6, 2019
Merged

Conversation

gwihlidal
Copy link
Contributor

Optimize meshopt_computeMeshletBounds by passing in pointer to meshlet instead of by value (636 bytes)

@zeux
Copy link
Owner

zeux commented Jan 13, 2019

This effectively reverts 925ff15; the premise of that change was that the callers in C/C++ would prefer pass-by-value since it's more intuitive than passing a singular pointer (in C++ I'd pass a const ref, but the interface is C89), and the performance penalty is negligible.

My mild preference is to keep the pass by value, but I'll need to double check what the performance impact is (if it's noticeable then we should definitely pass by pointer), whether any languages have issues with FFI when passing structs by value (probably not?) and also I'm not sure how idiomatic it is to pass by value vs by singleton pointer in C in general...

@zeux
Copy link
Owner

zeux commented Jan 16, 2019

Here's data from sanMiguel.obj on a revised version of this change where meshopt_computeMeshletBoundsPtr calls computeMeshletBounds (and does the copying-to-stack required):

image

So this suggests that out of 242ms generating bounds data for meshlets, we spend 3ms copying, making the copy overhead ~1%. That's with the default meshlet parameters (64 max vertices, 126 max triangles), however my sanMiguel model has very poor vertex-triangle ratio, so the average meshlet ends up having 26 triangles which basically maximizes the copying cost relative to computation cost - on more reasonable models the overhead should be below 1% as the avg triangle count/meshlet should be around 90.

So unless there's any issues with FFI (I've double checked and it seems like well known FFIs all support passing structs by value?), I'd prefer to close this - let me know if my reasoning feels off!

@zeux
Copy link
Owner

zeux commented Mar 6, 2019

Since this came up again in a linked issue I'm having second thoughts and leaning to merging this. The performance impact is minimal but it seems like it's better to pass meshlet by pointer for now. Eventually I kinda want to redesign the meshlet API to not have a structure with hardcoded limits but this complicates the meshlet builder - for now pointer is fine I guess. Let me try to see if I can reopen & merge this...

@zeux zeux reopened this Mar 6, 2019
@zeux zeux merged commit 5bea116 into zeux:master Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants