0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/AndroidFence.cs
mageven a33dc2f491
Improved Logger (#1292)
* Logger class changes only

Now compile-time checking is possible with the help of Nullable Value
types.

* Misc formatting

* Manual optimizations

PrintGuestLog
PrintGuestStackTrace
Surfaceflinger DequeueBuffer

* Reduce SendVibrationXX log level to Debug

* Add Notice log level

This level is always enabled and used to print system info, etc...
Also, rewrite LogColor to switch expression as colors are static

* Unify unhandled exception event handlers

* Print enabled LogLevels during init

* Re-add App Exit disposes in proper order

nit: switch case spacing

* Revert PrintGuestStackTrace to Info logs due to #1407

PrintGuestStackTrace is now called in some critical error handlers
so revert to old behavior as KThread isn't part of Guest.

* Batch replace Logger statements
2020-08-04 01:32:53 +02:00

89 lines
No EOL
2.2 KiB
C#

using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Gpu;
using Ryujinx.HLE.HOS.Services.Nv.Types;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
{
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x24)]
struct AndroidFence : IFlattenable
{
public int FenceCount;
private byte _fenceStorageStart;
private Span<byte> _storage => MemoryMarshal.CreateSpan(ref _fenceStorageStart, Unsafe.SizeOf<NvFence>() * 4);
public Span<NvFence> NvFences => MemoryMarshal.Cast<byte, NvFence>(_storage);
public static AndroidFence NoFence
{
get
{
AndroidFence fence = new AndroidFence
{
FenceCount = 0
};
fence.NvFences[0].Id = NvFence.InvalidSyncPointId;
return fence;
}
}
public void AddFence(NvFence fence)
{
NvFences[FenceCount++] = fence;
}
public void WaitForever(GpuContext gpuContext)
{
bool hasTimeout = Wait(gpuContext, TimeSpan.FromMilliseconds(3000));
if (hasTimeout)
{
Logger.Error?.Print(LogClass.SurfaceFlinger, "Android fence didn't signal in 3000 ms");
Wait(gpuContext, Timeout.InfiniteTimeSpan);
}
}
public bool Wait(GpuContext gpuContext, TimeSpan timeout)
{
for (int i = 0; i < FenceCount; i++)
{
bool hasTimeout = NvFences[i].Wait(gpuContext, timeout);
if (hasTimeout)
{
return true;
}
}
return false;
}
public uint GetFlattenedSize()
{
return (uint)Unsafe.SizeOf<AndroidFence>();
}
public uint GetFdCount()
{
return 0;
}
public void Flatten(Parcel parcel)
{
parcel.WriteUnmanagedType(ref this);
}
public void Unflatten(Parcel parcel)
{
this = parcel.ReadUnmanagedType<AndroidFence>();
}
}
}