From 4ac91e105e816361938b4250cbcedae239749ce2 Mon Sep 17 00:00:00 2001 From: BRUTAL release Date: Fri, 23 Oct 2026 15:07:17 +1300 Subject: [PATCH] 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 Co-authored-by: sGo7-Dev Co-authored-by: Capsup --- Brutal.Core/Attributes.cs | 37 +- .../BRUTAL-FREETYPE-THIRD-PARTY-NOTICES.txt | 4 +- .../BRUTAL-GLFW-THIRD-PARTY-NOTICES.txt | 2 +- .../BRUTAL-GLI-THIRD-PARTY-NOTICES.txt | 2 +- .../GltfApi/GeneratedSchema/Accessor.gen.cs | 2 +- .../AnimationChannelTarget.gen.cs | 2 +- .../GeneratedSchema/AnimationSampler.gen.cs | 2 +- .../GltfApi/GeneratedSchema/Camera.gen.cs | 2 +- .../GeneratedSchema/GltfJsonContext.gen.cs | 46 +++ .../GltfApi/GeneratedSchema/Material.gen.cs | 2 +- Brutal.Gltf/GltfApi/GltfJsonContext.cs | 27 ++ Brutal.Gltf/GltfApi/GltfUtility.cs | 38 +- Brutal.Gltf/GltfApi/IExtensionGltfObject.cs | 28 +- .../BRUTAL-GLTF-THIRD-PARTY-NOTICES.txt | 2 +- .../BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt | 180 +++++++++ .../BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt | 180 +++++++++ .../PlatformBackends/GlfwBackend.cs | 3 + .../BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt | 180 +++++++++ .../BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt | 180 +++++++++ .../BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt | 33 +- .../BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt | 180 +++++++++ ...RUTAL-LOCALIZATION-THIRD-PARTY-NOTICES.txt | 2 +- ...UTAL-MESHOPTIMIZER-THIRD-PARTY-NOTICES.txt | 2 +- .../BRUTAL-NOTCURSES-THIRD-PARTY-NOTICES.txt | 4 +- .../BRUTAL-OPENAL-THIRD-PARTY-NOTICES.txt | 2 +- .../BRUTAL-OPENGL-THIRD-PARTY-NOTICES.txt | 2 +- .../BRUTAL-RAKNET-THIRD-PARTY-NOTICES.txt | 2 +- .../BRUTAL-SDL-IMAGE-THIRD-PARTY-NOTICES.txt | 4 +- .../BRUTAL-SDL-MIXER-THIRD-PARTY-NOTICES.txt | 4 +- .../BRUTAL-SDL-TTF-THIRD-PARTY-NOTICES.txt | 6 +- .../BRUTAL-SDL-THIRD-PARTY-NOTICES.txt | 2 +- .../BRUTAL-SHADERC-THIRD-PARTY-NOTICES.txt | 2 +- Brutal.Slang/AssemblyInfo.cs | 3 + .../BorrowedSlangInterfaceMarshaller.cs | 18 + Brutal.Slang/EntryPointLayoutExtensions.cs | 20 + Brutal.Slang/Generated/GlobalUsings.gen.cs | 2 +- Brutal.Slang/Generated/Interfaces.gen.cs | 355 ++++++++++++------ Brutal.Slang/Generated/InterfacesExt.gen.cs | 39 +- Brutal.Slang/Generated/Slang.gen.cs | 93 ++--- Brutal.Slang/Generated/Structs.gen.cs | 45 +-- Brutal.Slang/ICompileRequestExtensions.cs | 14 +- Brutal.Slang/ISessionExtensions.cs | 18 + Brutal.Slang/ISlangBlobExtensions.cs | 6 +- Brutal.Slang/ScalarMarshallers.cs | 34 ++ Brutal.Slang/Slang.cs | 111 +++++- Brutal.Slang/SlangComWrappers.cs | 40 ++ Brutal.Slang/SlangInterfaceMarshaller.cs | 23 ++ ...ULKAN-ABSTRACTIONS-THIRD-PARTY-NOTICES.txt | 2 +- .../BRUTAL-VULKAN-VMA-THIRD-PARTY-NOTICES.txt | 2 +- Brutal.Vulkan/Generated/Constants/VK.gen.cs | 151 ++++++++ Brutal.Vulkan/Generated/Macros/Vulkan.gen.cs | 157 ++++++++ Brutal.Vulkan/ImportResolver.cs | 47 ++- .../BRUTAL-VULKAN-THIRD-PARTY-NOTICES.txt | 2 +- Brutal.Vulkan/Manual/Constants/VK.cs | 10 - .../BRUTAL-ZLIB-THIRD-PARTY-NOTICES.txt | 2 +- 55 files changed, 2037 insertions(+), 321 deletions(-) create mode 100644 Brutal.Gltf/GltfApi/GeneratedSchema/GltfJsonContext.gen.cs create mode 100644 Brutal.Gltf/GltfApi/GltfJsonContext.cs create mode 100644 Brutal.ImGui.Abstractions/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt create mode 100644 Brutal.ImGui.Backends/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt create mode 100644 Brutal.ImGui.Extensions/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt create mode 100644 Brutal.ImGui.FreeType/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt create mode 100644 Brutal.ImPlot/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt create mode 100644 Brutal.Slang/AssemblyInfo.cs create mode 100644 Brutal.Slang/BorrowedSlangInterfaceMarshaller.cs create mode 100644 Brutal.Slang/EntryPointLayoutExtensions.cs create mode 100644 Brutal.Slang/ScalarMarshallers.cs create mode 100644 Brutal.Slang/SlangComWrappers.cs create mode 100644 Brutal.Slang/SlangInterfaceMarshaller.cs create mode 100644 Brutal.Vulkan/Generated/Macros/Vulkan.gen.cs diff --git a/Brutal.Core/Attributes.cs b/Brutal.Core/Attributes.cs index 672dcd6..2276f0a 100644 --- a/Brutal.Core/Attributes.cs +++ b/Brutal.Core/Attributes.cs @@ -1,6 +1,41 @@ namespace Brutal.Attributes; +/// +/// Indicates that an entity only exposes memory that has a fixed address. Marking an entity [Fixed] allows the analyser +/// to check that the entity is only used in contexts where the memory is guaranteed to be fixed, such as when it is +/// returned from a method or passed as a parameter. +/// The attribute can be applied to return values, parameters, fields, properties, interfaces, classes, and structs. +/// [AttributeUsage( - AttributeTargets.ReturnValue | AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property + AttributeTargets.ReturnValue + | AttributeTargets.Parameter + | AttributeTargets.Field + | AttributeTargets.Property + | AttributeTargets.Interface + | AttributeTargets.Class + | AttributeTargets.Struct )] public sealed class FixedAttribute : Attribute { } + +/// +/// Acts like the [Fixed] attribute but only if the referenced type is itself fixed. Pass the nameof a type +/// parameter of the containing method or type to resolve its type argument, or the typeof a concrete type or +/// interface. +/// +[AttributeUsage(AttributeTargets.ReturnValue | AttributeTargets.Property | AttributeTargets.Parameter)] +public sealed class FixedWhenAttribute : Attribute +{ + public FixedWhenAttribute(string typeName) + { + TypeName = typeName; + } + + public FixedWhenAttribute(Type type) + { + Type = type; + } + + public string? TypeName { get; } + + public Type? Type { get; } +} diff --git a/Brutal.FreeType/LICENSES/BRUTAL-FREETYPE-THIRD-PARTY-NOTICES.txt b/Brutal.FreeType/LICENSES/BRUTAL-FREETYPE-THIRD-PARTY-NOTICES.txt index dd5a06f..0545a49 100644 --- a/Brutal.FreeType/LICENSES/BRUTAL-FREETYPE-THIRD-PARTY-NOTICES.txt +++ b/Brutal.FreeType/LICENSES/BRUTAL-FREETYPE-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.FreeType +Ahwoo.BRUTAL.FreeType This package redistributes the third-party components listed below, each reproduced with the license that governs it. @@ -17,7 +17,7 @@ with the license that governs it. License for the library, and a separate X11-style license for each of the contributed BDF and PCF drivers, which are compiled into the shipped binaries. - zlib is not contained in this package. It is supplied by RocketWerkz.Brutal.ZLib, + zlib is not contained in this package. It is supplied by Ahwoo.BRUTAL.ZLib, on which this package depends, and is covered by that package's own notices. FreeType's own LICENSE.TXT distributes it "under two mutually exclusive open-source diff --git a/Brutal.Glfw/LICENSES/BRUTAL-GLFW-THIRD-PARTY-NOTICES.txt b/Brutal.Glfw/LICENSES/BRUTAL-GLFW-THIRD-PARTY-NOTICES.txt index f7bab84..83be9da 100644 --- a/Brutal.Glfw/LICENSES/BRUTAL-GLFW-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Glfw/LICENSES/BRUTAL-GLFW-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Glfw +Ahwoo.BRUTAL.Glfw Brutal.Glfw redistributes the third-party components named below, as native libraries. Each is reproduced with the license that governs it. diff --git a/Brutal.Gli/LICENSES/BRUTAL-GLI-THIRD-PARTY-NOTICES.txt b/Brutal.Gli/LICENSES/BRUTAL-GLI-THIRD-PARTY-NOTICES.txt index ae690f0..ea0e5b9 100644 --- a/Brutal.Gli/LICENSES/BRUTAL-GLI-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Gli/LICENSES/BRUTAL-GLI-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Gli +Ahwoo.BRUTAL.Gli Brutal.Gli redistributes the third-party components named below, as native libraries. Each is reproduced with the license that governs it. diff --git a/Brutal.Gltf/GltfApi/GeneratedSchema/Accessor.gen.cs b/Brutal.Gltf/GltfApi/GeneratedSchema/Accessor.gen.cs index 8ffaa4b..edaed97 100644 --- a/Brutal.Gltf/GltfApi/GeneratedSchema/Accessor.gen.cs +++ b/Brutal.Gltf/GltfApi/GeneratedSchema/Accessor.gen.cs @@ -158,7 +158,7 @@ namespace Brutal.GltfApi { /// /// Specifies if the accessor's elements are scalars, vectors, or matrices. /// - [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] [System.Text.Json.Serialization.JsonRequiredAttribute()] [System.Text.Json.Serialization.JsonPropertyNameAttribute("type")] public TypeEnum Type { diff --git a/Brutal.Gltf/GltfApi/GeneratedSchema/AnimationChannelTarget.gen.cs b/Brutal.Gltf/GltfApi/GeneratedSchema/AnimationChannelTarget.gen.cs index b1b3e14..92ef86b 100644 --- a/Brutal.Gltf/GltfApi/GeneratedSchema/AnimationChannelTarget.gen.cs +++ b/Brutal.Gltf/GltfApi/GeneratedSchema/AnimationChannelTarget.gen.cs @@ -58,7 +58,7 @@ namespace Brutal.GltfApi { /// /// The name of the node's TRS property to animate, or the `"weights"` of the Morph Targets it instantiates. For the `"translation"` property, the values that are provided by the sampler are the translation along the X, Y, and Z axes. For the `"rotation"` property, the values are a quaternion in the order (x, y, z, w), where w is the scalar. For the `"scale"` property, the values are the scaling factors along the X, Y, and Z axes. /// - [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] [System.Text.Json.Serialization.JsonRequiredAttribute()] [System.Text.Json.Serialization.JsonPropertyNameAttribute("path")] public PathEnum Path { diff --git a/Brutal.Gltf/GltfApi/GeneratedSchema/AnimationSampler.gen.cs b/Brutal.Gltf/GltfApi/GeneratedSchema/AnimationSampler.gen.cs index d19cefe..d248640 100644 --- a/Brutal.Gltf/GltfApi/GeneratedSchema/AnimationSampler.gen.cs +++ b/Brutal.Gltf/GltfApi/GeneratedSchema/AnimationSampler.gen.cs @@ -64,7 +64,7 @@ namespace Brutal.GltfApi { /// /// Interpolation algorithm. /// - [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] [System.Text.Json.Serialization.JsonPropertyNameAttribute("interpolation")] public InterpolationEnum Interpolation { get { diff --git a/Brutal.Gltf/GltfApi/GeneratedSchema/Camera.gen.cs b/Brutal.Gltf/GltfApi/GeneratedSchema/Camera.gen.cs index 487635d..3a53e0d 100644 --- a/Brutal.Gltf/GltfApi/GeneratedSchema/Camera.gen.cs +++ b/Brutal.Gltf/GltfApi/GeneratedSchema/Camera.gen.cs @@ -78,7 +78,7 @@ namespace Brutal.GltfApi { /// /// Specifies if the camera uses a perspective or orthographic projection. /// - [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] [System.Text.Json.Serialization.JsonRequiredAttribute()] [System.Text.Json.Serialization.JsonPropertyNameAttribute("type")] public TypeEnum Type { diff --git a/Brutal.Gltf/GltfApi/GeneratedSchema/GltfJsonContext.gen.cs b/Brutal.Gltf/GltfApi/GeneratedSchema/GltfJsonContext.gen.cs new file mode 100644 index 0000000..9f16494 --- /dev/null +++ b/Brutal.Gltf/GltfApi/GeneratedSchema/GltfJsonContext.gen.cs @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Brutal.GltfApi { + + + /// + /// Source-generated JSON metadata for the generated glTF schema types. + /// + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(System.Text.Json.JsonElement))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(DracoMeshCompressionGltfMeshPrimitiveExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(Gltf))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(LightsPunctualGltfDocumentExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MaterialsAnisotropyGltfMaterialExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MaterialsClearcoatGltfMaterialExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MaterialsEmissiveStrengthGltfMaterialExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MaterialsIridescenceGltfMaterialExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MaterialsSheenGltfMaterialExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MaterialsSpecularGltfMaterialExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MaterialsTransmissionGltfMaterialExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MaterialsUnlitGltfMaterialExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MaterialsVolumeGltfMaterialExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(TextureBasisuGltfTextureExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(TextureTransformGltfTextureinfoExtension))] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(Accessor.ComponentTypeEnum), TypeInfoPropertyName="AccessorComponentTypeEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(Accessor.TypeEnum), TypeInfoPropertyName="AccessorTypeEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(AccessorSparseIndices.ComponentTypeEnum), TypeInfoPropertyName="AccessorSparseIndicesComponentTypeEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(AnimationChannelTarget.PathEnum), TypeInfoPropertyName="AnimationChannelTargetPathEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(AnimationSampler.InterpolationEnum), TypeInfoPropertyName="AnimationSamplerInterpolationEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(BufferView.TargetEnum), TypeInfoPropertyName="BufferViewTargetEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(Camera.TypeEnum), TypeInfoPropertyName="CameraTypeEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(Material.AlphaModeEnum), TypeInfoPropertyName="MaterialAlphaModeEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(MeshPrimitive.ModeEnum), TypeInfoPropertyName="MeshPrimitiveModeEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(Sampler.MagFilterEnum), TypeInfoPropertyName="SamplerMagFilterEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(Sampler.MinFilterEnum), TypeInfoPropertyName="SamplerMinFilterEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(Sampler.WrapSEnum), TypeInfoPropertyName="SamplerWrapSEnum")] + [System.Text.Json.Serialization.JsonSerializableAttribute(typeof(Sampler.WrapTEnum), TypeInfoPropertyName="SamplerWrapTEnum")] + internal partial class GltfJsonContext { + } +} diff --git a/Brutal.Gltf/GltfApi/GeneratedSchema/Material.gen.cs b/Brutal.Gltf/GltfApi/GeneratedSchema/Material.gen.cs index 57b0c6d..afae9d0 100644 --- a/Brutal.Gltf/GltfApi/GeneratedSchema/Material.gen.cs +++ b/Brutal.Gltf/GltfApi/GeneratedSchema/Material.gen.cs @@ -181,7 +181,7 @@ namespace Brutal.GltfApi { /// /// The alpha rendering mode of the material. /// - [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + [System.Text.Json.Serialization.JsonConverterAttribute(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] [System.Text.Json.Serialization.JsonPropertyNameAttribute("alphaMode")] public AlphaModeEnum AlphaMode { get { diff --git a/Brutal.Gltf/GltfApi/GltfJsonContext.cs b/Brutal.Gltf/GltfApi/GltfJsonContext.cs new file mode 100644 index 0000000..7f89361 --- /dev/null +++ b/Brutal.Gltf/GltfApi/GltfJsonContext.cs @@ -0,0 +1,27 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Brutal.GltfApi; + +/// +/// Source-generated System.Text.Json metadata for the glTF schema, so that loading and saving +/// works without reflection (trimming and Native AOT). +/// +/// +/// The generator emits the other half of this class (GeneratedSchema/GltfJsonContext.gen.cs) with every +/// : the document root, every extension root type, the nested enums and +/// . Don't add here; the System.Text.Json source +/// generator fails when more than one partial declaration carries it. +/// +[JsonSourceGenerationOptions( + // glTF has no concept of an explicit JSON null; absent optional properties must be + // omitted entirely or strict validators reject the asset (e.g. "uri": null in GLB). + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + Converters = [ + typeof(JsonHelpers.Float3JsonConverter), + typeof(JsonHelpers.Float4JsonConverter), + typeof(JsonHelpers.FloatQuatJsonConverter), + typeof(JsonHelpers.Float4X4JsonConverter), + ] +)] +internal partial class GltfJsonContext : JsonSerializerContext; diff --git a/Brutal.Gltf/GltfApi/GltfUtility.cs b/Brutal.Gltf/GltfApi/GltfUtility.cs index cc08e93..979fc22 100644 --- a/Brutal.Gltf/GltfApi/GltfUtility.cs +++ b/Brutal.Gltf/GltfApi/GltfUtility.cs @@ -1,5 +1,7 @@ +using System.Diagnostics.CodeAnalysis; using System.Text; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; namespace Brutal.GltfApi; @@ -149,21 +151,37 @@ public static class GltfUtility } } + [UnconditionalSuppressMessage( + "Trimming", + "IL2026", + Justification = "Reflection is only used when JsonSerializer.IsReflectionEnabledByDefault, which is false under trimming and Native AOT." + )] + [UnconditionalSuppressMessage( + "AOT", + "IL3050", + Justification = "Reflection is only used when JsonSerializer.IsReflectionEnabledByDefault, which is false under trimming and Native AOT." + )] private static JsonSerializerOptions CreateSerializerOptions() { - var options = new JsonSerializerOptions(); - // glTF has no concept of an explicit JSON null; absent optional properties must be - // omitted entirely or strict validators reject the asset (e.g. "uri": null in GLB). - options.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull; - options.Converters.Add(new JsonHelpers.Float3JsonConverter()); - options.Converters.Add(new JsonHelpers.Float4JsonConverter()); - options.Converters.Add(new JsonHelpers.FloatQuatJsonConverter()); - options.Converters.Add(new JsonHelpers.Float4X4JsonConverter()); + // Settings, converters and metadata come from the source-generated GltfJsonContext, which is all + // that is available under trimming and Native AOT. When reflection is enabled, fall back to it for + // types the context doesn't know, such as custom extension classes passed to GetExtension or + // assigned to an Extensions map. + var options = new JsonSerializerOptions(GltfJsonContext.Default.Options); + if (JsonSerializer.IsReflectionEnabledByDefault) + { + options.TypeInfoResolver = JsonTypeInfoResolver.Combine( + GltfJsonContext.Default, + new DefaultJsonTypeInfoResolver() + ); + } return options; } internal static readonly JsonSerializerOptions JsonOptions = CreateSerializerOptions(); + private static readonly JsonTypeInfo GltfTypeInfo = (JsonTypeInfo)JsonOptions.GetTypeInfo(typeof(Gltf)); + /// /// Parses a JSON formatted text content /// @@ -171,7 +189,7 @@ public static class GltfUtility /// Schema.Gltf model public static Gltf DeserializeModelJson(string fileData) { - return JsonSerializer.Deserialize(fileData, JsonOptions) ?? throw new NullReferenceException(); + return JsonSerializer.Deserialize(fileData, GltfTypeInfo) ?? throw new NullReferenceException(); } /// @@ -181,7 +199,7 @@ public static class GltfUtility /// JSON formatted text public static string SerializeModelJson(this Gltf model) { - return JsonSerializer.Serialize(model, JsonOptions); + return JsonSerializer.Serialize(model, GltfTypeInfo); } private static byte[]? TryLoadBase64BinaryBufferUnchecked(Buffer buffer, string prefix) diff --git a/Brutal.Gltf/GltfApi/IExtensionGltfObject.cs b/Brutal.Gltf/GltfApi/IExtensionGltfObject.cs index 0255f56..24d5efb 100644 --- a/Brutal.Gltf/GltfApi/IExtensionGltfObject.cs +++ b/Brutal.Gltf/GltfApi/IExtensionGltfObject.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using System.Text.Json.Serialization.Metadata; namespace Brutal.GltfApi; @@ -9,8 +10,31 @@ public interface IExtensionGltfObject public static class GltfExtensions { + /// + /// Gets an extension object by name. + /// + /// + /// Under trimming or Native AOT, must be one of the extension types this library + /// defines; for your own extension types use the overload that takes a . + /// public static T? GetExtension(this IExtensionGltfObject obj, string extensionName) where T : class + { + return GetExtensionCore(obj, extensionName, jsonTypeInfo: null); + } + + /// + /// Gets an extension object by name, reading it with the given source-generated metadata. + /// + public static T? GetExtension(this IExtensionGltfObject obj, string extensionName, JsonTypeInfo jsonTypeInfo) + where T : class + { + ArgumentNullException.ThrowIfNull(jsonTypeInfo); + return GetExtensionCore(obj, extensionName, jsonTypeInfo); + } + + private static T? GetExtensionCore(IExtensionGltfObject obj, string extensionName, JsonTypeInfo? jsonTypeInfo) + where T : class { var extensionMap = obj.Extensions; if (extensionMap == null || !extensionMap.TryGetValue(extensionName, out var extObj)) @@ -19,8 +43,10 @@ public static class GltfExtensions // from deserialization hold the raw JsonElement. if (extObj is T typed) return typed; + // Metadata is resolved only here: for an unregistered T it throws under Native AOT, and in JIT builds + // for types System.Text.Json can't describe, which must not break lookups that never deserialize. if (extObj is JsonElement je) - return je.Deserialize(GltfUtility.JsonOptions); + return je.Deserialize(jsonTypeInfo ?? (JsonTypeInfo)GltfUtility.JsonOptions.GetTypeInfo(typeof(T))); throw new InvalidCastException( $"Extension '{extensionName}' holds a {extObj.GetType()}, expected {typeof(T)} or JsonElement" ); diff --git a/Brutal.Gltf/LICENSES/BRUTAL-GLTF-THIRD-PARTY-NOTICES.txt b/Brutal.Gltf/LICENSES/BRUTAL-GLTF-THIRD-PARTY-NOTICES.txt index cfe2353..f39b221 100644 --- a/Brutal.Gltf/LICENSES/BRUTAL-GLTF-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Gltf/LICENSES/BRUTAL-GLTF-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Gltf +Ahwoo.BRUTAL.Gltf This package contains no third-party library. Its glTF type definitions are generated from The Khronos Group's glTF 2.0 JSON schemas, and the descriptive text of those diff --git a/Brutal.ImGui.Abstractions/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt b/Brutal.ImGui.Abstractions/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt new file mode 100644 index 0000000..3ac9b12 --- /dev/null +++ b/Brutal.ImGui.Abstractions/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt @@ -0,0 +1,180 @@ +THIRD-PARTY LICENSE NOTICES +The Brutal.ImGui packages + +This file ships in all eleven packages named below. They redistribute the third-party +components listed here, each reproduced with the license that governs it. + + One file serves all eleven packages, so this table says which components apply to + the package you are holding: + + Ahwoo.BRUTAL.ImGui Dear ImGui, and the three stb libraries + compiled into it + Ahwoo.BRUTAL.ImGui.Backends Dear ImGui's platform and renderer + backends, translated to C# + Ahwoo.BRUTAL.ImGui.DemoWindow Dear ImGui's demo sources, translated + to C# + Ahwoo.BRUTAL.ImGui.FreeType Dear ImGui's FreeType font adapter + Ahwoo.BRUTAL.ImPlot ImPlot + Ahwoo.BRUTAL.ImPlot.DemoWindow ImPlot's demo sources, translated to C# + Ahwoo.BRUTAL.ImGui.Native Dear ImGui's native library, and the three + stb libraries compiled into it + Ahwoo.BRUTAL.ImGui.FreeType.Native Dear ImGui's FreeType font adapter, as a + native library + Ahwoo.BRUTAL.ImPlot.Native ImPlot's native library + Ahwoo.BRUTAL.ImGui.Abstractions no third-party code + Ahwoo.BRUTAL.ImGui.Extensions no third-party code + + The native libraries ship only in the three .Native packages, each for every + runtime identifier it supports (win-x64, linux-x64, osx-arm64): + + Dear ImGui 1.92.2 imgui.dll / libimgui.so / libimgui.dylib + imgui_freetype.dll / libimgui_freetype.so / libimgui_freetype.dylib + ImPlot 0.17 implot.dll / libimplot.so / libimplot.dylib + + Dear ImGui vendors three of Sean Barrett's stb libraries, and all three are + compiled into the Dear ImGui binaries shipped here. They have their own section + below. + + The managed assemblies are in scope as well as the native libraries. Type names, + enumerant values and entry-point signatures are generated from the corresponding + upstream headers, and the backend and demo assemblies are C# translations of + upstream sources. + + Ahwoo.BRUTAL.ImGui.FreeType binds Dear ImGui's FreeType font adapter, which + is Dear ImGui code and is covered by the Dear ImGui section below. FreeType itself + is in none of these eleven packages; it is supplied by Ahwoo.BRUTAL.FreeType, + whose own notices reproduce the FreeType License in full. + + +============================================================================== +Dear ImGui +============================================================================== + + Name Dear ImGui + Version 1.92.2, docking branch + Upstream https://github.com/ocornut/imgui + SPDX MIT + + Built from a RocketWerkz fork of the docking branch. The modifications are ours + and do not alter the terms below, which are reproduced from the copy these + packages were built from. + + This component covers the imgui and imgui_freetype native libraries, the managed + bindings generated from Dear ImGui's headers, and the C# translations of Dear + ImGui's backend and demo sources. + +The MIT License (MIT) + +Copyright (c) 2014-2025 Omar Cornut + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +============================================================================== +stb +============================================================================== + + Name stb_rect_pack, stb_textedit, stb_truetype + Version 1.01, 1.14, 1.26 respectively + Upstream https://github.com/nothings/stb + SPDX MIT OR Unlicense + + Vendored by Dear ImGui as imstb_rectpack.h, imstb_textedit.h and + imstb_truetype.h, and compiled into the Dear ImGui native libraries shipped + here. All three carry the same dual license, which offers a choice between + the MIT License and release into the public domain. It is reproduced once + below, from the copy these packages were built from. + +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ + + +============================================================================== +ImPlot +============================================================================== + + Name ImPlot + Version 0.17, upstream commit 3da8bd3 (26 commits after tag v0.16) + Upstream https://github.com/epezent/implot + SPDX MIT + + ImPlot is a plotting extension for Dear ImGui. Its version is the one ImPlot + reports for itself; the commit is given because upstream had not tagged 0.17 when + these packages were built. + + This component covers the implot native library, the managed bindings generated + from ImPlot's headers, and the C# translation of ImPlot's demo sources. + +MIT License + +Copyright (c) 2020 Evan Pezent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Brutal.ImGui.Backends/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt b/Brutal.ImGui.Backends/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt new file mode 100644 index 0000000..3ac9b12 --- /dev/null +++ b/Brutal.ImGui.Backends/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt @@ -0,0 +1,180 @@ +THIRD-PARTY LICENSE NOTICES +The Brutal.ImGui packages + +This file ships in all eleven packages named below. They redistribute the third-party +components listed here, each reproduced with the license that governs it. + + One file serves all eleven packages, so this table says which components apply to + the package you are holding: + + Ahwoo.BRUTAL.ImGui Dear ImGui, and the three stb libraries + compiled into it + Ahwoo.BRUTAL.ImGui.Backends Dear ImGui's platform and renderer + backends, translated to C# + Ahwoo.BRUTAL.ImGui.DemoWindow Dear ImGui's demo sources, translated + to C# + Ahwoo.BRUTAL.ImGui.FreeType Dear ImGui's FreeType font adapter + Ahwoo.BRUTAL.ImPlot ImPlot + Ahwoo.BRUTAL.ImPlot.DemoWindow ImPlot's demo sources, translated to C# + Ahwoo.BRUTAL.ImGui.Native Dear ImGui's native library, and the three + stb libraries compiled into it + Ahwoo.BRUTAL.ImGui.FreeType.Native Dear ImGui's FreeType font adapter, as a + native library + Ahwoo.BRUTAL.ImPlot.Native ImPlot's native library + Ahwoo.BRUTAL.ImGui.Abstractions no third-party code + Ahwoo.BRUTAL.ImGui.Extensions no third-party code + + The native libraries ship only in the three .Native packages, each for every + runtime identifier it supports (win-x64, linux-x64, osx-arm64): + + Dear ImGui 1.92.2 imgui.dll / libimgui.so / libimgui.dylib + imgui_freetype.dll / libimgui_freetype.so / libimgui_freetype.dylib + ImPlot 0.17 implot.dll / libimplot.so / libimplot.dylib + + Dear ImGui vendors three of Sean Barrett's stb libraries, and all three are + compiled into the Dear ImGui binaries shipped here. They have their own section + below. + + The managed assemblies are in scope as well as the native libraries. Type names, + enumerant values and entry-point signatures are generated from the corresponding + upstream headers, and the backend and demo assemblies are C# translations of + upstream sources. + + Ahwoo.BRUTAL.ImGui.FreeType binds Dear ImGui's FreeType font adapter, which + is Dear ImGui code and is covered by the Dear ImGui section below. FreeType itself + is in none of these eleven packages; it is supplied by Ahwoo.BRUTAL.FreeType, + whose own notices reproduce the FreeType License in full. + + +============================================================================== +Dear ImGui +============================================================================== + + Name Dear ImGui + Version 1.92.2, docking branch + Upstream https://github.com/ocornut/imgui + SPDX MIT + + Built from a RocketWerkz fork of the docking branch. The modifications are ours + and do not alter the terms below, which are reproduced from the copy these + packages were built from. + + This component covers the imgui and imgui_freetype native libraries, the managed + bindings generated from Dear ImGui's headers, and the C# translations of Dear + ImGui's backend and demo sources. + +The MIT License (MIT) + +Copyright (c) 2014-2025 Omar Cornut + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +============================================================================== +stb +============================================================================== + + Name stb_rect_pack, stb_textedit, stb_truetype + Version 1.01, 1.14, 1.26 respectively + Upstream https://github.com/nothings/stb + SPDX MIT OR Unlicense + + Vendored by Dear ImGui as imstb_rectpack.h, imstb_textedit.h and + imstb_truetype.h, and compiled into the Dear ImGui native libraries shipped + here. All three carry the same dual license, which offers a choice between + the MIT License and release into the public domain. It is reproduced once + below, from the copy these packages were built from. + +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ + + +============================================================================== +ImPlot +============================================================================== + + Name ImPlot + Version 0.17, upstream commit 3da8bd3 (26 commits after tag v0.16) + Upstream https://github.com/epezent/implot + SPDX MIT + + ImPlot is a plotting extension for Dear ImGui. Its version is the one ImPlot + reports for itself; the commit is given because upstream had not tagged 0.17 when + these packages were built. + + This component covers the implot native library, the managed bindings generated + from ImPlot's headers, and the C# translation of ImPlot's demo sources. + +MIT License + +Copyright (c) 2020 Evan Pezent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Brutal.ImGui.Backends/PlatformBackends/GlfwBackend.cs b/Brutal.ImGui.Backends/PlatformBackends/GlfwBackend.cs index e5e3032..ad0cfb2 100644 --- a/Brutal.ImGui.Backends/PlatformBackends/GlfwBackend.cs +++ b/Brutal.ImGui.Backends/PlatformBackends/GlfwBackend.cs @@ -277,6 +277,9 @@ public partial class GlfwBackend : IPlatformBackend private unsafe byte* GetClipboardText(ImGuiContextPtr context) { var str = Glfw.Clipboard; + if (str is null) + return null; + var byteCount = Utf8.GetByteCount(str); _cachedClipboardText.Count = byteCount + 1; Utf8.FromUtf16(str, _cachedClipboardText.AsSpan(), out _, out _); diff --git a/Brutal.ImGui.Extensions/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt b/Brutal.ImGui.Extensions/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt new file mode 100644 index 0000000..3ac9b12 --- /dev/null +++ b/Brutal.ImGui.Extensions/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt @@ -0,0 +1,180 @@ +THIRD-PARTY LICENSE NOTICES +The Brutal.ImGui packages + +This file ships in all eleven packages named below. They redistribute the third-party +components listed here, each reproduced with the license that governs it. + + One file serves all eleven packages, so this table says which components apply to + the package you are holding: + + Ahwoo.BRUTAL.ImGui Dear ImGui, and the three stb libraries + compiled into it + Ahwoo.BRUTAL.ImGui.Backends Dear ImGui's platform and renderer + backends, translated to C# + Ahwoo.BRUTAL.ImGui.DemoWindow Dear ImGui's demo sources, translated + to C# + Ahwoo.BRUTAL.ImGui.FreeType Dear ImGui's FreeType font adapter + Ahwoo.BRUTAL.ImPlot ImPlot + Ahwoo.BRUTAL.ImPlot.DemoWindow ImPlot's demo sources, translated to C# + Ahwoo.BRUTAL.ImGui.Native Dear ImGui's native library, and the three + stb libraries compiled into it + Ahwoo.BRUTAL.ImGui.FreeType.Native Dear ImGui's FreeType font adapter, as a + native library + Ahwoo.BRUTAL.ImPlot.Native ImPlot's native library + Ahwoo.BRUTAL.ImGui.Abstractions no third-party code + Ahwoo.BRUTAL.ImGui.Extensions no third-party code + + The native libraries ship only in the three .Native packages, each for every + runtime identifier it supports (win-x64, linux-x64, osx-arm64): + + Dear ImGui 1.92.2 imgui.dll / libimgui.so / libimgui.dylib + imgui_freetype.dll / libimgui_freetype.so / libimgui_freetype.dylib + ImPlot 0.17 implot.dll / libimplot.so / libimplot.dylib + + Dear ImGui vendors three of Sean Barrett's stb libraries, and all three are + compiled into the Dear ImGui binaries shipped here. They have their own section + below. + + The managed assemblies are in scope as well as the native libraries. Type names, + enumerant values and entry-point signatures are generated from the corresponding + upstream headers, and the backend and demo assemblies are C# translations of + upstream sources. + + Ahwoo.BRUTAL.ImGui.FreeType binds Dear ImGui's FreeType font adapter, which + is Dear ImGui code and is covered by the Dear ImGui section below. FreeType itself + is in none of these eleven packages; it is supplied by Ahwoo.BRUTAL.FreeType, + whose own notices reproduce the FreeType License in full. + + +============================================================================== +Dear ImGui +============================================================================== + + Name Dear ImGui + Version 1.92.2, docking branch + Upstream https://github.com/ocornut/imgui + SPDX MIT + + Built from a RocketWerkz fork of the docking branch. The modifications are ours + and do not alter the terms below, which are reproduced from the copy these + packages were built from. + + This component covers the imgui and imgui_freetype native libraries, the managed + bindings generated from Dear ImGui's headers, and the C# translations of Dear + ImGui's backend and demo sources. + +The MIT License (MIT) + +Copyright (c) 2014-2025 Omar Cornut + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +============================================================================== +stb +============================================================================== + + Name stb_rect_pack, stb_textedit, stb_truetype + Version 1.01, 1.14, 1.26 respectively + Upstream https://github.com/nothings/stb + SPDX MIT OR Unlicense + + Vendored by Dear ImGui as imstb_rectpack.h, imstb_textedit.h and + imstb_truetype.h, and compiled into the Dear ImGui native libraries shipped + here. All three carry the same dual license, which offers a choice between + the MIT License and release into the public domain. It is reproduced once + below, from the copy these packages were built from. + +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ + + +============================================================================== +ImPlot +============================================================================== + + Name ImPlot + Version 0.17, upstream commit 3da8bd3 (26 commits after tag v0.16) + Upstream https://github.com/epezent/implot + SPDX MIT + + ImPlot is a plotting extension for Dear ImGui. Its version is the one ImPlot + reports for itself; the commit is given because upstream had not tagged 0.17 when + these packages were built. + + This component covers the implot native library, the managed bindings generated + from ImPlot's headers, and the C# translation of ImPlot's demo sources. + +MIT License + +Copyright (c) 2020 Evan Pezent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Brutal.ImGui.FreeType/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt b/Brutal.ImGui.FreeType/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt new file mode 100644 index 0000000..3ac9b12 --- /dev/null +++ b/Brutal.ImGui.FreeType/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt @@ -0,0 +1,180 @@ +THIRD-PARTY LICENSE NOTICES +The Brutal.ImGui packages + +This file ships in all eleven packages named below. They redistribute the third-party +components listed here, each reproduced with the license that governs it. + + One file serves all eleven packages, so this table says which components apply to + the package you are holding: + + Ahwoo.BRUTAL.ImGui Dear ImGui, and the three stb libraries + compiled into it + Ahwoo.BRUTAL.ImGui.Backends Dear ImGui's platform and renderer + backends, translated to C# + Ahwoo.BRUTAL.ImGui.DemoWindow Dear ImGui's demo sources, translated + to C# + Ahwoo.BRUTAL.ImGui.FreeType Dear ImGui's FreeType font adapter + Ahwoo.BRUTAL.ImPlot ImPlot + Ahwoo.BRUTAL.ImPlot.DemoWindow ImPlot's demo sources, translated to C# + Ahwoo.BRUTAL.ImGui.Native Dear ImGui's native library, and the three + stb libraries compiled into it + Ahwoo.BRUTAL.ImGui.FreeType.Native Dear ImGui's FreeType font adapter, as a + native library + Ahwoo.BRUTAL.ImPlot.Native ImPlot's native library + Ahwoo.BRUTAL.ImGui.Abstractions no third-party code + Ahwoo.BRUTAL.ImGui.Extensions no third-party code + + The native libraries ship only in the three .Native packages, each for every + runtime identifier it supports (win-x64, linux-x64, osx-arm64): + + Dear ImGui 1.92.2 imgui.dll / libimgui.so / libimgui.dylib + imgui_freetype.dll / libimgui_freetype.so / libimgui_freetype.dylib + ImPlot 0.17 implot.dll / libimplot.so / libimplot.dylib + + Dear ImGui vendors three of Sean Barrett's stb libraries, and all three are + compiled into the Dear ImGui binaries shipped here. They have their own section + below. + + The managed assemblies are in scope as well as the native libraries. Type names, + enumerant values and entry-point signatures are generated from the corresponding + upstream headers, and the backend and demo assemblies are C# translations of + upstream sources. + + Ahwoo.BRUTAL.ImGui.FreeType binds Dear ImGui's FreeType font adapter, which + is Dear ImGui code and is covered by the Dear ImGui section below. FreeType itself + is in none of these eleven packages; it is supplied by Ahwoo.BRUTAL.FreeType, + whose own notices reproduce the FreeType License in full. + + +============================================================================== +Dear ImGui +============================================================================== + + Name Dear ImGui + Version 1.92.2, docking branch + Upstream https://github.com/ocornut/imgui + SPDX MIT + + Built from a RocketWerkz fork of the docking branch. The modifications are ours + and do not alter the terms below, which are reproduced from the copy these + packages were built from. + + This component covers the imgui and imgui_freetype native libraries, the managed + bindings generated from Dear ImGui's headers, and the C# translations of Dear + ImGui's backend and demo sources. + +The MIT License (MIT) + +Copyright (c) 2014-2025 Omar Cornut + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +============================================================================== +stb +============================================================================== + + Name stb_rect_pack, stb_textedit, stb_truetype + Version 1.01, 1.14, 1.26 respectively + Upstream https://github.com/nothings/stb + SPDX MIT OR Unlicense + + Vendored by Dear ImGui as imstb_rectpack.h, imstb_textedit.h and + imstb_truetype.h, and compiled into the Dear ImGui native libraries shipped + here. All three carry the same dual license, which offers a choice between + the MIT License and release into the public domain. It is reproduced once + below, from the copy these packages were built from. + +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ + + +============================================================================== +ImPlot +============================================================================== + + Name ImPlot + Version 0.17, upstream commit 3da8bd3 (26 commits after tag v0.16) + Upstream https://github.com/epezent/implot + SPDX MIT + + ImPlot is a plotting extension for Dear ImGui. Its version is the one ImPlot + reports for itself; the commit is given because upstream had not tagged 0.17 when + these packages were built. + + This component covers the implot native library, the managed bindings generated + from ImPlot's headers, and the C# translation of ImPlot's demo sources. + +MIT License + +Copyright (c) 2020 Evan Pezent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Brutal.ImGui/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt b/Brutal.ImGui/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt index b3cd102..3ac9b12 100644 --- a/Brutal.ImGui/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt +++ b/Brutal.ImGui/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt @@ -1,26 +1,31 @@ THIRD-PARTY LICENSE NOTICES The Brutal.ImGui packages -This file ships in all eight packages named below. They redistribute the third-party +This file ships in all eleven packages named below. They redistribute the third-party components listed here, each reproduced with the license that governs it. - One file serves all eight packages, so this table says which components apply to + One file serves all eleven packages, so this table says which components apply to the package you are holding: - RocketWerkz.Brutal.ImGui Dear ImGui, and the three stb libraries + Ahwoo.BRUTAL.ImGui Dear ImGui, and the three stb libraries compiled into it - RocketWerkz.Brutal.ImGui.Backends Dear ImGui's platform and renderer + Ahwoo.BRUTAL.ImGui.Backends Dear ImGui's platform and renderer backends, translated to C# - RocketWerkz.Brutal.ImGui.DemoWindow Dear ImGui's demo sources, translated + Ahwoo.BRUTAL.ImGui.DemoWindow Dear ImGui's demo sources, translated to C# - RocketWerkz.Brutal.ImGui.FreeType Dear ImGui's FreeType font adapter - RocketWerkz.Brutal.ImPlot ImPlot - RocketWerkz.Brutal.ImPlot.DemoWindow ImPlot's demo sources, translated to C# - RocketWerkz.Brutal.ImGui.Abstractions no third-party code - RocketWerkz.Brutal.ImGui.Extensions no third-party code + Ahwoo.BRUTAL.ImGui.FreeType Dear ImGui's FreeType font adapter + Ahwoo.BRUTAL.ImPlot ImPlot + Ahwoo.BRUTAL.ImPlot.DemoWindow ImPlot's demo sources, translated to C# + Ahwoo.BRUTAL.ImGui.Native Dear ImGui's native library, and the three + stb libraries compiled into it + Ahwoo.BRUTAL.ImGui.FreeType.Native Dear ImGui's FreeType font adapter, as a + native library + Ahwoo.BRUTAL.ImPlot.Native ImPlot's native library + Ahwoo.BRUTAL.ImGui.Abstractions no third-party code + Ahwoo.BRUTAL.ImGui.Extensions no third-party code - Where a package ships native libraries, it ships them for every runtime identifier - it supports (win-x64, linux-x64, osx-arm64): + The native libraries ship only in the three .Native packages, each for every + runtime identifier it supports (win-x64, linux-x64, osx-arm64): Dear ImGui 1.92.2 imgui.dll / libimgui.so / libimgui.dylib imgui_freetype.dll / libimgui_freetype.so / libimgui_freetype.dylib @@ -35,9 +40,9 @@ components listed here, each reproduced with the license that governs it. upstream headers, and the backend and demo assemblies are C# translations of upstream sources. - RocketWerkz.Brutal.ImGui.FreeType binds Dear ImGui's FreeType font adapter, which + Ahwoo.BRUTAL.ImGui.FreeType binds Dear ImGui's FreeType font adapter, which is Dear ImGui code and is covered by the Dear ImGui section below. FreeType itself - is in none of these eight packages; it is supplied by RocketWerkz.Brutal.FreeType, + is in none of these eleven packages; it is supplied by Ahwoo.BRUTAL.FreeType, whose own notices reproduce the FreeType License in full. diff --git a/Brutal.ImPlot/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt b/Brutal.ImPlot/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt new file mode 100644 index 0000000..3ac9b12 --- /dev/null +++ b/Brutal.ImPlot/LICENSES/BRUTAL-IMGUI-THIRD-PARTY-NOTICES.txt @@ -0,0 +1,180 @@ +THIRD-PARTY LICENSE NOTICES +The Brutal.ImGui packages + +This file ships in all eleven packages named below. They redistribute the third-party +components listed here, each reproduced with the license that governs it. + + One file serves all eleven packages, so this table says which components apply to + the package you are holding: + + Ahwoo.BRUTAL.ImGui Dear ImGui, and the three stb libraries + compiled into it + Ahwoo.BRUTAL.ImGui.Backends Dear ImGui's platform and renderer + backends, translated to C# + Ahwoo.BRUTAL.ImGui.DemoWindow Dear ImGui's demo sources, translated + to C# + Ahwoo.BRUTAL.ImGui.FreeType Dear ImGui's FreeType font adapter + Ahwoo.BRUTAL.ImPlot ImPlot + Ahwoo.BRUTAL.ImPlot.DemoWindow ImPlot's demo sources, translated to C# + Ahwoo.BRUTAL.ImGui.Native Dear ImGui's native library, and the three + stb libraries compiled into it + Ahwoo.BRUTAL.ImGui.FreeType.Native Dear ImGui's FreeType font adapter, as a + native library + Ahwoo.BRUTAL.ImPlot.Native ImPlot's native library + Ahwoo.BRUTAL.ImGui.Abstractions no third-party code + Ahwoo.BRUTAL.ImGui.Extensions no third-party code + + The native libraries ship only in the three .Native packages, each for every + runtime identifier it supports (win-x64, linux-x64, osx-arm64): + + Dear ImGui 1.92.2 imgui.dll / libimgui.so / libimgui.dylib + imgui_freetype.dll / libimgui_freetype.so / libimgui_freetype.dylib + ImPlot 0.17 implot.dll / libimplot.so / libimplot.dylib + + Dear ImGui vendors three of Sean Barrett's stb libraries, and all three are + compiled into the Dear ImGui binaries shipped here. They have their own section + below. + + The managed assemblies are in scope as well as the native libraries. Type names, + enumerant values and entry-point signatures are generated from the corresponding + upstream headers, and the backend and demo assemblies are C# translations of + upstream sources. + + Ahwoo.BRUTAL.ImGui.FreeType binds Dear ImGui's FreeType font adapter, which + is Dear ImGui code and is covered by the Dear ImGui section below. FreeType itself + is in none of these eleven packages; it is supplied by Ahwoo.BRUTAL.FreeType, + whose own notices reproduce the FreeType License in full. + + +============================================================================== +Dear ImGui +============================================================================== + + Name Dear ImGui + Version 1.92.2, docking branch + Upstream https://github.com/ocornut/imgui + SPDX MIT + + Built from a RocketWerkz fork of the docking branch. The modifications are ours + and do not alter the terms below, which are reproduced from the copy these + packages were built from. + + This component covers the imgui and imgui_freetype native libraries, the managed + bindings generated from Dear ImGui's headers, and the C# translations of Dear + ImGui's backend and demo sources. + +The MIT License (MIT) + +Copyright (c) 2014-2025 Omar Cornut + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +============================================================================== +stb +============================================================================== + + Name stb_rect_pack, stb_textedit, stb_truetype + Version 1.01, 1.14, 1.26 respectively + Upstream https://github.com/nothings/stb + SPDX MIT OR Unlicense + + Vendored by Dear ImGui as imstb_rectpack.h, imstb_textedit.h and + imstb_truetype.h, and compiled into the Dear ImGui native libraries shipped + here. All three carry the same dual license, which offers a choice between + the MIT License and release into the public domain. It is reproduced once + below, from the copy these packages were built from. + +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ + + +============================================================================== +ImPlot +============================================================================== + + Name ImPlot + Version 0.17, upstream commit 3da8bd3 (26 commits after tag v0.16) + Upstream https://github.com/epezent/implot + SPDX MIT + + ImPlot is a plotting extension for Dear ImGui. Its version is the one ImPlot + reports for itself; the commit is given because upstream had not tagged 0.17 when + these packages were built. + + This component covers the implot native library, the managed bindings generated + from ImPlot's headers, and the C# translation of ImPlot's demo sources. + +MIT License + +Copyright (c) 2020 Evan Pezent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Brutal.Localization/LICENSES/BRUTAL-LOCALIZATION-THIRD-PARTY-NOTICES.txt b/Brutal.Localization/LICENSES/BRUTAL-LOCALIZATION-THIRD-PARTY-NOTICES.txt index afd0b6c..8f4b2bc 100644 --- a/Brutal.Localization/LICENSES/BRUTAL-LOCALIZATION-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Localization/LICENSES/BRUTAL-LOCALIZATION-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Localization +Ahwoo.BRUTAL.Localization This package redistributes the third-party component listed below. It is reproduced with the license that governs it. diff --git a/Brutal.MeshOptimizer/LICENSES/BRUTAL-MESHOPTIMIZER-THIRD-PARTY-NOTICES.txt b/Brutal.MeshOptimizer/LICENSES/BRUTAL-MESHOPTIMIZER-THIRD-PARTY-NOTICES.txt index efdb35c..0421f7a 100644 --- a/Brutal.MeshOptimizer/LICENSES/BRUTAL-MESHOPTIMIZER-THIRD-PARTY-NOTICES.txt +++ b/Brutal.MeshOptimizer/LICENSES/BRUTAL-MESHOPTIMIZER-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.MeshOptimizer +Ahwoo.BRUTAL.MeshOptimizer Brutal.MeshOptimizer redistributes one third-party component, meshoptimizer, as native libraries on every runtime identifier it supports. It is reproduced below with the diff --git a/Brutal.NotCurses/LICENSES/BRUTAL-NOTCURSES-THIRD-PARTY-NOTICES.txt b/Brutal.NotCurses/LICENSES/BRUTAL-NOTCURSES-THIRD-PARTY-NOTICES.txt index cca5840..076b396 100644 --- a/Brutal.NotCurses/LICENSES/BRUTAL-NOTCURSES-THIRD-PARTY-NOTICES.txt +++ b/Brutal.NotCurses/LICENSES/BRUTAL-NOTCURSES-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.NotCurses +Ahwoo.BRUTAL.NotCurses This package ships three third-party components on macOS and Linux and four on Windows: notcurses, plus the parts of its dependency closure that are not part of the operating system. @@ -11,7 +11,7 @@ plus the parts of its dependency closure that are not part of the operating syst from the comments in those headers. zlib is not built or shipped by this package on any platform. It is supplied by the - RocketWerkz.Brutal.ZLib package, which this package depends on and whose own notices + Ahwoo.BRUTAL.ZLib package, which this package depends on and whose own notices file covers it. The terminfo database is read from the host and is not shipped. Upstream states a second license over one file that this package does not build. It diff --git a/Brutal.OpenAl/LICENSES/BRUTAL-OPENAL-THIRD-PARTY-NOTICES.txt b/Brutal.OpenAl/LICENSES/BRUTAL-OPENAL-THIRD-PARTY-NOTICES.txt index 995c46f..031ebd8 100644 --- a/Brutal.OpenAl/LICENSES/BRUTAL-OPENAL-THIRD-PARTY-NOTICES.txt +++ b/Brutal.OpenAl/LICENSES/BRUTAL-OPENAL-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.OpenAl +Ahwoo.BRUTAL.OpenAl This package redistributes the third-party components listed below, each reproduced with the license that governs it. diff --git a/Brutal.OpenGl/LICENSES/BRUTAL-OPENGL-THIRD-PARTY-NOTICES.txt b/Brutal.OpenGl/LICENSES/BRUTAL-OPENGL-THIRD-PARTY-NOTICES.txt index 3699980..a482b26 100644 --- a/Brutal.OpenGl/LICENSES/BRUTAL-OPENGL-THIRD-PARTY-NOTICES.txt +++ b/Brutal.OpenGl/LICENSES/BRUTAL-OPENGL-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.OpenGl +Ahwoo.BRUTAL.OpenGl This package ships one third-party native library, glad, on win-x64, linux-x64 and osx-arm64. It contains no OpenGL implementation - glad resolves OpenGL entry points at diff --git a/Brutal.RakNet/LICENSES/BRUTAL-RAKNET-THIRD-PARTY-NOTICES.txt b/Brutal.RakNet/LICENSES/BRUTAL-RAKNET-THIRD-PARTY-NOTICES.txt index f1f3c11..789a058 100644 --- a/Brutal.RakNet/LICENSES/BRUTAL-RAKNET-THIRD-PARTY-NOTICES.txt +++ b/Brutal.RakNet/LICENSES/BRUTAL-RAKNET-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.RakNet +Ahwoo.BRUTAL.RakNet This package redistributes third-party software. Where terms attach to that software, the license governing it is reproduced below in full. diff --git a/Brutal.Sdl.Image/LICENSES/BRUTAL-SDL-IMAGE-THIRD-PARTY-NOTICES.txt b/Brutal.Sdl.Image/LICENSES/BRUTAL-SDL-IMAGE-THIRD-PARTY-NOTICES.txt index f74b56d..de27820 100644 --- a/Brutal.Sdl.Image/LICENSES/BRUTAL-SDL-IMAGE-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Sdl.Image/LICENSES/BRUTAL-SDL-IMAGE-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Sdl.Image +Ahwoo.BRUTAL.Sdl.Image This package redistributes third-party software. The licenses governing that software are reproduced below in full. @@ -24,7 +24,7 @@ WHAT THIS PACKAGE CONTAINS A NOTE ON SCOPE - This package depends on RocketWerkz.Brutal.Sdl and links against SDL3 at runtime. + This package depends on Ahwoo.BRUTAL.Sdl and links against SDL3 at runtime. SDL3 is not contained in this package and is covered by that package's own notices. SDL_image can optionally be built against libpng, libjpeg, libtiff, libwebp, libavif, diff --git a/Brutal.Sdl.Mixer/LICENSES/BRUTAL-SDL-MIXER-THIRD-PARTY-NOTICES.txt b/Brutal.Sdl.Mixer/LICENSES/BRUTAL-SDL-MIXER-THIRD-PARTY-NOTICES.txt index 8023639..94b69f4 100644 --- a/Brutal.Sdl.Mixer/LICENSES/BRUTAL-SDL-MIXER-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Sdl.Mixer/LICENSES/BRUTAL-SDL-MIXER-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Sdl.Mixer +Ahwoo.BRUTAL.Sdl.Mixer This package redistributes third-party software. The licenses governing that software are reproduced below in full. @@ -20,7 +20,7 @@ WHAT THIS PACKAGE CONTAINS A NOTE ON SCOPE - This package depends on RocketWerkz.Brutal.Sdl and links against SDL3 at runtime. + This package depends on Ahwoo.BRUTAL.Sdl and links against SDL3 at runtime. SDL3 is not contained in this package and is covered by that package's own notices. SDL_mixer can optionally be built against libmpg123, libFLAC, libvorbis, libopus, diff --git a/Brutal.Sdl.Ttf/LICENSES/BRUTAL-SDL-TTF-THIRD-PARTY-NOTICES.txt b/Brutal.Sdl.Ttf/LICENSES/BRUTAL-SDL-TTF-THIRD-PARTY-NOTICES.txt index 8479d44..74fc495 100644 --- a/Brutal.Sdl.Ttf/LICENSES/BRUTAL-SDL-TTF-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Sdl.Ttf/LICENSES/BRUTAL-SDL-TTF-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Sdl.Ttf +Ahwoo.BRUTAL.Sdl.Ttf This package redistributes third-party software. The licenses governing that software are reproduced below in full. @@ -42,12 +42,12 @@ FREETYPE IS DUAL-LICENSED, AND WE DISTRIBUTE UNDER THE FREETYPE LICENSE This software is based in part of the work of the FreeType Team. The year is 2023 because that is the year of FreeType 2.13.2, the version contained - here. RocketWerkz.Brutal.FreeType contains a different version and its credit + here. Ahwoo.BRUTAL.FreeType contains a different version and its credit states a different year; both are correct, and they must not be made to agree. A NOTE ON SCOPE - This package depends on RocketWerkz.Brutal.Sdl and links against SDL3 at runtime. + This package depends on Ahwoo.BRUTAL.Sdl and links against SDL3 at runtime. SDL3 is not contained in this package and is covered by that package's own notices. SDL_ttf can optionally be built against PlutoSVG and PlutoVG for colour-emoji diff --git a/Brutal.Sdl/LICENSES/BRUTAL-SDL-THIRD-PARTY-NOTICES.txt b/Brutal.Sdl/LICENSES/BRUTAL-SDL-THIRD-PARTY-NOTICES.txt index dfe5065..86dec03 100644 --- a/Brutal.Sdl/LICENSES/BRUTAL-SDL-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Sdl/LICENSES/BRUTAL-SDL-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Sdl +Ahwoo.BRUTAL.Sdl This package redistributes third-party software. The licenses governing that software are reproduced below in full. diff --git a/Brutal.ShaderC/LICENSES/BRUTAL-SHADERC-THIRD-PARTY-NOTICES.txt b/Brutal.ShaderC/LICENSES/BRUTAL-SHADERC-THIRD-PARTY-NOTICES.txt index 4d7bf77..f6d8a05 100644 --- a/Brutal.ShaderC/LICENSES/BRUTAL-SHADERC-THIRD-PARTY-NOTICES.txt +++ b/Brutal.ShaderC/LICENSES/BRUTAL-SHADERC-THIRD-PARTY-NOTICES.txt @@ -2,7 +2,7 @@ BRUTAL SHADERC - THIRD-PARTY NOTICES ============================================================================== -RocketWerkz.Brutal.ShaderC redistributes third-party software inside the native +Ahwoo.BRUTAL.ShaderC redistributes third-party software inside the native libraries it ships under runtimes//native/: shaderc_shared win-x64, linux-x64, osx-arm64 diff --git a/Brutal.Slang/AssemblyInfo.cs b/Brutal.Slang/AssemblyInfo.cs new file mode 100644 index 0000000..c05c8ed --- /dev/null +++ b/Brutal.Slang/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Brutal.Slang.Test")] diff --git a/Brutal.Slang/BorrowedSlangInterfaceMarshaller.cs b/Brutal.Slang/BorrowedSlangInterfaceMarshaller.cs new file mode 100644 index 0000000..1b5e63d --- /dev/null +++ b/Brutal.Slang/BorrowedSlangInterfaceMarshaller.cs @@ -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 + where T : class +{ + public static T? ConvertToManaged(void* unmanaged) => Slang.WrapBorrowedComInstance((nint)unmanaged); + + public static void* ConvertToUnmanaged(T? managed) => ComInterfaceMarshaller.ConvertToUnmanaged(managed); +} diff --git a/Brutal.Slang/EntryPointLayoutExtensions.cs b/Brutal.Slang/EntryPointLayoutExtensions.cs new file mode 100644 index 0000000..15dadb4 --- /dev/null +++ b/Brutal.Slang/EntryPointLayoutExtensions.cs @@ -0,0 +1,20 @@ +namespace Brutal.SlangApi; + +/// +/// Hand-written helpers on entry-point reflection handles for flat-C getters that fill +/// output arrays, which the generated signatures expose as raw pointers. +/// +public static unsafe class EntryPointLayoutExtensions +{ + /// + /// Returns a compute entry point's thread-group size, its [numthreads], 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. + /// + 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]); + } +} diff --git a/Brutal.Slang/Generated/GlobalUsings.gen.cs b/Brutal.Slang/Generated/GlobalUsings.gen.cs index aae177d..2039f5d 100644 --- a/Brutal.Slang/Generated/GlobalUsings.gen.cs +++ b/Brutal.Slang/Generated/GlobalUsings.gen.cs @@ -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; diff --git a/Brutal.Slang/Generated/Interfaces.gen.cs b/Brutal.Slang/Generated/Interfaces.gen.cs index a05676c..24b982c 100644 --- a/Brutal.Slang/Generated/Interfaces.gen.cs +++ b/Brutal.Slang/Generated/Interfaces.gen.cs @@ -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))] 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))] + 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))] out ISlangBlob outUniqueIdentity + ); [PreserveSig] Result CalcCombinedPath( Brutal.SlangApi.PathType fromPathType, byte* fromPath, byte* path, - out ISlangBlob pathOut + [MarshalUsing(typeof(SlangInterfaceMarshaller))] 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))] 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 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))] + 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))] 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))] out ISlangBlob outPrelude + ); [PreserveSig] - Result CreateCompileRequest(out Brutal.SlangApi.ICompileRequest outCompileRequest); + Result CreateCompileRequest( + [MarshalUsing(typeof(SlangHandleMarshaller))] + out Brutal.SlangApi.ICompileRequest outCompileRequest + ); [PreserveSig] void AddBuiltins(byte* sourcePath, byte* sourceString); [PreserveSig] - void SetSharedLibraryLoader(ISlangSharedLibraryLoader loader); + void SetSharedLibraryLoader( + [MarshalUsing(typeof(SlangInterfaceMarshaller))] ISlangSharedLibraryLoader loader + ); [PreserveSig] + [return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller))] 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))] 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))] out ISlangUnknown outAuxAllocation ); [PreserveSig] - Result GetSessionDescDigest(in Brutal.SlangApi.SessionDesc sessionDesc, out ISlangBlob outBlob); + Result GetSessionDescDigest( + in Brutal.SlangApi.SessionDesc sessionDesc, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] 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))] out ISlangBlob outBlob ); }; @@ -282,118 +321,154 @@ namespace Brutal.SlangApi public unsafe partial interface ISession { [PreserveSig] + [return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller))] Brutal.SlangApi.IGlobalSession? GetGlobalSession(); [PreserveSig] - Brutal.SlangApi.IModule? LoadModule(byte* moduleName, out IBlob outDiagnostics); + [return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller))] + Brutal.SlangApi.IModule? LoadModule( + byte* moduleName, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics + ); [PreserveSig] + [return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller))] Brutal.SlangApi.IModule? LoadModuleFromSource( byte* moduleName, byte* path, - IBlob source, - out IBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] IBlob source, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics ); [PreserveSig] Result CreateCompositeComponentType( nint* componentTypes, Int componentTypeCount, - out Brutal.SlangApi.IComponentType outCompositeComponentType, - out ISlangBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.IComponentType outCompositeComponentType, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outDiagnostics ); [PreserveSig] + [return: MarshalUsing(typeof(SlangHandleMarshaller))] Brutal.SlangApi.TypeReflection SpecializeType( - Brutal.SlangApi.TypeReflection type, + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection type, in Brutal.SlangApi.SpecializationArg specializationArgs, Int specializationArgCount, - out ISlangBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outDiagnostics ); [PreserveSig] + [return: MarshalUsing(typeof(SlangHandleMarshaller))] Brutal.SlangApi.TypeLayoutReflection GetTypeLayout( - Brutal.SlangApi.TypeReflection type, + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection type, Int targetIndex, Brutal.SlangApi.LayoutRules rules, - out ISlangBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outDiagnostics ); [PreserveSig] + [return: MarshalUsing(typeof(SlangHandleMarshaller))] Brutal.SlangApi.TypeReflection GetContainerType( - Brutal.SlangApi.TypeReflection elementType, + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection elementType, Brutal.SlangApi.ContainerType containerType, - out ISlangBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outDiagnostics ); [PreserveSig] + [return: MarshalUsing(typeof(SlangHandleMarshaller))] Brutal.SlangApi.TypeReflection GetDynamicType(); [PreserveSig] - Result GetTypeRTTIMangledName(Brutal.SlangApi.TypeReflection type, out ISlangBlob outNameBlob); + Result GetTypeRTTIMangledName( + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection type, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outNameBlob + ); [PreserveSig] Result GetTypeConformanceWitnessMangledName( - Brutal.SlangApi.TypeReflection type, - Brutal.SlangApi.TypeReflection interfaceType, - out ISlangBlob outNameBlob + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection type, + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection interfaceType, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outNameBlob ); [PreserveSig] Result GetTypeConformanceWitnessSequentialID( - Brutal.SlangApi.TypeReflection type, - Brutal.SlangApi.TypeReflection interfaceType, + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection type, + [MarshalUsing(typeof(SlangHandleMarshaller))] + 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))] out CompileRequest outCompileRequest ); [PreserveSig] + Result CreateTypeConformanceComponentType( + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection type, + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection interfaceType, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.ITypeConformance outConformance, + Int conformanceIdOverride, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outDiagnostics + ); + + [PreserveSig] + [return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller))] Brutal.SlangApi.IModule? LoadModuleFromIRBlob( byte* moduleName, byte* path, - IBlob source, - out IBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] IBlob source, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics ); [PreserveSig] Int GetLoadedModuleCount(); [PreserveSig] + [return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller))] 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 binaryModuleBlob + ); [PreserveSig] + [return: MarshalUsing(typeof(BorrowedSlangInterfaceMarshaller))] Brutal.SlangApi.IModule? LoadModuleFromSourceString( byte* moduleName, byte* path, byte* @string, - out IBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics ); [PreserveSig] Result GetDynamicObjectRTTIBytes( - Brutal.SlangApi.TypeReflection type, - Brutal.SlangApi.TypeReflection interfaceType, - out uint outRTTIDataBuffer, + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection type, + [MarshalUsing(typeof(SlangHandleMarshaller))] + Brutal.SlangApi.TypeReflection interfaceType, + uint* outRTTIDataBuffer, uint bufferSizeInBytes ); [PreserveSig] Result LoadModuleInfoFromIRBlob( - IBlob source, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] 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 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? GetSession(); [PreserveSig] - ProgramLayout GetLayout(Int targetIndex, out IBlob outDiagnostics); + [return: MarshalUsing(typeof(SlangHandleMarshaller))] + ProgramLayout GetLayout( + Int targetIndex, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] 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))] out IBlob outCode, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics + ); [PreserveSig] - Result GetResultAsFileSystem(Int entryPointIndex, Int targetIndex, out ISlangMutableFileSystem outFileSystem); + Result GetResultAsFileSystem( + Int entryPointIndex, + Int targetIndex, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out ISlangMutableFileSystem outFileSystem + ); [PreserveSig] - void GetEntryPointHash(Int entryPointIndex, Int targetIndex, out IBlob outHash); + void GetEntryPointHash( + Int entryPointIndex, + Int targetIndex, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outHash + ); [PreserveSig] Result Specialize( in Brutal.SlangApi.SpecializationArg specializationArgs, Int specializationArgCount, - out Brutal.SlangApi.IComponentType outSpecializedComponentType, - out ISlangBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.IComponentType outSpecializedComponentType, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outDiagnostics ); [PreserveSig] - Result Link(out Brutal.SlangApi.IComponentType outLinkedComponentType, out ISlangBlob outDiagnostics); + Result Link( + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.IComponentType outLinkedComponentType, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outDiagnostics + ); [PreserveSig] Result GetEntryPointHostCallable( int entryPointIndex, int targetIndex, - out ISlangSharedLibrary outSharedLibrary, - out IBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out ISlangSharedLibrary outSharedLibrary, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics ); [PreserveSig] - Result RenameEntryPoint(byte* newName, out Brutal.SlangApi.IComponentType outEntryPoint); + Result RenameEntryPoint( + byte* newName, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.IComponentType outEntryPoint + ); [PreserveSig] Result LinkWithOptions( - out Brutal.SlangApi.IComponentType outLinkedComponentType, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.IComponentType outLinkedComponentType, uint compilerOptionEntryCount, in Brutal.SlangApi.CompilerOptionEntry compilerOptionEntries, - out ISlangBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outDiagnostics ); [PreserveSig] - Result GetTargetCode(Int targetIndex, out IBlob outCode, out IBlob outDiagnostics); + Result GetTargetCode( + Int targetIndex, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outCode, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics + ); [PreserveSig] - Result GetTargetMetadata(Int targetIndex, out Brutal.SlangApi.IMetadata outMetadata, out IBlob outDiagnostics); + Result GetTargetMetadata( + Int targetIndex, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.IMetadata outMetadata, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics + ); [PreserveSig] Result GetEntryPointMetadata( Int entryPointIndex, Int targetIndex, - out Brutal.SlangApi.IMetadata outMetadata, - out IBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.IMetadata outMetadata, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] 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))] + 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))] + out Brutal.SlangApi.IEntryPoint outEntryPoint + ); [PreserveSig] - Result Serialize(out ISlangBlob outSerializedBlob); + Result Serialize([MarshalUsing(typeof(SlangInterfaceMarshaller))] 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))] + out Brutal.SlangApi.IEntryPoint outEntryPoint, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out ISlangBlob outDiagnostics ); [PreserveSig] @@ -516,10 +641,11 @@ namespace Brutal.SlangApi byte* GetDependencyFilePath(Int32 index); [PreserveSig] + [return: MarshalUsing(typeof(SlangHandleMarshaller))] Brutal.SlangApi.DeclReflection GetModuleReflection(); [PreserveSig] - Result Disassemble(out IBlob outDisassembledBlob); + Result Disassemble([MarshalUsing(typeof(SlangInterfaceMarshaller))] 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))] out IBlob outblob); [PreserveSig] - Result GetMetadata(out Brutal.SlangApi.IMetadata outMetadata); + Result GetMetadata( + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + 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 GetFunctionReflection(); }; @@ -571,23 +701,26 @@ namespace Brutal.SlangApi [PreserveSig] Result GetTargetCompileResult( Int targetIndex, - out Brutal.SlangApi.ICompileResult outCompileResult, - out IBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.ICompileResult outCompileResult, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics ); [PreserveSig] Result GetEntryPointCompileResult( Int entryPointIndex, Int targetIndex, - out Brutal.SlangApi.ICompileResult outCompileResult, - out IBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out Brutal.SlangApi.ICompileResult outCompileResult, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outDiagnostics ); [PreserveSig] Result GetTargetHostCallable( int targetIndex, - out ISlangSharedLibrary outSharedLibrary, - out IBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] + out ISlangSharedLibrary outSharedLibrary, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] 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))] out ISlangBlob outDiagnostics + ); [PreserveSig] Result GetPrecompiledTargetCode( Brutal.SlangApi.CompileTarget target, - out IBlob outCode, - out IBlob outDiagnostics + [MarshalUsing(typeof(SlangInterfaceMarshaller))] out IBlob outCode, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] 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))] + out Brutal.SlangApi.IModule outModule, + [MarshalUsing(typeof(SlangInterfaceMarshaller))] 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 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))] out IBlob outBlob); [PreserveSig] - void* GetReturnValue(out ByteSize64 outValueSize); + void* GetReturnValue([MarshalUsing(typeof(SlangSizeMarshaller))] out ByteSize outValueSize); [PreserveSig] void SetExtInstHandlerUserData(void* userData); diff --git a/Brutal.Slang/Generated/InterfacesExt.gen.cs b/Brutal.Slang/Generated/InterfacesExt.gen.cs index 507551f..59a3da5 100644 --- a/Brutal.Slang/Generated/InterfacesExt.gen.cs +++ b/Brutal.Slang/Generated/InterfacesExt.gen.cs @@ -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); diff --git a/Brutal.Slang/Generated/Slang.gen.cs b/Brutal.Slang/Generated/Slang.gen.cs index 89c3a33..c727fa6 100644 --- a/Brutal.Slang/Generated/Slang.gen.cs +++ b/Brutal.Slang/Generated/Slang.gen.cs @@ -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(); diff --git a/Brutal.Slang/Generated/Structs.gen.cs b/Brutal.Slang/Generated/Structs.gen.cs index 574d021..1352702 100644 --- a/Brutal.Slang/Generated/Structs.gen.cs +++ b/Brutal.Slang/Generated/Structs.gen.cs @@ -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); } diff --git a/Brutal.Slang/ICompileRequestExtensions.cs b/Brutal.Slang/ICompileRequestExtensions.cs index b2b4441..ef25528 100644 --- a/Brutal.Slang/ICompileRequestExtensions.cs +++ b/Brutal.Slang/ICompileRequestExtensions.cs @@ -122,17 +122,11 @@ public static unsafe class ICompileRequestExtensions /// /// Returns the currently installed for /// , or null 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 . + /// getter lends the pointer without an AddRef; the returned proxy takes its own + /// reference, so release it with . /// - 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(self.GetWriter(channel)); /// /// Adds a translation-unit source whose contents are provided as an diff --git a/Brutal.Slang/ISessionExtensions.cs b/Brutal.Slang/ISessionExtensions.cs index 5f660b2..62bf70e 100644 --- a/Brutal.Slang/ISessionExtensions.cs +++ b/Brutal.Slang/ISessionExtensions.cs @@ -139,6 +139,24 @@ public static unsafe partial class ISessionExtensions return self.LoadModuleFromIRBlob(nameP, pathP, source, out outDiagnostics); } + /// + /// Writes the RTTI bytes Slang uses to identify 's conformance to + /// into , which must hold at + /// least 16 bytes. + /// + /// Thrown if slang reports a failing . + public static void GetDynamicObjectRTTIBytes( + this ISession self, + TypeReflection type, + TypeReflection interfaceType, + Span 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; diff --git a/Brutal.Slang/ISlangBlobExtensions.cs b/Brutal.Slang/ISlangBlobExtensions.cs index 362812d..f0bdf4a 100644 --- a/Brutal.Slang/ISlangBlobExtensions.cs +++ b/Brutal.Slang/ISlangBlobExtensions.cs @@ -9,9 +9,9 @@ public static unsafe partial class ISlangBlobExtensions { /// /// Returns the blob's contents as a . 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 . Copy if you need + /// the bytes to outlive it. /// public static ReadOnlySpan AsSpan(this ISlangBlob self) => - new(self.GetBufferPointer(), checked((int)self.GetBufferSize())); + new(self.GetBufferPointer(), checked((int)self.GetBufferSize().Value)); } diff --git a/Brutal.Slang/ScalarMarshallers.cs b/Brutal.Slang/ScalarMarshallers.cs new file mode 100644 index 0000000..ce2f628 --- /dev/null +++ b/Brutal.Slang/ScalarMarshallers.cs @@ -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 + where T : unmanaged +{ + public static nint ConvertToUnmanaged(T managed) => Unsafe.BitCast(managed); + + public static T ConvertToManaged(nint unmanaged) => Unsafe.BitCast(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(managed); + + public static Bool8 ConvertToManaged(byte unmanaged) => Unsafe.BitCast(unmanaged); +} diff --git a/Brutal.Slang/Slang.cs b/Brutal.Slang/Slang.cs index f220cc2..bd0f98d 100644 --- a/Brutal.Slang/Slang.cs +++ b/Brutal.Slang/Slang.cs @@ -6,25 +6,25 @@ namespace Brutal.SlangApi; /// The Slang class provides access to the slang library for compiling shaders. /// /// -/// Slang COM proxies (returned by , -/// , etc.) are released by the ComWrappers -/// finalizer when GC reclaims the managed proxy. There is no deterministic -/// Dispose. 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 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 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. /// public static partial class Slang { /// /// instance used to bridge raw COM pointers obtained from /// slang_* entry points (e.g. ) - /// into managed [GeneratedComInterface] proxies. The default - /// implementation discovers proxy classes + /// into managed [GeneratedComInterface] proxies. + /// keeps ' discovery of the proxy classes /// emitted by the source generator from the type's IID, so no per-interface /// registration is needed. /// - 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)["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((Result)0, raw)!; } /// @@ -151,9 +160,54 @@ public static partial class Slang internal static T? WrapComInstance(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(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(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; + } + } + + /// + /// 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. + /// + 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(); } /// @@ -163,6 +217,31 @@ public static partial class Slang /// count. Call on it when finished, or pass it to /// APIs that take ownership. /// - 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)comObject); + return System.Runtime.InteropServices.ComWrappers.TryGetComInstance(comObject, out var native) + ? native + : ComWrappers.GetOrCreateComInterfaceForObject(comObject, CreateComInterfaceFlags.None); + } + + /// + /// Gets an owned pointer to the requested native interface, including its correct + /// subobject address. Release the returned reference after the native call. + /// + public static unsafe nint GetComInstance(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.ConvertToUnmanaged(comObject); + } } diff --git a/Brutal.Slang/SlangComWrappers.cs b/Brutal.Slang/SlangComWrappers.cs new file mode 100644 index 0000000..e5dd05c --- /dev/null +++ b/Brutal.Slang/SlangComWrappers.cs @@ -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 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); + } +} diff --git a/Brutal.Slang/SlangInterfaceMarshaller.cs b/Brutal.Slang/SlangInterfaceMarshaller.cs new file mode 100644 index 0000000..15fec5c --- /dev/null +++ b/Brutal.Slang/SlangInterfaceMarshaller.cs @@ -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 + where T : class +{ + public static T? ConvertToManaged(void* unmanaged) => Slang.WrapBorrowedComInstance((nint)unmanaged); + + public static void* ConvertToUnmanaged(T? managed) => + managed is null ? null : (void*)Slang.GetComInstance(managed); + + public static void Free(void* unmanaged) + { + if (unmanaged != null) + Marshal.Release((nint)unmanaged); + } +} diff --git a/Brutal.Vulkan.Abstractions/LICENSES/BRUTAL-VULKAN-ABSTRACTIONS-THIRD-PARTY-NOTICES.txt b/Brutal.Vulkan.Abstractions/LICENSES/BRUTAL-VULKAN-ABSTRACTIONS-THIRD-PARTY-NOTICES.txt index 7f19500..c800d2b 100644 --- a/Brutal.Vulkan.Abstractions/LICENSES/BRUTAL-VULKAN-ABSTRACTIONS-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Vulkan.Abstractions/LICENSES/BRUTAL-VULKAN-ABSTRACTIONS-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Vulkan.Abstractions +Ahwoo.BRUTAL.Vulkan.Abstractions Brutal.Vulkan.Abstractions builds on the Brutal.Vulkan bindings, which are generated from the Khronos Vulkan API registry. This package contains no native library and no generated diff --git a/Brutal.Vulkan.Vma/LICENSES/BRUTAL-VULKAN-VMA-THIRD-PARTY-NOTICES.txt b/Brutal.Vulkan.Vma/LICENSES/BRUTAL-VULKAN-VMA-THIRD-PARTY-NOTICES.txt index 80198d6..dbdde53 100644 --- a/Brutal.Vulkan.Vma/LICENSES/BRUTAL-VULKAN-VMA-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Vulkan.Vma/LICENSES/BRUTAL-VULKAN-VMA-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.Vulkan.Vma +Ahwoo.BRUTAL.Vulkan.Vma Brutal.Vulkan.Vma redistributes one third-party component, the Vulkan Memory Allocator. It reaches this package by two routes: as native libraries, and as descriptive text taken from diff --git a/Brutal.Vulkan/Generated/Constants/VK.gen.cs b/Brutal.Vulkan/Generated/Constants/VK.gen.cs index 0667bcb..9cf8ee8 100644 --- a/Brutal.Vulkan/Generated/Constants/VK.gen.cs +++ b/Brutal.Vulkan/Generated/Constants/VK.gen.cs @@ -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"; + + /// + /// VK_API_VERSION_1_0 - Return API version number for Vulkan 1.0 + /// + /// + /// + /// VK_API_VERSION_1_0 returns the API version number for Vulkan 1.0.0. + /// + /// + /// // 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 + /// + /// + public const int API_VERSION_1_0 = unchecked( + (int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0))) + ); + + /// + /// VK_API_VERSION_1_1 - Return API version number for Vulkan 1.1 + /// + /// + /// + /// VK_API_VERSION_1_1 returns the API version number for Vulkan 1.1.0. + /// + /// + /// // 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 + /// + /// + public const int API_VERSION_1_1 = unchecked( + (int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(1)) << 12) | ((uint)(0))) + ); + + /// + /// VK_API_VERSION_1_2 - Return API version number for Vulkan 1.2 + /// + /// + /// + /// VK_API_VERSION_1_2 returns the API version number for Vulkan 1.2.0. + /// + /// + /// // 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 + /// + /// + public const int API_VERSION_1_2 = unchecked( + (int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(2)) << 12) | ((uint)(0))) + ); + + /// + /// VK_API_VERSION_1_3 - Return API version number for Vulkan 1.3 + /// + /// + /// + /// VK_API_VERSION_1_3 returns the API version number for Vulkan 1.3.0. + /// + /// + /// // 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 + /// + /// + public const int API_VERSION_1_3 = unchecked( + (int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(3)) << 12) | ((uint)(0))) + ); + + /// + /// VK_API_VERSION_1_4 - Return API version number for Vulkan 1.4 + /// + /// + /// + /// VK_API_VERSION_1_4 returns the API version number for Vulkan 1.4.0. + /// + /// + /// // 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 + /// + /// + public const int API_VERSION_1_4 = unchecked( + (int)((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(4)) << 12) | ((uint)(0))) + ); + + /// + /// VK_HEADER_VERSION - Vulkan header file version number + /// + /// + /// + /// VK_HEADER_VERSION is the version number of the `{core_header}` header. + /// This value is kept synchronized with the patch version of the released + /// Specification. + /// + /// + /// // Provided by VK_VERSION_1_0 + /// // Version of this file + /// #define VK_HEADER_VERSION 357 + /// + /// + public const int HEADER_VERSION = 357; + + /// + /// VK_HEADER_VERSION_COMPLETE - Vulkan header file complete version number + /// + /// + /// + /// VK_HEADER_VERSION_COMPLETE 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. + /// + /// + /// Applications should not use this value as their + /// VkApplicationInfo::apiVersion. + /// Instead applications should explicitly select a specific fixed major/minor + /// API version using, for example, one of the VK_API_VERSION_*_* values. + /// + /// + /// // 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) + /// + /// + 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))) + ); } } diff --git a/Brutal.Vulkan/Generated/Macros/Vulkan.gen.cs b/Brutal.Vulkan/Generated/Macros/Vulkan.gen.cs new file mode 100644 index 0000000..0474937 --- /dev/null +++ b/Brutal.Vulkan/Generated/Macros/Vulkan.gen.cs @@ -0,0 +1,157 @@ +namespace Brutal.VulkanApi +{ + public static partial class Vulkan + { + /// + /// VK_MAKE_VERSION - Construct an API version number + /// + /// + /// + /// VK_MAKE_VERSION constructs an API version number. + /// + /// + /// // Provided by VK_VERSION_1_0 + /// #define VK_MAKE_VERSION(major, minor, patch) \ + /// ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch))) + /// + /// + /// is the major version number. + /// is the minor version number. + /// is the patch version number. + public static int MakeVersion(int major, int minor, int patch) => + unchecked((int)((((uint)(major)) << 22) | (((uint)(minor)) << 12) | ((uint)(patch)))); + + /// + /// VK_VERSION_MAJOR - Extract API major version number + /// + /// + /// + /// VK_VERSION_MAJOR extracts the API major version number from a packed + /// version number: + /// + /// + /// // Provided by VK_VERSION_1_0 + /// #define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22U) + /// + /// + public static int VersionMajor(int version) => unchecked((int)((uint)(version) >> 22)); + + /// + /// VK_VERSION_MINOR - Extract API minor version number + /// + /// + /// + /// VK_VERSION_MINOR extracts the API minor version number from a packed + /// version number: + /// + /// + /// // Provided by VK_VERSION_1_0 + /// #define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU) + /// + /// + public static int VersionMinor(int version) => unchecked((int)(((uint)(version) >> 12) & 0x3FF)); + + /// + /// VK_VERSION_PATCH - Extract API patch version number + /// + /// + /// + /// VK_VERSION_PATCH extracts the API patch version number from a packed + /// version number: + /// + /// + /// // Provided by VK_VERSION_1_0 + /// #define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU) + /// + /// + public static int VersionPatch(int version) => unchecked((int)((uint)(version) & 0xFFF)); + + /// + /// VK_MAKE_API_VERSION - Construct an API version number + /// + /// + /// + /// VK_MAKE_API_VERSION constructs an API version number. + /// + /// + /// // Provided by VK_VERSION_1_0 + /// #define VK_MAKE_API_VERSION(variant, major, minor, patch) \ + /// ((((uint32_t)(variant)) << 29U) | (((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch))) + /// + /// + /// is the variant number. + /// is the major version number. + /// is the minor version number. + /// is the patch version number. + 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))) + ); + + /// + /// VK_API_VERSION_VARIANT - Extract API variant number + /// + /// + /// + /// VK_API_VERSION_VARIANT extracts the API variant number from a packed + /// version number: + /// + /// + /// // Provided by VK_VERSION_1_0 + /// #define VK_API_VERSION_VARIANT(version) ((uint32_t)(version) >> 29U) + /// + /// + public static int ApiVersionVariant(int version) => unchecked((int)((uint)(version) >> 29)); + + /// + /// VK_API_VERSION_MAJOR - Extract API major version number + /// + /// + /// + /// VK_API_VERSION_MAJOR extracts the API major version number from a + /// packed version number: + /// + /// + /// // Provided by VK_VERSION_1_0 + /// #define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22U) & 0x7FU) + /// + /// + public static int ApiVersionMajor(int version) => unchecked((int)(((uint)(version) >> 22) & 0x7F)); + + /// + /// VK_API_VERSION_MINOR - Extract API minor version number + /// + /// + /// + /// VK_API_VERSION_MINOR extracts the API minor version number from a + /// packed version number: + /// + /// + /// // Provided by VK_VERSION_1_0 + /// #define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU) + /// + /// + public static int ApiVersionMinor(int version) => unchecked((int)(((uint)(version) >> 12) & 0x3FF)); + + /// + /// VK_API_VERSION_PATCH - Extract API patch version number + /// + /// + /// + /// VK_API_VERSION_PATCH extracts the API patch version number from a + /// packed version number: + /// + /// + /// // Provided by VK_VERSION_1_0 + /// #define VK_API_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU) + /// + /// + public static int ApiVersionPatch(int version) => unchecked((int)((uint)(version) & 0xFFF)); + + /// + /// VK_MAKE_VIDEO_STD_VERSION + /// + public static int MakeVideoStdVersion(int major, int minor, int patch) => + unchecked((int)((((uint)(major)) << 22) | (((uint)(minor)) << 12) | ((uint)(patch)))); + } +} diff --git a/Brutal.Vulkan/ImportResolver.cs b/Brutal.Vulkan/ImportResolver.cs index 098163b..d7c1e3b 100644 --- a/Brutal.Vulkan/ImportResolver.cs +++ b/Brutal.Vulkan/ImportResolver.cs @@ -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)}"); + } } diff --git a/Brutal.Vulkan/LICENSES/BRUTAL-VULKAN-THIRD-PARTY-NOTICES.txt b/Brutal.Vulkan/LICENSES/BRUTAL-VULKAN-THIRD-PARTY-NOTICES.txt index 617d965..5ee3a0f 100644 --- a/Brutal.Vulkan/LICENSES/BRUTAL-VULKAN-THIRD-PARTY-NOTICES.txt +++ b/Brutal.Vulkan/LICENSES/BRUTAL-VULKAN-THIRD-PARTY-NOTICES.txt @@ -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. diff --git a/Brutal.Vulkan/Manual/Constants/VK.cs b/Brutal.Vulkan/Manual/Constants/VK.cs index a65fa7d..2ba9901 100644 --- a/Brutal.Vulkan/Manual/Constants/VK.cs +++ b/Brutal.Vulkan/Manual/Constants/VK.cs @@ -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; } diff --git a/Brutal.ZLib/LICENSES/BRUTAL-ZLIB-THIRD-PARTY-NOTICES.txt b/Brutal.ZLib/LICENSES/BRUTAL-ZLIB-THIRD-PARTY-NOTICES.txt index 01a53d2..0a69d5a 100644 --- a/Brutal.ZLib/LICENSES/BRUTAL-ZLIB-THIRD-PARTY-NOTICES.txt +++ b/Brutal.ZLib/LICENSES/BRUTAL-ZLIB-THIRD-PARTY-NOTICES.txt @@ -1,5 +1,5 @@ THIRD-PARTY LICENSE NOTICES -RocketWerkz.Brutal.ZLib +Ahwoo.BRUTAL.ZLib This package ships one third-party component, zlib, as native libraries and as its public C headers in source form. The license governing it is reproduced in full below.