Skip to content

Commit 51a07f2

Browse files
authored
Fix struct layout issues in DirectX and OpenXR bindings (#522)
* Fix DirectX (and some OpenXR) bindings & regenerate * Revert OpenXR regen * Fix #523 and review comments * Fix missing OpenXR mappings
1 parent 54db865 commit 51a07f2

File tree

89 files changed

+3678
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3678
-161
lines changed

build/cache/d3d12.json.gz

0 Bytes
Binary file not shown.

build/cache/dxgi.json.gz

0 Bytes
Binary file not shown.

build/cache/openxr.json.gz

6.97 KB
Binary file not shown.

build/csharp_typemap.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"uint32_t": "uint",
8484
"uint64_t": "ulong",
8585
"size_t": "nuint",
86+
"wchar_t": "char",
8687
"ANativeWindow": "nint",
8788
"MirConnection": "nint",
8889
"MirSurface": "nint",
@@ -132,7 +133,7 @@
132133
"wl_resource": "nint",
133134
"wl_buffer": "nint",
134135
"jobject": "nint",
135-
"timespec": "ValueTuple<nint,nint>",
136+
"timespec": "Timespec",
136137
"LARGE_INTEGER": "long",
137138
"xcb_glx_fbconfig_t": "nint",
138139
"xcb_glx_drawable_t": "nint",
@@ -143,7 +144,7 @@
143144
"HMONITOR__*": "nint",
144145
"HDC__**": "nint*",
145146
"HMONITOR__**": "nint*",
146-
"_LUID": "ValueTuple<ulong, long>",
147+
"_LUID": "Luid",
147148
"_LARGE_INTEGER": "long",
148149
"IUnknown": "Silk.NET.Core.Native.IUnknown",
149150
"tagRECT": "Silk.NET.Maths.Rectangle<int>",

generator.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,10 @@
611611
"iOS": "__Internal",
612612
"className": "OpenXRLibraryNameContainer"
613613
},
614+
"exclude": [
615+
"XrUuidMSFT",
616+
"XrSceneSphereBoundMSFT"
617+
],
614618
"typeMaps": [
615619
{
616620
"char": "byte",
@@ -644,7 +648,13 @@
644648
"EGLContext": "nint",
645649
"GLXFBConfig": "nint",
646650
"VkFormat": "uint",
647-
"EGLenum": "uint"
651+
"EGLenum": "uint",
652+
"XrUuidMSFT": "Guid",
653+
"XrSceneSphereBoundMSFT": "Silk.NET.Maths.Sphere<float>",
654+
"VkSamplerMipmapMode": "uint",
655+
"VkComponentSwizzle": "uint",
656+
"VkSamplerAddressMode": "uint",
657+
"VkFilter": "uint"
648658
},
649659
{
650660
"$include.commonTypeMap": "build/csharp_typemap.json"

src/Core/Silk.NET.BuildTools/Converters/Khronos/ParameterDefinition.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Xml.Linq;
1+
using System.Xml;
2+
using System.Xml.Linq;
23

34
namespace Silk.NET.BuildTools.Converters.Khronos
45
{
@@ -106,11 +107,26 @@ public static ParameterDefinition CreateFromXml(XElement xe)
106107
{
107108
var val = xe.Value;
108109
var idx = val.LastIndexOf('[') + 1;
109-
if (idx != -1 && int.TryParse(val.Substring(idx, val.Length - idx - 1), out count))
110+
if (idx != -1)
110111
{
111112
// array parameters are pointers in disguise
112113
pointerLevel++;
113114
}
115+
116+
var countVal = val.Substring(idx, val.Length - idx - 1);
117+
if (!int.TryParse(countVal, out count))
118+
{
119+
try
120+
{
121+
countVal = XElement.Parse(countVal).Value;
122+
}
123+
catch (XmlException)
124+
{
125+
// do nothing
126+
}
127+
128+
symbolic = countVal;
129+
}
114130
}
115131

116132
var type = new TypeSpec(typeName, pointerLevel);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Silk.NET.Core.Native
5+
{
6+
public struct Luid
7+
{
8+
public uint Low;
9+
public int High;
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Silk.NET.Core.Native
5+
{
6+
public struct Timespec
7+
{
8+
public nint Seconds;
9+
public nint Nanoseconds;
10+
}
11+
}

src/Microsoft/Silk.NET.DXGI/Structs/AdapterDesc.gen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public AdapterDesc
2828
nuint? dedicatedVideoMemory = null,
2929
nuint? dedicatedSystemMemory = null,
3030
nuint? sharedSystemMemory = null,
31-
ValueTuple<ulong,long>? adapterLuid = null
31+
Luid? adapterLuid = null
3232
) : this()
3333
{
3434
if (vendorId is not null)
@@ -115,6 +115,6 @@ public AdapterDesc
115115
[NativeName("Type", "LUID")]
116116
[NativeName("Type.Name", "LUID")]
117117
[NativeName("Name", "AdapterLuid")]
118-
public ValueTuple<ulong,long> AdapterLuid;
118+
public Luid AdapterLuid;
119119
}
120120
}

src/Microsoft/Silk.NET.DXGI/Structs/AdapterDesc1.gen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public AdapterDesc1
2828
nuint? dedicatedVideoMemory = null,
2929
nuint? dedicatedSystemMemory = null,
3030
nuint? sharedSystemMemory = null,
31-
ValueTuple<ulong,long>? adapterLuid = null,
31+
Luid? adapterLuid = null,
3232
uint? flags = null
3333
) : this()
3434
{
@@ -121,7 +121,7 @@ public AdapterDesc1
121121
[NativeName("Type", "LUID")]
122122
[NativeName("Type.Name", "LUID")]
123123
[NativeName("Name", "AdapterLuid")]
124-
public ValueTuple<ulong,long> AdapterLuid;
124+
public Luid AdapterLuid;
125125

126126
[NativeName("Type", "UINT")]
127127
[NativeName("Type.Name", "UINT")]

0 commit comments

Comments
 (0)