Cut 14a: native HarfBuzz hb-gpu C17 shim, RustToDust.HbGpu, HbGpuCanvas Vulkan renderer, Krypton.ttf
This commit is contained in:
parent
24eb3c96b8
commit
795cd93533
24 changed files with 3287 additions and 9 deletions
|
|
@ -4,28 +4,41 @@ using System.Reflection;
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Godot;
|
||||
using RustToDust.HbGpu;
|
||||
using Ymir.Box3D;
|
||||
|
||||
namespace RustToDust.Client;
|
||||
|
||||
/// <summary>
|
||||
/// Finds ymir_box3d for Ymir.Box3D's DllImports. Godot loads game assemblies into its own load context, so the
|
||||
/// default probing does not look beside them. A run from the editor or <c>--path</c> loads the library from the
|
||||
/// project's build directory; an exported run from the data folder Godot puts beside the executable.
|
||||
/// Resolves native libraries (ymir_box3d, rtd_hbgpu) for Godot's AssemblyLoadContext.
|
||||
/// </summary>
|
||||
internal static class NativeLibraries
|
||||
{
|
||||
private const string Library = "ymir_box3d";
|
||||
private const string YmirLibrary = "ymir_box3d";
|
||||
private const string HbGpuLibrary = "rtd_hbgpu";
|
||||
|
||||
#pragma warning disable CA2255 // application code: the resolver must exist before the first DllImport
|
||||
[ModuleInitializer]
|
||||
internal static void Register() =>
|
||||
internal static void Register()
|
||||
{
|
||||
NativeLibrary.SetDllImportResolver(typeof(Box3DSoaWorld).Assembly, Resolve);
|
||||
NativeLibrary.SetDllImportResolver(typeof(HbGpuNative).Assembly, Resolve);
|
||||
}
|
||||
|
||||
private static IntPtr Resolve(string name, Assembly assembly, DllImportSearchPath? searchPath)
|
||||
{
|
||||
if (name != Library) return IntPtr.Zero;
|
||||
string fileName = FileName();
|
||||
string? stem = name switch
|
||||
{
|
||||
YmirLibrary => YmirLibrary,
|
||||
HbGpuLibrary => HbGpuLibrary,
|
||||
_ => null
|
||||
};
|
||||
if (stem is null)
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
string fileName = FileName(stem);
|
||||
|
||||
if (OS.HasFeature("template"))
|
||||
{
|
||||
|
|
@ -65,8 +78,8 @@ internal static class NativeLibraries
|
|||
: IntPtr.Zero;
|
||||
}
|
||||
|
||||
private static string FileName() =>
|
||||
OperatingSystem.IsWindows() ? "ymir_box3d.dll" : OperatingSystem.IsMacOS() ? "libymir_box3d.dylib" : "libymir_box3d.so";
|
||||
private static string FileName(string stem) =>
|
||||
OperatingSystem.IsWindows() ? $"{stem}.dll" : OperatingSystem.IsMacOS() ? $"lib{stem}.dylib" : $"lib{stem}.so";
|
||||
|
||||
private static string Platform() =>
|
||||
OperatingSystem.IsWindows() ? "windows" : OperatingSystem.IsMacOS() ? "macos" : "linuxbsd";
|
||||
|
|
|
|||
Loading…
Reference in a new issue