Skip to content

Commit 846cec7

Browse files
committed
Update to Vulkan 1.4
1 parent 5b8b494 commit 846cec7

File tree

14 files changed

+29055
-11503
lines changed

14 files changed

+29055
-11503
lines changed
Lines changed: 105 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,105 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace Vulkan.Build.Codegen
6-
{
7-
public static class CodegenUtil
8-
{
9-
private static readonly Dictionary<string, int> s_typeSizes = new Dictionary<string, int>
10-
{
11-
{ "byte", 1 },
12-
{ "uint", 4 },
13-
{ "ulong", 4 },
14-
{ "int", 4 },
15-
{ "float", 4 },
16-
};
17-
18-
private static readonly HashSet<string> s_keywords = new HashSet<string>
19-
{
20-
"object",
21-
"event",
22-
};
23-
24-
public static int GetTypeSize(TypeSpec type)
25-
{
26-
if (type.PointerIndirection != 0 || !s_typeSizes.TryGetValue(type.Name, out int size))
27-
{
28-
throw new InvalidOperationException();
29-
}
30-
31-
return size;
32-
}
33-
34-
public static string NormalizeFieldName(string name)
35-
{
36-
if (s_keywords.Contains(name))
37-
{
38-
return "@" + name;
39-
}
40-
41-
return name;
42-
}
43-
public static void SpaceSeparatedList<T>(CsCodeWriter cw, IList<T> list, Action<T> action)
44-
{
45-
for (int i = 0; i < list.Count; i++)
46-
{
47-
var item = list[i];
48-
action(item);
49-
if (i != list.Count - 1)
50-
{
51-
cw.WriteLine();
52-
}
53-
}
54-
}
55-
56-
private static readonly char[] s_underscoreSeparator = { '_' };
57-
58-
private static readonly HashSet<string> s_preserveCaps = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
59-
{
60-
"khr",
61-
"khx",
62-
"ext",
63-
"nv",
64-
"nvx",
65-
"amd",
66-
};
67-
68-
69-
public static string GetPrettyName(string value, string prefix, HashSet<string> ignoredParts = null)
70-
{
71-
if (value.IndexOf(prefix) != 0)
72-
{
73-
return value;
74-
}
75-
76-
string[] parts = value.Substring(prefix.Length, value.Length - prefix.Length)
77-
.Split(s_underscoreSeparator, StringSplitOptions.RemoveEmptyEntries);
78-
StringBuilder sb = new StringBuilder();
79-
foreach (string part in parts)
80-
{
81-
if (ignoredParts != null && ignoredParts.Contains(part))
82-
{
83-
continue;
84-
}
85-
86-
if (s_preserveCaps.Contains(part))
87-
{
88-
sb.Append(part);
89-
}
90-
else
91-
{
92-
sb.Append(char.ToUpper(part[0]));
93-
for (int i = 1; i < part.Length; i++)
94-
{
95-
sb.Append(char.ToLower(part[i]));
96-
}
97-
}
98-
}
99-
100-
string prettyName = sb.ToString();
101-
return (char.IsNumber(prettyName[0])) ? "_" + prettyName : prettyName;
102-
}
103-
}
104-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Vulkan.Build.Codegen
6+
{
7+
public static class CodegenUtil
8+
{
9+
private static readonly Dictionary<string, int> s_typeSizes = new Dictionary<string, int>
10+
{
11+
{ "byte", 1 },
12+
{ "uint", 4 },
13+
{ "ulong", 4 },
14+
{ "int", 4 },
15+
{ "float", 4 },
16+
};
17+
18+
private static readonly HashSet<string> s_keywords = new HashSet<string>
19+
{
20+
"object",
21+
"event",
22+
"params"
23+
};
24+
25+
public static int GetTypeSize(TypeSpec type)
26+
{
27+
if (type.PointerIndirection != 0 || !s_typeSizes.TryGetValue(type.Name, out int size))
28+
{
29+
throw new InvalidOperationException();
30+
}
31+
32+
return size;
33+
}
34+
35+
public static string NormalizeFieldName(string name)
36+
{
37+
if (s_keywords.Contains(name))
38+
{
39+
return "@" + name;
40+
}
41+
42+
return name;
43+
}
44+
public static void SpaceSeparatedList<T>(CsCodeWriter cw, IList<T> list, Action<T> action)
45+
{
46+
for (int i = 0; i < list.Count; i++)
47+
{
48+
var item = list[i];
49+
action(item);
50+
if (i != list.Count - 1)
51+
{
52+
cw.WriteLine();
53+
}
54+
}
55+
}
56+
57+
private static readonly char[] s_underscoreSeparator = { '_' };
58+
59+
private static readonly HashSet<string> s_preserveCaps = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
60+
{
61+
"khr",
62+
"khx",
63+
"ext",
64+
"nv",
65+
"nvx",
66+
"amd",
67+
};
68+
69+
70+
public static string GetPrettyName(string value, string prefix, HashSet<string> ignoredParts = null)
71+
{
72+
if (value.IndexOf(prefix) != 0)
73+
{
74+
return value;
75+
}
76+
77+
string[] parts = value.Substring(prefix.Length, value.Length - prefix.Length)
78+
.Split(s_underscoreSeparator, StringSplitOptions.RemoveEmptyEntries);
79+
StringBuilder sb = new StringBuilder();
80+
foreach (string part in parts)
81+
{
82+
if (ignoredParts != null && ignoredParts.Contains(part))
83+
{
84+
continue;
85+
}
86+
87+
if (s_preserveCaps.Contains(part))
88+
{
89+
sb.Append(part);
90+
}
91+
else
92+
{
93+
sb.Append(char.ToUpper(part[0]));
94+
for (int i = 1; i < part.Length; i++)
95+
{
96+
sb.Append(char.ToLower(part[i]));
97+
}
98+
}
99+
}
100+
101+
string prettyName = sb.ToString();
102+
return (char.IsNumber(prettyName[0])) ? "_" + prettyName : prettyName;
103+
}
104+
}
105+
}

Vulkan.Build/Vulkan.Build.Codegen/TypeNameMappings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class TypeNameMappings
1212
{ "uint16_t", "ushort" },
1313
{ "uint32_t", "uint" },
1414
{ "uint64_t", "ulong" },
15+
{ "int16_t", "short" },
1516
{ "int32_t", "int" },
1617
{ "int64_t", "long" },
1718
{ "int64_t*", "long*" },
@@ -22,6 +23,8 @@ public class TypeNameMappings
2223
{ "ANativeWindow", "Android.ANativeWindow" },
2324
{ "AHardwareBuffer", "Android.AHardwareBuffer" },
2425

26+
{ "OHNativeWindow", "OpenHarmony.OHNativeWindow"},
27+
2528
{ "MirConnection", "Mir.MirConnection" },
2629
{ "MirSurface", "Mir.MirSurface" },
2730

Vulkan/ExternalTypes.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public struct ANativeWindow { }
5555
public struct AHardwareBuffer { }
5656
}
5757

58+
// Open Harmony
59+
namespace OpenHarmony
60+
{
61+
public struct OHNativeWindow { }
62+
}
63+
5864
// Linux
5965
namespace Mir
6066
{

Vulkan/Generated/Commands.gen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9909,7 +9909,7 @@ public static unsafe VkResult vkInvalidateMappedMemoryRanges(VkDevice device, ui
99099909

99109910
///<remarks>Success codes:VK_SUCCESS. Error codes:VK_ERROR_OUT_OF_HOST_MEMORY, VK_ERROR_OUT_OF_DEVICE_MEMORY, VK_ERROR_MEMORY_MAP_FAILED</remarks>
99119911
[Generator.CalliRewrite]
9912-
public static unsafe VkResult vkMapMemory(VkDevice device, VkDeviceMemory memory, ulong offset, ulong size, uint flags, void** ppData)
9912+
public static unsafe VkResult vkMapMemory(VkDevice device, VkDeviceMemory memory, ulong offset, ulong size, VkMemoryMapFlags flags, void** ppData)
99139913
{
99149914
throw VulkanNative.CreateUnpatchedException();
99159915
}

0 commit comments

Comments
 (0)