From b9fd7c8b23217c112dd80f76ff31da553cb6a1a1 Mon Sep 17 00:00:00 2001 From: Bruno Macabeus Date: Fri, 1 Jan 2021 14:03:33 -0800 Subject: [PATCH] Remove long <-> ulong casts from Nvservices code (#1848) * Remove long <-> ulong casts from Nvservices code * review: fix lint --- .../NvHostAsGpu/NvHostAsGpuDeviceFile.cs | 48 +++++++------- .../NvHostAsGpu/Types/AddressSpaceContext.cs | 62 +++++++++---------- .../NvHostAsGpu/Types/AllocSpaceArguments.cs | 2 +- .../NvHostAsGpu/Types/FreeSpaceArguments.cs | 6 +- .../NvHostAsGpu/Types/MapBufferExArguments.cs | 6 +- .../NvHostAsGpu/Types/UnmapBufferArguments.cs | 2 +- .../NvHostChannel/NvHostChannelDeviceFile.cs | 8 +-- .../Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs | 2 +- .../NvDrvServices/NvMap/Types/NvMapAlloc.cs | 12 ++-- .../Nv/NvDrvServices/NvMap/Types/NvMapFree.cs | 10 +-- .../NvDrvServices/NvMap/Types/NvMapHandle.cs | 16 ++--- .../Services/SurfaceFlinger/SurfaceFlinger.cs | 4 +- 12 files changed, 89 insertions(+), 89 deletions(-) diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs index c2296775..c013cefa 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs @@ -97,12 +97,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu // the Offset field holds the alignment size instead. if ((arguments.Flags & AddressSpaceFlags.FixedOffset) != 0) { - bool regionInUse = _memoryAllocator.IsRegionInUse((ulong)arguments.Offset, size, out ulong freeAddressStartPosition); + bool regionInUse = _memoryAllocator.IsRegionInUse(arguments.Offset, size, out ulong freeAddressStartPosition); ulong address; if (!regionInUse) { - _memoryAllocator.AllocateRange((ulong)arguments.Offset, size, freeAddressStartPosition); + _memoryAllocator.AllocateRange(arguments.Offset, size, freeAddressStartPosition); address = freeAddressStartPosition; } else @@ -110,17 +110,17 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu address = NvMemoryAllocator.PteUnmapped; } - arguments.Offset = (long)address; + arguments.Offset = address; } else { - ulong address = _memoryAllocator.GetFreeAddress((ulong)size, out ulong freeAddressStartPosition, (ulong)arguments.Offset); + ulong address = _memoryAllocator.GetFreeAddress(size, out ulong freeAddressStartPosition, arguments.Offset); if (address != NvMemoryAllocator.PteUnmapped) { - _memoryAllocator.AllocateRange(address, (ulong)size, freeAddressStartPosition); + _memoryAllocator.AllocateRange(address, size, freeAddressStartPosition); } - arguments.Offset = unchecked((long)address); + arguments.Offset = address; } if (arguments.Offset < 0) @@ -133,7 +133,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu } else { - addressSpaceContext.AddReservation(arguments.Offset, (long)size); + addressSpaceContext.AddReservation(arguments.Offset, size); } } @@ -152,8 +152,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu if (addressSpaceContext.RemoveReservation(arguments.Offset)) { - _memoryAllocator.DeallocateRange((ulong)arguments.Offset, size); - addressSpaceContext.Gmm.Free((ulong)arguments.Offset, size); + _memoryAllocator.DeallocateRange(arguments.Offset, size); + addressSpaceContext.Gmm.Free(arguments.Offset, size); } else { @@ -173,12 +173,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu lock (addressSpaceContext) { - if (addressSpaceContext.RemoveMap(arguments.Offset, out long size)) + if (addressSpaceContext.RemoveMap(arguments.Offset, out ulong size)) { if (size != 0) { - _memoryAllocator.DeallocateRange((ulong)arguments.Offset, (ulong)size); - addressSpaceContext.Gmm.Free((ulong)arguments.Offset, (ulong)size); + _memoryAllocator.DeallocateRange(arguments.Offset, size); + addressSpaceContext.Gmm.Free(arguments.Offset, size); } } else @@ -212,7 +212,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu pageSize = (ulong)map.Align; } - long physicalAddress; + ulong physicalAddress; if ((arguments.Flags & AddressSpaceFlags.RemapSubRange) != 0) { @@ -220,10 +220,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu { if (addressSpaceContext.TryGetMapPhysicalAddress(arguments.Offset, out physicalAddress)) { - long virtualAddress = arguments.Offset + arguments.BufferOffset; + ulong virtualAddress = arguments.Offset + arguments.BufferOffset; physicalAddress += arguments.BufferOffset; - addressSpaceContext.Gmm.Map((ulong)physicalAddress, (ulong)virtualAddress, (ulong)arguments.MappingSize); + addressSpaceContext.Gmm.Map(physicalAddress, virtualAddress, arguments.MappingSize); if (virtualAddress < 0) { @@ -247,7 +247,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu physicalAddress = map.Address + arguments.BufferOffset; - long size = arguments.MappingSize; + ulong size = arguments.MappingSize; if (size == 0) { @@ -266,7 +266,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu { if (addressSpaceContext.ValidateFixedBuffer(arguments.Offset, size, pageSize)) { - addressSpaceContext.Gmm.Map((ulong)physicalAddress, (ulong)arguments.Offset, (ulong)size); + addressSpaceContext.Gmm.Map(physicalAddress, arguments.Offset, size); } else { @@ -279,14 +279,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu } else { - ulong va = _memoryAllocator.GetFreeAddress((ulong)size, out ulong freeAddressStartPosition, (ulong) pageSize); + ulong va = _memoryAllocator.GetFreeAddress(size, out ulong freeAddressStartPosition, pageSize); if (va != NvMemoryAllocator.PteUnmapped) { - _memoryAllocator.AllocateRange(va, (ulong)size, freeAddressStartPosition); + _memoryAllocator.AllocateRange(va, size, freeAddressStartPosition); } - addressSpaceContext.Gmm.Map((ulong)physicalAddress, va, (ulong)size); - arguments.Offset = (long)va; + addressSpaceContext.Gmm.Map(physicalAddress, va, size); + arguments.Offset = va; } if (arguments.Offset < 0) @@ -335,11 +335,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu return NvInternalResult.InvalidInput; } - long shiftedGpuOffset = (long)((ulong)arguments[index].GpuOffset << 16); + ulong shiftedGpuOffset = ((ulong)arguments[index].GpuOffset << 16); gmm.Map( - ((ulong)arguments[index].MapOffset << 16) + (ulong)map.Address, - (ulong)shiftedGpuOffset, + ((ulong)arguments[index].MapOffset << 16) + map.Address, + shiftedGpuOffset, (ulong)arguments[index].Pages << 16); if (shiftedGpuOffset < 0) diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs index d39be297..b784ca51 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs @@ -12,22 +12,22 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types public ulong Start { get; private set; } public ulong End { get; private set; } - public Range(long position, long size) + public Range(ulong position, ulong size) { - Start = (ulong)position; - End = (ulong)size + Start; + Start = position; + End = size + Start; } } private class MappedMemory : Range { - public long PhysicalAddress { get; private set; } - public bool VaAllocated { get; private set; } + public ulong PhysicalAddress { get; private set; } + public bool VaAllocated { get; private set; } public MappedMemory( - long position, - long size, - long physicalAddress, + ulong position, + ulong size, + ulong physicalAddress, bool vaAllocated) : base(position, size) { PhysicalAddress = physicalAddress; @@ -35,8 +35,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types } } - private SortedList _maps; - private SortedList _reservations; + private SortedList _maps; + private SortedList _reservations; public MemoryManager Gmm { get; } @@ -44,22 +44,22 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types { Gmm = context.Device.Gpu.MemoryManager; - _maps = new SortedList(); - _reservations = new SortedList(); + _maps = new SortedList(); + _reservations = new SortedList(); } - public bool ValidateFixedBuffer(long position, long size, ulong alignment) + public bool ValidateFixedBuffer(ulong position, ulong size, ulong alignment) { - long mapEnd = position + size; + ulong mapEnd = position + size; // Check if size is valid (0 is also not allowed). - if ((ulong)mapEnd <= (ulong)position) + if (mapEnd <= position) { return false; } // Check if address is aligned. - if ((position & (long)(alignment - 1)) != 0) + if ((position & (alignment - 1)) != 0) { return false; } @@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types // Check for overlap with already mapped buffers. Range map = BinarySearchLt(_maps, mapEnd); - if (map != null && map.End > (ulong)position) + if (map != null && map.End > position) { return false; } @@ -82,15 +82,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types } public void AddMap( - long position, - long size, - long physicalAddress, + ulong position, + ulong size, + ulong physicalAddress, bool vaAllocated) { _maps.Add(position, new MappedMemory(position, size, physicalAddress, vaAllocated)); } - public bool RemoveMap(long position, out long size) + public bool RemoveMap(ulong position, out ulong size) { size = 0; @@ -100,7 +100,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types if (map.VaAllocated) { - size = (long)(map.End - map.Start); + size = (map.End - map.Start); } return true; @@ -109,7 +109,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types return false; } - public bool TryGetMapPhysicalAddress(long position, out long physicalAddress) + public bool TryGetMapPhysicalAddress(ulong position, out ulong physicalAddress) { Range map = BinarySearch(_maps, position); @@ -125,17 +125,17 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types return false; } - public void AddReservation(long position, long size) + public void AddReservation(ulong position, ulong size) { _reservations.Add(position, new Range(position, size)); } - public bool RemoveReservation(long position) + public bool RemoveReservation(ulong position) { return _reservations.Remove(position); } - private Range BinarySearch(SortedList lst, long position) + private Range BinarySearch(SortedList lst, ulong position) { int left = 0; int right = lst.Count - 1; @@ -148,12 +148,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types Range rg = lst.Values[middle]; - if ((ulong)position >= rg.Start && (ulong)position < rg.End) + if (position >= rg.Start && position < rg.End) { return rg; } - if ((ulong)position < rg.Start) + if (position < rg.Start) { right = middle - 1; } @@ -166,7 +166,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types return null; } - private Range BinarySearchLt(SortedList lst, long position) + private Range BinarySearchLt(SortedList lst, ulong position) { Range ltRg = null; @@ -181,7 +181,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types Range rg = lst.Values[middle]; - if ((ulong)position < rg.Start) + if (position < rg.Start) { right = middle - 1; } @@ -189,7 +189,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types { left = middle + 1; - if ((ulong)position > rg.Start) + if (position > rg.Start) { ltRg = rg; } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs index 73f746e2..d6dbbc26 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs @@ -9,6 +9,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types public uint PageSize; public AddressSpaceFlags Flags; public uint Padding; - public long Offset; + public ulong Offset; } } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs index a853974b..b25d295a 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs @@ -5,8 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types [StructLayout(LayoutKind.Sequential)] struct FreeSpaceArguments { - public long Offset; - public uint Pages; - public uint PageSize; + public ulong Offset; + public uint Pages; + public uint PageSize; } } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs index 02e058df..278793a0 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs @@ -9,8 +9,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types public int Kind; public int NvMapHandle; public int PageSize; - public long BufferOffset; - public long MappingSize; - public long Offset; + public ulong BufferOffset; + public ulong MappingSize; + public ulong Offset; } } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs index 7f41f26a..8fc4646e 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs @@ -3,7 +3,7 @@ struct UnmapBufferArguments { #pragma warning disable CS0649 - public long Offset; + public ulong Offset; #pragma warning restore CS0649 } } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs index 4a532cd7..807e0c92 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs @@ -158,7 +158,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel { NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, commandBuffer.Mem); - var data = _memory.GetSpan((ulong)map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4); + var data = _memory.GetSpan(map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4); _device.Host1x.Submit(MemoryMarshal.Cast(data)); } @@ -253,12 +253,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel if (va != NvMemoryAllocator.PteUnmapped && va <= uint.MaxValue && (va + (uint)map.Size) <= uint.MaxValue) { _memoryAllocator.AllocateRange(va, (uint)map.Size, freeAddressStartPosition); - gmm.Map((ulong)map.Address, va, (uint)map.Size); - map.DmaMapAddress = (long)va; + gmm.Map(map.Address, va, (uint)map.Size); + map.DmaMapAddress = va; } else { - map.DmaMapAddress = unchecked((long)NvMemoryAllocator.PteUnmapped); + map.DmaMapAddress = NvMemoryAllocator.PteUnmapped; } } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs index a549c81c..8218aca8 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs @@ -134,7 +134,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap int size = BitUtils.AlignUp(map.Size, (int)MemoryManager.PageSize); - long address = arguments.Address; + ulong address = arguments.Address; if (address == 0) { diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs index efc0f2aa..2ec75fc9 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs @@ -5,11 +5,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap [StructLayout(LayoutKind.Sequential)] struct NvMapAlloc { - public int Handle; - public int HeapMask; - public int Flags; - public int Align; - public long Kind; - public long Address; + public int Handle; + public int HeapMask; + public int Flags; + public int Align; + public long Kind; + public ulong Address; } } \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs index d142b9f3..34bcbc64 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs @@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap [StructLayout(LayoutKind.Sequential)] struct NvMapFree { - public int Handle; - public int Padding; - public long Address; - public int Size; - public int Flags; + public int Handle; + public int Padding; + public ulong Address; + public int Size; + public int Flags; } } \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs index 88ec1487..c97cee49 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs @@ -5,15 +5,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap class NvMapHandle { #pragma warning disable CS0649 - public int Handle; - public int Id; + public int Handle; + public int Id; #pragma warning restore CS0649 - public int Size; - public int Align; - public int Kind; - public long Address; - public bool Allocated; - public long DmaMapAddress; + public int Size; + public int Align; + public int Kind; + public ulong Address; + public bool Allocated; + public ulong DmaMapAddress; private long _dupes; diff --git a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs index 1fef6860..cec37a58 100644 --- a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs +++ b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs @@ -308,11 +308,11 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger nvMapHandle = item.GraphicBuffer.Object.Buffer.NvMapId; } - int bufferOffset = item.GraphicBuffer.Object.Buffer.Surfaces[0].Offset; + ulong bufferOffset = (ulong)item.GraphicBuffer.Object.Buffer.Surfaces[0].Offset; NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(layer.Owner, nvMapHandle); - ulong frameBufferAddress = (ulong)(map.Address + bufferOffset); + ulong frameBufferAddress = map.Address + bufferOffset; Format format = ConvertColorFormat(item.GraphicBuffer.Object.Buffer.Surfaces[0].ColorFormat);