aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Image
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-10-29 18:57:34 -0300
committerGitHub <noreply@github.com>2020-10-29 22:57:34 +0100
commit423da5cc911bf7545746ad4fd184eff42f32dd9b (patch)
treec554fe100de8be953a8a492d4386e23e6a91b7e8 /Ryujinx.Graphics.Gpu/Image
parent780c7530d69068dd651c33e18828e23dc6977d90 (diff)
Scale texture resolution before sending to backend (#1646)
* Work * Propagate scale factor to copy temp. Not really needed, just here for consistency * PR feedback
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image')
-rw-r--r--Ryujinx.Graphics.Gpu/Image/Texture.cs18
-rw-r--r--Ryujinx.Graphics.Gpu/Image/TextureManager.cs15
2 files changed, 18 insertions, 15 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs
index 2b1aaa0a..01610629 100644
--- a/Ryujinx.Graphics.Gpu/Image/Texture.cs
+++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs
@@ -181,7 +181,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
Debug.Assert(!isView);
- TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities);
+ TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, ScaleFactor);
HostTexture = _context.Renderer.CreateTexture(createInfo, ScaleFactor);
SynchronizeMemory(); // Load the data.
@@ -204,7 +204,7 @@ namespace Ryujinx.Graphics.Gpu.Image
ScaleFactor = GraphicsConfig.ResScale;
}
- TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities);
+ TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, ScaleFactor);
HostTexture = _context.Renderer.CreateTexture(createInfo, ScaleFactor);
}
}
@@ -232,8 +232,7 @@ namespace Ryujinx.Graphics.Gpu.Image
ScaleFactor,
ScaleMode);
- TextureCreateInfo createInfo = TextureManager.GetCreateInfo(info, _context.Capabilities);
-
+ TextureCreateInfo createInfo = TextureManager.GetCreateInfo(info, _context.Capabilities, ScaleFactor);
texture.HostTexture = HostTexture.CreateView(createInfo, firstLayer, firstLevel);
_viewStorage.AddView(texture);
@@ -375,7 +374,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Info.SwizzleB,
Info.SwizzleA));
- TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities);
+ TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, ScaleFactor);
if (_viewStorage != this)
{
@@ -451,7 +450,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Info.SwizzleB,
Info.SwizzleA);
- TextureCreateInfo createInfo = TextureManager.GetCreateInfo(viewInfo, _context.Capabilities);
+ TextureCreateInfo createInfo = TextureManager.GetCreateInfo(viewInfo, _context.Capabilities, ScaleFactor);
for (int i = 0; i < Info.DepthOrLayers; i++)
{
@@ -475,8 +474,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
if (storage == null)
{
- TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities);
-
+ TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, scale);
storage = _context.Renderer.CreateTexture(createInfo, scale);
}
@@ -530,12 +528,10 @@ namespace Ryujinx.Graphics.Gpu.Image
Logger.Debug?.Print(LogClass.Gpu, $" Recreating view {Info.Width}x{Info.Height} {Info.FormatInfo.Format.ToString()}.");
view.ScaleFactor = scale;
- TextureCreateInfo viewCreateInfo = TextureManager.GetCreateInfo(view.Info, _context.Capabilities);
-
+ TextureCreateInfo viewCreateInfo = TextureManager.GetCreateInfo(view.Info, _context.Capabilities, scale);
ITexture newView = HostTexture.CreateView(viewCreateInfo, view._firstLayer - _firstLayer, view._firstLevel - _firstLevel);
view.ReplaceStorage(newView);
-
view.ScaleMode = newScaleMode;
}
}
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
index 27292f56..b0e715ea 100644
--- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
+++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
@@ -754,7 +754,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
break;
- }
+ }
else if (overlapCompatibility == TextureViewCompatibility.CopyOnly)
{
// TODO: Copy rules for targets created after the container texture. See below.
@@ -833,7 +833,7 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureInfo overlapInfo = AdjustSizes(texture, overlap.Info, oInfo.FirstLevel);
- TextureCreateInfo createInfo = GetCreateInfo(overlapInfo, _context.Capabilities);
+ TextureCreateInfo createInfo = GetCreateInfo(overlapInfo, _context.Capabilities, overlap.ScaleFactor);
if (texture.ScaleFactor != overlap.ScaleFactor)
{
@@ -944,7 +944,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
else
{
- // Bpp may be a mismatch between the target texture and the param.
+ // Bpp may be a mismatch between the target texture and the param.
// Due to the way linear strided and block layouts work, widths can be multiplied by Bpp for comparison.
// Note: tex.Width is the aligned texture size. Prefer param.XCount, as the destination should be a texture with that exact size.
@@ -1054,8 +1054,9 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
/// <param name="info">Texture information</param>
/// <param name="caps">GPU capabilities</param>
+ /// <param name="scale">Texture scale factor, to be applied to the texture size</param>
/// <returns>The texture creation information</returns>
- public static TextureCreateInfo GetCreateInfo(TextureInfo info, Capabilities caps)
+ public static TextureCreateInfo GetCreateInfo(TextureInfo info, Capabilities caps, float scale)
{
FormatInfo formatInfo = info.FormatInfo;
@@ -1092,6 +1093,12 @@ namespace Ryujinx.Graphics.Gpu.Image
int depth = info.GetDepth() * info.GetLayers();
+ if (scale != 1f)
+ {
+ width = (int)MathF.Ceiling(width * scale);
+ height = (int)MathF.Ceiling(height * scale);
+ }
+
return new TextureCreateInfo(
width,
height,