mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58:24 +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
40
Brutal.Slang/SlangComWrappers.cs
Normal file
40
Brutal.Slang/SlangComWrappers.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
|
||||
namespace Brutal.SlangApi;
|
||||
|
||||
// Some Slang 2026.7 objects implement a public interface but answer QueryInterface
|
||||
// only for a native interface derived from it, whose vtable therefore starts with the
|
||||
// public one. Preserve the public IIDs and prefer them; only retry E_NOINTERFACE
|
||||
// against the derived interface. See upstream
|
||||
// source/compiler-core/slang-artifact-associated{,-impl}.{h,cpp} (IMetadata) and
|
||||
// source/compiler-core/slang-artifact{,-impl}.{h,cpp} (ICompileResult).
|
||||
internal sealed class SlangComWrappers : StrategyBasedComWrappers
|
||||
{
|
||||
protected override IIUnknownStrategy GetOrCreateIUnknownStrategy() => DerivedInterfaceQueryStrategy.Instance;
|
||||
|
||||
private sealed unsafe class DerivedInterfaceQueryStrategy : IIUnknownStrategy
|
||||
{
|
||||
internal static readonly DerivedInterfaceQueryStrategy Instance = new();
|
||||
private const int NoInterface = unchecked((int)0x80004002);
|
||||
|
||||
private static readonly Dictionary<System.Guid, System.Guid> DerivedIds = new()
|
||||
{
|
||||
// IArtifactPostEmitMetadata
|
||||
[typeof(IMetadata).GUID] = new("5d03bce9-afb1-4fc8-a46f-3ce07b061b1b"),
|
||||
// IArtifact
|
||||
[typeof(ICompileResult).GUID] = new("f90acdb0-9a4a-414e-8545-8b26c92d9442"),
|
||||
};
|
||||
|
||||
public void* CreateInstancePointer(void* unknown) => DefaultIUnknownStrategy.CreateInstancePointer(unknown);
|
||||
|
||||
public int QueryInterface(void* instancePtr, in System.Guid iid, out void* ppObj)
|
||||
{
|
||||
var result = DefaultIUnknownStrategy.QueryInterface(instancePtr, in iid, out ppObj);
|
||||
if (result == NoInterface && DerivedIds.TryGetValue(iid, out var derived))
|
||||
return DefaultIUnknownStrategy.QueryInterface(instancePtr, in derived, out ppObj);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int Release(void* instancePtr) => DefaultIUnknownStrategy.Release(instancePtr);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue