diff --git a/Source/Core/VideoCommon/FramebufferManager.cpp b/Source/Core/VideoCommon/FramebufferManager.cpp index c989f9d5c8..6953582ed6 100644 --- a/Source/Core/VideoCommon/FramebufferManager.cpp +++ b/Source/Core/VideoCommon/FramebufferManager.cpp @@ -509,7 +509,7 @@ void FramebufferManager::DestroyReadbackPipelines() bool FramebufferManager::CreateReadbackFramebuffer() { - if (g_renderer->GetEFBScale() != 1) + if (g_renderer->IsUnscaled()) { const TextureConfig color_config(IsUsingTiledEFBCache() ? m_efb_cache_tile_size : EFB_WIDTH, IsUsingTiledEFBCache() ? m_efb_cache_tile_size : EFB_HEIGHT, 1, @@ -530,7 +530,7 @@ bool FramebufferManager::CreateReadbackFramebuffer() (IsUsingTiledEFBCache() && !g_ActiveConfig.backend_info.bSupportsPartialDepthCopies) || !AbstractTexture::IsCompatibleDepthAndColorFormats(m_efb_depth_texture->GetFormat(), GetEFBDepthCopyFormat()) || - g_renderer->GetEFBScale() != 1) + g_renderer->IsUnscaled()) { const TextureConfig depth_config(IsUsingTiledEFBCache() ? m_efb_cache_tile_size : EFB_WIDTH, IsUsingTiledEFBCache() ? m_efb_cache_tile_size : EFB_HEIGHT, 1, @@ -602,7 +602,7 @@ void FramebufferManager::PopulateEFBCache(bool depth, u32 tile_index) const MathUtil::Rectangle native_rect = g_renderer->ConvertEFBRectangle(rect); AbstractTexture* src_texture = depth ? ResolveEFBDepthTexture(native_rect) : ResolveEFBColorTexture(native_rect); - if (g_renderer->GetEFBScale() != 1 || force_intermediate_copy) + if (g_renderer->IsUnscaled() || force_intermediate_copy) { // Downsample from internal resolution to 1x. // TODO: This won't produce correct results at IRs above 2x. More samples are required. @@ -781,7 +781,7 @@ void FramebufferManager::CreatePokeVertices(std::vector* destinat // GPU will expand the point to a quad. const float cs_x = (static_cast(x) + 0.5f) * cs_pixel_width - 1.0f; const float cs_y = 1.0f - (static_cast(y) + 0.5f) * cs_pixel_height; - const float point_size = static_cast(g_renderer->GetEFBScale()); + const float point_size = g_renderer->GetEFBScalef(); destination_list->push_back({{cs_x, cs_y, z, point_size}, color}); return; } diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 2e5709f86c..5623d4f480 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -275,19 +275,24 @@ void Renderer::RenderToXFB(u32 xfbAddr, const MathUtil::Rectangle& sourceRc return; } -unsigned int Renderer::GetEFBScale() const +bool Renderer::IsUnscaled() const { - return m_efb_scale; + return m_efb_scale == 2; +} + +float Renderer::GetEFBScalef() const +{ + return m_efb_scale / 2.0f; } int Renderer::EFBToScaledX(int x) const { - return x * static_cast(m_efb_scale); + return x * static_cast(m_efb_scale) / 2; } int Renderer::EFBToScaledY(int y) const { - return y * static_cast(m_efb_scale); + return y * static_cast(m_efb_scale) / 2; } float Renderer::EFBToScaledXf(float x) const @@ -302,7 +307,7 @@ float Renderer::EFBToScaledYf(float y) const std::tuple Renderer::CalculateTargetScale(int x, int y) const { - return std::make_tuple(x * static_cast(m_efb_scale), y * static_cast(m_efb_scale)); + return std::make_tuple(x * static_cast(m_efb_scale) / 2, y * static_cast(m_efb_scale) / 2); } // return true if target size changed diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 03f756d55a..d0064fe3c3 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -188,7 +188,8 @@ public: std::tuple, MathUtil::Rectangle> ConvertStereoRectangle(const MathUtil::Rectangle& rc) const; - unsigned int GetEFBScale() const; + bool IsUnscaled() const; + float GetEFBScalef() const; // Use this to upscale native EFB coordinates to IDEAL internal resolution int EFBToScaledX(int x) const; @@ -342,7 +343,7 @@ private: std::tuple CalculateOutputDimensions(int width, int height) const; PEControl::PixelFormat m_prev_efb_format = PEControl::INVALID_FMT; - unsigned int m_efb_scale = 1; + unsigned int m_efb_scale = 2; // These will be set on the first call to SetWindowSize. int m_last_window_request_width = 0; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index fdf3c0e6b3..d8c552adb4 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -992,7 +992,7 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex, // that have arbitrary contents, eg. are used for fog effects where the // distance they kick in at is important to preserve at any resolution. // Correct this with the upscaling factor of custom textures. - s64 lod_offset = std::log2(g_renderer->GetEFBScale() / custom_tex_scale) * 256.f; + s64 lod_offset = std::log2(g_renderer->GetEFBScalef() / custom_tex_scale) * (s64) 256.f; state.lod_bias = std::clamp(state.lod_bias + lod_offset, -32768, 32767); // Anisotropic also pushes mips farther away so it cannot be used either @@ -2142,8 +2142,7 @@ void TextureCacheBase::CopyRenderTargetToTexture( // TODO: This only produces perfect downsampling for 2x IR, other resolutions will need more // complex down filtering to average all pixels and produce the correct result. const bool linear_filter = - !is_depth_copy && (scaleByHalf || g_renderer->GetEFBScale() != 1 || y_scale > 1.0f); - + !is_depth_copy && (scaleByHalf || g_renderer->IsUnscaled() || y_scale > 1.0f); TCacheEntry* entry = nullptr; if (copy_to_vram) {