From 88593bf8727e0da05a8f319951dce19f27e287d6 Mon Sep 17 00:00:00 2001 From: Thomas Guillemard Date: Fri, 8 Nov 2019 15:49:28 +0100 Subject: [PATCH] Add detail of ZbcSetTableArguments (#810) * Add detail of ZbcSetTableArguments This is a missing part of the #800 PR that cause an assert to be triggered in debug mode. Also, remove Fence in SurfaceFlinger as it's a duplicate of NvFence. * Fix critical issue in size checking of ioctl oops --- Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs | 2 +- .../Types/ZbcSetTableArguments.cs | 43 ++++++++++++++++++- .../Services/SurfaceFlinger/Types/Fence.cs | 11 ----- .../SurfaceFlinger/Types/MultiFence.cs | 11 ++--- 4 files changed, 48 insertions(+), 19 deletions(-) delete mode 100644 Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Fence.cs diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs index 9e22d17e..2b9f09fa 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs @@ -91,7 +91,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (isRead && isWrite) { - if (outputDataPosition < inputDataSize) + if (outputDataSize < inputDataSize) { arguments = null; diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs index e21e437e..ed74cc26 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs @@ -1,10 +1,49 @@ -using System.Runtime.InteropServices; +using System; +using System.Runtime.InteropServices; namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types { + [StructLayout(LayoutKind.Sequential)] + struct ZbcColorArray + { + private uint element0; + private uint element1; + private uint element2; + private uint element3; + + public uint this[int index] + { + get + { + if (index == 0) + { + return element0; + } + else if (index == 1) + { + return element1; + } + else if (index == 2) + { + return element2; + } + else if (index == 2) + { + return element3; + } + + throw new IndexOutOfRangeException(); + } + } + } + [StructLayout(LayoutKind.Sequential)] struct ZbcSetTableArguments { - // TODO + public ZbcColorArray ColorDs; + public ZbcColorArray ColorL2; + public uint Depth; + public uint Format; + public uint Type; } } diff --git a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Fence.cs b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Fence.cs deleted file mode 100644 index 356a1232..00000000 --- a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Fence.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger -{ - [StructLayout(LayoutKind.Sequential, Size = 0x8)] - struct Fence - { - public int Id; - public int Value; - } -} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/MultiFence.cs b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/MultiFence.cs index 97ad3e20..20e0723b 100644 --- a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/MultiFence.cs +++ b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/MultiFence.cs @@ -1,4 +1,5 @@ -using System.Runtime.InteropServices; +using Ryujinx.HLE.HOS.Services.Nv.Types; +using System.Runtime.InteropServices; namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { @@ -9,15 +10,15 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public int FenceCount; [FieldOffset(0x4)] - public Fence Fence0; + public NvFence Fence0; [FieldOffset(0xC)] - public Fence Fence1; + public NvFence Fence1; [FieldOffset(0x14)] - public Fence Fence2; + public NvFence Fence2; [FieldOffset(0x1C)] - public Fence Fence3; + public NvFence Fence3; } } \ No newline at end of file