Scale texture resolution before sending to backend (#1646)
* Work * Propagate scale factor to copy temp. Not really needed, just here for consistency * PR feedback
This commit is contained in:
parent
780c7530d6
commit
423da5cc91
@ -181,7 +181,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
Debug.Assert(!isView);
|
Debug.Assert(!isView);
|
||||||
|
|
||||||
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities);
|
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, ScaleFactor);
|
||||||
HostTexture = _context.Renderer.CreateTexture(createInfo, ScaleFactor);
|
HostTexture = _context.Renderer.CreateTexture(createInfo, ScaleFactor);
|
||||||
|
|
||||||
SynchronizeMemory(); // Load the data.
|
SynchronizeMemory(); // Load the data.
|
||||||
@ -204,7 +204,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
ScaleFactor = GraphicsConfig.ResScale;
|
ScaleFactor = GraphicsConfig.ResScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities);
|
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, ScaleFactor);
|
||||||
HostTexture = _context.Renderer.CreateTexture(createInfo, ScaleFactor);
|
HostTexture = _context.Renderer.CreateTexture(createInfo, ScaleFactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,8 +232,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
ScaleFactor,
|
ScaleFactor,
|
||||||
ScaleMode);
|
ScaleMode);
|
||||||
|
|
||||||
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(info, _context.Capabilities);
|
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(info, _context.Capabilities, ScaleFactor);
|
||||||
|
|
||||||
texture.HostTexture = HostTexture.CreateView(createInfo, firstLayer, firstLevel);
|
texture.HostTexture = HostTexture.CreateView(createInfo, firstLayer, firstLevel);
|
||||||
|
|
||||||
_viewStorage.AddView(texture);
|
_viewStorage.AddView(texture);
|
||||||
@ -375,7 +374,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
Info.SwizzleB,
|
Info.SwizzleB,
|
||||||
Info.SwizzleA));
|
Info.SwizzleA));
|
||||||
|
|
||||||
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities);
|
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, ScaleFactor);
|
||||||
|
|
||||||
if (_viewStorage != this)
|
if (_viewStorage != this)
|
||||||
{
|
{
|
||||||
@ -451,7 +450,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
Info.SwizzleB,
|
Info.SwizzleB,
|
||||||
Info.SwizzleA);
|
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++)
|
for (int i = 0; i < Info.DepthOrLayers; i++)
|
||||||
{
|
{
|
||||||
@ -475,8 +474,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
if (storage == null)
|
if (storage == null)
|
||||||
{
|
{
|
||||||
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities);
|
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, scale);
|
||||||
|
|
||||||
storage = _context.Renderer.CreateTexture(createInfo, 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()}.");
|
Logger.Debug?.Print(LogClass.Gpu, $" Recreating view {Info.Width}x{Info.Height} {Info.FormatInfo.Format.ToString()}.");
|
||||||
view.ScaleFactor = scale;
|
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);
|
ITexture newView = HostTexture.CreateView(viewCreateInfo, view._firstLayer - _firstLayer, view._firstLevel - _firstLevel);
|
||||||
|
|
||||||
view.ReplaceStorage(newView);
|
view.ReplaceStorage(newView);
|
||||||
|
|
||||||
view.ScaleMode = newScaleMode;
|
view.ScaleMode = newScaleMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -754,7 +754,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (overlapCompatibility == TextureViewCompatibility.CopyOnly)
|
else if (overlapCompatibility == TextureViewCompatibility.CopyOnly)
|
||||||
{
|
{
|
||||||
// TODO: Copy rules for targets created after the container texture. See below.
|
// 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);
|
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)
|
if (texture.ScaleFactor != overlap.ScaleFactor)
|
||||||
{
|
{
|
||||||
@ -944,7 +944,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
else
|
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.
|
// 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.
|
// 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>
|
/// </summary>
|
||||||
/// <param name="info">Texture information</param>
|
/// <param name="info">Texture information</param>
|
||||||
/// <param name="caps">GPU capabilities</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>
|
/// <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;
|
FormatInfo formatInfo = info.FormatInfo;
|
||||||
|
|
||||||
@ -1092,6 +1093,12 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
int depth = info.GetDepth() * info.GetLayers();
|
int depth = info.GetDepth() * info.GetLayers();
|
||||||
|
|
||||||
|
if (scale != 1f)
|
||||||
|
{
|
||||||
|
width = (int)MathF.Ceiling(width * scale);
|
||||||
|
height = (int)MathF.Ceiling(height * scale);
|
||||||
|
}
|
||||||
|
|
||||||
return new TextureCreateInfo(
|
return new TextureCreateInfo(
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.OpenGL.Image
|
namespace Ryujinx.Graphics.OpenGL.Image
|
||||||
{
|
{
|
||||||
@ -10,8 +9,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
|
|
||||||
public TextureCreateInfo Info { get; }
|
public TextureCreateInfo Info { get; }
|
||||||
|
|
||||||
public int Width { get; }
|
public int Width => Info.Width;
|
||||||
public int Height { get; }
|
public int Height => Info.Height;
|
||||||
public float ScaleFactor { get; }
|
public float ScaleFactor { get; }
|
||||||
|
|
||||||
public Target Target => Info.Target;
|
public Target Target => Info.Target;
|
||||||
@ -20,8 +19,6 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
public TextureBase(TextureCreateInfo info, float scaleFactor = 1f)
|
public TextureBase(TextureCreateInfo info, float scaleFactor = 1f)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
Width = (int)Math.Ceiling(Info.Width * scaleFactor);
|
|
||||||
Height = (int)Math.Ceiling(Info.Height * scaleFactor);
|
|
||||||
ScaleFactor = scaleFactor;
|
ScaleFactor = scaleFactor;
|
||||||
|
|
||||||
Handle = GL.GenTexture();
|
Handle = GL.GenTexture();
|
||||||
|
@ -129,7 +129,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
|
|
||||||
public TextureView BgraSwap(TextureView from)
|
public TextureView BgraSwap(TextureView from)
|
||||||
{
|
{
|
||||||
TextureView to = (TextureView)_renderer.CreateTexture(from.Info, 1f);
|
TextureView to = (TextureView)_renderer.CreateTexture(from.Info, from.ScaleFactor);
|
||||||
|
|
||||||
EnsurePbo(from);
|
EnsurePbo(from);
|
||||||
|
|
||||||
|
@ -15,16 +15,15 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
int srcLayer,
|
int srcLayer,
|
||||||
int dstLayer,
|
int dstLayer,
|
||||||
int srcLevel,
|
int srcLevel,
|
||||||
int dstLevel,
|
int dstLevel)
|
||||||
float scaleFactor = 1f)
|
|
||||||
{
|
{
|
||||||
int srcWidth = (int)Math.Ceiling(srcInfo.Width * scaleFactor);
|
int srcWidth = srcInfo.Width;
|
||||||
int srcHeight = (int)Math.Ceiling(srcInfo.Height * scaleFactor);
|
int srcHeight = srcInfo.Height;
|
||||||
int srcDepth = srcInfo.GetDepthOrLayers();
|
int srcDepth = srcInfo.GetDepthOrLayers();
|
||||||
int srcLevels = srcInfo.Levels;
|
int srcLevels = srcInfo.Levels;
|
||||||
|
|
||||||
int dstWidth = (int)Math.Ceiling(dstInfo.Width * scaleFactor);
|
int dstWidth = dstInfo.Width;
|
||||||
int dstHeight = (int)Math.Ceiling(dstInfo.Height * scaleFactor);
|
int dstHeight = dstInfo.Height;
|
||||||
int dstDepth = dstInfo.GetDepthOrLayers();
|
int dstDepth = dstInfo.GetDepthOrLayers();
|
||||||
int dstLevels = dstInfo.Levels;
|
int dstLevels = dstInfo.Levels;
|
||||||
|
|
||||||
|
@ -37,9 +37,6 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
|
|
||||||
GL.BindTexture(target, Handle);
|
GL.BindTexture(target, Handle);
|
||||||
|
|
||||||
int width = (int)Math.Ceiling(Info.Width * ScaleFactor);
|
|
||||||
int height = (int)Math.Ceiling(Info.Height * ScaleFactor);
|
|
||||||
|
|
||||||
FormatInfo format = FormatTable.GetFormatInfo(Info.Format);
|
FormatInfo format = FormatTable.GetFormatInfo(Info.Format);
|
||||||
|
|
||||||
SizedInternalFormat internalFormat;
|
SizedInternalFormat internalFormat;
|
||||||
@ -60,7 +57,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
TextureTarget1d.Texture1D,
|
TextureTarget1d.Texture1D,
|
||||||
Info.Levels,
|
Info.Levels,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
width);
|
Info.Width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Target.Texture1DArray:
|
case Target.Texture1DArray:
|
||||||
@ -68,8 +65,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
TextureTarget2d.Texture1DArray,
|
TextureTarget2d.Texture1DArray,
|
||||||
Info.Levels,
|
Info.Levels,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
width,
|
Info.Width,
|
||||||
height);
|
Info.Height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Target.Texture2D:
|
case Target.Texture2D:
|
||||||
@ -77,8 +74,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
TextureTarget2d.Texture2D,
|
TextureTarget2d.Texture2D,
|
||||||
Info.Levels,
|
Info.Levels,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
width,
|
Info.Width,
|
||||||
height);
|
Info.Height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Target.Texture2DArray:
|
case Target.Texture2DArray:
|
||||||
@ -86,8 +83,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
TextureTarget3d.Texture2DArray,
|
TextureTarget3d.Texture2DArray,
|
||||||
Info.Levels,
|
Info.Levels,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
width,
|
Info.Width,
|
||||||
height,
|
Info.Height,
|
||||||
Info.Depth);
|
Info.Depth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -96,8 +93,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
TextureTargetMultisample2d.Texture2DMultisample,
|
TextureTargetMultisample2d.Texture2DMultisample,
|
||||||
Info.Samples,
|
Info.Samples,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
width,
|
Info.Width,
|
||||||
height,
|
Info.Height,
|
||||||
true);
|
true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -106,8 +103,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
TextureTargetMultisample3d.Texture2DMultisampleArray,
|
TextureTargetMultisample3d.Texture2DMultisampleArray,
|
||||||
Info.Samples,
|
Info.Samples,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
width,
|
Info.Width,
|
||||||
height,
|
Info.Height,
|
||||||
Info.Depth,
|
Info.Depth,
|
||||||
true);
|
true);
|
||||||
break;
|
break;
|
||||||
@ -117,8 +114,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
TextureTarget3d.Texture3D,
|
TextureTarget3d.Texture3D,
|
||||||
Info.Levels,
|
Info.Levels,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
width,
|
Info.Width,
|
||||||
height,
|
Info.Height,
|
||||||
Info.Depth);
|
Info.Depth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -127,8 +124,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
TextureTarget2d.TextureCubeMap,
|
TextureTarget2d.TextureCubeMap,
|
||||||
Info.Levels,
|
Info.Levels,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
width,
|
Info.Width,
|
||||||
height);
|
Info.Height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Target.CubemapArray:
|
case Target.CubemapArray:
|
||||||
@ -136,8 +133,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
(TextureTarget3d)All.TextureCubeMapArray,
|
(TextureTarget3d)All.TextureCubeMapArray,
|
||||||
Info.Levels,
|
Info.Levels,
|
||||||
internalFormat,
|
internalFormat,
|
||||||
width,
|
Info.Width,
|
||||||
height,
|
Info.Height,
|
||||||
Info.Depth);
|
Info.Depth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
_incompatibleFormatView = (TextureView)_renderer.CreateTexture(Info, ScaleFactor);
|
_incompatibleFormatView = (TextureView)_renderer.CreateTexture(Info, ScaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCopyUnscaled.Copy(_parent.Info, _incompatibleFormatView.Info, _parent.Handle, _incompatibleFormatView.Handle, FirstLayer, 0, FirstLevel, 0, ScaleFactor);
|
TextureCopyUnscaled.Copy(_parent.Info, _incompatibleFormatView.Info, _parent.Handle, _incompatibleFormatView.Handle, FirstLayer, 0, FirstLevel, 0);
|
||||||
|
|
||||||
return _incompatibleFormatView.Handle;
|
return _incompatibleFormatView.Handle;
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
{
|
{
|
||||||
if (_incompatibleFormatView != null)
|
if (_incompatibleFormatView != null)
|
||||||
{
|
{
|
||||||
TextureCopyUnscaled.Copy(_incompatibleFormatView.Info, _parent.Info, _incompatibleFormatView.Handle, _parent.Handle, 0, FirstLayer, 0, FirstLevel, ScaleFactor);
|
TextureCopyUnscaled.Copy(_incompatibleFormatView.Info, _parent.Info, _incompatibleFormatView.Handle, _parent.Handle, 0, FirstLayer, 0, FirstLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
{
|
{
|
||||||
TextureView destinationView = (TextureView)destination;
|
TextureView destinationView = (TextureView)destination;
|
||||||
|
|
||||||
TextureCopyUnscaled.Copy(Info, destinationView.Info, Handle, destinationView.Handle, 0, firstLayer, 0, firstLevel, ScaleFactor);
|
TextureCopyUnscaled.Copy(Info, destinationView.Info, Handle, destinationView.Handle, 0, firstLayer, 0, firstLevel);
|
||||||
|
|
||||||
if (destinationView._emulatedViewParent != null)
|
if (destinationView._emulatedViewParent != null)
|
||||||
{
|
{
|
||||||
@ -166,8 +166,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
0,
|
0,
|
||||||
destinationView.FirstLayer,
|
destinationView.FirstLayer,
|
||||||
0,
|
0,
|
||||||
destinationView.FirstLevel,
|
destinationView.FirstLevel);
|
||||||
ScaleFactor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user