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

Reduce zero initialization and copying overhead of render commands #17471

Merged
merged 10 commits into from
May 23, 2023

Conversation

hrydgard
Copy link
Owner

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.

@hrydgard hrydgard added this to the v1.16.0 milestone May 16, 2023
@hrydgard hrydgard changed the title Reduce zero initialization Reduce zero initialization and copying overhead of render commands May 16, 2023
@hrydgard hrydgard force-pushed the reduce-zero-initialization branch from db29911 to 6ce0b12 Compare May 17, 2023 07:41
@hrydgard hrydgard added OpenGL Vulkan GE emulation Backend-independent GPU issues labels May 17, 2023
@hrydgard hrydgard marked this pull request as ready for review May 23, 2023 06:47
@hrydgard hrydgard force-pushed the reduce-zero-initialization branch from 6ce0b12 to 234c1f0 Compare May 23, 2023 06:54
@hrydgard hrydgard merged commit 8d7c561 into master May 23, 2023
20 checks passed
@hrydgard hrydgard deleted the reduce-zero-initialization branch May 23, 2023 07:14
Common/GPU/OpenGL/GLQueueRunner.cpp Show resolved Hide resolved
if (size < size_) {
size_ = size;
} else {
// TODO
Copy link
Collaborator

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]

Copy link
Owner Author

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.

Common/VR/PPSSPPVR.cpp Show resolved Hide resolved
hrydgard added a commit that referenced this pull request Jun 4, 2023
Followup to #17471: Fix Lubos' VR sky clearing hack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GE emulation Backend-independent GPU issues OpenGL Vulkan
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants