mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 13:08: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
15 changed files with 2034 additions and 318 deletions
3
Brutal.Slang/AssemblyInfo.cs
Normal file
3
Brutal.Slang/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Brutal.Slang.Test")]
|
||||
18
Brutal.Slang/BorrowedSlangInterfaceMarshaller.cs
Normal file
18
Brutal.Slang/BorrowedSlangInterfaceMarshaller.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
|
||||
namespace Brutal.SlangApi;
|
||||
|
||||
// Slang's direct interface-returning getters/loaders lend a reference. The RCW
|
||||
// takes its own reference, but the returned pointer must not be released by the stub.
|
||||
[CustomMarshaller(
|
||||
typeof(CustomMarshallerAttribute.GenericPlaceholder),
|
||||
MarshalMode.Default,
|
||||
typeof(BorrowedSlangInterfaceMarshaller<>)
|
||||
)]
|
||||
internal static unsafe class BorrowedSlangInterfaceMarshaller<T>
|
||||
where T : class
|
||||
{
|
||||
public static T? ConvertToManaged(void* unmanaged) => Slang.WrapBorrowedComInstance<T>((nint)unmanaged);
|
||||
|
||||
public static void* ConvertToUnmanaged(T? managed) => ComInterfaceMarshaller<T>.ConvertToUnmanaged(managed);
|
||||
}
|
||||
20
Brutal.Slang/EntryPointLayoutExtensions.cs
Normal file
20
Brutal.Slang/EntryPointLayoutExtensions.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
namespace Brutal.SlangApi;
|
||||
|
||||
/// <summary>
|
||||
/// Hand-written helpers on entry-point reflection handles for flat-C getters that fill
|
||||
/// output arrays, which the generated signatures expose as raw pointers.
|
||||
/// </summary>
|
||||
public static unsafe class EntryPointLayoutExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a compute entry point's thread-group size, its <c>[numthreads]</c>, along
|
||||
/// X, Y and Z. The handle borrows from its program layout, so call this only while the
|
||||
/// component that produced the layout is alive.
|
||||
/// </summary>
|
||||
public static (ulong X, ulong Y, ulong Z) GetComputeThreadGroupSize(this EntryPointLayout entryPoint)
|
||||
{
|
||||
var sizes = stackalloc ulong[3];
|
||||
Slang.PInvoke.spReflectionEntryPoint_getComputeThreadGroupSize(entryPoint, 3, sizes);
|
||||
return (sizes[0], sizes[1], sizes[2]);
|
||||
}
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@ global using ReflectionDecl = Brutal.SlangApi.DeclReflection;
|
|||
global using ReflectionEntryPoint = Brutal.SlangApi.EntryPointLayout;
|
||||
global using ReflectionFunction = Brutal.SlangApi.FunctionReflection;
|
||||
global using ReflectionGeneric = Brutal.SlangApi.GenericReflection;
|
||||
global using ReflectionModifier = Brutal.SlangApi.Modifier;
|
||||
global using ReflectionParameter = Brutal.SlangApi.VariableLayoutReflection;
|
||||
global using ReflectionType = Brutal.SlangApi.TypeReflection;
|
||||
global using ReflectionTypeLayout = Brutal.SlangApi.TypeLayoutReflection;
|
||||
|
|
@ -69,4 +70,3 @@ global using ReflectionTypeParameter = Brutal.SlangApi.TypeParameterReflection;
|
|||
global using ReflectionVariable = Brutal.SlangApi.VariableReflection;
|
||||
global using ReflectionVariableLayout = Brutal.SlangApi.VariableLayoutReflection;
|
||||
global using Session = Brutal.SlangApi.IGlobalSession;
|
||||
global using UserAttribute = Brutal.SlangApi.Attribute;
|
||||
|
|
|
|||
|
|
@ -7,17 +7,7 @@ namespace Brutal.SlangApi
|
|||
{
|
||||
[GeneratedComInterface]
|
||||
[Guid("00000000-0000-0000-c000-000000000046")]
|
||||
public unsafe partial interface ISlangUnknown
|
||||
{
|
||||
[PreserveSig]
|
||||
Result QueryInterface(ref Brutal.SlangApi.Uuid uuid, out void* outObject);
|
||||
|
||||
[PreserveSig]
|
||||
uint AddRef();
|
||||
|
||||
[PreserveSig]
|
||||
uint Release();
|
||||
};
|
||||
public unsafe partial interface ISlangUnknown { };
|
||||
|
||||
[GeneratedComInterface]
|
||||
[Guid("87ede0e1-4852-44b0-8bf2-cb31874de239")]
|
||||
|
|
@ -43,7 +33,8 @@ namespace Brutal.SlangApi
|
|||
void* GetBufferPointer();
|
||||
|
||||
[PreserveSig]
|
||||
ByteSize64 GetBufferSize();
|
||||
[return: MarshalUsing(typeof(SlangSizeMarshaller))]
|
||||
ByteSize GetBufferSize();
|
||||
};
|
||||
|
||||
[GeneratedComInterface]
|
||||
|
|
@ -51,7 +42,10 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface ISlangFileSystem : Brutal.SlangApi.ISlangCastable
|
||||
{
|
||||
[PreserveSig]
|
||||
Result LoadFile(byte* path, out ISlangBlob outBlob);
|
||||
Result LoadFile(
|
||||
byte* path,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outBlob
|
||||
);
|
||||
};
|
||||
|
||||
[GeneratedComInterface]
|
||||
|
|
@ -75,7 +69,11 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface ISlangSharedLibraryLoader
|
||||
{
|
||||
[PreserveSig]
|
||||
Result LoadSharedLibrary(byte* path, out ISlangSharedLibrary sharedLibraryOut);
|
||||
Result LoadSharedLibrary(
|
||||
byte* path,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangSharedLibrary>))]
|
||||
out ISlangSharedLibrary sharedLibraryOut
|
||||
);
|
||||
};
|
||||
|
||||
[GeneratedComInterface]
|
||||
|
|
@ -83,21 +81,28 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface ISlangFileSystemExt : Brutal.SlangApi.ISlangFileSystem
|
||||
{
|
||||
[PreserveSig]
|
||||
Result GetFileUniqueIdentity(byte* path, out ISlangBlob outUniqueIdentity);
|
||||
Result GetFileUniqueIdentity(
|
||||
byte* path,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outUniqueIdentity
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result CalcCombinedPath(
|
||||
Brutal.SlangApi.PathType fromPathType,
|
||||
byte* fromPath,
|
||||
byte* path,
|
||||
out ISlangBlob pathOut
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob pathOut
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetPathType(byte* path, out Brutal.SlangApi.PathType pathTypeOut);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetPath(PathKind kind, byte* path, out ISlangBlob outPath);
|
||||
Result GetPath(
|
||||
PathKind kind,
|
||||
byte* path,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outPath
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
void ClearCache();
|
||||
|
|
@ -114,10 +119,13 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface ISlangMutableFileSystem : Brutal.SlangApi.ISlangFileSystemExt
|
||||
{
|
||||
[PreserveSig]
|
||||
Result SaveFile(byte* path, void* data, ByteSize64 size);
|
||||
Result SaveFile(byte* path, void* data, [MarshalUsing(typeof(SlangSizeMarshaller))] ByteSize size);
|
||||
|
||||
[PreserveSig]
|
||||
Result SaveFileBlob(byte* path, ISlangBlob dataBlob);
|
||||
Result SaveFileBlob(
|
||||
byte* path,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] ISlangBlob dataBlob
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result Remove(byte* path);
|
||||
|
|
@ -131,18 +139,19 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface ISlangWriter
|
||||
{
|
||||
[PreserveSig]
|
||||
byte* BeginAppendBuffer(ByteSize64 maxNumChars);
|
||||
byte* BeginAppendBuffer([MarshalUsing(typeof(SlangSizeMarshaller))] ByteSize maxNumChars);
|
||||
|
||||
[PreserveSig]
|
||||
Result EndAppendBuffer(byte* buffer, ByteSize64 numChars);
|
||||
Result EndAppendBuffer(byte* buffer, [MarshalUsing(typeof(SlangSizeMarshaller))] ByteSize numChars);
|
||||
|
||||
[PreserveSig]
|
||||
Result Write(byte* chars, ByteSize64 numChars);
|
||||
Result Write(byte* chars, [MarshalUsing(typeof(SlangSizeMarshaller))] ByteSize numChars);
|
||||
|
||||
[PreserveSig]
|
||||
void Flush();
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(SlangBoolMarshaller))]
|
||||
Bool IsConsole();
|
||||
|
||||
[PreserveSig]
|
||||
|
|
@ -154,7 +163,8 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface ISlangProfiler
|
||||
{
|
||||
[PreserveSig]
|
||||
ByteSize64 GetEntryCount();
|
||||
[return: MarshalUsing(typeof(SlangSizeMarshaller))]
|
||||
ByteSize GetEntryCount();
|
||||
|
||||
[PreserveSig]
|
||||
byte* GetEntryName(uint index);
|
||||
|
|
@ -171,7 +181,11 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface IGlobalSession
|
||||
{
|
||||
[PreserveSig]
|
||||
Result CreateSession(ref Brutal.SlangApi.SessionDesc desc, out Brutal.SlangApi.ISession outSession);
|
||||
Result CreateSession(
|
||||
ref Brutal.SlangApi.SessionDesc desc,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.ISession>))]
|
||||
out Brutal.SlangApi.ISession outSession
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Brutal.SlangApi.ProfileID FindProfile(byte* name);
|
||||
|
|
@ -183,7 +197,10 @@ namespace Brutal.SlangApi
|
|||
void SetDownstreamCompilerPrelude(Brutal.SlangApi.PassThrough passThrough, byte* preludeText);
|
||||
|
||||
[PreserveSig]
|
||||
void GetDownstreamCompilerPrelude(Brutal.SlangApi.PassThrough passThrough, out ISlangBlob outPrelude);
|
||||
void GetDownstreamCompilerPrelude(
|
||||
Brutal.SlangApi.PassThrough passThrough,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outPrelude
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
byte* GetBuildTagString();
|
||||
|
|
@ -201,18 +218,27 @@ namespace Brutal.SlangApi
|
|||
void SetLanguagePrelude(Brutal.SlangApi.SourceLanguage sourceLanguage, byte* preludeText);
|
||||
|
||||
[PreserveSig]
|
||||
void GetLanguagePrelude(Brutal.SlangApi.SourceLanguage sourceLanguage, out ISlangBlob outPrelude);
|
||||
void GetLanguagePrelude(
|
||||
Brutal.SlangApi.SourceLanguage sourceLanguage,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outPrelude
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result CreateCompileRequest(out Brutal.SlangApi.ICompileRequest outCompileRequest);
|
||||
Result CreateCompileRequest(
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.ICompileRequest>))]
|
||||
out Brutal.SlangApi.ICompileRequest outCompileRequest
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
void AddBuiltins(byte* sourcePath, byte* sourceString);
|
||||
|
||||
[PreserveSig]
|
||||
void SetSharedLibraryLoader(ISlangSharedLibraryLoader loader);
|
||||
void SetSharedLibraryLoader(
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangSharedLibraryLoader>))] ISlangSharedLibraryLoader loader
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller<ISlangSharedLibraryLoader>))]
|
||||
ISlangSharedLibraryLoader? GetSharedLibraryLoader();
|
||||
|
||||
[PreserveSig]
|
||||
|
|
@ -225,10 +251,16 @@ namespace Brutal.SlangApi
|
|||
Result CompileCoreModule(CompileCoreModuleFlags flags);
|
||||
|
||||
[PreserveSig]
|
||||
Result LoadCoreModule(void* coreModule, ByteSize64 coreModuleSizeInBytes);
|
||||
Result LoadCoreModule(
|
||||
void* coreModule,
|
||||
[MarshalUsing(typeof(SlangSizeMarshaller))] ByteSize coreModuleSizeInBytes
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result SaveCoreModule(Brutal.SlangApi.ArchiveType archiveType, out ISlangBlob outBlob);
|
||||
Result SaveCoreModule(
|
||||
Brutal.SlangApi.ArchiveType archiveType,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outBlob
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Brutal.SlangApi.CapabilityID FindCapability(byte* name);
|
||||
|
|
@ -257,23 +289,30 @@ namespace Brutal.SlangApi
|
|||
int argc,
|
||||
byte** argv,
|
||||
out Brutal.SlangApi.SessionDesc outSessionDesc,
|
||||
out ISlangUnknown outAuxAllocation
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangUnknown>))] out ISlangUnknown outAuxAllocation
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetSessionDescDigest(in Brutal.SlangApi.SessionDesc sessionDesc, out ISlangBlob outBlob);
|
||||
Result GetSessionDescDigest(
|
||||
in Brutal.SlangApi.SessionDesc sessionDesc,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outBlob
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result CompileBuiltinModule(Brutal.SlangApi.BuiltinModuleName module, CompileCoreModuleFlags flags);
|
||||
|
||||
[PreserveSig]
|
||||
Result LoadBuiltinModule(Brutal.SlangApi.BuiltinModuleName module, void* moduleData, ByteSize64 sizeInBytes);
|
||||
Result LoadBuiltinModule(
|
||||
Brutal.SlangApi.BuiltinModuleName module,
|
||||
void* moduleData,
|
||||
[MarshalUsing(typeof(SlangSizeMarshaller))] ByteSize sizeInBytes
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result SaveBuiltinModule(
|
||||
Brutal.SlangApi.BuiltinModuleName module,
|
||||
Brutal.SlangApi.ArchiveType archiveType,
|
||||
out ISlangBlob outBlob
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outBlob
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -282,118 +321,154 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface ISession
|
||||
{
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller<Brutal.SlangApi.IGlobalSession>))]
|
||||
Brutal.SlangApi.IGlobalSession? GetGlobalSession();
|
||||
|
||||
[PreserveSig]
|
||||
Brutal.SlangApi.IModule? LoadModule(byte* moduleName, out IBlob outDiagnostics);
|
||||
[return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller<Brutal.SlangApi.IModule>))]
|
||||
Brutal.SlangApi.IModule? LoadModule(
|
||||
byte* moduleName,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller<Brutal.SlangApi.IModule>))]
|
||||
Brutal.SlangApi.IModule? LoadModuleFromSource(
|
||||
byte* moduleName,
|
||||
byte* path,
|
||||
IBlob source,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] IBlob source,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result CreateCompositeComponentType(
|
||||
nint* componentTypes,
|
||||
Int componentTypeCount,
|
||||
out Brutal.SlangApi.IComponentType outCompositeComponentType,
|
||||
out ISlangBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IComponentType>))]
|
||||
out Brutal.SlangApi.IComponentType outCompositeComponentType,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection SpecializeType(
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
in Brutal.SlangApi.SpecializationArg specializationArgs,
|
||||
Int specializationArgCount,
|
||||
out ISlangBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeLayoutReflection>))]
|
||||
Brutal.SlangApi.TypeLayoutReflection GetTypeLayout(
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
Int targetIndex,
|
||||
Brutal.SlangApi.LayoutRules rules,
|
||||
out ISlangBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection GetContainerType(
|
||||
Brutal.SlangApi.TypeReflection elementType,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection elementType,
|
||||
Brutal.SlangApi.ContainerType containerType,
|
||||
out ISlangBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection GetDynamicType();
|
||||
|
||||
[PreserveSig]
|
||||
Result GetTypeRTTIMangledName(Brutal.SlangApi.TypeReflection type, out ISlangBlob outNameBlob);
|
||||
Result GetTypeRTTIMangledName(
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outNameBlob
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetTypeConformanceWitnessMangledName(
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
Brutal.SlangApi.TypeReflection interfaceType,
|
||||
out ISlangBlob outNameBlob
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection interfaceType,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outNameBlob
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetTypeConformanceWitnessSequentialID(
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
Brutal.SlangApi.TypeReflection interfaceType,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection interfaceType,
|
||||
out uint outId
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result CreateCompileRequest(out CompileRequest outCompileRequest);
|
||||
|
||||
[PreserveSig]
|
||||
Result CreateTypeConformanceComponentType(
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
Brutal.SlangApi.TypeReflection interfaceType,
|
||||
out Brutal.SlangApi.ITypeConformance outConformance,
|
||||
Int conformanceIdOverride,
|
||||
out ISlangBlob outDiagnostics
|
||||
Result CreateCompileRequest(
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<CompileRequest>))] out CompileRequest outCompileRequest
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result CreateTypeConformanceComponentType(
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection interfaceType,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.ITypeConformance>))]
|
||||
out Brutal.SlangApi.ITypeConformance outConformance,
|
||||
Int conformanceIdOverride,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller<Brutal.SlangApi.IModule>))]
|
||||
Brutal.SlangApi.IModule? LoadModuleFromIRBlob(
|
||||
byte* moduleName,
|
||||
byte* path,
|
||||
IBlob source,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] IBlob source,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Int GetLoadedModuleCount();
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller<Brutal.SlangApi.IModule>))]
|
||||
Brutal.SlangApi.IModule? GetLoadedModule(Int index);
|
||||
|
||||
[PreserveSig]
|
||||
Brutal.Bool8 IsBinaryModuleUpToDate(byte* modulePath, IBlob binaryModuleBlob);
|
||||
[return: MarshalUsing(typeof(SlangBoolMarshaller))]
|
||||
Brutal.Bool8 IsBinaryModuleUpToDate(
|
||||
byte* modulePath,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] IBlob binaryModuleBlob
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller<Brutal.SlangApi.IModule>))]
|
||||
Brutal.SlangApi.IModule? LoadModuleFromSourceString(
|
||||
byte* moduleName,
|
||||
byte* path,
|
||||
byte* @string,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetDynamicObjectRTTIBytes(
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
Brutal.SlangApi.TypeReflection interfaceType,
|
||||
out uint outRTTIDataBuffer,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection type,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.TypeReflection>))]
|
||||
Brutal.SlangApi.TypeReflection interfaceType,
|
||||
uint* outRTTIDataBuffer,
|
||||
uint bufferSizeInBytes
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result LoadModuleInfoFromIRBlob(
|
||||
IBlob source,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] IBlob source,
|
||||
ref Int outModuleVersion,
|
||||
ref byte* outModuleCompilerVersion,
|
||||
ref byte* outModuleName
|
||||
|
|
@ -401,7 +476,8 @@ namespace Brutal.SlangApi
|
|||
|
||||
[PreserveSig]
|
||||
Result GetDeclSourceLocation(
|
||||
Brutal.SlangApi.DeclReflection decl,
|
||||
[MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.DeclReflection>))]
|
||||
Brutal.SlangApi.DeclReflection decl,
|
||||
out Brutal.SlangApi.SourceLocation outLocation
|
||||
);
|
||||
};
|
||||
|
|
@ -411,65 +487,105 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface IComponentType
|
||||
{
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller<Brutal.SlangApi.ISession>))]
|
||||
Brutal.SlangApi.ISession? GetSession();
|
||||
|
||||
[PreserveSig]
|
||||
ProgramLayout GetLayout(Int targetIndex, out IBlob outDiagnostics);
|
||||
[return: MarshalUsing(typeof(SlangHandleMarshaller<ProgramLayout>))]
|
||||
ProgramLayout GetLayout(
|
||||
Int targetIndex,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Int GetSpecializationParamCount();
|
||||
|
||||
[PreserveSig]
|
||||
Result GetEntryPointCode(Int entryPointIndex, Int targetIndex, out IBlob outCode, out IBlob outDiagnostics);
|
||||
Result GetEntryPointCode(
|
||||
Int entryPointIndex,
|
||||
Int targetIndex,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outCode,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetResultAsFileSystem(Int entryPointIndex, Int targetIndex, out ISlangMutableFileSystem outFileSystem);
|
||||
Result GetResultAsFileSystem(
|
||||
Int entryPointIndex,
|
||||
Int targetIndex,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangMutableFileSystem>))]
|
||||
out ISlangMutableFileSystem outFileSystem
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
void GetEntryPointHash(Int entryPointIndex, Int targetIndex, out IBlob outHash);
|
||||
void GetEntryPointHash(
|
||||
Int entryPointIndex,
|
||||
Int targetIndex,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outHash
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result Specialize(
|
||||
in Brutal.SlangApi.SpecializationArg specializationArgs,
|
||||
Int specializationArgCount,
|
||||
out Brutal.SlangApi.IComponentType outSpecializedComponentType,
|
||||
out ISlangBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IComponentType>))]
|
||||
out Brutal.SlangApi.IComponentType outSpecializedComponentType,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result Link(out Brutal.SlangApi.IComponentType outLinkedComponentType, out ISlangBlob outDiagnostics);
|
||||
Result Link(
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IComponentType>))]
|
||||
out Brutal.SlangApi.IComponentType outLinkedComponentType,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetEntryPointHostCallable(
|
||||
int entryPointIndex,
|
||||
int targetIndex,
|
||||
out ISlangSharedLibrary outSharedLibrary,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangSharedLibrary>))]
|
||||
out ISlangSharedLibrary outSharedLibrary,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result RenameEntryPoint(byte* newName, out Brutal.SlangApi.IComponentType outEntryPoint);
|
||||
Result RenameEntryPoint(
|
||||
byte* newName,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IComponentType>))]
|
||||
out Brutal.SlangApi.IComponentType outEntryPoint
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result LinkWithOptions(
|
||||
out Brutal.SlangApi.IComponentType outLinkedComponentType,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IComponentType>))]
|
||||
out Brutal.SlangApi.IComponentType outLinkedComponentType,
|
||||
uint compilerOptionEntryCount,
|
||||
in Brutal.SlangApi.CompilerOptionEntry compilerOptionEntries,
|
||||
out ISlangBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetTargetCode(Int targetIndex, out IBlob outCode, out IBlob outDiagnostics);
|
||||
Result GetTargetCode(
|
||||
Int targetIndex,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outCode,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetTargetMetadata(Int targetIndex, out Brutal.SlangApi.IMetadata outMetadata, out IBlob outDiagnostics);
|
||||
Result GetTargetMetadata(
|
||||
Int targetIndex,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IMetadata>))]
|
||||
out Brutal.SlangApi.IMetadata outMetadata,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetEntryPointMetadata(
|
||||
Int entryPointIndex,
|
||||
Int targetIndex,
|
||||
out Brutal.SlangApi.IMetadata outMetadata,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IMetadata>))]
|
||||
out Brutal.SlangApi.IMetadata outMetadata,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -478,16 +594,24 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface IModule : Brutal.SlangApi.IComponentType
|
||||
{
|
||||
[PreserveSig]
|
||||
Result FindEntryPointByName(byte* name, out Brutal.SlangApi.IEntryPoint outEntryPoint);
|
||||
Result FindEntryPointByName(
|
||||
byte* name,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IEntryPoint>))]
|
||||
out Brutal.SlangApi.IEntryPoint outEntryPoint
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Int32 GetDefinedEntryPointCount();
|
||||
|
||||
[PreserveSig]
|
||||
Result GetDefinedEntryPoint(Int32 index, out Brutal.SlangApi.IEntryPoint outEntryPoint);
|
||||
Result GetDefinedEntryPoint(
|
||||
Int32 index,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IEntryPoint>))]
|
||||
out Brutal.SlangApi.IEntryPoint outEntryPoint
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result Serialize(out ISlangBlob outSerializedBlob);
|
||||
Result Serialize([MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outSerializedBlob);
|
||||
|
||||
[PreserveSig]
|
||||
Result WriteToFile(byte* fileName);
|
||||
|
|
@ -505,8 +629,9 @@ namespace Brutal.SlangApi
|
|||
Result FindAndCheckEntryPoint(
|
||||
byte* name,
|
||||
Brutal.SlangApi.Stage stage,
|
||||
out Brutal.SlangApi.IEntryPoint outEntryPoint,
|
||||
out ISlangBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IEntryPoint>))]
|
||||
out Brutal.SlangApi.IEntryPoint outEntryPoint,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
|
|
@ -516,10 +641,11 @@ namespace Brutal.SlangApi
|
|||
byte* GetDependencyFilePath(Int32 index);
|
||||
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.DeclReflection>))]
|
||||
Brutal.SlangApi.DeclReflection GetModuleReflection();
|
||||
|
||||
[PreserveSig]
|
||||
Result Disassemble(out IBlob outDisassembledBlob);
|
||||
Result Disassemble([MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDisassembledBlob);
|
||||
};
|
||||
|
||||
[GeneratedComInterface]
|
||||
|
|
@ -535,7 +661,7 @@ namespace Brutal.SlangApi
|
|||
Brutal.SlangApi.ParameterCategory category,
|
||||
UInt spaceIndex,
|
||||
UInt registerIndex,
|
||||
ref Brutal.Bool8 outUsed
|
||||
[MarshalUsing(typeof(SlangBoolMarshaller))] ref Brutal.Bool8 outUsed
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
|
|
@ -550,10 +676,13 @@ namespace Brutal.SlangApi
|
|||
uint GetItemCount();
|
||||
|
||||
[PreserveSig]
|
||||
Result GetItemData(uint index, out IBlob outblob);
|
||||
Result GetItemData(uint index, [MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outblob);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetMetadata(out Brutal.SlangApi.IMetadata outMetadata);
|
||||
Result GetMetadata(
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IMetadata>))]
|
||||
out Brutal.SlangApi.IMetadata outMetadata
|
||||
);
|
||||
};
|
||||
|
||||
[GeneratedComInterface]
|
||||
|
|
@ -561,6 +690,7 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface IEntryPoint : Brutal.SlangApi.IComponentType
|
||||
{
|
||||
[PreserveSig]
|
||||
[return: MarshalUsing(typeof(SlangHandleMarshaller<Brutal.SlangApi.FunctionReflection>))]
|
||||
Brutal.SlangApi.FunctionReflection GetFunctionReflection();
|
||||
};
|
||||
|
||||
|
|
@ -571,23 +701,26 @@ namespace Brutal.SlangApi
|
|||
[PreserveSig]
|
||||
Result GetTargetCompileResult(
|
||||
Int targetIndex,
|
||||
out Brutal.SlangApi.ICompileResult outCompileResult,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.ICompileResult>))]
|
||||
out Brutal.SlangApi.ICompileResult outCompileResult,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetEntryPointCompileResult(
|
||||
Int entryPointIndex,
|
||||
Int targetIndex,
|
||||
out Brutal.SlangApi.ICompileResult outCompileResult,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.ICompileResult>))]
|
||||
out Brutal.SlangApi.ICompileResult outCompileResult,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetTargetHostCallable(
|
||||
int targetIndex,
|
||||
out ISlangSharedLibrary outSharedLibrary,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangSharedLibrary>))]
|
||||
out ISlangSharedLibrary outSharedLibrary,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -596,13 +729,16 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface IModulePrecompileService_Experimental
|
||||
{
|
||||
[PreserveSig]
|
||||
Result PrecompileForTarget(Brutal.SlangApi.CompileTarget target, out ISlangBlob outDiagnostics);
|
||||
Result PrecompileForTarget(
|
||||
Brutal.SlangApi.CompileTarget target,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<ISlangBlob>))] out ISlangBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
Result GetPrecompiledTargetCode(
|
||||
Brutal.SlangApi.CompileTarget target,
|
||||
out IBlob outCode,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outCode,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
|
||||
[PreserveSig]
|
||||
|
|
@ -611,8 +747,9 @@ namespace Brutal.SlangApi
|
|||
[PreserveSig]
|
||||
Result GetModuleDependency(
|
||||
Int dependencyIndex,
|
||||
out Brutal.SlangApi.IModule outModule,
|
||||
out IBlob outDiagnostics
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<Brutal.SlangApi.IModule>))]
|
||||
out Brutal.SlangApi.IModule outModule,
|
||||
[MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outDiagnostics
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -621,7 +758,7 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial interface IByteCodeRunner
|
||||
{
|
||||
[PreserveSig]
|
||||
Result LoadModule(IBlob moduleBlob);
|
||||
Result LoadModule([MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] IBlob moduleBlob);
|
||||
|
||||
[PreserveSig]
|
||||
Result SelectFunctionByIndex(uint functionIndex);
|
||||
|
|
@ -636,13 +773,13 @@ namespace Brutal.SlangApi
|
|||
void* GetCurrentWorkingSet();
|
||||
|
||||
[PreserveSig]
|
||||
Result Execute(void* argumentData, ByteSize64 argumentSize);
|
||||
Result Execute(void* argumentData, [MarshalUsing(typeof(SlangSizeMarshaller))] ByteSize argumentSize);
|
||||
|
||||
[PreserveSig]
|
||||
void GetErrorString(out IBlob outBlob);
|
||||
void GetErrorString([MarshalUsing(typeof(SlangInterfaceMarshaller<IBlob>))] out IBlob outBlob);
|
||||
|
||||
[PreserveSig]
|
||||
void* GetReturnValue(out ByteSize64 outValueSize);
|
||||
void* GetReturnValue([MarshalUsing(typeof(SlangSizeMarshaller))] out ByteSize outValueSize);
|
||||
|
||||
[PreserveSig]
|
||||
void SetExtInstHandlerUserData(void* userData);
|
||||
|
|
|
|||
|
|
@ -6,17 +6,6 @@ using Brutal.Strings;
|
|||
|
||||
namespace Brutal.SlangApi;
|
||||
|
||||
public static unsafe partial class ISlangUnknownExtensions
|
||||
{
|
||||
public static void* QueryInterface(this ISlangUnknown self, ref Brutal.SlangApi.Uuid uuid)
|
||||
{
|
||||
self.QueryInterface(ref uuid, out var __result).ThrowIfFailure();
|
||||
return __result;
|
||||
}
|
||||
public static Result TryQueryInterface(this ISlangUnknown self, ref Brutal.SlangApi.Uuid uuid, out void* outObject)
|
||||
=> self.QueryInterface(ref uuid, out outObject);
|
||||
}
|
||||
|
||||
public static unsafe partial class ISlangFileSystemExtensions
|
||||
{
|
||||
public static ISlangBlob LoadFile(this ISlangFileSystem self, byte* path)
|
||||
|
|
@ -75,7 +64,7 @@ public static unsafe partial class ISlangFileSystemExtExtensions
|
|||
|
||||
public static unsafe partial class ISlangMutableFileSystemExtensions
|
||||
{
|
||||
public static Result TrySaveFile(this ISlangMutableFileSystem self, byte* path, void* data, ByteSize64 size)
|
||||
public static Result TrySaveFile(this ISlangMutableFileSystem self, byte* path, void* data, ByteSize size)
|
||||
=> self.SaveFile(path, data, size);
|
||||
public static Result TrySaveFileBlob(this ISlangMutableFileSystem self, byte* path, ISlangBlob dataBlob)
|
||||
=> self.SaveFileBlob(path, dataBlob);
|
||||
|
|
@ -87,9 +76,9 @@ public static unsafe partial class ISlangMutableFileSystemExtensions
|
|||
|
||||
public static unsafe partial class ISlangWriterExtensions
|
||||
{
|
||||
public static Result TryEndAppendBuffer(this ISlangWriter self, byte* buffer, ByteSize64 numChars)
|
||||
public static Result TryEndAppendBuffer(this ISlangWriter self, byte* buffer, ByteSize numChars)
|
||||
=> self.EndAppendBuffer(buffer, numChars);
|
||||
public static Result TryWrite(this ISlangWriter self, byte* chars, ByteSize64 numChars)
|
||||
public static Result TryWrite(this ISlangWriter self, byte* chars, ByteSize numChars)
|
||||
=> self.Write(chars, numChars);
|
||||
public static Result TrySetMode(this ISlangWriter self, Brutal.SlangApi.WriterMode mode)
|
||||
=> self.SetMode(mode);
|
||||
|
|
@ -119,7 +108,7 @@ public static unsafe partial class IGlobalSessionExtensions
|
|||
=> self.CheckPassThroughSupport(passThrough);
|
||||
public static Result TryCompileCoreModule(this IGlobalSession self, CompileCoreModuleFlags flags)
|
||||
=> self.CompileCoreModule(flags);
|
||||
public static Result TryLoadCoreModule(this IGlobalSession self, void* coreModule, ByteSize64 coreModuleSizeInBytes)
|
||||
public static Result TryLoadCoreModule(this IGlobalSession self, void* coreModule, ByteSize coreModuleSizeInBytes)
|
||||
=> self.LoadCoreModule(coreModule, coreModuleSizeInBytes);
|
||||
public static ISlangBlob SaveCoreModule(this IGlobalSession self, Brutal.SlangApi.ArchiveType archiveType)
|
||||
{
|
||||
|
|
@ -130,9 +119,9 @@ public static unsafe partial class IGlobalSessionExtensions
|
|||
=> self.SaveCoreModule(archiveType, out outBlob);
|
||||
public static Result TrySetSpirvCoreGrammar(this IGlobalSession self, byte* jsonPath)
|
||||
=> self.SetSpirvCoreGrammar(jsonPath);
|
||||
public static ISlangUnknown ParseCommandLineArguments(this IGlobalSession self, int argc, byte** argv, out Brutal.SlangApi.SessionDesc outSessionDesc)
|
||||
public static Brutal.SlangApi.SessionDesc ParseCommandLineArguments(this IGlobalSession self, int argc, byte** argv, out ISlangUnknown outAuxAllocation)
|
||||
{
|
||||
self.ParseCommandLineArguments(argc, argv, out outSessionDesc, out var __result).ThrowIfFailure();
|
||||
self.ParseCommandLineArguments(argc, argv, out var __result, out outAuxAllocation).ThrowIfFailure();
|
||||
return __result;
|
||||
}
|
||||
public static Result TryParseCommandLineArguments(this IGlobalSession self, int argc, byte** argv, out Brutal.SlangApi.SessionDesc outSessionDesc, out ISlangUnknown outAuxAllocation)
|
||||
|
|
@ -146,7 +135,7 @@ public static unsafe partial class IGlobalSessionExtensions
|
|||
=> self.GetSessionDescDigest(in sessionDesc, out outBlob);
|
||||
public static Result TryCompileBuiltinModule(this IGlobalSession self, Brutal.SlangApi.BuiltinModuleName module, CompileCoreModuleFlags flags)
|
||||
=> self.CompileBuiltinModule(module, flags);
|
||||
public static Result TryLoadBuiltinModule(this IGlobalSession self, Brutal.SlangApi.BuiltinModuleName module, void* moduleData, ByteSize64 sizeInBytes)
|
||||
public static Result TryLoadBuiltinModule(this IGlobalSession self, Brutal.SlangApi.BuiltinModuleName module, void* moduleData, ByteSize sizeInBytes)
|
||||
=> self.LoadBuiltinModule(module, moduleData, sizeInBytes);
|
||||
public static ISlangBlob SaveBuiltinModule(this IGlobalSession self, Brutal.SlangApi.BuiltinModuleName module, Brutal.SlangApi.ArchiveType archiveType)
|
||||
{
|
||||
|
|
@ -187,15 +176,15 @@ public static unsafe partial class ISessionExtensions
|
|||
}
|
||||
public static Result TryCreateCompileRequest(this ISession self, out CompileRequest outCompileRequest)
|
||||
=> self.CreateCompileRequest(out outCompileRequest);
|
||||
public static ISlangBlob CreateTypeConformanceComponentType(this ISession self, Brutal.SlangApi.TypeReflection type, Brutal.SlangApi.TypeReflection interfaceType, out Brutal.SlangApi.ITypeConformance outConformance, Int conformanceIdOverride)
|
||||
public static Brutal.SlangApi.ITypeConformance CreateTypeConformanceComponentType(this ISession self, Brutal.SlangApi.TypeReflection type, Brutal.SlangApi.TypeReflection interfaceType, Int conformanceIdOverride, out ISlangBlob outDiagnostics)
|
||||
{
|
||||
self.CreateTypeConformanceComponentType(type, interfaceType, out outConformance, conformanceIdOverride, out var __result).ThrowIfFailure();
|
||||
self.CreateTypeConformanceComponentType(type, interfaceType, out var __result, conformanceIdOverride, out outDiagnostics).ThrowIfFailure();
|
||||
return __result;
|
||||
}
|
||||
public static Result TryCreateTypeConformanceComponentType(this ISession self, Brutal.SlangApi.TypeReflection type, Brutal.SlangApi.TypeReflection interfaceType, out Brutal.SlangApi.ITypeConformance outConformance, Int conformanceIdOverride, out ISlangBlob outDiagnostics)
|
||||
=> self.CreateTypeConformanceComponentType(type, interfaceType, out outConformance, conformanceIdOverride, out outDiagnostics);
|
||||
public static Result TryGetDynamicObjectRTTIBytes(this ISession self, Brutal.SlangApi.TypeReflection type, Brutal.SlangApi.TypeReflection interfaceType, out uint outRTTIDataBuffer, uint bufferSizeInBytes)
|
||||
=> self.GetDynamicObjectRTTIBytes(type, interfaceType, out outRTTIDataBuffer, bufferSizeInBytes);
|
||||
public static Result TryGetDynamicObjectRTTIBytes(this ISession self, Brutal.SlangApi.TypeReflection type, Brutal.SlangApi.TypeReflection interfaceType, uint* outRTTIDataBuffer, uint bufferSizeInBytes)
|
||||
=> self.GetDynamicObjectRTTIBytes(type, interfaceType, outRTTIDataBuffer, bufferSizeInBytes);
|
||||
public static Result TryLoadModuleInfoFromIRBlob(this ISession self, IBlob source, ref Int outModuleVersion, ref byte* outModuleCompilerVersion, ref byte* outModuleName)
|
||||
=> self.LoadModuleInfoFromIRBlob(source, ref outModuleVersion, ref outModuleCompilerVersion, ref outModuleName);
|
||||
public static Brutal.SlangApi.SourceLocation GetDeclSourceLocation(this ISession self, Brutal.SlangApi.DeclReflection decl)
|
||||
|
|
@ -251,9 +240,9 @@ public static unsafe partial class IComponentTypeExtensions
|
|||
}
|
||||
public static Result TryRenameEntryPoint(this IComponentType self, byte* newName, out Brutal.SlangApi.IComponentType outEntryPoint)
|
||||
=> self.RenameEntryPoint(newName, out outEntryPoint);
|
||||
public static ISlangBlob LinkWithOptions(this IComponentType self, out Brutal.SlangApi.IComponentType outLinkedComponentType, uint compilerOptionEntryCount, in Brutal.SlangApi.CompilerOptionEntry compilerOptionEntries)
|
||||
public static Brutal.SlangApi.IComponentType LinkWithOptions(this IComponentType self, uint compilerOptionEntryCount, in Brutal.SlangApi.CompilerOptionEntry compilerOptionEntries, out ISlangBlob outDiagnostics)
|
||||
{
|
||||
self.LinkWithOptions(out outLinkedComponentType, compilerOptionEntryCount, in compilerOptionEntries, out var __result).ThrowIfFailure();
|
||||
self.LinkWithOptions(out var __result, compilerOptionEntryCount, in compilerOptionEntries, out outDiagnostics).ThrowIfFailure();
|
||||
return __result;
|
||||
}
|
||||
public static Result TryLinkWithOptions(this IComponentType self, out Brutal.SlangApi.IComponentType outLinkedComponentType, uint compilerOptionEntryCount, in Brutal.SlangApi.CompilerOptionEntry compilerOptionEntries, out ISlangBlob outDiagnostics)
|
||||
|
|
@ -409,7 +398,7 @@ public static unsafe partial class IByteCodeRunnerExtensions
|
|||
}
|
||||
public static Result TryGetFunctionInfo(this IByteCodeRunner self, uint index, out Brutal.SlangApi.ByteCodeFuncInfo outInfo)
|
||||
=> self.GetFunctionInfo(index, out outInfo);
|
||||
public static Result TryExecute(this IByteCodeRunner self, void* argumentData, ByteSize64 argumentSize)
|
||||
public static Result TryExecute(this IByteCodeRunner self, void* argumentData, ByteSize argumentSize)
|
||||
=> self.Execute(argumentData, argumentSize);
|
||||
public static Result TryRegisterExtCall(this IByteCodeRunner self, byte* name, VMExtFunction functionPtr)
|
||||
=> self.RegisterExtCall(name, functionPtr);
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ namespace Brutal.SlangApi
|
|||
CompileRequest request,
|
||||
RefString8 basePath,
|
||||
void* libData,
|
||||
ByteSize64 libDataSize
|
||||
ByteSize libDataSize
|
||||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
|
|
@ -342,7 +342,7 @@ namespace Brutal.SlangApi
|
|||
public static partial void* spGetEntryPointCode(
|
||||
CompileRequest request,
|
||||
int entryPointIndex,
|
||||
out ByteSize64 outSize
|
||||
out ByteSize outSize
|
||||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
|
|
@ -372,7 +372,7 @@ namespace Brutal.SlangApi
|
|||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial void* spGetCompileRequestCode(CompileRequest request, out ByteSize64 outSize);
|
||||
public static partial void* spGetCompileRequestCode(CompileRequest request, out ByteSize outSize);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial Result spGetContainerCode(CompileRequest request, out nint outBlob);
|
||||
|
|
@ -382,7 +382,7 @@ namespace Brutal.SlangApi
|
|||
CompileRequest request,
|
||||
nint fileSystem,
|
||||
void* data,
|
||||
ByteSize64 size
|
||||
ByteSize size
|
||||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
|
|
@ -402,7 +402,7 @@ namespace Brutal.SlangApi
|
|||
public static partial Result spExtractRepro(
|
||||
nint session,
|
||||
void* reproData,
|
||||
ByteSize64 reproDataSize,
|
||||
ByteSize reproDataSize,
|
||||
nint fileSystem
|
||||
);
|
||||
|
||||
|
|
@ -410,7 +410,7 @@ namespace Brutal.SlangApi
|
|||
public static partial Result spLoadReproAsFileSystem(
|
||||
nint session,
|
||||
void* reproData,
|
||||
ByteSize64 reproDataSize,
|
||||
ByteSize reproDataSize,
|
||||
nint replaceFileSystem,
|
||||
out nint outFileSystem
|
||||
);
|
||||
|
|
@ -473,7 +473,7 @@ namespace Brutal.SlangApi
|
|||
public static partial string spReflectionUserAttribute_GetArgumentValueString(
|
||||
Brutal.SlangApi.ReflectionUserAttribute attrib,
|
||||
uint index,
|
||||
out ByteSize64 outSize
|
||||
out ByteSize outSize
|
||||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
|
|
@ -507,10 +507,10 @@ namespace Brutal.SlangApi
|
|||
public static partial ReflectionVariable spReflectionType_GetFieldByIndex(ReflectionType type, uint index);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ByteSize64 spReflectionType_GetElementCount(ReflectionType type);
|
||||
public static partial ByteSize spReflectionType_GetElementCount(ReflectionType type);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ByteSize64 spReflectionType_GetSpecializedElementCount(
|
||||
public static partial ByteSize spReflectionType_GetSpecializedElementCount(
|
||||
ReflectionType type,
|
||||
Reflection reflection
|
||||
);
|
||||
|
|
@ -558,13 +558,13 @@ namespace Brutal.SlangApi
|
|||
public static partial Brutal.SlangApi.TypeKind spReflectionTypeLayout_getKind(ReflectionTypeLayout type);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ByteSize64 spReflectionTypeLayout_GetSize(
|
||||
public static partial ByteSize spReflectionTypeLayout_GetSize(
|
||||
ReflectionTypeLayout type,
|
||||
Brutal.SlangApi.ParameterCategory category
|
||||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ByteSize64 spReflectionTypeLayout_GetStride(
|
||||
public static partial ByteSize spReflectionTypeLayout_GetStride(
|
||||
ReflectionTypeLayout type,
|
||||
Brutal.SlangApi.ParameterCategory category
|
||||
);
|
||||
|
|
@ -597,7 +597,7 @@ namespace Brutal.SlangApi
|
|||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ByteSize64 spReflectionTypeLayout_GetElementStride(
|
||||
public static partial ByteSize spReflectionTypeLayout_GetElementStride(
|
||||
ReflectionTypeLayout type,
|
||||
Brutal.SlangApi.ParameterCategory category
|
||||
);
|
||||
|
|
@ -801,7 +801,7 @@ namespace Brutal.SlangApi
|
|||
public static partial ReflectionType spReflectionVariable_GetType(ReflectionVariable var);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial Brutal.SlangApi.ReflectionModifier spReflectionVariable_FindModifier(
|
||||
public static partial ReflectionModifier spReflectionVariable_FindModifier(
|
||||
ReflectionVariable var,
|
||||
Brutal.SlangApi.ModifierID modifierID
|
||||
);
|
||||
|
|
@ -851,13 +851,13 @@ namespace Brutal.SlangApi
|
|||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ByteSize64 spReflectionVariableLayout_GetOffset(
|
||||
public static partial ByteSize spReflectionVariableLayout_GetOffset(
|
||||
ReflectionVariableLayout var,
|
||||
Brutal.SlangApi.ParameterCategory category
|
||||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ByteSize64 spReflectionVariableLayout_GetSpace(
|
||||
public static partial ByteSize spReflectionVariableLayout_GetSpace(
|
||||
ReflectionVariableLayout var,
|
||||
Brutal.SlangApi.ParameterCategory category
|
||||
);
|
||||
|
|
@ -875,7 +875,7 @@ namespace Brutal.SlangApi
|
|||
public static partial string spReflectionVariableLayout_GetSemanticName(ReflectionVariableLayout var);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ByteSize64 spReflectionVariableLayout_GetSemanticIndex(ReflectionVariableLayout var);
|
||||
public static partial ByteSize spReflectionVariableLayout_GetSemanticIndex(ReflectionVariableLayout var);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ReflectionDecl spReflectionFunction_asDecl(ReflectionFunction func);
|
||||
|
|
@ -888,7 +888,7 @@ namespace Brutal.SlangApi
|
|||
public static partial string spReflectionFunction_GetName(ReflectionFunction func);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial Brutal.SlangApi.ReflectionModifier spReflectionFunction_FindModifier(
|
||||
public static partial ReflectionModifier spReflectionFunction_FindModifier(
|
||||
ReflectionFunction var,
|
||||
Brutal.SlangApi.ModifierID modifierID
|
||||
);
|
||||
|
|
@ -981,7 +981,7 @@ namespace Brutal.SlangApi
|
|||
public static partial ReflectionDecl spReflectionDecl_getParent(ReflectionDecl decl);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial Brutal.SlangApi.ReflectionModifier spReflectionDecl_findModifier(
|
||||
public static partial ReflectionModifier spReflectionDecl_findModifier(
|
||||
ReflectionDecl decl,
|
||||
Brutal.SlangApi.ModifierID modifierID
|
||||
);
|
||||
|
|
@ -1120,7 +1120,7 @@ namespace Brutal.SlangApi
|
|||
public static partial void spReflectionEntryPoint_getComputeThreadGroupSize(
|
||||
ReflectionEntryPoint entryPoint,
|
||||
UInt axisCount,
|
||||
out UInt outSizeAlongAxis
|
||||
UInt* outSizeAlongAxis
|
||||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
|
|
@ -1251,7 +1251,7 @@ namespace Brutal.SlangApi
|
|||
public static partial UInt spReflection_getGlobalConstantBufferBinding(Reflection reflection);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ByteSize64 spReflection_getGlobalConstantBufferSize(Reflection reflection);
|
||||
public static partial ByteSize spReflection_getGlobalConstantBufferSize(Reflection reflection);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ReflectionType spReflection_specializeType(
|
||||
|
|
@ -1290,11 +1290,11 @@ namespace Brutal.SlangApi
|
|||
public static partial string spReflection_getHashedString(
|
||||
Reflection reflection,
|
||||
UInt index,
|
||||
out ByteSize64 outCount
|
||||
out ByteSize outCount
|
||||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial UInt32 spComputeStringHash(RefString8 chars, ByteSize64 count);
|
||||
public static partial UInt32 spComputeStringHash(RefString8 chars, ByteSize count);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial ReflectionTypeLayout spReflection_getGlobalParamsTypeLayout(Reflection reflection);
|
||||
|
|
@ -1312,9 +1312,6 @@ namespace Brutal.SlangApi
|
|||
[LibraryImport("slang")]
|
||||
public static partial Int spReflection_getBindlessSpaceIndex(Reflection reflection);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial nint spReflection_GetSession(Reflection reflection);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial Result spCompileRequest_getProgram(CompileRequest request, out nint outProgram);
|
||||
|
||||
|
|
@ -1342,7 +1339,7 @@ namespace Brutal.SlangApi
|
|||
public static partial Result spCompileRequest_getSession(CompileRequest request, out nint outSession);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial nint slang_createBlob(void* data, ByteSize64 size);
|
||||
public static partial nint slang_createBlob(void* data, ByteSize size);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial nint slang_loadModuleFromSource(
|
||||
|
|
@ -1350,7 +1347,7 @@ namespace Brutal.SlangApi
|
|||
RefString8 moduleName,
|
||||
RefString8 path,
|
||||
RefString8 source,
|
||||
ByteSize64 sourceSize,
|
||||
ByteSize sourceSize,
|
||||
out nint outDiagnostics
|
||||
);
|
||||
|
||||
|
|
@ -1360,7 +1357,7 @@ namespace Brutal.SlangApi
|
|||
RefString8 moduleName,
|
||||
RefString8 path,
|
||||
void* source,
|
||||
ByteSize64 sourceSize,
|
||||
ByteSize sourceSize,
|
||||
out nint outDiagnostics
|
||||
);
|
||||
|
||||
|
|
@ -1368,7 +1365,7 @@ namespace Brutal.SlangApi
|
|||
public static partial Result slang_loadModuleInfoFromIRBlob(
|
||||
nint session,
|
||||
void* source,
|
||||
ByteSize64 sourceSize,
|
||||
ByteSize sourceSize,
|
||||
ref Int outModuleVersion,
|
||||
ref byte* outModuleCompilerVersion,
|
||||
ref byte* outModuleName
|
||||
|
|
@ -1389,9 +1386,6 @@ namespace Brutal.SlangApi
|
|||
out nint outGlobalSession
|
||||
);
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial nint slang_getEmbeddedCoreModule();
|
||||
|
||||
[LibraryImport("slang")]
|
||||
public static partial void slang_shutdown();
|
||||
|
||||
|
|
@ -1502,7 +1496,7 @@ namespace Brutal.SlangApi
|
|||
internal static unsafe Result ExtractRepro(
|
||||
nint session,
|
||||
void* reproData,
|
||||
ByteSize64 reproDataSize,
|
||||
ByteSize reproDataSize,
|
||||
nint fileSystem
|
||||
)
|
||||
{
|
||||
|
|
@ -1512,7 +1506,7 @@ namespace Brutal.SlangApi
|
|||
internal static unsafe Result LoadReproAsFileSystem(
|
||||
nint session,
|
||||
void* reproData,
|
||||
ByteSize64 reproDataSize,
|
||||
ByteSize reproDataSize,
|
||||
nint replaceFileSystem,
|
||||
out nint outFileSystem
|
||||
)
|
||||
|
|
@ -1567,12 +1561,12 @@ namespace Brutal.SlangApi
|
|||
return PInvoke.spReflectionType_GetFieldByIndex(type, index);
|
||||
}
|
||||
|
||||
public static ByteSize64 ReflectionTypeGetElementCount(ReflectionType type)
|
||||
public static ByteSize ReflectionTypeGetElementCount(ReflectionType type)
|
||||
{
|
||||
return PInvoke.spReflectionType_GetElementCount(type);
|
||||
}
|
||||
|
||||
public static ByteSize64 ReflectionTypeGetSpecializedElementCount(ReflectionType type, Reflection reflection)
|
||||
public static ByteSize ReflectionTypeGetSpecializedElementCount(ReflectionType type, Reflection reflection)
|
||||
{
|
||||
return PInvoke.spReflectionType_GetSpecializedElementCount(type, reflection);
|
||||
}
|
||||
|
|
@ -1637,7 +1631,7 @@ namespace Brutal.SlangApi
|
|||
return PInvoke.spReflectionTypeLayout_getKind(type);
|
||||
}
|
||||
|
||||
public static ByteSize64 ReflectionTypeLayoutGetSize(
|
||||
public static ByteSize ReflectionTypeLayoutGetSize(
|
||||
ReflectionTypeLayout type,
|
||||
Brutal.SlangApi.ParameterCategory category
|
||||
)
|
||||
|
|
@ -1645,7 +1639,7 @@ namespace Brutal.SlangApi
|
|||
return PInvoke.spReflectionTypeLayout_GetSize(type, category);
|
||||
}
|
||||
|
||||
public static ByteSize64 ReflectionTypeLayoutGetStride(
|
||||
public static ByteSize ReflectionTypeLayoutGetStride(
|
||||
ReflectionTypeLayout type,
|
||||
Brutal.SlangApi.ParameterCategory category
|
||||
)
|
||||
|
|
@ -1688,7 +1682,7 @@ namespace Brutal.SlangApi
|
|||
return PInvoke.spReflectionTypeLayout_GetExplicitCounter(typeLayout);
|
||||
}
|
||||
|
||||
public static ByteSize64 ReflectionTypeLayoutGetElementStride(
|
||||
public static ByteSize ReflectionTypeLayoutGetElementStride(
|
||||
ReflectionTypeLayout type,
|
||||
Brutal.SlangApi.ParameterCategory category
|
||||
)
|
||||
|
|
@ -1954,7 +1948,7 @@ namespace Brutal.SlangApi
|
|||
return PInvoke.spReflectionVariable_GetType(var);
|
||||
}
|
||||
|
||||
public static Brutal.SlangApi.ReflectionModifier ReflectionVariableFindModifier(
|
||||
public static ReflectionModifier ReflectionVariableFindModifier(
|
||||
ReflectionVariable var,
|
||||
Brutal.SlangApi.ModifierID modifierID
|
||||
)
|
||||
|
|
@ -2022,7 +2016,7 @@ namespace Brutal.SlangApi
|
|||
return PInvoke.spReflectionFunction_GetName(func);
|
||||
}
|
||||
|
||||
public static Brutal.SlangApi.ReflectionModifier ReflectionFunctionFindModifier(
|
||||
public static ReflectionModifier ReflectionFunctionFindModifier(
|
||||
ReflectionFunction var,
|
||||
Brutal.SlangApi.ModifierID modifierID
|
||||
)
|
||||
|
|
@ -2149,7 +2143,7 @@ namespace Brutal.SlangApi
|
|||
return PInvoke.spReflectionDecl_getParent(decl);
|
||||
}
|
||||
|
||||
public static Brutal.SlangApi.ReflectionModifier ReflectionDeclFindModifier(
|
||||
public static ReflectionModifier ReflectionDeclFindModifier(
|
||||
ReflectionDecl decl,
|
||||
Brutal.SlangApi.ModifierID modifierID
|
||||
)
|
||||
|
|
@ -2263,12 +2257,12 @@ namespace Brutal.SlangApi
|
|||
return PInvoke.spReflectionTypeParameter_GetConstraintByIndex(typeParam, index);
|
||||
}
|
||||
|
||||
public static UInt32 ComputeStringHash(RefString8 chars, ByteSize64 count)
|
||||
public static UInt32 ComputeStringHash(RefString8 chars, ByteSize count)
|
||||
{
|
||||
return PInvoke.spComputeStringHash(chars, count);
|
||||
}
|
||||
|
||||
internal static unsafe nint CreateBlob(void* data, ByteSize64 size)
|
||||
internal static unsafe nint CreateBlob(void* data, ByteSize size)
|
||||
{
|
||||
return PInvoke.slang_createBlob(data, size);
|
||||
}
|
||||
|
|
@ -2278,7 +2272,7 @@ namespace Brutal.SlangApi
|
|||
RefString8 moduleName,
|
||||
RefString8 path,
|
||||
RefString8 source,
|
||||
ByteSize64 sourceSize,
|
||||
ByteSize sourceSize,
|
||||
out nint outDiagnostics
|
||||
)
|
||||
{
|
||||
|
|
@ -2297,7 +2291,7 @@ namespace Brutal.SlangApi
|
|||
RefString8 moduleName,
|
||||
RefString8 path,
|
||||
void* source,
|
||||
ByteSize64 sourceSize,
|
||||
ByteSize sourceSize,
|
||||
out nint outDiagnostics
|
||||
)
|
||||
{
|
||||
|
|
@ -2314,7 +2308,7 @@ namespace Brutal.SlangApi
|
|||
internal static unsafe Result LoadModuleInfoFromIRBlob(
|
||||
nint session,
|
||||
void* source,
|
||||
ByteSize64 sourceSize,
|
||||
ByteSize sourceSize,
|
||||
ref Int outModuleVersion,
|
||||
ref byte* outModuleCompilerVersion,
|
||||
ref byte* outModuleName
|
||||
|
|
@ -2348,11 +2342,6 @@ namespace Brutal.SlangApi
|
|||
return PInvoke.slang_createGlobalSessionWithoutCoreModule(apiVersion, out outGlobalSession);
|
||||
}
|
||||
|
||||
internal static nint GetEmbeddedCoreModule()
|
||||
{
|
||||
return PInvoke.slang_getEmbeddedCoreModule();
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
{
|
||||
PInvoke.slang_shutdown();
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ namespace Brutal.SlangApi
|
|||
Slang.PInvoke.spAddTranslationUnitSourceString(this, translationUnitIndex, path, source);
|
||||
}
|
||||
|
||||
public unsafe Result AddLibraryReference(RefString8 basePath, void* libData, ByteSize64 libDataSize)
|
||||
public unsafe Result AddLibraryReference(RefString8 basePath, void* libData, ByteSize libDataSize)
|
||||
{
|
||||
return Slang.PInvoke.spAddLibraryReference(this, basePath, libData, libDataSize);
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spGetEntryPointSource(this, entryPointIndex);
|
||||
}
|
||||
|
||||
public unsafe void* GetEntryPointCode(int entryPointIndex, out ByteSize64 outSize)
|
||||
public unsafe void* GetEntryPointCode(int entryPointIndex, out ByteSize outSize)
|
||||
{
|
||||
return Slang.PInvoke.spGetEntryPointCode(this, entryPointIndex, out outSize);
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spGetTargetHostCallable(this, targetIndex, out outSharedLibrary);
|
||||
}
|
||||
|
||||
public unsafe void* GetCompileRequestCode(out ByteSize64 outSize)
|
||||
public unsafe void* GetCompileRequestCode(out ByteSize outSize)
|
||||
{
|
||||
return Slang.PInvoke.spGetCompileRequestCode(this, out outSize);
|
||||
}
|
||||
|
|
@ -340,7 +340,7 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spGetContainerCode(this, out outBlob);
|
||||
}
|
||||
|
||||
internal unsafe Result LoadRepro(nint fileSystem, void* data, ByteSize64 size)
|
||||
internal unsafe Result LoadRepro(nint fileSystem, void* data, ByteSize size)
|
||||
{
|
||||
return Slang.PInvoke.spLoadRepro(this, fileSystem, data, size);
|
||||
}
|
||||
|
|
@ -494,7 +494,7 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spReflectionDecl_getParent(this);
|
||||
}
|
||||
|
||||
public Brutal.SlangApi.ReflectionModifier FindModifier(Brutal.SlangApi.ModifierID modifierID)
|
||||
public ReflectionModifier FindModifier(Brutal.SlangApi.ModifierID modifierID)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionDecl_findModifier(this, modifierID);
|
||||
}
|
||||
|
|
@ -513,12 +513,12 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spReflectionTypeLayout_getKind(this);
|
||||
}
|
||||
|
||||
public ByteSize64 GetSize(Brutal.SlangApi.ParameterCategory category)
|
||||
public ByteSize GetSize(Brutal.SlangApi.ParameterCategory category)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionTypeLayout_GetSize(this, category);
|
||||
}
|
||||
|
||||
public ByteSize64 GetStride(Brutal.SlangApi.ParameterCategory category)
|
||||
public ByteSize GetStride(Brutal.SlangApi.ParameterCategory category)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionTypeLayout_GetStride(this, category);
|
||||
}
|
||||
|
|
@ -548,7 +548,7 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spReflectionTypeLayout_GetExplicitCounter(this);
|
||||
}
|
||||
|
||||
public ByteSize64 GetElementStride(Brutal.SlangApi.ParameterCategory category)
|
||||
public ByteSize GetElementStride(Brutal.SlangApi.ParameterCategory category)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionTypeLayout_GetElementStride(this, category);
|
||||
}
|
||||
|
|
@ -817,12 +817,12 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spReflectionType_GetFieldByIndex(this, index);
|
||||
}
|
||||
|
||||
public ByteSize64 GetElementCount()
|
||||
public ByteSize GetElementCount()
|
||||
{
|
||||
return Slang.PInvoke.spReflectionType_GetElementCount(this);
|
||||
}
|
||||
|
||||
public ByteSize64 GetSpecializedElementCount(Reflection reflection)
|
||||
public ByteSize GetSpecializedElementCount(Reflection reflection)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionType_GetSpecializedElementCount(this, reflection);
|
||||
}
|
||||
|
|
@ -901,12 +901,12 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spReflectionVariableLayout_GetTypeLayout(this);
|
||||
}
|
||||
|
||||
public ByteSize64 GetOffset(Brutal.SlangApi.ParameterCategory category)
|
||||
public ByteSize GetOffset(Brutal.SlangApi.ParameterCategory category)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionVariableLayout_GetOffset(this, category);
|
||||
}
|
||||
|
||||
public ByteSize64 GetSpace(Brutal.SlangApi.ParameterCategory category)
|
||||
public ByteSize GetSpace(Brutal.SlangApi.ParameterCategory category)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionVariableLayout_GetSpace(this, category);
|
||||
}
|
||||
|
|
@ -921,7 +921,7 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spReflectionVariableLayout_GetSemanticName(this);
|
||||
}
|
||||
|
||||
public ByteSize64 GetSemanticIndex()
|
||||
public ByteSize GetSemanticIndex()
|
||||
{
|
||||
return Slang.PInvoke.spReflectionVariableLayout_GetSemanticIndex(this);
|
||||
}
|
||||
|
|
@ -950,7 +950,7 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spReflectionVariable_GetType(this);
|
||||
}
|
||||
|
||||
public Brutal.SlangApi.ReflectionModifier FindModifier(Brutal.SlangApi.ModifierID modifierID)
|
||||
public ReflectionModifier FindModifier(Brutal.SlangApi.ModifierID modifierID)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionVariable_FindModifier(this, modifierID);
|
||||
}
|
||||
|
|
@ -1009,7 +1009,7 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spReflectionFunction_GetName(this);
|
||||
}
|
||||
|
||||
public Brutal.SlangApi.ReflectionModifier FindModifier(Brutal.SlangApi.ModifierID modifierID)
|
||||
public ReflectionModifier FindModifier(Brutal.SlangApi.ModifierID modifierID)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionFunction_FindModifier(this, modifierID);
|
||||
}
|
||||
|
|
@ -1149,9 +1149,6 @@ namespace Brutal.SlangApi
|
|||
}
|
||||
};
|
||||
|
||||
[InteropHandle]
|
||||
public readonly unsafe partial struct Attribute { };
|
||||
|
||||
[InteropHandle]
|
||||
public readonly unsafe partial struct ShaderReflection { };
|
||||
|
||||
|
|
@ -1213,7 +1210,7 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial struct SessionDesc
|
||||
{
|
||||
/// The size of this structure, in bytes.
|
||||
public ByteSize64 StructureSize;
|
||||
public ByteSize StructureSize;
|
||||
|
||||
/// Code generation targets to include in the session.
|
||||
public Brutal.SlangApi.TargetDesc* Targets;
|
||||
|
|
@ -1272,7 +1269,7 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial struct TargetDesc
|
||||
{
|
||||
/// The size of this structure, in bytes.
|
||||
public ByteSize64 StructureSize;
|
||||
public ByteSize StructureSize;
|
||||
|
||||
/// The target format to generate code for (e.g., SPIR-V, DXIL, etc.)
|
||||
public Brutal.SlangApi.CompileTarget Format;
|
||||
|
|
@ -1336,7 +1333,7 @@ namespace Brutal.SlangApi
|
|||
public unsafe partial struct ByteCodeRunnerDesc
|
||||
{
|
||||
/// The size of this structure, in bytes.
|
||||
public ByteSize64 StructSize;
|
||||
public ByteSize StructSize;
|
||||
};
|
||||
|
||||
/// A "Universally Unique Identifier" (UUID)
|
||||
|
|
@ -1355,8 +1352,6 @@ namespace Brutal.SlangApi
|
|||
public fixed byte Data4[8];
|
||||
};
|
||||
|
||||
public unsafe partial struct Guid { };
|
||||
|
||||
/// Can be requested from ISlangCastable cast to indicate the contained chars are null
|
||||
/// terminated.
|
||||
public unsafe partial struct TerminatedChars
|
||||
|
|
@ -1372,8 +1367,6 @@ namespace Brutal.SlangApi
|
|||
[InteropHandle]
|
||||
public readonly unsafe partial struct EntryPointLayout { };
|
||||
|
||||
public unsafe partial struct ReflectionModifier { };
|
||||
|
||||
[InteropHandle]
|
||||
public readonly unsafe partial struct ReflectionUserAttribute
|
||||
{
|
||||
|
|
@ -1402,7 +1395,7 @@ namespace Brutal.SlangApi
|
|||
return Slang.PInvoke.spReflectionUserAttribute_GetArgumentValueFloat(this, index, rs);
|
||||
}
|
||||
|
||||
public string GetArgumentValueString(uint index, out ByteSize64 outSize)
|
||||
public string GetArgumentValueString(uint index, out ByteSize outSize)
|
||||
{
|
||||
return Slang.PInvoke.spReflectionUserAttribute_GetArgumentValueString(this, index, out outSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,17 +122,11 @@ public static unsafe class ICompileRequestExtensions
|
|||
/// <summary>
|
||||
/// Returns the <see cref="ISlangWriter"/> currently installed for
|
||||
/// <paramref name="channel"/>, or <c>null</c> if the channel is unset. Slang's
|
||||
/// getter does not AddRef the returned pointer, so this wrapper performs the
|
||||
/// AddRef itself before handing the pointer to <see cref="ComWrappers"/>.
|
||||
/// getter lends the pointer without an AddRef; the returned proxy takes its own
|
||||
/// reference, so release it with <see cref="Slang.Release"/>.
|
||||
/// </summary>
|
||||
public static ISlangWriter? GetWriter(this ICompileRequest self, WriterChannel channel)
|
||||
{
|
||||
var raw = self.GetWriter(channel);
|
||||
if (raw == 0)
|
||||
return null;
|
||||
Marshal.AddRef(raw);
|
||||
return (ISlangWriter)Slang.ComWrappers.GetOrCreateObjectForComInstance(raw, CreateObjectFlags.None);
|
||||
}
|
||||
public static ISlangWriter? GetWriter(this ICompileRequest self, WriterChannel channel) =>
|
||||
Slang.WrapBorrowedComInstance<ISlangWriter>(self.GetWriter(channel));
|
||||
|
||||
/// <summary>
|
||||
/// Adds a translation-unit source whose contents are provided as an
|
||||
|
|
|
|||
|
|
@ -139,6 +139,24 @@ public static unsafe partial class ISessionExtensions
|
|||
return self.LoadModuleFromIRBlob(nameP, pathP, source, out outDiagnostics);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the RTTI bytes Slang uses to identify <paramref name="type"/>'s conformance to
|
||||
/// <paramref name="interfaceType"/> into <paramref name="buffer"/>, which must hold at
|
||||
/// least 16 bytes.
|
||||
/// </summary>
|
||||
/// <exception cref="SlangException">Thrown if slang reports a failing <see cref="Result"/>.</exception>
|
||||
public static void GetDynamicObjectRTTIBytes(
|
||||
this ISession self,
|
||||
TypeReflection type,
|
||||
TypeReflection interfaceType,
|
||||
Span<byte> buffer
|
||||
)
|
||||
{
|
||||
fixed (byte* p = buffer)
|
||||
self.GetDynamicObjectRTTIBytes(type, interfaceType, (uint*)p, checked((uint)buffer.Length))
|
||||
.ThrowIfFailure();
|
||||
}
|
||||
|
||||
private const int ShortStringStackBytes = 256;
|
||||
private const int LongStringStackBytes = 8192;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ public static unsafe partial class ISlangBlobExtensions
|
|||
{
|
||||
/// <summary>
|
||||
/// Returns the blob's contents as a <see cref="ReadOnlySpan{Byte}"/>. The span is
|
||||
/// valid for the lifetime of the underlying blob. Copy if you need the bytes
|
||||
/// to outlive it.
|
||||
/// valid until the blob is passed to <see cref="Slang.Release"/>. Copy if you need
|
||||
/// the bytes to outlive it.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> AsSpan(this ISlangBlob self) =>
|
||||
new(self.GetBufferPointer(), checked((int)self.GetBufferSize()));
|
||||
new(self.GetBufferPointer(), checked((int)self.GetBufferSize().Value));
|
||||
}
|
||||
|
|
|
|||
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);
|
||||
}
|
||||
|
|
@ -6,25 +6,25 @@ namespace Brutal.SlangApi;
|
|||
/// The Slang class provides access to the slang library for compiling shaders.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Slang COM proxies (returned by <see cref="CreateGlobalSession(Int)"/>,
|
||||
/// <see cref="ISessionExtensions.LoadModule"/>, etc.) are released by the ComWrappers
|
||||
/// finalizer when GC reclaims the managed proxy. There is no deterministic
|
||||
/// <c>Dispose</c>. Callers don't need to do anything special. COM proxies in this
|
||||
/// binding represent shared-ownership references; the underlying slang object stays
|
||||
/// alive as long as anything (slang internals, other proxies, or the global session)
|
||||
/// holds a reference, regardless of when any single proxy is collected.
|
||||
/// Release returned COM proxies with <see cref="Release"/> on the thread using
|
||||
/// them, in reverse dependency order: code/diagnostics and components, modules,
|
||||
/// session, then global session. Keep parents alive until their children have
|
||||
/// been released. The garbage collector never releases a proxy, so one that is
|
||||
/// not passed to <see cref="Release"/> keeps its native object alive.
|
||||
/// Each returned proxy owns an independent reference; releasing one proxy does
|
||||
/// not invalidate another proxy for the same native object.
|
||||
/// </remarks>
|
||||
public static partial class Slang
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="ComWrappers"/> instance used to bridge raw COM pointers obtained from
|
||||
/// <c>slang_*</c> entry points (e.g. <see cref="PInvoke.slang_createGlobalSession"/>)
|
||||
/// into managed <c>[GeneratedComInterface]</c> proxies. The default
|
||||
/// <see cref="StrategyBasedComWrappers"/> implementation discovers proxy classes
|
||||
/// into managed <c>[GeneratedComInterface]</c> proxies. <see cref="SlangComWrappers"/>
|
||||
/// keeps <see cref="StrategyBasedComWrappers"/>' discovery of the proxy classes
|
||||
/// emitted by the source generator from the type's IID, so no per-interface
|
||||
/// registration is needed.
|
||||
/// </summary>
|
||||
internal static readonly StrategyBasedComWrappers ComWrappers = new();
|
||||
internal static readonly StrategyBasedComWrappers ComWrappers = new SlangComWrappers();
|
||||
|
||||
public static partial class PInvoke
|
||||
{
|
||||
|
|
@ -34,6 +34,15 @@ public static partial class Slang
|
|||
|
||||
var nativeDll = NativeLibrary.Load("slang", assembly, DllImportSearchPath.AssemblyDirectory);
|
||||
|
||||
// Slang loads slang-glslang and slang-glsl-module by bare name at run time. Windows
|
||||
// searches only the application and system directories for them, which misses a
|
||||
// RID-less NuGet build's runtimes/win-x64/native folder, so load them from wherever
|
||||
// slang came from; Slang's own LoadLibrary then finds the loaded modules. macOS and
|
||||
// Linux resolve them through slang's rpath.
|
||||
if (OperatingSystem.IsWindows())
|
||||
foreach (var companion in (ReadOnlySpan<string>)["slang-glslang", "slang-glsl-module"])
|
||||
NativeLibrary.TryLoad(companion, assembly, DllImportSearchPath.AssemblyDirectory, out _);
|
||||
|
||||
NativeLibrary.SetDllImportResolver(
|
||||
assembly,
|
||||
(libraryName, _, _) => libraryName == "slang" ? nativeDll : IntPtr.Zero
|
||||
|
|
@ -93,10 +102,10 @@ public static partial class Slang
|
|||
{
|
||||
nint raw;
|
||||
fixed (byte* p = data)
|
||||
raw = PInvoke.slang_createBlob(p, (Brutal.ByteSize64)data.Length);
|
||||
raw = PInvoke.slang_createBlob(p, Brutal.ByteSize.Of(data));
|
||||
if (raw == 0)
|
||||
throw new SlangException((Result)(-1), "slang_createBlob returned a null pointer.");
|
||||
return (ISlangBlob)ComWrappers.GetOrCreateObjectForComInstance(raw, CreateObjectFlags.None);
|
||||
return WrapComInstance<ISlangBlob>((Result)0, raw)!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -151,9 +160,54 @@ public static partial class Slang
|
|||
internal static T? WrapComInstance<T>(Result hr, nint comInstance)
|
||||
where T : class
|
||||
{
|
||||
if (hr.IsFailure || comInstance == 0)
|
||||
if (comInstance == 0)
|
||||
return null;
|
||||
return (T)ComWrappers.GetOrCreateObjectForComInstance(comInstance, CreateObjectFlags.None);
|
||||
try
|
||||
{
|
||||
return hr.IsFailure ? null : WrapBorrowedComInstance<T>(comInstance);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// The RCW retains its own reference. Consume the reference transferred by
|
||||
// the native export, including when interface conversion throws.
|
||||
Marshal.Release(comInstance);
|
||||
}
|
||||
}
|
||||
|
||||
internal static T? WrapBorrowedComInstance<T>(nint pointer)
|
||||
where T : class
|
||||
{
|
||||
if (pointer == 0)
|
||||
return null;
|
||||
var wrapper = ComWrappers.GetOrCreateObjectForComInstance(pointer, CreateObjectFlags.UniqueInstance);
|
||||
// Only Release frees a proxy's native references. Its finalizer would release them
|
||||
// on the finalizer thread, in no order relative to the proxy's session.
|
||||
GC.SuppressFinalize(wrapper);
|
||||
try
|
||||
{
|
||||
return (T)wrapper;
|
||||
}
|
||||
catch
|
||||
{
|
||||
((ComObject)wrapper).FinalRelease();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases a proxy returned by this binding immediately. This is the only way a
|
||||
/// proxy's native reference is released: the garbage collector never does it.
|
||||
/// Null and repeated releases are harmless. Do not use the proxy afterwards. Release children
|
||||
/// before their owning session and release sessions before their global session.
|
||||
/// Do not race release against another call using the same proxy.
|
||||
/// </summary>
|
||||
public static void Release(object? instance)
|
||||
{
|
||||
if (instance is null)
|
||||
return;
|
||||
if (instance is not ComObject wrapper)
|
||||
throw new ArgumentException("Expected a Slang COM proxy.", nameof(instance));
|
||||
wrapper.FinalRelease();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -163,6 +217,31 @@ public static partial class Slang
|
|||
/// count. Call <see cref="Marshal.Release"/> on it when finished, or pass it to
|
||||
/// APIs that take ownership.
|
||||
/// </summary>
|
||||
public static nint GetComInstance(object comObject) =>
|
||||
ComWrappers.GetOrCreateComInterfaceForObject(comObject, CreateComInterfaceFlags.None);
|
||||
public static nint GetComInstance(object comObject)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(comObject);
|
||||
if (comObject is ComObject)
|
||||
return GetComInstance<ISlangUnknown>((ISlangUnknown)comObject);
|
||||
return System.Runtime.InteropServices.ComWrappers.TryGetComInstance(comObject, out var native)
|
||||
? native
|
||||
: ComWrappers.GetOrCreateComInterfaceForObject(comObject, CreateComInterfaceFlags.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an owned pointer to the requested native interface, including its correct
|
||||
/// subobject address. Release the returned reference after the native call.
|
||||
/// </summary>
|
||||
public static unsafe nint GetComInstance<T>(T comObject)
|
||||
where T : class
|
||||
{
|
||||
if (comObject is ComObject wrapper)
|
||||
{
|
||||
var table = ((IUnmanagedVirtualMethodTableProvider)wrapper).GetVirtualMethodTableInfoForKey(typeof(T));
|
||||
var pointer = (nint)table.ThisPointer;
|
||||
Marshal.AddRef(pointer);
|
||||
GC.KeepAlive(wrapper);
|
||||
return pointer;
|
||||
}
|
||||
return (nint)ComInterfaceMarshaller<T>.ConvertToUnmanaged(comObject);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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);
|
||||
}
|
||||
}
|
||||
23
Brutal.Slang/SlangInterfaceMarshaller.cs
Normal file
23
Brutal.Slang/SlangInterfaceMarshaller.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
|
||||
namespace Brutal.SlangApi;
|
||||
|
||||
[CustomMarshaller(
|
||||
typeof(CustomMarshallerAttribute.GenericPlaceholder),
|
||||
MarshalMode.Default,
|
||||
typeof(SlangInterfaceMarshaller<>)
|
||||
)]
|
||||
internal static unsafe class SlangInterfaceMarshaller<T>
|
||||
where T : class
|
||||
{
|
||||
public static T? ConvertToManaged(void* unmanaged) => Slang.WrapBorrowedComInstance<T>((nint)unmanaged);
|
||||
|
||||
public static void* ConvertToUnmanaged(T? managed) =>
|
||||
managed is null ? null : (void*)Slang.GetComInstance<T>(managed);
|
||||
|
||||
public static void Free(void* unmanaged)
|
||||
{
|
||||
if (unmanaged != null)
|
||||
Marshal.Release((nint)unmanaged);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue