mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-29 14:38:25 +01:00
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:
parent
a25cdf80b2
commit
4ac91e105e
1 changed files with 2034 additions and 318 deletions
34
Brutal.Slang/ScalarMarshallers.cs
Normal file
34
Brutal.Slang/ScalarMarshallers.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
|
||||
namespace Brutal.SlangApi;
|
||||
|
||||
[CustomMarshaller(
|
||||
typeof(CustomMarshallerAttribute.GenericPlaceholder),
|
||||
MarshalMode.Default,
|
||||
typeof(SlangHandleMarshaller<>)
|
||||
)]
|
||||
internal static class SlangHandleMarshaller<T>
|
||||
where T : unmanaged
|
||||
{
|
||||
public static nint ConvertToUnmanaged(T managed) => Unsafe.BitCast<T, nint>(managed);
|
||||
|
||||
public static T ConvertToManaged(nint unmanaged) => Unsafe.BitCast<nint, T>(unmanaged);
|
||||
}
|
||||
|
||||
[CustomMarshaller(typeof(ByteSize), MarshalMode.Default, typeof(SlangSizeMarshaller))]
|
||||
internal static class SlangSizeMarshaller
|
||||
{
|
||||
public static nuint ConvertToUnmanaged(ByteSize managed) => managed.Value;
|
||||
|
||||
public static ByteSize ConvertToManaged(nuint unmanaged) => (ByteSize)unmanaged;
|
||||
}
|
||||
|
||||
[CustomMarshaller(typeof(Bool8), MarshalMode.Default, typeof(SlangBoolMarshaller))]
|
||||
internal static class SlangBoolMarshaller
|
||||
{
|
||||
public static byte ConvertToUnmanaged(Bool8 managed) => Unsafe.BitCast<Bool8, byte>(managed);
|
||||
|
||||
public static Bool8 ConvertToManaged(byte unmanaged) => Unsafe.BitCast<byte, Bool8>(unmanaged);
|
||||
}
|
||||
Loading…
Reference in a new issue