From a92ae827c1cc47b6d45ddc71aca4785b290329db Mon Sep 17 00:00:00 2001 From: eladash Date: Mon, 1 Oct 2018 07:57:12 +0300 Subject: [PATCH] rsx: Remove texture mipmap hack --- rpcs3/Emu/RSX/GL/GLTexture.cpp | 2 +- rpcs3/Emu/RSX/RSXTexture.cpp | 15 ++++++--------- rpcs3/Emu/RSX/rsx_utils.h | 5 +++++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index 83ffc907aa..809ae621a6 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -214,7 +214,7 @@ namespace gl glSamplerParameterfv(samplerHandle, GL_TEXTURE_BORDER_COLOR, border_color.rgba); if (sampled_image->upload_context != rsx::texture_upload_context::shader_read || - tex.get_exact_mipmap_count() <= 1) + tex.get_exact_mipmap_count() == 1) { GLint min_filter = tex_min_filter(tex.min_filter()); diff --git a/rpcs3/Emu/RSX/RSXTexture.cpp b/rpcs3/Emu/RSX/RSXTexture.cpp index 66b91f45dc..8311ce8187 100644 --- a/rpcs3/Emu/RSX/RSXTexture.cpp +++ b/rpcs3/Emu/RSX/RSXTexture.cpp @@ -65,18 +65,17 @@ namespace rsx u16 fragment_texture::get_exact_mipmap_count() const { - u16 max_mipmap_count = 1; + u16 max_mipmap_count; if (is_compressed_format()) { // OpenGL considers that highest mipmap level for DXTC format is when either width or height is 1 // not both. Assume it's the same for others backend. - max_mipmap_count = static_cast(floor(log2(std::min(width() / 4, height() / 4))) + 1); + max_mipmap_count = floor_log2(static_cast(std::min(width() / 4, height() / 4))) + 1; } else - max_mipmap_count = static_cast(floor(log2(std::max(width(), height()))) + 1); + max_mipmap_count = floor_log2(static_cast(std::max(width(), height()))) + 1; - max_mipmap_count = std::min(mipmap(), max_mipmap_count); - return (max_mipmap_count > 0) ? max_mipmap_count : 1; + return std::min(verify(HERE, mipmap()), max_mipmap_count); } rsx::texture_wrap_mode fragment_texture::wrap_s() const @@ -326,10 +325,8 @@ namespace rsx u16 vertex_texture::get_exact_mipmap_count() const { - u16 max_mipmap_count = static_cast(floor(log2(std::max(width(), height()))) + 1); - max_mipmap_count = std::min(mipmap(), max_mipmap_count); - - return (max_mipmap_count > 0) ? max_mipmap_count : 1; + const u16 max_mipmap_count = floor_log2(static_cast(std::max(width(), height()))) + 1; + return std::min(verify(HERE, mipmap()), max_mipmap_count); } std::pair, std::array> vertex_texture::decoded_remap() const diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 8c5522ce6e..bf5cdb4c34 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -144,6 +144,11 @@ namespace rsx } // + static inline u32 floor_log2(u32 value) + { + return value <= 1 ? 0 : utils::cntlz32(value, true) ^ 31; + } + static inline u32 ceil_log2(u32 value) { return value <= 1 ? 0 : utils::cntlz32((value - 1) << 1, true) ^ 31;