Skip to content

Commit

Permalink
Split the resolution setting into Window Size and Rendering Resolutio…
Browse files Browse the repository at this point in the history
…n (internal resolution).

Gets rid of our "antialiasing" (simply crank up internal resolution to 2x your window size).

Proper MSAA is coming later.
  • Loading branch information
hrydgard committed Sep 10, 2013
1 parent 5e6c837 commit 2745744
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 310 deletions.
21 changes: 12 additions & 9 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename)
general->Get("GridView2", &bGridView2, true);
general->Get("GridView3", &bGridView3, true);


// "default" means let emulator decide, "" means disable.
general->Get("ReportingHost", &sReportHost, "default");
general->Get("Recent", recentIsos);
Expand All @@ -83,6 +82,8 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename)
general->Get("TopMost", &bTopMost);
general->Get("WindowX", &iWindowX, 40);
general->Get("WindowY", &iWindowY, 100);
general->Get("WindowWidth", &iWindowWidth, 0); // 0 will be automatically reset later (need to do the AdjustWindowRect dance).
general->Get("WindowHeight", &iWindowHeight, 0);
#endif

IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
Expand Down Expand Up @@ -124,11 +125,6 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename)

IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
graphics->Get("ShowFPSCounter", &iShowFPSCounter, false);
#ifdef _WIN32
graphics->Get("ResolutionScale", &iWindowZoom, 2);
#else
graphics->Get("ResolutionScale", &iWindowZoom, 1);
#endif
graphics->Get("RenderingMode", &iRenderingMode,
// Many ARMv6 devices have serious problems with buffered rendering.
#if defined(ARM) && !defined(ARMV7)
Expand All @@ -140,7 +136,13 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename)
graphics->Get("SoftwareRendering", &bSoftwareRendering, false);
graphics->Get("HardwareTransform", &bHardwareTransform, true);
graphics->Get("TextureFiltering", &iTexFiltering, 1);
graphics->Get("SSAA", &bAntiAliasing, 0);
// Auto on Windows, 1x elsewhere. Maybe change to 2x on large screens?
#ifdef _WIN32
graphics->Get("InternalResolution", &iInternalResolution, 0);
#else
graphics->Get("InternalResolution", &iInternalResolution, 1);
#endif

graphics->Get("FrameSkip", &iFrameSkip, 0);
graphics->Get("FrameRate", &iFpsLimit, 0);
graphics->Get("ForceMaxEmulatedFPS", &iForceMaxEmulatedFPS, 60);
Expand Down Expand Up @@ -268,6 +270,8 @@ void Config::Save() {
general->Set("TopMost", bTopMost);
general->Set("WindowX", iWindowX);
general->Set("WindowY", iWindowY);
general->Set("WindowWidth", iWindowWidth);
general->Set("WindowHeight", iWindowHeight);
#endif
general->Set("Language", languageIni);
general->Set("NumWorkerThreads", iNumWorkerThreads);
Expand Down Expand Up @@ -300,12 +304,11 @@ void Config::Save() {

IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
graphics->Set("ShowFPSCounter", iShowFPSCounter);
graphics->Set("ResolutionScale", iWindowZoom);
graphics->Set("RenderingMode", iRenderingMode);
graphics->Set("SoftwareRendering", bSoftwareRendering);
graphics->Set("HardwareTransform", bHardwareTransform);
graphics->Set("TextureFiltering", iTexFiltering);
graphics->Set("SSAA", bAntiAliasing);
graphics->Set("InternalResolution", iInternalResolution);
graphics->Set("FrameSkip", iFrameSkip);
graphics->Set("FrameRate", iFpsLimit);
graphics->Set("ForceMaxEmulatedFPS", iForceMaxEmulatedFPS);
Expand Down
6 changes: 4 additions & 2 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ struct Config {

int iWindowX;
int iWindowY;
int iWindowZoom; // for Windows
bool bAntiAliasing;
int iWindowWidth; // Windows and other windowed environments
int iWindowHeight;

bool bVertexCache;
bool bFullScreen;
#ifdef _WIN32
bool bFullScreenOnLaunch;
#endif
int iInternalResolution; // 0 = Auto (native), 1 = 1x (480x272), 2 = 2x, 3 = 3x, 4 = 4x and so on.
int iAnisotropyLevel; // 0 - 5, powers of 2: 0 = 1x = no aniso
bool bTrueColor;
bool bMipMap;
Expand Down
2 changes: 1 addition & 1 deletion Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void UpdateScreenScale() {
g_dpi = 72;
g_dpi_scale = 1.0f;
#ifdef _WIN32
if (g_Config.iWindowZoom == 1)
if (pixel_xres < 480 + 80)
{
dp_xres *= 2;
dp_yres *= 2;
Expand Down
2 changes: 1 addition & 1 deletion UI/CwCheatScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ std::vector<std::string> CwCheatScreen::CreateCodeList() {
if (cheatList[i].substr(0, 3) == "_C1") {
formattedList.push_back(cheatList[i].substr(4));
enableCheat[j++] = true;
locations.push_back(i);
locations.push_back((int)i);
}
if (cheatList[i].substr(0, 3) == "_C0") {
formattedList.push_back(cheatList[i].substr(4));
Expand Down
22 changes: 12 additions & 10 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,22 @@ void EmuScreen::bootGame(const std::string &filename) {
coreParam.enableDebugging = false;
coreParam.printfEmuLog = false;
coreParam.headLess = false;
#ifndef _WIN32
if (g_Config.iWindowZoom < 1 || g_Config.iWindowZoom > 2)
g_Config.iWindowZoom = 1;
#endif
coreParam.renderWidth = 480 * g_Config.iWindowZoom;
coreParam.renderHeight = 272 * g_Config.iWindowZoom;

if (g_Config.iInternalResolution == 0) {
coreParam.renderWidth = dp_xres;
coreParam.renderHeight = dp_yres;
} else {
if (g_Config.iInternalResolution < 0)
g_Config.iInternalResolution = 1;
coreParam.renderWidth = 480 * g_Config.iInternalResolution;
coreParam.renderHeight = 272 * g_Config.iInternalResolution;
}

coreParam.outputWidth = dp_xres;
coreParam.outputHeight = dp_yres;
coreParam.pixelWidth = pixel_xres;
coreParam.pixelHeight = pixel_yres;
if (g_Config.bAntiAliasing) {
coreParam.renderWidth *= 2;
coreParam.renderHeight *= 2;
}

std::string error_string;
if (PSP_Init(coreParam, &error_string)) {
invalid_ = false;
Expand Down
9 changes: 8 additions & 1 deletion UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ void GameSettingsScreen::CreateViews() {
graphicsSettings->Add(new ItemHeader(gs->T("Features")));
graphicsSettings->Add(new CheckBox(&g_Config.bHardwareTransform, gs->T("Hardware Transform")));
graphicsSettings->Add(new CheckBox(&g_Config.bVertexCache, gs->T("Vertex Cache")));
graphicsSettings->Add(new CheckBox(&g_Config.bAntiAliasing, gs->T("Anti-Aliasing")));

static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalResolution, gs->T("Rendering Resolution"), internalResolutions, 0, 6, gs, screenManager()))->OnClick.Handle(this, &GameSettingsScreen::OnResolutionChange);
graphicsSettings->Add(new CheckBox(&g_Config.bStretchToDisplay, gs->T("Stretch to Display")));
#ifdef BLACKBERRY
if (pixel_xres == pixel_yres)
Expand Down Expand Up @@ -281,6 +283,11 @@ UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) {
return UI::EVENT_DONE;
}

UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) {
gpu->Resized();

This comment has been minimized.

Copy link
@unknownbrackets

unknownbrackets Sep 11, 2013

Collaborator

Does this need a null check for setting it while a game is not running?

-[Unknown]

This comment has been minimized.

Copy link
@hrydgard

hrydgard Sep 11, 2013

Author Owner

Uh, yes. Thanks.

return UI::EVENT_DONE;
}

void DrawBackground(float alpha);

UI::EventReturn GameSettingsScreen::OnDumpNextFrameToLog(UI::EventParams &e) {
Expand Down
1 change: 1 addition & 0 deletions UI/GameSettingsScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class GameSettingsScreen : public UIDialogScreenWithBackground {
UI::EventReturn OnChangeNickname(UI::EventParams &e);
UI::EventReturn OnClearRecents(UI::EventParams &e);
UI::EventReturn OnRenderingMode(UI::EventParams &e);
UI::EventReturn OnResolutionChange(UI::EventParams &e);

// Temporaries to convert bools to int settings
bool cap60FPS_;
Expand Down
Loading

9 comments on commit 2745744

@wuspring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thedax why some menu in win32UI can not be translated?

@solarmystic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hrydgard

Thanks for finally implementing this function!

It does seem like a downgrade to those who're rocking full HD monitors (1920x1080) and wish to do 2xSSAA, since the maximum allowable PSP rendering resolution is just 5x or Auto.

We'd need to allow up to 8x PSP rendering resolution to get the previous image fidelity at 4x Window Size. (4 x 2 = 8)

@wuspring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thedax i see..i'll try to fix it, make it translatable.

@hrydgard
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wuspring, sorry I probably forgot something, should be easy to fix.

@hrydgard
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solarmystic, maybe a better solution for extreme resolutions would be "Auto x2"...

Anyway, should see how hard it would be to implement proper MSAA too, and maybe some other fancy AA methods, there are many these days...

@Line524
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done ! :)
But I suggest to implement FXAA and SMAA instead of MSAA.
First reason - FXAA and SMAA are just shader based postprocessing filters, so it didn't touch complexity of geometry rendering, so it doesn't break anything in emulation procedures.
Second reason - MSAA has (and always had) BIG performance drop. Speed loss depends on rendering resolution.
Third reason - MSAA always caused problems in graphics emulation in all modern emulators - Dolphin, PCSX2.....
Last reason - FXAA and SMAA also does subpixel anti-aliasing, so it is more accurate and a lot faster.

@solarmystic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Line524

All three should be considered though, more options are always better. FXAA is rather CPU heavy though and ends up blurring the picture. SMAA is indeed the best out of all the options but it's also rather heavy.We're trying to offload the burden to the graphics card and FXAA and SMAA are rather CPU dependant options. (FXAA especially)

MSAA is the most GPU dependant option.

@Line524
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CPU ??
I saw the code from those shader based filters and project description from Nvidia (FXAA) and AMD (SMAA) - it all loads and works on GPU mostly. And Speed loss using FXAA = ~2-5%, SMAA = ~ 3-15% and MSAA ~ 40-xx % So it shows that shader based filters are the best.
FXAA gives blur effect on lowest settings, you can always adjust sharp parameters how you like.
Right now I using FXAA with PPSSPP, applying it from Nvidia control panel. It works great and no performance drop in all games. Picture is clear, like using 4xMSAA or 2xSSAA (but which gives huge speed loss).
But sometimes it doesn't work with fullscreen mode in PPSSPP, that's why it would be cool to implement it correctly in emulator (SMAA and FXAA).

@hrydgard
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, FXAA does barely cause any CPU load and is definitely a possibility. Might give it a shot soon.

MSAA/CSAA is more accurate though and does not cause blurring, but maybe that's not that important.

Please sign in to comment.