mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +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
|
|
@ -276,7 +276,9 @@ internal class PluginImageCache : IDisposable, IServiceType
|
||||||
// FIXME(goat): This is a hack around this call failing randomly in certain situations. Might be related to not being called on the main thread.
|
// FIXME(goat): This is a hack around this call failing randomly in certain situations. Might be related to not being called on the main thread.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
image = await textureManager.CreateFromImageAsync(bytes);
|
image = await textureManager.CreateFromImageAsync(
|
||||||
|
bytes,
|
||||||
|
$"{nameof(PluginImageCache)}({name} for {manifest.InternalName} at {loc})");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -586,8 +586,12 @@ internal sealed partial class FontAtlasFactory
|
||||||
var bpp = use4 ? 2 : 4;
|
var bpp = use4 ? 2 : 4;
|
||||||
var width = this.NewImAtlas.TexWidth;
|
var width = this.NewImAtlas.TexWidth;
|
||||||
var height = this.NewImAtlas.TexHeight;
|
var height = this.NewImAtlas.TexHeight;
|
||||||
foreach (ref var texture in this.data.ImTextures.DataSpan)
|
var textureSpan = this.data.ImTextures.DataSpan;
|
||||||
|
for (var i = 0; i < textureSpan.Length; i++)
|
||||||
{
|
{
|
||||||
|
ref var texture = ref textureSpan[i];
|
||||||
|
var name =
|
||||||
|
$"FontAtlas.{ this.data.Owner?.Name ?? "(no owner or name)"}[0x{(long)this.data.Atlas.NativePtr:X}][{i}]";
|
||||||
if (texture.TexID != 0)
|
if (texture.TexID != 0)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
|
|
@ -596,7 +600,8 @@ internal sealed partial class FontAtlasFactory
|
||||||
{
|
{
|
||||||
var wrap = this.factory.TextureManager.CreateFromRaw(
|
var wrap = this.factory.TextureManager.CreateFromRaw(
|
||||||
RawImageSpecification.Rgba32(width, height),
|
RawImageSpecification.Rgba32(width, height),
|
||||||
new(texture.TexPixelsRGBA32, width * height * 4));
|
new(texture.TexPixelsRGBA32, width * height * 4),
|
||||||
|
name);
|
||||||
this.data.AddExistingTexture(wrap);
|
this.data.AddExistingTexture(wrap);
|
||||||
texture.TexID = wrap.ImGuiHandle;
|
texture.TexID = wrap.ImGuiHandle;
|
||||||
}
|
}
|
||||||
|
|
@ -640,7 +645,8 @@ internal sealed partial class FontAtlasFactory
|
||||||
height,
|
height,
|
||||||
(int)(use4 ? Format.B4G4R4A4_UNorm : Format.B8G8R8A8_UNorm),
|
(int)(use4 ? Format.B4G4R4A4_UNorm : Format.B8G8R8A8_UNorm),
|
||||||
width * bpp),
|
width * bpp),
|
||||||
buf);
|
buf,
|
||||||
|
name);
|
||||||
this.data.AddExistingTexture(wrap);
|
this.data.AddExistingTexture(wrap);
|
||||||
texture.TexID = wrap.ImGuiHandle;
|
texture.TexID = wrap.ImGuiHandle;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -362,7 +362,8 @@ internal sealed partial class FontAtlasFactory
|
||||||
? DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM
|
? DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM
|
||||||
: DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM),
|
: DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM),
|
||||||
texFile.Header.Width * bpp),
|
texFile.Header.Width * bpp),
|
||||||
buffer));
|
buffer,
|
||||||
|
$"{nameof(FontAtlasFactory)}:{texPathFormat.Format(fileIndex)}:{channelIndex}"));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ internal sealed partial class TextureManager
|
||||||
IDalamudTextureWrap wrap,
|
IDalamudTextureWrap wrap,
|
||||||
TextureModificationArgs args = default,
|
TextureModificationArgs args = default,
|
||||||
bool leaveWrapOpen = false,
|
bool leaveWrapOpen = false,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default) =>
|
CancellationToken cancellationToken = default) =>
|
||||||
this.DynamicPriorityTextureLoader.LoadAsync<IDalamudTextureWrap>(
|
this.DynamicPriorityTextureLoader.LoadAsync<IDalamudTextureWrap>(
|
||||||
null,
|
null,
|
||||||
|
|
@ -80,6 +81,7 @@ internal sealed partial class TextureManager
|
||||||
true);
|
true);
|
||||||
this.BlameSetName(
|
this.BlameSetName(
|
||||||
outWrap,
|
outWrap,
|
||||||
|
debugName ??
|
||||||
$"{nameof(this.CreateFromExistingTextureAsync)}({nameof(wrap)}, {nameof(args)}, {nameof(leaveWrapOpen)}, {nameof(cancellationToken)})");
|
$"{nameof(this.CreateFromExistingTextureAsync)}({nameof(wrap)}, {nameof(args)}, {nameof(leaveWrapOpen)}, {nameof(cancellationToken)})");
|
||||||
return outWrap;
|
return outWrap;
|
||||||
}
|
}
|
||||||
|
|
@ -90,16 +92,19 @@ internal sealed partial class TextureManager
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
Task<IDalamudTextureWrap> ITextureProvider.CreateFromImGuiViewportAsync(
|
Task<IDalamudTextureWrap> ITextureProvider.CreateFromImGuiViewportAsync(
|
||||||
ImGuiViewportTextureArgs args,
|
ImGuiViewportTextureArgs args,
|
||||||
CancellationToken cancellationToken) => this.CreateFromImGuiViewportAsync(args, null, cancellationToken);
|
string? debugName,
|
||||||
|
CancellationToken cancellationToken) =>
|
||||||
|
this.CreateFromImGuiViewportAsync(args, null, debugName, cancellationToken);
|
||||||
|
|
||||||
/// <inheritdoc cref="ITextureProvider.CreateFromImGuiViewportAsync"/>
|
/// <inheritdoc cref="ITextureProvider.CreateFromImGuiViewportAsync"/>
|
||||||
public Task<IDalamudTextureWrap> CreateFromImGuiViewportAsync(
|
public Task<IDalamudTextureWrap> CreateFromImGuiViewportAsync(
|
||||||
ImGuiViewportTextureArgs args,
|
ImGuiViewportTextureArgs args,
|
||||||
LocalPlugin? ownerPlugin,
|
LocalPlugin? ownerPlugin,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
args.ThrowOnInvalidValues();
|
args.ThrowOnInvalidValues();
|
||||||
var t = new ViewportTextureWrap(args, ownerPlugin, cancellationToken);
|
var t = new ViewportTextureWrap(args, debugName, ownerPlugin, cancellationToken);
|
||||||
t.QueueUpdate();
|
t.QueueUpdate();
|
||||||
return t.FirstUpdateTask;
|
return t.FirstUpdateTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ internal sealed partial class TextureManager
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Task<IDalamudTextureWrap> CreateFromImageAsync(
|
public Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||||
ReadOnlyMemory<byte> bytes,
|
ReadOnlyMemory<byte> bytes,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default) =>
|
CancellationToken cancellationToken = default) =>
|
||||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||||
null,
|
null,
|
||||||
|
|
@ -125,6 +126,7 @@ internal sealed partial class TextureManager
|
||||||
() =>
|
() =>
|
||||||
this.BlameSetName(
|
this.BlameSetName(
|
||||||
this.NoThrottleCreateFromImage(bytes.ToArray(), ct),
|
this.NoThrottleCreateFromImage(bytes.ToArray(), ct),
|
||||||
|
debugName ??
|
||||||
$"{nameof(this.CreateFromImageAsync)}({nameof(bytes)}, {nameof(cancellationToken)})"),
|
$"{nameof(this.CreateFromImageAsync)}({nameof(bytes)}, {nameof(cancellationToken)})"),
|
||||||
ct),
|
ct),
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
@ -133,6 +135,7 @@ internal sealed partial class TextureManager
|
||||||
public Task<IDalamudTextureWrap> CreateFromImageAsync(
|
public Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||||
Stream stream,
|
Stream stream,
|
||||||
bool leaveOpen = false,
|
bool leaveOpen = false,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default) =>
|
CancellationToken cancellationToken = default) =>
|
||||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||||
null,
|
null,
|
||||||
|
|
@ -142,6 +145,7 @@ internal sealed partial class TextureManager
|
||||||
await stream.CopyToAsync(ms, ct).ConfigureAwait(false);
|
await stream.CopyToAsync(ms, ct).ConfigureAwait(false);
|
||||||
return this.BlameSetName(
|
return this.BlameSetName(
|
||||||
this.NoThrottleCreateFromImage(ms.GetBuffer(), ct),
|
this.NoThrottleCreateFromImage(ms.GetBuffer(), ct),
|
||||||
|
debugName ??
|
||||||
$"{nameof(this.CreateFromImageAsync)}({nameof(stream)}, {nameof(leaveOpen)}, {nameof(cancellationToken)})");
|
$"{nameof(this.CreateFromImageAsync)}({nameof(stream)}, {nameof(leaveOpen)}, {nameof(cancellationToken)})");
|
||||||
},
|
},
|
||||||
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.
|
// It probably doesn't make sense to throttle this, as it copies the passed bytes to GPU without any transformation.
|
||||||
public IDalamudTextureWrap CreateFromRaw(
|
public IDalamudTextureWrap CreateFromRaw(
|
||||||
RawImageSpecification specs,
|
RawImageSpecification specs,
|
||||||
ReadOnlySpan<byte> bytes) =>
|
ReadOnlySpan<byte> bytes,
|
||||||
|
string? debugName = null) =>
|
||||||
this.BlameSetName(
|
this.BlameSetName(
|
||||||
this.NoThrottleCreateFromRaw(specs, bytes),
|
this.NoThrottleCreateFromRaw(specs, bytes),
|
||||||
$"{nameof(this.CreateFromRaw)}({nameof(specs)}, {nameof(bytes)})");
|
debugName ?? $"{nameof(this.CreateFromRaw)}({nameof(specs)}, {nameof(bytes)})");
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Task<IDalamudTextureWrap> CreateFromRawAsync(
|
public Task<IDalamudTextureWrap> CreateFromRawAsync(
|
||||||
RawImageSpecification specs,
|
RawImageSpecification specs,
|
||||||
ReadOnlyMemory<byte> bytes,
|
ReadOnlyMemory<byte> bytes,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default) =>
|
CancellationToken cancellationToken = default) =>
|
||||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||||
null,
|
null,
|
||||||
_ => Task.FromResult(
|
_ => Task.FromResult(
|
||||||
this.BlameSetName(
|
this.BlameSetName(
|
||||||
this.NoThrottleCreateFromRaw(specs, bytes.Span),
|
this.NoThrottleCreateFromRaw(specs, bytes.Span),
|
||||||
|
debugName ??
|
||||||
$"{nameof(this.CreateFromRawAsync)}({nameof(specs)}, {nameof(bytes)}, {nameof(cancellationToken)})")),
|
$"{nameof(this.CreateFromRawAsync)}({nameof(specs)}, {nameof(bytes)}, {nameof(cancellationToken)})")),
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
|
|
@ -174,6 +181,7 @@ internal sealed partial class TextureManager
|
||||||
RawImageSpecification specs,
|
RawImageSpecification specs,
|
||||||
Stream stream,
|
Stream stream,
|
||||||
bool leaveOpen = false,
|
bool leaveOpen = false,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default) =>
|
CancellationToken cancellationToken = default) =>
|
||||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||||
null,
|
null,
|
||||||
|
|
@ -183,6 +191,7 @@ internal sealed partial class TextureManager
|
||||||
await stream.CopyToAsync(ms, ct).ConfigureAwait(false);
|
await stream.CopyToAsync(ms, ct).ConfigureAwait(false);
|
||||||
return this.BlameSetName(
|
return this.BlameSetName(
|
||||||
this.NoThrottleCreateFromRaw(specs, ms.GetBuffer().AsSpan(0, (int)ms.Length)),
|
this.NoThrottleCreateFromRaw(specs, ms.GetBuffer().AsSpan(0, (int)ms.Length)),
|
||||||
|
debugName ??
|
||||||
$"{nameof(this.CreateFromRawAsync)}({nameof(specs)}, {nameof(stream)}, {nameof(leaveOpen)}, {nameof(cancellationToken)})");
|
$"{nameof(this.CreateFromRawAsync)}({nameof(specs)}, {nameof(stream)}, {nameof(leaveOpen)}, {nameof(cancellationToken)})");
|
||||||
},
|
},
|
||||||
cancellationToken,
|
cancellationToken,
|
||||||
|
|
@ -197,13 +206,14 @@ internal sealed partial class TextureManager
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Task<IDalamudTextureWrap> CreateFromTexFileAsync(
|
public Task<IDalamudTextureWrap> CreateFromTexFileAsync(
|
||||||
TexFile file,
|
TexFile file,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default) =>
|
CancellationToken cancellationToken = default) =>
|
||||||
this.DynamicPriorityTextureLoader.LoadAsync(
|
this.DynamicPriorityTextureLoader.LoadAsync(
|
||||||
null,
|
null,
|
||||||
_ => Task.FromResult(
|
_ => Task.FromResult(
|
||||||
this.BlameSetName(
|
this.BlameSetName(
|
||||||
this.NoThrottleCreateFromTexFile(file),
|
this.NoThrottleCreateFromTexFile(file),
|
||||||
$"{nameof(this.CreateFromTexFile)}({nameof(file)})")),
|
debugName ?? $"{nameof(this.CreateFromTexFile)}({nameof(file)})")),
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@ internal sealed partial class TextureManagerPluginScoped
|
||||||
IDalamudTextureWrap wrap,
|
IDalamudTextureWrap wrap,
|
||||||
TextureModificationArgs args = default,
|
TextureModificationArgs args = default,
|
||||||
bool leaveWrapOpen = false,
|
bool leaveWrapOpen = false,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var manager = await this.ManagerTask;
|
var manager = await this.ManagerTask;
|
||||||
|
|
@ -146,6 +147,7 @@ internal sealed partial class TextureManagerPluginScoped
|
||||||
wrap,
|
wrap,
|
||||||
args,
|
args,
|
||||||
leaveWrapOpen,
|
leaveWrapOpen,
|
||||||
|
debugName,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
manager.Blame(textureWrap, this.plugin);
|
manager.Blame(textureWrap, this.plugin);
|
||||||
return textureWrap;
|
return textureWrap;
|
||||||
|
|
@ -154,10 +156,11 @@ internal sealed partial class TextureManagerPluginScoped
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<IDalamudTextureWrap> CreateFromImGuiViewportAsync(
|
public async Task<IDalamudTextureWrap> CreateFromImGuiViewportAsync(
|
||||||
ImGuiViewportTextureArgs args,
|
ImGuiViewportTextureArgs args,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var manager = await this.ManagerTask;
|
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);
|
manager.Blame(textureWrap, this.plugin);
|
||||||
return textureWrap;
|
return textureWrap;
|
||||||
}
|
}
|
||||||
|
|
@ -165,10 +168,11 @@ internal sealed partial class TextureManagerPluginScoped
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<IDalamudTextureWrap> CreateFromImageAsync(
|
public async Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||||
ReadOnlyMemory<byte> bytes,
|
ReadOnlyMemory<byte> bytes,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var manager = await this.ManagerTask;
|
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);
|
manager.Blame(textureWrap, this.plugin);
|
||||||
return textureWrap;
|
return textureWrap;
|
||||||
}
|
}
|
||||||
|
|
@ -177,10 +181,11 @@ internal sealed partial class TextureManagerPluginScoped
|
||||||
public async Task<IDalamudTextureWrap> CreateFromImageAsync(
|
public async Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||||
Stream stream,
|
Stream stream,
|
||||||
bool leaveOpen = false,
|
bool leaveOpen = false,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var manager = await this.ManagerTask;
|
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);
|
manager.Blame(textureWrap, this.plugin);
|
||||||
return textureWrap;
|
return textureWrap;
|
||||||
}
|
}
|
||||||
|
|
@ -188,10 +193,11 @@ internal sealed partial class TextureManagerPluginScoped
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IDalamudTextureWrap CreateFromRaw(
|
public IDalamudTextureWrap CreateFromRaw(
|
||||||
RawImageSpecification specs,
|
RawImageSpecification specs,
|
||||||
ReadOnlySpan<byte> bytes)
|
ReadOnlySpan<byte> bytes,
|
||||||
|
string? debugName = null)
|
||||||
{
|
{
|
||||||
var manager = this.ManagerOrThrow;
|
var manager = this.ManagerOrThrow;
|
||||||
var textureWrap = manager.CreateFromRaw(specs, bytes);
|
var textureWrap = manager.CreateFromRaw(specs, bytes, debugName);
|
||||||
manager.Blame(textureWrap, this.plugin);
|
manager.Blame(textureWrap, this.plugin);
|
||||||
return textureWrap;
|
return textureWrap;
|
||||||
}
|
}
|
||||||
|
|
@ -200,10 +206,11 @@ internal sealed partial class TextureManagerPluginScoped
|
||||||
public async Task<IDalamudTextureWrap> CreateFromRawAsync(
|
public async Task<IDalamudTextureWrap> CreateFromRawAsync(
|
||||||
RawImageSpecification specs,
|
RawImageSpecification specs,
|
||||||
ReadOnlyMemory<byte> bytes,
|
ReadOnlyMemory<byte> bytes,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var manager = await this.ManagerTask;
|
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);
|
manager.Blame(textureWrap, this.plugin);
|
||||||
return textureWrap;
|
return textureWrap;
|
||||||
}
|
}
|
||||||
|
|
@ -213,10 +220,11 @@ internal sealed partial class TextureManagerPluginScoped
|
||||||
RawImageSpecification specs,
|
RawImageSpecification specs,
|
||||||
Stream stream,
|
Stream stream,
|
||||||
bool leaveOpen = false,
|
bool leaveOpen = false,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var manager = await this.ManagerTask;
|
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);
|
manager.Blame(textureWrap, this.plugin);
|
||||||
return textureWrap;
|
return textureWrap;
|
||||||
}
|
}
|
||||||
|
|
@ -233,10 +241,11 @@ internal sealed partial class TextureManagerPluginScoped
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<IDalamudTextureWrap> CreateFromTexFileAsync(
|
public async Task<IDalamudTextureWrap> CreateFromTexFileAsync(
|
||||||
TexFile file,
|
TexFile file,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var manager = await this.ManagerTask;
|
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);
|
manager.Blame(textureWrap, this.plugin);
|
||||||
return textureWrap;
|
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>
|
/// <summary>A texture wrap that takes its buffer from the frame buffer (of swap chain).</summary>
|
||||||
internal sealed class ViewportTextureWrap : IDalamudTextureWrap, IDeferredDisposable
|
internal sealed class ViewportTextureWrap : IDalamudTextureWrap, IDeferredDisposable
|
||||||
{
|
{
|
||||||
|
private readonly string? debugName;
|
||||||
private readonly LocalPlugin? ownerPlugin;
|
private readonly LocalPlugin? ownerPlugin;
|
||||||
private readonly CancellationToken cancellationToken;
|
private readonly CancellationToken cancellationToken;
|
||||||
private readonly TaskCompletionSource<IDalamudTextureWrap> firstUpdateTaskCompletionSource = new();
|
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>
|
/// <summary>Initializes a new instance of the <see cref="ViewportTextureWrap"/> class.</summary>
|
||||||
/// <param name="args">The arguments for creating a texture.</param>
|
/// <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="ownerPlugin">The owner plugin.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
public ViewportTextureWrap(
|
public ViewportTextureWrap(
|
||||||
ImGuiViewportTextureArgs args, LocalPlugin? ownerPlugin, CancellationToken cancellationToken)
|
ImGuiViewportTextureArgs args, string? debugName, LocalPlugin? ownerPlugin, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
this.args = args;
|
this.args = args;
|
||||||
|
this.debugName = debugName;
|
||||||
this.ownerPlugin = ownerPlugin;
|
this.ownerPlugin = ownerPlugin;
|
||||||
this.cancellationToken = cancellationToken;
|
this.cancellationToken = cancellationToken;
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +154,7 @@ internal sealed class ViewportTextureWrap : IDalamudTextureWrap, IDeferredDispos
|
||||||
Service<TextureManager>.Get().Blame(this, this.ownerPlugin);
|
Service<TextureManager>.Get().Blame(this, this.ownerPlugin);
|
||||||
Service<TextureManager>.Get().BlameSetName(
|
Service<TextureManager>.Get().BlameSetName(
|
||||||
this,
|
this,
|
||||||
$"{nameof(ViewportTextureWrap)}({this.args})");
|
this.debugName ?? $"{nameof(ViewportTextureWrap)}({this.args})");
|
||||||
}
|
}
|
||||||
|
|
||||||
// context.Get()->CopyResource((ID3D11Resource*)this.tex.Get(), (ID3D11Resource*)backBuffer.Get());
|
// context.Get()->CopyResource((ID3D11Resource*)this.tex.Get(), (ID3D11Resource*)backBuffer.Get());
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,10 @@ public class UldWrapper : IDisposable
|
||||||
inputSlice.CopyTo(outputSlice);
|
inputSlice.CopyTo(outputSlice);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.textureManager.CreateFromRaw(RawImageSpecification.Rgba32(part.W, part.H), imageData);
|
return this.textureManager.CreateFromRaw(
|
||||||
|
RawImageSpecification.Rgba32(part.W, part.H),
|
||||||
|
imageData,
|
||||||
|
$"{nameof(UldWrapper)}({this.Uld?.FilePath.Path}: {part.TextureId})");
|
||||||
}
|
}
|
||||||
|
|
||||||
private (uint Id, int Width, int Height, bool HD, byte[] RgbaData)? GetTexture(string texturePath)
|
private (uint Id, int Width, int Height, bool HD, byte[] RgbaData)? GetTexture(string texturePath)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Interface.Internal;
|
using Dalamud.Interface.Internal;
|
||||||
|
using Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||||
using Dalamud.Interface.Textures;
|
using Dalamud.Interface.Textures;
|
||||||
|
|
||||||
using Lumina.Data.Files;
|
using Lumina.Data.Files;
|
||||||
|
|
@ -16,6 +17,10 @@ namespace Dalamud.Plugin.Services;
|
||||||
/// <summary>Service that grants you access to textures you may render via ImGui.</summary>
|
/// <summary>Service that grants you access to textures you may render via ImGui.</summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
|
/// <b>Create</b> functions will return a new texture, and the returned instance of <see cref="IDalamudTextureWrap"/>
|
||||||
|
/// must be disposed after use.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
/// <b>Get</b> functions will return a shared texture, and the returnd instance of <see cref="ISharedImmediateTexture"/>
|
/// <b>Get</b> functions will return a shared texture, and the returnd instance of <see cref="ISharedImmediateTexture"/>
|
||||||
/// do not require calling <see cref="IDisposable.Dispose"/>, unless a new reference has been created by calling
|
/// do not require calling <see cref="IDisposable.Dispose"/>, unless a new reference has been created by calling
|
||||||
/// <see cref="ISharedImmediateTexture.RentAsync"/>.<br />
|
/// <see cref="ISharedImmediateTexture.RentAsync"/>.<br />
|
||||||
|
|
@ -23,8 +28,8 @@ namespace Dalamud.Plugin.Services;
|
||||||
/// <see cref="IDalamudTextureWrap"/> that will stay valid for the rest of the frame.
|
/// <see cref="IDalamudTextureWrap"/> that will stay valid for the rest of the frame.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// <b>Create</b> functions will return a new texture, and the returned instance of <see cref="IDalamudTextureWrap"/>
|
/// <c>debugName</c> parameter can be used to name your textures, to aid debugging resource leaks using
|
||||||
/// must be disposed after use.
|
/// <see cref="TexWidget"/>.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public partial interface ITextureProvider
|
public partial interface ITextureProvider
|
||||||
|
|
@ -36,6 +41,7 @@ public partial interface ITextureProvider
|
||||||
/// <param name="args">The texture modification arguments.</param>
|
/// <param name="args">The texture modification arguments.</param>
|
||||||
/// <param name="leaveWrapOpen">Whether to leave <paramref name="wrap"/> non-disposed when the returned
|
/// <param name="leaveWrapOpen">Whether to leave <paramref name="wrap"/> non-disposed when the returned
|
||||||
/// <see cref="Task{TResult}"/> completes.</param>
|
/// <see cref="Task{TResult}"/> completes.</param>
|
||||||
|
/// <param name="debugName">Name for debug display purposes.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>A <see cref="Task{TResult}"/> containing the copied texture on success. Dispose after use.</returns>
|
/// <returns>A <see cref="Task{TResult}"/> containing the copied texture on success. Dispose after use.</returns>
|
||||||
/// <remarks><para>This function may throw an exception.</para></remarks>
|
/// <remarks><para>This function may throw an exception.</para></remarks>
|
||||||
|
|
@ -43,10 +49,12 @@ public partial interface ITextureProvider
|
||||||
IDalamudTextureWrap wrap,
|
IDalamudTextureWrap wrap,
|
||||||
TextureModificationArgs args = default,
|
TextureModificationArgs args = default,
|
||||||
bool leaveWrapOpen = false,
|
bool leaveWrapOpen = false,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>Creates a texture from an ImGui viewport.</summary>
|
/// <summary>Creates a texture from an ImGui viewport.</summary>
|
||||||
/// <param name="args">The arguments for creating a texture.</param>
|
/// <param name="args">The arguments for creating a texture.</param>
|
||||||
|
/// <param name="debugName">Name for debug display purposes.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>A <see cref="Task{TResult}"/> containing the copied texture on success. Dispose after use.</returns>
|
/// <returns>A <see cref="Task{TResult}"/> containing the copied texture on success. Dispose after use.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|
@ -55,22 +63,26 @@ public partial interface ITextureProvider
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
Task<IDalamudTextureWrap> CreateFromImGuiViewportAsync(
|
Task<IDalamudTextureWrap> CreateFromImGuiViewportAsync(
|
||||||
ImGuiViewportTextureArgs args,
|
ImGuiViewportTextureArgs args,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>Gets a texture from the given bytes, trying to interpret it as a .tex file or other well-known image
|
/// <summary>Gets a texture from the given bytes, trying to interpret it as a .tex file or other well-known image
|
||||||
/// files, such as .png.</summary>
|
/// files, such as .png.</summary>
|
||||||
/// <param name="bytes">The bytes to load.</param>
|
/// <param name="bytes">The bytes to load.</param>
|
||||||
|
/// <param name="debugName">Name for debug display purposes.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>A <see cref="Task{TResult}"/> containing the loaded texture on success. Dispose after use.</returns>
|
/// <returns>A <see cref="Task{TResult}"/> containing the loaded texture on success. Dispose after use.</returns>
|
||||||
/// <remarks><para>This function may throw an exception.</para></remarks>
|
/// <remarks><para>This function may throw an exception.</para></remarks>
|
||||||
Task<IDalamudTextureWrap> CreateFromImageAsync(
|
Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||||
ReadOnlyMemory<byte> bytes,
|
ReadOnlyMemory<byte> bytes,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>Gets a texture from the given stream, trying to interpret it as a .tex file or other well-known image
|
/// <summary>Gets a texture from the given stream, trying to interpret it as a .tex file or other well-known image
|
||||||
/// files, such as .png.</summary>
|
/// files, such as .png.</summary>
|
||||||
/// <param name="stream">The stream to load data from.</param>
|
/// <param name="stream">The stream to load data from.</param>
|
||||||
/// <param name="leaveOpen">Whether to leave the stream open once the task completes, sucessfully or not.</param>
|
/// <param name="leaveOpen">Whether to leave the stream open once the task completes, sucessfully or not.</param>
|
||||||
|
/// <param name="debugName">Name for debug display purposes.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>A <see cref="Task{TResult}"/> containing the loaded texture on success. Dispose after use.</returns>
|
/// <returns>A <see cref="Task{TResult}"/> containing the loaded texture on success. Dispose after use.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|
@ -80,32 +92,38 @@ public partial interface ITextureProvider
|
||||||
Task<IDalamudTextureWrap> CreateFromImageAsync(
|
Task<IDalamudTextureWrap> CreateFromImageAsync(
|
||||||
Stream stream,
|
Stream stream,
|
||||||
bool leaveOpen = false,
|
bool leaveOpen = false,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>Gets a texture from the given bytes, interpreting it as a raw bitmap.</summary>
|
/// <summary>Gets a texture from the given bytes, interpreting it as a raw bitmap.</summary>
|
||||||
/// <param name="specs">The specifications for the raw bitmap.</param>
|
/// <param name="specs">The specifications for the raw bitmap.</param>
|
||||||
/// <param name="bytes">The bytes to load.</param>
|
/// <param name="bytes">The bytes to load.</param>
|
||||||
|
/// <param name="debugName">Name for debug display purposes.</param>
|
||||||
/// <returns>The texture loaded from the supplied raw bitmap. Dispose after use.</returns>
|
/// <returns>The texture loaded from the supplied raw bitmap. Dispose after use.</returns>
|
||||||
/// <remarks><para>This function may throw an exception.</para></remarks>
|
/// <remarks><para>This function may throw an exception.</para></remarks>
|
||||||
IDalamudTextureWrap CreateFromRaw(
|
IDalamudTextureWrap CreateFromRaw(
|
||||||
RawImageSpecification specs,
|
RawImageSpecification specs,
|
||||||
ReadOnlySpan<byte> bytes);
|
ReadOnlySpan<byte> bytes,
|
||||||
|
string? debugName = null);
|
||||||
|
|
||||||
/// <summary>Gets a texture from the given bytes, interpreting it as a raw bitmap.</summary>
|
/// <summary>Gets a texture from the given bytes, interpreting it as a raw bitmap.</summary>
|
||||||
/// <param name="specs">The specifications for the raw bitmap.</param>
|
/// <param name="specs">The specifications for the raw bitmap.</param>
|
||||||
/// <param name="bytes">The bytes to load.</param>
|
/// <param name="bytes">The bytes to load.</param>
|
||||||
|
/// <param name="debugName">Name for debug display purposes.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>A <see cref="Task{TResult}"/> containing the loaded texture on success. Dispose after use.</returns>
|
/// <returns>A <see cref="Task{TResult}"/> containing the loaded texture on success. Dispose after use.</returns>
|
||||||
/// <remarks><para>This function may throw an exception.</para></remarks>
|
/// <remarks><para>This function may throw an exception.</para></remarks>
|
||||||
Task<IDalamudTextureWrap> CreateFromRawAsync(
|
Task<IDalamudTextureWrap> CreateFromRawAsync(
|
||||||
RawImageSpecification specs,
|
RawImageSpecification specs,
|
||||||
ReadOnlyMemory<byte> bytes,
|
ReadOnlyMemory<byte> bytes,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>Gets a texture from the given stream, interpreting the read data as a raw bitmap.</summary>
|
/// <summary>Gets a texture from the given stream, interpreting the read data as a raw bitmap.</summary>
|
||||||
/// <param name="specs">The specifications for the raw bitmap.</param>
|
/// <param name="specs">The specifications for the raw bitmap.</param>
|
||||||
/// <param name="stream">The stream to load data from.</param>
|
/// <param name="stream">The stream to load data from.</param>
|
||||||
/// <param name="leaveOpen">Whether to leave the stream open once the task completes, sucessfully or not.</param>
|
/// <param name="leaveOpen">Whether to leave the stream open once the task completes, sucessfully or not.</param>
|
||||||
|
/// <param name="debugName">Name for debug display purposes.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>A <see cref="Task{TResult}"/> containing the loaded texture on success. Dispose after use.</returns>
|
/// <returns>A <see cref="Task{TResult}"/> containing the loaded texture on success. Dispose after use.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|
@ -117,6 +135,7 @@ public partial interface ITextureProvider
|
||||||
RawImageSpecification specs,
|
RawImageSpecification specs,
|
||||||
Stream stream,
|
Stream stream,
|
||||||
bool leaveOpen = false,
|
bool leaveOpen = false,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -130,11 +149,13 @@ public partial interface ITextureProvider
|
||||||
|
|
||||||
/// <summary>Get a texture handle for the specified Lumina <see cref="TexFile"/>.</summary>
|
/// <summary>Get a texture handle for the specified Lumina <see cref="TexFile"/>.</summary>
|
||||||
/// <param name="file">The texture to obtain a handle to.</param>
|
/// <param name="file">The texture to obtain a handle to.</param>
|
||||||
|
/// <param name="debugName">Name for debug display purposes.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>A texture wrap that can be used to render the texture. Dispose after use.</returns>
|
/// <returns>A texture wrap that can be used to render the texture. Dispose after use.</returns>
|
||||||
/// <remarks><para>This function may throw an exception.</para></remarks>
|
/// <remarks><para>This function may throw an exception.</para></remarks>
|
||||||
Task<IDalamudTextureWrap> CreateFromTexFileAsync(
|
Task<IDalamudTextureWrap> CreateFromTexFileAsync(
|
||||||
TexFile file,
|
TexFile file,
|
||||||
|
string? debugName = null,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>Gets the supported bitmap decoders.</summary>
|
/// <summary>Gets the supported bitmap decoders.</summary>
|
||||||
|
|
@ -144,8 +165,8 @@ public partial interface ITextureProvider
|
||||||
/// <ul>
|
/// <ul>
|
||||||
/// <li><see cref="GetFromFile"/></li>
|
/// <li><see cref="GetFromFile"/></li>
|
||||||
/// <li><see cref="GetFromManifestResource"/></li>
|
/// <li><see cref="GetFromManifestResource"/></li>
|
||||||
/// <li><see cref="CreateFromImageAsync(ReadOnlyMemory{byte},CancellationToken)"/></li>
|
/// <li><see cref="CreateFromImageAsync(ReadOnlyMemory{byte},string?,CancellationToken)"/></li>
|
||||||
/// <li><see cref="CreateFromImageAsync(Stream,bool,CancellationToken)"/></li>
|
/// <li><see cref="CreateFromImageAsync(Stream,bool,string?,CancellationToken)"/></li>
|
||||||
/// </ul>
|
/// </ul>
|
||||||
/// <para>This function may throw an exception.</para>
|
/// <para>This function may throw an exception.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ internal sealed class DalamudAssetManager : IServiceType, IDisposable, IDalamudA
|
||||||
|
|
||||||
this.fileStreams = Enum.GetValues<DalamudAsset>().ToDictionary(x => x, _ => (Task<FileStream>?)null);
|
this.fileStreams = Enum.GetValues<DalamudAsset>().ToDictionary(x => x, _ => (Task<FileStream>?)null);
|
||||||
this.textureWraps = Enum.GetValues<DalamudAsset>().ToDictionary(x => x, _ => (Task<IDalamudTextureWrap>?)null);
|
this.textureWraps = Enum.GetValues<DalamudAsset>().ToDictionary(x => x, _ => (Task<IDalamudTextureWrap>?)null);
|
||||||
|
|
||||||
// Block until all the required assets to be ready.
|
// Block until all the required assets to be ready.
|
||||||
var loadTimings = Timings.Start("DAM LoadAll");
|
var loadTimings = Timings.Start("DAM LoadAll");
|
||||||
registerStartupBlocker(
|
registerStartupBlocker(
|
||||||
|
|
@ -72,11 +72,11 @@ internal sealed class DalamudAssetManager : IServiceType, IDisposable, IDalamudA
|
||||||
"Prevent Dalamud from loading more stuff, until we've ensured that all required assets are available.");
|
"Prevent Dalamud from loading more stuff, until we've ensured that all required assets are available.");
|
||||||
|
|
||||||
Task.WhenAll(
|
Task.WhenAll(
|
||||||
Enum.GetValues<DalamudAsset>()
|
Enum.GetValues<DalamudAsset>()
|
||||||
.Where(x => x is not DalamudAsset.Empty4X4)
|
.Where(x => x is not DalamudAsset.Empty4X4)
|
||||||
.Where(x => x.GetAttribute<DalamudAssetAttribute>()?.Required is false)
|
.Where(x => x.GetAttribute<DalamudAssetAttribute>()?.Required is false)
|
||||||
.Select(this.CreateStreamAsync)
|
.Select(this.CreateStreamAsync)
|
||||||
.Select(x => x.ToContentDisposedTask()))
|
.Select(x => x.ToContentDisposedTask()))
|
||||||
.ContinueWith(r => Log.Verbose($"Optional assets load state: {r}"));
|
.ContinueWith(r => Log.Verbose($"Optional assets load state: {r}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ internal sealed class DalamudAssetManager : IServiceType, IDisposable, IDalamudA
|
||||||
this.cancellationTokenSource.Token);
|
this.cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var j = RenameAttemptCount; ; j--)
|
for (var j = RenameAttemptCount;; j--)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -313,10 +313,15 @@ internal sealed class DalamudAssetManager : IServiceType, IDisposable, IDalamudA
|
||||||
stream.ReadExactly(buf, 0, length);
|
stream.ReadExactly(buf, 0, length);
|
||||||
var image = purpose switch
|
var image = purpose switch
|
||||||
{
|
{
|
||||||
DalamudAssetPurpose.TextureFromPng => await tm.CreateFromImageAsync(buf),
|
DalamudAssetPurpose.TextureFromPng => await tm.CreateFromImageAsync(
|
||||||
|
buf,
|
||||||
|
$"{nameof(DalamudAsset)}.{Enum.GetName(asset)}"),
|
||||||
DalamudAssetPurpose.TextureFromRaw =>
|
DalamudAssetPurpose.TextureFromRaw =>
|
||||||
asset.GetAttribute<DalamudAssetRawTextureAttribute>() is { } raw
|
asset.GetAttribute<DalamudAssetRawTextureAttribute>() is { } raw
|
||||||
? await tm.CreateFromRawAsync(raw.Specification, buf)
|
? await tm.CreateFromRawAsync(
|
||||||
|
raw.Specification,
|
||||||
|
buf,
|
||||||
|
$"{nameof(DalamudAsset)}.{Enum.GetName(asset)}")
|
||||||
: throw new InvalidOperationException(
|
: throw new InvalidOperationException(
|
||||||
"TextureFromRaw must accompany a DalamudAssetRawTextureAttribute."),
|
"TextureFromRaw must accompany a DalamudAssetRawTextureAttribute."),
|
||||||
_ => null,
|
_ => null,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue