Improved Min/Mip -> MinFilter enum conversion

This commit is contained in:
gdk 2019-10-13 23:24:31 -03:00 committed by Thog
parent 1bb08742c1
commit cdeeac163f
3 changed files with 52 additions and 3 deletions

View file

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

View file

@ -0,0 +1,8 @@
namespace Ryujinx.Graphics.Gpu.Image
{
enum SamplerMinFilter
{
Nearest = 1,
Linear
}
}

View file

@ -0,0 +1,9 @@
namespace Ryujinx.Graphics.Gpu.Image
{
enum SamplerMipFilter
{
None = 1,
Nearest,
Linear
}
}