mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 14:27:45 +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>
|
/// <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets a value indicating the native handle of the game main window.
|
/// Gets a value indicating the native handle of the game main window.
|
||||||
|
|
@ -249,9 +249,11 @@ internal class InterfaceManager : IInternalDisposableService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Task FontBuildTask => WhenFontsReady().dalamudAtlas!.BuildTask;
|
public Task FontBuildTask => WhenFontsReady().dalamudAtlas!.BuildTask;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Gets the number of calls to <see cref="PresentDetour"/> so far.</summary>
|
||||||
/// Gets the number of calls to <see cref="PresentDetour"/> so far.
|
/// <remarks>
|
||||||
/// </summary>
|
/// The value increases even when Dalamud is hidden via "/xlui hide".
|
||||||
|
/// <see cref="DalamudInterface.FrameCount"/> does not.
|
||||||
|
/// </remarks>
|
||||||
public long CumulativePresentCalls { get; private set; }
|
public long CumulativePresentCalls { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -657,7 +659,7 @@ internal class InterfaceManager : IInternalDisposableService
|
||||||
}
|
}
|
||||||
|
|
||||||
this.CumulativePresentCalls++;
|
this.CumulativePresentCalls++;
|
||||||
this.IsInPresent = true;
|
this.IsMainThreadInPresent = true;
|
||||||
|
|
||||||
while (this.runBeforeImGuiRender.TryDequeue(out var action))
|
while (this.runBeforeImGuiRender.TryDequeue(out var action))
|
||||||
action.InvokeSafely();
|
action.InvokeSafely();
|
||||||
|
|
@ -668,14 +670,14 @@ internal class InterfaceManager : IInternalDisposableService
|
||||||
|
|
||||||
RenderImGui(this.scene!);
|
RenderImGui(this.scene!);
|
||||||
this.PostImGuiRender();
|
this.PostImGuiRender();
|
||||||
this.IsInPresent = false;
|
this.IsMainThreadInPresent = false;
|
||||||
|
|
||||||
return pRes;
|
return pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderImGui(this.scene!);
|
RenderImGui(this.scene!);
|
||||||
this.PostImGuiRender();
|
this.PostImGuiRender();
|
||||||
this.IsInPresent = false;
|
this.IsMainThreadInPresent = false;
|
||||||
|
|
||||||
return this.presentHook!.Original(swapChain, syncInterval, presentFlags);
|
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
|
// Not sure why this and the below can't be unconditional RunOnFrameworkThread
|
||||||
private async Task RunDuringPresent(Action action)
|
private async Task RunDuringPresent(Action action)
|
||||||
{
|
{
|
||||||
if (this.interfaceManager.IsInPresent && ThreadSafety.IsMainThread)
|
if (this.interfaceManager.IsMainThreadInPresent && ThreadSafety.IsMainThread)
|
||||||
action();
|
action();
|
||||||
else
|
else
|
||||||
await this.interfaceManager.RunBeforeImGuiRender(action);
|
await this.interfaceManager.RunBeforeImGuiRender(action);
|
||||||
|
|
@ -392,7 +392,7 @@ internal sealed partial class TextureManager
|
||||||
/// <returns>The return value from the function.</returns>
|
/// <returns>The return value from the function.</returns>
|
||||||
private async Task<T> RunDuringPresent<T>(Func<T> func)
|
private async Task<T> RunDuringPresent<T>(Func<T> func)
|
||||||
{
|
{
|
||||||
if (this.interfaceManager.IsInPresent && ThreadSafety.IsMainThread)
|
if (this.interfaceManager.IsMainThreadInPresent && ThreadSafety.IsMainThread)
|
||||||
return func();
|
return func();
|
||||||
return await this.interfaceManager.RunBeforeImGuiRender(func);
|
return await this.interfaceManager.RunBeforeImGuiRender(func);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue