Some improvements for nvnflinger (#555)
* Initial fixes for last release of libnx For now, the framebuffer aren't okay but it will not crash/ * Improve code reaadability in NvFlinger parsing * Make surfaces access more userfriendly * Add ColorFormat * Fix code style in ColorFormat.cs * Add multiple framebuffer support in nvnflinger This fix libnx console rendering * Move ReadStruct/WriteStruct to Ryujinx.Common * fix the last nit * Fix inverted color for R5G6B5 Also add some other format that libnx might uses. * Remove hardcoded BlockHeight in nvflinger
This commit is contained in:
parent
290f5e812e
commit
b4d91402c6
9 changed files with 693 additions and 84 deletions
37
Ryujinx.Common/StructIOExtension.cs
Normal file
37
Ryujinx.Common/StructIOExtension.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.Common
|
||||
{
|
||||
public static class StructIOExtension
|
||||
{
|
||||
public unsafe static T ReadStruct<T>(this BinaryReader reader) where T : struct
|
||||
{
|
||||
int size = Marshal.SizeOf<T>();
|
||||
|
||||
byte[] data = reader.ReadBytes(size);
|
||||
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
return Marshal.PtrToStructure<T>((IntPtr)ptr);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe static void WriteStruct<T>(this BinaryWriter writer, T value) where T : struct
|
||||
{
|
||||
long size = Marshal.SizeOf<T>();
|
||||
|
||||
byte[] data = new byte[size];
|
||||
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
Marshal.StructureToPtr<T>(value, (IntPtr)ptr, false);
|
||||
}
|
||||
|
||||
writer.Write(data);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue