Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yeah I've experimented with caching vertex arrays in a scenario very similar to ImGui. It's gotta be faster when there's thousands of frames with zero changes, right?

Turns out, not really. It's very easy to make performance worse like this. I'm sure you can find scenarios where it makes sense, but in general it's just not a big deal.



If writing the low level gpu handling code, the easy cases to handle are the 100% constant data case and the 100% dynamic data case. Anything else counts as 100% dynamic, pretty much, and it's a pain to deal with because you also have to take a copy of the original data. You don't know which bits won't get overwritten, and the contents of those areas need saving regardless.

This can work out as a net positive, because copying memory can be cheap compared to recalculating the data it contains. But if your API requires the caller to resubmit all the data on every frame, it makes no difference.

(Which is not to suggest there's anything wrong with requiring the caller to resubmit all the data, if it makes life easier for them. The worst case needs to perform well and one way of making sure it does is to make sure it's exercised all the time.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: