Skip to content

Document Vulkan memory allocator APIs #234

Open

Description

@ramezgerges

Document the Vulkan memory allocator APIs added by mono/SkiaSharp#4585.

Namespace: SkiaSharp

New type:

  • GRVkMemoryAllocator — a Skia-owned Vulkan memory allocator (the default VMA-backed implementation) that can be supplied to Ganesh and Graphite Vulkan contexts.
public static GRVkMemoryAllocator CreateDefault(
    IntPtr vkInstance, IntPtr vkPhysicalDevice, IntPtr vkDevice, IntPtr vkQueue,
    uint maxApiVersion, GRVkGetProcedureAddressDelegate getProcedureAddress);
public static GRVkMemoryAllocator CreateDefault(
    IntPtr vkInstance, IntPtr vkPhysicalDevice, IntPtr vkDevice, IntPtr vkQueue,
    uint maxApiVersion, GRVkGetProcedureAddressDelegate getProcedureAddress,
    bool threadSafe);
public static GRVkMemoryAllocator CreateDefault(
    IntPtr vkInstance, IntPtr vkPhysicalDevice, IntPtr vkDevice, IntPtr vkQueue,
    uint maxApiVersion, GRVkGetProcedureAddressDelegate getProcedureAddress,
    bool threadSafe, bool protectedContent);

New properties:

  • GRVkBackendContext.MemoryAllocator
  • SKGraphiteVkBackendContext.MemoryAllocator

Points worth covering:

  • vkQueue is required; CreateDefault throws ArgumentException when it (or the instance, physical device or device) is null, and ArgumentNullException for a null getProcedureAddress.
  • Returns null when Vulkan support is not compiled into the native library or allocator initialization fails.
  • threadSafe should match the context's threading model: false for Ganesh and non-thread-safe Graphite, true for thread-safe Graphite or parallel multi-recorder use.
  • protectedContent requests an allocator that serves protected (DRM) memory.
  • The context takes its own reference to the allocator, so the managed wrapper may be disposed as soon as the context has been created.
  • Leaving MemoryAllocator null keeps the existing behavior: the native layer creates Skia's default allocator automatically.
  • The getProcedureAddress delegate is only needed for the duration of CreateDefault; the allocator caches the resolved function pointers.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions