From 6e0799580f0d1b473a79471c5d365c6524d97a86 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 11 Jan 2022 16:15:17 -0300 Subject: Fix render target clear when sizes mismatch (#2994) --- Ryujinx.Graphics.Gpu/Image/Texture.cs | 14 ++++++++- Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 43 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) (limited to 'Ryujinx.Graphics.Gpu/Image') diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs index eacfa4f5..b2fa15a2 100644 --- a/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -47,6 +47,16 @@ namespace Ryujinx.Graphics.Gpu.Image /// public Target Target { get; private set; } + /// + /// Texture width. + /// + public int Width { get; private set; } + + /// + /// Texture height. + /// + public int Height { get; private set; } + /// /// Texture information. /// @@ -926,7 +936,7 @@ namespace Ryujinx.Graphics.Gpu.Image FlushTextureDataToGuest(tracked); } } - + /// /// Gets a host texture to use for flushing the texture, at 1x resolution. /// If the HostTexture is already at 1x resolution, it is returned directly. @@ -1322,6 +1332,8 @@ namespace Ryujinx.Graphics.Gpu.Image { Info = info; Target = info.Target; + Width = info.Width; + Height = info.Height; CanForceAnisotropy = CanTextureForceAnisotropy(); _depth = info.GetDepth(); diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index 70cb57d0..90e26442 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -19,6 +19,9 @@ namespace Ryujinx.Graphics.Gpu.Image private Texture _rtDepthStencil; private ITexture _rtHostDs; + public int ClipRegionWidth { get; private set; } + public int ClipRegionHeight { get; private set; } + /// /// The scaling factor applied to all currently bound render targets. /// @@ -210,6 +213,17 @@ namespace Ryujinx.Graphics.Gpu.Image return changesScale || ScaleNeedsUpdated(depthStencil); } + /// + /// Sets the host clip region, which should be the intersection of all render target texture sizes. + /// + /// Width of the clip region, defined as the minimum width across all bound textures + /// Height of the clip region, defined as the minimum height across all bound textures + public void SetClipRegion(int width, int height) + { + ClipRegionWidth = width; + ClipRegionHeight = height; + } + /// /// Gets the first available bound colour target, or the depth stencil target if not present. /// @@ -409,6 +423,35 @@ namespace Ryujinx.Graphics.Gpu.Image } } + /// + /// Update host framebuffer attachments based on currently bound render target buffers. + /// + /// + /// All attachments other than will be unbound. + /// + /// Index of the render target color to be updated + public void UpdateRenderTarget(int index) + { + new Span(_rtHostColors).Fill(null); + _rtHostColors[index] = _rtColors[index]?.HostTexture; + + _context.Renderer.Pipeline.SetRenderTargets(_rtHostColors, null); + } + + /// + /// Update host framebuffer attachments based on currently bound render target buffers. + /// + /// + /// All color attachments will be unbound. + /// + public void UpdateRenderTargetDepthStencil() + { + new Span(_rtHostColors).Fill(null); + _rtHostDs = _rtDepthStencil?.HostTexture; + + _context.Renderer.Pipeline.SetRenderTargets(_rtHostColors, _rtHostDs); + } + /// /// Forces all textures, samplers, images and render targets to be rebound the next time /// CommitGraphicsBindings is called. -- cgit v1.2.3