diff --git a/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/Ryujinx.Graphics.Gpu/Image/TexturePool.cs index a4f54c520..f81c67ef7 100644 --- a/Ryujinx.Graphics.Gpu/Image/TexturePool.cs +++ b/Ryujinx.Graphics.Gpu/Image/TexturePool.cs @@ -179,6 +179,22 @@ namespace Ryujinx.Graphics.Gpu.Image swizzleB, swizzleA); + if (IsDepthStencil(formatInfo.Format)) + { + swizzleR = SwizzleComponent.Red; + swizzleG = SwizzleComponent.Red; + swizzleB = SwizzleComponent.Red; + + if (depthStencilMode == DepthStencilMode.Depth) + { + swizzleA = SwizzleComponent.One; + } + else + { + swizzleA = SwizzleComponent.Red; + } + } + return new TextureInfo( address, width, @@ -252,6 +268,26 @@ namespace Ryujinx.Graphics.Gpu.Image component == SwizzleComponent.Green; } + /// + /// Checks if the texture format is a depth, stencil or depth-stencil format. + /// + /// Texture format + /// True if the format is a depth, stencil or depth-stencil format, false otherwise + private static bool IsDepthStencil(Format format) + { + switch (format) + { + case Format.D16Unorm: + case Format.D24UnormS8Uint: + case Format.D24X8Unorm: + case Format.D32Float: + case Format.D32FloatS8Uint: + return true; + } + + return false; + } + /// /// Decrements the reference count of the texture. /// This indicates that the texture pool is not using it anymore.