diff --git a/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs b/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs index 0a43dd1b9..c94473a23 100644 --- a/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs +++ b/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs @@ -94,10 +94,42 @@ namespace Ryujinx.Graphics.Gpu.Image public MinFilter UnpackMinFilter() { - int minFilter = (int)(Word1 >> 4) & 3; - int mipFilter = (int)(Word1 >> 6) & 3; + SamplerMinFilter minFilter = (SamplerMinFilter)((Word1 >> 4) & 3); + SamplerMipFilter mipFilter = (SamplerMipFilter)((Word1 >> 6) & 3); - return (MinFilter)(minFilter + (mipFilter - 1) * 2); + return ConvertFilter(minFilter, mipFilter); + } + + private static MinFilter ConvertFilter(SamplerMinFilter minFilter, SamplerMipFilter mipFilter) + { + switch (mipFilter) + { + case SamplerMipFilter.None: + switch (minFilter) + { + case SamplerMinFilter.Nearest: return MinFilter.Nearest; + case SamplerMinFilter.Linear: return MinFilter.Linear; + } + break; + + case SamplerMipFilter.Nearest: + switch (minFilter) + { + case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapNearest; + case SamplerMinFilter.Linear: return MinFilter.LinearMipmapNearest; + } + break; + + case SamplerMipFilter.Linear: + switch (minFilter) + { + case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapLinear; + case SamplerMinFilter.Linear: return MinFilter.LinearMipmapLinear; + } + break; + } + + return MinFilter.Nearest; } public ReductionFilter UnpackReductionFilter() diff --git a/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs b/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs new file mode 100644 index 000000000..b3274b649 --- /dev/null +++ b/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.Graphics.Gpu.Image +{ + enum SamplerMinFilter + { + Nearest = 1, + Linear + } +} diff --git a/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs b/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs new file mode 100644 index 000000000..0bc9eb92c --- /dev/null +++ b/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs @@ -0,0 +1,9 @@ +namespace Ryujinx.Graphics.Gpu.Image +{ + enum SamplerMipFilter + { + None = 1, + Nearest, + Linear + } +}