From 9493cdfe553d77d8f37927ef2acf87cfbab1c467 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Fri, 20 Nov 2020 20:14:45 +0000 Subject: Allow copy destination to have a different scale from source (#1711) * Allow copy destination to have a different scale from source Will result in more scaled copy destinations, but allows scaling in some games that copy textures to the output framebuffer. * Support copying multiple levels/layers Uses glFramebufferTextureLayer to copy multiple layers, copies levels individually (and scales the regions). Remove CopyArrayScaled, since the backend copy handles it now. --- Ryujinx.Graphics.Gpu/Image/Texture.cs | 51 +--------------------------- Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 9 ++++- 2 files changed, 9 insertions(+), 51 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Image') diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs index 21418a4b..7fb41572 100644 --- a/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -430,48 +430,6 @@ namespace Ryujinx.Graphics.Gpu.Image } } - /// - /// Helper method for copying our Texture2DArray texture to the given target, with scaling. - /// This creates temporary views for each array layer on both textures, copying each one at a time. - /// - /// The texture array to copy to - private void CopyArrayScaled(ITexture target) - { - TextureInfo viewInfo = new TextureInfo( - Info.Address, - Info.Width, - Info.Height, - 1, - Info.Levels, - Info.SamplesInX, - Info.SamplesInY, - Info.Stride, - Info.IsLinear, - Info.GobBlocksInY, - Info.GobBlocksInZ, - Info.GobBlocksInTileX, - Target.Texture2D, - Info.FormatInfo, - Info.DepthStencilMode, - Info.SwizzleR, - Info.SwizzleG, - Info.SwizzleB, - Info.SwizzleA); - - TextureCreateInfo createInfo = TextureManager.GetCreateInfo(viewInfo, _context.Capabilities, ScaleFactor); - - for (int i = 0; i < Info.DepthOrLayers; i++) - { - ITexture from = HostTexture.CreateView(createInfo, i, 0); - ITexture to = target.CreateView(createInfo, i, 0); - - from.CopyTo(to, new Extents2D(0, 0, from.Width, from.Height), new Extents2D(0, 0, to.Width, to.Height), true); - - from.Release(); - to.Release(); - } - } - /// /// Copy the host texture to a scaled one. If a texture is not provided, create it with the given scale. /// @@ -486,14 +444,7 @@ namespace Ryujinx.Graphics.Gpu.Image storage = _context.Renderer.CreateTexture(createInfo, scale); } - if (Info.Target == Target.Texture2DArray) - { - CopyArrayScaled(storage); - } - else - { - HostTexture.CopyTo(storage, new Extents2D(0, 0, HostTexture.Width, HostTexture.Height), new Extents2D(0, 0, storage.Width, storage.Height), true); - } + HostTexture.CopyTo(storage, new Extents2D(0, 0, HostTexture.Width, HostTexture.Height), new Extents2D(0, 0, storage.Width, storage.Height), true); return storage; } diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index f1d31f4f..8e64ca61 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -387,7 +387,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// True if eligible public bool IsUpscaleCompatible(TextureInfo info) { - return (info.Target == Target.Texture2D || info.Target == Target.Texture2DArray) && info.Levels == 1 && !info.FormatInfo.IsCompressed && UpscaleSafeMode(info); + return (info.Target == Target.Texture2D || info.Target == Target.Texture2DArray) && !info.FormatInfo.IsCompressed && UpscaleSafeMode(info); } /// @@ -401,6 +401,13 @@ namespace Ryujinx.Graphics.Gpu.Image // While upscaling works for all targets defined by IsUpscaleCompatible, we additionally blacklist targets here that // may have undesirable results (upscaling blur textures) or simply waste GPU resources (upscaling texture atlas). + if (info.Levels > 3) + { + // Textures with more than 3 levels are likely to be game textures, rather than render textures. + // Small textures with full mips are likely to be removed by the next check. + return false; + } + if (!(info.FormatInfo.Format.IsDepthOrStencil() || info.FormatInfo.Components == 1)) { // Discount square textures that aren't depth-stencil like. (excludes game textures, cubemap faces, most 3D texture LUT, texture atlas) -- cgit v1.2.3