mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-10-20 07:41:40 +00:00
cf6cd71488
* IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel * Fix for applet transfer memory + some nits * Keep handles if possible to avoid server handle table exhaustion * Fix IPC ZeroFill bug * am: Correctly implement CreateManagedDisplayLayer and implement CreateManagedDisplaySeparableLayer CreateManagedDisplaySeparableLayer is requires since 10.x+ when appletResourceUserId != 0 * Make it exit properly * Make ServiceNotImplementedException show the full message again * Allow yielding execution to avoid starving other threads * Only wait if active * Merge IVirtualMemoryManager and IAddressSpaceManager * Fix Ro loading data from the wrong process Co-authored-by: Thog <me@thog.eu>
75 lines
No EOL
2.2 KiB
C#
75 lines
No EOL
2.2 KiB
C#
using Ryujinx.HLE.HOS.Kernel.Process;
|
|
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
|
|
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|
{
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
struct GraphicBuffer : IFlattenable
|
|
{
|
|
public GraphicBufferHeader Header;
|
|
public NvGraphicBuffer Buffer;
|
|
|
|
public int Width => Header.Width;
|
|
public int Height => Header.Height;
|
|
public PixelFormat Format => Header.Format;
|
|
public int Usage => Header.Usage;
|
|
|
|
public Rect ToRect()
|
|
{
|
|
return new Rect(Width, Height);
|
|
}
|
|
|
|
public void Flatten(Parcel parcel)
|
|
{
|
|
parcel.WriteUnmanagedType(ref Header);
|
|
parcel.WriteUnmanagedType(ref Buffer);
|
|
}
|
|
|
|
public void Unflatten(Parcel parcel)
|
|
{
|
|
Header = parcel.ReadUnmanagedType<GraphicBufferHeader>();
|
|
|
|
int expectedSize = Unsafe.SizeOf<NvGraphicBuffer>() / 4;
|
|
|
|
if (Header.IntsCount != expectedSize)
|
|
{
|
|
throw new NotImplementedException($"Unexpected Graphic Buffer ints count (expected 0x{expectedSize:x}, found 0x{Header.IntsCount:x})");
|
|
}
|
|
|
|
Buffer = parcel.ReadUnmanagedType<NvGraphicBuffer>();
|
|
}
|
|
|
|
public void IncrementNvMapHandleRefCount(long pid)
|
|
{
|
|
NvMapDeviceFile.IncrementMapRefCount(pid, Buffer.NvMapId);
|
|
|
|
for (int i = 0; i < Buffer.Surfaces.Length; i++)
|
|
{
|
|
NvMapDeviceFile.IncrementMapRefCount(pid, Buffer.Surfaces[i].NvMapHandle);
|
|
}
|
|
}
|
|
|
|
public void DecrementNvMapHandleRefCount(long pid)
|
|
{
|
|
NvMapDeviceFile.DecrementMapRefCount(pid, Buffer.NvMapId);
|
|
|
|
for (int i = 0; i < Buffer.Surfaces.Length; i++)
|
|
{
|
|
NvMapDeviceFile.DecrementMapRefCount(pid, Buffer.Surfaces[i].NvMapHandle);
|
|
}
|
|
}
|
|
|
|
public uint GetFlattenedSize()
|
|
{
|
|
return (uint)Unsafe.SizeOf<GraphicBuffer>();
|
|
}
|
|
|
|
public uint GetFdCount()
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
} |