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
7 changed files with 47 additions and 52 deletions
|
@ -1,6 +1,5 @@
|
|||
using OpenTK.Graphics.OpenGL;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.OpenGL.Image
|
||||
{
|
||||
|
@ -10,8 +9,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
|
||||
public TextureCreateInfo Info { get; }
|
||||
|
||||
public int Width { get; }
|
||||
public int Height { get; }
|
||||
public int Width => Info.Width;
|
||||
public int Height => Info.Height;
|
||||
public float ScaleFactor { get; }
|
||||
|
||||
public Target Target => Info.Target;
|
||||
|
@ -20,8 +19,6 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
public TextureBase(TextureCreateInfo info, float scaleFactor = 1f)
|
||||
{
|
||||
Info = info;
|
||||
Width = (int)Math.Ceiling(Info.Width * scaleFactor);
|
||||
Height = (int)Math.Ceiling(Info.Height * scaleFactor);
|
||||
ScaleFactor = scaleFactor;
|
||||
|
||||
Handle = GL.GenTexture();
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
|
||||
public TextureView BgraSwap(TextureView from)
|
||||
{
|
||||
TextureView to = (TextureView)_renderer.CreateTexture(from.Info, 1f);
|
||||
TextureView to = (TextureView)_renderer.CreateTexture(from.Info, from.ScaleFactor);
|
||||
|
||||
EnsurePbo(from);
|
||||
|
||||
|
|
|
@ -15,16 +15,15 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
int srcLayer,
|
||||
int dstLayer,
|
||||
int srcLevel,
|
||||
int dstLevel,
|
||||
float scaleFactor = 1f)
|
||||
int dstLevel)
|
||||
{
|
||||
int srcWidth = (int)Math.Ceiling(srcInfo.Width * scaleFactor);
|
||||
int srcHeight = (int)Math.Ceiling(srcInfo.Height * scaleFactor);
|
||||
int srcWidth = srcInfo.Width;
|
||||
int srcHeight = srcInfo.Height;
|
||||
int srcDepth = srcInfo.GetDepthOrLayers();
|
||||
int srcLevels = srcInfo.Levels;
|
||||
|
||||
int dstWidth = (int)Math.Ceiling(dstInfo.Width * scaleFactor);
|
||||
int dstHeight = (int)Math.Ceiling(dstInfo.Height * scaleFactor);
|
||||
int dstWidth = dstInfo.Width;
|
||||
int dstHeight = dstInfo.Height;
|
||||
int dstDepth = dstInfo.GetDepthOrLayers();
|
||||
int dstLevels = dstInfo.Levels;
|
||||
|
||||
|
|
|
@ -37,9 +37,6 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
|
||||
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);
|
||||
|
||||
SizedInternalFormat internalFormat;
|
||||
|
@ -60,7 +57,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
TextureTarget1d.Texture1D,
|
||||
Info.Levels,
|
||||
internalFormat,
|
||||
width);
|
||||
Info.Width);
|
||||
break;
|
||||
|
||||
case Target.Texture1DArray:
|
||||
|
@ -68,8 +65,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
TextureTarget2d.Texture1DArray,
|
||||
Info.Levels,
|
||||
internalFormat,
|
||||
width,
|
||||
height);
|
||||
Info.Width,
|
||||
Info.Height);
|
||||
break;
|
||||
|
||||
case Target.Texture2D:
|
||||
|
@ -77,8 +74,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
TextureTarget2d.Texture2D,
|
||||
Info.Levels,
|
||||
internalFormat,
|
||||
width,
|
||||
height);
|
||||
Info.Width,
|
||||
Info.Height);
|
||||
break;
|
||||
|
||||
case Target.Texture2DArray:
|
||||
|
@ -86,8 +83,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
TextureTarget3d.Texture2DArray,
|
||||
Info.Levels,
|
||||
internalFormat,
|
||||
width,
|
||||
height,
|
||||
Info.Width,
|
||||
Info.Height,
|
||||
Info.Depth);
|
||||
break;
|
||||
|
||||
|
@ -96,8 +93,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
TextureTargetMultisample2d.Texture2DMultisample,
|
||||
Info.Samples,
|
||||
internalFormat,
|
||||
width,
|
||||
height,
|
||||
Info.Width,
|
||||
Info.Height,
|
||||
true);
|
||||
break;
|
||||
|
||||
|
@ -106,8 +103,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
TextureTargetMultisample3d.Texture2DMultisampleArray,
|
||||
Info.Samples,
|
||||
internalFormat,
|
||||
width,
|
||||
height,
|
||||
Info.Width,
|
||||
Info.Height,
|
||||
Info.Depth,
|
||||
true);
|
||||
break;
|
||||
|
@ -117,8 +114,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
TextureTarget3d.Texture3D,
|
||||
Info.Levels,
|
||||
internalFormat,
|
||||
width,
|
||||
height,
|
||||
Info.Width,
|
||||
Info.Height,
|
||||
Info.Depth);
|
||||
break;
|
||||
|
||||
|
@ -127,8 +124,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
TextureTarget2d.TextureCubeMap,
|
||||
Info.Levels,
|
||||
internalFormat,
|
||||
width,
|
||||
height);
|
||||
Info.Width,
|
||||
Info.Height);
|
||||
break;
|
||||
|
||||
case Target.CubemapArray:
|
||||
|
@ -136,8 +133,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
(TextureTarget3d)All.TextureCubeMapArray,
|
||||
Info.Levels,
|
||||
internalFormat,
|
||||
width,
|
||||
height,
|
||||
Info.Width,
|
||||
Info.Height,
|
||||
Info.Depth);
|
||||
break;
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
_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;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -166,8 +166,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
0,
|
||||
destinationView.FirstLayer,
|
||||
0,
|
||||
destinationView.FirstLevel,
|
||||
ScaleFactor);
|
||||
destinationView.FirstLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue