SOURCE DUMP v1

This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit fb20299e9d
34 changed files with 768360 additions and 0 deletions

View file

@ -0,0 +1,12 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public enum ClassId : int
{
Texture1C = 1,
Texture2C = 2,
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,18 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate KtxErrorCode IterateCallbackDelegate(
int miplevel,
int face,
int width,
int height,
int depth,
ulong faceLodSize,
IntPtr pixels,
IntPtr userdata
);
}
#pragma warning restore 1591

View file

@ -0,0 +1,152 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public enum KhrDfModel : int
{
/// <summary>No interpretation of color channels defined</summary>
Unspecified = 0,
/// <summary>Color primaries (red, green, blue) + alpha, depth and stencil</summary>
Rgbsda = 1,
/// <summary>Color differences (Y', Cb, Cr) + alpha, depth and stencil</summary>
Yuvsda = 2,
/// <summary>Color differences (Y', I, Q) + alpha, depth and stencil</summary>
Yiqsda = 3,
/// <summary>Perceptual color (CIE L*a*b*) + alpha, depth and stencil</summary>
Labsda = 4,
/// <summary>Subtractive colors (cyan, magenta, yellow, black) + alpha</summary>
Cmyka = 5,
/// <summary>Non-color coordinate data (X, Y, Z, W)</summary>
Xyzw = 6,
/// <summary>Hue, saturation, value, hue angle on color circle, plus alpha</summary>
HsvaAng = 7,
/// <summary>Hue, saturation, lightness, hue angle on color circle, plus alpha</summary>
HslaAng = 8,
/// <summary>Hue, saturation, value, hue on color hexagon, plus alpha</summary>
HsvaHex = 9,
/// <summary>Hue, saturation, lightness, hue on color hexagon, plus alpha</summary>
HslaHex = 10,
/// <summary>Lightweight approximate color difference (luma, orange, green)</summary>
Ycgcoa = 11,
/// <summary>ITU BT.2020 constant luminance YcCbcCrc</summary>
Yccbccrc = 12,
/// <summary>ITU BT.2100 constant intensity ICtCp</summary>
Ictcp = 13,
/// <summary>CIE 1931 XYZ color coordinates (X, Y, Z)</summary>
Ciexyz = 14,
/// <summary>CIE 1931 xyY color coordinates (X, Y, Y)</summary>
Ciexyy = 15,
/// <summary>Compressed formats start at 128.</summary>
/// These compressed formats should generally have a single sample,sited at the 0,0 position of the texel block. Where multiplechannels are used to distinguish formats, these should be cosited.
/// Direct3D (and S3) compressed formats
/// Note that premultiplied status is recorded separately
/// DXT1 "channels" are RGB (0), Alpha (1)
/// DXT1/BC1 with one channel is opaque
/// DXT1/BC1 with a cosited alpha sample is transparent
Dxt1A = 128,
/// <summary>Compressed formats start at 128.</summary>
/// These compressed formats should generally have a single sample,sited at the 0,0 position of the texel block. Where multiplechannels are used to distinguish formats, these should be cosited.
/// Direct3D (and S3) compressed formats
/// Note that premultiplied status is recorded separately
/// DXT1 "channels" are RGB (0), Alpha (1)
/// DXT1/BC1 with one channel is opaque
/// DXT1/BC1 with a cosited alpha sample is transparent
Bc1A = 128,
/// <summary>DXT2/DXT3/BC2, with explicit 4-bit alpha</summary>
Dxt2 = 129,
/// <summary>DXT2/DXT3/BC2, with explicit 4-bit alpha</summary>
Dxt3 = 129,
/// <summary>DXT2/DXT3/BC2, with explicit 4-bit alpha</summary>
Bc2 = 129,
/// <summary>DXT4/DXT5/BC3, with interpolated alpha</summary>
Dxt4 = 130,
/// <summary>DXT4/DXT5/BC3, with interpolated alpha</summary>
Dxt5 = 130,
/// <summary>DXT4/DXT5/BC3, with interpolated alpha</summary>
Bc3 = 130,
/// <summary>ATI1n/DXT5A/BC4 - single channel interpolated 8-bit data</summary>
/// (The UNORM/SNORM variation is recorded in the channel data)
Ati1N = 131,
/// <summary>ATI1n/DXT5A/BC4 - single channel interpolated 8-bit data</summary>
/// (The UNORM/SNORM variation is recorded in the channel data)
Dxt5A = 131,
/// <summary>ATI1n/DXT5A/BC4 - single channel interpolated 8-bit data</summary>
/// (The UNORM/SNORM variation is recorded in the channel data)
Bc4 = 131,
/// <summary>ATI2n_XY/DXN/BC5 - two channel interpolated 8-bit data</summary>
/// (The UNORM/SNORM variation is recorded in the channel data)
Ati2NXy = 132,
/// <summary>ATI2n_XY/DXN/BC5 - two channel interpolated 8-bit data</summary>
/// (The UNORM/SNORM variation is recorded in the channel data)
Dxn = 132,
/// <summary>ATI2n_XY/DXN/BC5 - two channel interpolated 8-bit data</summary>
/// (The UNORM/SNORM variation is recorded in the channel data)
Bc5 = 132,
/// <summary>BC6H - DX11 format for 16-bit float channels</summary>
Bc6H = 133,
/// <summary>BC7 - DX11 format</summary>
Bc7 = 134,
/// <summary>Mobile compressed formats follow</summary>
/// A format of ETC1 indicates that the format shall be decodableby an ETC1-compliant decoder and not rely on ETC2 features
Etc1 = 160,
/// <summary>A format of ETC2 is permitted to use ETC2 encodings on top ofthe baseline ETC1 specification</summary>
/// The ETC2 format has channels "red", "green", "RGB" and "alpha",which should be cosited samples
/// Punch-through alpha can be distinguished from full alpha bythe plane size in bytes required for the texel block
Etc2 = 161,
/// <summary>Adaptive Scalable Texture Compression</summary>
/// ASTC HDR vs LDR is determined by the float flag in the channel
/// ASTC block size can be distinguished by texel block size
Astc = 162,
/// <summary>ETC1S is a simplified subset of ETC1</summary>
Etc1S = 163,
/// <summary>PowerVR Texture Compression</summary>
Pvrtc = 164,
/// <summary>PowerVR Texture Compression</summary>
Pvrtc2 = 165,
/// <summary>PowerVR Texture Compression</summary>
Uastc = 166,
/// <summary>Proprietary formats (ATITC, etc.) should follow</summary>
Max = 255,
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,54 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public enum KhrDfPrimaries : int
{
/// <summary>No color primaries defined</summary>
Unspecified = 0,
/// <summary>Color primaries of ITU-R BT.709 and sRGB</summary>
Bt709 = 1,
/// <summary>Synonym for KHR_DF_PRIMARIES_BT709</summary>
Srgb = 1,
/// <summary>Color primaries of ITU-R BT.601 (625-line EBU variant)</summary>
Bt601Ebu = 2,
/// <summary>Color primaries of ITU-R BT.601 (525-line SMPTE C variant)</summary>
Bt601Smpte = 3,
/// <summary>Color primaries of ITU-R BT.2020</summary>
Bt2020 = 4,
/// <summary>ITU-R BT.2100 uses the same primaries as BT.2020</summary>
Bt2100 = 4,
/// <summary>CIE theoretical color coordinate space</summary>
Ciexyz = 5,
/// <summary>Academy Color Encoding System primaries</summary>
Aces = 6,
/// <summary>Color primaries of ACEScc</summary>
Acescc = 7,
/// <summary>Legacy NTSC 1953 primaries</summary>
Ntsc1953 = 8,
/// <summary>Legacy PAL 525-line primaries</summary>
Pal525 = 9,
/// <summary>Color primaries of Display P3</summary>
Displayp3 = 10,
/// <summary>Color primaries of Adobe RGB (1998)</summary>
Adobergb = 11,
/// <summary>Color primaries of Adobe RGB (1998)</summary>
Max = 255,
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,141 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public enum KhrDfTransfer : int
{
/// <summary>No transfer function defined</summary>
Unspecified = 0,
/// <summary>Linear transfer function (value proportional to intensity)</summary>
Linear = 1,
/// <summary>Perceptually-linear transfer function of sRGB (~2.2); also used for scRGB</summary>
Srgb = 2,
/// <summary>Perceptually-linear transfer function of sRGB (~2.2); also used for scRGB</summary>
SrgbEotf = 2,
/// <summary>Perceptually-linear transfer function of sRGB (~2.2); also used for scRGB</summary>
Scrgb = 2,
/// <summary>Perceptually-linear transfer function of sRGB (~2.2); also used for scRGB</summary>
ScrgbEotf = 2,
/// <summary>Perceptually-linear transfer function of ITU BT.601, BT.709 and BT.2020 (~1/.45)</summary>
Itu = 3,
/// <summary>Perceptually-linear transfer function of ITU BT.601, BT.709 and BT.2020 (~1/.45)</summary>
ItuOetf = 3,
/// <summary>Perceptually-linear transfer function of ITU BT.601, BT.709 and BT.2020 (~1/.45)</summary>
Bt601 = 3,
/// <summary>Perceptually-linear transfer function of ITU BT.601, BT.709 and BT.2020 (~1/.45)</summary>
Bt601Oetf = 3,
/// <summary>Perceptually-linear transfer function of ITU BT.601, BT.709 and BT.2020 (~1/.45)</summary>
Bt709 = 3,
/// <summary>Perceptually-linear transfer function of ITU BT.601, BT.709 and BT.2020 (~1/.45)</summary>
Bt709Oetf = 3,
/// <summary>Perceptually-linear transfer function of ITU BT.601, BT.709 and BT.2020 (~1/.45)</summary>
Bt2020 = 3,
/// <summary>Perceptually-linear transfer function of ITU BT.601, BT.709 and BT.2020 (~1/.45)</summary>
Bt2020Oetf = 3,
/// <summary>SMTPE170M (digital NTSC) defines an alias for the ITU transfer function (~1/.45) and a linear OOTF</summary>
Smtpe170M = 3,
/// <summary>SMTPE170M (digital NTSC) defines an alias for the ITU transfer function (~1/.45) and a linear OOTF</summary>
Smtpe170MOetf = 3,
/// <summary>SMTPE170M (digital NTSC) defines an alias for the ITU transfer function (~1/.45) and a linear OOTF</summary>
Smtpe170MEotf = 3,
/// <summary>Perceptually-linear gamma function of original NTSC (simple 2.2 gamma)</summary>
Ntsc = 4,
/// <summary>Perceptually-linear gamma function of original NTSC (simple 2.2 gamma)</summary>
NtscEotf = 4,
/// <summary>Sony S-log used by Sony video cameras</summary>
Slog = 5,
/// <summary>Sony S-log used by Sony video cameras</summary>
SlogOetf = 5,
/// <summary>Sony S-log 2 used by Sony video cameras</summary>
Slog2 = 6,
/// <summary>Sony S-log 2 used by Sony video cameras</summary>
Slog2Oetf = 6,
/// <summary>ITU BT.1886 EOTF</summary>
Bt1886 = 7,
/// <summary>ITU BT.1886 EOTF</summary>
Bt1886Eotf = 7,
/// <summary>ITU BT.2100 HLG OETF (typical scene-referred content), linear light normalized 0..1</summary>
HlgOetf = 8,
/// <summary>ITU BT.2100 HLG EOTF (nominal HDR display of HLG content), linear light normalized 0..1</summary>
HlgEotf = 9,
/// <summary>ITU BT.2100 PQ EOTF (typical HDR display-referred PQ content)</summary>
PqEotf = 10,
/// <summary>ITU BT.2100 PQ OETF (nominal scene described by PQ HDR content)</summary>
PqOetf = 11,
/// <summary>DCI P3 transfer function</summary>
Dcip3 = 12,
/// <summary>DCI P3 transfer function</summary>
Dcip3Eotf = 12,
/// <summary>Legacy PAL OETF</summary>
PalOetf = 13,
/// <summary>Legacy PAL 625-line EOTF</summary>
Pal625Eotf = 14,
/// <summary>Legacy ST240 transfer function</summary>
St240 = 15,
/// <summary>Legacy ST240 transfer function</summary>
St240Oetf = 15,
/// <summary>Legacy ST240 transfer function</summary>
St240Eotf = 15,
/// <summary>ACEScc transfer function</summary>
Acescc = 16,
/// <summary>ACEScc transfer function</summary>
AcesccOetf = 16,
/// <summary>ACEScct transfer function</summary>
Acescct = 17,
/// <summary>ACEScct transfer function</summary>
AcescctOetf = 17,
/// <summary>Adobe RGB (1998) transfer function</summary>
Adobergb = 18,
/// <summary>Adobe RGB (1998) transfer function</summary>
AdobergbEotf = 18,
/// <summary>Legacy ITU BT.2100 HLG OETF (typical scene-referred content), linear light normalized 0..12</summary>
HlgUnnormalizedOetf = 19,
/// <summary>Legacy ITU BT.2100 HLG OETF (typical scene-referred content), linear light normalized 0..12</summary>
Max = 255,
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,38 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
[StructLayout(LayoutKind.Explicit, Pack = 4)]
public unsafe partial struct KtxAstcParams
{
[FieldOffset(0)]
public uint StructSize;
[FieldOffset(4)]
public Bool8 Verbose;
[FieldOffset(8)]
public uint ThreadCount;
/// <summary>astcenc params</summary>
[FieldOffset(12)]
public uint BlockDimension;
[FieldOffset(16)]
public uint Mode;
[FieldOffset(20)]
public uint QualityLevel;
[FieldOffset(24)]
public Bool8 NormalMap;
[FieldOffset(25)]
public Bool8 Perceptual;
[FieldOffset(26)]
public unsafe fixed byte InputSwizzle[4];
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,87 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
[StructLayout(LayoutKind.Explicit, Pack = 4)]
public unsafe partial struct KtxBasisParams
{
[FieldOffset(0)]
public uint StructSize;
[FieldOffset(4)]
public Bool8 Uastc;
[FieldOffset(5)]
public Bool8 Verbose;
[FieldOffset(6)]
public Bool8 NoSse;
[FieldOffset(8)]
public uint ThreadCount;
/// <summary>ETC1S params</summary>
[FieldOffset(12)]
public uint CompressionLevel;
[FieldOffset(16)]
public uint QualityLevel;
[FieldOffset(20)]
public uint MaxEndpoints;
[FieldOffset(24)]
public float EndpointRdoThreshold;
[FieldOffset(28)]
public uint MaxSelectors;
[FieldOffset(32)]
public float SelectorRdoThreshold;
[FieldOffset(36)]
public unsafe fixed byte InputSwizzle[4];
[FieldOffset(40)]
public Bool8 NormalMap;
[FieldOffset(41)]
public Bool8 SeparateRgtORgbA;
[FieldOffset(42)]
public Bool8 PreSwizzle;
[FieldOffset(43)]
public Bool8 NoEndpointRdo;
[FieldOffset(44)]
public Bool8 NoSelectorRdo;
/// <summary>UASTC params</summary>
[FieldOffset(48)]
public KtxPackUastcFlagBits UastcFlags;
[FieldOffset(52)]
public Bool8 UastcRdo;
[FieldOffset(56)]
public float UastcRdoQualityScalar;
[FieldOffset(60)]
public uint UastcRdoDictSize;
[FieldOffset(64)]
public float UastcRdoMaxSmoothBlockErrorScale;
[FieldOffset(68)]
public float UastcRdoMaxSmoothBlockStdDev;
[FieldOffset(72)]
public Bool8 UastcRdoDontFavorSimplerModes;
[FieldOffset(73)]
public Bool8 UastcRdoNoMultithreading;
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,75 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public enum KtxErrorCode : int
{
/// <summary>Operation was successful.</summary>
Success = 0,
/// <summary>The data in the file is inconsistent with the spec.</summary>
FileDataError,
/// <summary>The file is a pipe or named pipe.</summary>
FileIspipe,
/// <summary>The target file could not be opened.</summary>
FileOpenFailed,
/// <summary>The operation would exceed the max file size.</summary>
FileOverflow,
/// <summary>An error occurred while reading from the file.</summary>
FileReadError,
/// <summary>An error occurred while seeking in the file.</summary>
FileSeekError,
/// <summary>File does not have enough data to satisfy request.</summary>
FileUnexpectedEof,
/// <summary>An error occurred while writing to the file.</summary>
FileWriteError,
/// <summary>GL operations resulted in an error.</summary>
GlError,
/// <summary>The operation is not allowed in the current state.</summary>
InvalidOperation,
/// <summary>A parameter value was not valid.</summary>
InvalidValue,
/// <summary>Requested metadata key or required dynamically loaded GPU function was not found.</summary>
NotFound,
/// <summary>Not enough memory to complete the operation.</summary>
OutOfMemory,
/// <summary>Transcoding of block compressed texture failed.</summary>
TranscodeFailed,
/// <summary>The file not a KTX file</summary>
UnknownFileFormat,
/// <summary>The KTX file specifies an unsupported texture type.</summary>
UnsupportedTextureType,
/// <summary>Feature not included in in-use library or not yet implemented.</summary>
UnsupportedFeature,
/// <summary>Library dependency (OpenGL or Vulkan) not linked into application.</summary>
LibraryNotLinked,
/// <summary>Decompressed byte count does not match expected byte size</summary>
DecompressLengthError,
/// <summary>Checksum mismatch when decompressing</summary>
DecompressChecksumError,
/// <summary>For safety checks.</summary>
ErrorMaxEnum = 20,
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,39 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
[StructLayout(LayoutKind.Explicit, Pack = 4)]
public unsafe partial struct KtxFormatSize
{
[FieldOffset(0)]
public readonly uint Flags;
/// <summary>For KTX1.</summary>
[FieldOffset(4)]
public readonly uint PaletteSizeInBits;
[FieldOffset(8)]
public readonly uint BlockSizeInBits;
/// <summary>in texels</summary>
[FieldOffset(12)]
public readonly uint BlockWidth;
/// <summary>in texels</summary>
[FieldOffset(16)]
public readonly uint BlockHeight;
/// <summary>in texels</summary>
[FieldOffset(20)]
public readonly uint BlockDepth;
/// <summary>Minimum required number of blocks</summary>
[FieldOffset(24)]
public readonly uint MinBlocksX;
[FieldOffset(28)]
public readonly uint MinBlocksY;
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,82 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public enum KtxPackAstcBlockDimension : int
{
/// <summary>: 8.00 bpp</summary>
BlockDimension4X4,
/// <summary>: 6.40 bpp</summary>
BlockDimension5X4,
/// <summary>: 5.12 bpp</summary>
BlockDimension5X5,
/// <summary>: 4.27 bpp</summary>
BlockDimension6X5,
/// <summary>: 3.56 bpp</summary>
BlockDimension6X6,
/// <summary>: 3.20 bpp</summary>
BlockDimension8X5,
/// <summary>: 2.67 bpp</summary>
BlockDimension8X6,
/// <summary>: 2.56 bpp</summary>
BlockDimension10X5,
/// <summary>: 2.13 bpp</summary>
BlockDimension10X6,
/// <summary>: 2.00 bpp</summary>
BlockDimension8X8,
/// <summary>: 1.60 bpp</summary>
BlockDimension10X8,
/// <summary>: 1.28 bpp</summary>
BlockDimension10X10,
/// <summary>: 1.07 bpp</summary>
BlockDimension12X10,
/// <summary>: 0.89 bpp</summary>
BlockDimension12X12,
/// <summary>: 4.74 bpp</summary>
BlockDimension3X3X3,
/// <summary>: 3.56 bpp</summary>
BlockDimension4X3X3,
/// <summary>: 2.67 bpp</summary>
BlockDimension4X4X3,
/// <summary>: 2.00 bpp</summary>
BlockDimension4X4X4,
/// <summary>: 1.60 bpp</summary>
BlockDimension5X4X4,
/// <summary>: 1.28 bpp</summary>
BlockDimension5X5X4,
/// <summary>: 1.02 bpp</summary>
BlockDimension5X5X5,
/// <summary>: 0.85 bpp</summary>
BlockDimension6X5X5,
/// <summary>: 0.71 bpp</summary>
BlockDimension6X6X5,
/// <summary>: 0.59 bpp</summary>
BlockDimension6X6X6,
BlockDimensionMax = 23,
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,16 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public enum KtxPackAstcQualityLevels : int
{
Fastest = 0,
Fast = 10,
Medium = 60,
Thorough = 98,
Exhaustive = 100,
Max = 100,
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,23 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
[System.Flags]
public enum KtxPackUastcFlagBits : int
{
LevelFastest = 0,
LevelFaster = 1,
LevelDefault = 2,
LevelSlower = 3,
LevelVeryslow = 4,
MaxLevel = 4,
LevelMask = 15,
FavorUastcError = 8,
FavorBc7Error = 16,
Etc1FasterHints = 64,
Etc1FastestHints = 128,
Etc1DisableFlipAndIndividual = 256,
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,26 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public enum KtxSupercmpScheme : int
{
/// <summary>No supercompression.</summary>
None = 0,
/// <summary>Basis LZ supercompression.</summary>
BasisLz = 1,
/// <summary>ZStd supercompression.</summary>
Zstd = 2,
/// <summary>ZLIB supercompression.</summary>
Zlib = 3,
BeginRange = 0,
EndRange = 3,
BeginVendorRange = 65536,
EndVendorRange = 131071,
BeginReserved = 131072,
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,171 @@
#pragma warning disable 1591
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Brutal.Pointers.Extensions;
namespace Brutal.KtxApi
{
public static unsafe partial class KtxTexture
{
[LibraryImport("Ktx", EntryPoint = "ktxTexture_CreateFromNamedFile1")]
public static unsafe partial KtxErrorCode CreateFromNamedFile(
ReadOnlySpan<byte> filename,
KtxTextureCreateFlagBits createFlags,
out KtxTextureHandle newTex
);
public static unsafe KtxErrorCode CreateFromMemory(
ReadOnlySpan<byte> bytes,
KtxTextureCreateFlagBits createFlags,
out KtxTextureHandle newTex
)
{
return CreateFromMemoryRealInterop(
ref Unsafe.AsRef<byte>(bytes.AsPointer()),
bytes.AsPointer() is not null ? (ulong)bytes.Length : 0,
createFlags,
out newTex
);
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_CreateFromMemory1")]
private static unsafe partial KtxErrorCode CreateFromMemoryRealInterop(
ref readonly byte bytes,
ulong size,
KtxTextureCreateFlagBits createFlags,
out KtxTextureHandle newTex
);
/// <summary>Returns a pointer to the image data of a ktxTexture object.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetData1")]
public static unsafe partial byte* GetData(this KtxTextureHandle thisParam);
/// <summary>Returns the pitch of a row of an image at the specified level.Similar to the rowPitch in a VkSubResourceLayout.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetRowPitch1")]
public static unsafe partial uint GetRowPitch(this KtxTextureHandle thisParam, uint level);
/// <summary>Return the element size of the texture's images.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetElementSize1")]
public static unsafe partial uint GetElementSize(this KtxTextureHandle thisParam);
/// <summary>Returns the size of all the image data of a ktxTexture object in bytes.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetDataSize1")]
public static unsafe partial ulong GetDataSize(this KtxTextureHandle thisParam);
/// <summary>Iterate over the levels or faces in a ktxTexture object.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_IterateLevelFaces1")]
public static unsafe partial KtxErrorCode IterateLevelFaces(
this KtxTextureHandle thisParam,
IterateCallbackDelegate iterCb,
IntPtr userdata
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetVkFormat1")]
public static unsafe partial VkFormat GetVkFormat(this KtxTextureHandle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_Destroy1")]
public static unsafe partial void Destroy(this KtxTextureHandle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetImageOffset1")]
public static unsafe partial KtxErrorCode GetImageOffset(
this KtxTextureHandle thisParam,
uint level,
uint layer,
uint faceSlice,
out ulong pOffset
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetDataSizeUncompressed1")]
public static unsafe partial ulong GetDataSizeUncompressed(this KtxTextureHandle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetImageSize1")]
public static unsafe partial ulong GetImageSize(this KtxTextureHandle thisParam, uint level);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetLevelSize1")]
public static unsafe partial ulong GetLevelSize(this KtxTextureHandle thisParam, uint level);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_IterateLevels1")]
public static unsafe partial KtxErrorCode IterateLevels(
this KtxTextureHandle thisParam,
IterateCallbackDelegate iterCb,
IntPtr userdata
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_IterateLoadLevelFaces1")]
public static unsafe partial KtxErrorCode IterateLoadLevelFaces(
this KtxTextureHandle thisParam,
IterateCallbackDelegate iterCb,
IntPtr userdata
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_NeedsTranscoding1")]
public static unsafe partial Bool8 NeedsTranscoding(this KtxTextureHandle thisParam);
public static unsafe KtxErrorCode LoadImageData(this KtxTextureHandle thisParam, Span<byte> pBuffer)
{
return LoadImageDataRealInterop(
thisParam,
ref *pBuffer.AsPointer(),
pBuffer.AsPointer() is not null ? (ulong)pBuffer.Length : 0
);
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_LoadImageData1")]
private static unsafe partial KtxErrorCode LoadImageDataRealInterop(
this KtxTextureHandle thisParam,
ref byte pBuffer,
ulong bufSize
);
public static unsafe KtxErrorCode SetImageFromMemory(
this KtxTextureHandle thisParam,
uint level,
uint layer,
uint faceSlice,
ReadOnlySpan<byte> src
)
{
return SetImageFromMemoryRealInterop(
thisParam,
level,
layer,
faceSlice,
ref *src.AsPointer(),
(ulong)src.Length
);
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_SetImageFromMemory1")]
private static unsafe partial KtxErrorCode SetImageFromMemoryRealInterop(
this KtxTextureHandle thisParam,
uint level,
uint layer,
uint faceSlice,
ref readonly byte src,
ulong srcSize
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_WriteToNamedFile1")]
public static unsafe partial KtxErrorCode WriteToNamedFile(
this KtxTextureHandle thisParam,
ReadOnlySpan<byte> dstname
);
public static unsafe KtxErrorCode WriteToMemory(this KtxTextureHandle thisParam, out KtxNativeBuffer bytes)
{
byte* mem;
ulong size;
var returnValue = WriteToMemoryRealInterop(thisParam, out mem, out size);
bytes = new KtxNativeBuffer(mem, size);
return returnValue;
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_WriteToMemory1")]
private static unsafe partial KtxErrorCode WriteToMemoryRealInterop(
this KtxTextureHandle thisParam,
out byte* bytes,
out ulong size
);
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,201 @@
#pragma warning disable 1591
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Brutal.Pointers.Extensions;
namespace Brutal.KtxApi
{
public static unsafe partial class KtxTexture1
{
[LibraryImport("Ktx", EntryPoint = "ktxTexture1_CreateFromNamedFile1")]
public static unsafe partial KtxErrorCode CreateFromNamedFile(
ReadOnlySpan<byte> filename,
KtxTextureCreateFlagBits createFlags,
out KtxTexture1Handle newTex
);
public static unsafe KtxErrorCode CreateFromMemory(
ReadOnlySpan<byte> bytes,
KtxTextureCreateFlagBits createFlags,
out KtxTexture1Handle newTex
)
{
return CreateFromMemoryRealInterop(
ref Unsafe.AsRef<byte>(bytes.AsPointer()),
bytes.AsPointer() is not null ? (ulong)bytes.Length : 0,
createFlags,
out newTex
);
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture1_CreateFromMemory1")]
private static unsafe partial KtxErrorCode CreateFromMemoryRealInterop(
ref readonly byte bytes,
ulong size,
KtxTextureCreateFlagBits createFlags,
out KtxTexture1Handle newTex
);
/// <summary>Create a new ktxTexture1.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture1_Create1")]
public static unsafe partial KtxErrorCode Create(
ref readonly KtxTextureCreateInfo createInfo,
KtxTextureCreateStorageEnum storageAllocation,
out KtxTexture1Handle newTex
);
/// <summary>Returns a pointer to the image data of a ktxTexture object.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetData1")]
public static unsafe partial byte* GetData(this KtxTexture1Handle thisParam);
/// <summary>Returns the pitch of a row of an image at the specified level.Similar to the rowPitch in a VkSubResourceLayout.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetRowPitch1")]
public static unsafe partial uint GetRowPitch(this KtxTexture1Handle thisParam, uint level);
/// <summary>Return the element size of the texture's images.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetElementSize1")]
public static unsafe partial uint GetElementSize(this KtxTexture1Handle thisParam);
/// <summary>Returns the size of all the image data of a ktxTexture object in bytes.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetDataSize1")]
public static unsafe partial ulong GetDataSize(this KtxTexture1Handle thisParam);
/// <summary>Iterate over the levels or faces in a ktxTexture object.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_IterateLevelFaces1")]
public static unsafe partial KtxErrorCode IterateLevelFaces(
this KtxTexture1Handle thisParam,
IterateCallbackDelegate iterCb,
IntPtr userdata
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture1_GetVkFormat1")]
public static unsafe partial VkFormat GetVkFormat(this KtxTexture1Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_Destroy1")]
public static unsafe partial void Destroy(this KtxTexture1Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetImageOffset1")]
public static unsafe partial KtxErrorCode GetImageOffset(
this KtxTexture1Handle thisParam,
uint level,
uint layer,
uint faceSlice,
out ulong pOffset
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetDataSizeUncompressed1")]
public static unsafe partial ulong GetDataSizeUncompressed(this KtxTexture1Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetImageSize1")]
public static unsafe partial ulong GetImageSize(this KtxTexture1Handle thisParam, uint level);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetLevelSize1")]
public static unsafe partial ulong GetLevelSize(this KtxTexture1Handle thisParam, uint level);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_IterateLevels1")]
public static unsafe partial KtxErrorCode IterateLevels(
this KtxTexture1Handle thisParam,
IterateCallbackDelegate iterCb,
IntPtr userdata
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_IterateLoadLevelFaces1")]
public static unsafe partial KtxErrorCode IterateLoadLevelFaces(
this KtxTexture1Handle thisParam,
IterateCallbackDelegate iterCb,
IntPtr userdata
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_NeedsTranscoding1")]
public static unsafe partial Bool8 NeedsTranscoding(this KtxTexture1Handle thisParam);
public static unsafe KtxErrorCode LoadImageData(this KtxTexture1Handle thisParam, Span<byte> pBuffer)
{
return LoadImageDataRealInterop(
thisParam,
ref *pBuffer.AsPointer(),
pBuffer.AsPointer() is not null ? (ulong)pBuffer.Length : 0
);
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_LoadImageData1")]
private static unsafe partial KtxErrorCode LoadImageDataRealInterop(
this KtxTexture1Handle thisParam,
ref byte pBuffer,
ulong bufSize
);
public static unsafe KtxErrorCode SetImageFromMemory(
this KtxTexture1Handle thisParam,
uint level,
uint layer,
uint faceSlice,
ReadOnlySpan<byte> src
)
{
return SetImageFromMemoryRealInterop(
thisParam,
level,
layer,
faceSlice,
ref *src.AsPointer(),
(ulong)src.Length
);
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_SetImageFromMemory1")]
private static unsafe partial KtxErrorCode SetImageFromMemoryRealInterop(
this KtxTexture1Handle thisParam,
uint level,
uint layer,
uint faceSlice,
ref readonly byte src,
ulong srcSize
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_WriteToNamedFile1")]
public static unsafe partial KtxErrorCode WriteToNamedFile(
this KtxTexture1Handle thisParam,
ReadOnlySpan<byte> dstname
);
public static unsafe KtxErrorCode WriteToMemory(this KtxTexture1Handle thisParam, out KtxNativeBuffer bytes)
{
byte* mem;
ulong size;
var returnValue = WriteToMemoryRealInterop(thisParam, out mem, out size);
bytes = new KtxNativeBuffer(mem, size);
return returnValue;
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_WriteToMemory1")]
private static unsafe partial KtxErrorCode WriteToMemoryRealInterop(
this KtxTexture1Handle thisParam,
out byte* bytes,
out ulong size
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture1_WriteKTX2ToNamedFile1")]
public static unsafe partial KtxErrorCode WriteKtx2ToNamedFile(
this KtxTexture1Handle thisParam,
ReadOnlySpan<byte> dstname
);
public static unsafe KtxErrorCode WriteKtx2ToMemory(this KtxTexture1Handle thisParam, out KtxNativeBuffer bytes)
{
byte* mem;
ulong size;
var returnValue = WriteKtx2ToMemoryRealInterop(thisParam, out mem, out size);
bytes = new KtxNativeBuffer(mem, size);
return returnValue;
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture1_WriteKTX2ToMemory1")]
private static unsafe partial KtxErrorCode WriteKtx2ToMemoryRealInterop(
this KtxTexture1Handle thisParam,
out byte* bytes,
out ulong size
);
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,55 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public partial struct KtxTexture1Handle : INullable, IDisposable
{
public KtxTexture1Handle(nint impl)
{
_impl = impl;
}
/// <summary>Returns whether the handle has been initialised or not.</summary>
public bool IsNull() => _impl is 0;
internal nint Impl => _impl;
public void Dispose() => Release();
public static implicit operator KtxTextureHandle(KtxTexture1Handle handle) => new KtxTextureHandle(handle.Impl);
public unsafe ref KtxTexture1Native Ptr => ref *(KtxTexture1Native*)_impl;
public ClassId ClassId => Ptr.ClassId;
public unsafe KtxTextureProtected* Protected => Ptr.Protected;
public Bool8 IsArray => Ptr.IsArray;
public Bool8 IsCubemap => Ptr.IsCubemap;
public Bool8 IsCompressed => Ptr.IsCompressed;
public Bool8 GenerateMipmaps => Ptr.GenerateMipmaps;
public uint BaseWidth => Ptr.BaseWidth;
public uint BaseHeight => Ptr.BaseHeight;
public uint BaseDepth => Ptr.BaseDepth;
public uint NumDimensions => Ptr.NumDimensions;
public uint NumLevels => Ptr.NumLevels;
public uint NumLayers => Ptr.NumLayers;
public uint NumFaces => Ptr.NumFaces;
public Orientation Orientation => Ptr.Orientation;
public ulong DataSize => Ptr.DataSize;
public unsafe byte* PData => Ptr.PData;
public uint GlFormat => Ptr.GlFormat;
public uint GlInternalformat => Ptr.GlInternalformat;
public uint GlBaseInternalformat => Ptr.GlBaseInternalformat;
public uint GlType => Ptr.GlType;
private void Release()
{
var impl = Interlocked.Exchange(ref _impl, 0);
if (impl == 0)
return;
KtxTexture1.Destroy(new(impl));
}
private nint _impl;
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,74 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
[StructLayout(LayoutKind.Explicit, Pack = 8)]
public unsafe partial struct KtxTexture1Native
{
[FieldOffset(0)]
public readonly ClassId ClassId;
[FieldOffset(24)]
public readonly KtxTextureProtected* Protected;
[FieldOffset(32)]
public readonly Bool8 IsArray;
[FieldOffset(33)]
public readonly Bool8 IsCubemap;
[FieldOffset(34)]
public readonly Bool8 IsCompressed;
[FieldOffset(35)]
public readonly Bool8 GenerateMipmaps;
[FieldOffset(36)]
public readonly uint BaseWidth;
[FieldOffset(40)]
public readonly uint BaseHeight;
[FieldOffset(44)]
public readonly uint BaseDepth;
[FieldOffset(48)]
public readonly uint NumDimensions;
[FieldOffset(52)]
public readonly uint NumLevels;
[FieldOffset(56)]
public readonly uint NumLayers;
[FieldOffset(60)]
public readonly uint NumFaces;
[FieldOffset(64)]
public readonly Orientation Orientation;
[FieldOffset(104)]
public readonly ulong DataSize;
[FieldOffset(112)]
public readonly byte* PData;
/// <summary>Format of the texture data, e.g., GL_RGB.</summary>
[FieldOffset(120)]
public readonly uint GlFormat;
/// <summary>Internal format of the texture data,e.g., GL_RGB8.</summary>
[FieldOffset(124)]
public readonly uint GlInternalformat;
/// <summary>Base format of the texture data,e.g., GL_RGB.</summary>
[FieldOffset(128)]
public readonly uint GlBaseInternalformat;
/// <summary>Type of the texture data, e.g, GL_UNSIGNED_BYTE.</summary>
[FieldOffset(132)]
public readonly uint GlType;
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,283 @@
#pragma warning disable 1591
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Brutal.Pointers.Extensions;
namespace Brutal.KtxApi
{
public static unsafe partial class KtxTexture2
{
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_CreateFromNamedFile1")]
public static unsafe partial KtxErrorCode CreateFromNamedFile(
ReadOnlySpan<byte> filename,
KtxTextureCreateFlagBits createFlags,
out KtxTexture2Handle newTex
);
public static unsafe KtxErrorCode CreateFromMemory(
ReadOnlySpan<byte> bytes,
KtxTextureCreateFlagBits createFlags,
out KtxTexture2Handle newTex
)
{
return CreateFromMemoryRealInterop(
ref Unsafe.AsRef<byte>(bytes.AsPointer()),
bytes.AsPointer() is not null ? (ulong)bytes.Length : 0,
createFlags,
out newTex
);
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_CreateFromMemory1")]
private static unsafe partial KtxErrorCode CreateFromMemoryRealInterop(
ref readonly byte bytes,
ulong size,
KtxTextureCreateFlagBits createFlags,
out KtxTexture2Handle newTex
);
/// <summary>Create a new ktxTexture2.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_Create1")]
public static unsafe partial KtxErrorCode Create(
ref readonly KtxTextureCreateInfo createInfo,
KtxTextureCreateStorageEnum storageAllocation,
out KtxTexture2Handle newTex
);
/// <summary>Returns a pointer to the image data of a ktxTexture object.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetData1")]
public static unsafe partial byte* GetData(this KtxTexture2Handle thisParam);
/// <summary>Returns the pitch of a row of an image at the specified level.Similar to the rowPitch in a VkSubResourceLayout.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetRowPitch1")]
public static unsafe partial uint GetRowPitch(this KtxTexture2Handle thisParam, uint level);
/// <summary>Return the element size of the texture's images.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetElementSize1")]
public static unsafe partial uint GetElementSize(this KtxTexture2Handle thisParam);
/// <summary>Returns the size of all the image data of a ktxTexture object in bytes.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetDataSize1")]
public static unsafe partial ulong GetDataSize(this KtxTexture2Handle thisParam);
/// <summary>Iterate over the levels or faces in a ktxTexture object.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture_IterateLevelFaces1")]
public static unsafe partial KtxErrorCode IterateLevelFaces(
this KtxTexture2Handle thisParam,
IterateCallbackDelegate iterCb,
IntPtr userdata
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_GetVkFormat1")]
public static unsafe partial VkFormat GetVkFormat(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_Destroy1")]
public static unsafe partial void Destroy(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetImageOffset1")]
public static unsafe partial KtxErrorCode GetImageOffset(
this KtxTexture2Handle thisParam,
uint level,
uint layer,
uint faceSlice,
out ulong pOffset
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetDataSizeUncompressed1")]
public static unsafe partial ulong GetDataSizeUncompressed(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetImageSize1")]
public static unsafe partial ulong GetImageSize(this KtxTexture2Handle thisParam, uint level);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_GetLevelSize1")]
public static unsafe partial ulong GetLevelSize(this KtxTexture2Handle thisParam, uint level);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_IterateLevels1")]
public static unsafe partial KtxErrorCode IterateLevels(
this KtxTexture2Handle thisParam,
IterateCallbackDelegate iterCb,
IntPtr userdata
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_IterateLoadLevelFaces1")]
public static unsafe partial KtxErrorCode IterateLoadLevelFaces(
this KtxTexture2Handle thisParam,
IterateCallbackDelegate iterCb,
IntPtr userdata
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_NeedsTranscoding1")]
public static unsafe partial Bool8 NeedsTranscoding(this KtxTexture2Handle thisParam);
public static unsafe KtxErrorCode LoadImageData(this KtxTexture2Handle thisParam, Span<byte> pBuffer)
{
return LoadImageDataRealInterop(
thisParam,
ref *pBuffer.AsPointer(),
pBuffer.AsPointer() is not null ? (ulong)pBuffer.Length : 0
);
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_LoadImageData1")]
private static unsafe partial KtxErrorCode LoadImageDataRealInterop(
this KtxTexture2Handle thisParam,
ref byte pBuffer,
ulong bufSize
);
public static unsafe KtxErrorCode SetImageFromMemory(
this KtxTexture2Handle thisParam,
uint level,
uint layer,
uint faceSlice,
ReadOnlySpan<byte> src
)
{
return SetImageFromMemoryRealInterop(
thisParam,
level,
layer,
faceSlice,
ref *src.AsPointer(),
(ulong)src.Length
);
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_SetImageFromMemory1")]
private static unsafe partial KtxErrorCode SetImageFromMemoryRealInterop(
this KtxTexture2Handle thisParam,
uint level,
uint layer,
uint faceSlice,
ref readonly byte src,
ulong srcSize
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture_WriteToNamedFile1")]
public static unsafe partial KtxErrorCode WriteToNamedFile(
this KtxTexture2Handle thisParam,
ReadOnlySpan<byte> dstname
);
public static unsafe KtxErrorCode WriteToMemory(this KtxTexture2Handle thisParam, out KtxNativeBuffer bytes)
{
byte* mem;
ulong size;
var returnValue = WriteToMemoryRealInterop(thisParam, out mem, out size);
bytes = new KtxNativeBuffer(mem, size);
return returnValue;
}
[LibraryImport("Ktx", EntryPoint = "ktxTexture_WriteToMemory1")]
private static unsafe partial KtxErrorCode WriteToMemoryRealInterop(
this KtxTexture2Handle thisParam,
out byte* bytes,
out ulong size
);
/// <summary>Create a new ktxTexture2 as a copy of an existing texture.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_CreateCopy1")]
public static unsafe partial KtxErrorCode CreateCopy(this KtxTexture2Handle orig, out KtxTexture2Handle newTex);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_CompressBasis1")]
public static unsafe partial KtxErrorCode CompressBasis(this KtxTexture2Handle thisParam, uint quality);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_CompressBasisEx1")]
public static unsafe partial KtxErrorCode CompressBasisEx(
this KtxTexture2Handle thisParam,
ref readonly KtxBasisParams basisParams
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_DeflateZstd1")]
public static unsafe partial KtxErrorCode DeflateZstd(this KtxTexture2Handle thisParam, uint level);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_DeflateZLIB1")]
public static unsafe partial KtxErrorCode DeflateZlib(this KtxTexture2Handle thisParam, uint level);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_GetComponentInfo1")]
public static unsafe partial void GetComponentInfo(
this KtxTexture2Handle thisParam,
out uint numComponents,
out uint componentByteLength
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_GetNumComponents1")]
public static unsafe partial uint GetNumComponents(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_GetTransferFunction_e1")]
public static unsafe partial KhrDfTransfer GetTransferFunctionE(this KtxTexture2Handle thisParam);
/// <summary>For backward compatibility.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_GetOETF_e1")]
public static unsafe partial KhrDfTransfer GetOetfE(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_GetOETF1")]
public static unsafe partial uint GetOetf(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_GetColorModel_e1")]
public static unsafe partial KhrDfModel GetColorModelE(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_GetPremultipliedAlpha1")]
public static unsafe partial Bool8 GetPremultipliedAlpha(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_GetPrimaries_e1")]
public static unsafe partial KhrDfPrimaries GetPrimariesE(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_SetTransferFunction1")]
public static unsafe partial KtxErrorCode SetTransferFunction(
this KtxTexture2Handle thisParam,
KhrDfTransfer tf
);
/// <summary>For backward compatibility.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_SetOETF1")]
public static unsafe partial KtxErrorCode SetOetf(this KtxTexture2Handle thisParam, KhrDfTransfer oetf);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_SetPrimaries1")]
public static unsafe partial KtxErrorCode SetPrimaries(
this KtxTexture2Handle thisParam,
KhrDfPrimaries primaries
);
/// <summary>For rare testing scenarios. Use ktxTexture2_LoadImageData.</summary>
public static unsafe KtxErrorCode LoadDeflatedImageData(this KtxTexture2Handle thisParam, Span<byte> pBuffer)
{
return LoadDeflatedImageDataRealInterop(
thisParam,
ref *pBuffer.AsPointer(),
pBuffer.AsPointer() is not null ? (ulong)pBuffer.Length : 0
);
}
/// <summary>For rare testing scenarios. Use ktxTexture2_LoadImageData.</summary>
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_LoadDeflatedImageData1")]
private static unsafe partial KtxErrorCode LoadDeflatedImageDataRealInterop(
this KtxTexture2Handle thisParam,
ref byte pBuffer,
ulong bufSize
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_TranscodeBasis1")]
public static unsafe partial KtxErrorCode TranscodeBasis(
this KtxTexture2Handle thisParam,
KtxTranscodeFmt fmt,
KtxTranscodeFlagBits transcodeFlags
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_CompressAstcEx1")]
public static unsafe partial KtxErrorCode CompressAstcEx(
this KtxTexture2Handle thisParam,
ref readonly KtxAstcParams basisParams
);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_DecodeAstc1")]
public static unsafe partial KtxErrorCode DecodeAstc(this KtxTexture2Handle thisParam);
[LibraryImport("Ktx", EntryPoint = "ktxTexture2_CompressAstc1")]
public static unsafe partial KtxErrorCode CompressAstc(
this KtxTexture2Handle thisParam,
KtxPackAstcQualityLevels quality
);
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,58 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
public partial struct KtxTexture2Handle : INullable, IDisposable
{
public KtxTexture2Handle(nint impl)
{
_impl = impl;
}
/// <summary>Returns whether the handle has been initialised or not.</summary>
public bool IsNull() => _impl is 0;
internal nint Impl => _impl;
public void Dispose() => Release();
public static implicit operator KtxTextureHandle(KtxTexture2Handle handle) => new KtxTextureHandle(handle.Impl);
public unsafe ref KtxTexture2Native Ptr => ref *(KtxTexture2Native*)_impl;
public ClassId ClassId => Ptr.ClassId;
public unsafe KtxTextureProtected* Protected => Ptr.Protected;
public Bool8 IsArray => Ptr.IsArray;
public Bool8 IsCubemap => Ptr.IsCubemap;
public Bool8 IsCompressed => Ptr.IsCompressed;
public Bool8 GenerateMipmaps => Ptr.GenerateMipmaps;
public uint BaseWidth => Ptr.BaseWidth;
public uint BaseHeight => Ptr.BaseHeight;
public uint BaseDepth => Ptr.BaseDepth;
public uint NumDimensions => Ptr.NumDimensions;
public uint NumLevels => Ptr.NumLevels;
public uint NumLayers => Ptr.NumLayers;
public uint NumFaces => Ptr.NumFaces;
public Orientation Orientation => Ptr.Orientation;
public ulong DataSize => Ptr.DataSize;
public unsafe byte* PData => Ptr.PData;
public uint VkFormat => Ptr.VkFormat;
public unsafe uint* PDfd => Ptr.PDfd;
public KtxSupercmpScheme SupercompressionScheme => Ptr.SupercompressionScheme;
public Bool8 IsVideo => Ptr.IsVideo;
public uint Duration => Ptr.Duration;
public uint Timescale => Ptr.Timescale;
public uint Loopcount => Ptr.Loopcount;
private void Release()
{
var impl = Interlocked.Exchange(ref _impl, 0);
if (impl == 0)
return;
KtxTexture2.Destroy(new(impl));
}
private nint _impl;
}
}
#pragma warning restore 1591

View file

@ -0,0 +1,79 @@
#pragma warning disable 1591
using System.Runtime.InteropServices;
namespace Brutal.KtxApi
{
[StructLayout(LayoutKind.Explicit, Pack = 8)]
public unsafe partial struct KtxTexture2Native
{
[FieldOffset(0)]
public readonly ClassId ClassId;
[FieldOffset(24)]
public readonly KtxTextureProtected* Protected;
[FieldOffset(32)]
public readonly Bool8 IsArray;
[FieldOffset(33)]
public readonly Bool8 IsCubemap;
[FieldOffset(34)]
public readonly Bool8 IsCompressed;
[FieldOffset(35)]
public readonly Bool8 GenerateMipmaps;
[FieldOffset(36)]
public readonly uint BaseWidth;
[FieldOffset(40)]
public readonly uint BaseHeight;
[FieldOffset(44)]
public readonly uint BaseDepth;
[FieldOffset(48)]
public readonly uint NumDimensions;
[FieldOffset(52)]
public readonly uint NumLevels;
[FieldOffset(56)]
public readonly uint NumLayers;
[FieldOffset(60)]
public readonly uint NumFaces;
[FieldOffset(64)]
public readonly Orientation Orientation;
[FieldOffset(104)]
public readonly ulong DataSize;
[FieldOffset(112)]
public readonly byte* PData;
[FieldOffset(120)]
public readonly uint VkFormat;
[FieldOffset(128)]
public readonly uint* PDfd;
[FieldOffset(136)]
public readonly KtxSupercmpScheme SupercompressionScheme;
[FieldOffset(140)]
public readonly Bool8 IsVideo;
[FieldOffset(144)]
public readonly uint Duration;
[FieldOffset(148)]
public readonly uint Timescale;
[FieldOffset(152)]
public readonly uint Loopcount;
}
}
#pragma warning restore 1591

Some files were not shown because too many files have changed in this diff Show more