From 9bfb373bdf85178ef319fa4d107ae20d0a2d4a04 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 31 Dec 2019 19:22:45 -0300 Subject: [PATCH] Remove more unused code --- Ryujinx.Graphics.GAL/ITexture.cs | 4 -- Ryujinx.Graphics.Gpu/Engine/Methods.cs | 47 ++----------------- Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs | 2 - Ryujinx.Graphics.OpenGL/TextureView.cs | 36 -------------- Ryujinx.Graphics.Shader/QueryInfoName.cs | 3 +- .../Translation/EmitterContext.cs | 13 +---- .../Translation/ShaderConfig.cs | 2 - 7 files changed, 7 insertions(+), 100 deletions(-) diff --git a/Ryujinx.Graphics.GAL/ITexture.cs b/Ryujinx.Graphics.GAL/ITexture.cs index 7664f89c58..f5bc1b4705 100644 --- a/Ryujinx.Graphics.GAL/ITexture.cs +++ b/Ryujinx.Graphics.GAL/ITexture.cs @@ -4,15 +4,11 @@ namespace Ryujinx.Graphics.GAL { public interface ITexture : IDisposable { - int Handle { get; } - void CopyTo(ITexture destination, int firstLayer, int firstLevel); void CopyTo(ITexture destination, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter); ITexture CreateView(TextureCreateInfo info, int firstLayer, int firstLevel); - int GetStorageDebugId(); - byte[] GetData(); void SetData(Span data); diff --git a/Ryujinx.Graphics.Gpu/Engine/Methods.cs b/Ryujinx.Graphics.Gpu/Engine/Methods.cs index 12a9744cb2..6dce61f2b3 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -336,8 +336,6 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetDepthMode(depthMode); - bool transformEnable = GetViewportTransformEnable(state); - bool flipY = (state.Get(MethodOffset.YControl) & 1) != 0; float yFlip = flipY ? -1 : 1; @@ -349,35 +347,13 @@ namespace Ryujinx.Graphics.Gpu.Engine var transform = state.Get(MethodOffset.ViewportTransform, index); var extents = state.Get (MethodOffset.ViewportExtents, index); - RectangleF region; + float x = transform.TranslateX - MathF.Abs(transform.ScaleX); + float y = transform.TranslateY - MathF.Abs(transform.ScaleY); - if (transformEnable) - { - float x = transform.TranslateX - MathF.Abs(transform.ScaleX); - float y = transform.TranslateY - MathF.Abs(transform.ScaleY); + float width = transform.ScaleX * 2; + float height = transform.ScaleY * 2 * yFlip; - float width = transform.ScaleX * 2; - float height = transform.ScaleY * 2 * yFlip; - - region = new RectangleF(x, y, width, height); - } - else - { - // It's not possible to fully disable viewport transform, at least with the most - // common graphics APIs, but we can effectively disable it with a dummy transform. - // The transform is defined as: xw = (width / 2) * xndc + x + (width / 2) - // By setting x to -(width / 2), we effectively remove the translation. - // By setting the width to 2, we remove the scale since 2 / 2 = 1. - // Now, the only problem is the viewport clipping, that we also can't disable. - // To prevent the values from being clipped, we multiply (-1, -1, 2, 2) by - // the maximum supported viewport dimensions. - // This must be compensated on the shader, by dividing the vertex position - // by the maximum viewport dimensions. - float maxSize = _context.Capabilities.MaximumViewportDimensions; - float halfMaxSize = _context.Capabilities.MaximumViewportDimensions * 0.5f; - - region = new RectangleF(-halfMaxSize, -halfMaxSize, maxSize, maxSize * yFlip); - } + RectangleF region = new RectangleF(x, y, width, height); viewports[index] = new Viewport( region, @@ -827,19 +803,6 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetProgram(gs.HostProgram); } - /// - /// Gets viewport transform enable. - /// - /// Current GPU state - /// Viewport transform enable - public bool GetViewportTransformEnable(GpuState state) - { - // FIXME: We should read ViewportTransformEnable, but it seems that some games writes 0 there? - // return state.Get(MethodOffset.ViewportTransformEnable) != 0; - - return true; - } - /// /// Gets texture target from a sampler type. /// diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index ad2a603700..02837cbb14 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -308,8 +308,6 @@ namespace Ryujinx.Graphics.Gpu.Shader return Convert.ToInt32(QueryIsTextureRectangle(state, (int)stage - 1, index)); case QueryInfoName.PrimitiveTopology: return (int)GetPrimitiveTopology(); - case QueryInfoName.ViewportTransformEnable: - return Convert.ToInt32(_context.Methods.GetViewportTransformEnable(state)); } return QueryInfoCommon(info); diff --git a/Ryujinx.Graphics.OpenGL/TextureView.cs b/Ryujinx.Graphics.OpenGL/TextureView.cs index f533404b03..563e0ca61e 100644 --- a/Ryujinx.Graphics.OpenGL/TextureView.cs +++ b/Ryujinx.Graphics.OpenGL/TextureView.cs @@ -130,24 +130,12 @@ namespace Ryujinx.Graphics.OpenGL } } - public int GetStorageDebugId() - { - return _parent.GetHashCode(); - } - public void CopyTo(ITexture destination, int firstLayer, int firstLevel) { TextureView destinationView = (TextureView)destination; TextureCopyUnscaled.Copy(this, destinationView, firstLayer, firstLevel); - int width = Math.Min(Width, destinationView.Width); - int height = Math.Min(Height, destinationView.Height); - - int depth = Math.Min(_info.GetDepthOrLayers(), destinationView._info.GetDepthOrLayers()); - - int levels = Math.Min(_info.Levels, destinationView._info.Levels); - if (destinationView._emulatedViewParent != null) { TextureCopyUnscaled.Copy( @@ -415,32 +403,8 @@ namespace Ryujinx.Graphics.OpenGL GL.BindTexture(target, Handle); } - public void Acquire() - { - _acquired = true; - } - - public void Release() - { - _acquired = false; - - if (_pendingDelete) - { - _pendingDelete = false; - - Dispose(); - } - } - public void Dispose() { - if (_acquired) - { - _pendingDelete = true; - - return; - } - if (Handle != 0) { GL.DeleteTexture(Handle); diff --git a/Ryujinx.Graphics.Shader/QueryInfoName.cs b/Ryujinx.Graphics.Shader/QueryInfoName.cs index e976dcdbdb..1d87c2c881 100644 --- a/Ryujinx.Graphics.Shader/QueryInfoName.cs +++ b/Ryujinx.Graphics.Shader/QueryInfoName.cs @@ -11,7 +11,6 @@ namespace Ryujinx.Graphics.Shader MaximumViewportDimensions, PrimitiveTopology, StorageBufferOffsetAlignment, - SupportsNonConstantTextureOffset, - ViewportTransformEnable + SupportsNonConstantTextureOffset } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs b/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs index 9620145aff..e6334feaf6 100644 --- a/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs +++ b/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs @@ -59,18 +59,7 @@ namespace Ryujinx.Graphics.Shader.Translation public void PrepareForReturn() { - if (_config.Stage == ShaderStage.Vertex) - { - if (!_config.QueryInfoBool(QueryInfoName.ViewportTransformEnable)) - { - Operand posX = Attribute(AttributeConsts.PositionX); - Operand posY = Attribute(AttributeConsts.PositionY); - - this.Copy(posX, this.FPDivide(posX, ConstF(_config.QueryInfo(QueryInfoName.MaximumViewportDimensions) / 2))); - this.Copy(posY, this.FPDivide(posY, ConstF(_config.QueryInfo(QueryInfoName.MaximumViewportDimensions) / 2))); - } - } - else if (_config.Stage == ShaderStage.Fragment) + if (_config.Stage == ShaderStage.Fragment) { if (_config.OmapDepth) { diff --git a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs index 78dcde490c..d73a268e96 100644 --- a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs +++ b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs @@ -94,8 +94,6 @@ namespace Ryujinx.Graphics.Shader.Translation return 16; case QueryInfoName.SupportsNonConstantTextureOffset: return Convert.ToInt32(true); - case QueryInfoName.ViewportTransformEnable: - return Convert.ToInt32(true); } }