diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs index 497674ccb0..98fe172ec1 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs @@ -47,8 +47,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL const int Level = 0; //TODO: Support mipmap textures. const int Border = 0; - //Debug.Assert(Image.MaxMipmapLevel != 1, "No Mipmap support"); - TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Size); if (ImageUtils.IsCompressed(Image.Format)) @@ -104,10 +102,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL int FaceSize = ImageUtils.GetSize(Image) / Image.Depth; - for (int i = 0; i < 6; i++) + for (int Face = 0; Face < 6; Face++) { GL.TexImage2D( - TextureTarget.TextureCubeMapPositiveX + i, + TextureTarget.TextureCubeMapPositiveX + Face, Level, InternalFmt, Image.Width, @@ -119,7 +117,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL } break; default: - throw new InvalidOperationException($"Unsupported texture target type: {Target}"); + throw new NotImplementedException($"Unsupported texture target type: {Target}"); } } @@ -134,8 +132,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL const int Level = 0; //TODO: Support mipmap textures. const int Border = 0; - //Debug.Assert(Image.MaxMipmapLevel != 1, "No Mipmap support"); - TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Data.Length); if (ImageUtils.IsCompressed(Image.Format) && !IsAstc(Image.Format)) @@ -183,17 +179,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL int FaceSize = ImageUtils.GetSize(Image) / Image.Depth; - for (int i = 0; i < 6; i++) + for (int Face = 0; Face < 6; Face++) { GL.CompressedTexImage2D( - TextureTarget.TextureCubeMapPositiveX + i, + TextureTarget.TextureCubeMapPositiveX + Face, Level, InternalFmt, Image.Width, Image.Height, Border, FaceSize, - Array.Slice(i * FaceSize, FaceSize).ToArray()); + Array.Slice(Face * FaceSize, FaceSize).ToArray()); } break; case TextureTarget.TextureCubeMapArray: @@ -209,7 +205,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL Data); break; default: - throw new InvalidOperationException($"Unsupported texture target type: {Target}"); + throw new NotImplementedException($"Unsupported texture target type: {Target}"); } } else @@ -282,10 +278,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL int FaceSize = ImageUtils.GetSize(Image) / Image.Depth; - for (int i = 0; i < 6; i++) + for (int Face = 0; Face < 6; Face++) { GL.TexImage2D( - TextureTarget.TextureCubeMapPositiveX + i, + TextureTarget.TextureCubeMapPositiveX + Face, Level, InternalFmt, Image.Width, @@ -293,11 +289,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL Border, Format, Type, - Array.Slice(i * FaceSize, FaceSize).ToArray()); + Array.Slice(Face * FaceSize, FaceSize).ToArray()); } break; default: - throw new InvalidOperationException($"Unsupported texture target type: {Target}"); + throw new NotImplementedException($"Unsupported texture target type: {Target}"); } } } diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index fd5a355a85..e65a47239b 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -268,7 +268,6 @@ namespace Ryujinx.Graphics.Gal.Shader if (HasShadow) Result += "Shadow"; - return Result; } @@ -1439,7 +1438,7 @@ namespace Ryujinx.Graphics.Gal.Shader // TODO: Support AOFFI if ((Suffix & TextureInstructionSuffix.AOFFI) != 0) { - throw new NotSupportedException(); + throw new NotImplementedException(); } return "textureGather(" + Sampler + ", " + Coords + ", " + Comp + ")" + ChString; diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs index 329a99ecb3..7fecb5b0a4 100644 --- a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs +++ b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs @@ -508,7 +508,11 @@ namespace Ryujinx.Graphics.Gal.Shader EmitTld4(Block, OpCode, TextureType.TwoD, Suffix, RGBA, OpCode.Read(0x34, 0x3), true); } - private static void EmitTexs(ShaderIrBlock Block, long OpCode, ShaderIrInst Inst, TextureType TextureType, TextureInstructionSuffix TextureInstructionSuffix) + private static void EmitTexs(ShaderIrBlock Block, + long OpCode, + ShaderIrInst Inst, + TextureType TextureType, + TextureInstructionSuffix TextureInstructionSuffix) { if (Inst == ShaderIrInst.Txlf && TextureType == TextureType.CubeArray) { @@ -580,7 +584,7 @@ namespace Ryujinx.Graphics.Gal.Shader OperBIndex--; } - // TODO: Find what MZ do and what change about the encoding (Maybe Multisample?) + // TODO: Find what MZ does and what changes about the encoding (Maybe Multisample?) if ((TextureInstructionSuffix & TextureInstructionSuffix.LL) != 0) { LevelOfDetail = OpCode.Gpr20(); diff --git a/Ryujinx.Graphics/Graphics3d/Texture/BlockLinearSwizzle.cs b/Ryujinx.Graphics/Graphics3d/Texture/BlockLinearSwizzle.cs index d8638839e3..11dada692f 100644 --- a/Ryujinx.Graphics/Graphics3d/Texture/BlockLinearSwizzle.cs +++ b/Ryujinx.Graphics/Graphics3d/Texture/BlockLinearSwizzle.cs @@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Texture private int XShift; private int GobStride; - private int LayerZ; + private int SliceSize; public BlockLinearSwizzle(int Width, int Height, int Bpp, int BlockHeight) { @@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Texture XShift = CountLsbZeros(512 * BlockHeight); - LayerZ = Bpp * Width * Height; + SliceSize = Bpp * Width * Height; } private int CountLsbZeros(int Value) @@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Texture Position += ((Y & 0x01) >> 0) << 4; Position += ((X & 0x0f) >> 0) << 0; - return (Z * LayerZ) + Position; + return Z * SliceSize + Position; } } } \ No newline at end of file diff --git a/Ryujinx.Graphics/Graphics3d/Texture/ImageUtils.cs b/Ryujinx.Graphics/Graphics3d/Texture/ImageUtils.cs index 92af2ed1f3..22e04f3938 100644 --- a/Ryujinx.Graphics/Graphics3d/Texture/ImageUtils.cs +++ b/Ryujinx.Graphics/Graphics3d/Texture/ImageUtils.cs @@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Texture public int BytesPerPixel { get; private set; } public int BlockWidth { get; private set; } public int BlockHeight { get; private set; } - public int BlockDepth { get; private set; } + public int BlockDepth { get; private set; } public TargetBuffer Target { get; private set; } @@ -34,7 +34,7 @@ namespace Ryujinx.Graphics.Texture this.BytesPerPixel = BytesPerPixel; this.BlockWidth = BlockWidth; this.BlockHeight = BlockHeight; - this.BlockDepth = BlockDepth; + this.BlockDepth = BlockDepth; this.Target = Target; } } @@ -360,7 +360,7 @@ namespace Ryujinx.Graphics.Texture case 3: return Desc.BytesPerPixel * Width * Height * Depth; default: - throw new InvalidOperationException(); + throw new InvalidOperationException($"Invalid component count: {ComponentCount}"); } } @@ -529,7 +529,7 @@ namespace Ryujinx.Graphics.Texture case TextureType.CubeArray: return 4; default: - throw new NotImplementedException($"TextureTpe.{TextureType} not implemented yet"); + throw new NotImplementedException($"TextureTpe.{TextureType} not implemented yet."); } } } diff --git a/Ryujinx.Graphics/Graphics3d/Texture/LinearSwizzle.cs b/Ryujinx.Graphics/Graphics3d/Texture/LinearSwizzle.cs index ed4250148d..ffd9b472b7 100644 --- a/Ryujinx.Graphics/Graphics3d/Texture/LinearSwizzle.cs +++ b/Ryujinx.Graphics/Graphics3d/Texture/LinearSwizzle.cs @@ -5,18 +5,18 @@ namespace Ryujinx.Graphics.Texture private int Pitch; private int Bpp; - private int ZLayer; + private int SliceSize; public LinearSwizzle(int Pitch, int Bpp, int Width, int Height) { this.Pitch = Pitch; this.Bpp = Bpp; - this.ZLayer = Width * Height * Bpp; + SliceSize = Width * Height * Bpp; } public int GetSwizzleOffset(int X, int Y, int Z) { - return Z * ZLayer + X * Bpp + Y * Pitch; + return Z * SliceSize + X * Bpp + Y * Pitch; } } } \ No newline at end of file diff --git a/Ryujinx.Graphics/Graphics3d/Texture/TextureFactory.cs b/Ryujinx.Graphics/Graphics3d/Texture/TextureFactory.cs index efad86babd..c9a98e432e 100644 --- a/Ryujinx.Graphics/Graphics3d/Texture/TextureFactory.cs +++ b/Ryujinx.Graphics/Graphics3d/Texture/TextureFactory.cs @@ -16,8 +16,6 @@ namespace Ryujinx.Graphics.Texture TextureType TextureType = (TextureType)((Tic[4] >> 23) & 0xF); - - GalTextureSource XSource = (GalTextureSource)((Tic[0] >> 19) & 7); GalTextureSource YSource = (GalTextureSource)((Tic[0] >> 22) & 7); GalTextureSource ZSource = (GalTextureSource)((Tic[0] >> 25) & 7); diff --git a/Ryujinx.Graphics/Graphics3d/Texture/TextureHelper.cs b/Ryujinx.Graphics/Graphics3d/Texture/TextureHelper.cs index 4dbe82b476..4680b29df7 100644 --- a/Ryujinx.Graphics/Graphics3d/Texture/TextureHelper.cs +++ b/Ryujinx.Graphics/Graphics3d/Texture/TextureHelper.cs @@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Texture int BlockHeight = ImageUtils.GetBlockHeight (Image.Format); int BytesPerPixel = ImageUtils.GetBytesPerPixel(Image.Format); - int Width = (Image.Width + (BlockWidth - 1)) / BlockWidth; + int Width = (Image.Width + (BlockWidth - 1)) / BlockWidth; int Height = (Image.Height + (BlockHeight - 1)) / BlockHeight; if (Image.Layout == GalMemoryLayout.BlockLinear) diff --git a/Ryujinx.Graphics/Texture/TextureType.cs b/Ryujinx.Graphics/Texture/TextureType.cs index 2c095140a7..aeaab692ff 100644 --- a/Ryujinx.Graphics/Texture/TextureType.cs +++ b/Ryujinx.Graphics/Texture/TextureType.cs @@ -2,14 +2,14 @@ { public enum TextureType { - OneD = 0, - TwoD = 1, - ThreeD = 2, - CubeMap = 3, - OneDArray = 4, - TwoDArray = 5, - OneDBuffer = 6, + OneD = 0, + TwoD = 1, + ThreeD = 2, + CubeMap = 3, + OneDArray = 4, + TwoDArray = 5, + OneDBuffer = 6, TwoDNoMipMap = 7, - CubeArray = 8, + CubeArray = 8, } }