Make surfaces access more userfriendly
This commit is contained in:
parent
f647647c43
commit
eb6532f129
2 changed files with 38 additions and 14 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
@ -60,6 +61,40 @@ namespace Ryujinx.HLE.HOS.Services.Android
|
||||||
public long Size;
|
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)]
|
[StructLayout(LayoutKind.Explicit, Size = 0x144)]
|
||||||
struct NvGraphicBuffer
|
struct NvGraphicBuffer
|
||||||
{
|
{
|
||||||
|
@ -93,19 +128,8 @@ namespace Ryujinx.HLE.HOS.Services.Android
|
||||||
[FieldOffset(0x2C)]
|
[FieldOffset(0x2C)]
|
||||||
public int PlanesCount;
|
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)]
|
[FieldOffset(0x34)]
|
||||||
public NvGraphicBufferSurface Surface0;
|
public NvGraphicBufferSurfaceArray Surfaces;
|
||||||
|
|
||||||
[FieldOffset(0x8c)]
|
|
||||||
public NvGraphicBufferSurface Surface1;
|
|
||||||
|
|
||||||
[FieldOffset(0xe4)]
|
|
||||||
public NvGraphicBufferSurface Surface2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GbpBuffer
|
struct GbpBuffer
|
||||||
|
|
|
@ -385,14 +385,14 @@ namespace Ryujinx.HLE.HOS.Services.Android
|
||||||
int fbWidth = _bufferQueue[slot].Data.Header.Width;
|
int fbWidth = _bufferQueue[slot].Data.Header.Width;
|
||||||
int fbHeight = _bufferQueue[slot].Data.Header.Height;
|
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)
|
if (nvMapHandle == 0)
|
||||||
{
|
{
|
||||||
nvMapHandle = _bufferQueue[slot].Data.Buffer.NvMapId;
|
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);
|
NvMapHandle map = NvMapIoctl.GetNvMap(context, nvMapHandle);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue