Skip to content

Class VulkanDevice

Namespace: Apogee.Graphics.Vulkan
Assembly: Apogee.Graphics.dll

The Vulkan implementation of : the instance, the logical device and everything created with it (the queue, the VMA allocator, the device commands). It owns the instance and, when it was created for a window, the window's surface. The engine's baseline is Vulkan 1.3 with dynamic rendering, synchronization2, buffer device addresses and descriptor indexing; a GPU without them is rejected with the reason.

public sealed class VulkanDevice : GraphicsDevice, IDisposable

Inheritance

object ← GraphicsDevice ← VulkanDevice

Implements

IDisposable

Inherited Members

GraphicsDevice.Backend, GraphicsDevice.ShaderBackend, GraphicsDevice.Name, GraphicsDevice.Kind, GraphicsDevice.Immediate, GraphicsDevice.Bindless, GraphicsDevice.TimestampPeriod, GraphicsDevice.SupportsTimestamps, GraphicsDevice.MinUniformBufferOffsetAlignment, GraphicsDevice.MaxSamplerAnisotropy, GraphicsDevice.SupportsBc, GraphicsDevice.SupportsAstc, GraphicsDevice.SupportsAnisotropy, GraphicsDevice.SupportsDrawIndirectCount, GraphicsDevice.SupportsSamplerFilterMinMax, GraphicsDevice.ValidationErrorCount, GraphicsDevice.TakeValidationErrors(), GraphicsDevice.DefaultBackend, GraphicsDevice.RequiredWindowOptions(GraphicsBackend?), GraphicsDevice.Create(GraphicsDeviceOptions?), GraphicsDevice.TryCreate(GraphicsDeviceOptions?, out GraphicsDevice?, out string?), GraphicsDevice.EnumerateDevices(GraphicsDeviceOptions?), GraphicsDevice.CreateBuffer(ulong, BufferUsage, MemoryKind, string?), GraphicsDevice.CreateImage(in ImageDescription, string?), GraphicsDevice.CreateSampler(in SamplerDescription, string?), GraphicsDevice.CreateComputePipeline(in ShaderCode, string?), GraphicsDevice.CreateGraphicsPipeline(GraphicsPipelineDescription, string?), GraphicsDevice.CreateSwapchain(bool), GraphicsDevice.CreateFrameLoop(Swapchain?, int, int), GraphicsDevice.WaitIdle(), GraphicsDevice.Dispose(), GraphicsDevice.CreateBuffer(ReadOnlySpan<byte>, BufferUsage, string?), GraphicsDevice.UploadBuffer(GpuBuffer, ReadOnlySpan<byte>, ulong), GraphicsDevice.UploadImage(GpuImage, ReadOnlySpan<byte>, ReadOnlySpan<ImageRegion>, ImageState), GraphicsDevice.ReadBuffer(GpuBuffer, ulong, int), GraphicsDevice.ReadImage(GpuImage, ImageState, uint, uint), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Properties

Allocator

public Allocator* Allocator { get; }

Property Value

Allocator*

Backend

public override GraphicsBackend Backend { get; }

Property Value

GraphicsBackend

Commands

public VkDeviceCommands Commands { get; }

Property Value

VkDeviceCommands

Handle

public VkDevice Handle { get; }

Property Value

VkDevice

Instance

public VulkanInstance Instance { get; }

Property Value

VulkanInstance

Kind

public override GpuKind Kind { get; }

Property Value

GpuKind

MaxPushConstantsSize

public uint MaxPushConstantsSize { get; }

Property Value

uint

MaxSamplerAnisotropy

public override float MaxSamplerAnisotropy { get; }

Property Value

float

MinUniformBufferOffsetAlignment

public override ulong MinUniformBufferOffsetAlignment { get; }

Property Value

ulong

Name

public override string Name { get; }

Property Value

string

Physical

public PhysicalDeviceInfo Physical { get; }

Property Value

PhysicalDeviceInfo

Queue

The one queue the engine submits to: graphics, compute and transfer, and presentation when a surface was given.

public VkQueue Queue { get; }

Property Value

VkQueue

QueueFamily

public uint QueueFamily { get; }

Property Value

uint

QueueLock

Held while submitting to : Vulkan queues need external synchronization.

public object QueueLock { get; }

Property Value

object

ShaderBackend

The kind of shader code this device runs: pass it to .

public override ShaderBackend ShaderBackend { get; }

Property Value

ShaderBackend

SupportsAnisotropy

public override bool SupportsAnisotropy { get; }

Property Value

bool

SupportsAstc

ASTC LDR textures can be sampled (mobile and Apple GPUs).

public override bool SupportsAstc { get; }

Property Value

bool

SupportsBc

BC1-7 textures can be sampled (desktop GPUs); otherwise transcode Basis textures to ASTC or RGBA8.

public override bool SupportsBc { get; }

Property Value

bool

SupportsDrawIndirectCount

works: the GPU decides how many draws to make (Vulkan's optional drawIndirectCount). Metal has no such draw; use with a maximum count instead.

public override bool SupportsDrawIndirectCount { get; }

Property Value

bool

SupportsMultiDrawIndirect

One indirect draw command can make several draws (multiDrawIndirect); without it the recorder issues one command at a time.

public bool SupportsMultiDrawIndirect { get; }

Property Value

bool

SupportsSamplerFilterMinMax

Samplers can return the minimum or maximum of their footprint (): a Hi-Z pyramid can be built with a single sample per texel. Metal has none; a shader takes the four texels itself.

public override bool SupportsSamplerFilterMinMax { get; }

Property Value

bool

SupportsSwapchain

public bool SupportsSwapchain { get; }

Property Value

bool

SupportsTimestamps

The queue writes timestamps (all of graphics and compute can).

public override bool SupportsTimestamps { get; }

Property Value

bool

TimestampPeriod

Nanoseconds per timestamp tick, for GPU timings.

public override float TimestampPeriod { get; }

Property Value

float

ValidationErrorCount

How many warnings and errors the API's validation layer has reported; tests fail on any.

public override int ValidationErrorCount { get; }

Property Value

int

VulkanBindless

The bindless heap as a Vulkan one: the descriptor set and the pipeline layout.

public VulkanBindlessHeap VulkanBindless { get; }

Property Value

VulkanBindlessHeap

Methods

Create(VulkanInstance, GraphicsDeviceOptions?)

Creates the device on an instance the caller keeps (the caller disposes the instance after the device). A surface is made for the window, if there is one.

public static VulkanDevice Create(VulkanInstance instance, GraphicsDeviceOptions? options = null)

Parameters

instance VulkanInstance

options GraphicsDeviceOptions?

Returns

VulkanDevice

CreateBuffer(ulong, BufferUsage, MemoryKind, string?)

public override GpuBuffer CreateBuffer(ulong size, BufferUsage usage, MemoryKind kind = MemoryKind.DeviceLocal, string? name = null)

Parameters

size ulong

usage BufferUsage

kind MemoryKind

name string?

Returns

GpuBuffer

CreateComputePipeline(in ShaderCode, string?)

public override Pipeline CreateComputePipeline(in ShaderCode shader, string? name = null)

Parameters

shader ShaderCode

name string?

Returns

Pipeline

CreateFrameLoop(Swapchain?, int, int)

The loop that records and submits frames, to swapchain or headless.

public override FrameLoop CreateFrameLoop(Swapchain? swapchain = null, int framesInFlight = 2, int arenaBytes = 4194304)

Parameters

swapchain Swapchain?

framesInFlight int

arenaBytes int

Returns

FrameLoop

CreateGraphicsPipeline(GraphicsPipelineDescription, string?)

public override Pipeline CreateGraphicsPipeline(GraphicsPipelineDescription description, string? name = null)

Parameters

description GraphicsPipelineDescription

name string?

Returns

Pipeline

CreateImage(in ImageDescription, string?)

public override GpuImage CreateImage(in ImageDescription description, string? name = null)

Parameters

description ImageDescription

name string?

Returns

GpuImage

CreateSampler(in SamplerDescription, string?)

public override GpuSampler CreateSampler(in SamplerDescription description, string? name = null)

Parameters

description SamplerDescription

name string?

Returns

GpuSampler

CreateSwapchain(bool)

A swapchain for the window the device was created for.

public override Swapchain CreateSwapchain(bool vsync = true)

Parameters

vsync bool

Returns

Swapchain

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public override void Dispose()

EnumeratePhysicalDevices(VulkanInstance, VkSurfaceKHR)

Lists the GPUs the loader reports, with whether each meets the baseline.

public static PhysicalDeviceInfo[] EnumeratePhysicalDevices(VulkanInstance instance, VkSurfaceKHR surface = default)

Parameters

instance VulkanInstance

surface VkSurfaceKHR

Returns

PhysicalDeviceInfo[]

SetDebugName(VkObjectType, ulong, string)

Names an object for the validation layer and capture tools (RenderDoc, Nsight). Does nothing without VK_EXT_debug_utils.

public void SetDebugName(VkObjectType type, ulong handle, string name)

Parameters

type VkObjectType

handle ulong

name string

TakeValidationErrors()

Takes the validation messages reported so far.

public override string[] TakeValidationErrors()

Returns

string[]

WaitIdle()

public override void WaitIdle()