From a7de2322a17e013a0d54f1b2e47840484e8c6f2b Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 27 Aug 2018 03:03:31 -0300 Subject: [PATCH] Implement TEX texture array --- Ryujinx.Graphics/Gal/OpenGL/OGLHelper.cs | 63 +++++++++++-------- .../Gal/Shader/ShaderDecodeMem.cs | 21 ++++--- .../Gal/Shader/ShaderTextureType.cs | 2 + Ryujinx/Ryujinx.conf | 2 +- 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLHelper.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLHelper.cs index 0106673e5..258baae13 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLHelper.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLHelper.cs @@ -62,38 +62,38 @@ namespace Ryujinx.Graphics.Gal.OpenGL break; case TextureTarget.TextureCubeMap: + { + long FaceSize = Data.LongLength / 6; + + for (int Face = 0; Face < 6; Face++) { - long FaceSize = Data.LongLength / 6; - - for (int Face = 0; Face < 6; Face++) + fixed (byte* DataPtr = Data) { - fixed (byte* DataPtr = Data) + IntPtr Addr; + + if (Data != null) { - IntPtr Addr; - - if (Data != null) - { - Addr = new IntPtr(DataPtr + FaceSize * Face); - } - else - { - Addr = new IntPtr(0); - } - - GL.TexImage2D( - TextureTarget.TextureCubeMapPositiveX + Face, - Level, - InternalFormat, - Width, - Height, - Border, - PixelFormat, - PixelType, - Addr); + Addr = new IntPtr(DataPtr + FaceSize * Face); } + else + { + Addr = new IntPtr(0); + } + + GL.TexImage2D( + TextureTarget.TextureCubeMapPositiveX + Face, + Level, + InternalFormat, + Width, + Height, + Border, + PixelFormat, + PixelType, + Addr); } - break; } + break; + } default: throw new NotImplementedException(Target.ToString()); @@ -112,6 +112,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL { switch (Target) { + case TextureTarget.Texture1D: + GL.CompressedTexImage1D( + Target, + Level, + InternalFormat, + Width, + Border, + Data.Length, + Data); + break; + case TextureTarget.Texture2D: GL.CompressedTexImage2D( Target, diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs index 1ae572725..4fbda458d 100644 --- a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs +++ b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs @@ -31,12 +31,12 @@ namespace Ryujinx.Graphics.Gal.Shader { RGB_, RG_A, R_BA, _GBA, RGBA, ____, ____, ____ } }; - private static ShaderTextureType[] TexTypes = new ShaderTextureType[] + private static ShaderTextureType[,] TexTypes = new ShaderTextureType[,] { - ShaderTextureType._1d, - ShaderTextureType._2d, - ShaderTextureType._3d, - ShaderTextureType.Cube, + { ShaderTextureType._1d, ShaderTextureType._1dArray }, + { ShaderTextureType._2d, ShaderTextureType._2dArray }, + { ShaderTextureType._3d, ShaderTextureType.Invalid }, + { ShaderTextureType.Cube, ShaderTextureType.Invalid } }; private static int[] TexTypeCoords = new int[] { 1, 2, 3, 3 }; @@ -169,13 +169,20 @@ namespace Ryujinx.Graphics.Gal.Shader private static void EmitTex(ShaderIrBlock Block, long OpCode, bool GprHandle) { + bool IsArray = ((OpCode >> 28) & 1) != 0; + int TypeId = (int)((OpCode >> 29) & 3); ShaderIrOperGpr[] Coords = new ShaderIrOperGpr[3]; - ShaderTextureType Type = TexTypes[TypeId]; + ShaderTextureType Type = TexTypes[TypeId, IsArray ? 1 : 0]; - for (int Index = 0; Index < TexTypeCoords[TypeId]; Index++) + if (Type == ShaderTextureType.Invalid) + { + throw new InvalidOperationException(); + } + + for (int Index = 0; Index < TexTypeCoords[TypeId] + (IsArray ? 1 : 0); Index++) { Coords[Index] = GetOperGpr8(OpCode) + Index; diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderTextureType.cs b/Ryujinx.Graphics/Gal/Shader/ShaderTextureType.cs index 27cab3080..81059e7e4 100644 --- a/Ryujinx.Graphics/Gal/Shader/ShaderTextureType.cs +++ b/Ryujinx.Graphics/Gal/Shader/ShaderTextureType.cs @@ -2,7 +2,9 @@ { enum ShaderTextureType { + Invalid, _1d, + _1dArray, _2d, _2dArray, _3d, diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index 8e736d38c..6e15a6ac2 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -2,7 +2,7 @@ Enable_Memory_Checks = false #Dump shaders in local directory (e.g. `C:\ShaderDumps`) -Graphics_Shaders_Dump_Path = D:\Shaders +Graphics_Shaders_Dump_Path = #Enable print debug logs Logging_Enable_Debug = false