mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Move post-processing settings to DisplayLayoutScreen
This commit is contained in:
@@ -107,14 +107,15 @@ bool FramebufferManagerCommon::UpdateRenderSize() {
|
||||
return newRender || newSettings;
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::BeginFrame() {
|
||||
DecimateFBOs();
|
||||
|
||||
// Might have a new post shader - let's compile it.
|
||||
void FramebufferManagerCommon::CheckPostShaders() {
|
||||
if (updatePostShaders_) {
|
||||
presentation_->UpdatePostShader();
|
||||
updatePostShaders_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::BeginFrame() {
|
||||
DecimateFBOs();
|
||||
|
||||
currentRenderVfb_ = nullptr;
|
||||
}
|
||||
@@ -2382,6 +2383,10 @@ void FramebufferManagerCommon::NotifyRenderResized() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::NotifyConfigChanged() {
|
||||
updatePostShaders_ = true;
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::DestroyAllFBOs() {
|
||||
currentRenderVfb_ = nullptr;
|
||||
displayFramebuf_ = nullptr;
|
||||
|
||||
@@ -398,8 +398,11 @@ public:
|
||||
}
|
||||
void SetSafeSize(u16 w, u16 h);
|
||||
|
||||
virtual void NotifyRenderResized();
|
||||
void NotifyRenderResized();
|
||||
virtual void NotifyDisplayResized();
|
||||
void NotifyConfigChanged();
|
||||
|
||||
void CheckPostShaders();
|
||||
|
||||
virtual void DestroyAllFBOs();
|
||||
|
||||
|
||||
+3
-1
@@ -633,11 +633,13 @@ void GPUCommon::CheckConfigChanged() {
|
||||
if (configChanged_) {
|
||||
gstate_c.useFlags = CheckGPUFeatures();
|
||||
drawEngineCommon_->NotifyConfigChanged();
|
||||
shaderManager_->DirtyLastShader(); // Don't think this is needed, at all.
|
||||
textureCache_->NotifyConfigChanged();
|
||||
framebufferManager_->NotifyConfigChanged();
|
||||
BuildReportingInfo();
|
||||
configChanged_ = false;
|
||||
}
|
||||
|
||||
framebufferManager_->CheckPostShaders();
|
||||
}
|
||||
|
||||
void GPUCommon::CheckDisplayResized() {
|
||||
|
||||
+1
-1
@@ -79,6 +79,7 @@ public:
|
||||
virtual u32 CheckGPUFeatures() const;
|
||||
|
||||
void CheckDisplayResized() override;
|
||||
void CheckConfigChanged() override;
|
||||
|
||||
void UpdateCmdInfo();
|
||||
|
||||
@@ -266,7 +267,6 @@ protected:
|
||||
void DeviceLost() override;
|
||||
void DeviceRestore() override;
|
||||
|
||||
void CheckConfigChanged();
|
||||
void CheckRenderResized();
|
||||
|
||||
// Add additional common features dependent on other features, which may be backend-determined.
|
||||
|
||||
@@ -199,6 +199,7 @@ public:
|
||||
virtual void EndHostFrame() = 0;
|
||||
|
||||
virtual void CheckDisplayResized() = 0;
|
||||
virtual void CheckConfigChanged() = 0;
|
||||
|
||||
// Draw queue management
|
||||
virtual DisplayList* getList(int listid) = 0;
|
||||
|
||||
+97
-20
@@ -25,6 +25,8 @@
|
||||
#include "Common/UI/View.h"
|
||||
#include "Common/Math/math_util.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/System/NativeApp.h"
|
||||
#include "Common/StringUtils.h"
|
||||
|
||||
#include "Common/Data/Color/RGBAUtil.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
@@ -34,6 +36,7 @@
|
||||
#include "Core/System.h"
|
||||
#include "GPU/Common/FramebufferManagerCommon.h"
|
||||
#include "GPU/Common/PresentationCommon.h"
|
||||
#include "GPU/Common/PostShader.h"
|
||||
|
||||
static const int leftColumnWidth = 200;
|
||||
static const float orgRatio = 1.764706f; // 480.0 / 272.0
|
||||
@@ -158,16 +161,36 @@ void DisplayLayoutScreen::dialogFinished(const Screen *dialog, DialogResult resu
|
||||
RecreateViews();
|
||||
}
|
||||
|
||||
// Stealing StickyChoice's layout and text rendering.
|
||||
class HighlightLabel : public UI::StickyChoice {
|
||||
public:
|
||||
HighlightLabel(const std::string &text, UI::LayoutParams *layoutParams)
|
||||
: UI::StickyChoice(text, "", layoutParams) {
|
||||
Press();
|
||||
}
|
||||
UI::EventReturn DisplayLayoutScreen::OnPostProcShaderChange(UI::EventParams &e) {
|
||||
g_Config.vPostShaderNames.erase(std::remove(g_Config.vPostShaderNames.begin(), g_Config.vPostShaderNames.end(), "Off"), g_Config.vPostShaderNames.end());
|
||||
|
||||
bool CanBeFocused() const override { return false; }
|
||||
};
|
||||
NativeMessageReceived("gpu_configChanged", "");
|
||||
NativeMessageReceived("gpu_renderResized", ""); // To deal with shaders that can change render resolution like upscaling.
|
||||
NativeMessageReceived("postshader_updated", "");
|
||||
|
||||
if (gpu) {
|
||||
gpu->NotifyConfigChanged();
|
||||
}
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
static std::string PostShaderTranslateName(const char *value) {
|
||||
auto ps = GetI18NCategory("PostShaders");
|
||||
const ShaderInfo *info = GetPostShaderInfo(value);
|
||||
if (info) {
|
||||
return ps->T(value, info ? info->name.c_str() : value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayLayoutScreen::sendMessage(const char *message, const char *value) {
|
||||
UIDialogScreenWithGameBackground::sendMessage(message, value);
|
||||
if (!strcmp(message, "postshader_updated")) {
|
||||
g_Config.bShaderChainRequires60FPS = PostShaderChainRequires60FPS(GetFullPostShadersChain(g_Config.vPostShaderNames));
|
||||
RecreateViews();
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayLayoutScreen::CreateViews() {
|
||||
const Bounds &bounds = screenManager()->getUIContext()->GetBounds();
|
||||
@@ -177,9 +200,13 @@ void DisplayLayoutScreen::CreateViews() {
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
auto gr = GetI18NCategory("Graphics");
|
||||
auto co = GetI18NCategory("Controls");
|
||||
auto ps = GetI18NCategory("PostShaders");
|
||||
|
||||
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
|
||||
ViewGroup *rightColumn = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(300.0f, FILL_PARENT, NONE, 10.f, 10.0f, 10.0f, false));
|
||||
root_->Add(rightColumn);
|
||||
|
||||
// We manually implement insets here for the buttons. This file defied refactoring :(
|
||||
float leftInset = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT);
|
||||
|
||||
@@ -189,11 +216,9 @@ void DisplayLayoutScreen::CreateViews() {
|
||||
bRotated_ = true;
|
||||
}
|
||||
|
||||
HighlightLabel *label = nullptr;
|
||||
mode_ = nullptr;
|
||||
if (g_Config.iSmallDisplayZoomType >= (int)SmallDisplayZoom::AUTO) { // Scaling
|
||||
if (g_Config.iSmallDisplayZoomType == (int)SmallDisplayZoom::AUTO) {
|
||||
label = new HighlightLabel(gr->T("Auto Scaling"), new AnchorLayoutParams(WRAP_CONTENT, 64.0f, bounds.w / 2.0f, bounds.h / 2.0f, NONE, NONE, true));
|
||||
float autoBound = bounds.h / 270.0f;
|
||||
// Case of screen rotated ~ only works with buffered rendering
|
||||
if (bRotated_) {
|
||||
@@ -229,7 +254,6 @@ void DisplayLayoutScreen::CreateViews() {
|
||||
mode_->SetSelection(0, false);
|
||||
}
|
||||
} else { // Stretching
|
||||
label = new HighlightLabel(gr->T("Stretching"), new AnchorLayoutParams(WRAP_CONTENT, 64.0f, bounds.w / 2.0f, bounds.h / 2.0f, NONE, NONE, true));
|
||||
float width = bounds.w;
|
||||
float height = bounds.h;
|
||||
if (g_Config.iSmallDisplayZoomType != (int)SmallDisplayZoom::STRETCH) {
|
||||
@@ -252,23 +276,76 @@ void DisplayLayoutScreen::CreateViews() {
|
||||
if (mode_) {
|
||||
root_->Add(mode_);
|
||||
}
|
||||
if (label) {
|
||||
root_->Add(label);
|
||||
}
|
||||
|
||||
static const char *zoomLevels[] = { "Stretching", "Partial Stretch", "Auto Scaling", "Manual Scaling" };
|
||||
auto zoom = new PopupMultiChoice(&g_Config.iSmallDisplayZoomType, di->T("Options"), zoomLevels, 0, ARRAY_SIZE(zoomLevels), gr->GetName(), screenManager(), new AnchorLayoutParams(400, WRAP_CONTENT, bounds.w / 2.0f - 200.0f, NONE, NONE, 10));
|
||||
zoom->OnChoice.Handle(this, &DisplayLayoutScreen::OnZoomTypeChange);
|
||||
root_->Add(zoom);
|
||||
rightColumn->Add(zoom);
|
||||
|
||||
static const char *displayRotation[] = { "Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed" };
|
||||
auto rotation = new PopupMultiChoice(&g_Config.iInternalScreenRotation, gr->T("Rotation"), displayRotation, 1, ARRAY_SIZE(displayRotation), co->GetName(), screenManager(), new AnchorLayoutParams(400, WRAP_CONTENT, bounds.w / 2.0f - 200.0f, 10, NONE, bounds.h - 64 - 10));
|
||||
auto rotation = new PopupMultiChoice(&g_Config.iInternalScreenRotation, gr->T("Rotation"), displayRotation, 1, ARRAY_SIZE(displayRotation), co->GetName(), screenManager());
|
||||
rotation->SetEnabledFunc([] {
|
||||
return !g_Config.bSkipBufferEffects || g_Config.bSoftwareRendering;
|
||||
});
|
||||
root_->Add(rotation);
|
||||
rightColumn->Add(rotation);
|
||||
|
||||
Choice *back = new Choice(di->T("Back"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10 + leftInset, NONE, NONE, 10));
|
||||
rightColumn->Add(new ItemHeader(gr->T("Postprocessing effect")));
|
||||
|
||||
Draw::DrawContext *draw = screenManager()->getDrawContext();
|
||||
|
||||
bool multiViewSupported = draw->GetDeviceCaps().multiViewSupported;
|
||||
|
||||
auto enableStereo = [=]() -> bool {
|
||||
return g_Config.bStereoRendering && multiViewSupported;
|
||||
};
|
||||
|
||||
std::set<std::string> alreadyAddedShader;
|
||||
for (int i = 0; i < (int)g_Config.vPostShaderNames.size() + 1 && i < ARRAY_SIZE(shaderNames_); ++i) {
|
||||
// Vector element pointer get invalidated on resize, cache name to have always a valid reference in the rendering thread
|
||||
shaderNames_[i] = i == g_Config.vPostShaderNames.size() ? "Off" : g_Config.vPostShaderNames[i];
|
||||
postProcChoice_ = rightColumn->Add(new ChoiceWithValueDisplay(&shaderNames_[i], StringFromFormat("%s #%d", gr->T("Postprocessing Shader"), i + 1), &PostShaderTranslateName));
|
||||
postProcChoice_->OnClick.Add([=](EventParams &e) {
|
||||
auto gr = GetI18NCategory("Graphics");
|
||||
auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"), i, false);
|
||||
procScreen->OnChoice.Handle(this, &DisplayLayoutScreen::OnPostProcShaderChange);
|
||||
if (e.v)
|
||||
procScreen->SetPopupOrigin(e.v);
|
||||
screenManager()->push(procScreen);
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
postProcChoice_->SetEnabledFunc([=] {
|
||||
return !g_Config.bSkipBufferEffects && !enableStereo();
|
||||
});
|
||||
|
||||
// No need for settings on the last one.
|
||||
if (i == g_Config.vPostShaderNames.size())
|
||||
continue;
|
||||
|
||||
auto shaderChain = GetPostShaderChain(g_Config.vPostShaderNames[i]);
|
||||
for (auto shaderInfo : shaderChain) {
|
||||
// Disable duplicated shader slider
|
||||
bool duplicated = alreadyAddedShader.find(shaderInfo->section) != alreadyAddedShader.end();
|
||||
alreadyAddedShader.insert(shaderInfo->section);
|
||||
for (size_t i = 0; i < ARRAY_SIZE(shaderInfo->settings); ++i) {
|
||||
auto &setting = shaderInfo->settings[i];
|
||||
if (!setting.name.empty()) {
|
||||
auto &value = g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", shaderInfo->section.c_str(), i + 1)];
|
||||
if (duplicated) {
|
||||
auto sliderName = StringFromFormat("%s %s", ps->T(setting.name), ps->T("(duplicated setting, previous slider will be used)"));
|
||||
PopupSliderChoiceFloat *settingValue = rightColumn->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, sliderName, setting.step, screenManager()));
|
||||
settingValue->SetEnabled(false);
|
||||
} else {
|
||||
PopupSliderChoiceFloat *settingValue = rightColumn->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager()));
|
||||
settingValue->SetEnabledFunc([=] {
|
||||
return !g_Config.bSkipBufferEffects && !enableStereo();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Choice *back = new Choice(di->T("Back"), "", false);
|
||||
back->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
root_->Add(back);
|
||||
rightColumn->Add(back);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,15 @@ protected:
|
||||
virtual UI::EventReturn OnCenter(UI::EventParams &e);
|
||||
virtual UI::EventReturn OnZoomTypeChange(UI::EventParams &e);
|
||||
|
||||
UI::EventReturn OnPostProcShaderChange(UI::EventParams &e);
|
||||
|
||||
void sendMessage(const char *message, const char *value) override;
|
||||
|
||||
private:
|
||||
UI::ChoiceStrip *mode_ = nullptr;
|
||||
UI::Choice *postProcChoice_ = nullptr;
|
||||
std::string shaderNames_[256];
|
||||
|
||||
bool dragging_ = false;
|
||||
bool bRotated_ = false;
|
||||
|
||||
|
||||
+10
-69
@@ -145,16 +145,6 @@ static std::string TextureTranslateName(const char *value) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::string PostShaderTranslateName(const char *value) {
|
||||
auto ps = GetI18NCategory("PostShaders");
|
||||
const ShaderInfo *info = GetPostShaderInfo(value);
|
||||
if (info) {
|
||||
return ps->T(value, info ? info->name.c_str() : value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static std::string *GPUDeviceNameSetting() {
|
||||
if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
|
||||
return &g_Config.sVulkanDevice;
|
||||
@@ -192,6 +182,16 @@ bool PathToVisualUsbPath(Path path, std::string &outPath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::string PostShaderTranslateName(const char *value) {
|
||||
auto ps = GetI18NCategory("PostShaders");
|
||||
const ShaderInfo *info = GetPostShaderInfo(value);
|
||||
if (info) {
|
||||
return ps->T(value, info ? info->name.c_str() : value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
void GameSettingsScreen::CreateViews() {
|
||||
ReloadAllPostShaderInfo(screenManager()->getDrawContext());
|
||||
ReloadAllThemeInfo();
|
||||
@@ -403,52 +403,6 @@ void GameSettingsScreen::CreateViews() {
|
||||
}
|
||||
}
|
||||
|
||||
std::set<std::string> alreadyAddedShader;
|
||||
for (int i = 0; i < (int)g_Config.vPostShaderNames.size() + 1 && i < ARRAY_SIZE(shaderNames_); ++i) {
|
||||
// Vector element pointer get invalidated on resize, cache name to have always a valid reference in the rendering thread
|
||||
shaderNames_[i] = i == g_Config.vPostShaderNames.size() ? "Off" : g_Config.vPostShaderNames[i];
|
||||
postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&shaderNames_[i], StringFromFormat("%s #%d", gr->T("Postprocessing Shader"), i + 1), &PostShaderTranslateName));
|
||||
postProcChoice_->OnClick.Add([=](EventParams &e) {
|
||||
auto gr = GetI18NCategory("Graphics");
|
||||
auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"), i, false);
|
||||
procScreen->OnChoice.Handle(this, &GameSettingsScreen::OnPostProcShaderChange);
|
||||
if (e.v)
|
||||
procScreen->SetPopupOrigin(e.v);
|
||||
screenManager()->push(procScreen);
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
postProcChoice_->SetEnabledFunc([=] {
|
||||
return !g_Config.bSkipBufferEffects && !enableStereo();
|
||||
});
|
||||
|
||||
// No need for settings on the last one.
|
||||
if (i == g_Config.vPostShaderNames.size())
|
||||
continue;
|
||||
|
||||
auto shaderChain = GetPostShaderChain(g_Config.vPostShaderNames[i]);
|
||||
for (auto shaderInfo : shaderChain) {
|
||||
// Disable duplicated shader slider
|
||||
bool duplicated = alreadyAddedShader.find(shaderInfo->section) != alreadyAddedShader.end();
|
||||
alreadyAddedShader.insert(shaderInfo->section);
|
||||
for (size_t i = 0; i < ARRAY_SIZE(shaderInfo->settings); ++i) {
|
||||
auto &setting = shaderInfo->settings[i];
|
||||
if (!setting.name.empty()) {
|
||||
auto &value = g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", shaderInfo->section.c_str(), i + 1)];
|
||||
if (duplicated) {
|
||||
auto sliderName = StringFromFormat("%s %s", ps->T(setting.name), ps->T("(duplicated setting, previous slider will be used)"));
|
||||
PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, sliderName, setting.step, screenManager()));
|
||||
settingValue->SetEnabled(false);
|
||||
} else {
|
||||
PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager()));
|
||||
settingValue->SetEnabledFunc([=] {
|
||||
return !g_Config.bSkipBufferEffects && !enableStereo();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceType != DEVICE_TYPE_VR) {
|
||||
graphicsSettings->Add(new ItemHeader(gr->T("Screen layout")));
|
||||
#if !defined(MOBILE_DEVICE)
|
||||
@@ -1395,10 +1349,6 @@ void GameSettingsScreen::onFinish(DialogResult result) {
|
||||
|
||||
void GameSettingsScreen::sendMessage(const char *message, const char *value) {
|
||||
UIDialogScreenWithGameBackground::sendMessage(message, value);
|
||||
if (!strcmp(message, "postshader_updated")) {
|
||||
g_Config.bShaderChainRequires60FPS = PostShaderChainRequires60FPS(GetFullPostShadersChain(g_Config.vPostShaderNames));
|
||||
RecreateViews();
|
||||
}
|
||||
if (!strcmp(message, "gameSettings_search")) {
|
||||
std::string filter = value ? value : "";
|
||||
searchFilter_.resize(filter.size());
|
||||
@@ -1712,15 +1662,6 @@ UI::EventReturn GameSettingsScreen::OnLanguageChange(UI::EventParams &e) {
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnPostProcShaderChange(UI::EventParams &e) {
|
||||
g_Config.vPostShaderNames.erase(std::remove(g_Config.vPostShaderNames.begin(), g_Config.vPostShaderNames.end(), "Off"), g_Config.vPostShaderNames.end());
|
||||
|
||||
NativeMessageReceived("gpu_configChanged", "");
|
||||
NativeMessageReceived("gpu_renderResized", ""); // To deal with shaders that can change render resolution like upscaling.
|
||||
NativeMessageReceived("postshader_updated", "");
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnTextureShader(UI::EventParams &e) {
|
||||
auto gr = GetI18NCategory("Graphics");
|
||||
auto shaderScreen = new TextureShaderScreen(gr->T("Texture Shader"));
|
||||
|
||||
@@ -55,7 +55,6 @@ private:
|
||||
bool lastVertical_;
|
||||
UI::CheckBox *enableReportsCheckbox_;
|
||||
UI::Choice *layoutEditorChoice_;
|
||||
UI::Choice *postProcChoice_;
|
||||
UI::Choice *displayEditor_;
|
||||
UI::Choice *backgroundChoice_ = nullptr;
|
||||
UI::PopupMultiChoice *resolutionChoice_;
|
||||
@@ -142,7 +141,6 @@ private:
|
||||
bool enableReportsSet_ = false;
|
||||
bool analogSpeedMapped_ = false;
|
||||
|
||||
std::string shaderNames_[256];
|
||||
std::string searchFilter_;
|
||||
|
||||
//edit the game-specific settings and restore the global settings after exiting
|
||||
|
||||
@@ -362,6 +362,7 @@ void DrawGameBackground(UIContext &dc, const Path &gamePath, float x, float y, f
|
||||
|
||||
if (PSP_IsInited() && !g_Config.bSkipBufferEffects) {
|
||||
gpu->CheckDisplayResized();
|
||||
gpu->CheckConfigChanged();
|
||||
gpu->CopyDisplayToOutput(true);
|
||||
|
||||
DrawContext *draw = dc.GetDrawContext();
|
||||
|
||||
Reference in New Issue
Block a user