Implement Mip Filter

master
FernandoS27 2018-10-24 19:25:28 +07:00
parent dc85e3bff1
commit 258f0f5c31
4 changed files with 33 additions and 10 deletions

@ -731,11 +731,15 @@ void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntr
if (mag_filter != config.mag_filter) {
mag_filter = config.mag_filter;
glSamplerParameteri(s, GL_TEXTURE_MAG_FILTER, MaxwellToGL::TextureFilterMode(mag_filter));
glSamplerParameteri(
s, GL_TEXTURE_MAG_FILTER,
MaxwellToGL::TextureFilterMode(mag_filter, Tegra::Texture::TextureMipmapFilter::None));
}
if (min_filter != config.min_filter) {
if (min_filter != config.min_filter || mip_filter != config.mip_filter) {
min_filter = config.min_filter;
glSamplerParameteri(s, GL_TEXTURE_MIN_FILTER, MaxwellToGL::TextureFilterMode(min_filter));
mip_filter = config.mip_filter;
glSamplerParameteri(s, GL_TEXTURE_MIN_FILTER,
MaxwellToGL::TextureFilterMode(min_filter, mip_filter));
}
if (wrap_u != config.wrap_u) {

@ -93,6 +93,7 @@ private:
private:
Tegra::Texture::TextureFilter mag_filter;
Tegra::Texture::TextureFilter min_filter;
Tegra::Texture::TextureMipmapFilter mip_filter;
Tegra::Texture::WrapMode wrap_u;
Tegra::Texture::WrapMode wrap_v;
Tegra::Texture::WrapMode wrap_p;

@ -919,7 +919,7 @@ struct SurfaceParams {
u32 height = MipHeight(mip_level);
u32 bh = block_height;
// Magical block resizing algorithm, needs more testing.
while (bh != 1 && height / bh <= 16) {
while (bh > 1 && (height + bh - 1) / bh <= 16) {
bh = bh >> 1;
}
return bh;
@ -929,7 +929,7 @@ struct SurfaceParams {
u32 depth = MipDepth(mip_level);
u32 bd = block_depth;
// Magical block resizing algorithm, needs more testing.
while (bd != 1 && depth / bd <= 16) {
while (bd > 1 && depth / bd <= 16) {
bd = bd >> 1;
}
return bd;

@ -135,12 +135,29 @@ inline GLenum PrimitiveTopology(Maxwell::PrimitiveTopology topology) {
return {};
}
inline GLenum TextureFilterMode(Tegra::Texture::TextureFilter filter_mode) {
inline GLenum TextureFilterMode(Tegra::Texture::TextureFilter filter_mode,
Tegra::Texture::TextureMipmapFilter mip_filter_mode) {
switch (filter_mode) {
case Tegra::Texture::TextureFilter::Linear:
case Tegra::Texture::TextureFilter::Linear: {
switch (mip_filter_mode) {
case Tegra::Texture::TextureMipmapFilter::None:
return GL_LINEAR;
case Tegra::Texture::TextureFilter::Nearest:
case Tegra::Texture::TextureMipmapFilter::Nearest:
return GL_NEAREST_MIPMAP_LINEAR;
case Tegra::Texture::TextureMipmapFilter::Linear:
return GL_LINEAR_MIPMAP_LINEAR;
}
}
case Tegra::Texture::TextureFilter::Nearest: {
switch (mip_filter_mode) {
case Tegra::Texture::TextureMipmapFilter::None:
return GL_NEAREST;
case Tegra::Texture::TextureMipmapFilter::Nearest:
return GL_NEAREST_MIPMAP_NEAREST;
case Tegra::Texture::TextureMipmapFilter::Linear:
return GL_LINEAR_MIPMAP_NEAREST;
}
}
}
LOG_CRITICAL(Render_OpenGL, "Unimplemented texture filter mode={}",
static_cast<u32>(filter_mode));
@ -148,6 +165,7 @@ inline GLenum TextureFilterMode(Tegra::Texture::TextureFilter filter_mode) {
return {};
}
inline GLenum WrapMode(Tegra::Texture::WrapMode wrap_mode) {
switch (wrap_mode) {
case Tegra::Texture::WrapMode::Wrap: