Update Slang, Vulkan, Gltf and ImGui. Offload natives to sub-packages.

Public-PR: https://github.com/ahwootech/BRUTAL/pull/9
Public-PR: https://github.com/ahwootech/BRUTAL/pull/15
Public-PR: https://github.com/ahwootech/BRUTAL/pull/21
Fixes: ahwootech/BRUTAL#8
Fixes: ahwootech/BRUTAL#22
Co-authored-by: Laurens de Voogd <laurens@devoogd.be>
Co-authored-by: sGo7-Dev <goulax16@gmail.com>
Co-authored-by: Capsup <capsup@live.dk>
This commit is contained in:
BRUTAL release 2026-10-23 15:07:17 +13:00
commit 4ac91e105e
5 changed files with 2034 additions and 318 deletions

View file

@ -1077,5 +1077,156 @@ namespace Brutal.VulkanApi
public const int STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_SPEC_VERSION =
STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_API_VERSION_1_0_0;
public const string STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_EXTENSION_NAME = "VK_STD_vulkan_video_codec_av1_encode";
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_API_VERSION_1_0.html">VK_API_VERSION_1_0</see> - Return API version number for Vulkan 1.0
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_API_VERSION_1_0</c> returns the API version number for Vulkan 1.0.0.
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// // Vulkan 1.0 version number
/// #define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0)// Patch version should always be set to 0
/// </code>
/// </remarks>
public const int API_VERSION_1_0 = unchecked(
(int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0)))
);
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_API_VERSION_1_1.html">VK_API_VERSION_1_1</see> - Return API version number for Vulkan 1.1
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_API_VERSION_1_1</c> returns the API version number for Vulkan 1.1.0.
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_1
/// // Vulkan 1.1 version number
/// #define VK_API_VERSION_1_1 VK_MAKE_API_VERSION(0, 1, 1, 0)// Patch version should always be set to 0
/// </code>
/// </remarks>
public const int API_VERSION_1_1 = unchecked(
(int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(1)) << 12) | ((uint)(0)))
);
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_API_VERSION_1_2.html">VK_API_VERSION_1_2</see> - Return API version number for Vulkan 1.2
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_API_VERSION_1_2</c> returns the API version number for Vulkan 1.2.0.
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_2
/// // Vulkan 1.2 version number
/// #define VK_API_VERSION_1_2 VK_MAKE_API_VERSION(0, 1, 2, 0)// Patch version should always be set to 0
/// </code>
/// </remarks>
public const int API_VERSION_1_2 = unchecked(
(int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(2)) << 12) | ((uint)(0)))
);
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_API_VERSION_1_3.html">VK_API_VERSION_1_3</see> - Return API version number for Vulkan 1.3
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_API_VERSION_1_3</c> returns the API version number for Vulkan 1.3.0.
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_3
/// // Vulkan 1.3 version number
/// #define VK_API_VERSION_1_3 VK_MAKE_API_VERSION(0, 1, 3, 0)// Patch version should always be set to 0
/// </code>
/// </remarks>
public const int API_VERSION_1_3 = unchecked(
(int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(3)) << 12) | ((uint)(0)))
);
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_API_VERSION_1_4.html">VK_API_VERSION_1_4</see> - Return API version number for Vulkan 1.4
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_API_VERSION_1_4</c> returns the API version number for Vulkan 1.4.0.
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_4
/// // Vulkan 1.4 version number
/// #define VK_API_VERSION_1_4 VK_MAKE_API_VERSION(0, 1, 4, 0)// Patch version should always be set to 0
/// </code>
/// </remarks>
public const int API_VERSION_1_4 = unchecked(
(int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(4)) << 12) | ((uint)(0)))
);
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_HEADER_VERSION.html">VK_HEADER_VERSION</see> - Vulkan header file version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_HEADER_VERSION</c> is the version number of the `{core_header}` header.
/// This value is kept synchronized with the patch version of the released
/// Specification.
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// // Version of this file
/// #define VK_HEADER_VERSION 357
/// </code>
/// </remarks>
public const int HEADER_VERSION = 357;
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_HEADER_VERSION_COMPLETE.html">VK_HEADER_VERSION_COMPLETE</see> - Vulkan header file complete version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_HEADER_VERSION_COMPLETE</c> is the complete version number of the
/// `{core_header}` header, comprising the major, minor, and patch versions.
/// The major/minor values are kept synchronized with the complete version of
/// the released Specification.
/// This value is intended for use by automated tools to identify exactly which
/// version of the header was used during their generation.
/// </para>
/// <para>
/// Applications should not use this value as their
/// <c>VkApplicationInfo::apiVersion</c>.
/// Instead applications should explicitly select a specific fixed major/minor
/// API version using, for example, one of the <c>VK_API_VERSION_</c>*_* values.
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// // Complete version of this file
/// #define VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(0, 1, 4, VK_HEADER_VERSION)
/// </code>
/// </remarks>
public const int HEADER_VERSION_COMPLETE = unchecked(
(int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(4)) << 12) | ((uint)(VK.HEADER_VERSION)))
);
public const int STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 = unchecked(
(int)((((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0)))
);
public const int STD_VULKAN_VIDEO_CODEC_H264_ENCODE_API_VERSION_1_0_0 = unchecked(
(int)((((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0)))
);
public const int STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 = unchecked(
(int)((((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0)))
);
public const int STD_VULKAN_VIDEO_CODEC_H265_ENCODE_API_VERSION_1_0_0 = unchecked(
(int)((((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0)))
);
public const int STD_VULKAN_VIDEO_CODEC_VP9_DECODE_API_VERSION_1_0_0 = unchecked(
(int)((((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0)))
);
public const int STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_1_0_0 = unchecked(
(int)((((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0)))
);
public const int STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_API_VERSION_1_0_0 = unchecked(
(int)((((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0)))
);
}
}

View file

@ -0,0 +1,157 @@
namespace Brutal.VulkanApi
{
public static partial class Vulkan
{
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_MAKE_VERSION.html">VK_MAKE_VERSION</see> - Construct an API version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_MAKE_VERSION</c> constructs an API version number.
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// #define VK_MAKE_VERSION(major, minor, patch) \
/// ((((uint32_t)(major)) &lt;&lt; 22U) | (((uint32_t)(minor)) &lt;&lt; 12U) | ((uint32_t)(patch)))
/// </code>
/// </remarks>
/// <param name="major">is the major version number.</param>
/// <param name="minor">is the minor version number.</param>
/// <param name="patch">is the patch version number.</param>
public static int MakeVersion(int major, int minor, int patch) =>
unchecked((int)((((uint)(major)) << 22) | (((uint)(minor)) << 12) | ((uint)(patch))));
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_VERSION_MAJOR.html">VK_VERSION_MAJOR</see> - Extract API major version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_VERSION_MAJOR</c> extracts the API major version number from a packed
/// version number:
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// #define VK_VERSION_MAJOR(version) ((uint32_t)(version) &gt;&gt; 22U)
/// </code>
/// </remarks>
public static int VersionMajor(int version) => unchecked((int)((uint)(version) >> 22));
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_VERSION_MINOR.html">VK_VERSION_MINOR</see> - Extract API minor version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_VERSION_MINOR</c> extracts the API minor version number from a packed
/// version number:
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// #define VK_VERSION_MINOR(version) (((uint32_t)(version) &gt;&gt; 12U) &amp; 0x3FFU)
/// </code>
/// </remarks>
public static int VersionMinor(int version) => unchecked((int)(((uint)(version) >> 12) & 0x3FF));
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_VERSION_PATCH.html">VK_VERSION_PATCH</see> - Extract API patch version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_VERSION_PATCH</c> extracts the API patch version number from a packed
/// version number:
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// #define VK_VERSION_PATCH(version) ((uint32_t)(version) &amp; 0xFFFU)
/// </code>
/// </remarks>
public static int VersionPatch(int version) => unchecked((int)((uint)(version) & 0xFFF));
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_MAKE_API_VERSION.html">VK_MAKE_API_VERSION</see> - Construct an API version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_MAKE_API_VERSION</c> constructs an API version number.
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// #define VK_MAKE_API_VERSION(variant, major, minor, patch) \
/// ((((uint32_t)(variant)) &lt;&lt; 29U) | (((uint32_t)(major)) &lt;&lt; 22U) | (((uint32_t)(minor)) &lt;&lt; 12U) | ((uint32_t)(patch)))
/// </code>
/// </remarks>
/// <param name="variant">is the variant number.</param>
/// <param name="major">is the major version number.</param>
/// <param name="minor">is the minor version number.</param>
/// <param name="patch">is the patch version number.</param>
public static int MakeApiVersion(int variant, int major, int minor, int patch) =>
unchecked(
(int)((((uint)(variant)) << 29) | (((uint)(major)) << 22) | (((uint)(minor)) << 12) | ((uint)(patch)))
);
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_API_VERSION_VARIANT.html">VK_API_VERSION_VARIANT</see> - Extract API variant number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_API_VERSION_VARIANT</c> extracts the API variant number from a packed
/// version number:
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// #define VK_API_VERSION_VARIANT(version) ((uint32_t)(version) &gt;&gt; 29U)
/// </code>
/// </remarks>
public static int ApiVersionVariant(int version) => unchecked((int)((uint)(version) >> 29));
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_API_VERSION_MAJOR.html">VK_API_VERSION_MAJOR</see> - Extract API major version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_API_VERSION_MAJOR</c> extracts the API major version number from a
/// packed version number:
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// #define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) &gt;&gt; 22U) &amp; 0x7FU)
/// </code>
/// </remarks>
public static int ApiVersionMajor(int version) => unchecked((int)(((uint)(version) >> 22) & 0x7F));
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_API_VERSION_MINOR.html">VK_API_VERSION_MINOR</see> - Extract API minor version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_API_VERSION_MINOR</c> extracts the API minor version number from a
/// packed version number:
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// #define VK_API_VERSION_MINOR(version) (((uint32_t)(version) &gt;&gt; 12U) &amp; 0x3FFU)
/// </code>
/// </remarks>
public static int ApiVersionMinor(int version) => unchecked((int)(((uint)(version) >> 12) & 0x3FF));
/// <summary>
/// <see href="https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_API_VERSION_PATCH.html">VK_API_VERSION_PATCH</see> - Extract API patch version number
/// </summary>
/// <remarks>
/// <para>
/// <c>VK_API_VERSION_PATCH</c> extracts the API patch version number from a
/// packed version number:
/// </para>
/// <code>
/// // Provided by VK_VERSION_1_0
/// #define VK_API_VERSION_PATCH(version) ((uint32_t)(version) &amp; 0xFFFU)
/// </code>
/// </remarks>
public static int ApiVersionPatch(int version) => unchecked((int)((uint)(version) & 0xFFF));
/// <summary>
/// VK_MAKE_VIDEO_STD_VERSION
/// </summary>
public static int MakeVideoStdVersion(int major, int minor, int patch) =>
unchecked((int)((((uint)(major)) << 22) | (((uint)(minor)) << 12) | ((uint)(patch))));
}
}

View file

@ -16,19 +16,7 @@ public partial class Vulkan
static Vulkan()
{
// Load the correct Vulkan library for the platform
if (OperatingSystem.IsWindows())
Dll = NativeLibrary.Load("vulkan-1", typeof(Vulkan).Assembly, DllImportSearchPath.System32);
// TODO: This is a hack which only works if SDK is installed, we need to package the Vulkan binary on macOS
if (OperatingSystem.IsMacOS())
Dll = NativeLibrary.Load("VulkanEx", typeof(Vulkan).Assembly, DllImportSearchPath.LegacyBehavior);
if (OperatingSystem.IsLinux())
Dll = NativeLibrary.Load("vulkan", typeof(Vulkan).Assembly, DllImportSearchPath.LegacyBehavior);
if (Dll == nint.Zero)
throw new NullReferenceException("Failed to load Vulkan library");
Dll = LoadVulkanLibrary();
// Assign the native library to the assembly resolver
NativeLibrary.SetDllImportResolver(
@ -47,4 +35,37 @@ public partial class Vulkan
throw new NullReferenceException("Failed to load vkGetInstanceProcAddr from Vulkan library");
}
}
private static nint LoadVulkanLibrary()
{
var assembly = typeof(Vulkan).Assembly;
if (OperatingSystem.IsWindows())
return NativeLibrary.Load("vulkan-1", assembly, DllImportSearchPath.System32);
// Prefer the system Vulkan loader, falling back to the old names
string[] candidates = [];
// TODO: Package the Vulkan loader on macOS so it works without Homebrew or the SDK installed
if (OperatingSystem.IsMacOS())
candidates =
[
"libvulkan.1.dylib",
"/opt/homebrew/lib/libvulkan.1.dylib",
"/usr/local/lib/libvulkan.1.dylib",
"VulkanEx",
];
// libvulkan.so (what "vulkan" resolves to) only ships in -dev packages
if (OperatingSystem.IsLinux())
candidates = ["libvulkan.so.1", "vulkan"];
foreach (var candidate in candidates)
{
if (NativeLibrary.TryLoad(candidate, assembly, DllImportSearchPath.LegacyBehavior, out var dll))
return dll;
}
throw new DllNotFoundException($"Failed to load Vulkan library, tried: {string.Join(", ", candidates)}");
}
}

View file

@ -1,5 +1,5 @@
THIRD-PARTY LICENSE NOTICES
RocketWerkz.Brutal.Vulkan
Ahwoo.BRUTAL.Vulkan
Brutal.Vulkan contains two kinds of Khronos material, each reproduced below with the
license that governs it. The managed bindings are generated from the Vulkan API registry.

View file

@ -3,14 +3,4 @@ namespace Brutal.VulkanApi;
public static partial class VK
{
public static readonly ByteSize WHOLE_SIZE = ByteSize.Of(unchecked((int)(~0UL)));
// #define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \
// ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch)))
private const int STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 = 1 << 22;
private const int STD_VULKAN_VIDEO_CODEC_H264_ENCODE_API_VERSION_1_0_0 = 1 << 22;
private const int STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 = 1 << 22;
private const int STD_VULKAN_VIDEO_CODEC_H265_ENCODE_API_VERSION_1_0_0 = 1 << 22;
private const int STD_VULKAN_VIDEO_CODEC_VP9_DECODE_API_VERSION_1_0_0 = 1 << 22;
private const int STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_1_0_0 = 1 << 22;
private const int STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_API_VERSION_1_0_0 = 1 << 22;
}