2018-10-17 13:15:50 -04:00
|
|
|
using Ryujinx.Common.Logging;
|
2018-03-12 00:04:52 -04:00
|
|
|
using Ryujinx.Graphics.Gal;
|
2018-09-18 00:30:35 -04:00
|
|
|
using Ryujinx.Graphics.Memory;
|
2018-08-16 19:47:36 -04:00
|
|
|
using Ryujinx.HLE.HOS.Kernel;
|
2018-09-18 00:30:35 -04:00
|
|
|
using Ryujinx.HLE.HOS.Services.Nv.NvGpuAS;
|
2018-08-16 19:47:36 -04:00
|
|
|
using Ryujinx.HLE.HOS.Services.Nv.NvMap;
|
2018-02-23 16:48:27 -05:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2018-03-20 16:00:00 -04:00
|
|
|
using System.IO;
|
2018-02-23 16:48:27 -05:00
|
|
|
using System.Text;
|
|
|
|
using System.Threading;
|
2018-06-23 20:39:25 -04:00
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
using static Ryujinx.HLE.HOS.Services.Android.Parcel;
|
2018-06-09 12:05:41 -04:00
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Android
|
2018-02-23 16:48:27 -05:00
|
|
|
{
|
|
|
|
class NvFlinger : IDisposable
|
|
|
|
{
|
|
|
|
private delegate long ServiceProcessParcel(ServiceCtx Context, BinaryReader ParcelReader);
|
|
|
|
|
|
|
|
private Dictionary<(string, int), ServiceProcessParcel> Commands;
|
|
|
|
|
2018-09-18 00:30:35 -04:00
|
|
|
private KEvent BinderEvent;
|
2018-03-19 14:58:46 -04:00
|
|
|
|
|
|
|
private IGalRenderer Renderer;
|
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
private const int BufferQueueCount = 0x40;
|
|
|
|
private const int BufferQueueMask = BufferQueueCount - 1;
|
|
|
|
|
|
|
|
[Flags]
|
|
|
|
private enum HalTransform
|
|
|
|
{
|
|
|
|
FlipX = 1 << 0,
|
|
|
|
FlipY = 1 << 1,
|
|
|
|
Rotate90 = 1 << 2
|
|
|
|
}
|
|
|
|
|
|
|
|
private enum BufferState
|
|
|
|
{
|
|
|
|
Free,
|
|
|
|
Dequeued,
|
|
|
|
Queued,
|
|
|
|
Acquired
|
|
|
|
}
|
|
|
|
|
2018-02-28 21:37:40 -05:00
|
|
|
private struct Rect
|
|
|
|
{
|
|
|
|
public int Top;
|
|
|
|
public int Left;
|
|
|
|
public int Right;
|
|
|
|
public int Bottom;
|
|
|
|
}
|
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
private struct BufferEntry
|
|
|
|
{
|
|
|
|
public BufferState State;
|
|
|
|
|
|
|
|
public HalTransform Transform;
|
|
|
|
|
2018-02-28 21:37:40 -05:00
|
|
|
public Rect Crop;
|
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
public GbpBuffer Data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private BufferEntry[] BufferQueue;
|
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
private AutoResetEvent WaitBufferFree;
|
2018-04-06 00:01:52 -04:00
|
|
|
|
2018-04-13 14:12:58 -04:00
|
|
|
private bool Disposed;
|
2018-02-23 16:48:27 -05:00
|
|
|
|
2018-09-18 00:30:35 -04:00
|
|
|
public NvFlinger(IGalRenderer Renderer, KEvent BinderEvent)
|
2018-02-23 16:48:27 -05:00
|
|
|
{
|
|
|
|
Commands = new Dictionary<(string, int), ServiceProcessParcel>()
|
|
|
|
{
|
|
|
|
{ ("android.gui.IGraphicBufferProducer", 0x1), GbpRequestBuffer },
|
|
|
|
{ ("android.gui.IGraphicBufferProducer", 0x3), GbpDequeueBuffer },
|
2018-03-12 00:04:52 -04:00
|
|
|
{ ("android.gui.IGraphicBufferProducer", 0x4), GbpDetachBuffer },
|
2018-02-23 16:48:27 -05:00
|
|
|
{ ("android.gui.IGraphicBufferProducer", 0x7), GbpQueueBuffer },
|
|
|
|
{ ("android.gui.IGraphicBufferProducer", 0x8), GbpCancelBuffer },
|
|
|
|
{ ("android.gui.IGraphicBufferProducer", 0x9), GbpQuery },
|
|
|
|
{ ("android.gui.IGraphicBufferProducer", 0xa), GbpConnect },
|
2018-03-06 15:27:50 -05:00
|
|
|
{ ("android.gui.IGraphicBufferProducer", 0xb), GbpDisconnect },
|
2018-02-23 16:48:27 -05:00
|
|
|
{ ("android.gui.IGraphicBufferProducer", 0xe), GbpPreallocBuffer }
|
|
|
|
};
|
2018-04-06 00:01:52 -04:00
|
|
|
|
2018-09-18 00:30:35 -04:00
|
|
|
this.Renderer = Renderer;
|
|
|
|
this.BinderEvent = BinderEvent;
|
2018-03-12 00:04:52 -04:00
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
BufferQueue = new BufferEntry[0x40];
|
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
WaitBufferFree = new AutoResetEvent(false);
|
2018-02-23 16:48:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public long ProcessParcelRequest(ServiceCtx Context, byte[] ParcelData, int Code)
|
|
|
|
{
|
|
|
|
using (MemoryStream MS = new MemoryStream(ParcelData))
|
|
|
|
{
|
|
|
|
BinaryReader Reader = new BinaryReader(MS);
|
|
|
|
|
|
|
|
MS.Seek(4, SeekOrigin.Current);
|
|
|
|
|
|
|
|
int StrSize = Reader.ReadInt32();
|
|
|
|
|
|
|
|
string InterfaceName = Encoding.Unicode.GetString(Reader.ReadBytes(StrSize * 2));
|
|
|
|
|
|
|
|
long Remainder = MS.Position & 0xf;
|
|
|
|
|
|
|
|
if (Remainder != 0)
|
|
|
|
{
|
|
|
|
MS.Seek(0x10 - Remainder, SeekOrigin.Current);
|
|
|
|
}
|
|
|
|
|
|
|
|
MS.Seek(0x50, SeekOrigin.Begin);
|
|
|
|
|
|
|
|
if (Commands.TryGetValue((InterfaceName, Code), out ServiceProcessParcel ProcReq))
|
|
|
|
{
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintDebug(LogClass.ServiceVi, $"{InterfaceName} {ProcReq.Method.Name}");
|
2018-02-23 16:48:27 -05:00
|
|
|
|
|
|
|
return ProcReq(Context, Reader);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new NotImplementedException($"{InterfaceName} {Code}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private long GbpRequestBuffer(ServiceCtx Context, BinaryReader ParcelReader)
|
|
|
|
{
|
|
|
|
int Slot = ParcelReader.ReadInt32();
|
|
|
|
|
|
|
|
using (MemoryStream MS = new MemoryStream())
|
|
|
|
{
|
|
|
|
BinaryWriter Writer = new BinaryWriter(MS);
|
2018-04-06 00:01:52 -04:00
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
BufferEntry Entry = BufferQueue[Slot];
|
|
|
|
|
|
|
|
int BufferCount = 1; //?
|
|
|
|
long BufferSize = Entry.Data.Size;
|
|
|
|
|
|
|
|
Writer.Write(BufferCount);
|
|
|
|
Writer.Write(BufferSize);
|
|
|
|
|
|
|
|
Entry.Data.Write(Writer);
|
|
|
|
|
|
|
|
Writer.Write(0);
|
|
|
|
|
|
|
|
return MakeReplyParcel(Context, MS.ToArray());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private long GbpDequeueBuffer(ServiceCtx Context, BinaryReader ParcelReader)
|
|
|
|
{
|
|
|
|
//TODO: Errors.
|
|
|
|
int Format = ParcelReader.ReadInt32();
|
|
|
|
int Width = ParcelReader.ReadInt32();
|
|
|
|
int Height = ParcelReader.ReadInt32();
|
|
|
|
int GetTimestamps = ParcelReader.ReadInt32();
|
|
|
|
int Usage = ParcelReader.ReadInt32();
|
|
|
|
|
|
|
|
int Slot = GetFreeSlotBlocking(Width, Height);
|
|
|
|
|
2018-08-15 14:59:51 -04:00
|
|
|
return MakeReplyParcel(Context, Slot, 1, 0x24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
2018-02-23 16:48:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private long GbpQueueBuffer(ServiceCtx Context, BinaryReader ParcelReader)
|
|
|
|
{
|
2018-08-16 19:47:36 -04:00
|
|
|
Context.Device.Statistics.RecordGameFrameTime();
|
2018-03-06 15:18:49 -05:00
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
//TODO: Errors.
|
|
|
|
int Slot = ParcelReader.ReadInt32();
|
|
|
|
int Unknown4 = ParcelReader.ReadInt32();
|
|
|
|
int Unknown8 = ParcelReader.ReadInt32();
|
|
|
|
int Unknownc = ParcelReader.ReadInt32();
|
|
|
|
int Timestamp = ParcelReader.ReadInt32();
|
|
|
|
int IsAutoTimestamp = ParcelReader.ReadInt32();
|
|
|
|
int CropTop = ParcelReader.ReadInt32();
|
|
|
|
int CropLeft = ParcelReader.ReadInt32();
|
|
|
|
int CropRight = ParcelReader.ReadInt32();
|
|
|
|
int CropBottom = ParcelReader.ReadInt32();
|
|
|
|
int ScalingMode = ParcelReader.ReadInt32();
|
|
|
|
int Transform = ParcelReader.ReadInt32();
|
|
|
|
int StickyTransform = ParcelReader.ReadInt32();
|
|
|
|
int Unknown34 = ParcelReader.ReadInt32();
|
|
|
|
int Unknown38 = ParcelReader.ReadInt32();
|
|
|
|
int IsFenceValid = ParcelReader.ReadInt32();
|
|
|
|
int Fence0Id = ParcelReader.ReadInt32();
|
|
|
|
int Fence0Value = ParcelReader.ReadInt32();
|
|
|
|
int Fence1Id = ParcelReader.ReadInt32();
|
|
|
|
int Fence1Value = ParcelReader.ReadInt32();
|
|
|
|
|
|
|
|
BufferQueue[Slot].Transform = (HalTransform)Transform;
|
|
|
|
|
2018-02-28 21:37:40 -05:00
|
|
|
BufferQueue[Slot].Crop.Top = CropTop;
|
|
|
|
BufferQueue[Slot].Crop.Left = CropLeft;
|
|
|
|
BufferQueue[Slot].Crop.Right = CropRight;
|
|
|
|
BufferQueue[Slot].Crop.Bottom = CropBottom;
|
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
BufferQueue[Slot].State = BufferState.Queued;
|
|
|
|
|
|
|
|
SendFrameBuffer(Context, Slot);
|
|
|
|
|
2018-09-09 19:38:56 -04:00
|
|
|
if (Context.Device.EnableDeviceVsync)
|
|
|
|
{
|
|
|
|
Context.Device.VsyncEvent.WaitOne();
|
|
|
|
}
|
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
return MakeReplyParcel(Context, 1280, 720, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2018-03-12 00:04:52 -04:00
|
|
|
private long GbpDetachBuffer(ServiceCtx Context, BinaryReader ParcelReader)
|
|
|
|
{
|
|
|
|
return MakeReplyParcel(Context, 0);
|
|
|
|
}
|
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
private long GbpCancelBuffer(ServiceCtx Context, BinaryReader ParcelReader)
|
|
|
|
{
|
|
|
|
//TODO: Errors.
|
|
|
|
int Slot = ParcelReader.ReadInt32();
|
|
|
|
|
|
|
|
BufferQueue[Slot].State = BufferState.Free;
|
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
WaitBufferFree.Set();
|
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
return MakeReplyParcel(Context, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private long GbpQuery(ServiceCtx Context, BinaryReader ParcelReader)
|
|
|
|
{
|
|
|
|
return MakeReplyParcel(Context, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private long GbpConnect(ServiceCtx Context, BinaryReader ParcelReader)
|
|
|
|
{
|
|
|
|
return MakeReplyParcel(Context, 1280, 720, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2018-03-06 15:27:50 -05:00
|
|
|
private long GbpDisconnect(ServiceCtx Context, BinaryReader ParcelReader)
|
|
|
|
{
|
|
|
|
return MakeReplyParcel(Context, 0);
|
|
|
|
}
|
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
private long GbpPreallocBuffer(ServiceCtx Context, BinaryReader ParcelReader)
|
|
|
|
{
|
|
|
|
int Slot = ParcelReader.ReadInt32();
|
2018-04-06 00:01:52 -04:00
|
|
|
|
2018-04-08 15:17:35 -04:00
|
|
|
int BufferCount = ParcelReader.ReadInt32();
|
2018-02-23 16:48:27 -05:00
|
|
|
|
2018-04-08 15:17:35 -04:00
|
|
|
if (BufferCount > 0)
|
|
|
|
{
|
|
|
|
long BufferSize = ParcelReader.ReadInt64();
|
2018-02-23 16:48:27 -05:00
|
|
|
|
2018-04-08 15:17:35 -04:00
|
|
|
BufferQueue[Slot].State = BufferState.Free;
|
|
|
|
|
|
|
|
BufferQueue[Slot].Data = new GbpBuffer(ParcelReader);
|
|
|
|
}
|
2018-02-23 16:48:27 -05:00
|
|
|
|
|
|
|
return MakeReplyParcel(Context, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private long MakeReplyParcel(ServiceCtx Context, params int[] Ints)
|
|
|
|
{
|
|
|
|
using (MemoryStream MS = new MemoryStream())
|
|
|
|
{
|
|
|
|
BinaryWriter Writer = new BinaryWriter(MS);
|
|
|
|
|
|
|
|
foreach (int Int in Ints)
|
|
|
|
{
|
|
|
|
Writer.Write(Int);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MakeReplyParcel(Context, MS.ToArray());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private long MakeReplyParcel(ServiceCtx Context, byte[] Data)
|
|
|
|
{
|
2018-11-28 17:18:09 -05:00
|
|
|
(long ReplyPos, long ReplySize) = Context.Request.GetBufferType0x22();
|
2018-02-23 16:48:27 -05:00
|
|
|
|
|
|
|
byte[] Reply = MakeParcel(Data, new byte[0]);
|
|
|
|
|
2018-06-09 12:05:41 -04:00
|
|
|
Context.Memory.WriteBytes(ReplyPos, Reply);
|
2018-02-23 16:48:27 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-13 14:12:58 -04:00
|
|
|
private void SendFrameBuffer(ServiceCtx Context, int Slot)
|
2018-02-23 16:48:27 -05:00
|
|
|
{
|
2018-07-19 01:30:21 -04:00
|
|
|
int FbWidth = BufferQueue[Slot].Data.Width;
|
|
|
|
int FbHeight = BufferQueue[Slot].Data.Height;
|
2018-02-23 16:48:27 -05: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
|
|
|
int NvMapHandle = BitConverter.ToInt32(BufferQueue[Slot].Data.RawData, 0x4c);
|
|
|
|
int BufferOffset = BitConverter.ToInt32(BufferQueue[Slot].Data.RawData, 0x50);
|
2018-02-23 16:48:27 -05: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
|
|
|
NvMapHandle Map = NvMapIoctl.GetNvMap(Context, NvMapHandle);;
|
2018-03-20 11:18:25 -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
|
|
|
long FbAddr = Map.Address + BufferOffset;
|
2018-02-23 16:48:27 -05:00
|
|
|
|
2018-02-28 21:37:40 -05:00
|
|
|
BufferQueue[Slot].State = BufferState.Acquired;
|
|
|
|
|
|
|
|
Rect Crop = BufferQueue[Slot].Crop;
|
|
|
|
|
2018-07-23 10:21:05 -04:00
|
|
|
bool FlipX = BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipX);
|
|
|
|
bool FlipY = BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipY);
|
2018-02-23 16:48:27 -05:00
|
|
|
|
2018-09-18 00:30:35 -04:00
|
|
|
//Note: Rotation is being ignored.
|
2018-03-04 18:32:18 -05:00
|
|
|
|
2018-07-23 10:21:05 -04:00
|
|
|
int Top = Crop.Top;
|
|
|
|
int Left = Crop.Left;
|
|
|
|
int Right = Crop.Right;
|
|
|
|
int Bottom = Crop.Bottom;
|
2018-03-04 18:32:18 -05:00
|
|
|
|
2018-09-18 00:30:35 -04:00
|
|
|
NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;
|
2018-03-12 00:04:52 -04:00
|
|
|
|
2018-09-18 00:30:35 -04:00
|
|
|
Renderer.QueueAction(() =>
|
2018-04-13 14:12:58 -04:00
|
|
|
{
|
2018-09-18 00:30:35 -04:00
|
|
|
if (!Renderer.Texture.TryGetImage(FbAddr, out GalImage Image))
|
|
|
|
{
|
|
|
|
Image = new GalImage(
|
|
|
|
FbWidth,
|
|
|
|
FbHeight, 1, 16,
|
|
|
|
GalMemoryLayout.BlockLinear,
|
2018-10-17 17:02:23 -04:00
|
|
|
GalImageFormat.RGBA8 | GalImageFormat.Unorm);
|
2018-09-18 00:30:35 -04:00
|
|
|
}
|
2018-02-23 16:48:27 -05:00
|
|
|
|
2018-09-18 00:30:35 -04:00
|
|
|
Context.Device.Gpu.ResourceManager.ClearPbCache();
|
|
|
|
Context.Device.Gpu.ResourceManager.SendTexture(Vmm, FbAddr, Image);
|
2018-03-12 00:04:52 -04:00
|
|
|
|
2018-09-18 00:30:35 -04:00
|
|
|
Renderer.RenderTarget.SetTransform(FlipX, FlipY, Top, Left, Right, Bottom);
|
2018-09-25 18:55:30 -04:00
|
|
|
Renderer.RenderTarget.Present(FbAddr);
|
2018-03-19 14:58:46 -04:00
|
|
|
|
2018-09-18 00:30:35 -04:00
|
|
|
ReleaseBuffer(Slot);
|
|
|
|
});
|
2018-02-23 16:48:27 -05:00
|
|
|
}
|
|
|
|
|
2018-04-13 14:12:58 -04:00
|
|
|
private void ReleaseBuffer(int Slot)
|
|
|
|
{
|
|
|
|
BufferQueue[Slot].State = BufferState.Free;
|
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
BinderEvent.ReadableEvent.Signal();
|
2018-04-13 14:12:58 -04:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
WaitBufferFree.Set();
|
2018-04-13 14:12:58 -04:00
|
|
|
}
|
|
|
|
|
2018-02-23 16:48:27 -05:00
|
|
|
private int GetFreeSlotBlocking(int Width, int Height)
|
|
|
|
{
|
|
|
|
int Slot;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2018-09-18 19:36:43 -04:00
|
|
|
if ((Slot = GetFreeSlot(Width, Height)) != -1)
|
2018-02-23 16:48:27 -05:00
|
|
|
{
|
2018-09-18 19:36:43 -04:00
|
|
|
break;
|
|
|
|
}
|
2018-02-23 16:48:27 -05:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
if (Disposed)
|
|
|
|
{
|
|
|
|
break;
|
2018-02-23 16:48:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
WaitBufferFree.WaitOne();
|
|
|
|
}
|
2018-04-13 14:12:58 -04:00
|
|
|
while (!Disposed);
|
2018-02-23 16:48:27 -05:00
|
|
|
|
|
|
|
return Slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
private int GetFreeSlot(int Width, int Height)
|
|
|
|
{
|
|
|
|
lock (BufferQueue)
|
|
|
|
{
|
|
|
|
for (int Slot = 0; Slot < BufferQueue.Length; Slot++)
|
|
|
|
{
|
|
|
|
if (BufferQueue[Slot].State != BufferState.Free)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
GbpBuffer Data = BufferQueue[Slot].Data;
|
|
|
|
|
|
|
|
if (Data.Width == Width &&
|
|
|
|
Data.Height == Height)
|
|
|
|
{
|
|
|
|
BufferQueue[Slot].State = BufferState.Dequeued;
|
|
|
|
|
|
|
|
return Slot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
Dispose(true);
|
|
|
|
}
|
|
|
|
|
2018-03-12 00:04:52 -04:00
|
|
|
protected virtual void Dispose(bool Disposing)
|
2018-02-23 16:48:27 -05:00
|
|
|
{
|
2018-04-13 14:12:58 -04:00
|
|
|
if (Disposing && !Disposed)
|
2018-02-23 16:48:27 -05:00
|
|
|
{
|
2018-04-13 14:12:58 -04:00
|
|
|
Disposed = true;
|
2018-03-12 00:04:52 -04:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
WaitBufferFree.Set();
|
2018-02-23 16:48:27 -05:00
|
|
|
WaitBufferFree.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|