diff --git a/Common/System/Display.cpp b/Common/System/Display.cpp index 79038890b874..5cb0a4bee4f9 100644 --- a/Common/System/Display.cpp +++ b/Common/System/Display.cpp @@ -54,11 +54,38 @@ DisplayProperties::DisplayProperties() { rot_matrix.setIdentity(); } +bool DisplayProperties::Recalculate(int new_pixel_xres, int new_pixel_yres, float new_scale, float customScale) { + bool px_changed = false; + if (pixel_xres != new_pixel_xres) { + pixel_xres = new_pixel_xres; + px_changed = true; + } + if (pixel_yres != new_pixel_yres) { + pixel_yres = new_pixel_yres; + px_changed = true; + } + + dpi_scale_real = new_scale; + dpi_scale = new_scale / customScale; + pixel_in_dps = 1.0f / dpi_scale; + + int new_dp_xres = (int)(new_pixel_xres * dpi_scale); + int new_dp_yres = (int)(new_pixel_yres * dpi_scale); + + if (new_dp_xres != dp_xres || new_dp_yres != dp_yres || px_changed) { + dp_xres = new_dp_xres; + dp_yres = new_dp_yres; + return true; + } else { + return false; + } +} + void DisplayProperties::Print() { printf("dp_xres/yres: %d, %d\n", dp_xres, dp_yres); printf("pixel_xres/yres: %d, %d\n", pixel_xres, pixel_yres); - printf("dpi, dpi_scale: %f, %f\n", dpi, dpi_scale); + printf("dpi_scale: %f\n", dpi_scale); printf("pixel_in_dps: %f\n", pixel_in_dps); printf("dpi_real: %f\n", dpi_scale_real); diff --git a/Common/System/Display.h b/Common/System/Display.h index 98f350690f0e..3c1bb436a621 100644 --- a/Common/System/Display.h +++ b/Common/System/Display.h @@ -16,20 +16,20 @@ enum class DisplayRotation { }; struct DisplayProperties { - // Display resolution in virtual ("display") pixels - int dp_xres; - int dp_yres; // Display resolution in true pixels. int pixel_xres; int pixel_yres; - float dpi = 1.0f; float dpi_scale = 1.0f; - // pixel_xres/yres in dps + // Display resolution in virtual ("display") pixels + int dp_xres; + int dp_yres; + + // Size of a physical pixel in dps float pixel_in_dps = 1.0f; - // If DPI is overridden (like in small window mode), these are still the original DPI. + // If DPI is overridden (like in small window mode), this is still the original DPI scale factor. float dpi_scale_real = 1.0f; float display_hz = 60.0f; @@ -39,6 +39,9 @@ struct DisplayProperties { DisplayProperties(); void Print(); + + // Returns true if the dimensions changed. + bool Recalculate(int new_pixel_xres, int new_pixel_yres, float new_scale, float customScale); }; extern DisplayProperties g_display; diff --git a/Common/System/NativeApp.h b/Common/System/NativeApp.h index 9308cf1bf2c1..8eef162c5b80 100644 --- a/Common/System/NativeApp.h +++ b/Common/System/NativeApp.h @@ -90,5 +90,5 @@ void Native_NotifyWindowHidden(bool hidden); bool Native_IsWindowHidden(); // TODO: Feels like this belongs elsewhere. -bool Native_UpdateScreenScale(int width, int height); +bool Native_UpdateScreenScale(int width, int height, float customScale); diff --git a/Core/Core.cpp b/Core/Core.cpp index 371019fbab3a..a37c59090745 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -427,7 +427,7 @@ void Core_Break(BreakReason reason, u32 relatedAddress) { // Allow overwriting the command. break; default: - ERROR_LOG(Log::CPU, "Core_Break called with a step-command already in progress: %s", g_cpuStepCommand.reason); + ERROR_LOG(Log::CPU, "Core_Break called with a step-command already in progress: %s", BreakReasonToString(g_cpuStepCommand.reason)); return; } } diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index 13cdb79f29e8..d9fb3e3b34e6 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -87,7 +87,7 @@ static u32 sceMp4AacDecode(u32 mp4, u32 auAddr, u32 bufferAddr, u32 init, u32 fr // Decode audio: // - init: 1 at first call, 0 afterwards // - frequency: 44100 - return hleLogError(Log::ME, 0, "mp4 % i, auAddr % 08x, bufferAddr % 08x, init % i, frequency % i ", mp4, auAddr, bufferAddr, init, frequency); + return hleLogError(Log::ME, 0, "mp4 %i, auAddr %08x, bufferAddr %08x, init %i, frequency %i ", mp4, auAddr, bufferAddr, init, frequency); //This is hack //return -1; } diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 6d07e637cf9f..81d33c927ab4 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -549,7 +549,7 @@ QString MainUI::InputBoxGetQString(QString title, QString defaultValue) { } void MainUI::resizeGL(int w, int h) { - if (Native_UpdateScreenScale(w, h)) { + if (Native_UpdateScreenScale(w, h, 1.0f)) { System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED); } xscale = w / this->width(); @@ -839,14 +839,10 @@ int main(int argc, char *argv[]) if (res.width() < res.height()) res.transpose(); - g_display.pixel_xres = res.width(); - g_display.pixel_yres = res.height(); - g_display.dpi_scale = screen->logicalDotsPerInchX() / screen->physicalDotsPerInchX(); // We assume physicalDotsPerInchY is the same as PerInchX. - g_display.dpi_scale_real = g_display.dpi_scale; - g_display.dp_xres = (int)(g_display.pixel_xres * g_display.dpi_scale); - g_display.dp_yres = (int)(g_display.pixel_yres * g_display.dpi_scale); + float dpi_scale = screen->logicalDotsPerInchX() / screen->physicalDotsPerInchX(); + g_display.Recalculate(res.width(), res.height(), dpi_scale, 1.0f); refreshRate = screen->refreshRate(); diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 7a553df63e28..2f585b7d0ee1 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -615,6 +615,7 @@ bool System_GetPropertyBool(SystemProperty prop) { #if PPSSPP_PLATFORM(MAC) case SYSPROP_HAS_FOLDER_BROWSER: case SYSPROP_HAS_FILE_BROWSER: + return true; #endif case SYSPROP_HAS_ACCELEROMETER: #if defined(MOBILE_DEVICE) @@ -779,7 +780,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN); // This one calls NativeResized if the size changed. - Native_UpdateScreenScale(new_width_px, new_height_px); + Native_UpdateScreenScale(new_width_px, new_height_px, 1.0f); // Set variable here in case fullscreen was toggled by hotkey if (g_Config.UseFullScreen() != fullscreen) { @@ -1436,7 +1437,7 @@ int main(int argc, char *argv[]) { float dpi_scale = 1.0f / (g_ForcedDPI == 0.0f ? g_DesktopDPI : g_ForcedDPI); - Native_UpdateScreenScale(w * g_DesktopDPI, h * g_DesktopDPI); + Native_UpdateScreenScale(w * g_DesktopDPI, h * g_DesktopDPI, 1.0f); bool mainThreadIsRender = g_Config.iGPUBackend == (int)GPUBackend::OPENGL; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index c280b156efdd..07fa45863eb4 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -646,11 +646,11 @@ void SystemInfoScreen::CreateTabs() { System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES)))); #endif - displayInfo->Add(new InfoItem(si->T("UI resolution"), StringFromFormat("%dx%d (%s: %0.2f)", + displayInfo->Add(new InfoItem(si->T("UI resolution"), StringFromFormat("%dx%d (%s: %d)", g_display.dp_xres, g_display.dp_yres, si->T_cstr("DPI"), - g_display.dpi))); + System_GetPropertyInt(SYSPROP_DISPLAY_DPI)))); displayInfo->Add(new InfoItem(si->T("Pixel resolution"), StringFromFormat("%dx%d", g_display.pixel_xres, g_display.pixel_yres))); @@ -1311,22 +1311,25 @@ void TouchTestScreen::DrawForeground(UIContext &dc) { truncate_cpy(extra_debug, Android_GetInputDeviceDebugString().c_str()); #endif - snprintf(buffer, sizeof(buffer), + // Hm, why don't we print all the info on Android? #if PPSSPP_PLATFORM(ANDROID) + snprintf(buffer, sizeof(buffer), + "display_res: %dx%d\n", + (int)System_GetPropertyInt(SYSPROP_DISPLAY_XRES), (int)System_GetPropertyInt(SYSPROP_DISPLAY_YRES)); +#else + snprintf(buffer, sizeof(buffer), "display_res: %dx%d\n" -#endif "dp_res: %dx%d pixel_res: %dx%d\n" - "g_dpi: %0.3f g_dpi_scale: %0.3f\n" - "g_dpi_scale_real: %0.3f\n" + "dpi_scale: %0.3f\n" + "dpi_scale_real: %0.3f\n" "delta: %0.2f ms fps: %0.3f\n%s", -#if PPSSPP_PLATFORM(ANDROID) (int)System_GetPropertyInt(SYSPROP_DISPLAY_XRES), (int)System_GetPropertyInt(SYSPROP_DISPLAY_YRES), -#endif g_display.dp_xres, g_display.dp_yres, g_display.pixel_xres, g_display.pixel_yres, - g_display.dpi, g_display.dpi_scale, + g_display.dpi_scale, g_display.dpi_scale_real, delta * 1000.0, 1.0 / delta, extra_debug); +#endif // On Android, also add joystick debug data. dc.DrawTextShadow(buffer, bounds.centerX(), bounds.y + 20.0f, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 79862da50010..8dca52188117 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1512,47 +1512,31 @@ bool Native_IsWindowHidden() { static bool IsWindowSmall(int pixelWidth, int pixelHeight) { // Can't take this from config as it will not be set if windows is maximized. - int w = (int)(pixelWidth * g_display.dpi_scale); - int h = (int)(pixelHeight * g_display.dpi_scale); + int w = (int)(pixelWidth * g_display.dpi_scale_real); + int h = (int)(pixelHeight * g_display.dpi_scale_real); return g_Config.IsPortrait() ? (h < 480 + 80) : (w < 480 + 80); } -bool Native_UpdateScreenScale(int width, int height) { - bool smallWindow; - +bool Native_UpdateScreenScale(int pixel_width, int pixel_height, float customScale) { float g_logical_dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_LOGICAL_DPI); - g_display.dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI); + float dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI); - if (g_display.dpi < 0.0f) { - g_display.dpi = 96.0f; + if (dpi < 0.0f) { + dpi = 96.0f; } if (g_logical_dpi < 0.0f) { g_logical_dpi = 96.0f; } - g_display.dpi_scale = g_logical_dpi / g_display.dpi; - g_display.dpi_scale_real = g_display.dpi_scale; - - smallWindow = IsWindowSmall(width, height); + bool smallWindow = IsWindowSmall(pixel_width, pixel_height); if (smallWindow) { - g_display.dpi /= 2.0f; - g_display.dpi_scale *= 2.0f; + customScale *= 0.5f; } - g_display.pixel_in_dps = 1.0f / g_display.dpi_scale; - - int new_dp_xres = (int)(width * g_display.dpi_scale); - int new_dp_yres = (int)(height * g_display.dpi_scale); - - bool dp_changed = new_dp_xres != g_display.dp_xres || new_dp_yres != g_display.dp_yres; - bool px_changed = g_display.pixel_xres != width || g_display.pixel_yres != height; - if (dp_changed || px_changed) { - g_display.dp_xres = new_dp_xres; - g_display.dp_yres = new_dp_yres; - g_display.pixel_xres = width; - g_display.pixel_yres = height; + if (g_display.Recalculate(pixel_width, pixel_height, g_logical_dpi / dpi, customScale)) { NativeResized(); return true; + } else { + return false; } - return false; } diff --git a/UWP/App.cpp b/UWP/App.cpp index 49eb8cd9762b..67bafebe0a4d 100644 --- a/UWP/App.cpp +++ b/UWP/App.cpp @@ -330,7 +330,7 @@ void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ ar PSP_CoreParameter().pixelWidth = (int)(width * scale); PSP_CoreParameter().pixelHeight = (int)(height * scale); - if (Native_UpdateScreenScale((int)width, (int)height)) { + if (Native_UpdateScreenScale((int)width, (int)height, 1.0f)) { System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED); } } diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 77c5fb51faed..93712f5fad7d 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -143,16 +143,21 @@ void PPSSPP_UWPMain::UpdateScreenState() { if (g_display.rotation == DisplayRotation::ROTATE_90 || g_display.rotation == DisplayRotation::ROTATE_270) { // We need to swap our width/height. + // TODO: This is most likely dead code, since we no longer support Windows Phone. std::swap(g_display.pixel_xres, g_display.pixel_yres); } - g_display.dpi = m_deviceResources->GetActualDpi(); + // TODO: The below stuff is probably completely redundant since the UWP app elsewhere calls Native_UpdateScreenScale. + float dpi = m_deviceResources->GetActualDpi(); if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_MOBILE) { // Boost DPI a bit to look better. - g_display.dpi *= 96.0f / 136.0f; + dpi *= 96.0f / 136.0f; } - g_display.dpi_scale = 96.0f / g_display.dpi; + + g_display.dpi_scale_real = 96.0f / dpi; + + g_display.dpi_scale = g_display.dpi_scale_real; g_display.pixel_in_dps = 1.0f / g_display.dpi_scale; g_display.dp_xres = g_display.pixel_xres * g_display.dpi_scale; diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 403a43d51c05..f0dc681c5c0f 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -298,7 +298,7 @@ namespace MainWindow DEBUG_LOG(Log::System, "Pixel width/height: %dx%d", PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); - if (Native_UpdateScreenScale(width, height)) { + if (Native_UpdateScreenScale(width, height, 1.0f)) { System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED); System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED); } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 2bfb19d75a5d..5a00a86c9af3 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -152,8 +152,8 @@ static int deviceType; // Exposed so it can be displayed on the touchscreen test. static int display_xres; static int display_yres; -static int display_dpi_x; -static int display_dpi_y; +static int display_dpi; + static int backbuffer_format; // Android PixelFormat enum static int desiredBackbufferSizeX; @@ -412,6 +412,8 @@ int64_t System_GetPropertyInt(SystemProperty prop) { return display_xres; case SYSPROP_DISPLAY_YRES: return display_yres; + case SYSPROP_DISPLAY_DPI: + return display_dpi; case SYSPROP_AUDIO_SAMPLE_RATE: return sampleRate; case SYSPROP_AUDIO_FRAMES_PER_BUFFER: @@ -998,37 +1000,28 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e return true; } -static void recalculateDpi() { - g_display.dpi = (float)display_dpi_x; - g_display.dpi_scale_real = 240.0f / (float)display_dpi_x; - g_display.dpi_scale = g_display.dpi_scale_real; - - g_display.dp_xres = display_xres * g_display.dpi_scale; - g_display.dp_yres = display_yres * g_display.dpi_scale; - - g_display.pixel_in_dps = (float)g_display.pixel_xres / g_display.dp_xres; +static bool recalculateDpi(int pixel_xres, int pixel_yres) { + bool retval = g_display.Recalculate(pixel_xres, pixel_yres, 240.0f / (float)display_dpi, 1.0f); INFO_LOG(Log::G3D, "RecalcDPI: display_xres=%d display_yres=%d pixel_xres=%d pixel_yres=%d", display_xres, display_yres, g_display.pixel_xres, g_display.pixel_yres); - INFO_LOG(Log::G3D, "RecalcDPI: g_dpi=%f g_dpi_scale=%f dp_xres=%d dp_yres=%d", g_display.dpi, g_display.dpi_scale, g_display.dp_xres, g_display.dp_yres); + INFO_LOG(Log::G3D, "RecalcDPI: g_dpi=%d g_dpi_scale=%f dp_xres=%d dp_yres=%d", display_dpi, g_display.dpi_scale, g_display.dp_xres, g_display.dp_yres); + + return retval; } -extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv *, jclass, jint bufw, jint bufh, jint format) { - INFO_LOG(Log::System, "NativeApp.backbufferResize(%d x %d)", bufw, bufh); +extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv *, jclass, jint pixel_xres, jint pixel_yres, jint format) { + INFO_LOG(Log::System, "NativeApp.backbufferResize(%d x %d)", pixel_xres, pixel_yres); - bool new_size = g_display.pixel_xres != bufw || g_display.pixel_yres != bufh; int old_w = g_display.pixel_xres; int old_h = g_display.pixel_yres; // pixel_*res is the backbuffer resolution. - g_display.pixel_xres = bufw; - g_display.pixel_yres = bufh; backbuffer_format = format; if (IsVREnabled()) { - GetVRResolutionPerEye(&g_display.pixel_xres, &g_display.pixel_yres); + GetVRResolutionPerEye(&pixel_xres, &pixel_yres); } - recalculateDpi(); - + bool new_size = recalculateDpi(pixel_xres, pixel_yres); if (new_size) { INFO_LOG(Log::G3D, "Size change detected (previously %d,%d) - calling NativeResized()", old_w, old_h); NativeResized(); @@ -1415,17 +1408,16 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setDisplayParameters(JN bool changed = false; changed = changed || display_xres != xres || display_yres != yres; - changed = changed || display_dpi_x != dpi || display_dpi_y != dpi; + changed = changed || display_dpi != dpi; changed = changed || g_display.display_hz != refreshRate; if (changed) { display_xres = xres; display_yres = yres; - display_dpi_x = dpi; - display_dpi_y = dpi; + display_dpi = dpi; g_display.display_hz = refreshRate; - - recalculateDpi(); + // TODO: This is conflicting with the call in backbufferResize. + recalculateDpi(display_xres, display_yres); NativeResized(); } } diff --git a/assets/compat.ini b/assets/compat.ini index 1f4fe2db98ea..4c83c6bdc3b6 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1359,6 +1359,7 @@ ULES00808 = true ULUS10270 = true [DeswizzleDepth] +# Ratchet & Clank smoke effects (#15859) UCUS98633 = true UCAS40145 = true UCES00420 = true diff --git a/ios/DisplayManager.mm b/ios/DisplayManager.mm index 62f53452f584..2319d5c944f4 100644 --- a/ios/DisplayManager.mm +++ b/ios/DisplayManager.mm @@ -142,26 +142,19 @@ - (void)updateResolution:(UIScreen *)screen { std::swap(size.height, size.width); } + float dpi; if (screen == [UIScreen mainScreen]) { - g_display.dpi = (IS_IPAD() ? 200.0f : 150.0f) * scale; + dpi = (IS_IPAD() ? 200.0f : 150.0f) * scale; } else { float diagonal = sqrt(size.height * size.height + size.width * size.width); - g_display.dpi = diagonal * scale * 0.1f; + dpi = diagonal * scale * 0.1f; } - g_display.dpi_scale_real = 240.0f / g_display.dpi; - g_display.dpi_scale = g_display.dpi_scale_real; + float dpi_scale = 240.0f / dpi; + g_display.Recalculate(size.width * scale, size.height * scale, dpi_scale, 1.0f); - g_display.pixel_xres = size.width * scale; - g_display.pixel_yres = size.height * scale; - - g_display.dp_xres = g_display.pixel_xres * g_display.dpi_scale; - g_display.dp_yres = g_display.pixel_yres * g_display.dpi_scale; - - g_display.pixel_in_dps = (float)g_display.pixel_xres / (float)g_display.dp_xres; - [[sharedViewController getView] setContentScaleFactor:scale]; - + // PSP native resize PSP_CoreParameter().pixelWidth = g_display.pixel_xres; PSP_CoreParameter().pixelHeight = g_display.pixel_yres;