Make surfaces access more userfriendly

This commit is contained in:
Thog 2019-01-04 15:47:09 +01:00
parent f647647c43
commit eb6532f129
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
2 changed files with 38 additions and 14 deletions

View file

@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
@ -60,6 +61,40 @@ namespace Ryujinx.HLE.HOS.Services.Android
public long Size;
}
[StructLayout(LayoutKind.Explicit)]
struct NvGraphicBufferSurfaceArray
{
[FieldOffset(0x0)]
private NvGraphicBufferSurface Surface0;
[FieldOffset(0x58)]
private NvGraphicBufferSurface Surface1;
[FieldOffset(0xb0)]
private NvGraphicBufferSurface Surface2;
public NvGraphicBufferSurface this[int index]
{
get
{
if (index == 0)
{
return Surface0;
}
else if (index == 1)
{
return Surface1;
}
else if (index == 2)
{
return Surface2;
}
throw new IndexOutOfRangeException();
}
}
}
[StructLayout(LayoutKind.Explicit, Size = 0x144)]
struct NvGraphicBuffer
{
@ -93,19 +128,8 @@ namespace Ryujinx.HLE.HOS.Services.Android
[FieldOffset(0x2C)]
public int PlanesCount;
// This throw an exception because C# is dumb and want to make every entries of the array appears at the FieldOffset
/*[FieldOffset(0x34)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public NvGraphicBufferSurface[] Surfaces;*/
[FieldOffset(0x34)]
public NvGraphicBufferSurface Surface0;
[FieldOffset(0x8c)]
public NvGraphicBufferSurface Surface1;
[FieldOffset(0xe4)]
public NvGraphicBufferSurface Surface2;
public NvGraphicBufferSurfaceArray Surfaces;
}
struct GbpBuffer

View file

@ -385,14 +385,14 @@ namespace Ryujinx.HLE.HOS.Services.Android
int fbWidth = _bufferQueue[slot].Data.Header.Width;
int fbHeight = _bufferQueue[slot].Data.Header.Height;
int nvMapHandle = _bufferQueue[slot].Data.Buffer.Surface0.NvMapHandle;
int nvMapHandle = _bufferQueue[slot].Data.Buffer.Surfaces[0].NvMapHandle;
if (nvMapHandle == 0)
{
nvMapHandle = _bufferQueue[slot].Data.Buffer.NvMapId;
}
int bufferOffset = _bufferQueue[slot].Data.Buffer.Surface0.Offset;
int bufferOffset = _bufferQueue[slot].Data.Buffer.Surfaces[0].Offset;
NvMapHandle map = NvMapIoctl.GetNvMap(context, nvMapHandle);