From 24004af8145a7babe0d0fcfb1b18231dda665aff Mon Sep 17 00:00:00 2001 From: Filoppi Date: Sat, 9 Sep 2023 15:48:37 +0300 Subject: [PATCH] Video: polish aspect ratio related code comments to make it clearer --- Source/Core/Core/HW/VideoInterface.cpp | 2 +- Source/Core/Core/HW/VideoInterface.h | 4 ++-- .../DolphinQt/Config/Graphics/EnhancementsWidget.cpp | 11 +++++------ Source/Core/VideoCommon/Present.h | 6 +++++- Source/Core/VideoCommon/VertexManagerBase.cpp | 5 +++-- Source/Core/VideoCommon/Widescreen.cpp | 1 + Source/Core/VideoCommon/Widescreen.h | 3 +++ 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Source/Core/Core/HW/VideoInterface.cpp b/Source/Core/Core/HW/VideoInterface.cpp index c89ac88f84..5848d9ef16 100644 --- a/Source/Core/Core/HW/VideoInterface.cpp +++ b/Source/Core/Core/HW/VideoInterface.cpp @@ -477,7 +477,7 @@ float VideoInterfaceManager::GetAspectRatio() const // signal (which would be 4:3) // This function only deals with standard aspect ratios. For widescreen aspect ratios, - // multiply the result by 1.33333.. + // multiply the result by 1.33333... (the ratio between 16:9 and 4:3) // 1. Get our active area in BT.601 samples (more or less pixels) int active_lines = m_vertical_timing_register.ACV; diff --git a/Source/Core/Core/HW/VideoInterface.h b/Source/Core/Core/HW/VideoInterface.h index e68ebfc2ad..8bb1e23405 100644 --- a/Source/Core/Core/HW/VideoInterface.h +++ b/Source/Core/Core/HW/VideoInterface.h @@ -388,9 +388,9 @@ public: u32 GetTicksPerHalfLine() const; u32 GetTicksPerField() const; - // Get the aspect ratio of VI's active area. + // Get the aspect ratio of VI's active area (rarely matching pure 4:3). // This function only deals with standard aspect ratios. For widescreen aspect ratios, multiply - // the result by 1.33333.. + // the result by 1.33333... (the ratio between 16:9 and 4:3) float GetAspectRatio() const; // Create a fake VI mode for a fifolog diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp index aa0e3d1d28..85f3a8faf8 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp @@ -561,12 +561,11 @@ void EnhancementsWidget::AddDescriptions() "causes slowdowns or graphical issues.

If unsure, leave " "this unchecked."); static const char TR_WIDESCREEN_HACK_DESCRIPTION[] = QT_TR_NOOP( - "Forces the game to output graphics for any aspect ratio. Use with \"Aspect Ratio\" set to " - "\"Force 16:9\" to force 4:3-only games to run at 16:9.

Rarely produces good " - "results and " - "often partially breaks graphics and game UIs. Unnecessary (and detrimental) if using any " - "AR/Gecko-code widescreen patches.

If unsure, leave " - "this unchecked."); + "Forces the game to output graphics at any aspect ratio by expanding the view frustum " + "without stretching the image.
This is a hack, and its results will vary widely game " + "to game (it often causes the UI to stretch).
" + "Game-specific AR/Gecko-code aspect ratio patches are preferable over this if available." + "

If unsure, leave this unchecked."); static const char TR_REMOVE_FOG_DESCRIPTION[] = QT_TR_NOOP("Makes distant objects more visible by removing fog, thus increasing the overall " "detail.

Disabling fog will break some games which rely on proper fog " diff --git a/Source/Core/VideoCommon/Present.h b/Source/Core/VideoCommon/Present.h index c8bbf44257..82942e0270 100644 --- a/Source/Core/VideoCommon/Present.h +++ b/Source/Core/VideoCommon/Present.h @@ -46,7 +46,7 @@ public: void ConfigChanged(u32 changed_bits); - // Display resolution + // Window resolution (display resolution if fullscreen) int GetBackbufferWidth() const { return m_backbuffer_width; } int GetBackbufferHeight() const { return m_backbuffer_height; } float GetBackbufferScale() const { return m_backbuffer_scale; } @@ -58,6 +58,7 @@ public: void UpdateDrawRectangle(); + // Returns the target aspect ratio the XFB output should be drawn with. float CalculateDrawAspectRatio(bool allow_stretch = true) const; // Crops the target rectangle to the framebuffer dimensions, reducing the size of the source @@ -126,6 +127,9 @@ private: Common::Flag m_surface_changed; Common::Flag m_surface_resized; + // The presentation rectangle. + // Width and height correspond to the final output resolution. + // Offsets imply black borders (if the window aspect ratio doesn't match the game's one). MathUtil::Rectangle m_target_rectangle = {}; RcTcacheEntry m_xfb_entry; diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index ac4446abba..35239d4e66 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -91,8 +91,9 @@ static bool IsAnamorphicProjection(const Projection::Raw& projection, const View const VideoConfig& config) { // If ratio between our projection and viewport aspect ratios is similar to 16:9 / 4:3 - // we have an anamorphic projection. This value can be overridden - // by a GameINI. + // we have an anamorphic projection. This value can be overridden by a GameINI. + // Game cheats that change the aspect ratio to natively unsupported ones + // won't be automatically recognized here. return std::abs(CalculateProjectionViewportRatio(projection, viewport) - config.widescreen_heuristic_widescreen_ratio) < diff --git a/Source/Core/VideoCommon/Widescreen.cpp b/Source/Core/VideoCommon/Widescreen.cpp index 4ca1ac3ccd..7591d098a4 100644 --- a/Source/Core/VideoCommon/Widescreen.cpp +++ b/Source/Core/VideoCommon/Widescreen.cpp @@ -53,6 +53,7 @@ void WidescreenManager::Update() } // Heuristic to detect if a GameCube game is in 16:9 anamorphic widescreen mode. +// Cheats that change the game aspect ratio to natively unsupported ones won't be recognized here. void WidescreenManager::UpdateWidescreenHeuristic() { const auto flush_statistics = g_vertex_manager->ResetFlushAspectRatioCount(); diff --git a/Source/Core/VideoCommon/Widescreen.h b/Source/Core/VideoCommon/Widescreen.h index c8dc5847ec..586aa48e84 100644 --- a/Source/Core/VideoCommon/Widescreen.h +++ b/Source/Core/VideoCommon/Widescreen.h @@ -11,11 +11,14 @@ class PointerWrap; // This class is responsible for tracking the game's aspect ratio. +// This exclusively supports 4:3 or 16:9 detection by default. class WidescreenManager { public: WidescreenManager(); + // Just a helper to tell whether the game seems to be running in widescreen, + // or if it's being forced to. bool IsGameWidescreen() const { return m_is_game_widescreen; } void DoState(PointerWrap& p);