mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-20 18:32:01 +00:00
Fix swizzle for certain formats
This commit is contained in:
parent
cd7d62542a
commit
d58f79ae0f
1 changed files with 26 additions and 4 deletions
|
@ -39,12 +39,34 @@ namespace Ryujinx.Graphics.Metal
|
||||||
descriptor.SampleCount = (ulong)Info.Samples;
|
descriptor.SampleCount = (ulong)Info.Samples;
|
||||||
descriptor.MipmapLevelCount = (ulong)Info.Levels;
|
descriptor.MipmapLevelCount = (ulong)Info.Levels;
|
||||||
descriptor.TextureType = Info.Target.Convert();
|
descriptor.TextureType = Info.Target.Convert();
|
||||||
|
|
||||||
|
var swizzleR = Info.SwizzleR.Convert();
|
||||||
|
var swizzleG = Info.SwizzleG.Convert();
|
||||||
|
var swizzleB = Info.SwizzleB.Convert();
|
||||||
|
var swizzleA = Info.SwizzleA.Convert();
|
||||||
|
|
||||||
|
if (info.Format == Format.R5G5B5A1Unorm ||
|
||||||
|
info.Format == Format.R5G5B5X1Unorm ||
|
||||||
|
info.Format == Format.R5G6B5Unorm)
|
||||||
|
{
|
||||||
|
(swizzleB, swizzleR) = (swizzleR, swizzleB);
|
||||||
|
} else if (descriptor.PixelFormat == MTLPixelFormat.ABGR4Unorm || info.Format == Format.A1B5G5R5Unorm)
|
||||||
|
{
|
||||||
|
var tempB = swizzleB;
|
||||||
|
var tempA = swizzleA;
|
||||||
|
|
||||||
|
swizzleB = swizzleG;
|
||||||
|
swizzleA = swizzleR;
|
||||||
|
swizzleR = tempA;
|
||||||
|
swizzleG = tempB;
|
||||||
|
}
|
||||||
|
|
||||||
descriptor.Swizzle = new MTLTextureSwizzleChannels
|
descriptor.Swizzle = new MTLTextureSwizzleChannels
|
||||||
{
|
{
|
||||||
red = Info.SwizzleR.Convert(),
|
red = swizzleR,
|
||||||
green = Info.SwizzleG.Convert(),
|
green = swizzleG,
|
||||||
blue = Info.SwizzleB.Convert(),
|
blue = swizzleB,
|
||||||
alpha = Info.SwizzleA.Convert()
|
alpha = swizzleA
|
||||||
};
|
};
|
||||||
|
|
||||||
MTLTexture = _device.NewTexture(descriptor);
|
MTLTexture = _device.NewTexture(descriptor);
|
||||||
|
|
Loading…
Reference in a new issue