aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.OpenGL/Image/TextureView.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2022-09-19 16:12:56 -0300
committerGitHub <noreply@github.com>2022-09-19 16:12:56 -0300
commitda75a9a6ea89787c551b20e068a2bed8a8dc4f92 (patch)
tree812f5d63819c0b4ab2e27d1256c0d7c37ac53813 /Ryujinx.Graphics.OpenGL/Image/TextureView.cs
parent41790aa7434a5e6d132fad2e24844d450378205b (diff)
OpenGL: Fix blit from non-multisample to multisample texture (#3596)1.1.277
* OpenGL: Fix blit from non-multisample to multisample texture * New approach for multisample copy using compute shaders
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Image/TextureView.cs')
-rw-r--r--Ryujinx.Graphics.OpenGL/Image/TextureView.cs67
1 files changed, 14 insertions, 53 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Image/TextureView.cs b/Ryujinx.Graphics.OpenGL/Image/TextureView.cs
index 243ca1b3..f17243d2 100644
--- a/Ryujinx.Graphics.OpenGL/Image/TextureView.cs
+++ b/Ryujinx.Graphics.OpenGL/Image/TextureView.cs
@@ -116,28 +116,15 @@ namespace Ryujinx.Graphics.OpenGL.Image
{
TextureView destinationView = (TextureView)destination;
- if (destinationView.Target.IsMultisample() || Target.IsMultisample())
+ if (!destinationView.Target.IsMultisample() && Target.IsMultisample())
{
- Extents2D srcRegion = new Extents2D(0, 0, Width, Height);
- Extents2D dstRegion = new Extents2D(0, 0, destinationView.Width, destinationView.Height);
-
- TextureView intermmediate = _renderer.TextureCopy.IntermmediatePool.GetOrCreateWithAtLeast(
- GetIntermmediateTarget(Target),
- Info.BlockWidth,
- Info.BlockHeight,
- Info.BytesPerPixel,
- Format,
- Width,
- Height,
- Info.Depth,
- Info.Levels);
-
- GL.Disable(EnableCap.FramebufferSrgb);
-
- _renderer.TextureCopy.Copy(this, intermmediate, srcRegion, srcRegion, true);
- _renderer.TextureCopy.Copy(intermmediate, destinationView, srcRegion, dstRegion, true, 0, firstLayer, 0, firstLevel);
-
- GL.Enable(EnableCap.FramebufferSrgb);
+ int layers = Math.Min(Info.GetLayers(), destinationView.Info.GetLayers() - firstLayer);
+ _renderer.TextureCopyMS.CopyMSToNonMS(this, destinationView, 0, firstLayer, layers);
+ }
+ else if (destinationView.Target.IsMultisample() && !Target.IsMultisample())
+ {
+ int layers = Math.Min(Info.GetLayers(), destinationView.Info.GetLayers() - firstLayer);
+ _renderer.TextureCopyMS.CopyNonMSToMS(this, destinationView, 0, firstLayer, layers);
}
else
{
@@ -149,28 +136,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
{
TextureView destinationView = (TextureView)destination;
- if (destinationView.Target.IsMultisample() || Target.IsMultisample())
+ if (!destinationView.Target.IsMultisample() && Target.IsMultisample())
{
- Extents2D srcRegion = new Extents2D(0, 0, Width, Height);
- Extents2D dstRegion = new Extents2D(0, 0, destinationView.Width, destinationView.Height);
-
- TextureView intermmediate = _renderer.TextureCopy.IntermmediatePool.GetOrCreateWithAtLeast(
- GetIntermmediateTarget(Target),
- Info.BlockWidth,
- Info.BlockHeight,
- Info.BytesPerPixel,
- Format,
- Math.Max(1, Width >> srcLevel),
- Math.Max(1, Height >> srcLevel),
- 1,
- 1);
-
- GL.Disable(EnableCap.FramebufferSrgb);
-
- _renderer.TextureCopy.Copy(this, intermmediate, srcRegion, srcRegion, true, srcLayer, 0, srcLevel, 0, 1, 1);
- _renderer.TextureCopy.Copy(intermmediate, destinationView, srcRegion, dstRegion, true, 0, dstLayer, 0, dstLevel, 1, 1);
-
- GL.Enable(EnableCap.FramebufferSrgb);
+ _renderer.TextureCopyMS.CopyMSToNonMS(this, destinationView, srcLayer, dstLayer,1);
+ }
+ else if (destinationView.Target.IsMultisample() && !Target.IsMultisample())
+ {
+ _renderer.TextureCopyMS.CopyNonMSToMS(this, destinationView, srcLayer, dstLayer, 1);
}
else
{
@@ -178,17 +150,6 @@ namespace Ryujinx.Graphics.OpenGL.Image
}
}
- private static Target GetIntermmediateTarget(Target srcTarget)
- {
- return srcTarget switch
- {
- Target.Texture2D => Target.Texture2DMultisample,
- Target.Texture2DArray => Target.Texture2DMultisampleArray,
- Target.Texture2DMultisampleArray => Target.Texture2DArray,
- _ => Target.Texture2D
- };
- }
-
public void CopyTo(ITexture destination, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter)
{
_renderer.TextureCopy.Copy(this, (TextureView)destination, srcRegion, dstRegion, linearFilter);