mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-10-07 19:03:29 +00:00
GPU: Restart when changing inflight frames setting.
We need to keep the push and pull in step, so changing at runtime is messy.
This commit is contained in:
parent
fa8968f5c6
commit
051a84e9bd
@ -774,7 +774,7 @@ static ConfigSetting graphicsSettings[] = {
|
||||
ConfigSetting("GfxDebugSplitSubmit", &g_Config.bGfxDebugSplitSubmit, false, false, false),
|
||||
ConfigSetting("LogFrameDrops", &g_Config.bLogFrameDrops, false, true, false),
|
||||
|
||||
ConfigSetting("InflightFrames", &g_Config.iInflightFrames, 3, true, true),
|
||||
ConfigSetting("InflightFrames", &g_Config.iInflightFrames, 3, true, false),
|
||||
|
||||
ConfigSetting(false),
|
||||
};
|
||||
|
@ -97,9 +97,6 @@ GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||
|
||||
textureCacheGL_->NotifyConfigChanged();
|
||||
|
||||
GLRenderManager *rm = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
rm->SetInflightFrames(g_Config.iInflightFrames);
|
||||
|
||||
// Load shader cache.
|
||||
std::string discID = g_paramSFO.GetDiscID();
|
||||
if (discID.size()) {
|
||||
@ -358,9 +355,6 @@ void GPU_GLES::BeginHostFrame() {
|
||||
GPUCommon::BeginHostFrame();
|
||||
UpdateCmdInfo();
|
||||
if (resized_) {
|
||||
GLRenderManager *rm = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
rm->SetInflightFrames(g_Config.iInflightFrames);
|
||||
|
||||
CheckGPUFeatures();
|
||||
framebufferManager_->Resized();
|
||||
drawEngine_.Resized();
|
||||
|
@ -97,8 +97,6 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||
if (vulkan_->GetDeviceFeatures().enabled.wideLines) {
|
||||
drawEngine_.SetLineWidth(PSP_CoreParameter().renderWidth / 480.0f);
|
||||
}
|
||||
VulkanRenderManager *rm = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
rm->SetInflightFrames(g_Config.iInflightFrames);
|
||||
|
||||
// Load shader cache.
|
||||
std::string discID = g_paramSFO.GetDiscID();
|
||||
@ -284,9 +282,6 @@ void GPU_Vulkan::BeginHostFrame() {
|
||||
UpdateCmdInfo();
|
||||
|
||||
if (resized_) {
|
||||
VulkanRenderManager *rm = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
rm->SetInflightFrames(g_Config.iInflightFrames);
|
||||
|
||||
CheckGPUFeatures();
|
||||
// In case the GPU changed.
|
||||
BuildReportingInfo();
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
draw_ = Draw::T3DCreateGLContext();
|
||||
SetGPUBackend(GPUBackend::OPENGL);
|
||||
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
||||
bool success = draw_->CreatePresets();
|
||||
_assert_msg_(G3D, success, "Failed to compile preset shaders");
|
||||
}
|
||||
|
@ -74,6 +74,7 @@
|
||||
GameSettingsScreen::GameSettingsScreen(std::string gamePath, std::string gameID, bool editThenRestore)
|
||||
: UIDialogScreenWithGameBackground(gamePath), gameID_(gameID), enableReports_(false), editThenRestore_(editThenRestore) {
|
||||
lastVertical_ = UseVerticalLayout();
|
||||
prevInflightFrames_ = g_Config.iInflightFrames;
|
||||
}
|
||||
|
||||
bool GameSettingsScreen::UseVerticalLayout() const {
|
||||
@ -352,10 +353,7 @@ void GameSettingsScreen::CreateViews() {
|
||||
if (GetGPUBackend() == GPUBackend::VULKAN || GetGPUBackend() == GPUBackend::OPENGL) {
|
||||
static const char *bufferOptions[] = { "No buffer", "Up to 1", "Up to 2" };
|
||||
PopupMultiChoice *inflightChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInflightFrames, gr->T("Buffer graphics commands (faster, input lag)"), bufferOptions, 0, ARRAY_SIZE(bufferOptions), gr->GetName(), screenManager()));
|
||||
inflightChoice->OnChoice.Add([=](EventParams &e) {
|
||||
NativeMessageReceived("gpu_resized", "");
|
||||
return UI::EVENT_CONTINUE;
|
||||
});
|
||||
inflightChoice->OnChoice.Handle(this, &GameSettingsScreen::OnInflightFramesChoice);
|
||||
}
|
||||
|
||||
CheckBox *hwTransform = graphicsSettings->Add(new CheckBox(&g_Config.bHardwareTransform, gr->T("Hardware Transform")));
|
||||
@ -1191,6 +1189,15 @@ void GameSettingsScreen::CallbackRenderingDevice(bool yes) {
|
||||
}
|
||||
}
|
||||
|
||||
void GameSettingsScreen::CallbackInflightFrames(bool yes) {
|
||||
if (yes) {
|
||||
g_Config.Save("GameSettingsScreen::InflightFramesYes");
|
||||
System_SendMessage("graphics_restart", "");
|
||||
} else {
|
||||
g_Config.iInflightFrames = prevInflightFrames_;
|
||||
}
|
||||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnRenderingBackend(UI::EventParams &e) {
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
|
||||
@ -1214,6 +1221,15 @@ UI::EventReturn GameSettingsScreen::OnRenderingDevice(UI::EventParams &e) {
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnInflightFramesChoice(UI::EventParams &e) {
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
if (g_Config.iInflightFrames != prevInflightFrames_) {
|
||||
screenManager()->push(new PromptScreen(di->T("ChangingInflightFrames", "Changing graphics command buffering requires PPSSPP to restart. Restart now?"), di->T("Yes"), di->T("No"),
|
||||
std::bind(&GameSettingsScreen::CallbackInflightFrames, this, std::placeholders::_1)));
|
||||
}
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnCameraDeviceChange(UI::EventParams& e) {
|
||||
Camera::onCameraDeviceChange();
|
||||
return UI::EVENT_DONE;
|
||||
|
@ -44,6 +44,7 @@ protected:
|
||||
void CallbackRestoreDefaults(bool yes);
|
||||
void CallbackRenderingBackend(bool yes);
|
||||
void CallbackRenderingDevice(bool yes);
|
||||
void CallbackInflightFrames(bool yes);
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
void CallbackMemstickFolder(bool yes);
|
||||
#endif
|
||||
@ -97,6 +98,7 @@ private:
|
||||
UI::EventReturn OnRenderingMode(UI::EventParams &e);
|
||||
UI::EventReturn OnRenderingBackend(UI::EventParams &e);
|
||||
UI::EventReturn OnRenderingDevice(UI::EventParams &e);
|
||||
UI::EventReturn OnInflightFramesChoice(UI::EventParams &e);
|
||||
UI::EventReturn OnCameraDeviceChange(UI::EventParams& e);
|
||||
UI::EventReturn OnAudioDevice(UI::EventParams &e);
|
||||
UI::EventReturn OnJitAffectingSetting(UI::EventParams &e);
|
||||
@ -132,6 +134,7 @@ private:
|
||||
bool resolutionEnable_;
|
||||
bool bloomHackEnable_;
|
||||
bool tessHWEnable_;
|
||||
int prevInflightFrames_;
|
||||
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
std::string pendingMemstickFolder_;
|
||||
|
@ -403,6 +403,7 @@ bool WindowsGLContext::InitFromRenderThread(std::string *error_message) {
|
||||
CheckGLExtensions();
|
||||
draw_ = Draw::T3DCreateGLContext();
|
||||
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
||||
SetGPUBackend(GPUBackend::OPENGL);
|
||||
bool success = draw_->CreatePresets(); // if we get this far, there will always be a GLSL compiler capable of compiling these.
|
||||
_assert_msg_(G3D, success, "Failed to compile preset shaders");
|
||||
|
@ -159,6 +159,7 @@ bool WindowsVulkanContext::Init(HINSTANCE hInst, HWND hWnd, std::string *error_m
|
||||
draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight());
|
||||
|
||||
VulkanRenderManager *renderManager = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
renderManager->SetInflightFrames(g_Config.iInflightFrames);
|
||||
if (!renderManager->HasBackbuffers()) {
|
||||
Shutdown();
|
||||
return false;
|
||||
|
@ -51,6 +51,7 @@ bool AndroidEGLGraphicsContext::InitFromRenderThread(ANativeWindow *wnd, int des
|
||||
draw_ = Draw::T3DCreateGLContext();
|
||||
SetGPUBackend(GPUBackend::OPENGL);
|
||||
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
||||
bool success = draw_->CreatePresets(); // There will always be a GLSL compiler capable of compiling these.
|
||||
_assert_msg_(G3D, success, "Failed to compile preset shaders");
|
||||
return true;
|
||||
|
@ -19,6 +19,7 @@ bool AndroidJavaEGLGraphicsContext::InitFromRenderThread(ANativeWindow *wnd, int
|
||||
g_display_rot_matrix.setIdentity();
|
||||
draw_ = Draw::T3DCreateGLContext();
|
||||
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
||||
bool success = draw_->CreatePresets();
|
||||
_assert_msg_(G3D, success, "Failed to compile preset shaders");
|
||||
return success;
|
||||
|
@ -174,6 +174,7 @@ bool AndroidVulkanContext::InitFromRenderThread(ANativeWindow *wnd, int desiredB
|
||||
draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight());
|
||||
|
||||
VulkanRenderManager *renderManager = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
renderManager->SetInflightFrames(g_Config.iInflightFrames);
|
||||
success = renderManager->HasBackbuffers();
|
||||
} else {
|
||||
success = false;
|
||||
|
@ -95,6 +95,12 @@ void GLRenderManager::ThreadStart(Draw::DrawContext *draw) {
|
||||
threadFrame_ = threadInitFrame_;
|
||||
renderThreadId = std::this_thread::get_id();
|
||||
|
||||
if (newInflightFrames_ != -1) {
|
||||
ILOG("Updating inflight frames to %d", newInflightFrames_);
|
||||
inflightFrames_ = newInflightFrames_;
|
||||
newInflightFrames_ = -1;
|
||||
}
|
||||
|
||||
// Don't save draw, we don't want any thread safety confusion.
|
||||
bool mapBuffers = draw->GetBugs().Has(Draw::Bugs::ANY_MAP_BUFFER_RANGE_SLOW);
|
||||
bool hasBufferStorage = gl_extensions.ARB_buffer_storage || gl_extensions.EXT_buffer_storage;
|
||||
@ -449,10 +455,6 @@ void GLRenderManager::Finish() {
|
||||
frameData.pull_condVar.notify_all();
|
||||
|
||||
curFrame_++;
|
||||
if (newInflightFrames_ != -1) {
|
||||
inflightFrames_ = newInflightFrames_;
|
||||
newInflightFrames_ = -1;
|
||||
}
|
||||
if (curFrame_ >= inflightFrames_)
|
||||
curFrame_ = 0;
|
||||
|
||||
|
@ -202,6 +202,12 @@ void VulkanRenderManager::CreateBackbuffers() {
|
||||
VLOG("Backbuffers Created");
|
||||
}
|
||||
|
||||
if (newInflightFrames_ != -1) {
|
||||
ILOG("Updating inflight frames to %d", newInflightFrames_);
|
||||
vulkan_->UpdateInflightFrames(newInflightFrames_);
|
||||
newInflightFrames_ = -1;
|
||||
}
|
||||
|
||||
// Start the thread.
|
||||
if (useThread_ && HasBackbuffers()) {
|
||||
run_ = true;
|
||||
@ -914,10 +920,6 @@ void VulkanRenderManager::Finish() {
|
||||
frameData.pull_condVar.notify_all();
|
||||
}
|
||||
vulkan_->EndFrame();
|
||||
if (newInflightFrames_ != -1) {
|
||||
vulkan_->UpdateInflightFrames(newInflightFrames_);
|
||||
newInflightFrames_ = -1;
|
||||
}
|
||||
|
||||
insideFrame_ = false;
|
||||
}
|
||||
|
@ -150,6 +150,7 @@ bool GLDummyGraphicsContext::InitFromRenderThread(std::string *errorMessage) {
|
||||
CheckGLExtensions();
|
||||
draw_ = Draw::T3DCreateGLContext();
|
||||
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
||||
SetGPUBackend(GPUBackend::OPENGL);
|
||||
bool success = draw_->CreatePresets();
|
||||
assert(success);
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
CheckGLExtensions();
|
||||
draw_ = Draw::T3DCreateGLContext();
|
||||
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
||||
SetGPUBackend(GPUBackend::OPENGL);
|
||||
bool success = draw_->CreatePresets();
|
||||
_assert_msg_(G3D, success, "Failed to compile preset shaders");
|
||||
|
Loading…
Reference in New Issue
Block a user