mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add OS thread ID info to the Resource Logger
This commit is contained in:
parent
62e9dc164d
commit
30e3cd1f38
3 changed files with 33 additions and 1 deletions
7
Penumbra/Interop/ProcessThreadApi.cs
Normal file
7
Penumbra/Interop/ProcessThreadApi.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace Penumbra.Interop;
|
||||||
|
|
||||||
|
public static partial class ProcessThreadApi
|
||||||
|
{
|
||||||
|
[LibraryImport("kernel32.dll")]
|
||||||
|
public static partial uint GetCurrentThreadId();
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using OtterGui.Classes;
|
using OtterGui.Classes;
|
||||||
using Penumbra.Collections;
|
using Penumbra.Collections;
|
||||||
using Penumbra.Enums;
|
using Penumbra.Enums;
|
||||||
|
using Penumbra.Interop;
|
||||||
using Penumbra.Interop.Structs;
|
using Penumbra.Interop.Structs;
|
||||||
using Penumbra.String;
|
using Penumbra.String;
|
||||||
using Penumbra.String.Classes;
|
using Penumbra.String.Classes;
|
||||||
|
|
@ -34,6 +35,7 @@ internal unsafe struct Record
|
||||||
public OptionalBool ReturnValue;
|
public OptionalBool ReturnValue;
|
||||||
public OptionalBool CustomLoad;
|
public OptionalBool CustomLoad;
|
||||||
public LoadState LoadState;
|
public LoadState LoadState;
|
||||||
|
public uint OsThreadId;
|
||||||
|
|
||||||
|
|
||||||
public static Record CreateRequest(CiByteString path, bool sync)
|
public static Record CreateRequest(CiByteString path, bool sync)
|
||||||
|
|
@ -54,6 +56,7 @@ internal unsafe struct Record
|
||||||
AssociatedGameObject = string.Empty,
|
AssociatedGameObject = string.Empty,
|
||||||
LoadState = LoadState.None,
|
LoadState = LoadState.None,
|
||||||
Crc64 = 0,
|
Crc64 = 0,
|
||||||
|
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Record CreateRequest(CiByteString path, bool sync, FullPath fullPath, ResolveData resolve)
|
public static Record CreateRequest(CiByteString path, bool sync, FullPath fullPath, ResolveData resolve)
|
||||||
|
|
@ -74,6 +77,7 @@ internal unsafe struct Record
|
||||||
AssociatedGameObject = string.Empty,
|
AssociatedGameObject = string.Empty,
|
||||||
LoadState = LoadState.None,
|
LoadState = LoadState.None,
|
||||||
Crc64 = fullPath.Crc64,
|
Crc64 = fullPath.Crc64,
|
||||||
|
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Record CreateDefaultLoad(CiByteString path, ResourceHandle* handle, ModCollection collection, string associatedGameObject)
|
public static Record CreateDefaultLoad(CiByteString path, ResourceHandle* handle, ModCollection collection, string associatedGameObject)
|
||||||
|
|
@ -96,6 +100,7 @@ internal unsafe struct Record
|
||||||
AssociatedGameObject = associatedGameObject,
|
AssociatedGameObject = associatedGameObject,
|
||||||
LoadState = handle->LoadState,
|
LoadState = handle->LoadState,
|
||||||
Crc64 = 0,
|
Crc64 = 0,
|
||||||
|
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,6 +123,7 @@ internal unsafe struct Record
|
||||||
AssociatedGameObject = associatedGameObject,
|
AssociatedGameObject = associatedGameObject,
|
||||||
LoadState = handle->LoadState,
|
LoadState = handle->LoadState,
|
||||||
Crc64 = path.Crc64,
|
Crc64 = path.Crc64,
|
||||||
|
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Record CreateDestruction(ResourceHandle* handle)
|
public static Record CreateDestruction(ResourceHandle* handle)
|
||||||
|
|
@ -140,6 +146,7 @@ internal unsafe struct Record
|
||||||
AssociatedGameObject = string.Empty,
|
AssociatedGameObject = string.Empty,
|
||||||
LoadState = handle->LoadState,
|
LoadState = handle->LoadState,
|
||||||
Crc64 = 0,
|
Crc64 = 0,
|
||||||
|
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,6 +168,7 @@ internal unsafe struct Record
|
||||||
AssociatedGameObject = string.Empty,
|
AssociatedGameObject = string.Empty,
|
||||||
LoadState = handle->LoadState,
|
LoadState = handle->LoadState,
|
||||||
Crc64 = 0,
|
Crc64 = 0,
|
||||||
|
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Record CreateResourceComplete(CiByteString path, ResourceHandle* handle, Utf8GamePath originalPath, ReadOnlySpan<byte> additionalData)
|
public static Record CreateResourceComplete(CiByteString path, ResourceHandle* handle, Utf8GamePath originalPath, ReadOnlySpan<byte> additionalData)
|
||||||
|
|
@ -181,6 +189,7 @@ internal unsafe struct Record
|
||||||
AssociatedGameObject = string.Empty,
|
AssociatedGameObject = string.Empty,
|
||||||
LoadState = handle->LoadState,
|
LoadState = handle->LoadState,
|
||||||
Crc64 = 0,
|
Crc64 = 0,
|
||||||
|
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static CiByteString CombinedPath(CiByteString path, ReadOnlySpan<byte> additionalData)
|
private static CiByteString CombinedPath(CiByteString path, ReadOnlySpan<byte> additionalData)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ internal sealed class ResourceWatcherTable : Table<Record>
|
||||||
new LoadStateColumn { Label = "State" },
|
new LoadStateColumn { Label = "State" },
|
||||||
new RefCountColumn { Label = "#Ref" },
|
new RefCountColumn { Label = "#Ref" },
|
||||||
new DateColumn { Label = "Time" },
|
new DateColumn { Label = "Time" },
|
||||||
new Crc64Column { Label = "Crc64" }
|
new Crc64Column { Label = "Crc64" },
|
||||||
|
new OsThreadColumn { Label = "TID" }
|
||||||
)
|
)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
@ -453,4 +454,19 @@ internal sealed class ResourceWatcherTable : Table<Record>
|
||||||
public override int Compare(Record lhs, Record rhs)
|
public override int Compare(Record lhs, Record rhs)
|
||||||
=> lhs.RefCount.CompareTo(rhs.RefCount);
|
=> lhs.RefCount.CompareTo(rhs.RefCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sealed class OsThreadColumn : ColumnString<Record>
|
||||||
|
{
|
||||||
|
public override float Width
|
||||||
|
=> 60 * UiHelpers.Scale;
|
||||||
|
|
||||||
|
public override string ToName(Record item)
|
||||||
|
=> item.OsThreadId.ToString();
|
||||||
|
|
||||||
|
public override void DrawColumn(Record item, int _)
|
||||||
|
=> ImGuiUtil.RightAlign(ToName(item));
|
||||||
|
|
||||||
|
public override int Compare(Record lhs, Record rhs)
|
||||||
|
=> lhs.OsThreadId.CompareTo(rhs.OsThreadId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue