From 1080f64df9abd7af7ed762668e4fc9a300ae30f2 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Thu, 4 Aug 2022 18:30:08 -0300 Subject: Implement HLE macros for render target clears (#3528) * Implement HLE macros for render target clears * Add constants for the offsets --- Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs') diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs index e6a64205..0791feef 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs @@ -487,11 +487,23 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// /// Clears the current color and depth-stencil buffers. - /// Which buffers should be cleared is also specified on the argument. + /// Which buffers should be cleared can also be specified with the argument. /// /// 3D engine where this method is being called /// Method call argument public void Clear(ThreedClass engine, int argument) + { + Clear(engine, argument, 1); + } + + /// + /// Clears the current color and depth-stencil buffers. + /// Which buffers should be cleared can also specified with the arguments. + /// + /// 3D engine where this method is being called + /// Method call argument + /// For array and 3D textures, indicates how many layers should be cleared + public void Clear(ThreedClass engine, int argument, int layerCount) { ConditionalRenderEnabled renderEnable = ConditionalRendering.GetRenderEnable( _context, @@ -507,7 +519,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed int index = (argument >> 6) & 0xf; int layer = (argument >> 10) & 0x3ff; - engine.UpdateRenderTargetState(useControl: false, layered: layer != 0, singleUse: index); + engine.UpdateRenderTargetState(useControl: false, layered: layer != 0 || layerCount > 1, singleUse: index); // If there is a mismatch on the host clip region and the one explicitly defined by the guest // on the screen scissor state, then we need to force only one texture to be bound to avoid @@ -578,7 +590,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed bool clearDepth = (argument & 1) != 0; bool clearStencil = (argument & 2) != 0; - uint componentMask = (uint)((argument >> 2) & 0xf); if (componentMask != 0) @@ -587,7 +598,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed ColorF color = new ColorF(clearColor.Red, clearColor.Green, clearColor.Blue, clearColor.Alpha); - _context.Renderer.Pipeline.ClearRenderTargetColor(index, layer, componentMask, color); + _context.Renderer.Pipeline.ClearRenderTargetColor(index, layer, layerCount, componentMask, color); } if (clearDepth || clearStencil) @@ -609,6 +620,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed _context.Renderer.Pipeline.ClearRenderTargetDepthStencil( layer, + layerCount, depthValue, clearDepth, stencilValue, -- cgit v1.2.3