-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Reduce zero initialization and copying overhead of render commands #17471
Conversation
db29911
to
6ce0b12
Compare
6ce0b12
to
234c1f0
Compare
if (size < size_) { | ||
size_ = size; | ||
} else { | ||
// TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should have an assert or something? I don't think anything's using this right now, though.
I do wonder if there might've been a way to coax the compiler to do less copying with enough move/emplace, but this is probably safer. I assume it's also faster in debug anyway...
-[Unknown]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually tried a bunch of things, but when looking at the disassembly, still lots of zeroing and copying. So gave up and did it this way. And yes, it helps debug performance indeed.
Followup to #17471: Fix Lubos' VR sky clearing hack
This introduces yet another custom vector, this time one specialized for cheaply adding items that don't need to be fully initialized, like our graphics command unions. It simply has a push_uninitialized() method that returns a pointer to the new item. std::vector simply can't do that.
This saves both zero-initialization of the structs and copying of the structs during push_back to the vectors.
So, this new vector is now used for command lists in both OpenGL and Vulkan backends. OpenGL gets the biggest wins here, sometimes up to a 8% detectable performance increase when profiling on PC (!). Vulkan only gets maybe 1-2% since those command structs are generally smaller I guess, and there are less of them since more state is passed in other ways like in pipeline keys.
Not intending to merge this until after the 1.15 process.