mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-17 05:17:42 +01:00
Assign debug names for textures
This commit is contained in:
parent
6a0f774625
commit
7f12e3f3da
10 changed files with 100 additions and 35 deletions
|
|
@ -49,6 +49,7 @@ internal sealed partial class TextureManager
|
|||
IDalamudTextureWrap wrap,
|
||||
TextureModificationArgs args = default,
|
||||
bool leaveWrapOpen = false,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
this.DynamicPriorityTextureLoader.LoadAsync<IDalamudTextureWrap>(
|
||||
null,
|
||||
|
|
@ -80,6 +81,7 @@ internal sealed partial class TextureManager
|
|||
true);
|
||||
this.BlameSetName(
|
||||
outWrap,
|
||||
debugName ??
|
||||
$"{nameof(this.CreateFromExistingTextureAsync)}({nameof(wrap)}, {nameof(args)}, {nameof(leaveWrapOpen)}, {nameof(cancellationToken)})");
|
||||
return outWrap;
|
||||
}
|
||||
|
|
@ -90,16 +92,19 @@ internal sealed partial class TextureManager
|
|||
/// <inheritdoc/>
|
||||
Task<IDalamudTextureWrap> ITextureProvider.CreateFromImGuiViewportAsync(
|
||||
ImGuiViewportTextureArgs args,
|
||||
CancellationToken cancellationToken) => this.CreateFromImGuiViewportAsync(args, null, cancellationToken);
|
||||
string? debugName,
|
||||
CancellationToken cancellationToken) =>
|
||||
this.CreateFromImGuiViewportAsync(args, null, debugName, cancellationToken);
|
||||
|
||||
/// <inheritdoc cref="ITextureProvider.CreateFromImGuiViewportAsync"/>
|
||||
public Task<IDalamudTextureWrap> CreateFromImGuiViewportAsync(
|
||||
ImGuiViewportTextureArgs args,
|
||||
LocalPlugin? ownerPlugin,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
args.ThrowOnInvalidValues();
|
||||
var t = new ViewportTextureWrap(args, ownerPlugin, cancellationToken);
|
||||
var t = new ViewportTextureWrap(args, debugName, ownerPlugin, cancellationToken);
|
||||
t.QueueUpdate();
|
||||
return t.FirstUpdateTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ internal sealed partial class TextureManager
|
|||
/// <inheritdoc/>
|
||||
public Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||
ReadOnlyMemory<byte> bytes,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||
null,
|
||||
|
|
@ -125,6 +126,7 @@ internal sealed partial class TextureManager
|
|||
() =>
|
||||
this.BlameSetName(
|
||||
this.NoThrottleCreateFromImage(bytes.ToArray(), ct),
|
||||
debugName ??
|
||||
$"{nameof(this.CreateFromImageAsync)}({nameof(bytes)}, {nameof(cancellationToken)})"),
|
||||
ct),
|
||||
cancellationToken);
|
||||
|
|
@ -133,6 +135,7 @@ internal sealed partial class TextureManager
|
|||
public Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||
Stream stream,
|
||||
bool leaveOpen = false,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||
null,
|
||||
|
|
@ -142,6 +145,7 @@ internal sealed partial class TextureManager
|
|||
await stream.CopyToAsync(ms, ct).ConfigureAwait(false);
|
||||
return this.BlameSetName(
|
||||
this.NoThrottleCreateFromImage(ms.GetBuffer(), ct),
|
||||
debugName ??
|
||||
$"{nameof(this.CreateFromImageAsync)}({nameof(stream)}, {nameof(leaveOpen)}, {nameof(cancellationToken)})");
|
||||
},
|
||||
cancellationToken,
|
||||
|
|
@ -151,21 +155,24 @@ internal sealed partial class TextureManager
|
|||
// It probably doesn't make sense to throttle this, as it copies the passed bytes to GPU without any transformation.
|
||||
public IDalamudTextureWrap CreateFromRaw(
|
||||
RawImageSpecification specs,
|
||||
ReadOnlySpan<byte> bytes) =>
|
||||
ReadOnlySpan<byte> bytes,
|
||||
string? debugName = null) =>
|
||||
this.BlameSetName(
|
||||
this.NoThrottleCreateFromRaw(specs, bytes),
|
||||
$"{nameof(this.CreateFromRaw)}({nameof(specs)}, {nameof(bytes)})");
|
||||
debugName ?? $"{nameof(this.CreateFromRaw)}({nameof(specs)}, {nameof(bytes)})");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<IDalamudTextureWrap> CreateFromRawAsync(
|
||||
RawImageSpecification specs,
|
||||
ReadOnlyMemory<byte> bytes,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||
null,
|
||||
_ => Task.FromResult(
|
||||
this.BlameSetName(
|
||||
this.NoThrottleCreateFromRaw(specs, bytes.Span),
|
||||
debugName ??
|
||||
$"{nameof(this.CreateFromRawAsync)}({nameof(specs)}, {nameof(bytes)}, {nameof(cancellationToken)})")),
|
||||
cancellationToken);
|
||||
|
||||
|
|
@ -174,6 +181,7 @@ internal sealed partial class TextureManager
|
|||
RawImageSpecification specs,
|
||||
Stream stream,
|
||||
bool leaveOpen = false,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||
null,
|
||||
|
|
@ -183,6 +191,7 @@ internal sealed partial class TextureManager
|
|||
await stream.CopyToAsync(ms, ct).ConfigureAwait(false);
|
||||
return this.BlameSetName(
|
||||
this.NoThrottleCreateFromRaw(specs, ms.GetBuffer().AsSpan(0, (int)ms.Length)),
|
||||
debugName ??
|
||||
$"{nameof(this.CreateFromRawAsync)}({nameof(specs)}, {nameof(stream)}, {nameof(leaveOpen)}, {nameof(cancellationToken)})");
|
||||
},
|
||||
cancellationToken,
|
||||
|
|
@ -197,13 +206,14 @@ internal sealed partial class TextureManager
|
|||
/// <inheritdoc/>
|
||||
public Task<IDalamudTextureWrap> CreateFromTexFileAsync(
|
||||
TexFile file,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||
null,
|
||||
_ => Task.FromResult(
|
||||
this.BlameSetName(
|
||||
this.NoThrottleCreateFromTexFile(file),
|
||||
$"{nameof(this.CreateFromTexFile)}({nameof(file)})")),
|
||||
debugName ?? $"{nameof(this.CreateFromTexFile)}({nameof(file)})")),
|
||||
cancellationToken);
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ internal sealed partial class TextureManagerPluginScoped
|
|||
IDalamudTextureWrap wrap,
|
||||
TextureModificationArgs args = default,
|
||||
bool leaveWrapOpen = false,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var manager = await this.ManagerTask;
|
||||
|
|
@ -146,6 +147,7 @@ internal sealed partial class TextureManagerPluginScoped
|
|||
wrap,
|
||||
args,
|
||||
leaveWrapOpen,
|
||||
debugName,
|
||||
cancellationToken);
|
||||
manager.Blame(textureWrap, this.plugin);
|
||||
return textureWrap;
|
||||
|
|
@ -154,10 +156,11 @@ internal sealed partial class TextureManagerPluginScoped
|
|||
/// <inheritdoc/>
|
||||
public async Task<IDalamudTextureWrap> CreateFromImGuiViewportAsync(
|
||||
ImGuiViewportTextureArgs args,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var manager = await this.ManagerTask;
|
||||
var textureWrap = await manager.CreateFromImGuiViewportAsync(args, this.plugin, cancellationToken);
|
||||
var textureWrap = await manager.CreateFromImGuiViewportAsync(args, this.plugin, debugName, cancellationToken);
|
||||
manager.Blame(textureWrap, this.plugin);
|
||||
return textureWrap;
|
||||
}
|
||||
|
|
@ -165,10 +168,11 @@ internal sealed partial class TextureManagerPluginScoped
|
|||
/// <inheritdoc/>
|
||||
public async Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||
ReadOnlyMemory<byte> bytes,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var manager = await this.ManagerTask;
|
||||
var textureWrap = await manager.CreateFromImageAsync(bytes, cancellationToken);
|
||||
var textureWrap = await manager.CreateFromImageAsync(bytes, debugName, cancellationToken);
|
||||
manager.Blame(textureWrap, this.plugin);
|
||||
return textureWrap;
|
||||
}
|
||||
|
|
@ -177,10 +181,11 @@ internal sealed partial class TextureManagerPluginScoped
|
|||
public async Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||
Stream stream,
|
||||
bool leaveOpen = false,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var manager = await this.ManagerTask;
|
||||
var textureWrap = await manager.CreateFromImageAsync(stream, leaveOpen, cancellationToken);
|
||||
var textureWrap = await manager.CreateFromImageAsync(stream, leaveOpen, debugName, cancellationToken);
|
||||
manager.Blame(textureWrap, this.plugin);
|
||||
return textureWrap;
|
||||
}
|
||||
|
|
@ -188,10 +193,11 @@ internal sealed partial class TextureManagerPluginScoped
|
|||
/// <inheritdoc/>
|
||||
public IDalamudTextureWrap CreateFromRaw(
|
||||
RawImageSpecification specs,
|
||||
ReadOnlySpan<byte> bytes)
|
||||
ReadOnlySpan<byte> bytes,
|
||||
string? debugName = null)
|
||||
{
|
||||
var manager = this.ManagerOrThrow;
|
||||
var textureWrap = manager.CreateFromRaw(specs, bytes);
|
||||
var textureWrap = manager.CreateFromRaw(specs, bytes, debugName);
|
||||
manager.Blame(textureWrap, this.plugin);
|
||||
return textureWrap;
|
||||
}
|
||||
|
|
@ -200,10 +206,11 @@ internal sealed partial class TextureManagerPluginScoped
|
|||
public async Task<IDalamudTextureWrap> CreateFromRawAsync(
|
||||
RawImageSpecification specs,
|
||||
ReadOnlyMemory<byte> bytes,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var manager = await this.ManagerTask;
|
||||
var textureWrap = await manager.CreateFromRawAsync(specs, bytes, cancellationToken);
|
||||
var textureWrap = await manager.CreateFromRawAsync(specs, bytes, debugName, cancellationToken);
|
||||
manager.Blame(textureWrap, this.plugin);
|
||||
return textureWrap;
|
||||
}
|
||||
|
|
@ -213,10 +220,11 @@ internal sealed partial class TextureManagerPluginScoped
|
|||
RawImageSpecification specs,
|
||||
Stream stream,
|
||||
bool leaveOpen = false,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var manager = await this.ManagerTask;
|
||||
var textureWrap = await manager.CreateFromRawAsync(specs, stream, leaveOpen, cancellationToken);
|
||||
var textureWrap = await manager.CreateFromRawAsync(specs, stream, leaveOpen, debugName, cancellationToken);
|
||||
manager.Blame(textureWrap, this.plugin);
|
||||
return textureWrap;
|
||||
}
|
||||
|
|
@ -233,10 +241,11 @@ internal sealed partial class TextureManagerPluginScoped
|
|||
/// <inheritdoc/>
|
||||
public async Task<IDalamudTextureWrap> CreateFromTexFileAsync(
|
||||
TexFile file,
|
||||
string? debugName = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var manager = await this.ManagerTask;
|
||||
var textureWrap = await manager.CreateFromTexFileAsync(file, cancellationToken);
|
||||
var textureWrap = await manager.CreateFromTexFileAsync(file, debugName, cancellationToken);
|
||||
manager.Blame(textureWrap, this.plugin);
|
||||
return textureWrap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ namespace Dalamud.Interface.Textures.Internal;
|
|||
/// <summary>A texture wrap that takes its buffer from the frame buffer (of swap chain).</summary>
|
||||
internal sealed class ViewportTextureWrap : IDalamudTextureWrap, IDeferredDisposable
|
||||
{
|
||||
private readonly string? debugName;
|
||||
private readonly LocalPlugin? ownerPlugin;
|
||||
private readonly CancellationToken cancellationToken;
|
||||
private readonly TaskCompletionSource<IDalamudTextureWrap> firstUpdateTaskCompletionSource = new();
|
||||
|
|
@ -34,12 +35,14 @@ internal sealed class ViewportTextureWrap : IDalamudTextureWrap, IDeferredDispos
|
|||
|
||||
/// <summary>Initializes a new instance of the <see cref="ViewportTextureWrap"/> class.</summary>
|
||||
/// <param name="args">The arguments for creating a texture.</param>
|
||||
/// <param name="debugName">Name for debug display purposes.</param>
|
||||
/// <param name="ownerPlugin">The owner plugin.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
public ViewportTextureWrap(
|
||||
ImGuiViewportTextureArgs args, LocalPlugin? ownerPlugin, CancellationToken cancellationToken)
|
||||
ImGuiViewportTextureArgs args, string? debugName, LocalPlugin? ownerPlugin, CancellationToken cancellationToken)
|
||||
{
|
||||
this.args = args;
|
||||
this.debugName = debugName;
|
||||
this.ownerPlugin = ownerPlugin;
|
||||
this.cancellationToken = cancellationToken;
|
||||
}
|
||||
|
|
@ -151,7 +154,7 @@ internal sealed class ViewportTextureWrap : IDalamudTextureWrap, IDeferredDispos
|
|||
Service<TextureManager>.Get().Blame(this, this.ownerPlugin);
|
||||
Service<TextureManager>.Get().BlameSetName(
|
||||
this,
|
||||
$"{nameof(ViewportTextureWrap)}({this.args})");
|
||||
this.debugName ?? $"{nameof(ViewportTextureWrap)}({this.args})");
|
||||
}
|
||||
|
||||
// context.Get()->CopyResource((ID3D11Resource*)this.tex.Get(), (ID3D11Resource*)backBuffer.Get());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue