Refactor MeshInstance

This commit is contained in:
2026-03-13 15:10:25 +09:00
parent 619720feee
commit 8a3b40b4f8
15 changed files with 57 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
# Ghost.Nvtt Usage Guide
# Ghost.Nvtt - Usage Guide
`Ghost.Nvtt` is a managed C# wrapper over the NVIDIA Texture Tools 3 (nvtt) native library.
All wrapper classes are in the `Ghost.Nvtt` namespace. Add a single `using Ghost.Nvtt;` and you have access to every wrapper class and every enum.
@@ -99,7 +99,7 @@ set.LoadDDS("texture_array.dds");
Console.WriteLine($"{set.FaceCount} faces, {set.MipmapCount} mips, " +
$"{set.Width}x{set.Height}");
// Access the raw pointer for face 0, mip 0 (borrowed do not dispose)
// Access the raw pointer for face 0, mip 0 (borrowed - do not dispose)
var surfacePtr = set.GetSurfacePtr(faceId: 0, mipId: 0);
```
@@ -203,10 +203,10 @@ diff.Save("diff.png");
| Returns | Ownership |
|---------|-----------|
| `new NvttSurface(...)` constructor overload accepting a raw pointer | **Takes** ownership dispose when done |
| `new NvttSurface(...)` constructor overload accepting a raw pointer | **Takes** ownership - dispose when done |
| `NvttSurface.Clone()` | Caller owns result |
| `NvttSurface.CreateSubImage()`, `CreateToksvigMap()` | Caller owns result |
| `NvttCubeSurface.Unfold()`, `IrradianceFilter()`, `CosinePowerFilter()`, `FastResample()` | Caller owns result |
| `NvttGlobal.Diff()`, `Histogram()`, `HistogramRange()` | Caller owns result |
| `NvttCubeSurface.FacePtr()`, `NvttSurfaceSet.GetSurfacePtr()` | **Borrowed** do NOT dispose |
| `NvttContext.GetTimingContextPtr()` | **Borrowed** do NOT dispose |
| `NvttCubeSurface.FacePtr()`, `NvttSurfaceSet.GetSurfacePtr()` | **Borrowed** - do NOT dispose |
| `NvttContext.GetTimingContextPtr()` | **Borrowed** - do NOT dispose |

View File

@@ -8,7 +8,7 @@ public sealed unsafe class NvttBatchListHandle : IDisposable
{
private NvttBatchList* _ptr;
/// <summary>Raw pointer use only when calling the native API directly.</summary>
/// <summary>Raw pointer - use only when calling the native API directly.</summary>
public NvttBatchList* Ptr => _ptr;
// -------------------------------------------------------------------------
@@ -62,7 +62,7 @@ public sealed unsafe class NvttBatchListHandle : IDisposable
/// <summary>
/// Returns the raw pointers for item <paramref name="index"/>.
/// The pointers are borrowed do NOT dispose them.
/// The pointers are borrowed - do NOT dispose them.
/// </summary>
public void GetItem(uint index,
out NvttSurface* surface, out int face, out int mipmap,

View File

@@ -1,14 +1,14 @@
namespace Ghost.Nvtt;
/// <summary>
/// Controls how a surface is compressed format, quality, pixel layout and
/// Controls how a surface is compressed - format, quality, pixel layout and
/// optional quantization settings.
/// </summary>
public sealed unsafe class NvttCompressionOptionsHandle : IDisposable
{
private NvttCompressionOptions* _ptr;
/// <summary>Raw pointer use only when calling the native API directly.</summary>
/// <summary>Raw pointer - use only when calling the native API directly.</summary>
public NvttCompressionOptions* Ptr => _ptr;
// -------------------------------------------------------------------------

View File

@@ -8,7 +8,7 @@ public sealed unsafe class NvttContextHandle : IDisposable
{
private NvttContext* _ptr;
/// <summary>Raw pointer use only when calling the native API directly.</summary>
/// <summary>Raw pointer - use only when calling the native API directly.</summary>
public NvttContext* Ptr => _ptr;
// -------------------------------------------------------------------------
@@ -63,7 +63,7 @@ public sealed unsafe class NvttContextHandle : IDisposable
/// <summary>
/// Returns the timing context owned by this nvtt context.
/// The pointer is borrowed do NOT dispose it separately.
/// The pointer is borrowed - do NOT dispose it separately.
/// Returns <c>null</c> if timing was never enabled.
/// </summary>
public NvttTimingContext* GetTimingContextPtr()

View File

@@ -10,7 +10,7 @@ public sealed unsafe class NvttCubeSurfaceHandle : IDisposable
{
private NvttCubeSurface* _ptr;
/// <summary>Raw pointer use only when calling the native API directly.</summary>
/// <summary>Raw pointer - use only when calling the native API directly.</summary>
public NvttCubeSurface* Ptr => _ptr;
// -------------------------------------------------------------------------
@@ -102,7 +102,7 @@ public sealed unsafe class NvttCubeSurfaceHandle : IDisposable
/// <summary>
/// Returns the raw <see cref="NvttSurface"/> pointer for the given face
/// (05). The pointer is owned by this cube surface do NOT dispose it.
/// (05). The pointer is owned by this cube surface - do NOT dispose it.
/// </summary>
public NvttSurface* FacePtr(int face)
{

View File

@@ -14,7 +14,7 @@ public sealed unsafe class NvttOutputOptionsHandle : IDisposable
{
private NvttOutputOptions* _ptr;
/// <summary>Raw pointer use only when calling the native API directly.</summary>
/// <summary>Raw pointer - use only when calling the native API directly.</summary>
public NvttOutputOptions* Ptr => _ptr;
// -------------------------------------------------------------------------
@@ -31,7 +31,7 @@ public sealed unsafe class NvttOutputOptionsHandle : IDisposable
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void ErrorDelegate(Ghost.Nvtt.Native.NvttError error);
// Pinned delegate instances must stay alive as long as native code may call them.
// Pinned delegate instances - must stay alive as long as native code may call them.
private BeginImageDelegate? _beginImageDelegate;
private OutputDataDelegate? _outputDataDelegate;
private ErrorDelegate? _errorDelegate;

View File

@@ -11,7 +11,7 @@ public sealed unsafe class NvttSurfaceHandle : IDisposable
{
private NvttSurface* _ptr;
/// <summary>Raw pointer use only when calling the native API directly.</summary>
/// <summary>Raw pointer - use only when calling the native API directly.</summary>
public NvttSurface* Ptr => _ptr;
// -------------------------------------------------------------------------

View File

@@ -8,7 +8,7 @@ public sealed unsafe class NvttSurfaceSetHandle : IDisposable
{
private NvttSurfaceSet* _ptr;
/// <summary>Raw pointer use only when calling the native API directly.</summary>
/// <summary>Raw pointer - use only when calling the native API directly.</summary>
public NvttSurfaceSet* Ptr => _ptr;
// -------------------------------------------------------------------------
@@ -72,7 +72,7 @@ public sealed unsafe class NvttSurfaceSetHandle : IDisposable
/// <summary>
/// Returns the raw <see cref="NvttSurface"/> pointer for the given face
/// and mip level. The pointer is owned by this surface set do NOT dispose
/// and mip level. The pointer is owned by this surface set - do NOT dispose
/// it.
/// </summary>
public NvttSurface* GetSurfacePtr(int faceId, int mipId, bool expectSigned = false)

View File

@@ -10,7 +10,7 @@ public sealed unsafe class NvttTimingContextHandle : IDisposable
{
private NvttTimingContext* _ptr;
/// <summary>Raw pointer use only when calling the native API directly.</summary>
/// <summary>Raw pointer - use only when calling the native API directly.</summary>
public NvttTimingContext* Ptr => _ptr;
// -------------------------------------------------------------------------