mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-08-17 06:08:43 +02:00
* Move GPU LLE emulation from HLE to Graphics * Graphics: Move Gal/Texture to Texture * Remove Engines/ directory and namespace * Use tables for image formats * Abstract OpCode decoding * Simplify image table * Do not leak Read* symbols in TextureReader * Fixups * Rename IGalFrameBuffer -> IGalRenderTarget * Remove MaxBpp hardcoded value * Change yet again texture data and add G8R8 flipping * Rename GalFrameBufferFormat to GalSurfaceFormat * Unident EnsureSetup in ImageHandler * Add IsCompressed * Address some feedback
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using ChocolArm64.Memory;
|
|
using Ryujinx.Graphics.Gal;
|
|
using Ryujinx.Graphics.Memory;
|
|
using System;
|
|
|
|
namespace Ryujinx.Graphics.Texture
|
|
{
|
|
static class TextureHelper
|
|
{
|
|
public static ISwizzle GetSwizzle(TextureInfo Texture, int BlockWidth, int Bpp)
|
|
{
|
|
int Width = (Texture.Width + (BlockWidth - 1)) / BlockWidth;
|
|
|
|
int AlignMask = Texture.TileWidth * (64 / Bpp) - 1;
|
|
|
|
Width = (Width + AlignMask) & ~AlignMask;
|
|
|
|
switch (Texture.Swizzle)
|
|
{
|
|
case TextureSwizzle._1dBuffer:
|
|
case TextureSwizzle.Pitch:
|
|
case TextureSwizzle.PitchColorKey:
|
|
return new LinearSwizzle(Texture.Pitch, Bpp);
|
|
|
|
case TextureSwizzle.BlockLinear:
|
|
case TextureSwizzle.BlockLinearColorKey:
|
|
return new BlockLinearSwizzle(Width, Bpp, Texture.BlockHeight);
|
|
}
|
|
|
|
throw new NotImplementedException(Texture.Swizzle.ToString());
|
|
}
|
|
|
|
public static (AMemory Memory, long Position) GetMemoryAndPosition(
|
|
IAMemory Memory,
|
|
long Position)
|
|
{
|
|
if (Memory is NvGpuVmm Vmm)
|
|
{
|
|
return (Vmm.Memory, Vmm.GetPhysicalAddress(Position));
|
|
}
|
|
|
|
return ((AMemory)Memory, Position);
|
|
}
|
|
}
|
|
}
|