Skip to content

Commit

Permalink
This is the June 2021 Update (v2.5.0) with production-ready OpenXR (#505
Browse files Browse the repository at this point in the history
)

* Add helper for making XrGraphicsBindingOpenGL* instances, start XR demo

* Fix OpenXR flags being 32-bit not 64-bit, "almost" working OpenXR demo

* Pushing latest demo - crosseyed is gone, replaced with weird fov thing

* Add maths helpers, is this progress I don't even know anymore

* Commit before rewrite

* Scrap the demo

* Stop us forgetting to ship bindings!

* Add missing bindings to SLN and missing typemaps, update changelog

* Update src/Core/Silk.NET.Core/Native/SilkMarshal.cs

Co-authored-by: Kai Jellinghaus <[email protected]>

* Bindings updates, fix release notes

* Update Silk.NET.sln

Co-authored-by: Kai Jellinghaus <[email protected]>
  • Loading branch information
Perksey and HurricanKai authored Jun 8, 2021
1 parent c26e41b commit 765c172
Show file tree
Hide file tree
Showing 79 changed files with 2,565 additions and 178 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
# skip Clean, Restore, and Compile as this will build the affect the whole solution.
# dotnet test will compile the necessary projects for testing only.
run: nuke Test --skip Clean Restore Compile
- name: Validation Checks
run: nuke ValidateSolution
- name: Pack
# TODO build native mixins such as BuildLibSilkDroid
run: nuke Pack --configuration Release --msbuild-properties VersionSuffix=build${{ github.run_number }}.0 ContinuousIntegrationBuild=true --feature-sets Android iOS
Expand Down
377 changes: 376 additions & 1 deletion Silk.NET.sln

Large diffs are not rendered by default.

Binary file modified build/cache/cl.json.gz
Binary file not shown.
Binary file modified build/cache/gles2.json.gz
Binary file not shown.
Binary file modified build/cache/openxr.json.gz
Binary file not shown.
Binary file modified build/cache/vulkan.json.gz
Binary file not shown.
52 changes: 52 additions & 0 deletions build/nuke/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,58 @@ Dictionary<string, object> ProcessedMsbuildProperties

AbsolutePath SourceDirectory => RootDirectory / "src";

// ReSharper disable once RedundantEmptyObjectOrCollectionInitializer
readonly HashSet<string> AllowedExclusions = new()
{

};

Target ValidateSolution => _ => _
.Executes
(
() =>
{
var files = RootDirectory.GlobFiles("**/*.csproj").ToArray();
Logger.Info($"Found {files.Length} csproj files in \"{RootDirectory}\"");
var missedOut = new List<string>();
foreach (var file in files)
{
var found = false;
foreach (var project in Solution.GetProjects("*"))
{
if (new FileInfo(file).FullName.Equals(new FileInfo(project.Path).FullName))
{
found = true;
break;
}
}

if (!found && !AllowedExclusions.Contains(Path.GetFileNameWithoutExtension(file)))
{
Logger.Error
(
"A project has not been included in the solution and will not be shipped! " +
$"\"{file}\" if this is acceptable please add the project name (excluding the path and " +
"extension) to the AllowedExclusions array in the NUKE Build.cs file."
);

missedOut.Add(file);
}
}

if (missedOut.Any())
{
Logger.Warn("Commands to add these for your convenience:");
foreach (var file in missedOut)
{
Logger.Warn($"dotnet sln \"{Path.GetFileName(Solution.FileName)}\" add \"{file}\"");
}

ControlFlow.Fail("Action required.");
}
}
);

Target Clean => _ => _
.Before(Restore)
.Executes(() =>
Expand Down
33 changes: 16 additions & 17 deletions build/props/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@
<LangVersion>preview</LangVersion>
<Authors>.NET Foundation and Contributors</Authors>
<PackageReleaseNotes>
Silk.NET May 2021 Update
Silk.NET June 2021 Update

- Add As methods to all Maths types &amp; other miscellaneous API additions
- Add support for provisional Vulkan Video encoding &amp; decoding extensions
- Update to latest OpenGL specification
- Update to latest OpenCL specification
- Update to Vulkan 1.2.177
- Update to OpenXR 1.0.15
- Fix ImGui robustness
- Fix disposal and reset robustness
- Fix SDL input backend not respecting deadzones
- Fix GLFW input backend not respecting start-up state
- Fix Vulkan device function pointer loader bugs
- Fix BSTR GlobalMemory issues
- Fix Vulkan codegen issues
- Fix bitfield codegen for Vulkan &amp; clang-generated bindings
- Miscellaneous windowing &amp; input bugfixes
- OpenXR bindings are now production-ready &amp; no longer experimental!
- Add (optional) native binaries for OpenAL Soft
- Add support for reversed-z projection matrices in Silk.NET.Maths
- Add bindings for a number of missing Vulkan and OpenCL extensions
- Add OpenGL-OpenXR interoperability helper APIs
- Add more helper APIs in Silk.NET.Core and Silk.NET.Maths
- Update to latest OpenGL and OpenGLES specifications
- Update to OpenXR 1.0.16
- Update to Vulkan 1.2.180
- Fix SDL OpenGL context issues when not using OpenGL
- Fix GLFW native window issues on 32-bit Windows
- Fix OpenXR loading issues
- Fix incorrect bindings in OpenXR
- Miscellaneous windowing &amp; input bugfixes &amp; improvements
</PackageReleaseNotes>
<PackageTags Condition="'$(PackageTags)' == ''">OpenCL;OpenGL;OpenAL;OpenGLES;GLES;Vulkan;Assimp;DirectX;GLFW;SDL;Windowing;Input;Gamepad;Joystick;Keyboard;Mouse;SilkTouch;Source;Generator;C#;F#;.NET;DotNet;Mono;Vector;Math;Maths;Numerics;Game;Graphics;Compute;Audio;Sound;Engine;Silk;Silk.NET;Slim.NET;ElgarTK;GPU;Sharp;Science;Scientific;Visualization;Visual;Audiovisual;Windows;macOS;Linux;Android;Bindings;OSX;Wrapper;Native</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageOutputPath>$(MSBuildThisFileDirectory)/../output_packages</PackageOutputPath>
<RepositoryUrl>https://github.com/dotnet/Silk.NET</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<VersionPrefix>2.4.0</VersionPrefix>
<VersionPrefix>2.5.0</VersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix>
<Description Condition="'$(Description)' == ''">
Silk.NET is a high-speed, advanced library, providing bindings to popular low-level APIs such as OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, and DirectX.
Expand Down
7 changes: 5 additions & 2 deletions generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@
"cl_version": "cl_uint",
"cl_mem_properties": "CLenum",
"cl_mipmap_filter_mode_img": "CLenum",
"cl_command_queue_capabilities_intel": "CLenum"
"cl_command_queue_capabilities_intel": "CLenum",
"cl_icd_dispatch": "void",
"cl_layer_info": "uint"
},
{
"$include.commonTypeMap": "build/csharp_typemap.json"
Expand Down Expand Up @@ -641,7 +643,8 @@
"EGLConfig": "nint",
"EGLContext": "nint",
"GLXFBConfig": "nint",
"VkFormat": "uint"
"VkFormat": "uint",
"EGLenum": "uint"
},
{
"$include.commonTypeMap": "build/csharp_typemap.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ public class TypedefDefinition
{
public string Name { get; }
public string Requires { get; }
public string BitValues { get; }
public string Type { get; }

public TypedefDefinition(string name, string requires, string type)
public TypedefDefinition(string name, string requires, string type, string bitValues = null)
{
Name = name;
Requires = requires;
Type = type;
BitValues = bitValues;
}

public static TypedefDefinition CreateFromXml(XElement xe)
{
var name = xe.GetNameElement();
var requires = xe.Attribute("requires")?.Value;
var type = xe.GetTypeElement();
return new TypedefDefinition(name, requires, type);
var bitValues = xe.Attribute("bitvalues")?.Value;
return new(name, requires, type, bitValues);
}

public override string ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ public VulkanSpecification(
Commands = commands;
Constants = constants;
Typedefs = typedefs;
Enums = enums;
Structures = structures;
Unions = unions;
Handles = handles;
BaseTypes = baseTypes;
Extensions = extensions;
Features = features;
AddExtensionEnums(Enums, Extensions);
AddExtensionEnums(Enums, Features);

var wipEnums = enums.ToList();
AddExtensionEnums(wipEnums, Extensions);
AddExtensionEnums(wipEnums, Features);
MixinEnumTypeFixups(wipEnums, Typedefs);

Enums = enums.ToArray();
}

public static VulkanSpecification LoadFromXmlStream(Stream specFileStream)
Expand Down Expand Up @@ -114,7 +118,7 @@ public static VulkanSpecification LoadFromXmlStream(Stream specFileStream)
features);
}

private void AddExtensionEnums(EnumDefinition[] enums, ExtensionDefinition[] extensions)
private void AddExtensionEnums(List<EnumDefinition> enums, ExtensionDefinition[] extensions)
{
foreach (var exDef in extensions)
{
Expand All @@ -132,7 +136,7 @@ private void AddExtensionEnums(EnumDefinition[] enums, ExtensionDefinition[] ext
}
}

private void AddExtensionEnums(EnumDefinition[] enums, FeatureDefinition[] extensions)
private void AddExtensionEnums(List<EnumDefinition> enums, FeatureDefinition[] extensions)
{
foreach (var exDef in extensions)
{
Expand All @@ -144,10 +148,42 @@ private void AddExtensionEnums(EnumDefinition[] enums, FeatureDefinition[] exten
}
}
}

private void MixinEnumTypeFixups(List<EnumDefinition> enums, TypedefDefinition[] typedefs)
{
foreach (var typedefDefinition in typedefs)
{
if (typedefDefinition.BitValues is not null)
{
foreach (var enumDefinition in enums)
{
// if the bit width is default and we have a typedef for this enum
if ((enumDefinition.Name == typedefDefinition.Name ||
enumDefinition.Name == typedefDefinition.BitValues) &&
enumDefinition.BitWidth == 32)
{
enumDefinition.BitWidth = typedefDefinition.Type switch
{
"XrFlags64" => 64,
_ => 32
};
}
}
}
}
}

private EnumDefinition GetEnumDef(EnumDefinition[] enums, string name)
private EnumDefinition GetEnumDef(List<EnumDefinition> enums, string name)
{
return enums.Single(ed => ed.Name == name);
var ret = enums.SingleOrDefault(ed => ed.Name == name);
if (ret == default)
{
// bandage around the fact that khronos always slip up on their xml specs
ret = EnumDefinition.CreateFromXml(XElement.Parse($"<enums name=\"{name}\" type=\"bitmask\" />"));
enums.Add(ret);
}

return ret;
}
}
}
78 changes: 78 additions & 0 deletions src/Core/Silk.NET.Core/Miscellaneous/Version64.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

namespace Silk.NET.Core
{
/// <summary>
/// A 64-bit version structure.
/// </summary>
public readonly struct Version64
{
/// <summary>
/// The underlying OpenXR-compatible 64-bit version integer.
/// </summary>
public ulong Value { get; }

/// <summary>
/// Creates a OpenXR version structure from the given major, minor, and patch values.
/// </summary>
/// <param name="major">The major value.</param>
/// <param name="minor">The minor value.</param>
/// <param name="patch">The patch value.</param>
public Version64(uint major, uint minor, uint patch)
=> Value = ((major & 0xffffUL) << 48) | ((minor & 0xffffUL) << 32) | (patch & 0xffffffffUL);

/// <summary>
/// Creates a OpenXR version structure from the given OpenXR-compatible value.
/// </summary>
/// <param name="value">The value.</param>
private Version64(ulong value) => Value = value;

/// <summary>
/// Gets the major component of this version structure.
/// </summary>
public uint Major => (uint) ((Value >> 48) & 0xffffUL);

/// <summary>
/// Gets the minor component of this version structure.
/// </summary>
public uint Minor => (uint) ((Value >> 32) & 0xffffUL);

/// <summary>
/// Gets the patch component of this version structure.
/// </summary>
public uint Patch => (uint) (Value & 0xffffffffUL);

/// <summary>
/// Creates a 64-bit version structure from the given 64-bit unsigned integer.
/// </summary>
/// <param name="val">The uint value.</param>
/// <returns>The 64-bit version structure.</returns>
public static explicit operator Version64(ulong val) => new(val);

/// <summary>
/// Creates a 64-bit version structure from the given managed version class.
/// </summary>
/// <param name="version">The version instance.</param>
/// <returns>The 64-bit version structure.</returns>
public static implicit operator Version64
(Version version) => new((uint) version.Major, (uint) version.Minor, (uint) version.Build);

/// <summary>
/// Gets the 64-bit unsigned integer representation for this 64-bit version structure.
/// </summary>
/// <param name="version">The 64-bit version structure.</param>
/// <returns>The 64-bit unsigned integer.</returns>
public static implicit operator ulong(Version64 version) => version.Value;

/// <summary>
/// Converts this 64-bit version structure to a managed version class.
/// </summary>
/// <param name="version">The 64-bit version structure.</param>
/// <returns>The managed representation.</returns>
public static implicit operator Version
(Version64 version) => new((int) version.Major, (int) version.Minor, (int) version.Patch);
}
}
Loading

0 comments on commit 765c172

Please sign in to comment.