From 54c8dabadc7ad09bec6745da0286301fe1777ad4 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Tue, 19 Mar 2024 22:58:27 -0400 Subject: [PATCH] Fix Cubemap & Array Texture Creation --- src/Ryujinx.Graphics.Metal/Texture.cs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal/Texture.cs b/src/Ryujinx.Graphics.Metal/Texture.cs index 8b742d2cba..b7b004b3e8 100644 --- a/src/Ryujinx.Graphics.Metal/Texture.cs +++ b/src/Ryujinx.Graphics.Metal/Texture.cs @@ -27,18 +27,24 @@ namespace Ryujinx.Graphics.Metal _pipeline = pipeline; _info = info; - var descriptor = new MTLTextureDescriptor - { - PixelFormat = FormatTable.GetFormat(Info.Format), - Usage = MTLTextureUsage.ShaderRead, - Width = (ulong)Width, - Height = (ulong)Height, - Depth = (ulong)Depth - }; - descriptor.Depth = (ulong)Info.Depth; + var descriptor = new MTLTextureDescriptor(); + + descriptor.PixelFormat = FormatTable.GetFormat(Info.Format); + descriptor.Usage = MTLTextureUsage.ShaderRead; descriptor.SampleCount = (ulong)Info.Samples; - descriptor.MipmapLevelCount = (ulong)Info.Levels; descriptor.TextureType = Info.Target.Convert(); + descriptor.Width = (ulong)Info.Width; + descriptor.Height = (ulong)Info.Height; + descriptor.MipmapLevelCount = (ulong)Info.Levels; + + if (info.Target == Target.Texture3D) + { + descriptor.Depth = (ulong)Info.Depth; + } + else if (info.Target != Target.Cubemap) + { + descriptor.ArrayLength = (ulong)Info.Depth; + } var swizzleR = Info.SwizzleR.Convert(); var swizzleG = Info.SwizzleG.Convert();