aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gpu/TextureReader.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-05-07 15:53:23 -0300
committerGitHub <noreply@github.com>2018-05-07 15:53:23 -0300
commit34037701c708cb70bbf44dea71ee0912f7b4102b (patch)
treeca4cf2bde85dea48af12033b8d0446f17b611f4f /Ryujinx.Graphics/Gpu/TextureReader.cs
parent4419e8d6b43432eae94a3a9304f7df22b34738a8 (diff)
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl * More work on NvHostCtrl * Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind * Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb) * Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks * Remove now unused code, add comment about probably wrong result codes
Diffstat (limited to 'Ryujinx.Graphics/Gpu/TextureReader.cs')
-rw-r--r--Ryujinx.Graphics/Gpu/TextureReader.cs144
1 files changed, 0 insertions, 144 deletions
diff --git a/Ryujinx.Graphics/Gpu/TextureReader.cs b/Ryujinx.Graphics/Gpu/TextureReader.cs
deleted file mode 100644
index 17fd95c5..00000000
--- a/Ryujinx.Graphics/Gpu/TextureReader.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-using ChocolArm64.Memory;
-using Ryujinx.Graphics.Gal;
-using System;
-
-namespace Ryujinx.Graphics.Gpu
-{
- public static class TextureReader
- {
- public static byte[] Read(AMemory Memory, Texture Texture)
- {
- switch (Texture.Format)
- {
- case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture);
- case GalTextureFormat.A1B5G5R5: return Read2Bpp (Memory, Texture);
- case GalTextureFormat.B5G6R5: return Read2Bpp (Memory, Texture);
- case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture);
- case GalTextureFormat.BC2: return Read16Bpt4x4(Memory, Texture);
- case GalTextureFormat.BC3: return Read16Bpt4x4(Memory, Texture);
- case GalTextureFormat.BC4: return Read8Bpt4x4 (Memory, Texture);
- case GalTextureFormat.BC5: return Read16Bpt4x4(Memory, Texture);
- }
-
- throw new NotImplementedException(Texture.Format.ToString());
- }
-
- private unsafe static byte[] Read2Bpp(AMemory Memory, Texture Texture)
- {
- int Width = Texture.Width;
- int Height = Texture.Height;
-
- byte[] Output = new byte[Width * Height * 2];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 2);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- short Pixel = Memory.ReadInt16Unchecked(Texture.Position + Offset);
-
- *(short*)(BuffPtr + OutOffs) = Pixel;
-
- OutOffs += 2;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read4Bpp(AMemory Memory, Texture Texture)
- {
- int Width = Texture.Width;
- int Height = Texture.Height;
-
- byte[] Output = new byte[Width * Height * 4];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 4);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- int Pixel = Memory.ReadInt32Unchecked(Texture.Position + Offset);
-
- *(int*)(BuffPtr + OutOffs) = Pixel;
-
- OutOffs += 4;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read8Bpt4x4(AMemory Memory, Texture Texture)
- {
- int Width = (Texture.Width + 3) / 4;
- int Height = (Texture.Height + 3) / 4;
-
- byte[] Output = new byte[Width * Height * 8];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 8);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- long Tile = Memory.ReadInt64Unchecked(Texture.Position + Offset);
-
- *(long*)(BuffPtr + OutOffs) = Tile;
-
- OutOffs += 8;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read16Bpt4x4(AMemory Memory, Texture Texture)
- {
- int Width = (Texture.Width + 3) / 4;
- int Height = (Texture.Height + 3) / 4;
-
- byte[] Output = new byte[Width * Height * 16];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 16);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- long Tile0 = Memory.ReadInt64Unchecked(Texture.Position + Offset + 0);
- long Tile1 = Memory.ReadInt64Unchecked(Texture.Position + Offset + 8);
-
- *(long*)(BuffPtr + OutOffs + 0) = Tile0;
- *(long*)(BuffPtr + OutOffs + 8) = Tile1;
-
- OutOffs += 16;
- }
- }
-
- return Output;
- }
- }
-}