From 034d979dcebd9e5f45b8a11e7b31909d3af451ee Mon Sep 17 00:00:00 2001 From: HorrorTroll Date: Thu, 23 Aug 2018 12:20:59 +0700 Subject: [PATCH] Add BGRA8Unorm, BGRA8Srgb, ZF32_X24S8 texture format --- Ryujinx.Graphics/Gal/GalTextureFormat.cs | 1 + Ryujinx.Graphics/Gal/ImageFormatConverter.cs | 13 ++++++++++--- Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs | 7 ++++--- Ryujinx.HLE/Gpu/Texture/TextureHelper.cs | 1 + Ryujinx.HLE/Gpu/Texture/TextureReader.cs | 1 + 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Ryujinx.Graphics/Gal/GalTextureFormat.cs b/Ryujinx.Graphics/Gal/GalTextureFormat.cs index 5ab7be89b2..d376ea78a1 100644 --- a/Ryujinx.Graphics/Gal/GalTextureFormat.cs +++ b/Ryujinx.Graphics/Gal/GalTextureFormat.cs @@ -24,6 +24,7 @@ namespace Ryujinx.Graphics.Gal BC5 = 0x28, Z24S8 = 0x29, ZF32 = 0x2f, + ZF32_X24S8 = 0x30, Astc2D4x4 = 0x40, Astc2D5x5 = 0x41, Astc2D6x6 = 0x42, diff --git a/Ryujinx.Graphics/Gal/ImageFormatConverter.cs b/Ryujinx.Graphics/Gal/ImageFormatConverter.cs index 2d20a8a0e0..6084c23cd4 100644 --- a/Ryujinx.Graphics/Gal/ImageFormatConverter.cs +++ b/Ryujinx.Graphics/Gal/ImageFormatConverter.cs @@ -53,6 +53,7 @@ namespace Ryujinx.Graphics.Gal case GalTextureFormat.BC4: return GalImageFormat.BC4_UNORM_BLOCK; case GalTextureFormat.BC5: return GalImageFormat.BC5_UNORM_BLOCK; case GalTextureFormat.Z24S8: return GalImageFormat.D24_UNORM_S8_UINT; + case GalTextureFormat.ZF32_X24S8: return GalImageFormat.D32_SFLOAT_S8_UINT; case GalTextureFormat.Astc2D4x4: return GalImageFormat.ASTC_4x4_UNORM_BLOCK; case GalTextureFormat.Astc2D5x5: return GalImageFormat.ASTC_5x5_UNORM_BLOCK; case GalTextureFormat.Astc2D6x6: return GalImageFormat.ASTC_6x6_UNORM_BLOCK; @@ -142,6 +143,8 @@ namespace Ryujinx.Graphics.Gal case GalFrameBufferFormat.RG8Snorm: return GalImageFormat.R8_SNORM; case GalFrameBufferFormat.RGBA8Snorm: return GalImageFormat.A8B8G8R8_SNORM_PACK32; case GalFrameBufferFormat.RG8Unorm: return GalImageFormat.R8G8_UNORM; + case GalFrameBufferFormat.BGRA8Unorm: return GalImageFormat.A8B8G8R8_UNORM_PACK32; + case GalFrameBufferFormat.BGRA8Srgb: return GalImageFormat.A8B8G8R8_SRGB_PACK32; } throw new NotImplementedException(Format.ToString()); @@ -151,9 +154,10 @@ namespace Ryujinx.Graphics.Gal { switch (Format) { - case GalZetaFormat.Z32Float: return GalImageFormat.D32_SFLOAT; - case GalZetaFormat.S8Z24Unorm: return GalImageFormat.D24_UNORM_S8_UINT; - case GalZetaFormat.Z16Unorm: return GalImageFormat.D16_UNORM; + case GalZetaFormat.Z32Float: return GalImageFormat.D32_SFLOAT; + case GalZetaFormat.S8Z24Unorm: return GalImageFormat.D24_UNORM_S8_UINT; + case GalZetaFormat.Z16Unorm: return GalImageFormat.D16_UNORM; + case GalZetaFormat.Z32S8X24Float: return GalImageFormat.D32_SFLOAT_S8_UINT; } throw new NotImplementedException(Format.ToString()); @@ -228,6 +232,7 @@ namespace Ryujinx.Graphics.Gal case GalImageFormat.D24_UNORM_S8_UINT: case GalImageFormat.D32_SFLOAT: case GalImageFormat.D16_UNORM: + case GalImageFormat.D32_SFLOAT_S8_UINT: return true; } @@ -241,6 +246,7 @@ namespace Ryujinx.Graphics.Gal case GalImageFormat.D24_UNORM_S8_UINT: case GalImageFormat.D32_SFLOAT: case GalImageFormat.D16_UNORM: + case GalImageFormat.D32_SFLOAT_S8_UINT: return true; } @@ -254,6 +260,7 @@ namespace Ryujinx.Graphics.Gal switch (Format) { case GalImageFormat.D24_UNORM_S8_UINT: + case GalImageFormat.D32_SFLOAT_S8_UINT: return true; } diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs index e04a59d444..9cedfe8cd6 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs @@ -168,9 +168,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL case GalImageFormat.R4G4B4A4_UNORM_PACK16_REVERSED: return (PixelInternalFormat.Rgba4, PixelFormat.Rgba, PixelType.UnsignedShort4444Reversed); - case GalImageFormat.D24_UNORM_S8_UINT: return (PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248); - case GalImageFormat.D32_SFLOAT: return (PixelInternalFormat.DepthComponent32f, PixelFormat.DepthComponent, PixelType.Float); - case GalImageFormat.D16_UNORM: return (PixelInternalFormat.DepthComponent16, PixelFormat.DepthComponent, PixelType.UnsignedShort); + case GalImageFormat.D24_UNORM_S8_UINT: return (PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248); + case GalImageFormat.D32_SFLOAT: return (PixelInternalFormat.DepthComponent32f, PixelFormat.DepthComponent, PixelType.Float); + case GalImageFormat.D16_UNORM: return (PixelInternalFormat.DepthComponent16, PixelFormat.DepthComponent, PixelType.UnsignedShort); + case GalImageFormat.D32_SFLOAT_S8_UINT: return (PixelInternalFormat.Depth32fStencil8, PixelFormat.DepthStencil, PixelType.Float32UnsignedInt248Rev); } throw new NotImplementedException(Format.ToString()); diff --git a/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs b/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs index 92b608a952..2958be81f3 100644 --- a/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs +++ b/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs @@ -44,6 +44,7 @@ namespace Ryujinx.HLE.Gpu.Texture case GalImageFormat.R16G16B16A16_SNORM: case GalImageFormat.R16G16B16A16_UINT: case GalImageFormat.R16G16B16A16_UNORM: + case GalImageFormat.D32_SFLOAT_S8_UINT: return Image.Width * Image.Height * 8; case GalImageFormat.A8B8G8R8_SINT_PACK32: diff --git a/Ryujinx.HLE/Gpu/Texture/TextureReader.cs b/Ryujinx.HLE/Gpu/Texture/TextureReader.cs index 19aa25d74d..95be40d9b7 100644 --- a/Ryujinx.HLE/Gpu/Texture/TextureReader.cs +++ b/Ryujinx.HLE/Gpu/Texture/TextureReader.cs @@ -32,6 +32,7 @@ namespace Ryujinx.HLE.Gpu.Texture case GalTextureFormat.BC4: return Read8Bpt4x4 (Memory, Texture); case GalTextureFormat.BC5: return Read16BptCompressedTexture(Memory, Texture, 4, 4); case GalTextureFormat.ZF32: return Read4Bpp (Memory, Texture); + case GalTextureFormat.ZF32_X24S8: return Read8Bpp (Memory, Texture); case GalTextureFormat.Astc2D4x4: return Read16BptCompressedTexture(Memory, Texture, 4, 4); case GalTextureFormat.Astc2D5x5: return Read16BptCompressedTexture(Memory, Texture, 5, 5); case GalTextureFormat.Astc2D6x6: return Read16BptCompressedTexture(Memory, Texture, 6, 6);