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

UI: Disable render dup frames where it can't work #12743

Merged
merged 2 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions UI/DisplayLayoutScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,12 @@ void DisplayLayoutScreen::CreateViews() {

static const char *displayRotation[] = { "Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed" };
rotation_ = new PopupMultiChoice(&g_Config.iInternalScreenRotation, gr->T("Rotation"), displayRotation, 1, ARRAY_SIZE(displayRotation), co->GetName(), screenManager(), new AnchorLayoutParams(400, WRAP_CONTENT, previewWidth - 200.0f, 10, NONE, local_dp_yres - 64 - 10));
rotation_->SetEnabledPtr(&displayRotEnable_);
displayRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
rotation_->SetEnabledFunc([] {
return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});
bool displayRotEnable = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
bRotated = false;
if (displayRotEnable_ && (g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180)) {
if (displayRotEnable && (g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180)) {
bRotated = true;
}
displayRepresentationScale_ = g_Config.fSmallDisplayZoomLevel * 8.0f; // Visual representation image is just icon size and have to be scaled 8 times to match PSP native resolution which is used as 1.0 for zoom
Expand Down
1 change: 0 additions & 1 deletion UI/DisplayLayoutScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class DisplayLayoutScreen : public UIDialogScreenWithBackground {
UI::ChoiceStrip *mode_;
UI::PopupMultiChoice *zoom_;
UI::PopupMultiChoice *rotation_;
bool displayRotEnable_;
bool bRotated;
bool stickToEdgeX;
bool stickToEdgeY;
Expand Down
58 changes: 32 additions & 26 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void GameSettingsScreen::CreateViews() {
}
}

static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering"};
static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering" };
PopupMultiChoice *renderingModeChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gr->T("Mode"), renderingMode, 0, ARRAY_SIZE(renderingMode), gr->GetName(), screenManager()));
renderingModeChoice->OnChoice.Add([=](EventParams &e) {
switch (g_Config.iRenderingMode) {
Expand Down Expand Up @@ -289,8 +289,9 @@ void GameSettingsScreen::CreateViews() {
auto ps = GetI18NCategory("PostShaders");
postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sPostShaderName, gr->T("Postprocessing Shader"), &PostShaderTranslateName));
postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader);
postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
postProcChoice_->SetEnabledPtr(&postProcEnable_);
postProcChoice_->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});
}

#if !defined(MOBILE_DEVICE)
Expand All @@ -315,14 +316,15 @@ void GameSettingsScreen::CreateViews() {

graphicsSettings->Add(new ItemHeader(gr->T("Performance")));
#ifndef MOBILE_DEVICE
static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP", "6x PSP", "7x PSP", "8x PSP", "9x PSP", "10x PSP" };
static const char *internalResolutions[] = { "Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP", "6x PSP", "7x PSP", "8x PSP", "9x PSP", "10x PSP" };
#else
static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
static const char *internalResolutions[] = { "Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
#endif
resolutionChoice_ = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalResolution, gr->T("Rendering Resolution"), internalResolutions, 0, ARRAY_SIZE(internalResolutions), gr->GetName(), screenManager()));
resolutionChoice_->OnChoice.Handle(this, &GameSettingsScreen::OnResolutionChange);
resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
resolutionChoice_->SetEnabledPtr(&resolutionEnable_);
resolutionChoice_->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});

#ifdef __ANDROID__
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) != DEVICE_TYPE_TV) {
Expand All @@ -344,6 +346,9 @@ void GameSettingsScreen::CreateViews() {
});
#endif
CheckBox *frameDuplication = graphicsSettings->Add(new CheckBox(&g_Config.bRenderDuplicateFrames, gr->T("Render duplicate frames to 60hz")));
frameDuplication->SetEnabledFunc([] {
return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE || (g_Config.bSoftwareRendering && g_Config.iFrameSkip != 0);
});
frameDuplication->OnClick.Add([=](EventParams &e) {
settingInfo_->Show(gr->T("RenderDuplicateFrames Tip", "Can make framerate smoother in games that run at lower framerates"), e.v);
return UI::EVENT_CONTINUE;
Expand Down Expand Up @@ -371,8 +376,9 @@ void GameSettingsScreen::CreateViews() {
settingInfo_->Show(gr->T("VertexCache Tip", "Faster, but may cause temporary flicker"), e.v);
return UI::EVENT_CONTINUE;
});
vtxCacheEnable_ = !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
vtxCache->SetEnabledPtr(&vtxCacheEnable_);
vtxCache->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
});

CheckBox *texBackoff = graphicsSettings->Add(new CheckBox(&g_Config.bTextureBackoffCache, gr->T("Lazy texture caching", "Lazy texture caching (speedup)")));
texBackoff->SetDisabledPtr(&g_Config.bSoftwareRendering);
Expand All @@ -394,7 +400,7 @@ void GameSettingsScreen::CreateViews() {
vtxJit->SetEnabled(false);
}*/

static const char *quality[] = { "Low", "Medium", "High"};
static const char *quality[] = { "Low", "Medium", "High" };
PopupMultiChoice *beziersChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iSplineBezierQuality, gr->T("LowCurves", "Spline/Bezier curves quality"), quality, 0, ARRAY_SIZE(quality), gr->GetName(), screenManager()));
beziersChoice->OnChoice.Add([=](EventParams &e) {
if (g_Config.iSplineBezierQuality != 0) {
Expand Down Expand Up @@ -481,8 +487,9 @@ void GameSettingsScreen::CreateViews() {

static const char *bloomHackOptions[] = { "Off", "Safe", "Balanced", "Aggressive" };
PopupMultiChoice *bloomHack = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iBloomHack, gr->T("Lower resolution for effects (reduces artifacts)"), bloomHackOptions, 0, ARRAY_SIZE(bloomHackOptions), gr->GetName(), screenManager()));
bloomHackEnable_ = !g_Config.bSoftwareRendering && (g_Config.iInternalResolution != 1);
bloomHack->SetEnabledPtr(&bloomHackEnable_);
bloomHack->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && g_Config.iInternalResolution != 1;
});

graphicsSettings->Add(new ItemHeader(gr->T("Overlay Information")));
static const char *fpsChoices[] = { "None", "Speed", "FPS", "Both" };
Expand Down Expand Up @@ -563,12 +570,14 @@ void GameSettingsScreen::CreateViews() {

#if defined(MOBILE_DEVICE)
controlsSettings->Add(new CheckBox(&g_Config.bHapticFeedback, co->T("HapticFeedback", "Haptic Feedback (vibration)")));
static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons", "L/R Trigger Buttons"};
static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons", "L/R Trigger Buttons" };
controlsSettings->Add(new PopupMultiChoice(&g_Config.iTiltInputType, co->T("Tilt Input Type"), tiltTypes, 0, ARRAY_SIZE(tiltTypes), co->GetName(), screenManager()))->OnClick.Handle(this, &GameSettingsScreen::OnTiltTypeChange);

Choice *customizeTilt = controlsSettings->Add(new Choice(co->T("Customize tilt")));
customizeTilt->OnClick.Handle(this, &GameSettingsScreen::OnTiltCustomize);
customizeTilt->SetEnabledPtr((bool *)&g_Config.iTiltInputType); //<- dirty int-to-bool cast
customizeTilt->SetEnabledFunc([] {
return g_Config.iTiltInputType != 0;
});
#endif

// TVs don't have touch control, at least not yet.
Expand Down Expand Up @@ -768,6 +777,10 @@ void GameSettingsScreen::CreateViews() {
View *ioTimingMethod = systemSettings->Add(new PopupMultiChoice(&g_Config.iIOTimingMethod, sy->T("IO timing method"), ioTimingMethods, 0, ARRAY_SIZE(ioTimingMethods), sy->GetName(), screenManager()));
systemSettings->Add(new CheckBox(&g_Config.bForceLagSync, sy->T("Force real clock sync (slower, less lag)")));
PopupSliderChoice *lockedMhz = systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, sy->T("Change CPU Clock", "Change CPU Clock (unstable)"), screenManager(), sy->T("MHz, 0:default")));
lockedMhz->OnChange.Add([&](UI::EventParams &) {
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
return UI::EVENT_CONTINUE;
});
lockedMhz->SetZeroLabel(sy->T("Auto"));
PopupSliderChoice *rewindFreq = systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindFlipFrequency, 0, 1800, sy->T("Rewind Snapshot Frequency", "Rewind Snapshot Frequency (mem hog)"), screenManager(), sy->T("frames, 0:off")));
rewindFreq->SetZeroLabel(sy->T("Off"));
Expand Down Expand Up @@ -864,10 +877,12 @@ void GameSettingsScreen::CreateViews() {
systemSettings->Add(new CheckBox(&g_Config.bCacheFullIsoInRam, sy->T("Cache ISO in RAM", "Cache full ISO in RAM")));
#endif

//#ifndef __ANDROID__
systemSettings->Add(new ItemHeader(sy->T("Cheats", "Cheats (experimental, see forums)")));
systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, sy->T("Enable Cheats")));
//#endif
CheckBox *enableCheats = systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, sy->T("Enable Cheats")));
enableCheats->OnClick.Add([&](UI::EventParams &) {
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
return UI::EVENT_CONTINUE;
});
systemSettings->SetSpacing(0);

systemSettings->Add(new ItemHeader(sy->T("PSP Settings")));
Expand Down Expand Up @@ -910,16 +925,11 @@ UI::EventReturn GameSettingsScreen::OnAutoFrameskip(UI::EventParams &e) {
}

UI::EventReturn GameSettingsScreen::OnSoftwareRendering(UI::EventParams &e) {
vtxCacheEnable_ = !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
bloomHackEnable_ = !g_Config.bSoftwareRendering && (g_Config.iInternalResolution != 1);
tessHWEnable_ = DoesBackendSupportHWTess() && !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
return UI::EVENT_DONE;
}

UI::EventReturn GameSettingsScreen::OnHardwareTransform(UI::EventParams &e) {
vtxCacheEnable_ = !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
tessHWEnable_ = DoesBackendSupportHWTess() && !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
return UI::EVENT_DONE;
}
Expand Down Expand Up @@ -969,9 +979,6 @@ UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) {
enableReports_ = Reporting::IsEnabled();
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());

postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);

if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
g_Config.bAutoFrameSkip = false;
}
Expand Down Expand Up @@ -1114,7 +1121,6 @@ UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) {
if (g_Config.iAndroidHwScale == 1) {
RecreateActivity();
}
bloomHackEnable_ = !g_Config.bSoftwareRendering && g_Config.iInternalResolution != 1;
Reporting::UpdateConfig();
return UI::EVENT_DONE;
}
Expand Down
12 changes: 3 additions & 9 deletions UI/GameSettingsScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,16 @@ class GameSettingsScreen : public UIDialogScreenWithGameBackground {
UI::EventReturn OnSavedataManager(UI::EventParams &e);
UI::EventReturn OnSysInfo(UI::EventParams &e);

// Temporaries to convert setting types.
// Temporaries to convert setting types, cache enabled, etc.
int iAlternateSpeedPercent1_;
int iAlternateSpeedPercent2_;
int prevInflightFrames_;
bool enableReports_;
bool tessHWEnable_;

//edit the game-specific settings and restore the global settings after exiting
bool editThenRestore_;

// Cached booleans
bool vtxCacheEnable_;
bool postProcEnable_;
bool resolutionEnable_;
bool bloomHackEnable_;
bool tessHWEnable_;
int prevInflightFrames_;

#if PPSSPP_PLATFORM(ANDROID)
std::string pendingMemstickFolder_;
#endif
Expand Down
30 changes: 25 additions & 5 deletions ext/native/ui/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,34 @@ class View {
return GetFocusedView() == this;
}

void SetEnabled(bool enabled) { enabled_ = enabled; enabledMeansDisabled_ = false; }
void SetEnabled(bool enabled) {
enabledFunc_ = nullptr;
enabledPtr_ = nullptr;
enabled_ = enabled;
enabledMeansDisabled_ = false;
}
bool IsEnabled() const {
if (enabledFunc_)
return enabledFunc_() != enabledMeansDisabled_;
if (enabledPtr_)
return *enabledPtr_ != enabledMeansDisabled_;
else
return enabled_ != enabledMeansDisabled_;
return enabled_ != enabledMeansDisabled_;
}
void SetEnabledFunc(std::function<bool()> func) {
enabledFunc_ = func;
enabledPtr_ = nullptr;
enabledMeansDisabled_ = false;
}
void SetEnabledPtr(bool *enabled) {
enabledFunc_ = nullptr;
enabledPtr_ = enabled;
enabledMeansDisabled_ = false;
}
void SetDisabledPtr(bool *disabled) {
enabledFunc_ = nullptr;
enabledPtr_ = disabled;
enabledMeansDisabled_ = true;
}
void SetEnabledPtr(bool *enabled) { enabledPtr_ = enabled; enabledMeansDisabled_ = false; }
void SetDisabledPtr(bool *disabled) { enabledPtr_ = disabled; enabledMeansDisabled_ = true; }

virtual void SetVisibility(Visibility visibility) { visibility_ = visibility; }
Visibility GetVisibility() const { return visibility_; }
Expand Down Expand Up @@ -445,6 +464,7 @@ class View {
std::vector<Tween *> tweens_;

private:
std::function<bool()> enabledFunc_;
bool *enabledPtr_;
bool enabled_;
bool enabledMeansDisabled_;
Expand Down