Skip to content

Commit

Permalink
Vulkan: Fix race condition when changing MSAA mode with the game runn…
Browse files Browse the repository at this point in the history
…ing "behind" the menu.
  • Loading branch information
hrydgard committed Jan 23, 2024
1 parent 4605cfd commit 5109727
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Common/GPU/Vulkan/thin3d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,14 @@ class VKContext : public DrawContext {
void ResetStats() override {
renderManager_.ResetStats();
}
void StopThreads() override {
renderManager_.StopThreads();
}

void StartThreads() override {
renderManager_.StartThreads();
}


std::string GetInfoString(InfoField info) const override {
// TODO: Make these actually query the right information
Expand Down
4 changes: 4 additions & 0 deletions Common/GPU/thin3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@ class DrawContext {
targetHeight_ = h;
}

// In Vulkan, when changing things like MSAA mode, we can't have draw commands in flight (since we only support one at a time).
virtual void StopThreads() {}
virtual void StartThreads() {}

virtual std::string GetInfoString(InfoField info) const = 0;
virtual uint64_t GetNativeObject(NativeObject obj, void *srcObject = nullptr) = 0; // Most uses don't need an srcObject.

Expand Down
2 changes: 2 additions & 0 deletions GPU/Common/FramebufferManagerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2810,7 +2810,9 @@ void FramebufferManagerCommon::NotifyRenderResized(int msaaLevel) {
PSP_CoreParameter().renderScaleFactor = scaleFactor;

if (UpdateRenderSize(msaaLevel)) {
draw_->StopThreads();
DestroyAllFBOs();
draw_->StartThreads();
}

// No drawing is allowed here. This includes anything that might potentially touch a command buffer, like creating images!
Expand Down

0 comments on commit 5109727

Please sign in to comment.