rsx: Remove texture mipmap hack

This commit is contained in:
eladash 2018-10-01 07:57:12 +03:00 committed by kd-11
parent 6586090307
commit a92ae827c1
3 changed files with 12 additions and 10 deletions

View file

@ -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());

View file

@ -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<u16>(floor(log2(std::min(width() / 4, height() / 4))) + 1);
max_mipmap_count = floor_log2(static_cast<u32>(std::min(width() / 4, height() / 4))) + 1;
}
else
max_mipmap_count = static_cast<u16>(floor(log2(std::max(width(), height()))) + 1);
max_mipmap_count = floor_log2(static_cast<u32>(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<u16>(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<u32>(std::max(width(), height()))) + 1;
return std::min(verify(HERE, mipmap()), max_mipmap_count);
}
std::pair<std::array<u8, 4>, std::array<u8, 4>> vertex_texture::decoded_remap() const

View file

@ -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;