From 7b2f471d4ff07bc811bbd84919c6708ab0f399f4 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 10 Apr 2018 18:54:50 -0300 Subject: [PATCH] [GPU] Add support for the BC4/5 texture formats --- Ryujinx.Core/OsHle/Services/Nv/INvDrvServices.cs | 2 ++ Ryujinx.Graphics/Gal/GalTextureFormat.cs | 4 +++- Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs | 2 ++ Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs | 14 +++++++++++--- Ryujinx.Graphics/Gpu/TextureReader.cs | 2 ++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Ryujinx.Core/OsHle/Services/Nv/INvDrvServices.cs b/Ryujinx.Core/OsHle/Services/Nv/INvDrvServices.cs index e41f03a4..800926df 100644 --- a/Ryujinx.Core/OsHle/Services/Nv/INvDrvServices.cs +++ b/Ryujinx.Core/OsHle/Services/Nv/INvDrvServices.cs @@ -316,6 +316,8 @@ namespace Ryujinx.Core.OsHle.Services.Nv int Padding = Reader.ReadInt32(); int Offset = Reader.ReadInt32(); int Pages = Reader.ReadInt32(); + + System.Console.WriteLine("remap " + Offset.ToString("x8") + " " + Pages.ToString("x8")); } //TODO diff --git a/Ryujinx.Graphics/Gal/GalTextureFormat.cs b/Ryujinx.Graphics/Gal/GalTextureFormat.cs index 8c2c718a..37291e18 100644 --- a/Ryujinx.Graphics/Gal/GalTextureFormat.cs +++ b/Ryujinx.Graphics/Gal/GalTextureFormat.cs @@ -7,6 +7,8 @@ namespace Ryujinx.Graphics.Gal B5G6R5 = 0x15, BC1 = 0x24, BC2 = 0x25, - BC3 = 0x26 + BC3 = 0x26, + BC4 = 0x27, + BC5 = 0x28 } } diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs index 03c3ef52..17bf6291 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs @@ -74,6 +74,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL case GalTextureFormat.BC1: return PixelInternalFormat.CompressedRgbaS3tcDxt1Ext; case GalTextureFormat.BC2: return PixelInternalFormat.CompressedRgbaS3tcDxt3Ext; case GalTextureFormat.BC3: return PixelInternalFormat.CompressedRgbaS3tcDxt5Ext; + case GalTextureFormat.BC4: return PixelInternalFormat.CompressedRedRgtc1; + case GalTextureFormat.BC5: return PixelInternalFormat.CompressedRgRgtc2; } throw new NotImplementedException(Format.ToString()); diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs index 681e6d67..b7c8999e 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs @@ -85,9 +85,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL private static bool IsCompressedTextureFormat(GalTextureFormat Format) { - return Format == GalTextureFormat.BC1 || - Format == GalTextureFormat.BC2 || - Format == GalTextureFormat.BC3; + switch (Format) + { + case GalTextureFormat.BC1: + case GalTextureFormat.BC2: + case GalTextureFormat.BC3: + case GalTextureFormat.BC4: + case GalTextureFormat.BC5: + return true; + } + + return false; } private int EnsureTextureInitialized(int TexIndex) diff --git a/Ryujinx.Graphics/Gpu/TextureReader.cs b/Ryujinx.Graphics/Gpu/TextureReader.cs index 715578b5..b3b016ed 100644 --- a/Ryujinx.Graphics/Gpu/TextureReader.cs +++ b/Ryujinx.Graphics/Gpu/TextureReader.cs @@ -16,6 +16,8 @@ namespace Ryujinx.Graphics.Gpu case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture); case GalTextureFormat.BC2: return Read16Bpt4x4(Memory, Texture); case GalTextureFormat.BC3: return Read16Bpt4x4(Memory, Texture); + case GalTextureFormat.BC4: return Read8Bpt4x4 (Memory, Texture); + case GalTextureFormat.BC5: return Read16Bpt4x4(Memory, Texture); } throw new NotImplementedException(Texture.Format.ToString());