1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-10-01 12:30:00 +02:00
Ryujinx/Ryujinx.Graphics/Graphics3d/Texture/TextureHelper.cs
LDj3SNuD eee639d6ba .NET Core 3.0 is here! (#784)
* .NET Core 3.0 is here!

* Remove IMemoryManager.cs and its references.

* Add T Math/F.FusedMultiplyAdd(T, T, T). Nits.

* Nit.

* Update appveyor.yml

* Revert "Resolve Visual Studio build issues"

This reverts commit 1772128ce0.

* Update SvcTable.cs
2019-10-31 19:09:03 +01:00

53 lines
1.7 KiB
C#

using ARMeilleure.Memory;
using Ryujinx.Common;
using Ryujinx.Graphics.Gal;
using Ryujinx.Graphics.Memory;
namespace Ryujinx.Graphics.Texture
{
static class TextureHelper
{
public static ISwizzle GetSwizzle(GalImage image)
{
int blockWidth = ImageUtils.GetBlockWidth (image.Format);
int blockHeight = ImageUtils.GetBlockHeight (image.Format);
int blockDepth = ImageUtils.GetBlockDepth (image.Format);
int bytesPerPixel = ImageUtils.GetBytesPerPixel(image.Format);
int width = BitUtils.DivRoundUp(image.Width, blockWidth);
int height = BitUtils.DivRoundUp(image.Height, blockHeight);
int depth = BitUtils.DivRoundUp(image.Depth, blockDepth);
if (image.Layout == GalMemoryLayout.BlockLinear)
{
int alignMask = image.TileWidth * (64 / bytesPerPixel) - 1;
width = (width + alignMask) & ~alignMask;
return new BlockLinearSwizzle(
width,
height,
depth,
image.GobBlockHeight,
image.GobBlockDepth,
bytesPerPixel);
}
else
{
return new LinearSwizzle(image.Pitch, bytesPerPixel, width, height);
}
}
public static (MemoryManager Memory, long Position) GetMemoryAndPosition(
IMemory memory,
long position)
{
if (memory is NvGpuVmm vmm)
{
return (vmm.Memory, vmm.GetPhysicalAddress(position));
}
return ((MemoryManager)memory, position);
}
}
}