2018-04-25 22:11:26 -04:00
|
|
|
using ChocolArm64.Memory;
|
|
|
|
using Ryujinx.Graphics.Gal;
|
|
|
|
using System;
|
|
|
|
|
2018-06-10 20:46:42 -04:00
|
|
|
namespace Ryujinx.HLE.Gpu
|
2018-04-25 22:11:26 -04:00
|
|
|
{
|
2018-06-08 20:15:56 -04:00
|
|
|
static class TextureWriter
|
2018-04-25 22:11:26 -04:00
|
|
|
{
|
2018-06-08 23:46:06 -04:00
|
|
|
public static void Write(
|
|
|
|
IAMemory Memory,
|
|
|
|
Texture Texture,
|
|
|
|
byte[] Data,
|
|
|
|
int Width,
|
|
|
|
int Height)
|
2018-04-25 22:11:26 -04:00
|
|
|
{
|
|
|
|
switch (Texture.Format)
|
|
|
|
{
|
2018-06-08 23:46:06 -04:00
|
|
|
case GalTextureFormat.A8B8G8R8: Write4Bpp(Memory, Texture, Data, Width, Height); break;
|
2018-04-25 22:11:26 -04:00
|
|
|
|
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
2018-05-07 14:53:23 -04:00
|
|
|
default: throw new NotImplementedException(Texture.Format.ToString());
|
2018-04-25 22:11:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-08 23:46:06 -04:00
|
|
|
private unsafe static void Write4Bpp(
|
|
|
|
IAMemory Memory,
|
|
|
|
Texture Texture,
|
|
|
|
byte[] Data,
|
|
|
|
int Width,
|
|
|
|
int Height)
|
2018-04-25 22:11:26 -04:00
|
|
|
{
|
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 4);
|
|
|
|
|
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
2018-05-07 14:53:23 -04:00
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
2018-04-25 22:11:26 -04:00
|
|
|
fixed (byte* BuffPtr = Data)
|
|
|
|
{
|
|
|
|
long InOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
|
|
|
int Pixel = *(int*)(BuffPtr + InOffs);
|
|
|
|
|
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
2018-05-07 14:53:23 -04:00
|
|
|
CpuMem.WriteInt32Unchecked(Position + Offset, Pixel);
|
2018-04-25 22:11:26 -04:00
|
|
|
|
|
|
|
InOffs += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|