Merge branch 'refs/heads/Exter-N/reslogger-tid'

This commit is contained in:
Ottermandias 2025-07-05 22:03:14 +02:00
commit c0aa2e36ea
3 changed files with 33 additions and 1 deletions

View file

@ -0,0 +1,7 @@
namespace Penumbra.Interop;
public static partial class ProcessThreadApi
{
[LibraryImport("kernel32.dll")]
public static partial uint GetCurrentThreadId();
}

View file

@ -1,6 +1,7 @@
using OtterGui.Classes;
using Penumbra.Collections;
using Penumbra.Enums;
using Penumbra.Interop;
using Penumbra.Interop.Structs;
using Penumbra.String;
using Penumbra.String.Classes;
@ -34,6 +35,7 @@ internal unsafe struct Record
public OptionalBool ReturnValue;
public OptionalBool CustomLoad;
public LoadState LoadState;
public uint OsThreadId;
public static Record CreateRequest(CiByteString path, bool sync)
@ -54,6 +56,7 @@ internal unsafe struct Record
AssociatedGameObject = string.Empty,
LoadState = LoadState.None,
Crc64 = 0,
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
};
public static Record CreateRequest(CiByteString path, bool sync, FullPath fullPath, ResolveData resolve)
@ -74,6 +77,7 @@ internal unsafe struct Record
AssociatedGameObject = string.Empty,
LoadState = LoadState.None,
Crc64 = fullPath.Crc64,
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
};
public static Record CreateDefaultLoad(CiByteString path, ResourceHandle* handle, ModCollection collection, string associatedGameObject)
@ -96,6 +100,7 @@ internal unsafe struct Record
AssociatedGameObject = associatedGameObject,
LoadState = handle->LoadState,
Crc64 = 0,
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
};
}
@ -118,6 +123,7 @@ internal unsafe struct Record
AssociatedGameObject = associatedGameObject,
LoadState = handle->LoadState,
Crc64 = path.Crc64,
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
};
public static Record CreateDestruction(ResourceHandle* handle)
@ -140,6 +146,7 @@ internal unsafe struct Record
AssociatedGameObject = string.Empty,
LoadState = handle->LoadState,
Crc64 = 0,
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
};
}
@ -161,6 +168,7 @@ internal unsafe struct Record
AssociatedGameObject = string.Empty,
LoadState = handle->LoadState,
Crc64 = 0,
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
};
public static Record CreateResourceComplete(CiByteString path, ResourceHandle* handle, Utf8GamePath originalPath, ReadOnlySpan<byte> additionalData)
@ -181,6 +189,7 @@ internal unsafe struct Record
AssociatedGameObject = string.Empty,
LoadState = handle->LoadState,
Crc64 = 0,
OsThreadId = ProcessThreadApi.GetCurrentThreadId(),
};
private static CiByteString CombinedPath(CiByteString path, ReadOnlySpan<byte> additionalData)

View file

@ -30,7 +30,8 @@ internal sealed class ResourceWatcherTable : Table<Record>
new LoadStateColumn { Label = "State" },
new RefCountColumn { Label = "#Ref" },
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)
=> 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);
}
}