From 43b4b34376cdea486906f8bb4058dda3be7e1bd8 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Thu, 12 May 2022 14:47:13 +0100 Subject: Implement Viewport Transform Disable (#3328) * Initial implementation (no specialization) * Use specialization * Fix render scale, increase code gen version * Revert accidental change * Address Feedback --- Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Engine') diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index 3bc15a31..d0c3bc5a 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -113,7 +113,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed nameof(ThreedClassState.DepthMode), nameof(ThreedClassState.ViewportTransform), nameof(ThreedClassState.ViewportExtents), - nameof(ThreedClassState.YControl)), + nameof(ThreedClassState.YControl), + nameof(ThreedClassState.ViewportTransformEnable)), new StateUpdateCallbackEntry(UpdatePolygonMode, nameof(ThreedClassState.PolygonModeFront), @@ -200,7 +201,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed // of the shader for the new state. if (_shaderSpecState != null) { - if (!_shaderSpecState.MatchesGraphics(_channel, GetPoolState())) + if (!_shaderSpecState.MatchesGraphics(_channel, GetPoolState(), GetGraphicsState())) { ForceShaderUpdate(); } @@ -568,6 +569,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed var yControl = _state.State.YControl; var face = _state.State.FaceState; + bool disableTransform = _state.State.ViewportTransformEnable == 0; + UpdateFrontFace(yControl, face.FrontFace); UpdateDepthMode(); @@ -577,6 +580,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed for (int index = 0; index < Constants.TotalViewports; index++) { + if (disableTransform) + { + ref var scissor = ref _state.State.ScreenScissorState; + + float rScale = _channel.TextureManager.RenderTargetScale; + var scissorRect = new RectangleF(0, 0, (scissor.X + scissor.Width) * rScale, (scissor.Y + scissor.Height) * rScale); + + viewports[index] = new Viewport(scissorRect, ViewportSwizzle.PositiveX, ViewportSwizzle.PositiveY, ViewportSwizzle.PositiveZ, ViewportSwizzle.PositiveW, 0, 1); + continue; + } + ref var transform = ref _state.State.ViewportTransform[index]; ref var extents = ref _state.State.ViewportExtents[index]; @@ -628,7 +642,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed viewports[index] = new Viewport(region, swizzleX, swizzleY, swizzleZ, swizzleW, depthNear, depthFar); } - _context.Renderer.Pipeline.SetViewports(0, viewports); + _context.Renderer.Pipeline.SetViewports(0, viewports, disableTransform); } /// @@ -1194,7 +1208,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed return new GpuChannelGraphicsState( _state.State.EarlyZForce, _drawState.Topology, - _state.State.TessMode); + _state.State.TessMode, + _state.State.ViewportTransformEnable == 0); } /// -- cgit v1.2.3