Support for resources on non-contiguous GPU memory regions (#1905)

* Support for resources on non-contiguous GPU memory regions

* Implement MultiRange physical addresses, only used with a single range for now

* Actually use non-contiguous ranges

* GetPhysicalRegions fixes

* Documentation and remove Address property from TextureInfo

* Finish implementing GetWritableRegion

* Fix typo
This commit is contained in:
gdkchan 2021-01-17 15:44:34 -03:00 committed by GitHub
parent 3bad321d2b
commit c4f56c5704
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1141 additions and 167 deletions

View file

@ -1,5 +1,7 @@
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Texture;
using Ryujinx.Memory.Range;
using System;
using System.Collections.Concurrent;
using System.Threading;
@ -25,6 +27,11 @@ namespace Ryujinx.Graphics.Gpu
/// </summary>
public TextureInfo Info { get; }
/// <summary>
/// Physical memory locations where the texture data is located.
/// </summary>
public MultiRange Range { get; }
/// <summary>
/// Texture crop region.
/// </summary>
@ -49,18 +56,21 @@ namespace Ryujinx.Graphics.Gpu
/// Creates a new instance of the presentation texture.
/// </summary>
/// <param name="info">Information of the texture to be presented</param>
/// <param name="range">Physical memory locations where the texture data is located</param>
/// <param name="crop">Texture crop region</param>
/// <param name="acquireCallback">Texture acquire callback</param>
/// <param name="releaseCallback">Texture release callback</param>
/// <param name="userObj">User defined object passed to the release callback, can be used to identify the texture</param>
public PresentationTexture(
TextureInfo info,
MultiRange range,
ImageCrop crop,
Action<GpuContext, object> acquireCallback,
Action<object> releaseCallback,
object userObj)
{
Info = info;
Range = range;
Crop = crop;
AcquireCallback = acquireCallback;
ReleaseCallback = releaseCallback;
@ -118,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu
FormatInfo formatInfo = new FormatInfo(format, 1, 1, bytesPerPixel, 4);
TextureInfo info = new TextureInfo(
address,
0UL,
width,
height,
1,
@ -133,7 +143,22 @@ namespace Ryujinx.Graphics.Gpu
Target.Texture2D,
formatInfo);
_frameQueue.Enqueue(new PresentationTexture(info, crop, acquireCallback, releaseCallback, userObj));
int size = SizeCalculator.GetBlockLinearTextureSize(
width,
height,
1,
1,
1,
1,
1,
bytesPerPixel,
gobBlocksInY,
1,
1).TotalSize;
MultiRange range = new MultiRange(address, (ulong)size);
_frameQueue.Enqueue(new PresentationTexture(info, range, crop, acquireCallback, releaseCallback, userObj));
}
/// <summary>
@ -149,7 +174,7 @@ namespace Ryujinx.Graphics.Gpu
{
pt.AcquireCallback(_context, pt.UserObj);
Texture texture = _context.Methods.TextureManager.FindOrCreateTexture(pt.Info, TextureSearchFlags.WithUpscale);
Texture texture = _context.Methods.TextureManager.FindOrCreateTexture(TextureSearchFlags.WithUpscale, pt.Info, 0, null, pt.Range);
texture.SynchronizeMemory();