2018-04-26 02:11:26 +00:00
|
|
|
using ChocolArm64.Memory;
|
2018-09-08 17:51:50 +00:00
|
|
|
using Ryujinx.Graphics.Gal;
|
|
|
|
using Ryujinx.Graphics.Memory;
|
2018-04-26 02:11:26 +00:00
|
|
|
|
2018-09-08 17:51:50 +00:00
|
|
|
namespace Ryujinx.Graphics.Texture
|
2018-04-26 02:11:26 +00:00
|
|
|
{
|
2018-06-09 00:15:56 +00:00
|
|
|
static class TextureWriter
|
2018-04-26 02:11:26 +00:00
|
|
|
{
|
2018-07-19 05:30:21 +00:00
|
|
|
public unsafe static void Write(IAMemory Memory, TextureInfo Texture, byte[] Data)
|
2018-04-26 02:11:26 +00:00
|
|
|
{
|
2018-07-19 05:30:21 +00:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 4);
|
2018-04-26 02:11:26 +00: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 18:53:23 +00:00
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
2018-04-26 02:11:26 +00:00
|
|
|
fixed (byte* BuffPtr = Data)
|
|
|
|
{
|
|
|
|
long InOffs = 0;
|
|
|
|
|
2018-07-19 05:30:21 +00:00
|
|
|
for (int Y = 0; Y < Texture.Height; Y++)
|
|
|
|
for (int X = 0; X < Texture.Width; X++)
|
2018-04-26 02:11:26 +00:00
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
|
|
|
int Pixel = *(int*)(BuffPtr + InOffs);
|
|
|
|
|
2018-08-15 18:59:51 +00:00
|
|
|
CpuMem.WriteInt32(Position + Offset, Pixel);
|
2018-04-26 02:11:26 +00:00
|
|
|
|
|
|
|
InOffs += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|