HelixToolkit.Nex.Graphics.Vulkan
1.2.0
dotnet add package HelixToolkit.Nex.Graphics.Vulkan --version 1.2.0
NuGet\Install-Package HelixToolkit.Nex.Graphics.Vulkan -Version 1.2.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="HelixToolkit.Nex.Graphics.Vulkan" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HelixToolkit.Nex.Graphics.Vulkan" Version="1.2.0" />
<PackageReference Include="HelixToolkit.Nex.Graphics.Vulkan" />
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 HelixToolkit.Nex.Graphics.Vulkan --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: HelixToolkit.Nex.Graphics.Vulkan, 1.2.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 HelixToolkit.Nex.Graphics.Vulkan@1.2.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=HelixToolkit.Nex.Graphics.Vulkan&version=1.2.0
#tool nuget:?package=HelixToolkit.Nex.Graphics.Vulkan&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
# HelixToolkit.Nex.Graphics.Vulkan
HelixToolkit.Nex.Graphics.Vulkan is a C# package that provides a robust and efficient interface for 3D graphics rendering using the Vulkan API. It is part of the HelixToolkit-Nex engine, designed to leverage Vulkan's capabilities for high-performance graphics applications.
## Overview
HelixToolkit.Nex.Graphics.Vulkan is a critical component of the HelixToolkit-Nex engine, responsible for managing Vulkan-based rendering operations. It provides abstractions for command buffers, pipelines, and other Vulkan constructs, facilitating the creation and management of complex 3D scenes. The package integrates with the engine's ECS architecture and render graph system, ensuring efficient rendering and resource management.
Key features include:
- Reverse-Z projection matrices for improved depth precision.
- Forward Plus light culling for efficient lighting calculations.
- GPU-based frustum and instance culling for optimized rendering.
- Support for Vulkan's advanced features like mesh shaders and dynamic rendering.
- Enhanced support for Vulkan features such as `shaderSampledImageArrayDynamicIndexing`, `shaderInt64`, `shaderInt16`, `extendedDynamicState`, and `colorWriteEnable`.
- Support for Linux configurations with `LinuxDebug` and `LinuxRelease`.
- New support for Linux external-memory-fd extensions for interop with Avalonia/EGL.
## Key Types
| Type | Description |
|-------------------------------|-----------------------------------------------------------------------------|
| `CommandBuffer` | Manages Vulkan command buffers for recording GPU commands. |
| `VulkanContext` | Represents the Vulkan graphics context, managing device and resource setup. |
| `VulkanImage` | Encapsulates Vulkan image resources, including views and memory management. |
| `VulkanImmediateCommands` | Handles immediate command buffer execution and synchronization. |
| `VulkanPipelineBuilder` | Facilitates the creation of Vulkan graphics pipelines. |
| `VulkanStagingDevice` | Manages staging buffers for efficient data transfer to the GPU. |
| `BarrierPlanner` | Provides GPU-free helpers for deciding what barriers to emit. |
| `Bindings` (enum) | Defines descriptor set binding points for Vulkan pipelines. |
| `DeviceQueues` | Manages Vulkan device queues for graphics, compute, and transfer operations.|
## Usage Examples
### Creating a Vulkan Context
```csharp
var config = new VulkanContextConfig
{
EnableValidation = true,
EnableVma = true,
TerminateOnValidationError = false,
PreferredPresentMode = VkPresentModeKHR.FifoRelaxed,
ForceIntegratedGPU = false,
MaxStagingBufferSize = 128u * 1024u * 1024u,
EnableExternalMemoryFd = true // Enable external memory FD for Linux interop
};
var context = VulkanBuilder.Create(config, windowHandle, displayHandle);
Recording Commands
var commandBuffer = context.AcquireCommandBuffer();
commandBuffer.BeginEncoding();
commandBuffer.BeginRendering(renderPass, framebuffer, dependencies);
commandBuffer.BindRenderPipeline(pipelineHandle);
commandBuffer.Draw(vertexCount, instanceCount, firstVertex, baseInstance);
commandBuffer.EndRendering();
commandBuffer.EndEncoding();
context.Submit(commandBuffer, presentTexture, syncInfo);
Creating a Texture
var textureDesc = new TextureDesc
{
Format = Format.RGBA_UN8,
Dimensions = new Dimensions(1024, 1024, 1),
Usage = TextureUsageBits.Sampled | TextureUsageBits.Storage
};
context.CreateTexture(textureDesc, out var textureResource, "MyTexture");
Generating Mipmaps
context.GenerateMipmap(textureResource.Handle, out uint levels);
Console.WriteLine($"Generated {levels} mipmap levels.");
Enabling Color Write
var colorWrites = new bool[] { true, false, true }; // Enable/disable color writes for attachments
commandBuffer.SetColorWriteEnabled(colorWrites);
Setting Color Write for Specific Attachments
commandBuffer.SetColorWriteEnabled(true, false, true, false);
Copying Texture to Buffer
commandBuffer.CopyTextureToBuffer(
srcTextureHandle,
dstBufferHandle,
bufferOffset: 0,
srcOffset: new Offset3D(0, 0, 0),
extent: new Dimensions(512, 512, 1),
layers: new TextureLayers(0, 1, 0, 1)
);
Setting Cull Mode
commandBuffer.SetCullMode(CullMode.Back);
Marking a Buffer as Dirty
context.MarkDirty(bufferHandle);
Marking a Buffer for Host Write
context.MarkHostWrite(bufferHandle, offset: 0, size: 1024);
Using Image Barriers
var transition = ImageTransition.ToShaderReadOnly;
if (commandBuffer.ImageBarrier(textureHandle, transition))
{
Console.WriteLine("Image barrier applied successfully.");
}
Using Buffer Barriers
commandBuffer.Barrier(bufferHandle, PipelineStageFlags.FragmentShader, AccessFlags.ShaderRead);
Transitioning Textures to Shader Read-Only
commandBuffer.TransitionToShaderReadOnly(textureHandle, ShaderStage.Vertex);
Architecture Notes
Dependencies:
- HelixToolkit.Nex.Maths
- HelixToolkit.Nex.Shaders
- Vortice.Vulkan
- Microsoft.Extensions.Logging
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Glslang.NET (>= 1.2.0)
- HelixToolkit.Nex.Graphics (>= 1.2.0)
- HelixToolkit.Nex.Maths (>= 1.2.0)
- HelixToolkit.Nex.Shaders (>= 1.2.0)
- Vortice.SPIRV (>= 1.0.4)
- Vortice.SPIRV.Reflect (>= 1.0.5)
- Vortice.Vulkan (>= 2.2.0)
- Vortice.VulkanMemoryAllocator (>= 1.6.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on HelixToolkit.Nex.Graphics.Vulkan:
| Package | Downloads |
|---|---|
|
HelixToolkit.Nex.Interop
Package Description |
|
|
HelixToolkit.Nex.Interop.DirectX
Package Description |
|
|
HelixToolkit.Nex.Avalonia
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.0 | 151 | 7/17/2026 |