Skip to content

Commit

Permalink
Merge pull request #17831 from hrydgard/no-inflight-no-multithreading
Browse files Browse the repository at this point in the history
Vulkan: Don't use multithreaded rendering if buffer commands (frames in flight) is set to 1
  • Loading branch information
hrydgard authored Aug 1, 2023
2 parents 3c41420 + ffd5e57 commit 7538807
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
1 change: 0 additions & 1 deletion Common/GPU/thin3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,6 @@ class DrawContext {

// Total amount of frames rendered. Unaffected by game pause, so more robust than gpuStats.numFlips
virtual int GetFrameCount() = 0;
virtual int GetFramesInFlight() { return 3; }

protected:
ShaderModule *vsPresets_[VS_MAX_PRESET];
Expand Down
6 changes: 5 additions & 1 deletion SDL/SDLVulkanGraphicsContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int w, in
return false;
}

draw_ = Draw::T3DCreateVulkanContext(vulkan_, g_Config.bRenderMultiThreading);
bool useMultiThreading = g_Config.bRenderMultiThreading;
if (g_Config.iInflightFrames == 1) {
useMultiThreading = false;
}
draw_ = Draw::T3DCreateVulkanContext(vulkan_, useMultiThreading);
SetGPUBackend(GPUBackend::VULKAN);
bool success = draw_->CreatePresets();
_assert_(success);
Expand Down
7 changes: 6 additions & 1 deletion Windows/GPU/WindowsVulkanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ bool WindowsVulkanContext::Init(HINSTANCE hInst, HWND hWnd, std::string *error_m
return false;
}

draw_ = Draw::T3DCreateVulkanContext(vulkan_, g_Config.bRenderMultiThreading);
bool useMultiThreading = g_Config.bRenderMultiThreading;
if (g_Config.iInflightFrames == 1) {
useMultiThreading = false;
}

draw_ = Draw::T3DCreateVulkanContext(vulkan_, useMultiThreading);
SetGPUBackend(GPUBackend::VULKAN, vulkan_->GetPhysicalDeviceProperties(deviceNum).properties.deviceName);
bool success = draw_->CreatePresets();
_assert_msg_(success, "Failed to compile preset shaders");
Expand Down
6 changes: 5 additions & 1 deletion android/jni/AndroidVulkanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ bool AndroidVulkanContext::InitFromRenderThread(ANativeWindow *wnd, int desiredB

bool success = true;
if (g_Vulkan->InitSwapchain()) {
draw_ = Draw::T3DCreateVulkanContext(g_Vulkan, g_Config.bRenderMultiThreading);
bool useMultiThreading = g_Config.bRenderMultiThreading;
if (g_Config.iInflightFrames == 1) {
useMultiThreading = false;
}
draw_ = Draw::T3DCreateVulkanContext(g_Vulkan, useMultiThreading);
SetGPUBackend(GPUBackend::VULKAN);
success = draw_->CreatePresets(); // Doesn't fail, we ship the compiler.
_assert_msg_(success, "Failed to compile preset shaders");
Expand Down
6 changes: 5 additions & 1 deletion libretro/LibretroVulkanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ void LibretroVulkanContext::CreateDrawContext() {
return;
}

draw_ = Draw::T3DCreateVulkanContext(vk, true);
bool useMultiThreading = g_Config.bRenderMultiThreading;
if (g_Config.iInflightFrames == 1) {
useMultiThreading = false;
}
draw_ = Draw::T3DCreateVulkanContext(vk, useMultiThreading);
((VulkanRenderManager*)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER))->SetInflightFrames(g_Config.iInflightFrames);
SetGPUBackend(GPUBackend::VULKAN);
}
Expand Down

0 comments on commit 7538807

Please sign in to comment.