From 1aa75b1081d9292510965273054c566269169c08 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sun, 8 Mar 2020 15:59:38 -0300 Subject: textures: Fix anisotropy hack Previous code could generate an anisotropy value way higher than x16. --- src/video_core/textures/texture.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/video_core') diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h index 07098c70d..7edc4abe1 100644 --- a/src/video_core/textures/texture.h +++ b/src/video_core/textures/texture.h @@ -337,20 +337,22 @@ struct TSCEntry { }; float GetMaxAnisotropy() const { - switch (static_cast(Settings::values.max_anisotropy)) { - case Anisotropy::Default: - return static_cast(1U << max_anisotropy); - case Anisotropy::Filter2x: - return static_cast(2U << max_anisotropy); - case Anisotropy::Filter4x: - return static_cast(4U << max_anisotropy); - case Anisotropy::Filter8x: - return static_cast(8U << max_anisotropy); - case Anisotropy::Filter16x: - return static_cast(16U << max_anisotropy); - default: - return static_cast(1U << max_anisotropy); - } + const u32 min_value = [] { + switch (static_cast(Settings::values.max_anisotropy)) { + default: + case Anisotropy::Default: + return 1U; + case Anisotropy::Filter2x: + return 2U; + case Anisotropy::Filter4x: + return 4U; + case Anisotropy::Filter8x: + return 8U; + case Anisotropy::Filter16x: + return 16U; + } + }(); + return static_cast(std::max(1U << max_anisotropy, min_value)); } float GetMinLod() const { -- cgit v1.2.3