From bf28d8f1aa4288fba9d2204b8fe1af573bc2a72e Mon Sep 17 00:00:00 2001 From: HorrorTroll Date: Sun, 2 Sep 2018 04:25:49 +0700 Subject: [PATCH] Add BGRA8Unorm, BGRA8Srgb, ZF32_X24S8 texture format (#377) * Add BGRA8Unorm, BGRA8Srgb, ZF32_X24S8 texture format * Add BGRA8Unorm, BGRA8Srgb, ZF32_X24S8 texture format * Revert "Add BGRA8Unorm, BGRA8Srgb, ZF32_X24S8 texture format" This reverts commit aea5c9db3a5e0b11545c3520f885e411a3587113. * Conflicts fix * Wrong fix * E * e --- 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 ed3d3d85d3..009d2b826e 100644 --- a/Ryujinx.Graphics/Gal/GalTextureFormat.cs +++ b/Ryujinx.Graphics/Gal/GalTextureFormat.cs @@ -25,6 +25,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 a56ab1a3fe..8684ba9618 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; @@ -145,6 +146,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; case GalFrameBufferFormat.RG32Float: return GalImageFormat.R32G32_SFLOAT; case GalFrameBufferFormat.RG32Sint: return GalImageFormat.R32G32_SINT; case GalFrameBufferFormat.RG32Uint: return GalImageFormat.R32G32_UINT; @@ -157,9 +160,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()); @@ -237,6 +241,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 false; } @@ -250,6 +255,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; } @@ -263,6 +269,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 07147cc081..959d0e3292 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs @@ -171,9 +171,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 89228b2509..98da852eee 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: case GalImageFormat.R32G32_SFLOAT: case GalImageFormat.R32G32_SINT: case GalImageFormat.R32G32_UINT: diff --git a/Ryujinx.HLE/Gpu/Texture/TextureReader.cs b/Ryujinx.HLE/Gpu/Texture/TextureReader.cs index 6bbc41cad0..65fa7e6ebe 100644 --- a/Ryujinx.HLE/Gpu/Texture/TextureReader.cs +++ b/Ryujinx.HLE/Gpu/Texture/TextureReader.cs @@ -33,6 +33,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);