aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Texture/TextureHelper.cs
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2018-09-08 14:51:50 -0300
committergdkchan <gab.dark.100@gmail.com>2018-09-08 14:51:50 -0300
commitce1d5be212e6f71a7ca32c3bd7b48e32d9f51b9a (patch)
tree759fe422127ce08c545d4616ccc9691f668032ec /Ryujinx.Graphics/Texture/TextureHelper.cs
parenta0c78f792012cdea060444d7cb6a36dbabb04d52 (diff)
Move GPU emulation from Ryujinx.HLE to Ryujinx.Graphics and misc changes (#402)
* 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
Diffstat (limited to 'Ryujinx.Graphics/Texture/TextureHelper.cs')
-rw-r--r--Ryujinx.Graphics/Texture/TextureHelper.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/Ryujinx.Graphics/Texture/TextureHelper.cs b/Ryujinx.Graphics/Texture/TextureHelper.cs
new file mode 100644
index 00000000..8130ab41
--- /dev/null
+++ b/Ryujinx.Graphics/Texture/TextureHelper.cs
@@ -0,0 +1,45 @@
+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);
+ }
+ }
+}