Reduce zero initialization and copying overhead of render commands#17471
Merged
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 |
Collaborator
There was a problem hiding this comment.
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]
Owner
Author
There was a problem hiding this comment.
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.
hrydgard
added a commit
that referenced
this pull request
Jun 4, 2023
hrydgard
added a commit
that referenced
this pull request
Jun 4, 2023
Followup to #17471: Fix Lubos' VR sky clearing hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.