diff options
author | gdkchan <gab.dark.100@gmail.com> | 2020-05-03 18:18:00 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-03 23:18:00 +0200 |
commit | 1758424208335d1f4ff7c27c554e517c81bf72f6 (patch) | |
tree | 23309e6fc1532efa05d32182ac2ffc25191ec8b6 /Ryujinx.Graphics.Gpu/Image/TexturePool.cs | |
parent | ea3d5fde7329e5fede58e216f8c1dc045b504029 (diff) |
Use correct swizzle on depth-stencil textures (#1196)
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/TexturePool.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TexturePool.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/Ryujinx.Graphics.Gpu/Image/TexturePool.cs index a4f54c52..f81c67ef 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, @@ -253,6 +269,26 @@ namespace Ryujinx.Graphics.Gpu.Image } /// <summary> + /// Checks if the texture format is a depth, stencil or depth-stencil format. + /// </summary> + /// <param name="format">Texture format</param> + /// <returns>True if the format is a depth, stencil or depth-stencil format, false otherwise</returns> + 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; + } + + /// <summary> /// Decrements the reference count of the texture. /// This indicates that the texture pool is not using it anymore. /// </summary> |