mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-24 09:06:01 +00:00
Add constrained border colours to samplers (#26)
This commit is contained in:
parent
b33c1ae22f
commit
e27ade5aee
1 changed files with 34 additions and 1 deletions
|
@ -14,9 +14,11 @@ namespace Ryujinx.Graphics.Metal
|
|||
{
|
||||
(MTLSamplerMinMagFilter minFilter, MTLSamplerMipFilter mipFilter) = info.MinFilter.Convert();
|
||||
|
||||
MTLSamplerBorderColor borderColor = GetConstrainedBorderColor(info.BorderColor, out _);
|
||||
|
||||
var samplerState = device.NewSamplerState(new MTLSamplerDescriptor
|
||||
{
|
||||
BorderColor = MTLSamplerBorderColor.TransparentBlack,
|
||||
BorderColor = borderColor,
|
||||
MinFilter = minFilter,
|
||||
MagFilter = info.MagFilter.Convert(),
|
||||
MipFilter = mipFilter,
|
||||
|
@ -39,6 +41,37 @@ namespace Ryujinx.Graphics.Metal
|
|||
_mtlSamplerState = samplerState;
|
||||
}
|
||||
|
||||
private static MTLSamplerBorderColor GetConstrainedBorderColor(ColorF arbitraryBorderColor, out bool cantConstrain)
|
||||
{
|
||||
float r = arbitraryBorderColor.Red;
|
||||
float g = arbitraryBorderColor.Green;
|
||||
float b = arbitraryBorderColor.Blue;
|
||||
float a = arbitraryBorderColor.Alpha;
|
||||
|
||||
if (r == 0f && g == 0f && b == 0f)
|
||||
{
|
||||
if (a == 1f)
|
||||
{
|
||||
cantConstrain = false;
|
||||
return MTLSamplerBorderColor.OpaqueBlack;
|
||||
}
|
||||
|
||||
if (a == 0f)
|
||||
{
|
||||
cantConstrain = false;
|
||||
return MTLSamplerBorderColor.TransparentBlack;
|
||||
}
|
||||
}
|
||||
else if (r == 1f && g == 1f && b == 1f && a == 1f)
|
||||
{
|
||||
cantConstrain = false;
|
||||
return MTLSamplerBorderColor.OpaqueWhite;
|
||||
}
|
||||
|
||||
cantConstrain = true;
|
||||
return MTLSamplerBorderColor.OpaqueBlack;
|
||||
}
|
||||
|
||||
public MTLSamplerState GetSampler()
|
||||
{
|
||||
return _mtlSamplerState;
|
||||
|
|
Loading…
Reference in a new issue