Ahjo.Vulkan.Ktx.Native 0.18.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ahjo.Vulkan.Ktx.Native --version 0.18.0
                    
NuGet\Install-Package Ahjo.Vulkan.Ktx.Native -Version 0.18.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ahjo.Vulkan.Ktx.Native" Version="0.18.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ahjo.Vulkan.Ktx.Native" Version="0.18.0" />
                    
Directory.Packages.props
<PackageReference Include="Ahjo.Vulkan.Ktx.Native" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ahjo.Vulkan.Ktx.Native --version 0.18.0
                    
#r "nuget: Ahjo.Vulkan.Ktx.Native, 0.18.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ahjo.Vulkan.Ktx.Native@0.18.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ahjo.Vulkan.Ktx.Native&version=0.18.0
                    
Install as a Cake Addin
#tool nuget:?package=Ahjo.Vulkan.Ktx.Native&version=0.18.0
                    
Install as a Cake Tool

Ahjo.Vulkan.Ktx.Native

Raw P/Invoke bindings for Khronos libktx — KTX2 container reading and Basis Universal transcoding — with native runtime binaries included for win-x64 and linux-x64.

The managed surface is generated with ClangSharpPInvokeGenerator from ktx.h at a pinned upstream tag. Nothing is hand-written, so the bindings are a mechanical function of that tag.

using Ahjo.Vulkan.Ktx.Native;

unsafe
{
    ktxTexture2* texture;
    fixed (byte* bytes = ktx2File)
    {
        var rc = Ktx.ktxTexture2_CreateFromMemory(
            bytes, (nuint)ktx2File.Length,
            (uint)ktxTextureCreateFlagBits.KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT,
            &texture);
        if (rc != ktx_error_code_e.KTX_SUCCESS) { /* handle */ }
    }

    if (Ktx.ktxTexture2_NeedsTranscoding(texture))
    {
        Ktx.ktxTexture2_TranscodeBasis(texture, ktx_transcode_fmt_e.KTX_TTF_BC7_RGBA, 0);
    }

    // texture->vkFormat, ->baseWidth/baseHeight, ->numLevels, ->pData, ->dataSize
    // are now the transcoded result. Upload them with your own resource path.
    Ktx.ktxTexture2_Destroy(texture);
}

What is and is not in the native library

The shipped ktx.dll / libktx.so is built from the pinned upstream tag with tools, tests, docs, the JNI and Python bindings, and both texture uploaders disabled.

Dropping KTX_FEATURE_VK_UPLOAD is the load-bearing choice: this package has no Vulkan dependency at all, and does not reference Ahjo.Vulkan.Native. libktx's own uploader creates its own VkImage and records its own barriers, which is precisely what a consumer that owns its resource pool and its synchronization does not want. The binding's contract ends at "here are transcoded bytes, a vkFormat, and mip offsets"; getting them onto the GPU is the caller's business.

The OpenGL entry points (ktxLoadOpenGL, ktxTexture_GLUpload) are therefore absent from the binary, and are excluded from generation as well — a binding whose only possible outcome is EntryPointNotFoundException is a trap, not a feature.

Platform support

RID Shipped Notes
win-x64 yes MSVC, x86-64
linux-x64 yes glibc; built on ubuntu-latest
*-arm64, osx-* no see below

arm64 and macOS are deliberately absent rather than untested. libktx links astc-encoder, whose SIMD backend is selected at compile time, so each RID needs a lane that actually loads the binary and transcodes before it can ship.

The x86-64 binaries require AVX2. That is upstream's default ISA selection for astc-encoder and matches the binaries Khronos publishes, so this package stays on the configuration upstream tests. CPUs older than roughly 2013 are out of scope.

Licensing

libktx is Apache-2.0 (Khronos Group); the bundled Basis Universal transcoder is Apache-2.0 (Binomial LLC). This package's own binding code is MIT, like the rest of the Ahjo.Vulkan repository.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.19.0 68 11/29/2026
0.18.1-alpha.0.6 59 11/29/2026
0.18.1-alpha.0.5 59 11/28/2026
0.18.1-alpha.0.4 59 11/28/2026
0.18.1-alpha.0.3 60 11/25/2026
0.18.1-alpha.0.2 76 11/13/2026
0.18.1-alpha.0.1 71 11/13/2026
0.18.0 119 11/13/2026
0.17.1-alpha.0.17 75 11/13/2026
0.17.1-alpha.0.16 75 11/13/2026
0.17.1-alpha.0.15 72 11/13/2026
0.17.1-alpha.0.14 70 11/13/2026
0.17.1-alpha.0.13 68 11/13/2026
0.17.1-alpha.0.12 63 11/13/2026
0.17.1-alpha.0.11 74 11/13/2026
0.17.1-alpha.0.10 66 11/13/2026
0.17.1-alpha.0.9 70 11/9/2026
0.17.1-alpha.0.8 72 11/6/2026
0.17.1-alpha.0.7 71 11/6/2026
0.17.1-alpha.0.6 74 11/6/2026
Loading failed