VideoConfig: Eliminate the widescreen hack adjustment values.

This commit is contained in:
Jordan Woyak 2025-03-11 03:28:00 -05:00
parent 5ed8b7bc9d
commit 7d2431fa32
4 changed files with 31 additions and 29 deletions

View file

@ -19,6 +19,7 @@
#include "VideoCommon/PostProcessing.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoConfig.h"
#include "VideoCommon/VideoEvents.h"
#include "VideoCommon/Widescreen.h"
@ -622,8 +623,7 @@ void Presenter::UpdateDrawRectangle()
const float draw_aspect_ratio = CalculateDrawAspectRatio();
// Update aspect ratio hack values
// Won't take effect until next frame
// Don't know if there is a better place for this code so there isn't a 1 frame delay
auto& system = Core::System::GetInstance();
if (g_ActiveConfig.bWidescreenHack)
{
const auto& vi = Core::System::GetInstance().GetVideoInterface();
@ -634,24 +634,12 @@ void Presenter::UpdateDrawRectangle()
source_aspect_ratio = SourceAspectRatioToWidescreen(source_aspect_ratio);
const float adjust = source_aspect_ratio / draw_aspect_ratio;
if (adjust > 1)
{
// Vert+
g_Config.fAspectRatioHackW = 1;
g_Config.fAspectRatioHackH = 1 / adjust;
}
else
{
// Hor+
g_Config.fAspectRatioHackW = adjust;
g_Config.fAspectRatioHackH = 1;
}
system.GetVertexShaderManager().SetAspectRatioHack(adjust);
}
else
{
// Hack is disabled.
g_Config.fAspectRatioHackW = 1;
g_Config.fAspectRatioHackH = 1;
system.GetVertexShaderManager().SetAspectRatioHack(1.f);
}
// The rendering window size

View file

@ -8,15 +8,11 @@
#include <cstring>
#include <iterator>
#include "Common/BitSet.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
#include "Common/Logging/Log.h"
#include "Common/Matrix.h"
#include "Core/Config/GraphicsSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "VideoCommon/BPFunctions.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/CPMemory.h"
@ -25,7 +21,6 @@
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h"
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h"
@ -43,9 +38,16 @@ void VertexShaderManager::Init()
m_viewport_correction = Common::Matrix44::Identity();
m_projection_matrix = Common::Matrix44::Identity().data;
m_aspect_ratio_hack = 1.f;
dirty = true;
}
void VertexShaderManager::SetAspectRatioHack(float adjustment)
{
m_aspect_ratio_hack = adjustment;
}
Common::Matrix44 VertexShaderManager::LoadProjectionMatrix()
{
const auto& rawProjection = xfmem.projection.rawProjection;
@ -57,14 +59,24 @@ Common::Matrix44 VertexShaderManager::LoadProjectionMatrix()
const Common::Vec2 fov_multiplier = g_freelook_camera.IsActive() ?
g_freelook_camera.GetFieldOfViewMultiplier() :
Common::Vec2{1, 1};
m_projection_matrix[0] = rawProjection[0] * g_ActiveConfig.fAspectRatioHackW * fov_multiplier.x;
// "Widescreen Hack":
float aspect_ratio_hack_w = m_aspect_ratio_hack.load();
float aspect_ratio_hack_h = 1.f;
if (aspect_ratio_hack_w > 1)
{
aspect_ratio_hack_h = 1.f / aspect_ratio_hack_w;
aspect_ratio_hack_w = 1.f;
}
m_projection_matrix[0] = rawProjection[0] * aspect_ratio_hack_w * fov_multiplier.x;
m_projection_matrix[1] = 0.0f;
m_projection_matrix[2] = rawProjection[1] * g_ActiveConfig.fAspectRatioHackW * fov_multiplier.x;
m_projection_matrix[2] = rawProjection[1] * aspect_ratio_hack_w * fov_multiplier.x;
m_projection_matrix[3] = 0.0f;
m_projection_matrix[4] = 0.0f;
m_projection_matrix[5] = rawProjection[2] * g_ActiveConfig.fAspectRatioHackH * fov_multiplier.y;
m_projection_matrix[6] = rawProjection[3] * g_ActiveConfig.fAspectRatioHackH * fov_multiplier.y;
m_projection_matrix[5] = rawProjection[2] * aspect_ratio_hack_h * fov_multiplier.y;
m_projection_matrix[6] = rawProjection[3] * aspect_ratio_hack_h * fov_multiplier.y;
m_projection_matrix[7] = 0.0f;
m_projection_matrix[8] = 0.0f;

View file

@ -4,10 +4,10 @@
#pragma once
#include <array>
#include <atomic>
#include <string>
#include <vector>
#include "Common/BitSet.h"
#include "Common/CommonTypes.h"
#include "Common/Matrix.h"
#include "VideoCommon/ConstantManager.h"
@ -78,6 +78,8 @@ public:
UpdateOffsets(&dirty, false, &constants.vertex_offset_normals, format.normals);
}
void SetAspectRatioHack(float adjustment);
private:
alignas(16) std::array<float, 16> m_projection_matrix;
@ -87,4 +89,6 @@ private:
Common::Matrix44 m_viewport_correction{};
Common::Matrix44 LoadProjectionMatrix();
std::atomic<float> m_aspect_ratio_hack = 1.f;
};

View file

@ -293,8 +293,6 @@ struct VideoConfig final
bool bSkipPresentingDuplicateXFBs = false;
bool bCopyEFBScaled = false;
int iSafeTextureCache_ColorSamples = 0;
float fAspectRatioHackW = 1; // Initial value needed for the first frame
float fAspectRatioHackH = 1;
bool bEnablePixelLighting = false;
bool bFastDepthCalc = false;
bool bVertexRounding = false;