mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 14:23:40 +01:00
Make IsMainThreadInPresent and CumulativePresentCalls clearer
This commit is contained in:
parent
6d8102dc79
commit
3f138c2600
2 changed files with 11 additions and 9 deletions
|
|
@ -217,7 +217,7 @@ internal class InterfaceManager : IInternalDisposableService
|
|||
|
||||
/// <summary>Gets a value indicating whether the main thread is executing <see cref="PresentDetour"/>.</summary>
|
||||
/// <remarks>This still will be <c>true</c> even when queried off the main thread.</remarks>
|
||||
public bool IsInPresent { get; private set; }
|
||||
public bool IsMainThreadInPresent { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating the native handle of the game main window.
|
||||
|
|
@ -249,9 +249,11 @@ internal class InterfaceManager : IInternalDisposableService
|
|||
/// </summary>
|
||||
public Task FontBuildTask => WhenFontsReady().dalamudAtlas!.BuildTask;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of calls to <see cref="PresentDetour"/> so far.
|
||||
/// </summary>
|
||||
/// <summary>Gets the number of calls to <see cref="PresentDetour"/> so far.</summary>
|
||||
/// <remarks>
|
||||
/// The value increases even when Dalamud is hidden via "/xlui hide".
|
||||
/// <see cref="DalamudInterface.FrameCount"/> does not.
|
||||
/// </remarks>
|
||||
public long CumulativePresentCalls { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -657,7 +659,7 @@ internal class InterfaceManager : IInternalDisposableService
|
|||
}
|
||||
|
||||
this.CumulativePresentCalls++;
|
||||
this.IsInPresent = true;
|
||||
this.IsMainThreadInPresent = true;
|
||||
|
||||
while (this.runBeforeImGuiRender.TryDequeue(out var action))
|
||||
action.InvokeSafely();
|
||||
|
|
@ -668,14 +670,14 @@ internal class InterfaceManager : IInternalDisposableService
|
|||
|
||||
RenderImGui(this.scene!);
|
||||
this.PostImGuiRender();
|
||||
this.IsInPresent = false;
|
||||
this.IsMainThreadInPresent = false;
|
||||
|
||||
return pRes;
|
||||
}
|
||||
|
||||
RenderImGui(this.scene!);
|
||||
this.PostImGuiRender();
|
||||
this.IsInPresent = false;
|
||||
this.IsMainThreadInPresent = false;
|
||||
|
||||
return this.presentHook!.Original(swapChain, syncInterval, presentFlags);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ internal sealed partial class TextureManager
|
|||
// Not sure why this and the below can't be unconditional RunOnFrameworkThread
|
||||
private async Task RunDuringPresent(Action action)
|
||||
{
|
||||
if (this.interfaceManager.IsInPresent && ThreadSafety.IsMainThread)
|
||||
if (this.interfaceManager.IsMainThreadInPresent && ThreadSafety.IsMainThread)
|
||||
action();
|
||||
else
|
||||
await this.interfaceManager.RunBeforeImGuiRender(action);
|
||||
|
|
@ -392,7 +392,7 @@ internal sealed partial class TextureManager
|
|||
/// <returns>The return value from the function.</returns>
|
||||
private async Task<T> RunDuringPresent<T>(Func<T> func)
|
||||
{
|
||||
if (this.interfaceManager.IsInPresent && ThreadSafety.IsMainThread)
|
||||
if (this.interfaceManager.IsMainThreadInPresent && ThreadSafety.IsMainThread)
|
||||
return func();
|
||||
return await this.interfaceManager.RunBeforeImGuiRender(func);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue